Leon4gr45 commited on
Commit
e62e139
·
verified ·
1 Parent(s): 90ee82a

Upload folder using huggingface_hub (part 2)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/.bin/acorn +4 -0
  2. node_modules/.bin/baseline-browser-mapping +2 -0
  3. node_modules/.bin/browserslist +156 -0
  4. node_modules/.bin/crc32 +105 -0
  5. node_modules/.bin/eslint +211 -0
  6. node_modules/.bin/eslint-config-prettier +240 -0
  7. node_modules/.bin/fxparser +97 -0
  8. node_modules/.bin/jiti +16 -0
  9. node_modules/.bin/js-yaml +117 -0
  10. node_modules/.bin/jsesc +148 -0
  11. node_modules/.bin/json5 +152 -0
  12. node_modules/.bin/mime +46 -0
  13. node_modules/.bin/msw +35 -0
  14. node_modules/.bin/nanoid +55 -0
  15. node_modules/.bin/node-which +52 -0
  16. node_modules/.bin/nodemon +16 -0
  17. node_modules/.bin/nodetouch +112 -0
  18. node_modules/.bin/parser +15 -0
  19. node_modules/.bin/pixelmatch +42 -0
  20. node_modules/.bin/prebuild-install +78 -0
  21. node_modules/.bin/prettier +80 -0
  22. node_modules/.bin/qrcode +159 -0
  23. node_modules/.bin/rc +4 -0
  24. node_modules/.bin/rolldown +2 -0
  25. node_modules/.bin/rollup +1912 -0
  26. node_modules/.bin/semver +195 -0
  27. node_modules/.bin/specificity +14 -0
  28. node_modules/.bin/terser +21 -0
  29. node_modules/.bin/tldts +21 -0
  30. node_modules/.bin/tree-kill +14 -0
  31. node_modules/.bin/tsc +2 -0
  32. node_modules/.bin/tsserver +2 -0
  33. node_modules/.bin/tsx +0 -0
  34. node_modules/.bin/update-browserslist-db +42 -0
  35. node_modules/.bin/uuid +2 -0
  36. node_modules/.bin/vite +79 -0
  37. node_modules/.bin/vitest +2 -0
  38. node_modules/.bin/why-is-node-running +18 -0
  39. node_modules/.package-lock.json +0 -0
  40. node_modules/@asamuzakjp/css-color/LICENSE +21 -0
  41. node_modules/@asamuzakjp/css-color/README.md +316 -0
  42. node_modules/@asamuzakjp/css-color/dist/esm/index.d.ts +20 -0
  43. node_modules/@asamuzakjp/css-color/dist/esm/index.js +29 -0
  44. node_modules/@asamuzakjp/css-color/dist/esm/index.js.map +1 -0
  45. node_modules/@asamuzakjp/css-color/dist/esm/js/cache.d.ts +38 -0
  46. node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js +90 -0
  47. node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js.map +1 -0
  48. node_modules/@asamuzakjp/css-color/dist/esm/js/color.d.ts +537 -0
  49. node_modules/@asamuzakjp/css-color/dist/esm/js/color.js +3534 -0
  50. node_modules/@asamuzakjp/css-color/dist/esm/js/color.js.map +0 -0
node_modules/.bin/acorn ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ "use strict"
3
+
4
+ require("../dist/bin.js")
node_modules/.bin/baseline-browser-mapping ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #!/usr/bin/env node
2
+ "use strict";const{getCompatibleVersions:e}=require("./index.cjs"),a=process.argv.slice(2),s={};for(let e=0;e<a.length;e++){const r=a[e];r&&("-h"===r||"--help"===r?s.help=!0:"--include-downstream-browsers"===r?s["include-downstream-browsers"]=!0:"--list-all-compatible-versions"===r?s["list-all-compatible-versions"]=!0:"--include-kaios"===r?s["include-kaios"]=!0:"--suppress-warnings"===r?s["suppress-warnings"]=!0:r.startsWith("--target-year=")?s["target-year"]=r.substring(14):"--target-year"===r?s["target-year"]=a[++e]:r.startsWith("--widely-available-on-date=")?s["widely-available-on-date"]=r.substring(27):"--widely-available-on-date"===r?s["widely-available-on-date"]=a[++e]:r.startsWith("--override-last-updated=")?s["override-last-updated"]=r.substring(24):"--override-last-updated"===r?s["override-last-updated"]=a[++e]:(console.error(`Unknown argument: ${r}`),process.exit(1)))}s.help&&(console.log("\nGet Baseline Widely available browser versions or Baseline year browser versions.\n\nUsage: baseline-browser-mapping [options]\n\nOptions:\n --target-year Pass a year between 2015 and the current year to get browser versions compatible \n with all Newly Available features as of the end of the year specified.\n --widely-available-on-date Pass a date in the format 'YYYY-MM-DD' to get versions compatible with Widely \n available on the specified date.\n --include-downstream-browsers Whether to include browsers that use the same engines as a core Baseline browser.\n --include-kaios Whether to include KaiOS in downstream browsers. Requires --include-downstream-browsers.\n --list-all-compatible-versions Whether to include only the minimum compatible browser versions or all compatible versions.\n --suppress-warnings Supress potential warnings about data staleness when using a very recent feature cut off date.\n --override-last-updated Override the last updated date for the baseline data for debugging purposes.\n -h, --help Show help\n\nExamples:\n npx baseline-browser-mapping --target-year 2020\n npx baseline-browser-mapping --widely-available-on-date 2023-04-05\n npx baseline-browser-mapping --include-downstream-browsers\n npx baseline-browser-mapping --list-all-compatible-versions\n".trim()),process.exit(0)),console.log(e({targetYear:s["target-year"]?Number.parseInt(s["target-year"]):void 0,widelyAvailableOnDate:s["widely-available-on-date"],includeDownstreamBrowsers:s["include-downstream-browsers"],listAllCompatibleVersions:s["list-all-compatible-versions"],includeKaiOS:s["include-kaios"],suppressWarnings:s["suppress-warnings"],overrideLastUpdated:s["override-last-updated"]?Number.parseInt(s["override-last-updated"]):void 0}));
node_modules/.bin/browserslist ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ var fs = require('fs')
4
+ var updateDb = require('update-browserslist-db')
5
+
6
+ var browserslist = require('./')
7
+ var pkg = require('./package.json')
8
+
9
+ var args = process.argv.slice(2)
10
+
11
+ var USAGE =
12
+ 'Usage:\n' +
13
+ ' npx browserslist\n' +
14
+ ' npx browserslist "QUERIES"\n' +
15
+ ' npx browserslist --json "QUERIES"\n' +
16
+ ' npx browserslist --config="path/to/browserlist/file"\n' +
17
+ ' npx browserslist --coverage "QUERIES"\n' +
18
+ ' npx browserslist --coverage=US "QUERIES"\n' +
19
+ ' npx browserslist --coverage=US,RU,global "QUERIES"\n' +
20
+ ' npx browserslist --env="environment name defined in config"\n' +
21
+ ' npx browserslist --stats="path/to/browserlist/stats/file"\n' +
22
+ ' npx browserslist --mobile-to-desktop\n' +
23
+ ' npx browserslist --ignore-unknown-versions\n'
24
+
25
+ function isArg(arg) {
26
+ return args.some(function (str) {
27
+ return str === arg || str.indexOf(arg + '=') === 0
28
+ })
29
+ }
30
+
31
+ function error(msg) {
32
+ process.stderr.write('browserslist: ' + msg + '\n')
33
+ process.exit(1)
34
+ }
35
+
36
+ if (isArg('--help') || isArg('-h')) {
37
+ process.stdout.write(pkg.description + '.\n\n' + USAGE + '\n')
38
+ } else if (isArg('--version') || isArg('-v')) {
39
+ process.stdout.write('browserslist ' + pkg.version + '\n')
40
+ } else if (isArg('--update-db')) {
41
+ /* c8 ignore next 8 */
42
+ process.stdout.write(
43
+ 'The --update-db command is deprecated.\n' +
44
+ 'Please use npx update-browserslist-db@latest instead.\n'
45
+ )
46
+ process.stdout.write('Browserslist DB update will still be made.\n')
47
+ updateDb(function (str) {
48
+ process.stdout.write(str)
49
+ })
50
+ } else {
51
+ var mode = 'browsers'
52
+ var opts = {}
53
+ var queries
54
+ var areas
55
+
56
+ for (var i = 0; i < args.length; i++) {
57
+ if (args[i][0] !== '-') {
58
+ queries = args[i].replace(/^["']|["']$/g, '')
59
+ continue
60
+ }
61
+
62
+ var arg = args[i].split('=')
63
+ var name = arg[0]
64
+ var value = arg[1]
65
+
66
+ if (value) value = value.replace(/^["']|["']$/g, '')
67
+
68
+ if (name === '--config' || name === '-b') {
69
+ opts.config = value
70
+ } else if (name === '--env' || name === '-e') {
71
+ opts.env = value
72
+ } else if (name === '--stats' || name === '-s') {
73
+ opts.stats = value
74
+ } else if (name === '--coverage' || name === '-c') {
75
+ if (mode !== 'json') mode = 'coverage'
76
+ if (value) {
77
+ areas = value.split(',')
78
+ } else {
79
+ areas = ['global']
80
+ }
81
+ } else if (name === '--json') {
82
+ mode = 'json'
83
+ } else if (name === '--mobile-to-desktop') {
84
+ /* c8 ignore next */
85
+ opts.mobileToDesktop = true
86
+ } else if (name === '--ignore-unknown-versions') {
87
+ /* c8 ignore next */
88
+ opts.ignoreUnknownVersions = true
89
+ } else {
90
+ error('Unknown arguments ' + args[i] + '.\n\n' + USAGE)
91
+ }
92
+ }
93
+
94
+ var browsers
95
+ try {
96
+ browsers = browserslist(queries, opts)
97
+ } catch (e) {
98
+ if (e.name === 'BrowserslistError') {
99
+ error(e.message)
100
+ } /* c8 ignore start */ else {
101
+ throw e
102
+ } /* c8 ignore end */
103
+ }
104
+
105
+ var coverage
106
+ if (mode === 'browsers') {
107
+ browsers.forEach(function (browser) {
108
+ process.stdout.write(browser + '\n')
109
+ })
110
+ } else if (areas) {
111
+ coverage = areas.map(function (area) {
112
+ var stats
113
+ if (area !== 'global') {
114
+ stats = area
115
+ } else if (opts.stats) {
116
+ stats = JSON.parse(fs.readFileSync(opts.stats))
117
+ }
118
+ var result = browserslist.coverage(browsers, stats)
119
+ var round = Math.round(result * 100) / 100.0
120
+
121
+ return [area, round]
122
+ })
123
+
124
+ if (mode === 'coverage') {
125
+ var prefix = 'These browsers account for '
126
+ process.stdout.write(prefix)
127
+ coverage.forEach(function (data, index) {
128
+ var area = data[0]
129
+ var round = data[1]
130
+ var end = 'globally'
131
+ if (area && area !== 'global') {
132
+ end = 'in the ' + area.toUpperCase()
133
+ } else if (opts.stats) {
134
+ end = 'in custom statistics'
135
+ }
136
+
137
+ if (index !== 0) {
138
+ process.stdout.write(prefix.replace(/./g, ' '))
139
+ }
140
+
141
+ process.stdout.write(round + '% of all users ' + end + '\n')
142
+ })
143
+ }
144
+ }
145
+
146
+ if (mode === 'json') {
147
+ var data = { browsers: browsers }
148
+ if (coverage) {
149
+ data.coverage = coverage.reduce(function (object, j) {
150
+ object[j[0]] = j[1]
151
+ return object
152
+ }, {})
153
+ }
154
+ process.stdout.write(JSON.stringify(data, null, ' ') + '\n')
155
+ }
156
+ }
node_modules/.bin/crc32 ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
3
+ /* eslint-env node */
4
+ /* vim: set ts=2 ft=javascript: */
5
+ /*jshint node:true */
6
+
7
+ var X/*:CRC32Module*/;
8
+ try { X = require('../'); } catch(e) { X = require('crc-32'); }
9
+
10
+ function help()/*:number*/ {
11
+ [
12
+ "usage: crc32 [options] [filename]",
13
+ "",
14
+ "Options:",
15
+ " -h, --help output usage information",
16
+ " -V, --version output the version number",
17
+ " -S, --seed=<n> use integer seed as starting value (rolling CRC)",
18
+ " -H, --hex-seed=<h> use hex seed as starting value (rolling CRC)",
19
+ " -d, --signed print result with format `%d` (default)",
20
+ " -u, --unsigned print result with format `%u`",
21
+ " -x, --hex print result with format `%0.8x`",
22
+ " -X, --HEX print result with format `%0.8X`",
23
+ " -c, --crc32c use CRC32C (Castagnoli)",
24
+ " -F, --format=<s> use specified printf format",
25
+ "",
26
+ "Set filename = '-' or pipe data into crc32 to read from stdin",
27
+ "Default output mode is signed (-d)",
28
+ ""
29
+ ].forEach(function(l) { console.log(l); });
30
+ return 0;
31
+ }
32
+
33
+ function version()/*:number*/ { console.log(X.version); return 0; }
34
+
35
+ var fs = require('fs');
36
+ try { require('exit-on-epipe'); } catch(e) {}
37
+
38
+ function die(msg/*:string*/, ec/*:?number*/)/*:void*/ { console.error(msg); process.exit(ec || 0); }
39
+
40
+ var args/*:Array<string>*/ = process.argv.slice(2);
41
+ var filename/*:string*/ = "";
42
+ var fmt/*:string*/ = "";
43
+ var seed = 0, r = 10;
44
+
45
+ for(var i = 0; i < args.length; ++i) {
46
+ var arg = args[i];
47
+ if(arg.charCodeAt(0) != 45) { if(filename === "") filename = arg; continue; }
48
+ var m = arg.indexOf("=") == -1 ? arg : arg.substr(0, arg.indexOf("="));
49
+ switch(m) {
50
+ case "-": filename = "-"; break;
51
+
52
+ case "--help": case "-h": process.exit(help()); break;
53
+ case "--version": case "-V": process.exit(version()); break;
54
+
55
+ case "--crc32c": case "-c": try { X = require('../crc32c'); } catch(e) { X = require('crc-32/crc32c'); } break;
56
+
57
+ case "--signed": case "-d": fmt = "%d"; break;
58
+ case "--unsigned": case "-u": fmt = "%u"; break;
59
+ case "--hex": case "-x": fmt = "%0.8x"; break;
60
+ case "--HEX": case "-X": fmt = "%0.8X"; break;
61
+ case "--format": case "-F":
62
+ try {
63
+ require("printj");
64
+ fmt = ((m!=arg) ? arg.substr(m.length+1) : args[++i])||"";
65
+ } catch(e) {
66
+ console.error("The `crc-32` module removed the `printj` dependency for formatting");
67
+ console.error("Use the `crc32-cli` module instead:");
68
+ console.error(" $ npx crc32-cli [options] [filename]");
69
+ } break;
70
+
71
+ case "--hex-seed": case "-H": r = 16;
72
+ /* falls through */
73
+ case "--seed": case "-S":
74
+ seed=parseInt((m!=arg) ? arg.substr(m.length+1) : args[++i], r)||0; break;
75
+
76
+ default: die("crc32: unrecognized option `" + arg + "'", 22);
77
+ }
78
+ }
79
+
80
+ if(!process.stdin.isTTY) filename = filename || "-";
81
+ if(filename.length===0) die("crc32: must specify a filename ('-' for stdin)",1);
82
+
83
+ var crc32 = seed;
84
+ // $FlowIgnore -- Writable is callable but type sig disagrees
85
+ var writable = require('stream').Writable();
86
+ writable._write = function(chunk, e, cb) { crc32 = X.buf(chunk, crc32); cb(); };
87
+ writable._writev = function(chunks, cb) {
88
+ chunks.forEach(function(c) { crc32 = X.buf(c.chunk, crc32);});
89
+ cb();
90
+ };
91
+ writable.on('finish', function() {
92
+ if(fmt === "") console.log(crc32);
93
+ else try { console.log(require("printj").sprintf(fmt, crc32)); } catch(e) {
94
+ switch(fmt) {
95
+ case "%d": console.log(crc32); break;
96
+ case "%u": console.log(crc32 >>> 0); break;
97
+ case "%0.8x": console.log((crc32 >>> 0).toString(16).padStart(8, "0").toLowerCase()); break;
98
+ case "%0.8X": console.log((crc32 >>> 0).toString(16).padStart(8, "0").toUpperCase()); break;
99
+ }
100
+ }
101
+ });
102
+
103
+ if(filename === "-") process.stdin.pipe(writable);
104
+ else if(fs.existsSync(filename)) fs.createReadStream(filename).pipe(writable);
105
+ else die("crc32: " + filename + ": No such file or directory", 2);
node_modules/.bin/eslint ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @fileoverview Main CLI that is run via the eslint command.
5
+ * @author Nicholas C. Zakas
6
+ */
7
+
8
+ /* eslint no-console:off -- CLI */
9
+
10
+ "use strict";
11
+
12
+ const mod = require("node:module");
13
+
14
+ // to use V8's code cache to speed up instantiation time
15
+ mod.enableCompileCache?.();
16
+
17
+ // must do this initialization *before* other requires in order to work
18
+ if (process.argv.includes("--debug")) {
19
+ require("debug").enable("eslint:*,-eslint:code-path,eslintrc:*");
20
+ }
21
+
22
+ //------------------------------------------------------------------------------
23
+ // Helpers
24
+ //------------------------------------------------------------------------------
25
+
26
+ /**
27
+ * Read data from stdin til the end.
28
+ *
29
+ * Note: See
30
+ * - https://github.com/nodejs/node/blob/master/doc/api/process.md#processstdin
31
+ * - https://github.com/nodejs/node/blob/master/doc/api/process.md#a-note-on-process-io
32
+ * - https://lists.gnu.org/archive/html/bug-gnu-emacs/2016-01/msg00419.html
33
+ * - https://github.com/nodejs/node/issues/7439 (historical)
34
+ *
35
+ * On Windows using `fs.readFileSync(STDIN_FILE_DESCRIPTOR, "utf8")` seems
36
+ * to read 4096 bytes before blocking and never drains to read further data.
37
+ *
38
+ * The investigation on the Emacs thread indicates:
39
+ *
40
+ * > Emacs on MS-Windows uses pipes to communicate with subprocesses; a
41
+ * > pipe on Windows has a 4K buffer. So as soon as Emacs writes more than
42
+ * > 4096 bytes to the pipe, the pipe becomes full, and Emacs then waits for
43
+ * > the subprocess to read its end of the pipe, at which time Emacs will
44
+ * > write the rest of the stuff.
45
+ * @returns {Promise<string>} The read text.
46
+ */
47
+ function readStdin() {
48
+ return new Promise((resolve, reject) => {
49
+ let content = "";
50
+ let chunk = "";
51
+
52
+ process.stdin
53
+ .setEncoding("utf8")
54
+ .on("readable", () => {
55
+ while ((chunk = process.stdin.read()) !== null) {
56
+ content += chunk;
57
+ }
58
+ })
59
+ .on("end", () => resolve(content))
60
+ .on("error", reject);
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Spawns an external command and propagates its exit status.
66
+ * @param {string} command The command to run.
67
+ * @param {string[]} args The command arguments.
68
+ * @throws {Error} If the command cannot be spawned.
69
+ * @returns {void}
70
+ */
71
+ function spawnExternalCommand(command, args) {
72
+ const spawn = require("cross-spawn");
73
+ const result = spawn.sync(command, args, {
74
+ encoding: "utf8",
75
+ stdio: "inherit",
76
+ });
77
+
78
+ if (result.error) {
79
+ throw result.error;
80
+ }
81
+
82
+ if (result.signal) {
83
+ process.kill(process.pid, result.signal);
84
+ return;
85
+ }
86
+
87
+ process.exitCode = result.status ?? 0;
88
+ }
89
+
90
+ /**
91
+ * Get the error message of a given value.
92
+ * @param {any} error The value to get.
93
+ * @returns {string} The error message.
94
+ */
95
+ function getErrorMessage(error) {
96
+ // Lazy loading because this is used only if an error happened.
97
+ const util = require("node:util");
98
+
99
+ // Foolproof -- third-party module might throw non-object.
100
+ if (typeof error !== "object" || error === null) {
101
+ return String(error);
102
+ }
103
+
104
+ // Use templates if `error.messageTemplate` is present.
105
+ if (typeof error.messageTemplate === "string") {
106
+ try {
107
+ const template = require(`../messages/${error.messageTemplate}.js`);
108
+
109
+ return template(error.messageData || {});
110
+ } catch {
111
+ // Ignore template error then fallback to use `error.stack`.
112
+ }
113
+ }
114
+
115
+ // Use the stacktrace if it's an error object.
116
+ if (typeof error.stack === "string") {
117
+ return error.stack;
118
+ }
119
+
120
+ // Otherwise, dump the object.
121
+ return util.format("%o", error);
122
+ }
123
+
124
+ /**
125
+ * Tracks error messages that are shown to the user so we only ever show the
126
+ * same message once.
127
+ * @type {Set<string>}
128
+ */
129
+ const displayedErrors = new Set();
130
+
131
+ /**
132
+ * Tracks whether an unexpected error was caught
133
+ * @type {boolean}
134
+ */
135
+ let hadFatalError = false;
136
+
137
+ /**
138
+ * Catch and report unexpected error.
139
+ * @param {any} error The thrown error object.
140
+ * @returns {void}
141
+ */
142
+ function onFatalError(error) {
143
+ process.exitCode = 2;
144
+ hadFatalError = true;
145
+
146
+ const { version } = require("../package.json");
147
+ const message = `
148
+ Oops! Something went wrong! :(
149
+
150
+ ESLint: ${version}
151
+
152
+ ${getErrorMessage(error)}`;
153
+
154
+ if (!displayedErrors.has(message)) {
155
+ console.error(message);
156
+ displayedErrors.add(message);
157
+ }
158
+ }
159
+
160
+ //------------------------------------------------------------------------------
161
+ // Execution
162
+ //------------------------------------------------------------------------------
163
+
164
+ (async function main() {
165
+ process.on("uncaughtException", onFatalError);
166
+ process.on("unhandledRejection", onFatalError);
167
+
168
+ // Call the config initializer if `--init` is present.
169
+ if (process.argv.includes("--init")) {
170
+ // `eslint --init` has been moved to `@eslint/create-config`
171
+ console.warn(
172
+ "You can also run this command directly using 'npm init @eslint/config@latest'.",
173
+ );
174
+
175
+ spawnExternalCommand("npm", ["init", "@eslint/config@latest"]);
176
+ return;
177
+ }
178
+
179
+ // start the MCP server if `--mcp` is present
180
+ if (process.argv.includes("--mcp")) {
181
+ console.warn(
182
+ "You can also run this command directly using 'npx @eslint/mcp@latest'.",
183
+ );
184
+
185
+ spawnExternalCommand("npx", ["@eslint/mcp@latest"]);
186
+ return;
187
+ }
188
+
189
+ // Otherwise, call the CLI.
190
+ const cli = require("../lib/cli");
191
+ const exitCode = await cli.execute(
192
+ process.argv,
193
+ process.argv.includes("--stdin") ? await readStdin() : void 0,
194
+ );
195
+
196
+ /*
197
+ * If an uncaught exception or unhandled rejection was detected in the meantime,
198
+ * keep the fatal exit code 2 that is already assigned to `process.exitCode`.
199
+ * Without this condition, exit code 2 (unsuccessful execution) could be overwritten with
200
+ * 1 (successful execution, lint problems found) or even 0 (successful execution, no lint problems found).
201
+ * This ensures that unexpected errors that seemingly don't affect the success
202
+ * of the execution will still cause a non-zero exit code, as it's a common
203
+ * practice and the default behavior of Node.js to exit with non-zero
204
+ * in case of an uncaught exception or unhandled rejection.
205
+ *
206
+ * Otherwise, assign the exit code returned from CLI.
207
+ */
208
+ if (!hadFatalError) {
209
+ process.exitCode = exitCode;
210
+ }
211
+ })().catch(onFatalError);
node_modules/.bin/eslint-config-prettier ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const validators = require("./validators");
6
+ const config = require("..");
7
+ const prettier = require("../prettier");
8
+
9
+ // Require locally installed eslint, for `npx eslint-config-prettier` support
10
+ // with no local eslint-config-prettier installation.
11
+ const localRequire = (request) =>
12
+ require(
13
+ require.resolve(request, {
14
+ paths: [process.cwd(), ...require.resolve.paths("eslint")],
15
+ })
16
+ );
17
+
18
+ let experimentalApi = {};
19
+ try {
20
+ experimentalApi = localRequire("eslint/use-at-your-own-risk");
21
+ } catch (_error) {}
22
+
23
+ const { ESLint, FlatESLint = experimentalApi.FlatESLint } =
24
+ localRequire("eslint");
25
+
26
+ const SPECIAL_RULES_URL =
27
+ "https://github.com/prettier/eslint-config-prettier#special-rules";
28
+
29
+ const PRETTIER_RULES_URL =
30
+ "https://github.com/prettier/eslint-config-prettier#arrow-body-style-and-prefer-arrow-callback";
31
+
32
+ if (module === require.main) {
33
+ const args = process.argv.slice(2);
34
+
35
+ if (args.length === 0) {
36
+ console.error(help());
37
+ process.exit(1);
38
+ }
39
+
40
+ const eslint = new ESLint();
41
+ const flatESLint = FlatESLint === undefined ? undefined : new FlatESLint();
42
+
43
+ Promise.all(
44
+ args.map((file) => {
45
+ switch (process.env.ESLINT_USE_FLAT_CONFIG) {
46
+ case "true": {
47
+ return flatESLint.calculateConfigForFile(file);
48
+ }
49
+ case "false": {
50
+ return eslint.calculateConfigForFile(file);
51
+ }
52
+ default: {
53
+ // This turns synchronous errors (such as `.calculateConfigForFile` not existing)
54
+ // and turns them into promise rejections.
55
+ return Promise.resolve()
56
+ .then(() => flatESLint.calculateConfigForFile(file))
57
+ .catch(() => eslint.calculateConfigForFile(file));
58
+ }
59
+ }
60
+ })
61
+ )
62
+ .then((configs) => {
63
+ const rules = configs.flatMap(
64
+ (
65
+ // Initializing config and rules for files that aren't included in the flat config,
66
+ // which is a very unlikely scenario, but should still be treated as a success
67
+ { rules = {} } = {},
68
+ index
69
+ ) => Object.entries(rules).map((entry) => [...entry, args[index]])
70
+ );
71
+ const result = processRules(rules);
72
+ if (result.stderr) {
73
+ console.error(result.stderr);
74
+ }
75
+ if (result.stdout) {
76
+ console.error(result.stdout);
77
+ }
78
+ process.exit(result.code);
79
+ })
80
+ .catch((error) => {
81
+ console.error(error.message);
82
+ process.exit(1);
83
+ });
84
+ }
85
+
86
+ function help() {
87
+ return `
88
+ Usage: npx eslint-config-prettier FILE...
89
+
90
+ Resolves an ESLint configuration for every given FILE and checks if they
91
+ contain rules that are unnecessary or conflict with Prettier. Example:
92
+
93
+ npx eslint-config-prettier index.js test/index.js other/file/to/check.js
94
+
95
+ Exit codes:
96
+
97
+ 0: No automatically detectable problems found.
98
+ 1: General error.
99
+ 2: Conflicting rules found.
100
+
101
+ For more information, see:
102
+ https://github.com/prettier/eslint-config-prettier#cli-helper-tool
103
+ `.trim();
104
+ }
105
+
106
+ function processRules(configRules) {
107
+ const regularRules = filterRules(config.rules, (_, value) => value === "off");
108
+ const optionsRules = filterRules(
109
+ config.rules,
110
+ (ruleName, value) => value === 0 && ruleName in validators
111
+ );
112
+ const specialRules = filterRules(
113
+ config.rules,
114
+ (ruleName, value) => value === 0 && !(ruleName in validators)
115
+ );
116
+
117
+ const enabledRules = configRules
118
+ .map(([ruleName, value, source]) => {
119
+ const arrayValue = Array.isArray(value) ? value : [value];
120
+ const [level, ...options] = arrayValue;
121
+ const isOff = level === "off" || level === 0;
122
+ return isOff ? null : { ruleName, options, source };
123
+ })
124
+ .filter(Boolean);
125
+
126
+ const flaggedRules = enabledRules.filter(
127
+ ({ ruleName }) => ruleName in config.rules
128
+ );
129
+
130
+ const regularFlaggedRuleNames = filterRuleNames(
131
+ flaggedRules,
132
+ ({ ruleName }) => ruleName in regularRules
133
+ );
134
+ const optionsFlaggedRuleNames = filterRuleNames(
135
+ flaggedRules,
136
+ ({ ruleName, ...rule }) =>
137
+ ruleName in optionsRules && !validators[ruleName](rule)
138
+ );
139
+ const specialFlaggedRuleNames = filterRuleNames(
140
+ flaggedRules,
141
+ ({ ruleName }) => ruleName in specialRules
142
+ );
143
+ const prettierFlaggedRuleNames = filterRuleNames(
144
+ enabledRules,
145
+ ({ ruleName, source }) =>
146
+ ruleName in prettier.rules &&
147
+ enabledRules.some(
148
+ (rule) =>
149
+ rule.ruleName === "prettier/prettier" && rule.source === source
150
+ )
151
+ );
152
+
153
+ const regularMessage = [
154
+ "The following rules are unnecessary or might conflict with Prettier:",
155
+ "",
156
+ printRuleNames(regularFlaggedRuleNames),
157
+ ].join("\n");
158
+
159
+ const optionsMessage = [
160
+ "The following rules are enabled with config that might conflict with Prettier. See:",
161
+ SPECIAL_RULES_URL,
162
+ "",
163
+ printRuleNames(optionsFlaggedRuleNames),
164
+ ].join("\n");
165
+
166
+ const specialMessage = [
167
+ "The following rules are enabled but cannot be automatically checked. See:",
168
+ SPECIAL_RULES_URL,
169
+ "",
170
+ printRuleNames(specialFlaggedRuleNames),
171
+ ].join("\n");
172
+
173
+ const prettierMessage = [
174
+ "The following rules can cause issues when using eslint-plugin-prettier at the same time.",
175
+ "Only enable them if you know what you are doing! See:",
176
+ PRETTIER_RULES_URL,
177
+ "",
178
+ printRuleNames(prettierFlaggedRuleNames),
179
+ ].join("\n");
180
+
181
+ if (
182
+ regularFlaggedRuleNames.length === 0 &&
183
+ optionsFlaggedRuleNames.length === 0
184
+ ) {
185
+ const message =
186
+ specialFlaggedRuleNames.length === 0 &&
187
+ prettierFlaggedRuleNames.length === 0
188
+ ? "No rules that are unnecessary or conflict with Prettier were found."
189
+ : [
190
+ specialFlaggedRuleNames.length === 0 ? null : specialMessage,
191
+ prettierFlaggedRuleNames.length === 0 ? null : prettierMessage,
192
+ "Other than that, no rules that are unnecessary or conflict with Prettier were found.",
193
+ ]
194
+ .filter(Boolean)
195
+ .join("\n\n");
196
+
197
+ return {
198
+ stdout: message,
199
+ code: 0,
200
+ };
201
+ }
202
+
203
+ const message = [
204
+ regularFlaggedRuleNames.length === 0 ? null : regularMessage,
205
+ optionsFlaggedRuleNames.length === 0 ? null : optionsMessage,
206
+ specialFlaggedRuleNames.length === 0 ? null : specialMessage,
207
+ prettierFlaggedRuleNames.length === 0 ? null : prettierMessage,
208
+ ]
209
+ .filter(Boolean)
210
+ .join("\n\n");
211
+
212
+ return {
213
+ stdout: message,
214
+ code: 2,
215
+ };
216
+ }
217
+
218
+ function filterRules(rules, fn) {
219
+ return Object.fromEntries(
220
+ Object.entries(rules)
221
+ .filter(([ruleName, value]) => fn(ruleName, value))
222
+ .map(([ruleName]) => [ruleName, true])
223
+ );
224
+ }
225
+
226
+ function filterRuleNames(rules, fn) {
227
+ return [
228
+ ...new Set(rules.filter((rule) => fn(rule)).map((rule) => rule.ruleName)),
229
+ ];
230
+ }
231
+
232
+ function printRuleNames(ruleNames) {
233
+ return ruleNames
234
+ .slice()
235
+ .sort()
236
+ .map((ruleName) => `- ${ruleName}`)
237
+ .join("\n");
238
+ }
239
+
240
+ exports.processRules = processRules;
node_modules/.bin/fxparser ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /*eslint-disable no-console*/
4
+ import fs from 'fs';
5
+ import { resolve } from 'path';
6
+ import {XMLParser, XMLValidator} from "../fxp.js";
7
+ import ReadToEnd from './read.js';
8
+ import cmdDetail from "./man.js"
9
+
10
+ console.warn("\x1b[33m%s\x1b[0m", "⚠️ Warning: The built-in CLI interface is now deprecated.");
11
+ console.warn("Please install the dedicated CLI package instead:");
12
+ console.warn(" npm install -g fxp-cli");
13
+
14
+ if (process.argv[2] === '--help' || process.argv[2] === '-h') {
15
+ console.log(cmdDetail);
16
+ } else if (process.argv[2] === '--version') {
17
+ const packageJsonPath = resolve(process.cwd(), 'package.json');
18
+ const version = JSON.parse(fs.readFileSync(packageJsonPath).toString()).version;
19
+ console.log(version);
20
+ } else {
21
+ const options = {
22
+ removeNSPrefix: true,
23
+ ignoreAttributes: false,
24
+ parseTagValue: true,
25
+ parseAttributeValue: true,
26
+ };
27
+ let fileName = '';
28
+ let outputFileName;
29
+ let validate = false;
30
+ let validateOnly = false;
31
+ for (let i = 2; i < process.argv.length; i++) {
32
+ if (process.argv[i] === '-ns') {
33
+ options.removeNSPrefix = false;
34
+ } else if (process.argv[i] === '-a') {
35
+ options.ignoreAttributes = true;
36
+ } else if (process.argv[i] === '-c') {
37
+ options.parseTagValue = false;
38
+ options.parseAttributeValue = false;
39
+ } else if (process.argv[i] === '-o') {
40
+ outputFileName = process.argv[++i];
41
+ } else if (process.argv[i] === '-v') {
42
+ validate = true;
43
+ } else if (process.argv[i] === '-V') {
44
+ validateOnly = true;
45
+ } else {
46
+ //filename
47
+ fileName = process.argv[i];
48
+ }
49
+ }
50
+
51
+ const callback = function(xmlData) {
52
+ let output = '';
53
+ if (validateOnly) {
54
+ output = XMLValidator.validate(xmlData);
55
+ process.exitCode = output === true ? 0 : 1;
56
+ } else {
57
+ const parser = new XMLParser(options);
58
+ output = JSON.stringify(parser.parse(xmlData,validate), null, 4);
59
+ }
60
+ if (outputFileName) {
61
+ writeToFile(outputFileName, output);
62
+ } else {
63
+ console.log(output);
64
+ }
65
+ };
66
+
67
+
68
+ try {
69
+
70
+ if (!fileName) {
71
+ ReadToEnd.readToEnd(process.stdin, function(err, data) {
72
+ if (err) {
73
+ throw err;
74
+ }
75
+ callback(data.toString());
76
+ });
77
+ } else {
78
+ fs.readFile(fileName, function(err, data) {
79
+ if (err) {
80
+ throw err;
81
+ }
82
+ callback(data.toString());
83
+ });
84
+ }
85
+ } catch (e) {
86
+ console.log('Seems an invalid file or stream.' + e);
87
+ }
88
+ }
89
+
90
+ function writeToFile(fileName, data) {
91
+ fs.writeFile(fileName, data, function(err) {
92
+ if (err) {
93
+ throw err;
94
+ }
95
+ console.log('JSON output has been written to ' + fileName);
96
+ });
97
+ }
node_modules/.bin/jiti ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ const { resolve } = require("node:path");
4
+
5
+ const script = process.argv.splice(2, 1)[0];
6
+
7
+ if (!script) {
8
+
9
+ console.error("Usage: jiti <path> [...arguments]");
10
+ process.exit(1);
11
+ }
12
+
13
+ const pwd = process.cwd();
14
+ const jiti = require("..")(pwd);
15
+ const resolved = (process.argv[1] = jiti.resolve(resolve(pwd, script)));
16
+ jiti(resolved);
node_modules/.bin/js-yaml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict'
4
+
5
+ const fs = require('fs')
6
+ const argparse = require('argparse')
7
+ const yaml = require('..')
8
+
9
+ /// /////////////////////////////////////////////////////////////////////////////
10
+
11
+ const cli = new argparse.ArgumentParser({
12
+ prog: 'js-yaml',
13
+ add_help: true
14
+ })
15
+
16
+ cli.add_argument('-v', '--version', {
17
+ action: 'version',
18
+ version: require('../package.json').version
19
+ })
20
+
21
+ cli.add_argument('-c', '--compact', {
22
+ help: 'Display errors in compact mode',
23
+ action: 'store_true'
24
+ })
25
+
26
+ // deprecated (not needed after we removed output colors)
27
+ // option suppressed, but not completely removed for compatibility
28
+ cli.add_argument('-j', '--to-json', {
29
+ help: argparse.SUPPRESS,
30
+ dest: 'json',
31
+ action: 'store_true'
32
+ })
33
+
34
+ cli.add_argument('-t', '--trace', {
35
+ help: 'Show stack trace on error',
36
+ action: 'store_true'
37
+ })
38
+
39
+ cli.add_argument('file', {
40
+ help: 'File to read, utf-8 encoded without BOM',
41
+ nargs: '?',
42
+ default: '-'
43
+ })
44
+
45
+ /// /////////////////////////////////////////////////////////////////////////////
46
+
47
+ const options = cli.parse_args()
48
+
49
+ /// /////////////////////////////////////////////////////////////////////////////
50
+
51
+ function readFile (filename, encoding, callback) {
52
+ if (options.file === '-') {
53
+ // read from stdin
54
+
55
+ const chunks = []
56
+
57
+ process.stdin.on('data', function (chunk) {
58
+ chunks.push(chunk)
59
+ })
60
+
61
+ process.stdin.on('end', function () {
62
+ return callback(null, Buffer.concat(chunks).toString(encoding))
63
+ })
64
+ } else {
65
+ fs.readFile(filename, encoding, callback)
66
+ }
67
+ }
68
+
69
+ readFile(options.file, 'utf8', function (error, input) {
70
+ let output
71
+ let isYaml
72
+
73
+ if (error) {
74
+ if (error.code === 'ENOENT') {
75
+ console.error('File not found: ' + options.file)
76
+ process.exit(2)
77
+ }
78
+
79
+ console.error(
80
+ (options.trace && error.stack) ||
81
+ error.message ||
82
+ String(error))
83
+
84
+ process.exit(1)
85
+ }
86
+
87
+ try {
88
+ output = JSON.parse(input)
89
+ isYaml = false
90
+ } catch (err) {
91
+ if (err instanceof SyntaxError) {
92
+ try {
93
+ output = []
94
+ yaml.loadAll(input, function (doc) { output.push(doc) }, {})
95
+ isYaml = true
96
+
97
+ if (output.length === 0) output = null
98
+ else if (output.length === 1) output = output[0]
99
+ } catch (e) {
100
+ if (options.trace && err.stack) console.error(e.stack)
101
+ else console.error(e.toString(options.compact))
102
+
103
+ process.exit(1)
104
+ }
105
+ } else {
106
+ console.error(
107
+ (options.trace && err.stack) ||
108
+ err.message ||
109
+ String(err))
110
+
111
+ process.exit(1)
112
+ }
113
+ }
114
+
115
+ if (isYaml) console.log(JSON.stringify(output, null, ' '))
116
+ else console.log(yaml.dump(output))
117
+ })
node_modules/.bin/jsesc ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ (function() {
3
+
4
+ var fs = require('fs');
5
+ var stringEscape = require('../jsesc.js');
6
+ var strings = process.argv.splice(2);
7
+ var stdin = process.stdin;
8
+ var data;
9
+ var timeout;
10
+ var isObject = false;
11
+ var options = {};
12
+ var log = console.log;
13
+
14
+ var main = function() {
15
+ var option = strings[0];
16
+
17
+ if (/^(?:-h|--help|undefined)$/.test(option)) {
18
+ log(
19
+ 'jsesc v%s - https://mths.be/jsesc',
20
+ stringEscape.version
21
+ );
22
+ log([
23
+ '\nUsage:\n',
24
+ '\tjsesc [string]',
25
+ '\tjsesc [-s | --single-quotes] [string]',
26
+ '\tjsesc [-d | --double-quotes] [string]',
27
+ '\tjsesc [-w | --wrap] [string]',
28
+ '\tjsesc [-e | --escape-everything] [string]',
29
+ '\tjsesc [-t | --escape-etago] [string]',
30
+ '\tjsesc [-6 | --es6] [string]',
31
+ '\tjsesc [-l | --lowercase-hex] [string]',
32
+ '\tjsesc [-j | --json] [string]',
33
+ '\tjsesc [-o | --object] [stringified_object]', // `JSON.parse()` the argument
34
+ '\tjsesc [-p | --pretty] [string]', // `compact: false`
35
+ '\tjsesc [-v | --version]',
36
+ '\tjsesc [-h | --help]',
37
+ '\nExamples:\n',
38
+ '\tjsesc \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
39
+ '\tjsesc --json \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
40
+ '\tjsesc --json --escape-everything \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
41
+ '\tjsesc --double-quotes --wrap \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
42
+ '\techo \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\' | jsesc'
43
+ ].join('\n'));
44
+ return process.exit(1);
45
+ }
46
+
47
+ if (/^(?:-v|--version)$/.test(option)) {
48
+ log('v%s', stringEscape.version);
49
+ return process.exit(1);
50
+ }
51
+
52
+ strings.forEach(function(string) {
53
+ // Process options
54
+ if (/^(?:-s|--single-quotes)$/.test(string)) {
55
+ options.quotes = 'single';
56
+ return;
57
+ }
58
+ if (/^(?:-d|--double-quotes)$/.test(string)) {
59
+ options.quotes = 'double';
60
+ return;
61
+ }
62
+ if (/^(?:-w|--wrap)$/.test(string)) {
63
+ options.wrap = true;
64
+ return;
65
+ }
66
+ if (/^(?:-e|--escape-everything)$/.test(string)) {
67
+ options.escapeEverything = true;
68
+ return;
69
+ }
70
+ if (/^(?:-t|--escape-etago)$/.test(string)) {
71
+ options.escapeEtago = true;
72
+ return;
73
+ }
74
+ if (/^(?:-6|--es6)$/.test(string)) {
75
+ options.es6 = true;
76
+ return;
77
+ }
78
+ if (/^(?:-l|--lowercase-hex)$/.test(string)) {
79
+ options.lowercaseHex = true;
80
+ return;
81
+ }
82
+ if (/^(?:-j|--json)$/.test(string)) {
83
+ options.json = true;
84
+ return;
85
+ }
86
+ if (/^(?:-o|--object)$/.test(string)) {
87
+ isObject = true;
88
+ return;
89
+ }
90
+ if (/^(?:-p|--pretty)$/.test(string)) {
91
+ isObject = true;
92
+ options.compact = false;
93
+ return;
94
+ }
95
+
96
+ // Process string(s)
97
+ var result;
98
+ try {
99
+ if (isObject) {
100
+ string = JSON.parse(string);
101
+ }
102
+ result = stringEscape(string, options);
103
+ log(result);
104
+ } catch(error) {
105
+ log(error.message + '\n');
106
+ log('Error: failed to escape.');
107
+ log('If you think this is a bug in jsesc, please report it:');
108
+ log('https://github.com/mathiasbynens/jsesc/issues/new');
109
+ log(
110
+ '\nStack trace using jsesc@%s:\n',
111
+ stringEscape.version
112
+ );
113
+ log(error.stack);
114
+ return process.exit(1);
115
+ }
116
+ });
117
+ // Return with exit status 0 outside of the `forEach` loop, in case
118
+ // multiple strings were passed in.
119
+ return process.exit(0);
120
+
121
+ };
122
+
123
+ if (stdin.isTTY) {
124
+ // handle shell arguments
125
+ main();
126
+ } else {
127
+ // Either the script is called from within a non-TTY context,
128
+ // or `stdin` content is being piped in.
129
+ if (!process.stdout.isTTY) { // called from a non-TTY context
130
+ timeout = setTimeout(function() {
131
+ // if no piped data arrived after a while, handle shell arguments
132
+ main();
133
+ }, 250);
134
+ }
135
+
136
+ data = '';
137
+ stdin.on('data', function(chunk) {
138
+ clearTimeout(timeout);
139
+ data += chunk;
140
+ });
141
+ stdin.on('end', function() {
142
+ strings.push(data.trim());
143
+ main();
144
+ });
145
+ stdin.resume();
146
+ }
147
+
148
+ }());
node_modules/.bin/json5 ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs')
4
+ const path = require('path')
5
+ const pkg = require('../package.json')
6
+ const JSON5 = require('./')
7
+
8
+ const argv = parseArgs()
9
+
10
+ if (argv.version) {
11
+ version()
12
+ } else if (argv.help) {
13
+ usage()
14
+ } else {
15
+ const inFilename = argv.defaults[0]
16
+
17
+ let readStream
18
+ if (inFilename) {
19
+ readStream = fs.createReadStream(inFilename)
20
+ } else {
21
+ readStream = process.stdin
22
+ }
23
+
24
+ let json5 = ''
25
+ readStream.on('data', data => {
26
+ json5 += data
27
+ })
28
+
29
+ readStream.on('end', () => {
30
+ let space
31
+ if (argv.space === 't' || argv.space === 'tab') {
32
+ space = '\t'
33
+ } else {
34
+ space = Number(argv.space)
35
+ }
36
+
37
+ let value
38
+ try {
39
+ value = JSON5.parse(json5)
40
+ if (!argv.validate) {
41
+ const json = JSON.stringify(value, null, space)
42
+
43
+ let writeStream
44
+
45
+ // --convert is for backward compatibility with v0.5.1. If
46
+ // specified with <file> and not --out-file, then a file with
47
+ // the same name but with a .json extension will be written.
48
+ if (argv.convert && inFilename && !argv.outFile) {
49
+ const parsedFilename = path.parse(inFilename)
50
+ const outFilename = path.format(
51
+ Object.assign(
52
+ parsedFilename,
53
+ {base: path.basename(parsedFilename.base, parsedFilename.ext) + '.json'}
54
+ )
55
+ )
56
+
57
+ writeStream = fs.createWriteStream(outFilename)
58
+ } else if (argv.outFile) {
59
+ writeStream = fs.createWriteStream(argv.outFile)
60
+ } else {
61
+ writeStream = process.stdout
62
+ }
63
+
64
+ writeStream.write(json)
65
+ }
66
+ } catch (err) {
67
+ console.error(err.message)
68
+ process.exit(1)
69
+ }
70
+ })
71
+ }
72
+
73
+ function parseArgs () {
74
+ let convert
75
+ let space
76
+ let validate
77
+ let outFile
78
+ let version
79
+ let help
80
+ const defaults = []
81
+
82
+ const args = process.argv.slice(2)
83
+ for (let i = 0; i < args.length; i++) {
84
+ const arg = args[i]
85
+ switch (arg) {
86
+ case '--convert':
87
+ case '-c':
88
+ convert = true
89
+ break
90
+
91
+ case '--space':
92
+ case '-s':
93
+ space = args[++i]
94
+ break
95
+
96
+ case '--validate':
97
+ case '-v':
98
+ validate = true
99
+ break
100
+
101
+ case '--out-file':
102
+ case '-o':
103
+ outFile = args[++i]
104
+ break
105
+
106
+ case '--version':
107
+ case '-V':
108
+ version = true
109
+ break
110
+
111
+ case '--help':
112
+ case '-h':
113
+ help = true
114
+ break
115
+
116
+ default:
117
+ defaults.push(arg)
118
+ break
119
+ }
120
+ }
121
+
122
+ return {
123
+ convert,
124
+ space,
125
+ validate,
126
+ outFile,
127
+ version,
128
+ help,
129
+ defaults,
130
+ }
131
+ }
132
+
133
+ function version () {
134
+ console.log(pkg.version)
135
+ }
136
+
137
+ function usage () {
138
+ console.log(
139
+ `
140
+ Usage: json5 [options] <file>
141
+
142
+ If <file> is not provided, then STDIN is used.
143
+
144
+ Options:
145
+
146
+ -s, --space The number of spaces to indent or 't' for tabs
147
+ -o, --out-file [file] Output to the specified file, otherwise STDOUT
148
+ -v, --validate Validate JSON5 but do not output JSON
149
+ -V, --version Output the version number
150
+ -h, --help Output usage information`
151
+ )
152
+ }
node_modules/.bin/mime ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ process.title = 'mime';
6
+ let mime = require('.');
7
+ let pkg = require('./package.json');
8
+ let args = process.argv.splice(2);
9
+
10
+ if (args.includes('--version') || args.includes('-v') || args.includes('--v')) {
11
+ console.log(pkg.version);
12
+ process.exit(0);
13
+ } else if (args.includes('--name') || args.includes('-n') || args.includes('--n')) {
14
+ console.log(pkg.name);
15
+ process.exit(0);
16
+ } else if (args.includes('--help') || args.includes('-h') || args.includes('--h')) {
17
+ console.log(pkg.name + ' - ' + pkg.description + '\n');
18
+ console.log(`Usage:
19
+
20
+ mime [flags] [path_or_extension]
21
+
22
+ Flags:
23
+ --help, -h Show this message
24
+ --version, -v Display the version
25
+ --name, -n Print the name of the program
26
+
27
+ Note: the command will exit after it executes if a command is specified
28
+ The path_or_extension is the path to the file or the extension of the file.
29
+
30
+ Examples:
31
+ mime --help
32
+ mime --version
33
+ mime --name
34
+ mime -v
35
+ mime src/log.js
36
+ mime new.py
37
+ mime foo.sh
38
+ `);
39
+ process.exit(0);
40
+ }
41
+
42
+ let file = args[0];
43
+ let type = mime.getType(file);
44
+
45
+ process.stdout.write(type + '\n');
46
+
node_modules/.bin/msw ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ import yargs from 'yargs'
3
+ import { init } from './init.js'
4
+
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
6
+ yargs(process.argv.slice(2))
7
+ .usage('$0 <cmd> [args]')
8
+ .command(
9
+ 'init',
10
+ 'Initializes Mock Service Worker at the specified directory',
11
+ (yargs) => {
12
+ yargs
13
+ .positional('publicDir', {
14
+ type: 'string',
15
+ description: 'Relative path to the public directory',
16
+ demandOption: false,
17
+ normalize: true,
18
+ })
19
+ .option('save', {
20
+ type: 'boolean',
21
+ description: 'Save the worker directory in your package.json',
22
+ })
23
+ .option('cwd', {
24
+ type: 'string',
25
+ description: 'Custom current worker directory',
26
+ normalize: true,
27
+ })
28
+ .example('msw init')
29
+ .example('msw init ./public')
30
+ .example('msw init ./static --save')
31
+ },
32
+ init,
33
+ )
34
+ .demandCommand()
35
+ .help().argv
node_modules/.bin/nanoid ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ let { nanoid, customAlphabet } = require('..')
4
+
5
+ function print(msg) {
6
+ process.stdout.write(msg + '\n')
7
+ }
8
+
9
+ function error(msg) {
10
+ process.stderr.write(msg + '\n')
11
+ process.exit(1)
12
+ }
13
+
14
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
15
+ print(`
16
+ Usage
17
+ $ nanoid [options]
18
+
19
+ Options
20
+ -s, --size Generated ID size
21
+ -a, --alphabet Alphabet to use
22
+ -h, --help Show this help
23
+
24
+ Examples
25
+ $ nanoid --s 15
26
+ S9sBF77U6sDB8Yg
27
+
28
+ $ nanoid --size 10 --alphabet abc
29
+ bcabababca`)
30
+ process.exit()
31
+ }
32
+
33
+ let alphabet, size
34
+ for (let i = 2; i < process.argv.length; i++) {
35
+ let arg = process.argv[i]
36
+ if (arg === '--size' || arg === '-s') {
37
+ size = Number(process.argv[i + 1])
38
+ i += 1
39
+ if (Number.isNaN(size) || size <= 0) {
40
+ error('Size must be positive integer')
41
+ }
42
+ } else if (arg === '--alphabet' || arg === '-a') {
43
+ alphabet = process.argv[i + 1]
44
+ i += 1
45
+ } else {
46
+ error('Unknown argument ' + arg)
47
+ }
48
+ }
49
+
50
+ if (alphabet) {
51
+ let customNanoid = customAlphabet(alphabet, size)
52
+ print(customNanoid())
53
+ } else {
54
+ print(nanoid(size))
55
+ }
node_modules/.bin/node-which ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ var which = require("../")
3
+ if (process.argv.length < 3)
4
+ usage()
5
+
6
+ function usage () {
7
+ console.error('usage: which [-as] program ...')
8
+ process.exit(1)
9
+ }
10
+
11
+ var all = false
12
+ var silent = false
13
+ var dashdash = false
14
+ var args = process.argv.slice(2).filter(function (arg) {
15
+ if (dashdash || !/^-/.test(arg))
16
+ return true
17
+
18
+ if (arg === '--') {
19
+ dashdash = true
20
+ return false
21
+ }
22
+
23
+ var flags = arg.substr(1).split('')
24
+ for (var f = 0; f < flags.length; f++) {
25
+ var flag = flags[f]
26
+ switch (flag) {
27
+ case 's':
28
+ silent = true
29
+ break
30
+ case 'a':
31
+ all = true
32
+ break
33
+ default:
34
+ console.error('which: illegal option -- ' + flag)
35
+ usage()
36
+ }
37
+ }
38
+ return false
39
+ })
40
+
41
+ process.exit(args.reduce(function (pv, current) {
42
+ try {
43
+ var f = which.sync(current, { all: all })
44
+ if (all)
45
+ f = f.join('\n')
46
+ if (!silent)
47
+ console.log(f)
48
+ return pv;
49
+ } catch (e) {
50
+ return 1;
51
+ }
52
+ }, 0))
node_modules/.bin/nodemon ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ const cli = require('../lib/cli');
4
+ const nodemon = require('../lib/');
5
+ const options = cli.parse(process.argv);
6
+
7
+ nodemon(options);
8
+
9
+ const fs = require('fs');
10
+
11
+ // checks for available update and returns an instance
12
+ const pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json'));
13
+
14
+ if (pkg.version.indexOf('0.0.0') !== 0 && options.noUpdateNotifier !== true) {
15
+ require('simple-update-notifier')({ pkg });
16
+ }
node_modules/.bin/nodetouch ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ const touch = require("../index.js")
3
+
4
+ const usage = code => {
5
+ console[code ? 'error' : 'log'](
6
+ 'usage:\n' +
7
+ 'touch [-acfm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...'
8
+ )
9
+ process.exit(code)
10
+ }
11
+
12
+ const singleFlags = {
13
+ a: 'atime',
14
+ m: 'mtime',
15
+ c: 'nocreate',
16
+ f: 'force'
17
+ }
18
+
19
+ const singleOpts = {
20
+ r: 'ref',
21
+ t: 'time'
22
+ }
23
+
24
+ const files = []
25
+ const args = process.argv.slice(2)
26
+ const options = {}
27
+ for (let i = 0; i < args.length; i++) {
28
+ const arg = args[i]
29
+ if (!arg.match(/^-/)) {
30
+ files.push(arg)
31
+ continue
32
+ }
33
+
34
+ // expand shorthands
35
+ if (arg.charAt(1) !== '-') {
36
+ const expand = []
37
+ for (let f = 1; f < arg.length; f++) {
38
+ const fc = arg.charAt(f)
39
+ const sf = singleFlags[fc]
40
+ const so = singleOpts[fc]
41
+ if (sf)
42
+ expand.push('--' + sf)
43
+ else if (so) {
44
+ const soslice = arg.slice(f + 1)
45
+ const soval = soslice.charAt(0) === '=' ? soslice : '=' + soslice
46
+ expand.push('--' + so + soval)
47
+ f = arg.length
48
+ } else if (arg !== '-' + fc)
49
+ expand.push('-' + fc)
50
+ }
51
+ if (expand.length) {
52
+ args.splice.apply(args, [i, 1].concat(expand))
53
+ i--
54
+ continue
55
+ }
56
+ }
57
+
58
+ const argsplit = arg.split('=')
59
+ const key = argsplit.shift().replace(/^\-\-/, '')
60
+ const val = argsplit.length ? argsplit.join('=') : null
61
+
62
+ switch (key) {
63
+ case 'time':
64
+ const timestr = val || args[++i]
65
+ // [-t [[CC]YY]MMDDhhmm[.SS]]
66
+ const parsedtime = timestr.match(
67
+ /^(([0-9]{2})?([0-9]{2}))?([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})(\.([0-9]{2}))?$/
68
+ )
69
+ if (!parsedtime) {
70
+ console.error('touch: out of range or illegal ' +
71
+ 'time specification: ' +
72
+ '[[CC]YY]MMDDhhmm[.SS]')
73
+ process.exit(1)
74
+ } else {
75
+ const y = +parsedtime[1]
76
+ const year = parsedtime[2] ? y
77
+ : y <= 68 ? 2000 + y
78
+ : 1900 + y
79
+
80
+ const MM = +parsedtime[4] - 1
81
+ const dd = +parsedtime[5]
82
+ const hh = +parsedtime[6]
83
+ const mm = +parsedtime[7]
84
+ const ss = +parsedtime[8]
85
+
86
+ options.time = new Date(Date.UTC(year, MM, dd, hh, mm, ss))
87
+ }
88
+ continue
89
+
90
+ case 'ref':
91
+ options.ref = val || args[++i]
92
+ continue
93
+
94
+ case 'mtime':
95
+ case 'nocreate':
96
+ case 'atime':
97
+ case 'force':
98
+ options[key] = true
99
+ continue
100
+
101
+ default:
102
+ console.error('touch: illegal option -- ' + arg)
103
+ usage(1)
104
+ }
105
+ }
106
+
107
+ if (!files.length)
108
+ usage()
109
+
110
+ process.exitCode = 0
111
+ Promise.all(files.map(f => touch(f, options)))
112
+ .catch(er => process.exitCode = 1)
node_modules/.bin/parser ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-var, unicorn/prefer-node-protocol */
3
+
4
+ var parser = require("..");
5
+ var fs = require("fs");
6
+
7
+ var filename = process.argv[2];
8
+ if (!filename) {
9
+ console.error("no filename specified");
10
+ } else {
11
+ var file = fs.readFileSync(filename, "utf8");
12
+ var ast = parser.parse(file);
13
+
14
+ console.log(JSON.stringify(ast, null, " "));
15
+ }
node_modules/.bin/pixelmatch ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-process-exit */
3
+
4
+ 'use strict';
5
+
6
+ const PNG = require('pngjs').PNG;
7
+ const fs = require('fs');
8
+ const match = require('../.');
9
+
10
+ if (process.argv.length < 4) {
11
+ console.log('Usage: pixelmatch image1.png image2.png [diff.png] [threshold] [includeAA]');
12
+ process.exit(64);
13
+ }
14
+
15
+ const [,, img1Path, img2Path, diffPath, threshold, includeAA] = process.argv;
16
+ const options = {};
17
+ if (threshold !== undefined) options.threshold = +threshold;
18
+ if (includeAA !== undefined) options.includeAA = includeAA !== 'false';
19
+
20
+ const img1 = PNG.sync.read(fs.readFileSync(img1Path));
21
+ const img2 = PNG.sync.read(fs.readFileSync(img2Path));
22
+
23
+ const {width, height} = img1;
24
+
25
+ if (img2.width !== width || img2.height !== height) {
26
+ console.log(`Image dimensions do not match: ${width}x${height} vs ${img2.width}x${img2.height}`);
27
+ process.exit(65);
28
+ }
29
+
30
+ const diff = diffPath ? new PNG({width, height}) : null;
31
+
32
+ console.time('matched in');
33
+ const diffs = match(img1.data, img2.data, diff ? diff.data : null, width, height, options);
34
+ console.timeEnd('matched in');
35
+
36
+ console.log(`different pixels: ${diffs}`);
37
+ console.log(`error: ${Math.round(100 * 100 * diffs / (width * height)) / 100}%`);
38
+
39
+ if (diff) {
40
+ fs.writeFileSync(diffPath, PNG.sync.write(diff));
41
+ }
42
+ process.exit(diffs ? 66 : 0);
node_modules/.bin/prebuild-install ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+ const napi = require('napi-build-utils')
6
+
7
+ const pkg = require(path.resolve('package.json'))
8
+ const rc = require('./rc')(pkg)
9
+ const log = require('./log')(rc, process.env)
10
+ const download = require('./download')
11
+ const asset = require('./asset')
12
+ const util = require('./util')
13
+
14
+ const prebuildClientVersion = require('./package.json').version
15
+ if (rc.version) {
16
+ console.log(prebuildClientVersion)
17
+ process.exit(0)
18
+ }
19
+
20
+ if (rc.path) process.chdir(rc.path)
21
+
22
+ if (rc.runtime === 'electron' && rc.target[0] === '4' && rc.abi === '64') {
23
+ log.error(`Electron version ${rc.target} found - skipping prebuild-install work due to known ABI issue`)
24
+ log.error('More information about this issue can be found at https://github.com/lgeiger/node-abi/issues/54')
25
+ process.exit(1)
26
+ }
27
+
28
+ if (!fs.existsSync('package.json')) {
29
+ log.error('setup', 'No package.json found. Aborting...')
30
+ process.exit(1)
31
+ }
32
+
33
+ if (rc.help) {
34
+ console.error(fs.readFileSync(path.join(__dirname, 'help.txt'), 'utf-8'))
35
+ process.exit(0)
36
+ }
37
+
38
+ log.info('begin', 'Prebuild-install version', prebuildClientVersion)
39
+
40
+ const opts = Object.assign({}, rc, { pkg: pkg, log: log })
41
+
42
+ if (napi.isNapiRuntime(rc.runtime)) napi.logUnsupportedVersion(rc.target, log)
43
+
44
+ const origin = util.packageOrigin(process.env, pkg)
45
+
46
+ if (opts.force) {
47
+ log.warn('install', 'prebuilt binaries enforced with --force!')
48
+ log.warn('install', 'prebuilt binaries may be out of date!')
49
+ } else if (origin && origin.length > 4 && origin.substr(0, 4) === 'git+') {
50
+ log.info('install', 'installing from git repository, skipping download.')
51
+ process.exit(1)
52
+ } else if (opts.buildFromSource) {
53
+ log.info('install', '--build-from-source specified, not attempting download.')
54
+ process.exit(1)
55
+ }
56
+
57
+ const startDownload = function (downloadUrl) {
58
+ download(downloadUrl, opts, function (err) {
59
+ if (err) {
60
+ log.warn('install', err.message)
61
+ return process.exit(1)
62
+ }
63
+ log.info('install', 'Successfully installed prebuilt binary!')
64
+ })
65
+ }
66
+
67
+ if (opts.token) {
68
+ asset(opts, function (err, assetId) {
69
+ if (err) {
70
+ log.warn('install', err.message)
71
+ return process.exit(1)
72
+ }
73
+
74
+ startDownload(util.getAssetUrl(opts, assetId))
75
+ })
76
+ } else {
77
+ startDownload(util.getDownloadUrl(opts))
78
+ }
node_modules/.bin/prettier ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __commonJS = function(cb, mod) {
5
+ return function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+ };
9
+
10
+ // node_modules/semver-compare/index.js
11
+ var require_semver_compare = __commonJS({
12
+ "node_modules/semver-compare/index.js": function(exports2, module2) {
13
+ module2.exports = function cmp(a, b) {
14
+ var pa = a.split(".");
15
+ var pb = b.split(".");
16
+ for (var i = 0; i < 3; i++) {
17
+ var na = Number(pa[i]);
18
+ var nb = Number(pb[i]);
19
+ if (na > nb) return 1;
20
+ if (nb > na) return -1;
21
+ if (!isNaN(na) && isNaN(nb)) return 1;
22
+ if (isNaN(na) && !isNaN(nb)) return -1;
23
+ }
24
+ return 0;
25
+ };
26
+ }
27
+ });
28
+
29
+ // node_modules/please-upgrade-node/index.js
30
+ var require_please_upgrade_node = __commonJS({
31
+ "node_modules/please-upgrade-node/index.js": function(exports2, module2) {
32
+ var semverCompare = require_semver_compare();
33
+ module2.exports = function pleaseUpgradeNode2(pkg, opts) {
34
+ var opts = opts || {};
35
+ var requiredVersion = pkg.engines.node.replace(">=", "");
36
+ var currentVersion = process.version.replace("v", "");
37
+ if (semverCompare(currentVersion, requiredVersion) === -1) {
38
+ if (opts.message) {
39
+ console.error(opts.message(requiredVersion));
40
+ } else {
41
+ console.error(
42
+ pkg.name + " requires at least version " + requiredVersion + " of Node, please upgrade"
43
+ );
44
+ }
45
+ if (opts.hasOwnProperty("exitCode")) {
46
+ process.exit(opts.exitCode);
47
+ } else {
48
+ process.exit(1);
49
+ }
50
+ }
51
+ };
52
+ }
53
+ });
54
+
55
+ // bin/prettier.cjs
56
+ var nodeModule = require("module");
57
+ if (typeof nodeModule.enableCompileCache === "function") {
58
+ nodeModule.enableCompileCache();
59
+ }
60
+ var pleaseUpgradeNode = require_please_upgrade_node();
61
+ var packageJson = require("../package.json");
62
+ pleaseUpgradeNode(packageJson);
63
+ var dynamicImport = new Function("module", "return import(module)");
64
+ var promise;
65
+ var index = process.argv.indexOf("--experimental-cli");
66
+ if (process.env.PRETTIER_EXPERIMENTAL_CLI || index !== -1) {
67
+ if (index !== -1) {
68
+ process.argv.splice(index, 1);
69
+ }
70
+ promise = dynamicImport("../internal/experimental-cli.mjs").then(
71
+ function(cli) {
72
+ return cli.__promise;
73
+ }
74
+ );
75
+ } else {
76
+ promise = dynamicImport("../internal/legacy-cli.mjs").then(function runCli(cli) {
77
+ return cli.run();
78
+ });
79
+ }
80
+ module.exports.__promise = promise;
node_modules/.bin/qrcode ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ var yargs = require('yargs')
3
+ var qr = require('../lib')
4
+
5
+ function save (file, text, options) {
6
+ qr.toFile(file, text, options, function (err, data) {
7
+ if (err) {
8
+ console.error('Error:', err.message)
9
+ process.exit(1)
10
+ }
11
+
12
+ console.log('saved qrcode to: ' + file + '\n')
13
+ })
14
+ }
15
+
16
+ function print (text, options) {
17
+ options.type = 'terminal'
18
+ qr.toString(text, options, function (err, text) {
19
+ if (err) {
20
+ console.error('Error:', err.message)
21
+ process.exit(1)
22
+ }
23
+
24
+ console.log(text)
25
+ })
26
+ }
27
+
28
+ function parseOptions (args) {
29
+ return {
30
+ version: args.qversion,
31
+ errorCorrectionLevel: args.error,
32
+ type: args.type,
33
+ small: !!args.small,
34
+ inverse: !!args.inverse,
35
+ maskPattern: args.mask,
36
+ margin: args.qzone,
37
+ width: args.width,
38
+ scale: args.scale,
39
+ color: {
40
+ light: args.lightcolor,
41
+ dark: args.darkcolor
42
+ }
43
+ }
44
+ }
45
+
46
+ function processInputs (text, opts) {
47
+ if (!text.length) {
48
+ yargs.showHelp()
49
+ process.exit(1)
50
+ }
51
+
52
+ if (opts.output) {
53
+ save(opts.output, text, parseOptions(opts))
54
+ } else {
55
+ print(text, parseOptions(opts))
56
+ }
57
+ }
58
+
59
+ var argv = yargs
60
+ .detectLocale(false)
61
+ .usage('Usage: $0 [options] <input string>')
62
+ .option('v', {
63
+ alias: 'qversion',
64
+ description: 'QR Code symbol version (1 - 40)',
65
+ group: 'QR Code options:',
66
+ type: 'number'
67
+ })
68
+ .option('e', {
69
+ alias: 'error',
70
+ description: 'Error correction level',
71
+ choices: ['L', 'M', 'Q', 'H'],
72
+ group: 'QR Code options:'
73
+ })
74
+ .option('m', {
75
+ alias: 'mask',
76
+ description: 'Mask pattern (0 - 7)',
77
+ group: 'QR Code options:',
78
+ type: 'number'
79
+ })
80
+ .option('t', {
81
+ alias: 'type',
82
+ description: 'Output type',
83
+ choices: ['png', 'svg', 'utf8'],
84
+ implies: 'output',
85
+ group: 'Renderer options:'
86
+ })
87
+ .option('i', {
88
+ alias: 'inverse',
89
+ type: 'boolean',
90
+ description: 'Invert colors',
91
+ group: 'Renderer options:'
92
+ })
93
+ .option('w', {
94
+ alias: 'width',
95
+ description: 'Image width (px)',
96
+ conflicts: 'scale',
97
+ group: 'Renderer options:',
98
+ type: 'number'
99
+ })
100
+ .option('s', {
101
+ alias: 'scale',
102
+ description: 'Scale factor',
103
+ conflicts: 'width',
104
+ group: 'Renderer options:',
105
+ type: 'number'
106
+ })
107
+ .option('q', {
108
+ alias: 'qzone',
109
+ description: 'Quiet zone size',
110
+ group: 'Renderer options:',
111
+ type: 'number'
112
+ })
113
+ .option('l', {
114
+ alias: 'lightcolor',
115
+ description: 'Light RGBA hex color',
116
+ group: 'Renderer options:'
117
+ })
118
+ .option('d', {
119
+ alias: 'darkcolor',
120
+ description: 'Dark RGBA hex color',
121
+ group: 'Renderer options:'
122
+ })
123
+ .option('small', {
124
+ type: 'boolean',
125
+ description: 'Output smaller QR code to terminal',
126
+ conflicts: 'type',
127
+ group: 'Renderer options:'
128
+ })
129
+ .option('o', {
130
+ alias: 'output',
131
+ description: 'Output file'
132
+ })
133
+ .help('h')
134
+ .alias('h', 'help')
135
+ .version()
136
+ .example('$0 "some text"', 'Draw in terminal window')
137
+ .example('$0 -o out.png "some text"', 'Save as png image')
138
+ .example('$0 -d F00 -o out.png "some text"', 'Use red as foreground color')
139
+ .parserConfiguration({'parse-numbers': false})
140
+ .argv
141
+
142
+ if (process.stdin.isTTY) {
143
+ processInputs(argv._.join(' '), argv)
144
+ } else {
145
+ var text = ''
146
+ process.stdin.setEncoding('utf8')
147
+ process.stdin.on('readable', function () {
148
+ var chunk = process.stdin.read()
149
+ if (chunk !== null) {
150
+ text += chunk
151
+ }
152
+ })
153
+
154
+ process.stdin.on('end', function () {
155
+ // this process can be run as a command outside of a tty so if there was no
156
+ // data on stdin read from argv
157
+ processInputs(text.length?text:argv._.join(' '), argv)
158
+ })
159
+ }
node_modules/.bin/rc ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #! /usr/bin/env node
2
+ var rc = require('./index')
3
+
4
+ console.log(JSON.stringify(rc(process.argv[2]), false, 2))
node_modules/.bin/rolldown ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.mjs';
node_modules/.bin/rollup ADDED
@@ -0,0 +1,1912 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /*
3
+ @license
4
+ Rollup.js v4.62.0
5
+ Sat, 13 Jun 2026 08:30:18 GMT - commit 5e0066d92defee0097f10fb814e63f60b2a7b612
6
+
7
+ https://github.com/rollup/rollup
8
+
9
+ Released under the MIT License.
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
14
+
15
+ const process$1 = require('node:process');
16
+ const rollup = require('../shared/rollup.js');
17
+ const require$$2 = require('util');
18
+ const require$$0 = require('path');
19
+ const require$$0$1 = require('fs');
20
+ const parseAst_js = require('../shared/parseAst.js');
21
+ const fseventsImporter = require('../shared/fsevents-importer.js');
22
+ const promises = require('node:fs/promises');
23
+ const path = require('node:path');
24
+ const loadConfigFile_js = require('../shared/loadConfigFile.js');
25
+ require('../native.js');
26
+ require('node:perf_hooks');
27
+ require('node:url');
28
+ require('../getLogFilter.js');
29
+
30
+ const help = "rollup version 4.62.0\n=====================================\n\nUsage: rollup [options] <entry file>\n\nOptions:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, Rollup will try to load configuration files in\n the following order:\n rollup.config.mjs -> rollup.config.cjs -> rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-p, --plugin <plugin> Use the plugin specified (may be repeated)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.autoId Generate the AMD ID based off the chunk name\n--amd.basePath <prefix> Path to prepend to auto generated AMD ID\n--amd.define <name> Function to use in place of `define`\n--amd.forceJsExtensionForImports Use `.js` extension in AMD imports\n--amd.id <id> ID for AMD module (default is anonymous)\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--no-dynamicImportInCjs Write external dynamic CommonJS imports as require\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--no-externalImportAttributes Omit import attributes in \"es\" output\n--no-externalLiveBindings Do not generate code to support live bindings\n--failAfterWarnings Exit with an error if the build produced warnings\n--filterLogs <filter> Filter log messages\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--forceExit Force exit the process when done\n--no-freeze Do not freeze namespace objects\n--generatedCode <preset> Which code features to use (es5/es2015)\n--generatedCode.arrowFunctions Use arrow functions in generated code\n--generatedCode.constBindings Use \"const\" in generated code\n--generatedCode.objectShorthand Use shorthand properties in generated code\n--no-generatedCode.reservedNamesAsProps Always quote reserved names as props\n--generatedCode.symbols Use symbols in generated code\n--hashCharacters <name> Use the specified character set for file hashes\n--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks\n--importAttributesKey <name> Use the specified keyword for import attributes\n--no-indent Don't indent result\n--inlineDynamicImports Create single bundle when using dynamic imports\n--no-interop Do not include interop block\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--logLevel <level> Which kind of logs to display\n--no-makeAbsoluteExternalsRelative Prevent normalization of external imports\n--maxParallelFileOps <value> How many files to read in parallel\n--minifyInternalExports Force or disable minification of internal exports\n--noConflict Generate a noConflict method for UMD globals\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--perf Display performance timings\n--no-preserveEntrySignatures Avoid facade chunks for entry points\n--preserveModules Preserve module structure\n--preserveModulesRoot Put preserved modules under this path at root level\n--preserveSymlinks Do not follow symlinks when resolving files\n--no-reexportProtoFromExternal Ignore `__proto__` in star re-exports\n--no-sanitizeFileName Do not replace invalid characters in file names\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base\n--sourcemapDebugIds Emit unique debug ids in source and sourcemaps\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--sourcemapFileNames <pattern> Name pattern for emitted sourcemaps\n--stdin=ext Specify file extension used for stdin input\n--no-stdin Do not read \"-\" from stdin\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--strictDeprecations Throw errors for deprecated features\n--no-systemNullSetters Do not replace empty SystemJS setters with `null`\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared\n--treeshake.manualPureFunctions <names> Manually declare functions as pure\n--no-treeshake.moduleSideEffects Assume modules have no side effects\n--no-treeshake.propertyReadSideEffects Ignore property access side effects\n--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking\n--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw\n--validate Validate output\n--waitForBundleInput Wait for bundle input files\n--watch.allowInputInsideOutputPath Whether the input path is allowed to be a\n subpath of the output path\n--watch.buildDelay <number> Throttle watch rebuilds\n--no-watch.clearScreen Do not clear the screen when rebuilding\n--watch.exclude <files> Exclude files from being watched\n--watch.include <files> Limit watching to specified files\n--watch.onBundleEnd <cmd> Shell command to run on `\"BUNDLE_END\"` event\n--watch.onBundleStart <cmd> Shell command to run on `\"BUNDLE_START\"` event\n--watch.onEnd <cmd> Shell command to run on `\"END\"` event\n--watch.onError <cmd> Shell command to run on `\"ERROR\"` event\n--watch.onStart <cmd> Shell command to run on `\"START\"` event\n--watch.skipWrite Do not write files to disk when watching\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
31
+
32
+ /**
33
+ * @license
34
+ * Copyright (c) 2016, Contributors
35
+ * SPDX-License-Identifier: ISC
36
+ */
37
+ function camelCase(str) {
38
+ // Handle the case where an argument is provided as camel case, e.g., fooBar.
39
+ // by ensuring that the string isn't already mixed case:
40
+ const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
41
+ if (!isCamelCase) {
42
+ str = str.toLowerCase();
43
+ }
44
+ if (str.indexOf('-') === -1 && str.indexOf('_') === -1) {
45
+ return str;
46
+ }
47
+ else {
48
+ let camelcase = '';
49
+ let nextChrUpper = false;
50
+ const leadingHyphens = str.match(/^-+/);
51
+ for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
52
+ let chr = str.charAt(i);
53
+ if (nextChrUpper) {
54
+ nextChrUpper = false;
55
+ chr = chr.toUpperCase();
56
+ }
57
+ if (i !== 0 && (chr === '-' || chr === '_')) {
58
+ nextChrUpper = true;
59
+ }
60
+ else if (chr !== '-' && chr !== '_') {
61
+ camelcase += chr;
62
+ }
63
+ }
64
+ return camelcase;
65
+ }
66
+ }
67
+ function decamelize(str, joinString) {
68
+ const lowercase = str.toLowerCase();
69
+ joinString = joinString || '-';
70
+ let notCamelcase = '';
71
+ for (let i = 0; i < str.length; i++) {
72
+ const chrLower = lowercase.charAt(i);
73
+ const chrString = str.charAt(i);
74
+ if (chrLower !== chrString && i > 0) {
75
+ notCamelcase += `${joinString}${lowercase.charAt(i)}`;
76
+ }
77
+ else {
78
+ notCamelcase += chrString;
79
+ }
80
+ }
81
+ return notCamelcase;
82
+ }
83
+ function looksLikeNumber(x) {
84
+ if (x === null || x === undefined)
85
+ return false;
86
+ // if loaded from config, may already be a number.
87
+ if (typeof x === 'number')
88
+ return true;
89
+ // hexadecimal.
90
+ if (/^0x[0-9a-f]+$/i.test(x))
91
+ return true;
92
+ // don't treat 0123 as a number; as it drops the leading '0'.
93
+ if (/^0[^.]/.test(x))
94
+ return false;
95
+ return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
96
+ }
97
+
98
+ /**
99
+ * @license
100
+ * Copyright (c) 2016, Contributors
101
+ * SPDX-License-Identifier: ISC
102
+ */
103
+ // take an un-split argv string and tokenize it.
104
+ function tokenizeArgString(argString) {
105
+ if (Array.isArray(argString)) {
106
+ return argString.map(e => typeof e !== 'string' ? e + '' : e);
107
+ }
108
+ argString = argString.trim();
109
+ let i = 0;
110
+ let prevC = null;
111
+ let c = null;
112
+ let opening = null;
113
+ const args = [];
114
+ for (let ii = 0; ii < argString.length; ii++) {
115
+ prevC = c;
116
+ c = argString.charAt(ii);
117
+ // split on spaces unless we're in quotes.
118
+ if (c === ' ' && !opening) {
119
+ if (!(prevC === ' ')) {
120
+ i++;
121
+ }
122
+ continue;
123
+ }
124
+ // don't split the string if we're in matching
125
+ // opening or closing single and double quotes.
126
+ if (c === opening) {
127
+ opening = null;
128
+ }
129
+ else if ((c === "'" || c === '"') && !opening) {
130
+ opening = c;
131
+ }
132
+ if (!args[i])
133
+ args[i] = '';
134
+ args[i] += c;
135
+ }
136
+ return args;
137
+ }
138
+
139
+ /**
140
+ * @license
141
+ * Copyright (c) 2016, Contributors
142
+ * SPDX-License-Identifier: ISC
143
+ */
144
+ var DefaultValuesForTypeKey;
145
+ (function (DefaultValuesForTypeKey) {
146
+ DefaultValuesForTypeKey["BOOLEAN"] = "boolean";
147
+ DefaultValuesForTypeKey["STRING"] = "string";
148
+ DefaultValuesForTypeKey["NUMBER"] = "number";
149
+ DefaultValuesForTypeKey["ARRAY"] = "array";
150
+ })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
151
+
152
+ /**
153
+ * @license
154
+ * Copyright (c) 2016, Contributors
155
+ * SPDX-License-Identifier: ISC
156
+ */
157
+ let mixin;
158
+ class YargsParser {
159
+ constructor(_mixin) {
160
+ mixin = _mixin;
161
+ }
162
+ parse(argsInput, options) {
163
+ const opts = Object.assign({
164
+ alias: undefined,
165
+ array: undefined,
166
+ boolean: undefined,
167
+ config: undefined,
168
+ configObjects: undefined,
169
+ configuration: undefined,
170
+ coerce: undefined,
171
+ count: undefined,
172
+ default: undefined,
173
+ envPrefix: undefined,
174
+ narg: undefined,
175
+ normalize: undefined,
176
+ string: undefined,
177
+ number: undefined,
178
+ __: undefined,
179
+ key: undefined
180
+ }, options);
181
+ // allow a string argument to be passed in rather
182
+ // than an argv array.
183
+ const args = tokenizeArgString(argsInput);
184
+ // tokenizeArgString adds extra quotes to args if argsInput is a string
185
+ // only strip those extra quotes in processValue if argsInput is a string
186
+ const inputIsString = typeof argsInput === 'string';
187
+ // aliases might have transitive relationships, normalize this.
188
+ const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
189
+ const configuration = Object.assign({
190
+ 'boolean-negation': true,
191
+ 'camel-case-expansion': true,
192
+ 'combine-arrays': false,
193
+ 'dot-notation': true,
194
+ 'duplicate-arguments-array': true,
195
+ 'flatten-duplicate-arrays': true,
196
+ 'greedy-arrays': true,
197
+ 'halt-at-non-option': false,
198
+ 'nargs-eats-options': false,
199
+ 'negation-prefix': 'no-',
200
+ 'parse-numbers': true,
201
+ 'parse-positional-numbers': true,
202
+ 'populate--': false,
203
+ 'set-placeholder-key': false,
204
+ 'short-option-groups': true,
205
+ 'strip-aliased': false,
206
+ 'strip-dashed': false,
207
+ 'unknown-options-as-args': false
208
+ }, opts.configuration);
209
+ const defaults = Object.assign(Object.create(null), opts.default);
210
+ const configObjects = opts.configObjects || [];
211
+ const envPrefix = opts.envPrefix;
212
+ const notFlagsOption = configuration['populate--'];
213
+ const notFlagsArgv = notFlagsOption ? '--' : '_';
214
+ const newAliases = Object.create(null);
215
+ const defaulted = Object.create(null);
216
+ // allow a i18n handler to be passed in, default to a fake one (util.format).
217
+ const __ = opts.__ || mixin.format;
218
+ const flags = {
219
+ aliases: Object.create(null),
220
+ arrays: Object.create(null),
221
+ bools: Object.create(null),
222
+ strings: Object.create(null),
223
+ numbers: Object.create(null),
224
+ counts: Object.create(null),
225
+ normalize: Object.create(null),
226
+ configs: Object.create(null),
227
+ nargs: Object.create(null),
228
+ coercions: Object.create(null),
229
+ keys: []
230
+ };
231
+ const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
232
+ const negatedBoolean = new RegExp('^--' + configuration['negation-prefix'] + '(.+)');
233
+ [].concat(opts.array || []).filter(Boolean).forEach(function (opt) {
234
+ const key = typeof opt === 'object' ? opt.key : opt;
235
+ // assign to flags[bools|strings|numbers]
236
+ const assignment = Object.keys(opt).map(function (key) {
237
+ const arrayFlagKeys = {
238
+ boolean: 'bools',
239
+ string: 'strings',
240
+ number: 'numbers'
241
+ };
242
+ return arrayFlagKeys[key];
243
+ }).filter(Boolean).pop();
244
+ // assign key to be coerced
245
+ if (assignment) {
246
+ flags[assignment][key] = true;
247
+ }
248
+ flags.arrays[key] = true;
249
+ flags.keys.push(key);
250
+ });
251
+ [].concat(opts.boolean || []).filter(Boolean).forEach(function (key) {
252
+ flags.bools[key] = true;
253
+ flags.keys.push(key);
254
+ });
255
+ [].concat(opts.string || []).filter(Boolean).forEach(function (key) {
256
+ flags.strings[key] = true;
257
+ flags.keys.push(key);
258
+ });
259
+ [].concat(opts.number || []).filter(Boolean).forEach(function (key) {
260
+ flags.numbers[key] = true;
261
+ flags.keys.push(key);
262
+ });
263
+ [].concat(opts.count || []).filter(Boolean).forEach(function (key) {
264
+ flags.counts[key] = true;
265
+ flags.keys.push(key);
266
+ });
267
+ [].concat(opts.normalize || []).filter(Boolean).forEach(function (key) {
268
+ flags.normalize[key] = true;
269
+ flags.keys.push(key);
270
+ });
271
+ if (typeof opts.narg === 'object') {
272
+ Object.entries(opts.narg).forEach(([key, value]) => {
273
+ if (typeof value === 'number') {
274
+ flags.nargs[key] = value;
275
+ flags.keys.push(key);
276
+ }
277
+ });
278
+ }
279
+ if (typeof opts.coerce === 'object') {
280
+ Object.entries(opts.coerce).forEach(([key, value]) => {
281
+ if (typeof value === 'function') {
282
+ flags.coercions[key] = value;
283
+ flags.keys.push(key);
284
+ }
285
+ });
286
+ }
287
+ if (typeof opts.config !== 'undefined') {
288
+ if (Array.isArray(opts.config) || typeof opts.config === 'string') {
289
+ [].concat(opts.config).filter(Boolean).forEach(function (key) {
290
+ flags.configs[key] = true;
291
+ });
292
+ }
293
+ else if (typeof opts.config === 'object') {
294
+ Object.entries(opts.config).forEach(([key, value]) => {
295
+ if (typeof value === 'boolean' || typeof value === 'function') {
296
+ flags.configs[key] = value;
297
+ }
298
+ });
299
+ }
300
+ }
301
+ // create a lookup table that takes into account all
302
+ // combinations of aliases: {f: ['foo'], foo: ['f']}
303
+ extendAliases(opts.key, aliases, opts.default, flags.arrays);
304
+ // apply default values to all aliases.
305
+ Object.keys(defaults).forEach(function (key) {
306
+ (flags.aliases[key] || []).forEach(function (alias) {
307
+ defaults[alias] = defaults[key];
308
+ });
309
+ });
310
+ let error = null;
311
+ checkConfiguration();
312
+ let notFlags = [];
313
+ const argv = Object.assign(Object.create(null), { _: [] });
314
+ // TODO(bcoe): for the first pass at removing object prototype we didn't
315
+ // remove all prototypes from objects returned by this API, we might want
316
+ // to gradually move towards doing so.
317
+ const argvReturn = {};
318
+ for (let i = 0; i < args.length; i++) {
319
+ const arg = args[i];
320
+ const truncatedArg = arg.replace(/^-{3,}/, '---');
321
+ let broken;
322
+ let key;
323
+ let letters;
324
+ let m;
325
+ let next;
326
+ let value;
327
+ // any unknown option (except for end-of-options, "--")
328
+ if (arg !== '--' && /^-/.test(arg) && isUnknownOptionAsArg(arg)) {
329
+ pushPositional(arg);
330
+ // ---, ---=, ----, etc,
331
+ }
332
+ else if (truncatedArg.match(/^---+(=|$)/)) {
333
+ // options without key name are invalid.
334
+ pushPositional(arg);
335
+ continue;
336
+ // -- separated by =
337
+ }
338
+ else if (arg.match(/^--.+=/) || (!configuration['short-option-groups'] && arg.match(/^-.+=/))) {
339
+ // Using [\s\S] instead of . because js doesn't support the
340
+ // 'dotall' regex modifier. See:
341
+ // http://stackoverflow.com/a/1068308/13216
342
+ m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
343
+ // arrays format = '--f=a b c'
344
+ if (m !== null && Array.isArray(m) && m.length >= 3) {
345
+ if (checkAllAliases(m[1], flags.arrays)) {
346
+ i = eatArray(i, m[1], args, m[2]);
347
+ }
348
+ else if (checkAllAliases(m[1], flags.nargs) !== false) {
349
+ // nargs format = '--f=monkey washing cat'
350
+ i = eatNargs(i, m[1], args, m[2]);
351
+ }
352
+ else {
353
+ setArg(m[1], m[2], true);
354
+ }
355
+ }
356
+ }
357
+ else if (arg.match(negatedBoolean) && configuration['boolean-negation']) {
358
+ m = arg.match(negatedBoolean);
359
+ if (m !== null && Array.isArray(m) && m.length >= 2) {
360
+ key = m[1];
361
+ setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
362
+ }
363
+ // -- separated by space.
364
+ }
365
+ else if (arg.match(/^--.+/) || (!configuration['short-option-groups'] && arg.match(/^-[^-]+/))) {
366
+ m = arg.match(/^--?(.+)/);
367
+ if (m !== null && Array.isArray(m) && m.length >= 2) {
368
+ key = m[1];
369
+ if (checkAllAliases(key, flags.arrays)) {
370
+ // array format = '--foo a b c'
371
+ i = eatArray(i, key, args);
372
+ }
373
+ else if (checkAllAliases(key, flags.nargs) !== false) {
374
+ // nargs format = '--foo a b c'
375
+ // should be truthy even if: flags.nargs[key] === 0
376
+ i = eatNargs(i, key, args);
377
+ }
378
+ else {
379
+ next = args[i + 1];
380
+ if (next !== undefined && (!next.match(/^-/) ||
381
+ next.match(negative)) &&
382
+ !checkAllAliases(key, flags.bools) &&
383
+ !checkAllAliases(key, flags.counts)) {
384
+ setArg(key, next);
385
+ i++;
386
+ }
387
+ else if (/^(true|false)$/.test(next)) {
388
+ setArg(key, next);
389
+ i++;
390
+ }
391
+ else {
392
+ setArg(key, defaultValue(key));
393
+ }
394
+ }
395
+ }
396
+ // dot-notation flag separated by '='.
397
+ }
398
+ else if (arg.match(/^-.\..+=/)) {
399
+ m = arg.match(/^-([^=]+)=([\s\S]*)$/);
400
+ if (m !== null && Array.isArray(m) && m.length >= 3) {
401
+ setArg(m[1], m[2]);
402
+ }
403
+ // dot-notation flag separated by space.
404
+ }
405
+ else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
406
+ next = args[i + 1];
407
+ m = arg.match(/^-(.\..+)/);
408
+ if (m !== null && Array.isArray(m) && m.length >= 2) {
409
+ key = m[1];
410
+ if (next !== undefined && !next.match(/^-/) &&
411
+ !checkAllAliases(key, flags.bools) &&
412
+ !checkAllAliases(key, flags.counts)) {
413
+ setArg(key, next);
414
+ i++;
415
+ }
416
+ else {
417
+ setArg(key, defaultValue(key));
418
+ }
419
+ }
420
+ }
421
+ else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
422
+ letters = arg.slice(1, -1).split('');
423
+ broken = false;
424
+ for (let j = 0; j < letters.length; j++) {
425
+ next = arg.slice(j + 2);
426
+ if (letters[j + 1] && letters[j + 1] === '=') {
427
+ value = arg.slice(j + 3);
428
+ key = letters[j];
429
+ if (checkAllAliases(key, flags.arrays)) {
430
+ // array format = '-f=a b c'
431
+ i = eatArray(i, key, args, value);
432
+ }
433
+ else if (checkAllAliases(key, flags.nargs) !== false) {
434
+ // nargs format = '-f=monkey washing cat'
435
+ i = eatNargs(i, key, args, value);
436
+ }
437
+ else {
438
+ setArg(key, value);
439
+ }
440
+ broken = true;
441
+ break;
442
+ }
443
+ if (next === '-') {
444
+ setArg(letters[j], next);
445
+ continue;
446
+ }
447
+ // current letter is an alphabetic character and next value is a number
448
+ if (/[A-Za-z]/.test(letters[j]) &&
449
+ /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) &&
450
+ checkAllAliases(next, flags.bools) === false) {
451
+ setArg(letters[j], next);
452
+ broken = true;
453
+ break;
454
+ }
455
+ if (letters[j + 1] && letters[j + 1].match(/\W/)) {
456
+ setArg(letters[j], next);
457
+ broken = true;
458
+ break;
459
+ }
460
+ else {
461
+ setArg(letters[j], defaultValue(letters[j]));
462
+ }
463
+ }
464
+ key = arg.slice(-1)[0];
465
+ if (!broken && key !== '-') {
466
+ if (checkAllAliases(key, flags.arrays)) {
467
+ // array format = '-f a b c'
468
+ i = eatArray(i, key, args);
469
+ }
470
+ else if (checkAllAliases(key, flags.nargs) !== false) {
471
+ // nargs format = '-f a b c'
472
+ // should be truthy even if: flags.nargs[key] === 0
473
+ i = eatNargs(i, key, args);
474
+ }
475
+ else {
476
+ next = args[i + 1];
477
+ if (next !== undefined && (!/^(-|--)[^-]/.test(next) ||
478
+ next.match(negative)) &&
479
+ !checkAllAliases(key, flags.bools) &&
480
+ !checkAllAliases(key, flags.counts)) {
481
+ setArg(key, next);
482
+ i++;
483
+ }
484
+ else if (/^(true|false)$/.test(next)) {
485
+ setArg(key, next);
486
+ i++;
487
+ }
488
+ else {
489
+ setArg(key, defaultValue(key));
490
+ }
491
+ }
492
+ }
493
+ }
494
+ else if (arg.match(/^-[0-9]$/) &&
495
+ arg.match(negative) &&
496
+ checkAllAliases(arg.slice(1), flags.bools)) {
497
+ // single-digit boolean alias, e.g: xargs -0
498
+ key = arg.slice(1);
499
+ setArg(key, defaultValue(key));
500
+ }
501
+ else if (arg === '--') {
502
+ notFlags = args.slice(i + 1);
503
+ break;
504
+ }
505
+ else if (configuration['halt-at-non-option']) {
506
+ notFlags = args.slice(i);
507
+ break;
508
+ }
509
+ else {
510
+ pushPositional(arg);
511
+ }
512
+ }
513
+ // order of precedence:
514
+ // 1. command line arg
515
+ // 2. value from env var
516
+ // 3. value from config file
517
+ // 4. value from config objects
518
+ // 5. configured default value
519
+ applyEnvVars(argv, true); // special case: check env vars that point to config file
520
+ applyEnvVars(argv, false);
521
+ setConfig(argv);
522
+ setConfigObjects();
523
+ applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
524
+ applyCoercions(argv);
525
+ if (configuration['set-placeholder-key'])
526
+ setPlaceholderKeys(argv);
527
+ // for any counts either not in args or without an explicit default, set to 0
528
+ Object.keys(flags.counts).forEach(function (key) {
529
+ if (!hasKey(argv, key.split('.')))
530
+ setArg(key, 0);
531
+ });
532
+ // '--' defaults to undefined.
533
+ if (notFlagsOption && notFlags.length)
534
+ argv[notFlagsArgv] = [];
535
+ notFlags.forEach(function (key) {
536
+ argv[notFlagsArgv].push(key);
537
+ });
538
+ if (configuration['camel-case-expansion'] && configuration['strip-dashed']) {
539
+ Object.keys(argv).filter(key => key !== '--' && key.includes('-')).forEach(key => {
540
+ delete argv[key];
541
+ });
542
+ }
543
+ if (configuration['strip-aliased']) {
544
+ [].concat(...Object.keys(aliases).map(k => aliases[k])).forEach(alias => {
545
+ if (configuration['camel-case-expansion'] && alias.includes('-')) {
546
+ delete argv[alias.split('.').map(prop => camelCase(prop)).join('.')];
547
+ }
548
+ delete argv[alias];
549
+ });
550
+ }
551
+ // Push argument into positional array, applying numeric coercion:
552
+ function pushPositional(arg) {
553
+ const maybeCoercedNumber = maybeCoerceNumber('_', arg);
554
+ if (typeof maybeCoercedNumber === 'string' || typeof maybeCoercedNumber === 'number') {
555
+ argv._.push(maybeCoercedNumber);
556
+ }
557
+ }
558
+ // how many arguments should we consume, based
559
+ // on the nargs option?
560
+ function eatNargs(i, key, args, argAfterEqualSign) {
561
+ let ii;
562
+ let toEat = checkAllAliases(key, flags.nargs);
563
+ // NaN has a special meaning for the array type, indicating that one or
564
+ // more values are expected.
565
+ toEat = typeof toEat !== 'number' || isNaN(toEat) ? 1 : toEat;
566
+ if (toEat === 0) {
567
+ if (!isUndefined(argAfterEqualSign)) {
568
+ error = Error(__('Argument unexpected for: %s', key));
569
+ }
570
+ setArg(key, defaultValue(key));
571
+ return i;
572
+ }
573
+ let available = isUndefined(argAfterEqualSign) ? 0 : 1;
574
+ if (configuration['nargs-eats-options']) {
575
+ // classic behavior, yargs eats positional and dash arguments.
576
+ if (args.length - (i + 1) + available < toEat) {
577
+ error = Error(__('Not enough arguments following: %s', key));
578
+ }
579
+ available = toEat;
580
+ }
581
+ else {
582
+ // nargs will not consume flag arguments, e.g., -abc, --foo,
583
+ // and terminates when one is observed.
584
+ for (ii = i + 1; ii < args.length; ii++) {
585
+ if (!args[ii].match(/^-[^0-9]/) || args[ii].match(negative) || isUnknownOptionAsArg(args[ii]))
586
+ available++;
587
+ else
588
+ break;
589
+ }
590
+ if (available < toEat)
591
+ error = Error(__('Not enough arguments following: %s', key));
592
+ }
593
+ let consumed = Math.min(available, toEat);
594
+ if (!isUndefined(argAfterEqualSign) && consumed > 0) {
595
+ setArg(key, argAfterEqualSign);
596
+ consumed--;
597
+ }
598
+ for (ii = i + 1; ii < (consumed + i + 1); ii++) {
599
+ setArg(key, args[ii]);
600
+ }
601
+ return (i + consumed);
602
+ }
603
+ // if an option is an array, eat all non-hyphenated arguments
604
+ // following it... YUM!
605
+ // e.g., --foo apple banana cat becomes ["apple", "banana", "cat"]
606
+ function eatArray(i, key, args, argAfterEqualSign) {
607
+ let argsToSet = [];
608
+ let next = argAfterEqualSign || args[i + 1];
609
+ // If both array and nargs are configured, enforce the nargs count:
610
+ const nargsCount = checkAllAliases(key, flags.nargs);
611
+ if (checkAllAliases(key, flags.bools) && !(/^(true|false)$/.test(next))) {
612
+ argsToSet.push(true);
613
+ }
614
+ else if (isUndefined(next) ||
615
+ (isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))) {
616
+ // for keys without value ==> argsToSet remains an empty []
617
+ // set user default value, if available
618
+ if (defaults[key] !== undefined) {
619
+ const defVal = defaults[key];
620
+ argsToSet = Array.isArray(defVal) ? defVal : [defVal];
621
+ }
622
+ }
623
+ else {
624
+ // value in --option=value is eaten as is
625
+ if (!isUndefined(argAfterEqualSign)) {
626
+ argsToSet.push(processValue(key, argAfterEqualSign, true));
627
+ }
628
+ for (let ii = i + 1; ii < args.length; ii++) {
629
+ if ((!configuration['greedy-arrays'] && argsToSet.length > 0) ||
630
+ (nargsCount && typeof nargsCount === 'number' && argsToSet.length >= nargsCount))
631
+ break;
632
+ next = args[ii];
633
+ if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))
634
+ break;
635
+ i = ii;
636
+ argsToSet.push(processValue(key, next, inputIsString));
637
+ }
638
+ }
639
+ // If both array and nargs are configured, create an error if less than
640
+ // nargs positionals were found. NaN has special meaning, indicating
641
+ // that at least one value is required (more are okay).
642
+ if (typeof nargsCount === 'number' && ((nargsCount && argsToSet.length < nargsCount) ||
643
+ (isNaN(nargsCount) && argsToSet.length === 0))) {
644
+ error = Error(__('Not enough arguments following: %s', key));
645
+ }
646
+ setArg(key, argsToSet);
647
+ return i;
648
+ }
649
+ function setArg(key, val, shouldStripQuotes = inputIsString) {
650
+ if (/-/.test(key) && configuration['camel-case-expansion']) {
651
+ const alias = key.split('.').map(function (prop) {
652
+ return camelCase(prop);
653
+ }).join('.');
654
+ addNewAlias(key, alias);
655
+ }
656
+ const value = processValue(key, val, shouldStripQuotes);
657
+ const splitKey = key.split('.');
658
+ setKey(argv, splitKey, value);
659
+ // handle populating aliases of the full key
660
+ if (flags.aliases[key]) {
661
+ flags.aliases[key].forEach(function (x) {
662
+ const keyProperties = x.split('.');
663
+ setKey(argv, keyProperties, value);
664
+ });
665
+ }
666
+ // handle populating aliases of the first element of the dot-notation key
667
+ if (splitKey.length > 1 && configuration['dot-notation']) {
668
+ (flags.aliases[splitKey[0]] || []).forEach(function (x) {
669
+ let keyProperties = x.split('.');
670
+ // expand alias with nested objects in key
671
+ const a = [].concat(splitKey);
672
+ a.shift(); // nuke the old key.
673
+ keyProperties = keyProperties.concat(a);
674
+ // populate alias only if is not already an alias of the full key
675
+ // (already populated above)
676
+ if (!(flags.aliases[key] || []).includes(keyProperties.join('.'))) {
677
+ setKey(argv, keyProperties, value);
678
+ }
679
+ });
680
+ }
681
+ // Set normalize getter and setter when key is in 'normalize' but isn't an array
682
+ if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
683
+ const keys = [key].concat(flags.aliases[key] || []);
684
+ keys.forEach(function (key) {
685
+ Object.defineProperty(argvReturn, key, {
686
+ enumerable: true,
687
+ get() {
688
+ return val;
689
+ },
690
+ set(value) {
691
+ val = typeof value === 'string' ? mixin.normalize(value) : value;
692
+ }
693
+ });
694
+ });
695
+ }
696
+ }
697
+ function addNewAlias(key, alias) {
698
+ if (!(flags.aliases[key] && flags.aliases[key].length)) {
699
+ flags.aliases[key] = [alias];
700
+ newAliases[alias] = true;
701
+ }
702
+ if (!(flags.aliases[alias] && flags.aliases[alias].length)) {
703
+ addNewAlias(alias, key);
704
+ }
705
+ }
706
+ function processValue(key, val, shouldStripQuotes) {
707
+ // strings may be quoted, clean this up as we assign values.
708
+ if (shouldStripQuotes) {
709
+ val = stripQuotes(val);
710
+ }
711
+ // handle parsing boolean arguments --foo=true --bar false.
712
+ if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
713
+ if (typeof val === 'string')
714
+ val = val === 'true';
715
+ }
716
+ let value = Array.isArray(val)
717
+ ? val.map(function (v) { return maybeCoerceNumber(key, v); })
718
+ : maybeCoerceNumber(key, val);
719
+ // increment a count given as arg (either no value or value parsed as boolean)
720
+ if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) {
721
+ value = increment();
722
+ }
723
+ // Set normalized value when key is in 'normalize' and in 'arrays'
724
+ if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
725
+ if (Array.isArray(val))
726
+ value = val.map((val) => { return mixin.normalize(val); });
727
+ else
728
+ value = mixin.normalize(val);
729
+ }
730
+ return value;
731
+ }
732
+ function maybeCoerceNumber(key, value) {
733
+ if (!configuration['parse-positional-numbers'] && key === '_')
734
+ return value;
735
+ if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
736
+ const shouldCoerceNumber = looksLikeNumber(value) && configuration['parse-numbers'] && (Number.isSafeInteger(Math.floor(parseFloat(`${value}`))));
737
+ if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) {
738
+ value = Number(value);
739
+ }
740
+ }
741
+ return value;
742
+ }
743
+ // set args from config.json file, this should be
744
+ // applied last so that defaults can be applied.
745
+ function setConfig(argv) {
746
+ const configLookup = Object.create(null);
747
+ // expand defaults/aliases, in-case any happen to reference
748
+ // the config.json file.
749
+ applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
750
+ Object.keys(flags.configs).forEach(function (configKey) {
751
+ const configPath = argv[configKey] || configLookup[configKey];
752
+ if (configPath) {
753
+ try {
754
+ let config = null;
755
+ const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
756
+ const resolveConfig = flags.configs[configKey];
757
+ if (typeof resolveConfig === 'function') {
758
+ try {
759
+ config = resolveConfig(resolvedConfigPath);
760
+ }
761
+ catch (e) {
762
+ config = e;
763
+ }
764
+ if (config instanceof Error) {
765
+ error = config;
766
+ return;
767
+ }
768
+ }
769
+ else {
770
+ config = mixin.require(resolvedConfigPath);
771
+ }
772
+ setConfigObject(config);
773
+ }
774
+ catch (ex) {
775
+ // Deno will receive a PermissionDenied error if an attempt is
776
+ // made to load config without the --allow-read flag:
777
+ if (ex.name === 'PermissionDenied')
778
+ error = ex;
779
+ else if (argv[configKey])
780
+ error = Error(__('Invalid JSON config file: %s', configPath));
781
+ }
782
+ }
783
+ });
784
+ }
785
+ // set args from config object.
786
+ // it recursively checks nested objects.
787
+ function setConfigObject(config, prev) {
788
+ Object.keys(config).forEach(function (key) {
789
+ const value = config[key];
790
+ const fullKey = prev ? prev + '.' + key : key;
791
+ // if the value is an inner object and we have dot-notation
792
+ // enabled, treat inner objects in config the same as
793
+ // heavily nested dot notations (foo.bar.apple).
794
+ if (typeof value === 'object' && value !== null && !Array.isArray(value) && configuration['dot-notation']) {
795
+ // if the value is an object but not an array, check nested object
796
+ setConfigObject(value, fullKey);
797
+ }
798
+ else {
799
+ // setting arguments via CLI takes precedence over
800
+ // values within the config file.
801
+ if (!hasKey(argv, fullKey.split('.')) || (checkAllAliases(fullKey, flags.arrays) && configuration['combine-arrays'])) {
802
+ setArg(fullKey, value);
803
+ }
804
+ }
805
+ });
806
+ }
807
+ // set all config objects passed in opts
808
+ function setConfigObjects() {
809
+ if (typeof configObjects !== 'undefined') {
810
+ configObjects.forEach(function (configObject) {
811
+ setConfigObject(configObject);
812
+ });
813
+ }
814
+ }
815
+ function applyEnvVars(argv, configOnly) {
816
+ if (typeof envPrefix === 'undefined')
817
+ return;
818
+ const prefix = typeof envPrefix === 'string' ? envPrefix : '';
819
+ const env = mixin.env();
820
+ Object.keys(env).forEach(function (envVar) {
821
+ if (prefix === '' || envVar.lastIndexOf(prefix, 0) === 0) {
822
+ // get array of nested keys and convert them to camel case
823
+ const keys = envVar.split('__').map(function (key, i) {
824
+ if (i === 0) {
825
+ key = key.substring(prefix.length);
826
+ }
827
+ return camelCase(key);
828
+ });
829
+ if (((configOnly && flags.configs[keys.join('.')]) || !configOnly) && !hasKey(argv, keys)) {
830
+ setArg(keys.join('.'), env[envVar]);
831
+ }
832
+ }
833
+ });
834
+ }
835
+ function applyCoercions(argv) {
836
+ let coerce;
837
+ const applied = new Set();
838
+ Object.keys(argv).forEach(function (key) {
839
+ if (!applied.has(key)) { // If we haven't already coerced this option via one of its aliases
840
+ coerce = checkAllAliases(key, flags.coercions);
841
+ if (typeof coerce === 'function') {
842
+ try {
843
+ const value = maybeCoerceNumber(key, coerce(argv[key]));
844
+ ([].concat(flags.aliases[key] || [], key)).forEach(ali => {
845
+ applied.add(ali);
846
+ argv[ali] = value;
847
+ });
848
+ }
849
+ catch (err) {
850
+ error = err;
851
+ }
852
+ }
853
+ }
854
+ });
855
+ }
856
+ function setPlaceholderKeys(argv) {
857
+ flags.keys.forEach((key) => {
858
+ // don't set placeholder keys for dot notation options 'foo.bar'.
859
+ if (~key.indexOf('.'))
860
+ return;
861
+ if (typeof argv[key] === 'undefined')
862
+ argv[key] = undefined;
863
+ });
864
+ return argv;
865
+ }
866
+ function applyDefaultsAndAliases(obj, aliases, defaults, canLog = false) {
867
+ Object.keys(defaults).forEach(function (key) {
868
+ if (!hasKey(obj, key.split('.'))) {
869
+ setKey(obj, key.split('.'), defaults[key]);
870
+ if (canLog)
871
+ defaulted[key] = true;
872
+ (aliases[key] || []).forEach(function (x) {
873
+ if (hasKey(obj, x.split('.')))
874
+ return;
875
+ setKey(obj, x.split('.'), defaults[key]);
876
+ });
877
+ }
878
+ });
879
+ }
880
+ function hasKey(obj, keys) {
881
+ let o = obj;
882
+ if (!configuration['dot-notation'])
883
+ keys = [keys.join('.')];
884
+ keys.slice(0, -1).forEach(function (key) {
885
+ o = (o[key] || {});
886
+ });
887
+ const key = keys[keys.length - 1];
888
+ if (typeof o !== 'object')
889
+ return false;
890
+ else
891
+ return key in o;
892
+ }
893
+ function setKey(obj, keys, value) {
894
+ let o = obj;
895
+ if (!configuration['dot-notation'])
896
+ keys = [keys.join('.')];
897
+ keys.slice(0, -1).forEach(function (key) {
898
+ // TODO(bcoe): in the next major version of yargs, switch to
899
+ // Object.create(null) for dot notation:
900
+ key = sanitizeKey(key);
901
+ if (typeof o === 'object' && o[key] === undefined) {
902
+ o[key] = {};
903
+ }
904
+ if (typeof o[key] !== 'object' || Array.isArray(o[key])) {
905
+ // ensure that o[key] is an array, and that the last item is an empty object.
906
+ if (Array.isArray(o[key])) {
907
+ o[key].push({});
908
+ }
909
+ else {
910
+ o[key] = [o[key], {}];
911
+ }
912
+ // we want to update the empty object at the end of the o[key] array, so set o to that object
913
+ o = o[key][o[key].length - 1];
914
+ }
915
+ else {
916
+ o = o[key];
917
+ }
918
+ });
919
+ // TODO(bcoe): in the next major version of yargs, switch to
920
+ // Object.create(null) for dot notation:
921
+ const key = sanitizeKey(keys[keys.length - 1]);
922
+ const isTypeArray = checkAllAliases(keys.join('.'), flags.arrays);
923
+ const isValueArray = Array.isArray(value);
924
+ let duplicate = configuration['duplicate-arguments-array'];
925
+ // nargs has higher priority than duplicate
926
+ if (!duplicate && checkAllAliases(key, flags.nargs)) {
927
+ duplicate = true;
928
+ if ((!isUndefined(o[key]) && flags.nargs[key] === 1) || (Array.isArray(o[key]) && o[key].length === flags.nargs[key])) {
929
+ o[key] = undefined;
930
+ }
931
+ }
932
+ if (value === increment()) {
933
+ o[key] = increment(o[key]);
934
+ }
935
+ else if (Array.isArray(o[key])) {
936
+ if (duplicate && isTypeArray && isValueArray) {
937
+ o[key] = configuration['flatten-duplicate-arrays'] ? o[key].concat(value) : (Array.isArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
938
+ }
939
+ else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
940
+ o[key] = value;
941
+ }
942
+ else {
943
+ o[key] = o[key].concat([value]);
944
+ }
945
+ }
946
+ else if (o[key] === undefined && isTypeArray) {
947
+ o[key] = isValueArray ? value : [value];
948
+ }
949
+ else if (duplicate && !(o[key] === undefined ||
950
+ checkAllAliases(key, flags.counts) ||
951
+ checkAllAliases(key, flags.bools))) {
952
+ o[key] = [o[key], value];
953
+ }
954
+ else {
955
+ o[key] = value;
956
+ }
957
+ }
958
+ // extend the aliases list with inferred aliases.
959
+ function extendAliases(...args) {
960
+ args.forEach(function (obj) {
961
+ Object.keys(obj || {}).forEach(function (key) {
962
+ // short-circuit if we've already added a key
963
+ // to the aliases array, for example it might
964
+ // exist in both 'opts.default' and 'opts.key'.
965
+ if (flags.aliases[key])
966
+ return;
967
+ flags.aliases[key] = [].concat(aliases[key] || []);
968
+ // For "--option-name", also set argv.optionName
969
+ flags.aliases[key].concat(key).forEach(function (x) {
970
+ if (/-/.test(x) && configuration['camel-case-expansion']) {
971
+ const c = camelCase(x);
972
+ if (c !== key && flags.aliases[key].indexOf(c) === -1) {
973
+ flags.aliases[key].push(c);
974
+ newAliases[c] = true;
975
+ }
976
+ }
977
+ });
978
+ // For "--optionName", also set argv['option-name']
979
+ flags.aliases[key].concat(key).forEach(function (x) {
980
+ if (x.length > 1 && /[A-Z]/.test(x) && configuration['camel-case-expansion']) {
981
+ const c = decamelize(x, '-');
982
+ if (c !== key && flags.aliases[key].indexOf(c) === -1) {
983
+ flags.aliases[key].push(c);
984
+ newAliases[c] = true;
985
+ }
986
+ }
987
+ });
988
+ flags.aliases[key].forEach(function (x) {
989
+ flags.aliases[x] = [key].concat(flags.aliases[key].filter(function (y) {
990
+ return x !== y;
991
+ }));
992
+ });
993
+ });
994
+ });
995
+ }
996
+ function checkAllAliases(key, flag) {
997
+ const toCheck = [].concat(flags.aliases[key] || [], key);
998
+ const keys = Object.keys(flag);
999
+ const setAlias = toCheck.find(key => keys.includes(key));
1000
+ return setAlias ? flag[setAlias] : false;
1001
+ }
1002
+ function hasAnyFlag(key) {
1003
+ const flagsKeys = Object.keys(flags);
1004
+ const toCheck = [].concat(flagsKeys.map(k => flags[k]));
1005
+ return toCheck.some(function (flag) {
1006
+ return Array.isArray(flag) ? flag.includes(key) : flag[key];
1007
+ });
1008
+ }
1009
+ function hasFlagsMatching(arg, ...patterns) {
1010
+ const toCheck = [].concat(...patterns);
1011
+ return toCheck.some(function (pattern) {
1012
+ const match = arg.match(pattern);
1013
+ return match && hasAnyFlag(match[1]);
1014
+ });
1015
+ }
1016
+ // based on a simplified version of the short flag group parsing logic
1017
+ function hasAllShortFlags(arg) {
1018
+ // if this is a negative number, or doesn't start with a single hyphen, it's not a short flag group
1019
+ if (arg.match(negative) || !arg.match(/^-[^-]+/)) {
1020
+ return false;
1021
+ }
1022
+ let hasAllFlags = true;
1023
+ let next;
1024
+ const letters = arg.slice(1).split('');
1025
+ for (let j = 0; j < letters.length; j++) {
1026
+ next = arg.slice(j + 2);
1027
+ if (!hasAnyFlag(letters[j])) {
1028
+ hasAllFlags = false;
1029
+ break;
1030
+ }
1031
+ if ((letters[j + 1] && letters[j + 1] === '=') ||
1032
+ next === '-' ||
1033
+ (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) ||
1034
+ (letters[j + 1] && letters[j + 1].match(/\W/))) {
1035
+ break;
1036
+ }
1037
+ }
1038
+ return hasAllFlags;
1039
+ }
1040
+ function isUnknownOptionAsArg(arg) {
1041
+ return configuration['unknown-options-as-args'] && isUnknownOption(arg);
1042
+ }
1043
+ function isUnknownOption(arg) {
1044
+ arg = arg.replace(/^-{3,}/, '--');
1045
+ // ignore negative numbers
1046
+ if (arg.match(negative)) {
1047
+ return false;
1048
+ }
1049
+ // if this is a short option group and all of them are configured, it isn't unknown
1050
+ if (hasAllShortFlags(arg)) {
1051
+ return false;
1052
+ }
1053
+ // e.g. '--count=2'
1054
+ const flagWithEquals = /^-+([^=]+?)=[\s\S]*$/;
1055
+ // e.g. '-a' or '--arg'
1056
+ const normalFlag = /^-+([^=]+?)$/;
1057
+ // e.g. '-a-'
1058
+ const flagEndingInHyphen = /^-+([^=]+?)-$/;
1059
+ // e.g. '-abc123'
1060
+ const flagEndingInDigits = /^-+([^=]+?\d+)$/;
1061
+ // e.g. '-a/usr/local'
1062
+ const flagEndingInNonWordCharacters = /^-+([^=]+?)\W+.*$/;
1063
+ // check the different types of flag styles, including negatedBoolean, a pattern defined near the start of the parse method
1064
+ return !hasFlagsMatching(arg, flagWithEquals, negatedBoolean, normalFlag, flagEndingInHyphen, flagEndingInDigits, flagEndingInNonWordCharacters);
1065
+ }
1066
+ // make a best effort to pick a default value
1067
+ // for an option based on name and type.
1068
+ function defaultValue(key) {
1069
+ if (!checkAllAliases(key, flags.bools) &&
1070
+ !checkAllAliases(key, flags.counts) &&
1071
+ `${key}` in defaults) {
1072
+ return defaults[key];
1073
+ }
1074
+ else {
1075
+ return defaultForType(guessType(key));
1076
+ }
1077
+ }
1078
+ // return a default value, given the type of a flag.,
1079
+ function defaultForType(type) {
1080
+ const def = {
1081
+ [DefaultValuesForTypeKey.BOOLEAN]: true,
1082
+ [DefaultValuesForTypeKey.STRING]: '',
1083
+ [DefaultValuesForTypeKey.NUMBER]: undefined,
1084
+ [DefaultValuesForTypeKey.ARRAY]: []
1085
+ };
1086
+ return def[type];
1087
+ }
1088
+ // given a flag, enforce a default type.
1089
+ function guessType(key) {
1090
+ let type = DefaultValuesForTypeKey.BOOLEAN;
1091
+ if (checkAllAliases(key, flags.strings))
1092
+ type = DefaultValuesForTypeKey.STRING;
1093
+ else if (checkAllAliases(key, flags.numbers))
1094
+ type = DefaultValuesForTypeKey.NUMBER;
1095
+ else if (checkAllAliases(key, flags.bools))
1096
+ type = DefaultValuesForTypeKey.BOOLEAN;
1097
+ else if (checkAllAliases(key, flags.arrays))
1098
+ type = DefaultValuesForTypeKey.ARRAY;
1099
+ return type;
1100
+ }
1101
+ function isUndefined(num) {
1102
+ return num === undefined;
1103
+ }
1104
+ // check user configuration settings for inconsistencies
1105
+ function checkConfiguration() {
1106
+ // count keys should not be set as array/narg
1107
+ Object.keys(flags.counts).find(key => {
1108
+ if (checkAllAliases(key, flags.arrays)) {
1109
+ error = Error(__('Invalid configuration: %s, opts.count excludes opts.array.', key));
1110
+ return true;
1111
+ }
1112
+ else if (checkAllAliases(key, flags.nargs)) {
1113
+ error = Error(__('Invalid configuration: %s, opts.count excludes opts.narg.', key));
1114
+ return true;
1115
+ }
1116
+ return false;
1117
+ });
1118
+ }
1119
+ return {
1120
+ aliases: Object.assign({}, flags.aliases),
1121
+ argv: Object.assign(argvReturn, argv),
1122
+ configuration: configuration,
1123
+ defaulted: Object.assign({}, defaulted),
1124
+ error: error,
1125
+ newAliases: Object.assign({}, newAliases)
1126
+ };
1127
+ }
1128
+ }
1129
+ // if any aliases reference each other, we should
1130
+ // merge them together.
1131
+ function combineAliases(aliases) {
1132
+ const aliasArrays = [];
1133
+ const combined = Object.create(null);
1134
+ let change = true;
1135
+ // turn alias lookup hash {key: ['alias1', 'alias2']} into
1136
+ // a simple array ['key', 'alias1', 'alias2']
1137
+ Object.keys(aliases).forEach(function (key) {
1138
+ aliasArrays.push([].concat(aliases[key], key));
1139
+ });
1140
+ // combine arrays until zero changes are
1141
+ // made in an iteration.
1142
+ while (change) {
1143
+ change = false;
1144
+ for (let i = 0; i < aliasArrays.length; i++) {
1145
+ for (let ii = i + 1; ii < aliasArrays.length; ii++) {
1146
+ const intersect = aliasArrays[i].filter(function (v) {
1147
+ return aliasArrays[ii].indexOf(v) !== -1;
1148
+ });
1149
+ if (intersect.length) {
1150
+ aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
1151
+ aliasArrays.splice(ii, 1);
1152
+ change = true;
1153
+ break;
1154
+ }
1155
+ }
1156
+ }
1157
+ }
1158
+ // map arrays back to the hash-lookup (de-dupe while
1159
+ // we're at it).
1160
+ aliasArrays.forEach(function (aliasArray) {
1161
+ aliasArray = aliasArray.filter(function (v, i, self) {
1162
+ return self.indexOf(v) === i;
1163
+ });
1164
+ const lastAlias = aliasArray.pop();
1165
+ if (lastAlias !== undefined && typeof lastAlias === 'string') {
1166
+ combined[lastAlias] = aliasArray;
1167
+ }
1168
+ });
1169
+ return combined;
1170
+ }
1171
+ // this function should only be called when a count is given as an arg
1172
+ // it is NOT called to set a default value
1173
+ // thus we can start the count at 1 instead of 0
1174
+ function increment(orig) {
1175
+ return orig !== undefined ? orig + 1 : 1;
1176
+ }
1177
+ // TODO(bcoe): in the next major version of yargs, switch to
1178
+ // Object.create(null) for dot notation:
1179
+ function sanitizeKey(key) {
1180
+ if (key === '__proto__')
1181
+ return '___proto___';
1182
+ return key;
1183
+ }
1184
+ function stripQuotes(val) {
1185
+ return (typeof val === 'string' &&
1186
+ (val[0] === "'" || val[0] === '"') &&
1187
+ val[val.length - 1] === val[0])
1188
+ ? val.substring(1, val.length - 1)
1189
+ : val;
1190
+ }
1191
+
1192
+ /**
1193
+ * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
1194
+ * CJS and ESM environments.
1195
+ *
1196
+ * @license
1197
+ * Copyright (c) 2016, Contributors
1198
+ * SPDX-License-Identifier: ISC
1199
+ */
1200
+ var _a, _b, _c;
1201
+ // See https://github.com/yargs/yargs-parser#supported-nodejs-versions for our
1202
+ // version support policy. The YARGS_MIN_NODE_VERSION is used for testing only.
1203
+ const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
1204
+ ? Number(process.env.YARGS_MIN_NODE_VERSION)
1205
+ : 12;
1206
+ const nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
1207
+ if (nodeVersion) {
1208
+ const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
1209
+ if (major < minNodeVersion) {
1210
+ throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
1211
+ }
1212
+ }
1213
+ // Creates a yargs-parser instance using Node.js standard libraries:
1214
+ const env = process ? process.env : {};
1215
+ const parser = new YargsParser({
1216
+ cwd: process.cwd,
1217
+ env: () => {
1218
+ return env;
1219
+ },
1220
+ format: require$$2.format,
1221
+ normalize: require$$0.normalize,
1222
+ resolve: require$$0.resolve,
1223
+ // TODO: figure out a way to combine ESM and CJS coverage, such that
1224
+ // we can exercise all the lines below:
1225
+ require: (path) => {
1226
+ if (typeof require !== 'undefined') {
1227
+ return require(path);
1228
+ }
1229
+ else if (path.match(/\.json$/)) {
1230
+ // Addresses: https://github.com/yargs/yargs/issues/2040
1231
+ return JSON.parse(require$$0$1.readFileSync(path, 'utf8'));
1232
+ }
1233
+ else {
1234
+ throw Error('only .json config files are supported in ESM');
1235
+ }
1236
+ }
1237
+ });
1238
+ const yargsParser = function Parser(args, opts) {
1239
+ const result = parser.parse(args.slice(), opts);
1240
+ return result.argv;
1241
+ };
1242
+ yargsParser.detailed = function (args, opts) {
1243
+ return parser.parse(args.slice(), opts);
1244
+ };
1245
+ yargsParser.camelCase = camelCase;
1246
+ yargsParser.decamelize = decamelize;
1247
+ yargsParser.looksLikeNumber = looksLikeNumber;
1248
+
1249
+ /******************************************************************************
1250
+ Copyright (c) Microsoft Corporation.
1251
+
1252
+ Permission to use, copy, modify, and/or distribute this software for any
1253
+ purpose with or without fee is hereby granted.
1254
+
1255
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1256
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1257
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1258
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1259
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1260
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1261
+ PERFORMANCE OF THIS SOFTWARE.
1262
+ ***************************************************************************** */
1263
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1264
+
1265
+
1266
+ function __addDisposableResource(env, value, async) {
1267
+ if (value !== null && value !== void 0) {
1268
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
1269
+ var dispose, inner;
1270
+ if (async) {
1271
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
1272
+ dispose = value[Symbol.asyncDispose];
1273
+ }
1274
+ if (dispose === void 0) {
1275
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
1276
+ dispose = value[Symbol.dispose];
1277
+ if (async) inner = dispose;
1278
+ }
1279
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
1280
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
1281
+ env.stack.push({ value: value, dispose: dispose, async: async });
1282
+ }
1283
+ else if (async) {
1284
+ env.stack.push({ async: true });
1285
+ }
1286
+ return value;
1287
+
1288
+ }
1289
+
1290
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1291
+ var e = new Error(message);
1292
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1293
+ };
1294
+
1295
+ function __disposeResources(env) {
1296
+ function fail(e) {
1297
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
1298
+ env.hasError = true;
1299
+ }
1300
+ var r, s = 0;
1301
+ function next() {
1302
+ while (r = env.stack.pop()) {
1303
+ try {
1304
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
1305
+ if (r.dispose) {
1306
+ var result = r.dispose.call(r.value);
1307
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
1308
+ }
1309
+ else s |= 1;
1310
+ }
1311
+ catch (e) {
1312
+ fail(e);
1313
+ }
1314
+ }
1315
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
1316
+ if (env.hasError) throw env.error;
1317
+ }
1318
+ return next();
1319
+ }
1320
+
1321
+ const toZeroIfInfinity = value => Number.isFinite(value) ? value : 0;
1322
+
1323
+ function parseNumber(milliseconds) {
1324
+ return {
1325
+ days: Math.trunc(milliseconds / 86_400_000),
1326
+ hours: Math.trunc(milliseconds / 3_600_000 % 24),
1327
+ minutes: Math.trunc(milliseconds / 60_000 % 60),
1328
+ seconds: Math.trunc(milliseconds / 1000 % 60),
1329
+ milliseconds: Math.trunc(milliseconds % 1000),
1330
+ microseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1000) % 1000),
1331
+ nanoseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1e6) % 1000),
1332
+ };
1333
+ }
1334
+
1335
+ function parseBigint(milliseconds) {
1336
+ return {
1337
+ days: milliseconds / 86_400_000n,
1338
+ hours: milliseconds / 3_600_000n % 24n,
1339
+ minutes: milliseconds / 60_000n % 60n,
1340
+ seconds: milliseconds / 1000n % 60n,
1341
+ milliseconds: milliseconds % 1000n,
1342
+ microseconds: 0n,
1343
+ nanoseconds: 0n,
1344
+ };
1345
+ }
1346
+
1347
+ function parseMilliseconds(milliseconds) {
1348
+ switch (typeof milliseconds) {
1349
+ case 'number': {
1350
+ if (Number.isFinite(milliseconds)) {
1351
+ return parseNumber(milliseconds);
1352
+ }
1353
+
1354
+ break;
1355
+ }
1356
+
1357
+ case 'bigint': {
1358
+ return parseBigint(milliseconds);
1359
+ }
1360
+
1361
+ // No default
1362
+ }
1363
+
1364
+ throw new TypeError('Expected a finite number or bigint');
1365
+ }
1366
+
1367
+ const isZero = value => value === 0 || value === 0n;
1368
+ const pluralize = (word, count) => (count === 1 || count === 1n) ? word : `${word}s`;
1369
+
1370
+ const SECOND_ROUNDING_EPSILON = 0.000_000_1;
1371
+ const ONE_DAY_IN_MILLISECONDS = 24n * 60n * 60n * 1000n;
1372
+
1373
+ function prettyMilliseconds(milliseconds, options) {
1374
+ const isBigInt = typeof milliseconds === 'bigint';
1375
+ if (!isBigInt && !Number.isFinite(milliseconds)) {
1376
+ throw new TypeError('Expected a finite number or bigint');
1377
+ }
1378
+
1379
+ options = {...options};
1380
+
1381
+ const sign = milliseconds < 0 ? '-' : '';
1382
+ milliseconds = milliseconds < 0 ? -milliseconds : milliseconds; // Cannot use `Math.abs()` because of BigInt support.
1383
+
1384
+ if (options.colonNotation) {
1385
+ options.compact = false;
1386
+ options.formatSubMilliseconds = false;
1387
+ options.separateMilliseconds = false;
1388
+ options.verbose = false;
1389
+ }
1390
+
1391
+ if (options.compact) {
1392
+ options.unitCount = 1;
1393
+ options.secondsDecimalDigits = 0;
1394
+ options.millisecondsDecimalDigits = 0;
1395
+ }
1396
+
1397
+ let result = [];
1398
+
1399
+ const floorDecimals = (value, decimalDigits) => {
1400
+ const flooredInterimValue = Math.floor((value * (10 ** decimalDigits)) + SECOND_ROUNDING_EPSILON);
1401
+ const flooredValue = Math.round(flooredInterimValue) / (10 ** decimalDigits);
1402
+ return flooredValue.toFixed(decimalDigits);
1403
+ };
1404
+
1405
+ const add = (value, long, short, valueString) => {
1406
+ if (
1407
+ (result.length === 0 || !options.colonNotation)
1408
+ && isZero(value)
1409
+ && !(options.colonNotation && short === 'm')) {
1410
+ return;
1411
+ }
1412
+
1413
+ valueString ??= String(value);
1414
+ if (options.colonNotation) {
1415
+ const wholeDigits = valueString.includes('.') ? valueString.split('.')[0].length : valueString.length;
1416
+ const minLength = result.length > 0 ? 2 : 1;
1417
+ valueString = '0'.repeat(Math.max(0, minLength - wholeDigits)) + valueString;
1418
+ } else {
1419
+ valueString += options.verbose ? ' ' + pluralize(long, value) : short;
1420
+ }
1421
+
1422
+ result.push(valueString);
1423
+ };
1424
+
1425
+ const parsed = parseMilliseconds(milliseconds);
1426
+ const days = BigInt(parsed.days);
1427
+
1428
+ if (options.hideYearAndDays) {
1429
+ add((BigInt(days) * 24n) + BigInt(parsed.hours), 'hour', 'h');
1430
+ } else {
1431
+ if (options.hideYear) {
1432
+ add(days, 'day', 'd');
1433
+ } else {
1434
+ add(days / 365n, 'year', 'y');
1435
+ add(days % 365n, 'day', 'd');
1436
+ }
1437
+
1438
+ add(Number(parsed.hours), 'hour', 'h');
1439
+ }
1440
+
1441
+ add(Number(parsed.minutes), 'minute', 'm');
1442
+
1443
+ if (!options.hideSeconds) {
1444
+ if (
1445
+ options.separateMilliseconds
1446
+ || options.formatSubMilliseconds
1447
+ || (!options.colonNotation && milliseconds < 1000 && !options.subSecondsAsDecimals)
1448
+ ) {
1449
+ const seconds = Number(parsed.seconds);
1450
+ const milliseconds = Number(parsed.milliseconds);
1451
+ const microseconds = Number(parsed.microseconds);
1452
+ const nanoseconds = Number(parsed.nanoseconds);
1453
+
1454
+ add(seconds, 'second', 's');
1455
+
1456
+ if (options.formatSubMilliseconds) {
1457
+ add(milliseconds, 'millisecond', 'ms');
1458
+ add(microseconds, 'microsecond', 'µs');
1459
+ add(nanoseconds, 'nanosecond', 'ns');
1460
+ } else {
1461
+ const millisecondsAndBelow
1462
+ = milliseconds
1463
+ + (microseconds / 1000)
1464
+ + (nanoseconds / 1e6);
1465
+
1466
+ const millisecondsDecimalDigits
1467
+ = typeof options.millisecondsDecimalDigits === 'number'
1468
+ ? options.millisecondsDecimalDigits
1469
+ : 0;
1470
+
1471
+ const roundedMilliseconds = millisecondsAndBelow >= 1
1472
+ ? Math.round(millisecondsAndBelow)
1473
+ : Math.ceil(millisecondsAndBelow);
1474
+
1475
+ const millisecondsString = millisecondsDecimalDigits
1476
+ ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits)
1477
+ : roundedMilliseconds;
1478
+
1479
+ add(
1480
+ Number.parseFloat(millisecondsString),
1481
+ 'millisecond',
1482
+ 'ms',
1483
+ millisecondsString,
1484
+ );
1485
+ }
1486
+ } else {
1487
+ const seconds = (
1488
+ (isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds)
1489
+ / 1000
1490
+ ) % 60;
1491
+ const secondsDecimalDigits
1492
+ = typeof options.secondsDecimalDigits === 'number'
1493
+ ? options.secondsDecimalDigits
1494
+ : 1;
1495
+ const secondsFixed = floorDecimals(seconds, secondsDecimalDigits);
1496
+ const secondsString = options.keepDecimalsOnWholeSeconds
1497
+ ? secondsFixed
1498
+ : secondsFixed.replace(/\.0+$/, '');
1499
+ add(Number.parseFloat(secondsString), 'second', 's', secondsString);
1500
+ }
1501
+ }
1502
+
1503
+ if (result.length === 0) {
1504
+ return sign + '0' + (options.verbose ? ' milliseconds' : 'ms');
1505
+ }
1506
+
1507
+ const separator = options.colonNotation ? ':' : ' ';
1508
+ if (typeof options.unitCount === 'number') {
1509
+ result = result.slice(0, Math.max(options.unitCount, 1));
1510
+ }
1511
+
1512
+ return sign + result.join(separator);
1513
+ }
1514
+
1515
+ const BYTE_UNITS = [
1516
+ 'B',
1517
+ 'kB',
1518
+ 'MB',
1519
+ 'GB',
1520
+ 'TB',
1521
+ 'PB',
1522
+ 'EB',
1523
+ 'ZB',
1524
+ 'YB',
1525
+ ];
1526
+
1527
+ const BIBYTE_UNITS = [
1528
+ 'B',
1529
+ 'KiB',
1530
+ 'MiB',
1531
+ 'GiB',
1532
+ 'TiB',
1533
+ 'PiB',
1534
+ 'EiB',
1535
+ 'ZiB',
1536
+ 'YiB',
1537
+ ];
1538
+
1539
+ const BIT_UNITS = [
1540
+ 'b',
1541
+ 'kbit',
1542
+ 'Mbit',
1543
+ 'Gbit',
1544
+ 'Tbit',
1545
+ 'Pbit',
1546
+ 'Ebit',
1547
+ 'Zbit',
1548
+ 'Ybit',
1549
+ ];
1550
+
1551
+ const BIBIT_UNITS = [
1552
+ 'b',
1553
+ 'kibit',
1554
+ 'Mibit',
1555
+ 'Gibit',
1556
+ 'Tibit',
1557
+ 'Pibit',
1558
+ 'Eibit',
1559
+ 'Zibit',
1560
+ 'Yibit',
1561
+ ];
1562
+
1563
+ /*
1564
+ Formats the given number using `Number#toLocaleString`.
1565
+ - If locale is a string, the value is expected to be a locale-key (for example: `de`).
1566
+ - If locale is true, the system default locale is used for translation.
1567
+ - If no value for locale is specified, the number is returned unmodified.
1568
+ */
1569
+ const toLocaleString = (number, locale, options) => {
1570
+ let result = number;
1571
+ if (typeof locale === 'string' || Array.isArray(locale)) {
1572
+ result = number.toLocaleString(locale, options);
1573
+ } else if (locale === true || options !== undefined) {
1574
+ result = number.toLocaleString(undefined, options);
1575
+ }
1576
+
1577
+ return result;
1578
+ };
1579
+
1580
+ const log10 = numberOrBigInt => {
1581
+ if (typeof numberOrBigInt === 'number') {
1582
+ return Math.log10(numberOrBigInt);
1583
+ }
1584
+
1585
+ const string = numberOrBigInt.toString(10);
1586
+
1587
+ return string.length + Math.log10(`0.${string.slice(0, 15)}`);
1588
+ };
1589
+
1590
+ const log = numberOrBigInt => {
1591
+ if (typeof numberOrBigInt === 'number') {
1592
+ return Math.log(numberOrBigInt);
1593
+ }
1594
+
1595
+ return log10(numberOrBigInt) * Math.log(10);
1596
+ };
1597
+
1598
+ const divide = (numberOrBigInt, divisor) => {
1599
+ if (typeof numberOrBigInt === 'number') {
1600
+ return numberOrBigInt / divisor;
1601
+ }
1602
+
1603
+ const integerPart = numberOrBigInt / BigInt(divisor);
1604
+ const remainder = numberOrBigInt % BigInt(divisor);
1605
+ return Number(integerPart) + (Number(remainder) / divisor);
1606
+ };
1607
+
1608
+ const applyFixedWidth = (result, fixedWidth) => {
1609
+ if (fixedWidth === undefined) {
1610
+ return result;
1611
+ }
1612
+
1613
+ if (typeof fixedWidth !== 'number' || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) {
1614
+ throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
1615
+ }
1616
+
1617
+ if (fixedWidth === 0) {
1618
+ return result;
1619
+ }
1620
+
1621
+ return result.length < fixedWidth ? result.padStart(fixedWidth, ' ') : result;
1622
+ };
1623
+
1624
+ const buildLocaleOptions = options => {
1625
+ const {minimumFractionDigits, maximumFractionDigits} = options;
1626
+
1627
+ if (minimumFractionDigits === undefined && maximumFractionDigits === undefined) {
1628
+ return undefined;
1629
+ }
1630
+
1631
+ return {
1632
+ ...(minimumFractionDigits !== undefined && {minimumFractionDigits}),
1633
+ ...(maximumFractionDigits !== undefined && {maximumFractionDigits}),
1634
+ roundingMode: 'trunc',
1635
+ };
1636
+ };
1637
+
1638
+ function prettyBytes(number, options) {
1639
+ if (typeof number !== 'bigint' && !Number.isFinite(number)) {
1640
+ throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
1641
+ }
1642
+
1643
+ options = {
1644
+ bits: false,
1645
+ binary: false,
1646
+ space: true,
1647
+ nonBreakingSpace: false,
1648
+ ...options,
1649
+ };
1650
+
1651
+ const UNITS = options.bits
1652
+ ? (options.binary ? BIBIT_UNITS : BIT_UNITS)
1653
+ : (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
1654
+
1655
+ const separator = options.space ? (options.nonBreakingSpace ? '\u00A0' : ' ') : '';
1656
+
1657
+ // Handle signed zero case
1658
+ const isZero = typeof number === 'number' ? number === 0 : number === 0n;
1659
+ if (options.signed && isZero) {
1660
+ const result = ` 0${separator}${UNITS[0]}`;
1661
+ return applyFixedWidth(result, options.fixedWidth);
1662
+ }
1663
+
1664
+ const isNegative = number < 0;
1665
+ const prefix = isNegative ? '-' : (options.signed ? '+' : '');
1666
+
1667
+ if (isNegative) {
1668
+ number = -number;
1669
+ }
1670
+
1671
+ const localeOptions = buildLocaleOptions(options);
1672
+ let result;
1673
+
1674
+ if (number < 1) {
1675
+ const numberString = toLocaleString(number, options.locale, localeOptions);
1676
+ result = prefix + numberString + separator + UNITS[0];
1677
+ } else {
1678
+ const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
1679
+ number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
1680
+
1681
+ if (!localeOptions) {
1682
+ const minPrecision = Math.max(3, Math.floor(number).toString().length);
1683
+ number = number.toPrecision(minPrecision);
1684
+ }
1685
+
1686
+ const numberString = toLocaleString(Number(number), options.locale, localeOptions);
1687
+ const unit = UNITS[exponent];
1688
+ result = prefix + numberString + separator + unit;
1689
+ }
1690
+
1691
+ return applyFixedWidth(result, options.fixedWidth);
1692
+ }
1693
+
1694
+ function printTimings(timings) {
1695
+ for (const [label, [time, memory, total]] of Object.entries(timings)) {
1696
+ const appliedColor = label[0] === '#' ? (label[1] === '#' ? rollup.bold : rollup.underline) : (text) => text;
1697
+ const row = `${label}: ${time.toFixed(0)}ms, ${prettyBytes(memory)} / ${prettyBytes(total)}`;
1698
+ console.info(appliedColor(row));
1699
+ }
1700
+ }
1701
+
1702
+ async function build(inputOptions, warnings, silent = false) {
1703
+ const env_1 = { stack: [], error: void 0, hasError: false };
1704
+ try {
1705
+ const outputOptions = inputOptions.output;
1706
+ const useStdout = !outputOptions[0].file && !outputOptions[0].dir;
1707
+ const start = Date.now();
1708
+ const files = useStdout ? ['stdout'] : outputOptions.map(t => parseAst_js.relativeId(t.file || t.dir));
1709
+ if (!silent) {
1710
+ let inputFiles;
1711
+ if (typeof inputOptions.input === 'string') {
1712
+ inputFiles = inputOptions.input;
1713
+ }
1714
+ else if (Array.isArray(inputOptions.input)) {
1715
+ inputFiles = inputOptions.input.join(', ');
1716
+ }
1717
+ else if (typeof inputOptions.input === 'object' && inputOptions.input !== null) {
1718
+ inputFiles = Object.values(inputOptions.input).join(', ');
1719
+ }
1720
+ rollup.stderr(rollup.cyan(`\n${rollup.bold(inputFiles)} → ${rollup.bold(files.join(', '))}...`));
1721
+ }
1722
+ const bundle = __addDisposableResource(env_1, await rollup.rollup(inputOptions), true);
1723
+ if (useStdout) {
1724
+ const output = outputOptions[0];
1725
+ if (output.sourcemap && output.sourcemap !== 'inline') {
1726
+ rollup.handleError(parseAst_js.logOnlyInlineSourcemapsForStdout());
1727
+ }
1728
+ const { output: outputs } = await bundle.generate(output);
1729
+ for (const file of outputs) {
1730
+ if (outputs.length > 1)
1731
+ process$1.stdout.write(`\n${rollup.cyan(rollup.bold(`//→ ${file.fileName}:`))}\n`);
1732
+ process$1.stdout.write(file.type === 'asset' ? file.source : file.code);
1733
+ }
1734
+ if (!silent) {
1735
+ warnings.flush();
1736
+ }
1737
+ return;
1738
+ }
1739
+ await Promise.all(outputOptions.map(bundle.write));
1740
+ if (!silent) {
1741
+ warnings.flush();
1742
+ rollup.stderr(rollup.green(`created ${rollup.bold(files.join(', '))} in ${rollup.bold(prettyMilliseconds(Date.now() - start))}`));
1743
+ if (bundle && bundle.getTimings) {
1744
+ printTimings(bundle.getTimings());
1745
+ }
1746
+ }
1747
+ }
1748
+ catch (e_1) {
1749
+ env_1.error = e_1;
1750
+ env_1.hasError = true;
1751
+ }
1752
+ finally {
1753
+ const result_1 = __disposeResources(env_1);
1754
+ if (result_1)
1755
+ await result_1;
1756
+ }
1757
+ }
1758
+
1759
+ const DEFAULT_CONFIG_BASE = 'rollup.config';
1760
+ async function getConfigPath(commandConfig) {
1761
+ if (commandConfig === true) {
1762
+ return path.resolve(await findConfigFileNameInCwd());
1763
+ }
1764
+ if (commandConfig.slice(0, 5) === 'node:') {
1765
+ const packageName = commandConfig.slice(5);
1766
+ try {
1767
+ return require.resolve(`rollup-config-${packageName}`, { paths: [process$1.cwd()] });
1768
+ }
1769
+ catch {
1770
+ try {
1771
+ return require.resolve(packageName, { paths: [process$1.cwd()] });
1772
+ }
1773
+ catch (error) {
1774
+ if (error.code === 'MODULE_NOT_FOUND') {
1775
+ rollup.handleError(parseAst_js.logMissingExternalConfig(commandConfig));
1776
+ }
1777
+ throw error;
1778
+ }
1779
+ }
1780
+ }
1781
+ return path.resolve(commandConfig);
1782
+ }
1783
+ async function findConfigFileNameInCwd() {
1784
+ const filesInWorkingDirectory = new Set(await promises.readdir(process$1.cwd()));
1785
+ for (const extension of ['mjs', 'cjs', 'ts']) {
1786
+ const fileName = `${DEFAULT_CONFIG_BASE}.${extension}`;
1787
+ if (filesInWorkingDirectory.has(fileName))
1788
+ return fileName;
1789
+ }
1790
+ return `${DEFAULT_CONFIG_BASE}.js`;
1791
+ }
1792
+
1793
+ async function loadConfigFromCommand(commandOptions, watchMode) {
1794
+ const warnings = loadConfigFile_js.batchWarnings(commandOptions);
1795
+ if (!commandOptions.input && (commandOptions.stdin || !process$1.stdin.isTTY)) {
1796
+ commandOptions.input = loadConfigFile_js.stdinName;
1797
+ }
1798
+ const options = await rollup.mergeOptions({ input: [] }, watchMode, commandOptions, warnings.log);
1799
+ await loadConfigFile_js.addCommandPluginsToInputOptions(options, commandOptions);
1800
+ return { options: [options], warnings };
1801
+ }
1802
+
1803
+ async function runRollup(command) {
1804
+ let inputSource;
1805
+ if (command._.length > 0) {
1806
+ if (command.input) {
1807
+ rollup.handleError(parseAst_js.logDuplicateImportOptions());
1808
+ }
1809
+ inputSource = command._;
1810
+ }
1811
+ else if (typeof command.input === 'string') {
1812
+ inputSource = [command.input];
1813
+ }
1814
+ else {
1815
+ inputSource = command.input;
1816
+ }
1817
+ if (inputSource && inputSource.length > 0) {
1818
+ if (inputSource.some((input) => input.includes('='))) {
1819
+ command.input = {};
1820
+ for (const input of inputSource) {
1821
+ const equalsIndex = input.indexOf('=');
1822
+ const value = input.slice(Math.max(0, equalsIndex + 1));
1823
+ const key = input.slice(0, Math.max(0, equalsIndex)) || parseAst_js.getAliasName(input);
1824
+ command.input[key] = value;
1825
+ }
1826
+ }
1827
+ else {
1828
+ command.input = inputSource;
1829
+ }
1830
+ }
1831
+ if (command.environment) {
1832
+ const environment = Array.isArray(command.environment)
1833
+ ? command.environment
1834
+ : [command.environment];
1835
+ for (const argument of environment) {
1836
+ for (const pair of argument.split(',')) {
1837
+ const [key, ...value] = pair.split(':');
1838
+ process$1.env[key] = value.length === 0 ? String(true) : value.join(':');
1839
+ }
1840
+ }
1841
+ }
1842
+ if (rollup.isWatchEnabled(command.watch)) {
1843
+ await fseventsImporter.loadFsEvents();
1844
+ const { watch } = await Promise.resolve().then(() => require('../shared/watch-cli.js'));
1845
+ await watch(command);
1846
+ }
1847
+ else {
1848
+ try {
1849
+ const { options, warnings } = await getConfigs(command);
1850
+ try {
1851
+ for (const inputOptions of options) {
1852
+ if (!inputOptions.cache) {
1853
+ // We explicitly disable the cache when unused as the CLI will not
1854
+ // use the cache object on the bundle when not in watch mode. This
1855
+ // improves performance as the cache is not generated.
1856
+ inputOptions.cache = false;
1857
+ }
1858
+ await build(inputOptions, warnings, command.silent);
1859
+ }
1860
+ if (command.failAfterWarnings && warnings.warningOccurred) {
1861
+ warnings.flush();
1862
+ rollup.handleError(parseAst_js.logFailAfterWarnings());
1863
+ }
1864
+ }
1865
+ catch (error) {
1866
+ warnings.flush();
1867
+ rollup.handleError(error);
1868
+ }
1869
+ }
1870
+ catch (error) {
1871
+ rollup.handleError(error);
1872
+ }
1873
+ }
1874
+ }
1875
+ async function getConfigs(command) {
1876
+ if (command.config) {
1877
+ const configFile = await getConfigPath(command.config);
1878
+ const { options, warnings } = await loadConfigFile_js.loadConfigFile(configFile, command, false);
1879
+ return { options, warnings };
1880
+ }
1881
+ return await loadConfigFromCommand(command, false);
1882
+ }
1883
+
1884
+ const command = yargsParser(process$1.argv.slice(2), {
1885
+ alias: rollup.commandAliases,
1886
+ configuration: { 'camel-case-expansion': false }
1887
+ });
1888
+ if (command.help || (process$1.argv.length <= 2 && process$1.stdin.isTTY)) {
1889
+ console.log(`\n${help}\n`);
1890
+ }
1891
+ else if (command.version) {
1892
+ console.log(`rollup v${rollup.version}`);
1893
+ }
1894
+ else {
1895
+ try {
1896
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
1897
+ require('source-map-support').install();
1898
+ }
1899
+ catch {
1900
+ // do nothing
1901
+ }
1902
+ const promise = runRollup(command);
1903
+ if (command.forceExit) {
1904
+ promise.then(() => process$1.exit());
1905
+ }
1906
+ }
1907
+
1908
+ exports.getConfigPath = getConfigPath;
1909
+ exports.loadConfigFromCommand = loadConfigFromCommand;
1910
+ exports.prettyMilliseconds = prettyMilliseconds;
1911
+ exports.printTimings = printTimings;
1912
+ //# sourceMappingURL=rollup.map
node_modules/.bin/semver ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ // Standalone semver comparison program.
3
+ // Exits successfully and prints matching version(s) if
4
+ // any supplied version is valid and passes all tests.
5
+
6
+ 'use strict'
7
+
8
+ const argv = process.argv.slice(2)
9
+
10
+ let versions = []
11
+
12
+ const range = []
13
+
14
+ let inc = null
15
+
16
+ const version = require('../package.json').version
17
+
18
+ let loose = false
19
+
20
+ let includePrerelease = false
21
+
22
+ let coerce = false
23
+
24
+ let rtl = false
25
+
26
+ let identifier
27
+
28
+ let identifierBase
29
+
30
+ const semver = require('../')
31
+ const parseOptions = require('../internal/parse-options')
32
+
33
+ let reverse = false
34
+
35
+ let options = {}
36
+
37
+ const main = () => {
38
+ if (!argv.length) {
39
+ return help()
40
+ }
41
+ while (argv.length) {
42
+ let a = argv.shift()
43
+ const indexOfEqualSign = a.indexOf('=')
44
+ if (indexOfEqualSign !== -1) {
45
+ const value = a.slice(indexOfEqualSign + 1)
46
+ a = a.slice(0, indexOfEqualSign)
47
+ argv.unshift(value)
48
+ }
49
+
50
+ switch (a) {
51
+ case '-rv': case '-rev': case '--rev': case '--reverse':
52
+ reverse = true
53
+ break
54
+ case '-l': case '--loose':
55
+ loose = true
56
+ break
57
+ case '-p': case '--include-prerelease':
58
+ includePrerelease = true
59
+ break
60
+ case '-v': case '--version':
61
+ versions.push(argv.shift())
62
+ break
63
+ case '-i': case '--inc': case '--increment':
64
+ if (semver.RELEASE_TYPES.includes(argv[0]) || (argv[0] === 'release')) {
65
+ inc = { value: argv.shift(), maybeErrantValue: null, option: a }
66
+ } else {
67
+ inc = { value: 'patch', maybeErrantValue: argv[0], option: a }
68
+ }
69
+ break
70
+ case '--preid':
71
+ identifier = argv.shift()
72
+ break
73
+ case '-r': case '--range':
74
+ range.push(argv.shift())
75
+ break
76
+ case '-n':
77
+ identifierBase = argv.shift()
78
+ if (identifierBase === 'false') {
79
+ identifierBase = false
80
+ }
81
+ break
82
+ case '-c': case '--coerce':
83
+ coerce = true
84
+ break
85
+ case '--rtl':
86
+ rtl = true
87
+ break
88
+ case '--ltr':
89
+ rtl = false
90
+ break
91
+ case '-h': case '--help': case '-?':
92
+ return help()
93
+ default:
94
+ versions.push(a)
95
+ break
96
+ }
97
+ }
98
+
99
+ options = parseOptions({ loose, includePrerelease, rtl })
100
+
101
+ if (
102
+ inc &&
103
+ versions.includes(inc.maybeErrantValue) &&
104
+ !semver.valid(inc.maybeErrantValue, options)
105
+ ) {
106
+ console.warn(`Invalid value for ${inc.option}; defaulting to 'patch'. This may become a failure in future major versions.`)
107
+ }
108
+
109
+ versions = versions.map((v) => {
110
+ return coerce ? (semver.coerce(v, options) || { version: v }).version : v
111
+ }).filter((v) => {
112
+ return semver.valid(v, options)
113
+ })
114
+ if (!versions.length) {
115
+ return fail()
116
+ }
117
+ if (inc && (versions.length !== 1 || range.length)) {
118
+ return failInc()
119
+ }
120
+
121
+ for (let i = 0, l = range.length; i < l; i++) {
122
+ versions = versions.filter((v) => {
123
+ return semver.satisfies(v, range[i], options)
124
+ })
125
+ if (!versions.length) {
126
+ return fail()
127
+ }
128
+ }
129
+ versions
130
+ .sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
131
+ .map(v => semver.clean(v, options))
132
+ .map(v => inc ? semver.inc(v, inc.value, options, identifier, identifierBase) : v)
133
+ .forEach(v => console.log(v))
134
+ }
135
+
136
+ const failInc = () => {
137
+ console.error('--inc can only be used on a single version with no range')
138
+ fail()
139
+ }
140
+
141
+ const fail = () => process.exit(1)
142
+
143
+ const help = () => console.log(
144
+ `SemVer ${version}
145
+
146
+ A JavaScript implementation of the https://semver.org/ specification
147
+ Copyright Isaac Z. Schlueter
148
+
149
+ Usage: semver [options] <version> [<version> [...]]
150
+ Prints valid versions sorted by SemVer precedence
151
+
152
+ Options:
153
+ -r --range <range>
154
+ Print versions that match the specified range.
155
+
156
+ -i --increment [<level>]
157
+ Increment a version by the specified level. Level can
158
+ be one of: major, minor, patch, premajor, preminor,
159
+ prepatch, prerelease, or release. Default level is 'patch'.
160
+ Only one version may be specified.
161
+
162
+ --preid <identifier>
163
+ Identifier to be used to prefix premajor, preminor,
164
+ prepatch or prerelease version increments.
165
+
166
+ -l --loose
167
+ Interpret versions and ranges loosely
168
+
169
+ -p --include-prerelease
170
+ Always include prerelease versions in range matching
171
+
172
+ -c --coerce
173
+ Coerce a string into SemVer if possible
174
+ (does not imply --loose)
175
+
176
+ --rtl
177
+ Coerce version strings right to left
178
+
179
+ --ltr
180
+ Coerce version strings left to right (default)
181
+
182
+ -n <base>
183
+ Base number to be used for the prerelease identifier.
184
+ Can be either 0 or 1, or false to omit the number altogether.
185
+ Defaults to 0.
186
+
187
+ Program exits successfully if any valid version satisfies
188
+ all supplied ranges, and prints all satisfying versions.
189
+
190
+ If no satisfying versions are found, then exits failure.
191
+
192
+ Versions are printed in ascending order, so supplying
193
+ multiple versions to the utility will just sort them.`)
194
+
195
+ main()
node_modules/.bin/specificity ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ import Specificity from '../dist/index.js';
3
+
4
+ if (!process.argv[2]) {
5
+ console.error('❌ Missing selector argument');
6
+ process.exit(1);
7
+ }
8
+
9
+ try {
10
+ const specificities = Specificity.calculate(process.argv[2]);
11
+ console.log(specificities.map((specificity) => `${specificity}`).join('\n'));
12
+ } catch (e) {
13
+ console.error(`❌ ${e.message}`);
14
+ }
node_modules/.bin/terser ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ require("../tools/exit.cjs");
6
+
7
+ try {
8
+ require("source-map-support").install();
9
+ } catch (err) {}
10
+
11
+ const fs = require("fs");
12
+ const path = require("path");
13
+ const program = require("commander");
14
+
15
+ const packageJson = require("../package.json");
16
+ const { _run_cli: run_cli } = require("..");
17
+
18
+ run_cli({ program, packageJson, fs, path }).catch((error) => {
19
+ console.error(error);
20
+ process.exitCode = 1;
21
+ });
node_modules/.bin/tldts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ const { parse } = require('..');
6
+ const readline = require('readline');
7
+
8
+ if (process.argv.length > 2) {
9
+ // URL(s) was specified in the command arguments
10
+ console.log(
11
+ JSON.stringify(parse(process.argv[process.argv.length - 1]), null, 2),
12
+ );
13
+ } else {
14
+ // No arguments were specified, read URLs from each line of STDIN
15
+ const rlInterface = readline.createInterface({
16
+ input: process.stdin,
17
+ });
18
+ rlInterface.on('line', function (line) {
19
+ console.log(JSON.stringify(parse(line), null, 2));
20
+ });
21
+ }
node_modules/.bin/tree-kill ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ kill = require('.')
3
+ try {
4
+ kill(process.argv[2], process.argv[3], function(err){
5
+ if (err) {
6
+ console.log(err.message)
7
+ process.exit(1)
8
+ }
9
+ })
10
+ }
11
+ catch (err) {
12
+ console.log(err.message)
13
+ process.exit(1)
14
+ }
node_modules/.bin/tsc ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #!/usr/bin/env node
2
+ require('../lib/tsc.js')
node_modules/.bin/tsserver ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #!/usr/bin/env node
2
+ require('../lib/tsserver.js')
node_modules/.bin/tsx ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/.bin/update-browserslist-db ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ let { readFileSync } = require('fs')
4
+ let { join } = require('path')
5
+
6
+ require('./check-npm-version')
7
+ let updateDb = require('./')
8
+
9
+ const ROOT = __dirname
10
+
11
+ function getPackage() {
12
+ return JSON.parse(readFileSync(join(ROOT, 'package.json')))
13
+ }
14
+
15
+ let args = process.argv.slice(2)
16
+
17
+ let USAGE = 'Usage:\n npx update-browserslist-db\n'
18
+
19
+ function isArg(arg) {
20
+ return args.some(i => i === arg)
21
+ }
22
+
23
+ function error(msg) {
24
+ process.stderr.write('update-browserslist-db: ' + msg + '\n')
25
+ process.exit(1)
26
+ }
27
+
28
+ if (isArg('--help') || isArg('-h')) {
29
+ process.stdout.write(getPackage().description + '.\n\n' + USAGE + '\n')
30
+ } else if (isArg('--version') || isArg('-v')) {
31
+ process.stdout.write('browserslist-lint ' + getPackage().version + '\n')
32
+ } else {
33
+ try {
34
+ updateDb()
35
+ } catch (e) {
36
+ if (e.name === 'BrowserslistUpdateError') {
37
+ error(e.message)
38
+ } else {
39
+ throw e
40
+ }
41
+ }
42
+ }
node_modules/.bin/uuid ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #!/usr/bin/env node
2
+ import '../uuid-bin.js';
node_modules/.bin/vite ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ import { performance } from 'node:perf_hooks'
3
+ import module from 'node:module'
4
+
5
+ if (!import.meta.url.includes('node_modules')) {
6
+ if (!process.env.DEBUG_DISABLE_SOURCE_MAP) {
7
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins -- only used in dev
8
+ process.setSourceMapsEnabled(true)
9
+ }
10
+
11
+ process.on('unhandledRejection', (err) => {
12
+ throw new Error('UNHANDLED PROMISE REJECTION', { cause: err })
13
+ })
14
+ }
15
+
16
+ global.__vite_start_time = performance.now()
17
+
18
+ // check debug mode first before requiring the CLI.
19
+ const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg))
20
+ const filterIndex = process.argv.findIndex((arg) =>
21
+ /^(?:-f|--filter)$/.test(arg),
22
+ )
23
+ const profileIndex = process.argv.indexOf('--profile')
24
+
25
+ if (debugIndex > 0) {
26
+ let value = process.argv[debugIndex + 1]
27
+ if (!value || value[0] === '-') {
28
+ value = 'vite:*'
29
+ } else {
30
+ // support debugging multiple flags with comma-separated list
31
+ value = value
32
+ .split(',')
33
+ .map((v) => `vite:${v}`)
34
+ .join(',')
35
+ }
36
+ process.env.DEBUG = `${
37
+ process.env.DEBUG ? process.env.DEBUG + ',' : ''
38
+ }${value}`
39
+
40
+ if (filterIndex > 0) {
41
+ const filter = process.argv[filterIndex + 1]
42
+ if (filter && filter[0] !== '-') {
43
+ process.env.VITE_DEBUG_FILTER = filter
44
+ }
45
+ }
46
+ }
47
+
48
+ function start() {
49
+ try {
50
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.8.0+ and only called if it exists
51
+ module.enableCompileCache?.()
52
+ // flush the cache after 10s because the cache is not flushed until process end
53
+ // for dev server, the cache is never flushed unless manually flushed because the process.exit is called
54
+ // also flushing the cache in SIGINT handler seems to cause the process to hang
55
+ setTimeout(() => {
56
+ try {
57
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.12.0+ and only called if it exists
58
+ module.flushCompileCache?.()
59
+ } catch {}
60
+ }, 10 * 1000).unref()
61
+ } catch {}
62
+ return import('../dist/node/cli.js')
63
+ }
64
+
65
+ if (profileIndex > 0) {
66
+ process.argv.splice(profileIndex, 1)
67
+ const next = process.argv[profileIndex]
68
+ if (next && next[0] !== '-') {
69
+ process.argv.splice(profileIndex, 1)
70
+ }
71
+ const inspector = await import('node:inspector').then((r) => r.default)
72
+ const session = (global.__vite_profile_session = new inspector.Session())
73
+ session.connect()
74
+ session.post('Profiler.enable', () => {
75
+ session.post('Profiler.start', start)
76
+ })
77
+ } else {
78
+ start()
79
+ }
node_modules/.bin/vitest ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #!/usr/bin/env node
2
+ import './dist/cli.js'
node_modules/.bin/why-is-node-running ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ var spawn = require('child_process').spawn
4
+ var path = require('path')
5
+
6
+ var prog = path.resolve(process.argv[2])
7
+ var progArgs = process.argv.slice(3)
8
+
9
+ console.log('probing program', prog)
10
+
11
+ var nodeArgs = [
12
+ '-r',
13
+ path.join(__dirname, 'include.js')
14
+ ]
15
+ var nodeOpts = { stdio: 'inherit' }
16
+ var child = spawn('node', nodeArgs.concat(prog).concat(progArgs), nodeOpts)
17
+
18
+ console.log('kill -SIGUSR1', child.pid, 'for logging')
node_modules/.package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@asamuzakjp/css-color/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2024 asamuzaK (Kazz)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/@asamuzakjp/css-color/README.md ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS color
2
+
3
+ [![build](https://github.com/asamuzaK/cssColor/actions/workflows/node.js.yml/badge.svg)](https://github.com/asamuzaK/cssColor/actions/workflows/node.js.yml)
4
+ [![CodeQL](https://github.com/asamuzaK/cssColor/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/asamuzaK/cssColor/actions/workflows/github-code-scanning/codeql)
5
+ [![npm (scoped)](https://img.shields.io/npm/v/@asamuzakjp/css-color)](https://www.npmjs.com/package/@asamuzakjp/css-color)
6
+
7
+ Resolve and convert CSS colors.
8
+
9
+ ## Install
10
+
11
+ ```console
12
+ npm i @asamuzakjp/css-color
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```javascript
18
+ import { convert, resolve, utils } from '@asamuzakjp/css-color';
19
+
20
+ const resolvedValue = resolve(
21
+ 'color-mix(in oklab, lch(67.5345 42.5 258.2), color(srgb 0 0.5 0))'
22
+ );
23
+ // 'oklab(0.620754 -0.0931934 -0.00374881)'
24
+
25
+ const convertedValue = convert.colorToHex('lab(46.2775% -47.5621 48.5837)');
26
+ // '#008000'
27
+
28
+ const result = utils.isColor('green');
29
+ // true
30
+ ```
31
+
32
+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
33
+
34
+ ### resolve(color, opt)
35
+
36
+ resolves CSS color
37
+
38
+ #### Parameters
39
+
40
+ - `color` **[string][133]** color value
41
+ - system colors are not supported
42
+ - `opt` **[object][135]?** options (optional, default `{}`)
43
+ - `opt.currentColor` **[string][133]?**
44
+ - color to use for `currentcolor` keyword
45
+ - if omitted, it will be treated as a missing color,
46
+ i.e. `rgb(none none none / none)`
47
+ - `opt.customProperty` **[object][135]?**
48
+ - custom properties
49
+ - pair of `--` prefixed property name as a key and it's value,
50
+ e.g.
51
+ ```javascript
52
+ const opt = {
53
+ customProperty: {
54
+ '--some-color': '#008000',
55
+ '--some-length': '16px'
56
+ }
57
+ };
58
+ ```
59
+ - and/or `callback` function to get the value of the custom property,
60
+ e.g.
61
+ ```javascript
62
+ const node = document.getElementById('foo');
63
+ const opt = {
64
+ customProperty: {
65
+ callback: node.style.getPropertyValue
66
+ }
67
+ };
68
+ ```
69
+ - `opt.dimension` **[object][135]?**
70
+ - dimension, e.g. for converting relative length to pixels
71
+ - pair of unit as a key and number in pixels as it's value,
72
+ e.g. suppose `1em === 12px`, `1rem === 16px` and `100vw === 1024px`, then
73
+ ```javascript
74
+ const opt = {
75
+ dimension: {
76
+ em: 12,
77
+ rem: 16,
78
+ vw: 10.24
79
+ }
80
+ };
81
+ ```
82
+ - and/or `callback` function to get the value as a number in pixels,
83
+ e.g.
84
+ ```javascript
85
+ const opt = {
86
+ dimension: {
87
+ callback: unit => {
88
+ switch (unit) {
89
+ case 'em':
90
+ return 12;
91
+ case 'rem':
92
+ return 16;
93
+ case 'vw':
94
+ return 10.24;
95
+ default:
96
+ return;
97
+ }
98
+ }
99
+ }
100
+ };
101
+ ```
102
+ - `opt.format` **[string][133]?**
103
+ - output format, one of below
104
+ - `computedValue` (default), [computed value][139] of the color
105
+ - `specifiedValue`, [specified value][140] of the color
106
+ - `hex`, hex color notation, i.e. `#rrggbb`
107
+ - `hexAlpha`, hex color notation with alpha channel, i.e. `#rrggbbaa`
108
+
109
+ Returns **[string][133]?** one of `rgba?()`, `#rrggbb(aa)?`, `color-name`, `color(color-space r g b / alpha)`, `color(color-space x y z / alpha)`, `(ok)?lab(l a b / alpha)`, `(ok)?lch(l c h / alpha)`, `'(empty-string)'`, `null`
110
+
111
+ - in `computedValue`, values are numbers, however `rgb()` values are integers
112
+ - in `specifiedValue`, returns `empty string` for unknown and/or invalid color
113
+ - in `hex`, returns `null` for `transparent`, and also returns `null` if any of `r`, `g`, `b`, `alpha` is not a number
114
+ - in `hexAlpha`, returns `#00000000` for `transparent`, however returns `null` if any of `r`, `g`, `b`, `alpha` is not a number
115
+
116
+ ### convert
117
+
118
+ Contains various color conversion functions.
119
+
120
+ ### convert.numberToHex(value)
121
+
122
+ convert number to hex string
123
+
124
+ #### Parameters
125
+
126
+ - `value` **[number][134]** color value
127
+
128
+ Returns **[string][133]** hex string: 00..ff
129
+
130
+ ### convert.colorToHex(value, opt)
131
+
132
+ convert color to hex
133
+
134
+ #### Parameters
135
+
136
+ - `value` **[string][133]** color value
137
+ - `opt` **[object][135]?** options (optional, default `{}`)
138
+ - `opt.alpha` **[boolean][136]?** return in #rrggbbaa notation
139
+ - `opt.customProperty` **[object][135]?**
140
+ - custom properties, see `resolve()` function above
141
+ - `opt.dimension` **[object][135]?**
142
+ - dimension, see `resolve()` function above
143
+
144
+ Returns **[string][133]** #rrggbb(aa)?
145
+
146
+ ### convert.colorToHsl(value, opt)
147
+
148
+ convert color to hsl
149
+
150
+ #### Parameters
151
+
152
+ - `value` **[string][133]** color value
153
+ - `opt` **[object][135]?** options (optional, default `{}`)
154
+ - `opt.customProperty` **[object][135]?**
155
+ - custom properties, see `resolve()` function above
156
+ - `opt.dimension` **[object][135]?**
157
+ - dimension, see `resolve()` function above
158
+
159
+ Returns **[Array][137]<[number][134]>** \[h, s, l, alpha]
160
+
161
+ ### convert.colorToHwb(value, opt)
162
+
163
+ convert color to hwb
164
+
165
+ #### Parameters
166
+
167
+ - `value` **[string][133]** color value
168
+ - `opt` **[object][135]?** options (optional, default `{}`)
169
+ - `opt.customProperty` **[object][135]?**
170
+ - custom properties, see `resolve()` function above
171
+ - `opt.dimension` **[object][135]?**
172
+ - dimension, see `resolve()` function above
173
+
174
+ Returns **[Array][137]<[number][134]>** \[h, w, b, alpha]
175
+
176
+ ### convert.colorToLab(value, opt)
177
+
178
+ convert color to lab
179
+
180
+ #### Parameters
181
+
182
+ - `value` **[string][133]** color value
183
+ - `opt` **[object][135]?** options (optional, default `{}`)
184
+ - `opt.customProperty` **[object][135]?**
185
+ - custom properties, see `resolve()` function above
186
+ - `opt.dimension` **[object][135]?**
187
+ - dimension, see `resolve()` function above
188
+
189
+ Returns **[Array][137]<[number][134]>** \[l, a, b, alpha]
190
+
191
+ ### convert.colorToLch(value, opt)
192
+
193
+ convert color to lch
194
+
195
+ #### Parameters
196
+
197
+ - `value` **[string][133]** color value
198
+ - `opt` **[object][135]?** options (optional, default `{}`)
199
+ - `opt.customProperty` **[object][135]?**
200
+ - custom properties, see `resolve()` function above
201
+ - `opt.dimension` **[object][135]?**
202
+ - dimension, see `resolve()` function above
203
+
204
+ Returns **[Array][137]<[number][134]>** \[l, c, h, alpha]
205
+
206
+ ### convert.colorToOklab(value, opt)
207
+
208
+ convert color to oklab
209
+
210
+ #### Parameters
211
+
212
+ - `value` **[string][133]** color value
213
+ - `opt` **[object][135]?** options (optional, default `{}`)
214
+ - `opt.customProperty` **[object][135]?**
215
+ - custom properties, see `resolve()` function above
216
+ - `opt.dimension` **[object][135]?**
217
+ - dimension, see `resolve()` function above
218
+
219
+ Returns **[Array][137]<[number][134]>** \[l, a, b, alpha]
220
+
221
+ ### convert.colorToOklch(value, opt)
222
+
223
+ convert color to oklch
224
+
225
+ #### Parameters
226
+
227
+ - `value` **[string][133]** color value
228
+ - `opt` **[object][135]?** options (optional, default `{}`)
229
+ - `opt.customProperty` **[object][135]?**
230
+ - custom properties, see `resolve()` function above
231
+ - `opt.dimension` **[object][135]?**
232
+ - dimension, see `resolve()` function above
233
+
234
+ Returns **[Array][137]<[number][134]>** \[l, c, h, alpha]
235
+
236
+ ### convert.colorToRgb(value, opt)
237
+
238
+ convert color to rgb
239
+
240
+ #### Parameters
241
+
242
+ - `value` **[string][133]** color value
243
+ - `opt` **[object][135]?** options (optional, default `{}`)
244
+ - `opt.customProperty` **[object][135]?**
245
+ - custom properties, see `resolve()` function above
246
+ - `opt.dimension` **[object][135]?**
247
+ - dimension, see `resolve()` function above
248
+
249
+ Returns **[Array][137]<[number][134]>** \[r, g, b, alpha]
250
+
251
+ ### convert.colorToXyz(value, opt)
252
+
253
+ convert color to xyz
254
+
255
+ #### Parameters
256
+
257
+ - `value` **[string][133]** color value
258
+ - `opt` **[object][135]?** options (optional, default `{}`)
259
+ - `opt.customProperty` **[object][135]?**
260
+ - custom properties, see `resolve()` function above
261
+ - `opt.dimension` **[object][135]?**
262
+ - dimension, see `resolve()` function above
263
+ - `opt.d50` **[boolean][136]?** xyz in d50 white point
264
+
265
+ Returns **[Array][137]<[number][134]>** \[x, y, z, alpha]
266
+
267
+ ### convert.colorToXyzD50(value, opt)
268
+
269
+ convert color to xyz-d50
270
+
271
+ #### Parameters
272
+
273
+ - `value` **[string][133]** color value
274
+ - `opt` **[object][135]?** options (optional, default `{}`)
275
+ - `opt.customProperty` **[object][135]?**
276
+ - custom properties, see `resolve()` function above
277
+ - `opt.dimension` **[object][135]?**
278
+ - dimension, see `resolve()` function above
279
+
280
+ Returns **[Array][137]<[number][134]>** \[x, y, z, alpha]
281
+
282
+ ### utils
283
+
284
+ Contains utility functions.
285
+
286
+ ### utils.isColor(color)
287
+
288
+ is valid color type
289
+
290
+ #### Parameters
291
+
292
+ - `color` **[string][133]** color value
293
+ - system colors are not supported
294
+
295
+ Returns **[boolean][136]**
296
+
297
+ ## Acknowledgments
298
+
299
+ The following resources have been of great help in the development of the CSS color.
300
+
301
+ - [csstools/postcss-plugins](https://github.com/csstools/postcss-plugins)
302
+ - [lru-cache](https://github.com/isaacs/node-lru-cache)
303
+
304
+ ---
305
+
306
+ Copyright (c) 2024 [asamuzaK (Kazz)](https://github.com/asamuzaK/)
307
+
308
+ [133]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
309
+ [134]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
310
+ [135]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
311
+ [136]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
312
+ [137]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
313
+ [138]: https://w3c.github.io/csswg-drafts/css-color-4/#color-conversion-code
314
+ [139]: https://developer.mozilla.org/en-US/docs/Web/CSS/computed_value
315
+ [140]: https://developer.mozilla.org/en-US/docs/Web/CSS/specified_value
316
+ [141]: https://www.npmjs.com/package/@csstools/css-calc
node_modules/@asamuzakjp/css-color/dist/esm/index.d.ts ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * CSS color - Resolve, parse, convert CSS color.
3
+ * @license MIT
4
+ * @copyright asamuzaK (Kazz)
5
+ * @see {@link https://github.com/asamuzaK/cssColor/blob/main/LICENSE}
6
+ */
7
+ export { convert } from './js/convert.js';
8
+ export { resolve } from './js/resolve.js';
9
+ export declare const utils: {
10
+ cssCalc: (value: string, opt?: import('./js/typedef.js').Options) => string;
11
+ cssVar: (value: string, opt?: import('./js/typedef.js').Options) => string;
12
+ extractDashedIdent: (value: string) => string[];
13
+ isAbsoluteFontSize: (css: unknown) => boolean;
14
+ isAbsoluteSizeOrLength: (value: number | string, unit: string | undefined) => boolean;
15
+ isColor: (value: unknown, opt?: import('./js/typedef.js').Options) => boolean;
16
+ isGradient: (value: string, opt?: import('./js/typedef.js').Options) => boolean;
17
+ resolveGradient: (value: string, opt?: import('./js/typedef.js').Options) => string;
18
+ resolveLengthInPixels: (value: number | string, unit: string | undefined, opt?: import('./js/typedef.js').Options) => number;
19
+ splitValue: (value: string, opt?: import('./js/typedef.js').Options) => string[];
20
+ };
node_modules/@asamuzakjp/css-color/dist/esm/index.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { resolve } from "./js/resolve.js";
2
+ import { extractDashedIdent, isAbsoluteFontSize, isAbsoluteSizeOrLength, isColor, resolveLengthInPixels, splitValue } from "./js/util.js";
3
+ import { cssVar } from "./js/css-var.js";
4
+ import { cssCalc } from "./js/css-calc.js";
5
+ import { isGradient, resolveGradient } from "./js/css-gradient.js";
6
+ import { convert } from "./js/convert.js";
7
+ //#region src/index.ts
8
+ /*!
9
+ * CSS color - Resolve, parse, convert CSS color.
10
+ * @license MIT
11
+ * @copyright asamuzaK (Kazz)
12
+ * @see {@link https://github.com/asamuzaK/cssColor/blob/main/LICENSE}
13
+ */
14
+ var utils = {
15
+ cssCalc,
16
+ cssVar,
17
+ extractDashedIdent,
18
+ isAbsoluteFontSize,
19
+ isAbsoluteSizeOrLength,
20
+ isColor,
21
+ isGradient,
22
+ resolveGradient,
23
+ resolveLengthInPixels,
24
+ splitValue
25
+ };
26
+ //#endregion
27
+ export { convert, resolve, utils };
28
+
29
+ //# sourceMappingURL=index.js.map
node_modules/@asamuzakjp/css-color/dist/esm/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/*!\n * CSS color - Resolve, parse, convert CSS color.\n * @license MIT\n * @copyright asamuzaK (Kazz)\n * @see {@link https://github.com/asamuzaK/cssColor/blob/main/LICENSE}\n */\n\nimport { cssCalc } from './js/css-calc';\nimport { isGradient, resolveGradient } from './js/css-gradient';\nimport { cssVar } from './js/css-var';\nimport {\n extractDashedIdent,\n isAbsoluteFontSize,\n isAbsoluteSizeOrLength,\n isColor,\n resolveLengthInPixels,\n splitValue\n} from './js/util';\n\nexport { convert } from './js/convert';\nexport { resolve } from './js/resolve';\n/* utils */\nexport const utils = {\n cssCalc,\n cssVar,\n extractDashedIdent,\n isAbsoluteFontSize,\n isAbsoluteSizeOrLength,\n isColor,\n isGradient,\n resolveGradient,\n resolveLengthInPixels,\n splitValue\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
node_modules/@asamuzakjp/css-color/dist/esm/js/cache.d.ts ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { GenerationalCache } from '@asamuzakjp/generational-cache';
2
+ import { Options } from './typedef.js';
3
+ /**
4
+ * CacheItem
5
+ */
6
+ export declare class CacheItem {
7
+ #private;
8
+ constructor(item: unknown, isNull?: boolean);
9
+ get item(): unknown;
10
+ get isNull(): boolean;
11
+ }
12
+ /**
13
+ * NullObject
14
+ */
15
+ export declare class NullObject extends CacheItem {
16
+ constructor();
17
+ }
18
+ export declare const genCache: GenerationalCache<string, CacheItem>;
19
+ /**
20
+ * set cache
21
+ * @param key - cache key
22
+ * @param value - value to cache
23
+ * @returns void
24
+ */
25
+ export declare const setCache: (key: string, value: unknown) => void;
26
+ /**
27
+ * get cache
28
+ * @param key - cache key
29
+ * @returns cached item or false otherwise
30
+ */
31
+ export declare const getCache: (key: string) => CacheItem | false;
32
+ /**
33
+ * create cache key
34
+ * @param keyData - key data
35
+ * @param [opt] - options
36
+ * @returns cache key
37
+ */
38
+ export declare const createCacheKey: (keyData: Record<string, string>, opt?: Options) => string;
node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { GenerationalCache } from "@asamuzakjp/generational-cache";
2
+ //#region src/js/cache.ts
3
+ /**
4
+ * cache
5
+ */
6
+ var CACHE_SIZE = 2048;
7
+ /**
8
+ * CacheItem
9
+ */
10
+ var CacheItem = class {
11
+ #isNull;
12
+ #item;
13
+ constructor(item, isNull = false) {
14
+ this.#item = item;
15
+ this.#isNull = !!isNull;
16
+ }
17
+ get item() {
18
+ return this.#item;
19
+ }
20
+ get isNull() {
21
+ return this.#isNull;
22
+ }
23
+ };
24
+ /**
25
+ * NullObject
26
+ */
27
+ var NullObject = class extends CacheItem {
28
+ constructor() {
29
+ super(Symbol("null"), true);
30
+ }
31
+ };
32
+ var genCache = new GenerationalCache(CACHE_SIZE);
33
+ /**
34
+ * shared null object
35
+ */
36
+ var sharedNullObject = new NullObject();
37
+ /**
38
+ * set cache
39
+ * @param key - cache key
40
+ * @param value - value to cache
41
+ * @returns void
42
+ */
43
+ var setCache = (key, value) => {
44
+ if (!key) return;
45
+ if (value === null) genCache.set(key, sharedNullObject);
46
+ else if (value instanceof CacheItem) genCache.set(key, value);
47
+ else genCache.set(key, new CacheItem(value));
48
+ };
49
+ /**
50
+ * get cache
51
+ * @param key - cache key
52
+ * @returns cached item or false otherwise
53
+ */
54
+ var getCache = (key) => {
55
+ if (!key) return false;
56
+ const item = genCache.get(key);
57
+ if (item !== void 0) return item;
58
+ return false;
59
+ };
60
+ /**
61
+ * helper function to sort object keys alphabetically
62
+ * @param obj - Object
63
+ * @returns stringified JSON
64
+ */
65
+ var stringifySorted = (obj) => {
66
+ const keys = Object.keys(obj);
67
+ if (keys.length === 0) return "";
68
+ keys.sort();
69
+ let result = "";
70
+ for (const key of keys) result += `${key}:${JSON.stringify(obj[key])};`;
71
+ return result;
72
+ };
73
+ /**
74
+ * create cache key
75
+ * @param keyData - key data
76
+ * @param [opt] - options
77
+ * @returns cache key
78
+ */
79
+ var createCacheKey = (keyData, opt = {}) => {
80
+ if (!keyData || opt.customProperty && typeof opt.customProperty.callback === "function" || opt.dimension && typeof opt.dimension.callback === "function") return "";
81
+ const namespace = keyData.namespace || "";
82
+ const name = keyData.name || "";
83
+ const value = keyData.value || "";
84
+ if (!namespace && !name && !value) return "";
85
+ return `${`${namespace}:${name}:${value}`}::${`${opt.format || ""}|${opt.colorSpace || ""}|${opt.colorScheme || ""}|${opt.currentColor || ""}|${opt.d50 ? "1" : "0"}|${opt.nullable ? "1" : "0"}|${opt.preserveComment ? "1" : "0"}|${opt.delimiter || ""}`}::${opt.customProperty ? stringifySorted(opt.customProperty) : ""}::${opt.dimension ? stringifySorted(opt.dimension) : ""}`;
86
+ };
87
+ //#endregion
88
+ export { CacheItem, NullObject, createCacheKey, getCache, setCache };
89
+
90
+ //# sourceMappingURL=cache.js.map
node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"cache.js","names":["#item","#isNull"],"sources":["../../../src/js/cache.ts"],"sourcesContent":["/**\n * cache\n */\n\nimport { GenerationalCache } from '@asamuzakjp/generational-cache';\nimport { Options } from './typedef';\n\n/* constants */\nconst CACHE_SIZE = 2048;\n\n/**\n * CacheItem\n */\nexport class CacheItem {\n /* private */\n #isNull: boolean;\n #item: unknown;\n\n constructor(item: unknown, isNull: boolean = false) {\n this.#item = item;\n this.#isNull = !!isNull;\n }\n\n get item() {\n return this.#item;\n }\n\n get isNull() {\n return this.#isNull;\n }\n}\n\n/**\n * NullObject\n */\nexport class NullObject extends CacheItem {\n constructor() {\n super(Symbol('null'), true);\n }\n}\n\n/*\n * generational cache instance\n */\nexport const genCache = new GenerationalCache<string, CacheItem>(CACHE_SIZE);\n\n/**\n * shared null object\n */\nconst sharedNullObject = new NullObject();\n\n/**\n * set cache\n * @param key - cache key\n * @param value - value to cache\n * @returns void\n */\nexport const setCache = (key: string, value: unknown): void => {\n if (!key) {\n return;\n }\n if (value === null) {\n genCache.set(key, sharedNullObject);\n } else if (value instanceof CacheItem) {\n genCache.set(key, value);\n } else {\n genCache.set(key, new CacheItem(value));\n }\n};\n\n/**\n * get cache\n * @param key - cache key\n * @returns cached item or false otherwise\n */\nexport const getCache = (key: string): CacheItem | false => {\n if (!key) {\n return false;\n }\n const item = genCache.get(key);\n if (item !== undefined) {\n return item as CacheItem;\n }\n return false;\n};\n\n/**\n * helper function to sort object keys alphabetically\n * @param obj - Object\n * @returns stringified JSON\n */\nconst stringifySorted = (obj: Record<string, unknown>): string => {\n const keys = Object.keys(obj);\n if (keys.length === 0) {\n return '';\n }\n keys.sort();\n let result = '';\n for (const key of keys) {\n result += `${key}:${JSON.stringify(obj[key])};`;\n }\n return result;\n};\n\n/**\n * create cache key\n * @param keyData - key data\n * @param [opt] - options\n * @returns cache key\n */\nexport const createCacheKey = (\n keyData: Record<string, string>,\n opt: Options = {}\n): string => {\n if (\n !keyData ||\n (opt.customProperty && typeof opt.customProperty.callback === 'function') ||\n (opt.dimension && typeof opt.dimension.callback === 'function')\n ) {\n return '';\n }\n const namespace = keyData.namespace || '';\n const name = keyData.name || '';\n const value = keyData.value || '';\n if (!namespace && !name && !value) {\n return '';\n }\n const baseKey = `${namespace}:${name}:${value}`;\n const optStr = `${opt.format || ''}|${opt.colorSpace || ''}|${opt.colorScheme || ''}|${opt.currentColor || ''}|${opt.d50 ? '1' : '0'}|${opt.nullable ? '1' : '0'}|${opt.preserveComment ? '1' : '0'}|${opt.delimiter || ''}`;\n const customPropStr = opt.customProperty\n ? stringifySorted(opt.customProperty as Record<string, unknown>)\n : '';\n const dimStr = opt.dimension\n ? stringifySorted(opt.dimension as Record<string, unknown>)\n : '';\n return `${baseKey}::${optStr}::${customPropStr}::${dimStr}`;\n};\n"],"mappings":";;;;;AAQA,IAAM,aAAa;;;;AAKnB,IAAa,YAAb,MAAuB;CAErB;CACA;CAEA,YAAY,MAAe,SAAkB,OAAO;AAClD,QAAA,OAAa;AACb,QAAA,SAAe,CAAC,CAAC;;CAGnB,IAAI,OAAO;AACT,SAAO,MAAA;;CAGT,IAAI,SAAS;AACX,SAAO,MAAA;;;;;;AAOX,IAAa,aAAb,cAAgC,UAAU;CACxC,cAAc;AACZ,QAAM,OAAO,OAAO,EAAE,KAAK;;;AAO/B,IAAa,WAAW,IAAI,kBAAqC,WAAW;;;;AAK5E,IAAM,mBAAmB,IAAI,YAAY;;;;;;;AAQzC,IAAa,YAAY,KAAa,UAAyB;AAC7D,KAAI,CAAC,IACH;AAEF,KAAI,UAAU,KACZ,UAAS,IAAI,KAAK,iBAAiB;UAC1B,iBAAiB,UAC1B,UAAS,IAAI,KAAK,MAAM;KAExB,UAAS,IAAI,KAAK,IAAI,UAAU,MAAM,CAAC;;;;;;;AAS3C,IAAa,YAAY,QAAmC;AAC1D,KAAI,CAAC,IACH,QAAO;CAET,MAAM,OAAO,SAAS,IAAI,IAAI;AAC9B,KAAI,SAAS,KAAA,EACX,QAAO;AAET,QAAO;;;;;;;AAQT,IAAM,mBAAmB,QAAyC;CAChE,MAAM,OAAO,OAAO,KAAK,IAAI;AAC7B,KAAI,KAAK,WAAW,EAClB,QAAO;AAET,MAAK,MAAM;CACX,IAAI,SAAS;AACb,MAAK,MAAM,OAAO,KAChB,WAAU,GAAG,IAAI,GAAG,KAAK,UAAU,IAAI,KAAK,CAAC;AAE/C,QAAO;;;;;;;;AAST,IAAa,kBACX,SACA,MAAe,EAAE,KACN;AACX,KACE,CAAC,WACA,IAAI,kBAAkB,OAAO,IAAI,eAAe,aAAa,cAC7D,IAAI,aAAa,OAAO,IAAI,UAAU,aAAa,WAEpD,QAAO;CAET,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,QAAQ,QAAQ,SAAS;AAC/B,KAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAC1B,QAAO;AAUT,QAAO,GARS,GAAG,UAAU,GAAG,KAAK,GAAG,QAQtB,IAPH,GAAG,IAAI,UAAU,GAAG,GAAG,IAAI,cAAc,GAAG,GAAG,IAAI,eAAe,GAAG,GAAG,IAAI,gBAAgB,GAAG,GAAG,IAAI,MAAM,MAAM,IAAI,GAAG,IAAI,WAAW,MAAM,IAAI,GAAG,IAAI,kBAAkB,MAAM,IAAI,GAAG,IAAI,aAAa,KAO3L,IANP,IAAI,iBACtB,gBAAgB,IAAI,eAA0C,GAC9D,GAI2C,IAHhC,IAAI,YACf,gBAAgB,IAAI,UAAqC,GACzD"}
node_modules/@asamuzakjp/css-color/dist/esm/js/color.d.ts ADDED
@@ -0,0 +1,537 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { NullObject } from './cache.js';
2
+ import { ColorChannels, Options, SpecifiedColorChannels } from './typedef.js';
3
+ /**
4
+ * @type TriColorChannels - color channels without alpha
5
+ */
6
+ type TriColorChannels = [x: number, y: number, z: number];
7
+ /**
8
+ * @type ColorMatrix - color matrix
9
+ */
10
+ type ColorMatrix = [
11
+ r1: TriColorChannels,
12
+ r2: TriColorChannels,
13
+ r3: TriColorChannels
14
+ ];
15
+ /**
16
+ * named colors
17
+ */
18
+ export declare const NAMED_COLORS: {
19
+ readonly aliceblue: [240, 248, 255];
20
+ readonly antiquewhite: [250, 235, 215];
21
+ readonly aqua: [0, 255, 255];
22
+ readonly aquamarine: [127, 255, 212];
23
+ readonly azure: [240, 255, 255];
24
+ readonly beige: [245, 245, 220];
25
+ readonly bisque: [255, 228, 196];
26
+ readonly black: [0, 0, 0];
27
+ readonly blanchedalmond: [255, 235, 205];
28
+ readonly blue: [0, 0, 255];
29
+ readonly blueviolet: [138, 43, 226];
30
+ readonly brown: [165, 42, 42];
31
+ readonly burlywood: [222, 184, 135];
32
+ readonly cadetblue: [95, 158, 160];
33
+ readonly chartreuse: [127, 255, 0];
34
+ readonly chocolate: [210, 105, 30];
35
+ readonly coral: [255, 127, 80];
36
+ readonly cornflowerblue: [100, 149, 237];
37
+ readonly cornsilk: [255, 248, 220];
38
+ readonly crimson: [220, 20, 60];
39
+ readonly cyan: [0, 255, 255];
40
+ readonly darkblue: [0, 0, 139];
41
+ readonly darkcyan: [0, 139, 139];
42
+ readonly darkgoldenrod: [184, 134, 11];
43
+ readonly darkgray: [169, 169, 169];
44
+ readonly darkgreen: [0, 100, 0];
45
+ readonly darkgrey: [169, 169, 169];
46
+ readonly darkkhaki: [189, 183, 107];
47
+ readonly darkmagenta: [139, 0, 139];
48
+ readonly darkolivegreen: [85, 107, 47];
49
+ readonly darkorange: [255, 140, 0];
50
+ readonly darkorchid: [153, 50, 204];
51
+ readonly darkred: [139, 0, 0];
52
+ readonly darksalmon: [233, 150, 122];
53
+ readonly darkseagreen: [143, 188, 143];
54
+ readonly darkslateblue: [72, 61, 139];
55
+ readonly darkslategray: [47, 79, 79];
56
+ readonly darkslategrey: [47, 79, 79];
57
+ readonly darkturquoise: [0, 206, 209];
58
+ readonly darkviolet: [148, 0, 211];
59
+ readonly deeppink: [255, 20, 147];
60
+ readonly deepskyblue: [0, 191, 255];
61
+ readonly dimgray: [105, 105, 105];
62
+ readonly dimgrey: [105, 105, 105];
63
+ readonly dodgerblue: [30, 144, 255];
64
+ readonly firebrick: [178, 34, 34];
65
+ readonly floralwhite: [255, 250, 240];
66
+ readonly forestgreen: [34, 139, 34];
67
+ readonly fuchsia: [255, 0, 255];
68
+ readonly gainsboro: [220, 220, 220];
69
+ readonly ghostwhite: [248, 248, 255];
70
+ readonly gold: [255, 215, 0];
71
+ readonly goldenrod: [218, 165, 32];
72
+ readonly gray: [128, 128, 128];
73
+ readonly green: [0, 128, 0];
74
+ readonly greenyellow: [173, 255, 47];
75
+ readonly grey: [128, 128, 128];
76
+ readonly honeydew: [240, 255, 240];
77
+ readonly hotpink: [255, 105, 180];
78
+ readonly indianred: [205, 92, 92];
79
+ readonly indigo: [75, 0, 130];
80
+ readonly ivory: [255, 255, 240];
81
+ readonly khaki: [240, 230, 140];
82
+ readonly lavender: [230, 230, 250];
83
+ readonly lavenderblush: [255, 240, 245];
84
+ readonly lawngreen: [124, 252, 0];
85
+ readonly lemonchiffon: [255, 250, 205];
86
+ readonly lightblue: [173, 216, 230];
87
+ readonly lightcoral: [240, 128, 128];
88
+ readonly lightcyan: [224, 255, 255];
89
+ readonly lightgoldenrodyellow: [250, 250, 210];
90
+ readonly lightgray: [211, 211, 211];
91
+ readonly lightgreen: [144, 238, 144];
92
+ readonly lightgrey: [211, 211, 211];
93
+ readonly lightpink: [255, 182, 193];
94
+ readonly lightsalmon: [255, 160, 122];
95
+ readonly lightseagreen: [32, 178, 170];
96
+ readonly lightskyblue: [135, 206, 250];
97
+ readonly lightslategray: [119, 136, 153];
98
+ readonly lightslategrey: [119, 136, 153];
99
+ readonly lightsteelblue: [176, 196, 222];
100
+ readonly lightyellow: [255, 255, 224];
101
+ readonly lime: [0, 255, 0];
102
+ readonly limegreen: [50, 205, 50];
103
+ readonly linen: [250, 240, 230];
104
+ readonly magenta: [255, 0, 255];
105
+ readonly maroon: [128, 0, 0];
106
+ readonly mediumaquamarine: [102, 205, 170];
107
+ readonly mediumblue: [0, 0, 205];
108
+ readonly mediumorchid: [186, 85, 211];
109
+ readonly mediumpurple: [147, 112, 219];
110
+ readonly mediumseagreen: [60, 179, 113];
111
+ readonly mediumslateblue: [123, 104, 238];
112
+ readonly mediumspringgreen: [0, 250, 154];
113
+ readonly mediumturquoise: [72, 209, 204];
114
+ readonly mediumvioletred: [199, 21, 133];
115
+ readonly midnightblue: [25, 25, 112];
116
+ readonly mintcream: [245, 255, 250];
117
+ readonly mistyrose: [255, 228, 225];
118
+ readonly moccasin: [255, 228, 181];
119
+ readonly navajowhite: [255, 222, 173];
120
+ readonly navy: [0, 0, 128];
121
+ readonly oldlace: [253, 245, 230];
122
+ readonly olive: [128, 128, 0];
123
+ readonly olivedrab: [107, 142, 35];
124
+ readonly orange: [255, 165, 0];
125
+ readonly orangered: [255, 69, 0];
126
+ readonly orchid: [218, 112, 214];
127
+ readonly palegoldenrod: [238, 232, 170];
128
+ readonly palegreen: [152, 251, 152];
129
+ readonly paleturquoise: [175, 238, 238];
130
+ readonly palevioletred: [219, 112, 147];
131
+ readonly papayawhip: [255, 239, 213];
132
+ readonly peachpuff: [255, 218, 185];
133
+ readonly peru: [205, 133, 63];
134
+ readonly pink: [255, 192, 203];
135
+ readonly plum: [221, 160, 221];
136
+ readonly powderblue: [176, 224, 230];
137
+ readonly purple: [128, 0, 128];
138
+ readonly rebeccapurple: [102, 51, 153];
139
+ readonly red: [255, 0, 0];
140
+ readonly rosybrown: [188, 143, 143];
141
+ readonly royalblue: [65, 105, 225];
142
+ readonly saddlebrown: [139, 69, 19];
143
+ readonly salmon: [250, 128, 114];
144
+ readonly sandybrown: [244, 164, 96];
145
+ readonly seagreen: [46, 139, 87];
146
+ readonly seashell: [255, 245, 238];
147
+ readonly sienna: [160, 82, 45];
148
+ readonly silver: [192, 192, 192];
149
+ readonly skyblue: [135, 206, 235];
150
+ readonly slateblue: [106, 90, 205];
151
+ readonly slategray: [112, 128, 144];
152
+ readonly slategrey: [112, 128, 144];
153
+ readonly snow: [255, 250, 250];
154
+ readonly springgreen: [0, 255, 127];
155
+ readonly steelblue: [70, 130, 180];
156
+ readonly tan: [210, 180, 140];
157
+ readonly teal: [0, 128, 128];
158
+ readonly thistle: [216, 191, 216];
159
+ readonly tomato: [255, 99, 71];
160
+ readonly turquoise: [64, 224, 208];
161
+ readonly violet: [238, 130, 238];
162
+ readonly wheat: [245, 222, 179];
163
+ readonly white: [255, 255, 255];
164
+ readonly whitesmoke: [245, 245, 245];
165
+ readonly yellow: [255, 255, 0];
166
+ readonly yellowgreen: [154, 205, 50];
167
+ };
168
+ /**
169
+ * cache invalid color value
170
+ * @param key - cache key
171
+ * @param nullable - is nullable
172
+ * @returns cached value
173
+ */
174
+ export declare const cacheInvalidColorValue: (cacheKey: string, format: string, nullable?: boolean) => SpecifiedColorChannels | string | NullObject;
175
+ /**
176
+ * resolve invalid color value
177
+ * @param format - output format
178
+ * @param nullable - is nullable
179
+ * @returns resolved value
180
+ */
181
+ export declare const resolveInvalidColorValue: (format: string, nullable?: boolean) => SpecifiedColorChannels | string | NullObject;
182
+ /**
183
+ * validate color components
184
+ * @param arr - color components
185
+ * @param [opt] - options
186
+ * @param [opt.alpha] - alpha channel
187
+ * @param [opt.minLength] - min length
188
+ * @param [opt.maxLength] - max length
189
+ * @param [opt.minRange] - min range
190
+ * @param [opt.maxRange] - max range
191
+ * @param [opt.validateRange] - validate range
192
+ * @returns result - validated color components
193
+ */
194
+ export declare const validateColorComponents: (arr: ColorChannels | TriColorChannels, opt?: {
195
+ alpha?: boolean;
196
+ minLength?: number;
197
+ maxLength?: number;
198
+ minRange?: number;
199
+ maxRange?: number;
200
+ validateRange?: boolean;
201
+ }) => ColorChannels | TriColorChannels;
202
+ /**
203
+ * transform matrix
204
+ * @param mtx - 3 * 3 matrix
205
+ * @param vct - vector
206
+ * @param [skip] - skip validate
207
+ * @returns TriColorChannels - [p1, p2, p3]
208
+ */
209
+ export declare const transformMatrix: (mtx: ColorMatrix, vct: TriColorChannels, skip?: boolean) => TriColorChannels;
210
+ /**
211
+ * normalize color components
212
+ * @param colorA - color components [v1, v2, v3, v4]
213
+ * @param colorB - color components [v1, v2, v3, v4]
214
+ * @param [skip] - skip validate
215
+ * @returns result - [colorA, colorB]
216
+ */
217
+ export declare const normalizeColorComponents: (colorA: [number | string, number | string, number | string, number | string], colorB: [number | string, number | string, number | string, number | string], skip?: boolean) => [ColorChannels, ColorChannels];
218
+ /**
219
+ * number to hex string
220
+ * @param value - numeric value
221
+ * @returns hex string
222
+ */
223
+ export declare const numberToHexString: (value: number) => string;
224
+ /**
225
+ * angle to deg
226
+ * @param angle
227
+ * @returns deg: 0..360
228
+ */
229
+ export declare const angleToDeg: (angle: string) => number;
230
+ /**
231
+ * parse alpha
232
+ * @param [alpha] - alpha value
233
+ * @returns alpha: 0..1
234
+ */
235
+ export declare const parseAlpha: (alpha?: string) => number;
236
+ /**
237
+ * parse hex alpha
238
+ * @param value - alpha value in hex string
239
+ * @returns alpha: 0..1
240
+ */
241
+ export declare const parseHexAlpha: (value: string) => number;
242
+ /**
243
+ * transform rgb to linear rgb
244
+ * @param rgb - [r, g, b] r|g|b: 0..255
245
+ * @param [skip] - skip validate
246
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..1
247
+ */
248
+ export declare const transformRgbToLinearRgb: (rgb: TriColorChannels, skip?: boolean) => TriColorChannels;
249
+ /**
250
+ * transform rgb to xyz
251
+ * @param rgb - [r, g, b] r|g|b: 0..255
252
+ * @param [skip] - skip validate
253
+ * @returns TriColorChannels - [x, y, z]
254
+ */
255
+ export declare const transformRgbToXyz: (rgb: TriColorChannels, skip?: boolean) => TriColorChannels;
256
+ /**
257
+ * transform rgb to xyz-d50
258
+ * @param rgb - [r, g, b] r|g|b: 0..255 alpha: 0..1
259
+ * @returns TriColorChannels - [x, y, z]
260
+ */
261
+ export declare const transformRgbToXyzD50: (rgb: TriColorChannels) => TriColorChannels;
262
+ /**
263
+ * transform linear rgb to rgb
264
+ * @param rgb - [r, g, b] r|g|b: 0..1
265
+ * @param [round] - round result
266
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..255
267
+ */
268
+ export declare const transformLinearRgbToRgb: (rgb: TriColorChannels, round?: boolean) => TriColorChannels;
269
+ /**
270
+ * transform xyz to rgb
271
+ * @param xyz - [x, y, z]
272
+ * @param [skip] - skip validate
273
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..255
274
+ */
275
+ export declare const transformXyzToRgb: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
276
+ /**
277
+ * transform xyz to xyz-d50
278
+ * @param xyz - [x, y, z]
279
+ * @returns TriColorChannels - [x, y, z]
280
+ */
281
+ export declare const transformXyzToXyzD50: (xyz: TriColorChannels) => TriColorChannels;
282
+ /**
283
+ * transform xyz to hsl
284
+ * @param xyz - [x, y, z]
285
+ * @param [skip] - skip validate
286
+ * @returns TriColorChannels - [h, s, l]
287
+ */
288
+ export declare const transformXyzToHsl: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
289
+ /**
290
+ * transform xyz to hwb
291
+ * @param xyz - [x, y, z]
292
+ * @param [skip] - skip validate
293
+ * @returns TriColorChannels - [h, w, b]
294
+ */
295
+ export declare const transformXyzToHwb: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
296
+ /**
297
+ * transform xyz to oklab
298
+ * @param xyz - [x, y, z]
299
+ * @param [skip] - skip validate
300
+ * @returns TriColorChannels - [l, a, b]
301
+ */
302
+ export declare const transformXyzToOklab: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
303
+ /**
304
+ * transform xyz to oklch
305
+ * @param xyz - [x, y, z]
306
+ * @param [skip] - skip validate
307
+ * @returns TriColorChannels - [l, c, h]
308
+ */
309
+ export declare const transformXyzToOklch: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
310
+ /**
311
+ * transform xyz D50 to rgb
312
+ * @param xyz - [x, y, z]
313
+ * @param [skip] - skip validate
314
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..255
315
+ */
316
+ export declare const transformXyzD50ToRgb: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
317
+ /**
318
+ * transform xyz-d50 to lab
319
+ * @param xyz - [x, y, z]
320
+ * @param [skip] - skip validate
321
+ * @returns TriColorChannels - [l, a, b]
322
+ */
323
+ export declare const transformXyzD50ToLab: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
324
+ /**
325
+ * transform xyz-d50 to lch
326
+ * @param xyz - [x, y, z]
327
+ * @param [skip] - skip validate
328
+ * @returns TriColorChannels - [l, c, h]
329
+ */
330
+ export declare const transformXyzD50ToLch: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
331
+ /**
332
+ * convert rgb to hex color
333
+ * @param rgb - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
334
+ * @returns hex color
335
+ */
336
+ export declare const convertRgbToHex: (rgb: ColorChannels) => string;
337
+ /**
338
+ * convert linear rgb to hex color
339
+ * @param rgb - [r, g, b, alpha] r|g|b|alpha: 0..1
340
+ * @param [skip] - skip validate
341
+ * @returns hex color
342
+ */
343
+ export declare const convertLinearRgbToHex: (rgb: ColorChannels, skip?: boolean) => string;
344
+ /**
345
+ * convert xyz to hex color
346
+ * @param xyz - [x, y, z, alpha]
347
+ * @returns hex color
348
+ */
349
+ export declare const convertXyzToHex: (xyz: ColorChannels) => string;
350
+ /**
351
+ * convert xyz D50 to hex color
352
+ * @param xyz - [x, y, z, alpha]
353
+ * @returns hex color
354
+ */
355
+ export declare const convertXyzD50ToHex: (xyz: ColorChannels) => string;
356
+ /**
357
+ * convert hex color to rgb
358
+ * @param value - hex color value
359
+ * @returns ColorChannels - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
360
+ */
361
+ export declare const convertHexToRgb: (value: string) => ColorChannels;
362
+ /**
363
+ * convert hex color to linear rgb
364
+ * @param value - hex color value
365
+ * @returns ColorChannels - [r, g, b, alpha] r|g|b|alpha: 0..1
366
+ */
367
+ export declare const convertHexToLinearRgb: (value: string) => ColorChannels;
368
+ /**
369
+ * convert hex color to xyz
370
+ * @param value - hex color value
371
+ * @returns ColorChannels - [x, y, z, alpha]
372
+ */
373
+ export declare const convertHexToXyz: (value: string) => ColorChannels;
374
+ /**
375
+ * parse rgb()
376
+ * @param value - rgb color value
377
+ * @param [opt] - options
378
+ * @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
379
+ */
380
+ export declare const parseRgb: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
381
+ /**
382
+ * parse hsl()
383
+ * @param value - hsl color value
384
+ * @param [opt] - options
385
+ * @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
386
+ */
387
+ export declare const parseHsl: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
388
+ /**
389
+ * parse hwb()
390
+ * @param value - hwb color value
391
+ * @param [opt] - options
392
+ * @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
393
+ */
394
+ export declare const parseHwb: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
395
+ /**
396
+ * parse lab()
397
+ * @param value - lab color value
398
+ * @param [opt] - options
399
+ * @returns parsed color
400
+ * - [xyz-d50, x, y, z, alpha], ['lab', l, a, b, alpha], '(empty)', NullObject
401
+ */
402
+ export declare const parseLab: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
403
+ /**
404
+ * parse lch()
405
+ * @param value - lch color value
406
+ * @param [opt] - options
407
+ * @returns parsed color
408
+ * - ['xyz-d50', x, y, z, alpha], ['lch', l, c, h, alpha]
409
+ * - '(empty)', NullObject
410
+ */
411
+ export declare const parseLch: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
412
+ /**
413
+ * parse oklab()
414
+ * @param value - oklab color value
415
+ * @param [opt] - options
416
+ * @returns parsed color
417
+ * - ['xyz-d65', x, y, z, alpha], ['oklab', l, a, b, alpha]
418
+ * - '(empty)', NullObject
419
+ */
420
+ export declare const parseOklab: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
421
+ /**
422
+ * parse oklch()
423
+ * @param value - oklch color value
424
+ * @param [opt] - options
425
+ * @returns parsed color
426
+ * - ['xyz-d65', x, y, z, alpha], ['oklch', l, c, h, alpha]
427
+ * - '(empty)', NullObject
428
+ */
429
+ export declare const parseOklch: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
430
+ /**
431
+ * parse color()
432
+ * @param value - color function value
433
+ * @param [opt] - options
434
+ * @returns parsed color
435
+ * - ['xyz-(d50|d65)', x, y, z, alpha], [cs, r, g, b, alpha]
436
+ * - '(empty)', NullObject
437
+ */
438
+ export declare const parseColorFunc: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
439
+ /**
440
+ * parse color value
441
+ * @param value - CSS color value
442
+ * @param [opt] - options
443
+ * @returns parsed color
444
+ * - ['xyz-(d50|d65)', x, y, z, alpha], ['rgb', r, g, b, alpha]
445
+ * - value, '(empty)', NullObject
446
+ */
447
+ export declare const parseColorValue: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
448
+ /**
449
+ * resolve color value
450
+ * @param value - CSS color value
451
+ * @param [opt] - options
452
+ * @returns resolved color
453
+ * - [cs, v1, v2, v3, alpha], value, '(empty)', NullObject
454
+ */
455
+ export declare const resolveColorValue: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
456
+ /**
457
+ * resolve color()
458
+ * @param value - color function value
459
+ * @param [opt] - options
460
+ * @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)', NullObject
461
+ */
462
+ export declare const resolveColorFunc: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
463
+ /**
464
+ * convert color value to linear rgb
465
+ * @param value - CSS color value
466
+ * @param [opt] - options
467
+ * @returns ColorChannels | NullObject - [r, g, b, alpha] r|g|b|alpha: 0..1
468
+ */
469
+ export declare const convertColorToLinearRgb: (value: string, opt?: {
470
+ colorSpace?: string;
471
+ format?: string;
472
+ }) => ColorChannels | NullObject;
473
+ /**
474
+ * convert color value to rgb
475
+ * @param value - CSS color value
476
+ * @param [opt] - options
477
+ * @returns ColorChannels | NullObject
478
+ * - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
479
+ */
480
+ export declare const convertColorToRgb: (value: string, opt?: Options) => ColorChannels | NullObject;
481
+ /**
482
+ * convert color value to xyz
483
+ * @param value - CSS color value
484
+ * @param [opt] - options
485
+ * @returns ColorChannels | NullObject - [x, y, z, alpha]
486
+ */
487
+ export declare const convertColorToXyz: (value: string, opt?: Options) => ColorChannels | NullObject;
488
+ /**
489
+ * convert color value to hsl
490
+ * @param value - CSS color value
491
+ * @param [opt] - options
492
+ * @returns ColorChannels | NullObject - [h, s, l, alpha], hue may be powerless
493
+ */
494
+ export declare const convertColorToHsl: (value: string, opt?: Options) => ColorChannels | [number | string, number, number, number] | NullObject;
495
+ /**
496
+ * convert color value to hwb
497
+ * @param value - CSS color value
498
+ * @param [opt] - options
499
+ * @returns ColorChannels | NullObject - [h, w, b, alpha], hue may be powerless
500
+ */
501
+ export declare const convertColorToHwb: (value: string, opt?: Options) => ColorChannels | [number | string, number, number, number] | NullObject;
502
+ /**
503
+ * convert color value to lab
504
+ * @param value - CSS color value
505
+ * @param [opt] - options
506
+ * @returns ColorChannels | NullObject - [l, a, b, alpha]
507
+ */
508
+ export declare const convertColorToLab: (value: string, opt?: Options) => ColorChannels | NullObject;
509
+ /**
510
+ * convert color value to lch
511
+ * @param value - CSS color value
512
+ * @param [opt] - options
513
+ * @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
514
+ */
515
+ export declare const convertColorToLch: (value: string, opt?: Options) => ColorChannels | [number, number, number | string, number] | NullObject;
516
+ /**
517
+ * convert color value to oklab
518
+ * @param value - CSS color value
519
+ * @param [opt] - options
520
+ * @returns ColorChannels | NullObject - [l, a, b, alpha]
521
+ */
522
+ export declare const convertColorToOklab: (value: string, opt?: Options) => ColorChannels | NullObject;
523
+ /**
524
+ * convert color value to oklch
525
+ * @param value - CSS color value
526
+ * @param [opt] - options
527
+ * @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
528
+ */
529
+ export declare const convertColorToOklch: (value: string, opt?: Options) => ColorChannels | [number, number, number | string, number] | NullObject;
530
+ /**
531
+ * resolve color-mix()
532
+ * @param value - color-mix color value
533
+ * @param [opt] - options
534
+ * @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)'
535
+ */
536
+ export declare const resolveColorMix: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
537
+ export {};
node_modules/@asamuzakjp/css-color/dist/esm/js/color.js ADDED
@@ -0,0 +1,3534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { CacheItem, NullObject, createCacheKey, getCache, setCache } from "./cache.js";
2
+ import { isString } from "./common.js";
3
+ import { ANGLE, CS_HUE_CAPT, CS_MIX, CS_RGB, CS_XYZ, FN_MIX, NONE, NUM, PCT, SYN_COLOR_TYPE, SYN_FN_COLOR, SYN_HSL, SYN_HSL_LV3, SYN_LCH, SYN_MIX, SYN_MIX_CAPT, SYN_MIX_PART, SYN_MOD, SYN_RGB_LV3, VAL_COMP, VAL_MIX, VAL_SPEC } from "./constant.js";
4
+ import { resolveColor } from "./resolve.js";
5
+ import { interpolateHue, roundToPrecision, splitValue } from "./util.js";
6
+ //#region src/js/color.ts
7
+ /**
8
+ * color
9
+ *
10
+ * Ref: CSS Color Module Level 4
11
+ * Sample code for Color Conversions
12
+ * https://w3c.github.io/csswg-drafts/css-color-4/#color-conversion-code
13
+ */
14
+ var NAMESPACE = "color";
15
+ var PPTH = .001;
16
+ var HALF = .5;
17
+ var DUO = 2;
18
+ var TRIA = 3;
19
+ var QUAD = 4;
20
+ var OCT = 8;
21
+ var DEC = 10;
22
+ var DOZ = 12;
23
+ var HEX = 16;
24
+ var SEXA = 60;
25
+ var DEG_HALF = 180;
26
+ var DEG = 360;
27
+ var MAX_PCT = 100;
28
+ var MAX_RGB = 255;
29
+ var POW_SQR = 2;
30
+ var POW_CUBE = 3;
31
+ var POW_LINEAR = 2.4;
32
+ var LINEAR_COEF = 12.92;
33
+ var LINEAR_OFFSET = .055;
34
+ var LAB_L = 116;
35
+ var LAB_A = 500;
36
+ var LAB_B = 200;
37
+ var LAB_EPSILON = 216 / 24389;
38
+ var LAB_KAPPA = 24389 / 27;
39
+ var D50 = [
40
+ .3457 / .3585,
41
+ 1,
42
+ .2958 / .3585
43
+ ];
44
+ var MATRIX_D50_TO_D65 = [
45
+ [
46
+ .955473421488075,
47
+ -.02309845494876471,
48
+ .06325924320057072
49
+ ],
50
+ [
51
+ -.0283697093338637,
52
+ 1.0099953980813041,
53
+ .021041441191917323
54
+ ],
55
+ [
56
+ .012314014864481998,
57
+ -.020507649298898964,
58
+ 1.330365926242124
59
+ ]
60
+ ];
61
+ var MATRIX_D65_TO_D50 = [
62
+ [
63
+ 1.0479297925449969,
64
+ .022946870601609652,
65
+ -.05019226628920524
66
+ ],
67
+ [
68
+ .02962780877005599,
69
+ .9904344267538799,
70
+ -.017073799063418826
71
+ ],
72
+ [
73
+ -.009243040646204504,
74
+ .015055191490298152,
75
+ .7518742814281371
76
+ ]
77
+ ];
78
+ var MATRIX_L_RGB_TO_XYZ = [
79
+ [
80
+ 506752 / 1228815,
81
+ 87881 / 245763,
82
+ 12673 / 70218
83
+ ],
84
+ [
85
+ 87098 / 409605,
86
+ 175762 / 245763,
87
+ 12673 / 175545
88
+ ],
89
+ [
90
+ 7918 / 409605,
91
+ 87881 / 737289,
92
+ 1001167 / 1053270
93
+ ]
94
+ ];
95
+ var MATRIX_XYZ_TO_L_RGB = [
96
+ [
97
+ 12831 / 3959,
98
+ -329 / 214,
99
+ -1974 / 3959
100
+ ],
101
+ [
102
+ -851781 / 878810,
103
+ 1648619 / 878810,
104
+ 36519 / 878810
105
+ ],
106
+ [
107
+ 705 / 12673,
108
+ -2585 / 12673,
109
+ 705 / 667
110
+ ]
111
+ ];
112
+ var MATRIX_XYZ_TO_LMS = [
113
+ [
114
+ .819022437996703,
115
+ .3619062600528904,
116
+ -.1288737815209879
117
+ ],
118
+ [
119
+ .0329836539323885,
120
+ .9292868615863434,
121
+ .0361446663506424
122
+ ],
123
+ [
124
+ .0481771893596242,
125
+ .2642395317527308,
126
+ .6335478284694309
127
+ ]
128
+ ];
129
+ var MATRIX_LMS_TO_XYZ = [
130
+ [
131
+ 1.2268798758459243,
132
+ -.5578149944602171,
133
+ .2813910456659647
134
+ ],
135
+ [
136
+ -.0405757452148008,
137
+ 1.112286803280317,
138
+ -.0717110580655164
139
+ ],
140
+ [
141
+ -.0763729366746601,
142
+ -.4214933324022432,
143
+ 1.5869240198367816
144
+ ]
145
+ ];
146
+ var MATRIX_OKLAB_TO_LMS = [
147
+ [
148
+ 1,
149
+ .3963377773761749,
150
+ .2158037573099136
151
+ ],
152
+ [
153
+ 1,
154
+ -.1055613458156586,
155
+ -.0638541728258133
156
+ ],
157
+ [
158
+ 1,
159
+ -.0894841775298119,
160
+ -1.2914855480194092
161
+ ]
162
+ ];
163
+ var MATRIX_LMS_TO_OKLAB = [
164
+ [
165
+ .210454268309314,
166
+ .7936177747023054,
167
+ -.0040720430116193
168
+ ],
169
+ [
170
+ 1.9779985324311684,
171
+ -2.42859224204858,
172
+ .450593709617411
173
+ ],
174
+ [
175
+ .0259040424655478,
176
+ .7827717124575296,
177
+ -.8086757549230774
178
+ ]
179
+ ];
180
+ var MATRIX_P3_TO_XYZ = [
181
+ [
182
+ 608311 / 1250200,
183
+ 189793 / 714400,
184
+ 198249 / 1000160
185
+ ],
186
+ [
187
+ 35783 / 156275,
188
+ 247089 / 357200,
189
+ 198249 / 2500400
190
+ ],
191
+ [
192
+ 0 / 1,
193
+ 32229 / 714400,
194
+ 5220557 / 5000800
195
+ ]
196
+ ];
197
+ var MATRIX_REC2020_TO_XYZ = [
198
+ [
199
+ 63426534 / 99577255,
200
+ 20160776 / 139408157,
201
+ 47086771 / 278816314
202
+ ],
203
+ [
204
+ 26158966 / 99577255,
205
+ 472592308 / 697040785,
206
+ 8267143 / 139408157
207
+ ],
208
+ [
209
+ 0 / 1,
210
+ 19567812 / 697040785,
211
+ 295819943 / 278816314
212
+ ]
213
+ ];
214
+ var MATRIX_A98_TO_XYZ = [
215
+ [
216
+ 573536 / 994567,
217
+ 263643 / 1420810,
218
+ 187206 / 994567
219
+ ],
220
+ [
221
+ 591459 / 1989134,
222
+ 6239551 / 9945670,
223
+ 374412 / 4972835
224
+ ],
225
+ [
226
+ 53769 / 1989134,
227
+ 351524 / 4972835,
228
+ 4929758 / 4972835
229
+ ]
230
+ ];
231
+ var MATRIX_PROPHOTO_TO_XYZ_D50 = [
232
+ [
233
+ .7977666449006423,
234
+ .13518129740053308,
235
+ .0313477341283922
236
+ ],
237
+ [
238
+ .2880748288194013,
239
+ .711835234241873,
240
+ 8993693872564e-17
241
+ ],
242
+ [
243
+ 0,
244
+ 0,
245
+ .8251046025104602
246
+ ]
247
+ ];
248
+ var REG_COLOR = new RegExp(`^(?:${SYN_COLOR_TYPE})$`);
249
+ var REG_CS_HUE = new RegExp(`^${CS_HUE_CAPT}$`);
250
+ var REG_CS_XYZ = /^xyz(?:-d(?:50|65))?$/;
251
+ var REG_CURRENT = /^currentColor$/i;
252
+ var REG_FN_COLOR = new RegExp(`^color\\(\\s*(${SYN_FN_COLOR})\\s*\\)$`);
253
+ var REG_HSL = new RegExp(`^hsla?\\(\\s*(${SYN_HSL}|${SYN_HSL_LV3})\\s*\\)$`);
254
+ var REG_HWB = new RegExp(`^hwb\\(\\s*(${SYN_HSL})\\s*\\)$`);
255
+ var REG_LAB = new RegExp(`^lab\\(\\s*(${SYN_MOD})\\s*\\)$`);
256
+ var REG_LCH = new RegExp(`^lch\\(\\s*(${SYN_LCH})\\s*\\)$`);
257
+ var REG_MIX = new RegExp(`^${SYN_MIX}$`);
258
+ var REG_MIX_CAPT = new RegExp(`^${SYN_MIX_CAPT}$`);
259
+ var REG_MIX_NEST = new RegExp(`${SYN_MIX}`, "g");
260
+ var REG_OKLAB = new RegExp(`^oklab\\(\\s*(${SYN_MOD})\\s*\\)$`);
261
+ var REG_OKLCH = new RegExp(`^oklch\\(\\s*(${SYN_LCH})\\s*\\)$`);
262
+ var REG_SPEC = /^(?:specifi|comput)edValue$/;
263
+ var REG_ANGLE_TO_DEG = new RegExp(`^(${NUM})(${ANGLE})?$`);
264
+ var REG_PARSE_RGB = new RegExp(`^rgba?\\(\\s*(${SYN_MOD}|${SYN_RGB_LV3})\\s*\\)$`);
265
+ var REG_MIX_CS_RGB_XYZ = new RegExp(`^(?:${CS_RGB}|${CS_XYZ})$`);
266
+ var REG_MIX_IN_CS = new RegExp(`in\\s+(${CS_MIX})`);
267
+ var REG_MIX_START = new RegExp(`^color-mix\\(\\s*in\\s+(${CS_MIX})\\s*,`);
268
+ var REG_MIX_COLOR_PART = new RegExp(`^(${SYN_COLOR_TYPE})(?:\\s+(${PCT}))?$`);
269
+ /**
270
+ * named colors
271
+ */
272
+ var NAMED_COLORS = {
273
+ aliceblue: [
274
+ 240,
275
+ 248,
276
+ 255
277
+ ],
278
+ antiquewhite: [
279
+ 250,
280
+ 235,
281
+ 215
282
+ ],
283
+ aqua: [
284
+ 0,
285
+ 255,
286
+ 255
287
+ ],
288
+ aquamarine: [
289
+ 127,
290
+ 255,
291
+ 212
292
+ ],
293
+ azure: [
294
+ 240,
295
+ 255,
296
+ 255
297
+ ],
298
+ beige: [
299
+ 245,
300
+ 245,
301
+ 220
302
+ ],
303
+ bisque: [
304
+ 255,
305
+ 228,
306
+ 196
307
+ ],
308
+ black: [
309
+ 0,
310
+ 0,
311
+ 0
312
+ ],
313
+ blanchedalmond: [
314
+ 255,
315
+ 235,
316
+ 205
317
+ ],
318
+ blue: [
319
+ 0,
320
+ 0,
321
+ 255
322
+ ],
323
+ blueviolet: [
324
+ 138,
325
+ 43,
326
+ 226
327
+ ],
328
+ brown: [
329
+ 165,
330
+ 42,
331
+ 42
332
+ ],
333
+ burlywood: [
334
+ 222,
335
+ 184,
336
+ 135
337
+ ],
338
+ cadetblue: [
339
+ 95,
340
+ 158,
341
+ 160
342
+ ],
343
+ chartreuse: [
344
+ 127,
345
+ 255,
346
+ 0
347
+ ],
348
+ chocolate: [
349
+ 210,
350
+ 105,
351
+ 30
352
+ ],
353
+ coral: [
354
+ 255,
355
+ 127,
356
+ 80
357
+ ],
358
+ cornflowerblue: [
359
+ 100,
360
+ 149,
361
+ 237
362
+ ],
363
+ cornsilk: [
364
+ 255,
365
+ 248,
366
+ 220
367
+ ],
368
+ crimson: [
369
+ 220,
370
+ 20,
371
+ 60
372
+ ],
373
+ cyan: [
374
+ 0,
375
+ 255,
376
+ 255
377
+ ],
378
+ darkblue: [
379
+ 0,
380
+ 0,
381
+ 139
382
+ ],
383
+ darkcyan: [
384
+ 0,
385
+ 139,
386
+ 139
387
+ ],
388
+ darkgoldenrod: [
389
+ 184,
390
+ 134,
391
+ 11
392
+ ],
393
+ darkgray: [
394
+ 169,
395
+ 169,
396
+ 169
397
+ ],
398
+ darkgreen: [
399
+ 0,
400
+ 100,
401
+ 0
402
+ ],
403
+ darkgrey: [
404
+ 169,
405
+ 169,
406
+ 169
407
+ ],
408
+ darkkhaki: [
409
+ 189,
410
+ 183,
411
+ 107
412
+ ],
413
+ darkmagenta: [
414
+ 139,
415
+ 0,
416
+ 139
417
+ ],
418
+ darkolivegreen: [
419
+ 85,
420
+ 107,
421
+ 47
422
+ ],
423
+ darkorange: [
424
+ 255,
425
+ 140,
426
+ 0
427
+ ],
428
+ darkorchid: [
429
+ 153,
430
+ 50,
431
+ 204
432
+ ],
433
+ darkred: [
434
+ 139,
435
+ 0,
436
+ 0
437
+ ],
438
+ darksalmon: [
439
+ 233,
440
+ 150,
441
+ 122
442
+ ],
443
+ darkseagreen: [
444
+ 143,
445
+ 188,
446
+ 143
447
+ ],
448
+ darkslateblue: [
449
+ 72,
450
+ 61,
451
+ 139
452
+ ],
453
+ darkslategray: [
454
+ 47,
455
+ 79,
456
+ 79
457
+ ],
458
+ darkslategrey: [
459
+ 47,
460
+ 79,
461
+ 79
462
+ ],
463
+ darkturquoise: [
464
+ 0,
465
+ 206,
466
+ 209
467
+ ],
468
+ darkviolet: [
469
+ 148,
470
+ 0,
471
+ 211
472
+ ],
473
+ deeppink: [
474
+ 255,
475
+ 20,
476
+ 147
477
+ ],
478
+ deepskyblue: [
479
+ 0,
480
+ 191,
481
+ 255
482
+ ],
483
+ dimgray: [
484
+ 105,
485
+ 105,
486
+ 105
487
+ ],
488
+ dimgrey: [
489
+ 105,
490
+ 105,
491
+ 105
492
+ ],
493
+ dodgerblue: [
494
+ 30,
495
+ 144,
496
+ 255
497
+ ],
498
+ firebrick: [
499
+ 178,
500
+ 34,
501
+ 34
502
+ ],
503
+ floralwhite: [
504
+ 255,
505
+ 250,
506
+ 240
507
+ ],
508
+ forestgreen: [
509
+ 34,
510
+ 139,
511
+ 34
512
+ ],
513
+ fuchsia: [
514
+ 255,
515
+ 0,
516
+ 255
517
+ ],
518
+ gainsboro: [
519
+ 220,
520
+ 220,
521
+ 220
522
+ ],
523
+ ghostwhite: [
524
+ 248,
525
+ 248,
526
+ 255
527
+ ],
528
+ gold: [
529
+ 255,
530
+ 215,
531
+ 0
532
+ ],
533
+ goldenrod: [
534
+ 218,
535
+ 165,
536
+ 32
537
+ ],
538
+ gray: [
539
+ 128,
540
+ 128,
541
+ 128
542
+ ],
543
+ green: [
544
+ 0,
545
+ 128,
546
+ 0
547
+ ],
548
+ greenyellow: [
549
+ 173,
550
+ 255,
551
+ 47
552
+ ],
553
+ grey: [
554
+ 128,
555
+ 128,
556
+ 128
557
+ ],
558
+ honeydew: [
559
+ 240,
560
+ 255,
561
+ 240
562
+ ],
563
+ hotpink: [
564
+ 255,
565
+ 105,
566
+ 180
567
+ ],
568
+ indianred: [
569
+ 205,
570
+ 92,
571
+ 92
572
+ ],
573
+ indigo: [
574
+ 75,
575
+ 0,
576
+ 130
577
+ ],
578
+ ivory: [
579
+ 255,
580
+ 255,
581
+ 240
582
+ ],
583
+ khaki: [
584
+ 240,
585
+ 230,
586
+ 140
587
+ ],
588
+ lavender: [
589
+ 230,
590
+ 230,
591
+ 250
592
+ ],
593
+ lavenderblush: [
594
+ 255,
595
+ 240,
596
+ 245
597
+ ],
598
+ lawngreen: [
599
+ 124,
600
+ 252,
601
+ 0
602
+ ],
603
+ lemonchiffon: [
604
+ 255,
605
+ 250,
606
+ 205
607
+ ],
608
+ lightblue: [
609
+ 173,
610
+ 216,
611
+ 230
612
+ ],
613
+ lightcoral: [
614
+ 240,
615
+ 128,
616
+ 128
617
+ ],
618
+ lightcyan: [
619
+ 224,
620
+ 255,
621
+ 255
622
+ ],
623
+ lightgoldenrodyellow: [
624
+ 250,
625
+ 250,
626
+ 210
627
+ ],
628
+ lightgray: [
629
+ 211,
630
+ 211,
631
+ 211
632
+ ],
633
+ lightgreen: [
634
+ 144,
635
+ 238,
636
+ 144
637
+ ],
638
+ lightgrey: [
639
+ 211,
640
+ 211,
641
+ 211
642
+ ],
643
+ lightpink: [
644
+ 255,
645
+ 182,
646
+ 193
647
+ ],
648
+ lightsalmon: [
649
+ 255,
650
+ 160,
651
+ 122
652
+ ],
653
+ lightseagreen: [
654
+ 32,
655
+ 178,
656
+ 170
657
+ ],
658
+ lightskyblue: [
659
+ 135,
660
+ 206,
661
+ 250
662
+ ],
663
+ lightslategray: [
664
+ 119,
665
+ 136,
666
+ 153
667
+ ],
668
+ lightslategrey: [
669
+ 119,
670
+ 136,
671
+ 153
672
+ ],
673
+ lightsteelblue: [
674
+ 176,
675
+ 196,
676
+ 222
677
+ ],
678
+ lightyellow: [
679
+ 255,
680
+ 255,
681
+ 224
682
+ ],
683
+ lime: [
684
+ 0,
685
+ 255,
686
+ 0
687
+ ],
688
+ limegreen: [
689
+ 50,
690
+ 205,
691
+ 50
692
+ ],
693
+ linen: [
694
+ 250,
695
+ 240,
696
+ 230
697
+ ],
698
+ magenta: [
699
+ 255,
700
+ 0,
701
+ 255
702
+ ],
703
+ maroon: [
704
+ 128,
705
+ 0,
706
+ 0
707
+ ],
708
+ mediumaquamarine: [
709
+ 102,
710
+ 205,
711
+ 170
712
+ ],
713
+ mediumblue: [
714
+ 0,
715
+ 0,
716
+ 205
717
+ ],
718
+ mediumorchid: [
719
+ 186,
720
+ 85,
721
+ 211
722
+ ],
723
+ mediumpurple: [
724
+ 147,
725
+ 112,
726
+ 219
727
+ ],
728
+ mediumseagreen: [
729
+ 60,
730
+ 179,
731
+ 113
732
+ ],
733
+ mediumslateblue: [
734
+ 123,
735
+ 104,
736
+ 238
737
+ ],
738
+ mediumspringgreen: [
739
+ 0,
740
+ 250,
741
+ 154
742
+ ],
743
+ mediumturquoise: [
744
+ 72,
745
+ 209,
746
+ 204
747
+ ],
748
+ mediumvioletred: [
749
+ 199,
750
+ 21,
751
+ 133
752
+ ],
753
+ midnightblue: [
754
+ 25,
755
+ 25,
756
+ 112
757
+ ],
758
+ mintcream: [
759
+ 245,
760
+ 255,
761
+ 250
762
+ ],
763
+ mistyrose: [
764
+ 255,
765
+ 228,
766
+ 225
767
+ ],
768
+ moccasin: [
769
+ 255,
770
+ 228,
771
+ 181
772
+ ],
773
+ navajowhite: [
774
+ 255,
775
+ 222,
776
+ 173
777
+ ],
778
+ navy: [
779
+ 0,
780
+ 0,
781
+ 128
782
+ ],
783
+ oldlace: [
784
+ 253,
785
+ 245,
786
+ 230
787
+ ],
788
+ olive: [
789
+ 128,
790
+ 128,
791
+ 0
792
+ ],
793
+ olivedrab: [
794
+ 107,
795
+ 142,
796
+ 35
797
+ ],
798
+ orange: [
799
+ 255,
800
+ 165,
801
+ 0
802
+ ],
803
+ orangered: [
804
+ 255,
805
+ 69,
806
+ 0
807
+ ],
808
+ orchid: [
809
+ 218,
810
+ 112,
811
+ 214
812
+ ],
813
+ palegoldenrod: [
814
+ 238,
815
+ 232,
816
+ 170
817
+ ],
818
+ palegreen: [
819
+ 152,
820
+ 251,
821
+ 152
822
+ ],
823
+ paleturquoise: [
824
+ 175,
825
+ 238,
826
+ 238
827
+ ],
828
+ palevioletred: [
829
+ 219,
830
+ 112,
831
+ 147
832
+ ],
833
+ papayawhip: [
834
+ 255,
835
+ 239,
836
+ 213
837
+ ],
838
+ peachpuff: [
839
+ 255,
840
+ 218,
841
+ 185
842
+ ],
843
+ peru: [
844
+ 205,
845
+ 133,
846
+ 63
847
+ ],
848
+ pink: [
849
+ 255,
850
+ 192,
851
+ 203
852
+ ],
853
+ plum: [
854
+ 221,
855
+ 160,
856
+ 221
857
+ ],
858
+ powderblue: [
859
+ 176,
860
+ 224,
861
+ 230
862
+ ],
863
+ purple: [
864
+ 128,
865
+ 0,
866
+ 128
867
+ ],
868
+ rebeccapurple: [
869
+ 102,
870
+ 51,
871
+ 153
872
+ ],
873
+ red: [
874
+ 255,
875
+ 0,
876
+ 0
877
+ ],
878
+ rosybrown: [
879
+ 188,
880
+ 143,
881
+ 143
882
+ ],
883
+ royalblue: [
884
+ 65,
885
+ 105,
886
+ 225
887
+ ],
888
+ saddlebrown: [
889
+ 139,
890
+ 69,
891
+ 19
892
+ ],
893
+ salmon: [
894
+ 250,
895
+ 128,
896
+ 114
897
+ ],
898
+ sandybrown: [
899
+ 244,
900
+ 164,
901
+ 96
902
+ ],
903
+ seagreen: [
904
+ 46,
905
+ 139,
906
+ 87
907
+ ],
908
+ seashell: [
909
+ 255,
910
+ 245,
911
+ 238
912
+ ],
913
+ sienna: [
914
+ 160,
915
+ 82,
916
+ 45
917
+ ],
918
+ silver: [
919
+ 192,
920
+ 192,
921
+ 192
922
+ ],
923
+ skyblue: [
924
+ 135,
925
+ 206,
926
+ 235
927
+ ],
928
+ slateblue: [
929
+ 106,
930
+ 90,
931
+ 205
932
+ ],
933
+ slategray: [
934
+ 112,
935
+ 128,
936
+ 144
937
+ ],
938
+ slategrey: [
939
+ 112,
940
+ 128,
941
+ 144
942
+ ],
943
+ snow: [
944
+ 255,
945
+ 250,
946
+ 250
947
+ ],
948
+ springgreen: [
949
+ 0,
950
+ 255,
951
+ 127
952
+ ],
953
+ steelblue: [
954
+ 70,
955
+ 130,
956
+ 180
957
+ ],
958
+ tan: [
959
+ 210,
960
+ 180,
961
+ 140
962
+ ],
963
+ teal: [
964
+ 0,
965
+ 128,
966
+ 128
967
+ ],
968
+ thistle: [
969
+ 216,
970
+ 191,
971
+ 216
972
+ ],
973
+ tomato: [
974
+ 255,
975
+ 99,
976
+ 71
977
+ ],
978
+ turquoise: [
979
+ 64,
980
+ 224,
981
+ 208
982
+ ],
983
+ violet: [
984
+ 238,
985
+ 130,
986
+ 238
987
+ ],
988
+ wheat: [
989
+ 245,
990
+ 222,
991
+ 179
992
+ ],
993
+ white: [
994
+ 255,
995
+ 255,
996
+ 255
997
+ ],
998
+ whitesmoke: [
999
+ 245,
1000
+ 245,
1001
+ 245
1002
+ ],
1003
+ yellow: [
1004
+ 255,
1005
+ 255,
1006
+ 0
1007
+ ],
1008
+ yellowgreen: [
1009
+ 154,
1010
+ 205,
1011
+ 50
1012
+ ]
1013
+ };
1014
+ /**
1015
+ * cache invalid color value
1016
+ * @param key - cache key
1017
+ * @param nullable - is nullable
1018
+ * @returns cached value
1019
+ */
1020
+ var cacheInvalidColorValue = (cacheKey, format, nullable = false) => {
1021
+ if (format === "specifiedValue") {
1022
+ const res = "";
1023
+ setCache(cacheKey, res);
1024
+ return res;
1025
+ }
1026
+ if (nullable) {
1027
+ setCache(cacheKey, null);
1028
+ return new NullObject();
1029
+ }
1030
+ const res = [
1031
+ "rgb",
1032
+ 0,
1033
+ 0,
1034
+ 0,
1035
+ 0
1036
+ ];
1037
+ setCache(cacheKey, res);
1038
+ return res;
1039
+ };
1040
+ /**
1041
+ * resolve invalid color value
1042
+ * @param format - output format
1043
+ * @param nullable - is nullable
1044
+ * @returns resolved value
1045
+ */
1046
+ var resolveInvalidColorValue = (format, nullable = false) => {
1047
+ switch (format) {
1048
+ case "hsl":
1049
+ case "hwb":
1050
+ case VAL_MIX: return new NullObject();
1051
+ case VAL_SPEC: return "";
1052
+ default:
1053
+ if (nullable) return new NullObject();
1054
+ return [
1055
+ "rgb",
1056
+ 0,
1057
+ 0,
1058
+ 0,
1059
+ 0
1060
+ ];
1061
+ }
1062
+ };
1063
+ /**
1064
+ * validate color components
1065
+ * @param arr - color components
1066
+ * @param [opt] - options
1067
+ * @param [opt.alpha] - alpha channel
1068
+ * @param [opt.minLength] - min length
1069
+ * @param [opt.maxLength] - max length
1070
+ * @param [opt.minRange] - min range
1071
+ * @param [opt.maxRange] - max range
1072
+ * @param [opt.validateRange] - validate range
1073
+ * @returns result - validated color components
1074
+ */
1075
+ var validateColorComponents = (arr, opt = {}) => {
1076
+ if (!Array.isArray(arr)) throw new TypeError(`${arr} is not an array.`);
1077
+ const { alpha = false, minLength = TRIA, maxLength = QUAD, minRange = 0, maxRange = 1, validateRange = true } = opt;
1078
+ if (!Number.isFinite(minLength)) throw new TypeError(`${minLength} is not a number.`);
1079
+ if (!Number.isFinite(maxLength)) throw new TypeError(`${maxLength} is not a number.`);
1080
+ if (!Number.isFinite(minRange)) throw new TypeError(`${minRange} is not a number.`);
1081
+ if (!Number.isFinite(maxRange)) throw new TypeError(`${maxRange} is not a number.`);
1082
+ const l = arr.length;
1083
+ if (l < minLength || l > maxLength) throw new Error(`Unexpected array length ${l}.`);
1084
+ let i = 0;
1085
+ while (i < l) {
1086
+ const v = arr[i];
1087
+ if (!Number.isFinite(v)) throw new TypeError(`${v} is not a number.`);
1088
+ else if (i < TRIA && validateRange && (v < minRange || v > maxRange)) throw new RangeError(`${v} is not between ${minRange} and ${maxRange}.`);
1089
+ else if (i === TRIA && (v < 0 || v > 1)) throw new RangeError(`${v} is not between 0 and 1.`);
1090
+ i++;
1091
+ }
1092
+ if (alpha && l === TRIA) arr.push(1);
1093
+ return arr;
1094
+ };
1095
+ /**
1096
+ * transform matrix
1097
+ * @param mtx - 3 * 3 matrix
1098
+ * @param vct - vector
1099
+ * @param [skip] - skip validate
1100
+ * @returns TriColorChannels - [p1, p2, p3]
1101
+ */
1102
+ var transformMatrix = (mtx, vct, skip = false) => {
1103
+ if (!Array.isArray(mtx)) throw new TypeError(`${mtx} is not an array.`);
1104
+ else if (mtx.length !== TRIA) throw new Error(`Unexpected array length ${mtx.length}.`);
1105
+ else if (!skip) for (let i of mtx) i = validateColorComponents(i, {
1106
+ maxLength: TRIA,
1107
+ validateRange: false
1108
+ });
1109
+ const [[r1c1, r1c2, r1c3], [r2c1, r2c2, r2c3], [r3c1, r3c2, r3c3]] = mtx;
1110
+ let v1, v2, v3;
1111
+ if (skip) [v1, v2, v3] = vct;
1112
+ else [v1, v2, v3] = validateColorComponents(vct, {
1113
+ maxLength: TRIA,
1114
+ validateRange: false
1115
+ });
1116
+ return [
1117
+ r1c1 * v1 + r1c2 * v2 + r1c3 * v3,
1118
+ r2c1 * v1 + r2c2 * v2 + r2c3 * v3,
1119
+ r3c1 * v1 + r3c2 * v2 + r3c3 * v3
1120
+ ];
1121
+ };
1122
+ /**
1123
+ * normalize color components
1124
+ * @param colorA - color components [v1, v2, v3, v4]
1125
+ * @param colorB - color components [v1, v2, v3, v4]
1126
+ * @param [skip] - skip validate
1127
+ * @returns result - [colorA, colorB]
1128
+ */
1129
+ var normalizeColorComponents = (colorA, colorB, skip = false) => {
1130
+ if (!Array.isArray(colorA)) throw new TypeError(`${colorA} is not an array.`);
1131
+ else if (colorA.length !== QUAD) throw new Error(`Unexpected array length ${colorA.length}.`);
1132
+ if (!Array.isArray(colorB)) throw new TypeError(`${colorB} is not an array.`);
1133
+ else if (colorB.length !== QUAD) throw new Error(`Unexpected array length ${colorB.length}.`);
1134
+ let i = 0;
1135
+ while (i < QUAD) {
1136
+ if (colorA[i] === "none" && colorB[i] === "none") {
1137
+ colorA[i] = 0;
1138
+ colorB[i] = 0;
1139
+ } else if (colorA[i] === "none") colorA[i] = colorB[i];
1140
+ else if (colorB[i] === "none") colorB[i] = colorA[i];
1141
+ i++;
1142
+ }
1143
+ if (skip) return [colorA, colorB];
1144
+ return [validateColorComponents(colorA, {
1145
+ minLength: QUAD,
1146
+ validateRange: false
1147
+ }), validateColorComponents(colorB, {
1148
+ minLength: QUAD,
1149
+ validateRange: false
1150
+ })];
1151
+ };
1152
+ /**
1153
+ * number to hex string
1154
+ * @param value - numeric value
1155
+ * @returns hex string
1156
+ */
1157
+ var numberToHexString = (value) => {
1158
+ if (!Number.isFinite(value)) throw new TypeError(`${value} is not a number.`);
1159
+ else {
1160
+ value = Math.round(value);
1161
+ if (value < 0 || value > MAX_RGB) throw new RangeError(`${value} is not between 0 and ${MAX_RGB}.`);
1162
+ }
1163
+ let hex = value.toString(HEX);
1164
+ if (hex.length === 1) hex = `0${hex}`;
1165
+ return hex;
1166
+ };
1167
+ /**
1168
+ * angle to deg
1169
+ * @param angle
1170
+ * @returns deg: 0..360
1171
+ */
1172
+ var angleToDeg = (angle) => {
1173
+ if (isString(angle)) angle = angle.trim();
1174
+ else throw new TypeError(`${angle} is not a string.`);
1175
+ const GRAD = DEG / 400;
1176
+ const RAD = DEG / (Math.PI * DUO);
1177
+ if (!REG_ANGLE_TO_DEG.test(angle)) throw new SyntaxError(`Invalid property value: ${angle}`);
1178
+ const [, value, unit] = angle.match(REG_ANGLE_TO_DEG);
1179
+ let deg;
1180
+ switch (unit) {
1181
+ case "grad":
1182
+ deg = parseFloat(value) * GRAD;
1183
+ break;
1184
+ case "rad":
1185
+ deg = parseFloat(value) * RAD;
1186
+ break;
1187
+ case "turn":
1188
+ deg = parseFloat(value) * DEG;
1189
+ break;
1190
+ default: deg = parseFloat(value);
1191
+ }
1192
+ deg %= DEG;
1193
+ if (deg < 0) deg += DEG;
1194
+ else if (Object.is(deg, -0)) deg = 0;
1195
+ return deg;
1196
+ };
1197
+ /**
1198
+ * parse alpha
1199
+ * @param [alpha] - alpha value
1200
+ * @returns alpha: 0..1
1201
+ */
1202
+ var parseAlpha = (alpha = "") => {
1203
+ if (isString(alpha)) {
1204
+ alpha = alpha.trim();
1205
+ if (!alpha) alpha = "1";
1206
+ else if (alpha === "none") alpha = "0";
1207
+ else {
1208
+ let a;
1209
+ if (alpha.endsWith("%")) a = parseFloat(alpha) / MAX_PCT;
1210
+ else a = parseFloat(alpha);
1211
+ if (!Number.isFinite(a)) throw new TypeError(`${a} is not a finite number.`);
1212
+ if (a < PPTH) alpha = "0";
1213
+ else if (a > 1) alpha = "1";
1214
+ else alpha = a.toFixed(TRIA);
1215
+ }
1216
+ } else alpha = "1";
1217
+ return parseFloat(alpha);
1218
+ };
1219
+ /**
1220
+ * parse hex alpha
1221
+ * @param value - alpha value in hex string
1222
+ * @returns alpha: 0..1
1223
+ */
1224
+ var parseHexAlpha = (value) => {
1225
+ if (isString(value)) {
1226
+ if (value === "") throw new SyntaxError("Invalid property value: (empty string)");
1227
+ value = value.trim();
1228
+ } else throw new TypeError(`${value} is not a string.`);
1229
+ let alpha = parseInt(value, HEX);
1230
+ if (alpha <= 0) return 0;
1231
+ if (alpha >= MAX_RGB) return 1;
1232
+ const alphaMap = /* @__PURE__ */ new Map();
1233
+ for (let i = 1; i < MAX_PCT; i++) alphaMap.set(Math.round(i * MAX_RGB / MAX_PCT), i);
1234
+ if (alphaMap.has(alpha)) alpha = alphaMap.get(alpha) / MAX_PCT;
1235
+ else alpha = Math.round(alpha / MAX_RGB / PPTH) * PPTH;
1236
+ return parseFloat(alpha.toFixed(TRIA));
1237
+ };
1238
+ /**
1239
+ * transform rgb to linear rgb
1240
+ * @param rgb - [r, g, b] r|g|b: 0..255
1241
+ * @param [skip] - skip validate
1242
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..1
1243
+ */
1244
+ var transformRgbToLinearRgb = (rgb, skip = false) => {
1245
+ let rr, gg, bb;
1246
+ if (skip) [rr, gg, bb] = rgb;
1247
+ else [rr, gg, bb] = validateColorComponents(rgb, {
1248
+ maxLength: TRIA,
1249
+ maxRange: MAX_RGB
1250
+ });
1251
+ let r = rr / MAX_RGB;
1252
+ let g = gg / MAX_RGB;
1253
+ let b = bb / MAX_RGB;
1254
+ const COND_POW = .04045;
1255
+ if (r > COND_POW) r = Math.pow((r + LINEAR_OFFSET) / (1 + LINEAR_OFFSET), POW_LINEAR);
1256
+ else r /= LINEAR_COEF;
1257
+ if (g > COND_POW) g = Math.pow((g + LINEAR_OFFSET) / (1 + LINEAR_OFFSET), POW_LINEAR);
1258
+ else g /= LINEAR_COEF;
1259
+ if (b > COND_POW) b = Math.pow((b + LINEAR_OFFSET) / (1 + LINEAR_OFFSET), POW_LINEAR);
1260
+ else b /= LINEAR_COEF;
1261
+ return [
1262
+ r,
1263
+ g,
1264
+ b
1265
+ ];
1266
+ };
1267
+ /**
1268
+ * transform rgb to xyz
1269
+ * @param rgb - [r, g, b] r|g|b: 0..255
1270
+ * @param [skip] - skip validate
1271
+ * @returns TriColorChannels - [x, y, z]
1272
+ */
1273
+ var transformRgbToXyz = (rgb, skip = false) => {
1274
+ if (!skip) rgb = validateColorComponents(rgb, {
1275
+ maxLength: TRIA,
1276
+ maxRange: MAX_RGB
1277
+ });
1278
+ rgb = transformRgbToLinearRgb(rgb, true);
1279
+ return transformMatrix(MATRIX_L_RGB_TO_XYZ, rgb, true);
1280
+ };
1281
+ /**
1282
+ * transform linear rgb to rgb
1283
+ * @param rgb - [r, g, b] r|g|b: 0..1
1284
+ * @param [round] - round result
1285
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..255
1286
+ */
1287
+ var transformLinearRgbToRgb = (rgb, round = false) => {
1288
+ let [r, g, b] = validateColorComponents(rgb, { maxLength: TRIA });
1289
+ const COND_POW = 809 / 258400;
1290
+ if (r > COND_POW) r = Math.pow(r, 1 / POW_LINEAR) * (1 + LINEAR_OFFSET) - LINEAR_OFFSET;
1291
+ else r *= LINEAR_COEF;
1292
+ r *= MAX_RGB;
1293
+ if (g > COND_POW) g = Math.pow(g, 1 / POW_LINEAR) * (1 + LINEAR_OFFSET) - LINEAR_OFFSET;
1294
+ else g *= LINEAR_COEF;
1295
+ g *= MAX_RGB;
1296
+ if (b > COND_POW) b = Math.pow(b, 1 / POW_LINEAR) * (1 + LINEAR_OFFSET) - LINEAR_OFFSET;
1297
+ else b *= LINEAR_COEF;
1298
+ b *= MAX_RGB;
1299
+ return [
1300
+ round ? Math.round(r) : r,
1301
+ round ? Math.round(g) : g,
1302
+ round ? Math.round(b) : b
1303
+ ];
1304
+ };
1305
+ /**
1306
+ * transform xyz to rgb
1307
+ * @param xyz - [x, y, z]
1308
+ * @param [skip] - skip validate
1309
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..255
1310
+ */
1311
+ var transformXyzToRgb = (xyz, skip = false) => {
1312
+ if (!skip) xyz = validateColorComponents(xyz, {
1313
+ maxLength: TRIA,
1314
+ validateRange: false
1315
+ });
1316
+ let [r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, xyz, true);
1317
+ [r, g, b] = transformLinearRgbToRgb([
1318
+ Math.min(Math.max(r, 0), 1),
1319
+ Math.min(Math.max(g, 0), 1),
1320
+ Math.min(Math.max(b, 0), 1)
1321
+ ], true);
1322
+ return [
1323
+ r,
1324
+ g,
1325
+ b
1326
+ ];
1327
+ };
1328
+ /**
1329
+ * transform xyz to hsl
1330
+ * @param xyz - [x, y, z]
1331
+ * @param [skip] - skip validate
1332
+ * @returns TriColorChannels - [h, s, l]
1333
+ */
1334
+ var transformXyzToHsl = (xyz, skip = false) => {
1335
+ const [rr, gg, bb] = transformXyzToRgb(xyz, skip);
1336
+ const r = rr / MAX_RGB;
1337
+ const g = gg / MAX_RGB;
1338
+ const b = bb / MAX_RGB;
1339
+ const max = Math.max(r, g, b);
1340
+ const min = Math.min(r, g, b);
1341
+ const d = max - min;
1342
+ const l = (max + min) * HALF * MAX_PCT;
1343
+ let h, s;
1344
+ if (Math.round(l) === 0 || Math.round(l) === MAX_PCT) {
1345
+ h = 0;
1346
+ s = 0;
1347
+ } else {
1348
+ s = d / (1 - Math.abs(max + min - 1)) * MAX_PCT;
1349
+ if (s === 0) h = 0;
1350
+ else {
1351
+ switch (max) {
1352
+ case r:
1353
+ h = (g - b) / d;
1354
+ break;
1355
+ case g:
1356
+ h = (b - r) / d + DUO;
1357
+ break;
1358
+ case b:
1359
+ default:
1360
+ h = (r - g) / d + QUAD;
1361
+ break;
1362
+ }
1363
+ h = h * SEXA % DEG;
1364
+ if (h < 0) h += DEG;
1365
+ }
1366
+ }
1367
+ return [
1368
+ h,
1369
+ s,
1370
+ l
1371
+ ];
1372
+ };
1373
+ /**
1374
+ * transform xyz to hwb
1375
+ * @param xyz - [x, y, z]
1376
+ * @param [skip] - skip validate
1377
+ * @returns TriColorChannels - [h, w, b]
1378
+ */
1379
+ var transformXyzToHwb = (xyz, skip = false) => {
1380
+ const [r, g, b] = transformXyzToRgb(xyz, skip);
1381
+ const wh = Math.min(r, g, b) / MAX_RGB;
1382
+ const bk = 1 - Math.max(r, g, b) / MAX_RGB;
1383
+ let h;
1384
+ if (wh + bk === 1) h = 0;
1385
+ else [h] = transformXyzToHsl(xyz);
1386
+ return [
1387
+ h,
1388
+ wh * MAX_PCT,
1389
+ bk * MAX_PCT
1390
+ ];
1391
+ };
1392
+ /**
1393
+ * transform xyz to oklab
1394
+ * @param xyz - [x, y, z]
1395
+ * @param [skip] - skip validate
1396
+ * @returns TriColorChannels - [l, a, b]
1397
+ */
1398
+ var transformXyzToOklab = (xyz, skip = false) => {
1399
+ if (!skip) xyz = validateColorComponents(xyz, {
1400
+ maxLength: TRIA,
1401
+ validateRange: false
1402
+ });
1403
+ let [l, a, b] = transformMatrix(MATRIX_LMS_TO_OKLAB, transformMatrix(MATRIX_XYZ_TO_LMS, xyz, true).map((c) => Math.cbrt(c)), true);
1404
+ l = Math.min(Math.max(l, 0), 1);
1405
+ const lPct = Math.round(parseFloat(l.toFixed(QUAD)) * MAX_PCT);
1406
+ if (lPct === 0 || lPct === MAX_PCT) {
1407
+ a = 0;
1408
+ b = 0;
1409
+ }
1410
+ return [
1411
+ l,
1412
+ a,
1413
+ b
1414
+ ];
1415
+ };
1416
+ /**
1417
+ * transform xyz to oklch
1418
+ * @param xyz - [x, y, z]
1419
+ * @param [skip] - skip validate
1420
+ * @returns TriColorChannels - [l, c, h]
1421
+ */
1422
+ var transformXyzToOklch = (xyz, skip = false) => {
1423
+ const [l, a, b] = transformXyzToOklab(xyz, skip);
1424
+ let c, h;
1425
+ const lPct = Math.round(parseFloat(l.toFixed(QUAD)) * MAX_PCT);
1426
+ if (lPct === 0 || lPct === MAX_PCT) {
1427
+ c = 0;
1428
+ h = 0;
1429
+ } else {
1430
+ c = Math.max(Math.sqrt(Math.pow(a, POW_SQR) + Math.pow(b, POW_SQR)), 0);
1431
+ if (parseFloat(c.toFixed(QUAD)) === 0) h = 0;
1432
+ else {
1433
+ h = Math.atan2(b, a) * DEG_HALF / Math.PI;
1434
+ if (h < 0) h += DEG;
1435
+ }
1436
+ }
1437
+ return [
1438
+ l,
1439
+ c,
1440
+ h
1441
+ ];
1442
+ };
1443
+ /**
1444
+ * transform xyz D50 to rgb
1445
+ * @param xyz - [x, y, z]
1446
+ * @param [skip] - skip validate
1447
+ * @returns TriColorChannels - [r, g, b] r|g|b: 0..255
1448
+ */
1449
+ var transformXyzD50ToRgb = (xyz, skip = false) => {
1450
+ if (!skip) xyz = validateColorComponents(xyz, {
1451
+ maxLength: TRIA,
1452
+ validateRange: false
1453
+ });
1454
+ return transformXyzToRgb(transformMatrix(MATRIX_D50_TO_D65, xyz, true), true);
1455
+ };
1456
+ /**
1457
+ * transform xyz-d50 to lab
1458
+ * @param xyz - [x, y, z]
1459
+ * @param [skip] - skip validate
1460
+ * @returns TriColorChannels - [l, a, b]
1461
+ */
1462
+ var transformXyzD50ToLab = (xyz, skip = false) => {
1463
+ if (!skip) xyz = validateColorComponents(xyz, {
1464
+ maxLength: TRIA,
1465
+ validateRange: false
1466
+ });
1467
+ const [f0, f1, f2] = xyz.map((val, i) => val / D50[i]).map((val) => val > LAB_EPSILON ? Math.cbrt(val) : (val * LAB_KAPPA + HEX) / LAB_L);
1468
+ const l = Math.min(Math.max(LAB_L * f1 - HEX, 0), MAX_PCT);
1469
+ let a, b;
1470
+ if (l === 0 || l === MAX_PCT) {
1471
+ a = 0;
1472
+ b = 0;
1473
+ } else {
1474
+ a = (f0 - f1) * LAB_A;
1475
+ b = (f1 - f2) * LAB_B;
1476
+ }
1477
+ return [
1478
+ l,
1479
+ a,
1480
+ b
1481
+ ];
1482
+ };
1483
+ /**
1484
+ * transform xyz-d50 to lch
1485
+ * @param xyz - [x, y, z]
1486
+ * @param [skip] - skip validate
1487
+ * @returns TriColorChannels - [l, c, h]
1488
+ */
1489
+ var transformXyzD50ToLch = (xyz, skip = false) => {
1490
+ const [l, a, b] = transformXyzD50ToLab(xyz, skip);
1491
+ let c, h;
1492
+ if (l === 0 || l === MAX_PCT) {
1493
+ c = 0;
1494
+ h = 0;
1495
+ } else {
1496
+ c = Math.max(Math.sqrt(Math.pow(a, POW_SQR) + Math.pow(b, POW_SQR)), 0);
1497
+ h = Math.atan2(b, a) * DEG_HALF / Math.PI;
1498
+ if (h < 0) h += DEG;
1499
+ }
1500
+ return [
1501
+ l,
1502
+ c,
1503
+ h
1504
+ ];
1505
+ };
1506
+ /**
1507
+ * convert rgb to hex color
1508
+ * @param rgb - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
1509
+ * @returns hex color
1510
+ */
1511
+ var convertRgbToHex = (rgb) => {
1512
+ const [r, g, b, alpha] = validateColorComponents(rgb, {
1513
+ alpha: true,
1514
+ maxRange: MAX_RGB
1515
+ });
1516
+ const rr = numberToHexString(r);
1517
+ const gg = numberToHexString(g);
1518
+ const bb = numberToHexString(b);
1519
+ const aa = numberToHexString(alpha * MAX_RGB);
1520
+ let hex;
1521
+ if (aa === "ff") hex = `#${rr}${gg}${bb}`;
1522
+ else hex = `#${rr}${gg}${bb}${aa}`;
1523
+ return hex;
1524
+ };
1525
+ /**
1526
+ * convert hex color to rgb
1527
+ * @param value - hex color value
1528
+ * @returns ColorChannels - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
1529
+ */
1530
+ var convertHexToRgb = (value) => {
1531
+ if (isString(value)) value = value.toLowerCase().trim();
1532
+ else throw new TypeError(`${value} is not a string.`);
1533
+ if (!(/^#[\da-f]{6}$/.test(value) || /^#[\da-f]{3}$/.test(value) || /^#[\da-f]{8}$/.test(value) || /^#[\da-f]{4}$/.test(value))) throw new SyntaxError(`Invalid property value: ${value}`);
1534
+ const arr = [];
1535
+ if (/^#[\da-f]{3}$/.test(value)) {
1536
+ const [, r, g, b] = value.match(/^#([\da-f])([\da-f])([\da-f])$/);
1537
+ arr.push(parseInt(`${r}${r}`, HEX), parseInt(`${g}${g}`, HEX), parseInt(`${b}${b}`, HEX), 1);
1538
+ } else if (/^#[\da-f]{4}$/.test(value)) {
1539
+ const [, r, g, b, alpha] = value.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])$/);
1540
+ arr.push(parseInt(`${r}${r}`, HEX), parseInt(`${g}${g}`, HEX), parseInt(`${b}${b}`, HEX), parseHexAlpha(`${alpha}${alpha}`));
1541
+ } else if (/^#[\da-f]{8}$/.test(value)) {
1542
+ const [, r, g, b, alpha] = value.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);
1543
+ arr.push(parseInt(r, HEX), parseInt(g, HEX), parseInt(b, HEX), parseHexAlpha(alpha));
1544
+ } else {
1545
+ const [, r, g, b] = value.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);
1546
+ arr.push(parseInt(r, HEX), parseInt(g, HEX), parseInt(b, HEX), 1);
1547
+ }
1548
+ return arr;
1549
+ };
1550
+ /**
1551
+ * convert hex color to linear rgb
1552
+ * @param value - hex color value
1553
+ * @returns ColorChannels - [r, g, b, alpha] r|g|b|alpha: 0..1
1554
+ */
1555
+ var convertHexToLinearRgb = (value) => {
1556
+ const [rr, gg, bb, alpha] = convertHexToRgb(value);
1557
+ const [r, g, b] = transformRgbToLinearRgb([
1558
+ rr,
1559
+ gg,
1560
+ bb
1561
+ ], true);
1562
+ return [
1563
+ r,
1564
+ g,
1565
+ b,
1566
+ alpha
1567
+ ];
1568
+ };
1569
+ /**
1570
+ * convert hex color to xyz
1571
+ * @param value - hex color value
1572
+ * @returns ColorChannels - [x, y, z, alpha]
1573
+ */
1574
+ var convertHexToXyz = (value) => {
1575
+ const [r, g, b, alpha] = convertHexToLinearRgb(value);
1576
+ const [x, y, z] = transformMatrix(MATRIX_L_RGB_TO_XYZ, [
1577
+ r,
1578
+ g,
1579
+ b
1580
+ ], true);
1581
+ return [
1582
+ x,
1583
+ y,
1584
+ z,
1585
+ alpha
1586
+ ];
1587
+ };
1588
+ /**
1589
+ * parse rgb()
1590
+ * @param value - rgb color value
1591
+ * @param [opt] - options
1592
+ * @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
1593
+ */
1594
+ var parseRgb = (value, opt = {}) => {
1595
+ if (isString(value)) value = value.toLowerCase().trim();
1596
+ else throw new TypeError(`${value} is not a string.`);
1597
+ const { format = "", nullable = false } = opt;
1598
+ if (!REG_PARSE_RGB.test(value)) {
1599
+ const res = resolveInvalidColorValue(format, nullable);
1600
+ if (res instanceof NullObject) return res;
1601
+ if (isString(res)) return res;
1602
+ return res;
1603
+ }
1604
+ const [, val] = value.match(REG_PARSE_RGB);
1605
+ const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1606
+ let r, g, b;
1607
+ if (v1 === "none") r = 0;
1608
+ else {
1609
+ if (v1.endsWith("%")) r = parseFloat(v1) * MAX_RGB / MAX_PCT;
1610
+ else r = parseFloat(v1);
1611
+ r = Math.min(Math.max(roundToPrecision(r, OCT), 0), MAX_RGB);
1612
+ }
1613
+ if (v2 === "none") g = 0;
1614
+ else {
1615
+ if (v2.endsWith("%")) g = parseFloat(v2) * MAX_RGB / MAX_PCT;
1616
+ else g = parseFloat(v2);
1617
+ g = Math.min(Math.max(roundToPrecision(g, OCT), 0), MAX_RGB);
1618
+ }
1619
+ if (v3 === "none") b = 0;
1620
+ else {
1621
+ if (v3.endsWith("%")) b = parseFloat(v3) * MAX_RGB / MAX_PCT;
1622
+ else b = parseFloat(v3);
1623
+ b = Math.min(Math.max(roundToPrecision(b, OCT), 0), MAX_RGB);
1624
+ }
1625
+ const alpha = parseAlpha(v4);
1626
+ return [
1627
+ "rgb",
1628
+ r,
1629
+ g,
1630
+ b,
1631
+ format === "mixValue" && v4 === "none" ? NONE : alpha
1632
+ ];
1633
+ };
1634
+ /**
1635
+ * parse hsl()
1636
+ * @param value - hsl color value
1637
+ * @param [opt] - options
1638
+ * @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
1639
+ */
1640
+ var parseHsl = (value, opt = {}) => {
1641
+ if (isString(value)) value = value.trim();
1642
+ else throw new TypeError(`${value} is not a string.`);
1643
+ const { format = "", nullable = false } = opt;
1644
+ if (!REG_HSL.test(value)) {
1645
+ const res = resolveInvalidColorValue(format, nullable);
1646
+ if (res instanceof NullObject) return res;
1647
+ if (isString(res)) return res;
1648
+ return res;
1649
+ }
1650
+ const [, val] = value.match(REG_HSL);
1651
+ const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1652
+ let h, s, l;
1653
+ if (v1 === "none") h = 0;
1654
+ else h = angleToDeg(v1);
1655
+ if (v2 === "none") s = 0;
1656
+ else s = Math.min(Math.max(parseFloat(v2), 0), MAX_PCT);
1657
+ if (v3 === "none") l = 0;
1658
+ else l = Math.min(Math.max(parseFloat(v3), 0), MAX_PCT);
1659
+ const alpha = parseAlpha(v4);
1660
+ if (format === "hsl") return [
1661
+ format,
1662
+ v1 === "none" ? v1 : h,
1663
+ v2 === "none" ? v2 : s,
1664
+ v3 === "none" ? v3 : l,
1665
+ v4 === "none" ? v4 : alpha
1666
+ ];
1667
+ h = h / DEG * DOZ;
1668
+ l /= MAX_PCT;
1669
+ const sa = s / MAX_PCT * Math.min(l, 1 - l);
1670
+ const rk = h % DOZ;
1671
+ const gk = (8 + h) % DOZ;
1672
+ const bk = (4 + h) % DOZ;
1673
+ const r = l - sa * Math.max(-1, Math.min(rk - TRIA, TRIA ** POW_SQR - rk, 1));
1674
+ const g = l - sa * Math.max(-1, Math.min(gk - TRIA, TRIA ** POW_SQR - gk, 1));
1675
+ const b = l - sa * Math.max(-1, Math.min(bk - TRIA, TRIA ** POW_SQR - bk, 1));
1676
+ return [
1677
+ "rgb",
1678
+ Math.min(Math.max(roundToPrecision(r * MAX_RGB, OCT), 0), MAX_RGB),
1679
+ Math.min(Math.max(roundToPrecision(g * MAX_RGB, OCT), 0), MAX_RGB),
1680
+ Math.min(Math.max(roundToPrecision(b * MAX_RGB, OCT), 0), MAX_RGB),
1681
+ alpha
1682
+ ];
1683
+ };
1684
+ /**
1685
+ * parse hwb()
1686
+ * @param value - hwb color value
1687
+ * @param [opt] - options
1688
+ * @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
1689
+ */
1690
+ var parseHwb = (value, opt = {}) => {
1691
+ if (isString(value)) value = value.trim();
1692
+ else throw new TypeError(`${value} is not a string.`);
1693
+ const { format = "", nullable = false } = opt;
1694
+ if (!REG_HWB.test(value)) {
1695
+ const res = resolveInvalidColorValue(format, nullable);
1696
+ if (res instanceof NullObject) return res;
1697
+ if (isString(res)) return res;
1698
+ return res;
1699
+ }
1700
+ const [, val] = value.match(REG_HWB);
1701
+ const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1702
+ let h, wh, bk;
1703
+ if (v1 === "none") h = 0;
1704
+ else h = angleToDeg(v1);
1705
+ if (v2 === "none") wh = 0;
1706
+ else wh = Math.min(Math.max(parseFloat(v2), 0), MAX_PCT) / MAX_PCT;
1707
+ if (v3 === "none") bk = 0;
1708
+ else bk = Math.min(Math.max(parseFloat(v3), 0), MAX_PCT) / MAX_PCT;
1709
+ const alpha = parseAlpha(v4);
1710
+ if (format === "hwb") return [
1711
+ format,
1712
+ v1 === "none" ? v1 : h,
1713
+ v2 === "none" ? v2 : wh * MAX_PCT,
1714
+ v3 === "none" ? v3 : bk * MAX_PCT,
1715
+ v4 === "none" ? v4 : alpha
1716
+ ];
1717
+ if (wh + bk >= 1) {
1718
+ const v = roundToPrecision(wh / (wh + bk) * MAX_RGB, OCT);
1719
+ return [
1720
+ "rgb",
1721
+ v,
1722
+ v,
1723
+ v,
1724
+ alpha
1725
+ ];
1726
+ }
1727
+ const factor = (1 - wh - bk) / MAX_RGB;
1728
+ let [, r, g, b] = parseHsl(`hsl(${h} 100 50)`);
1729
+ r = roundToPrecision((r * factor + wh) * MAX_RGB, OCT);
1730
+ g = roundToPrecision((g * factor + wh) * MAX_RGB, OCT);
1731
+ b = roundToPrecision((b * factor + wh) * MAX_RGB, OCT);
1732
+ return [
1733
+ "rgb",
1734
+ Math.min(Math.max(r, 0), MAX_RGB),
1735
+ Math.min(Math.max(g, 0), MAX_RGB),
1736
+ Math.min(Math.max(b, 0), MAX_RGB),
1737
+ alpha
1738
+ ];
1739
+ };
1740
+ /**
1741
+ * parse lab()
1742
+ * @param value - lab color value
1743
+ * @param [opt] - options
1744
+ * @returns parsed color
1745
+ * - [xyz-d50, x, y, z, alpha], ['lab', l, a, b, alpha], '(empty)', NullObject
1746
+ */
1747
+ var parseLab = (value, opt = {}) => {
1748
+ if (isString(value)) value = value.trim();
1749
+ else throw new TypeError(`${value} is not a string.`);
1750
+ const { format = "", nullable = false } = opt;
1751
+ if (!REG_LAB.test(value)) {
1752
+ const res = resolveInvalidColorValue(format, nullable);
1753
+ if (res instanceof NullObject) return res;
1754
+ if (isString(res)) return res;
1755
+ return res;
1756
+ }
1757
+ const COEF_PCT = 1.25;
1758
+ const COND_POW = 8;
1759
+ const [, val] = value.match(REG_LAB);
1760
+ const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1761
+ let l, a, b;
1762
+ if (v1 === "none") l = 0;
1763
+ else {
1764
+ if (v1.endsWith("%")) {
1765
+ l = parseFloat(v1);
1766
+ if (l > MAX_PCT) l = MAX_PCT;
1767
+ } else l = parseFloat(v1);
1768
+ if (l < 0) l = 0;
1769
+ }
1770
+ if (v2 === "none") a = 0;
1771
+ else a = v2.endsWith("%") ? parseFloat(v2) * COEF_PCT : parseFloat(v2);
1772
+ if (v3 === "none") b = 0;
1773
+ else b = v3.endsWith("%") ? parseFloat(v3) * COEF_PCT : parseFloat(v3);
1774
+ const alpha = parseAlpha(v4);
1775
+ if (REG_SPEC.test(format)) return [
1776
+ "lab",
1777
+ v1 === "none" ? v1 : roundToPrecision(l, HEX),
1778
+ v2 === "none" ? v2 : roundToPrecision(a, HEX),
1779
+ v3 === "none" ? v3 : roundToPrecision(b, HEX),
1780
+ v4 === "none" ? v4 : alpha
1781
+ ];
1782
+ const fl = (l + HEX) / LAB_L;
1783
+ const fa = a / LAB_A + fl;
1784
+ const fb = fl - b / LAB_B;
1785
+ const powFl = Math.pow(fl, POW_CUBE);
1786
+ const powFa = Math.pow(fa, POW_CUBE);
1787
+ const powFb = Math.pow(fb, POW_CUBE);
1788
+ const [x, y, z] = [
1789
+ powFa > LAB_EPSILON ? powFa : (fa * LAB_L - HEX) / LAB_KAPPA,
1790
+ l > COND_POW ? powFl : l / LAB_KAPPA,
1791
+ powFb > LAB_EPSILON ? powFb : (fb * LAB_L - HEX) / LAB_KAPPA
1792
+ ].map((val, i) => val * D50[i]);
1793
+ return [
1794
+ "xyz-d50",
1795
+ roundToPrecision(x, HEX),
1796
+ roundToPrecision(y, HEX),
1797
+ roundToPrecision(z, HEX),
1798
+ alpha
1799
+ ];
1800
+ };
1801
+ /**
1802
+ * parse lch()
1803
+ * @param value - lch color value
1804
+ * @param [opt] - options
1805
+ * @returns parsed color
1806
+ * - ['xyz-d50', x, y, z, alpha], ['lch', l, c, h, alpha]
1807
+ * - '(empty)', NullObject
1808
+ */
1809
+ var parseLch = (value, opt = {}) => {
1810
+ if (isString(value)) value = value.trim();
1811
+ else throw new TypeError(`${value} is not a string.`);
1812
+ const { format = "", nullable = false } = opt;
1813
+ if (!REG_LCH.test(value)) {
1814
+ const res = resolveInvalidColorValue(format, nullable);
1815
+ if (res instanceof NullObject) return res;
1816
+ if (isString(res)) return res;
1817
+ return res;
1818
+ }
1819
+ const COEF_PCT = 1.5;
1820
+ const [, val] = value.match(REG_LCH);
1821
+ const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1822
+ let l, c, h;
1823
+ if (v1 === "none") l = 0;
1824
+ else {
1825
+ l = parseFloat(v1);
1826
+ if (l < 0) l = 0;
1827
+ }
1828
+ if (v2 === "none") c = 0;
1829
+ else c = v2.endsWith("%") ? parseFloat(v2) * COEF_PCT : parseFloat(v2);
1830
+ if (v3 === "none") h = 0;
1831
+ else h = angleToDeg(v3);
1832
+ const alpha = parseAlpha(v4);
1833
+ if (REG_SPEC.test(format)) return [
1834
+ "lch",
1835
+ v1 === "none" ? v1 : roundToPrecision(l, HEX),
1836
+ v2 === "none" ? v2 : roundToPrecision(c, HEX),
1837
+ v3 === "none" ? v3 : roundToPrecision(h, HEX),
1838
+ v4 === "none" ? v4 : alpha
1839
+ ];
1840
+ const a = c * Math.cos(h * Math.PI / DEG_HALF);
1841
+ const b = c * Math.sin(h * Math.PI / DEG_HALF);
1842
+ const [, x, y, z] = parseLab(`lab(${l} ${a} ${b})`);
1843
+ return [
1844
+ "xyz-d50",
1845
+ roundToPrecision(x, HEX),
1846
+ roundToPrecision(y, HEX),
1847
+ roundToPrecision(z, HEX),
1848
+ alpha
1849
+ ];
1850
+ };
1851
+ /**
1852
+ * parse oklab()
1853
+ * @param value - oklab color value
1854
+ * @param [opt] - options
1855
+ * @returns parsed color
1856
+ * - ['xyz-d65', x, y, z, alpha], ['oklab', l, a, b, alpha]
1857
+ * - '(empty)', NullObject
1858
+ */
1859
+ var parseOklab = (value, opt = {}) => {
1860
+ if (isString(value)) value = value.trim();
1861
+ else throw new TypeError(`${value} is not a string.`);
1862
+ const { format = "", nullable = false } = opt;
1863
+ if (!REG_OKLAB.test(value)) {
1864
+ const res = resolveInvalidColorValue(format, nullable);
1865
+ if (res instanceof NullObject) return res;
1866
+ if (isString(res)) return res;
1867
+ return res;
1868
+ }
1869
+ const COEF_PCT = .4;
1870
+ const [, val] = value.match(REG_OKLAB);
1871
+ const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1872
+ let l, a, b;
1873
+ if (v1 === "none") l = 0;
1874
+ else {
1875
+ l = v1.endsWith("%") ? parseFloat(v1) / MAX_PCT : parseFloat(v1);
1876
+ if (l < 0) l = 0;
1877
+ }
1878
+ if (v2 === "none") a = 0;
1879
+ else if (v2.endsWith("%")) a = parseFloat(v2) * COEF_PCT / MAX_PCT;
1880
+ else a = parseFloat(v2);
1881
+ if (v3 === "none") b = 0;
1882
+ else if (v3.endsWith("%")) b = parseFloat(v3) * COEF_PCT / MAX_PCT;
1883
+ else b = parseFloat(v3);
1884
+ const alpha = parseAlpha(v4);
1885
+ if (REG_SPEC.test(format)) return [
1886
+ "oklab",
1887
+ v1 === "none" ? v1 : roundToPrecision(l, HEX),
1888
+ v2 === "none" ? v2 : roundToPrecision(a, HEX),
1889
+ v3 === "none" ? v3 : roundToPrecision(b, HEX),
1890
+ v4 === "none" ? v4 : alpha
1891
+ ];
1892
+ const [x, y, z] = transformMatrix(MATRIX_LMS_TO_XYZ, transformMatrix(MATRIX_OKLAB_TO_LMS, [
1893
+ l,
1894
+ a,
1895
+ b
1896
+ ]).map((c) => Math.pow(c, POW_CUBE)), true);
1897
+ return [
1898
+ "xyz-d65",
1899
+ roundToPrecision(x, HEX),
1900
+ roundToPrecision(y, HEX),
1901
+ roundToPrecision(z, HEX),
1902
+ alpha
1903
+ ];
1904
+ };
1905
+ /**
1906
+ * parse oklch()
1907
+ * @param value - oklch color value
1908
+ * @param [opt] - options
1909
+ * @returns parsed color
1910
+ * - ['xyz-d65', x, y, z, alpha], ['oklch', l, c, h, alpha]
1911
+ * - '(empty)', NullObject
1912
+ */
1913
+ var parseOklch = (value, opt = {}) => {
1914
+ if (isString(value)) value = value.trim();
1915
+ else throw new TypeError(`${value} is not a string.`);
1916
+ const { format = "", nullable = false } = opt;
1917
+ if (!REG_OKLCH.test(value)) {
1918
+ const res = resolveInvalidColorValue(format, nullable);
1919
+ if (res instanceof NullObject) return res;
1920
+ if (isString(res)) return res;
1921
+ return res;
1922
+ }
1923
+ const COEF_PCT = .4;
1924
+ const [, val] = value.match(REG_OKLCH);
1925
+ const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1926
+ let l, c, h;
1927
+ if (v1 === "none") l = 0;
1928
+ else {
1929
+ l = v1.endsWith("%") ? parseFloat(v1) / MAX_PCT : parseFloat(v1);
1930
+ if (l < 0) l = 0;
1931
+ }
1932
+ if (v2 === "none") c = 0;
1933
+ else {
1934
+ if (v2.endsWith("%")) c = parseFloat(v2) * COEF_PCT / MAX_PCT;
1935
+ else c = parseFloat(v2);
1936
+ if (c < 0) c = 0;
1937
+ }
1938
+ if (v3 === "none") h = 0;
1939
+ else h = angleToDeg(v3);
1940
+ const alpha = parseAlpha(v4);
1941
+ if (REG_SPEC.test(format)) return [
1942
+ "oklch",
1943
+ v1 === "none" ? v1 : roundToPrecision(l, HEX),
1944
+ v2 === "none" ? v2 : roundToPrecision(c, HEX),
1945
+ v3 === "none" ? v3 : roundToPrecision(h, HEX),
1946
+ v4 === "none" ? v4 : alpha
1947
+ ];
1948
+ const a = c * Math.cos(h * Math.PI / DEG_HALF);
1949
+ const b = c * Math.sin(h * Math.PI / DEG_HALF);
1950
+ const [x, y, z] = transformMatrix(MATRIX_LMS_TO_XYZ, transformMatrix(MATRIX_OKLAB_TO_LMS, [
1951
+ l,
1952
+ a,
1953
+ b
1954
+ ]).map((cc) => Math.pow(cc, POW_CUBE)), true);
1955
+ return [
1956
+ "xyz-d65",
1957
+ roundToPrecision(x, HEX),
1958
+ roundToPrecision(y, HEX),
1959
+ roundToPrecision(z, HEX),
1960
+ alpha
1961
+ ];
1962
+ };
1963
+ /**
1964
+ * parse color()
1965
+ * @param value - color function value
1966
+ * @param [opt] - options
1967
+ * @returns parsed color
1968
+ * - ['xyz-(d50|d65)', x, y, z, alpha], [cs, r, g, b, alpha]
1969
+ * - '(empty)', NullObject
1970
+ */
1971
+ var parseColorFunc = (value, opt = {}) => {
1972
+ if (isString(value)) value = value.trim();
1973
+ else throw new TypeError(`${value} is not a string.`);
1974
+ const { colorSpace = "", d50 = false, format = "", nullable = false } = opt;
1975
+ if (!REG_FN_COLOR.test(value)) {
1976
+ const res = resolveInvalidColorValue(format, nullable);
1977
+ if (res instanceof NullObject) return res;
1978
+ if (isString(res)) return res;
1979
+ return res;
1980
+ }
1981
+ const [, val] = value.match(REG_FN_COLOR);
1982
+ let [cs, v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
1983
+ let r, g, b;
1984
+ if (cs === "xyz") cs = "xyz-d65";
1985
+ if (v1 === "none") r = 0;
1986
+ else r = v1.endsWith("%") ? parseFloat(v1) / MAX_PCT : parseFloat(v1);
1987
+ if (v2 === "none") g = 0;
1988
+ else g = v2.endsWith("%") ? parseFloat(v2) / MAX_PCT : parseFloat(v2);
1989
+ if (v3 === "none") b = 0;
1990
+ else b = v3.endsWith("%") ? parseFloat(v3) / MAX_PCT : parseFloat(v3);
1991
+ const alpha = parseAlpha(v4);
1992
+ if (REG_SPEC.test(format) || format === "mixValue" && cs === colorSpace) return [
1993
+ cs,
1994
+ v1 === "none" ? v1 : roundToPrecision(r, DEC),
1995
+ v2 === "none" ? v2 : roundToPrecision(g, DEC),
1996
+ v3 === "none" ? v3 : roundToPrecision(b, DEC),
1997
+ v4 === "none" ? v4 : alpha
1998
+ ];
1999
+ let x = 0;
2000
+ let y = 0;
2001
+ let z = 0;
2002
+ if (cs === "srgb-linear") {
2003
+ [x, y, z] = transformMatrix(MATRIX_L_RGB_TO_XYZ, [
2004
+ r,
2005
+ g,
2006
+ b
2007
+ ]);
2008
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2009
+ x,
2010
+ y,
2011
+ z
2012
+ ], true);
2013
+ } else if (cs === "display-p3") {
2014
+ const linearRgb = transformRgbToLinearRgb([
2015
+ r * MAX_RGB,
2016
+ g * MAX_RGB,
2017
+ b * MAX_RGB
2018
+ ]);
2019
+ [x, y, z] = transformMatrix(MATRIX_P3_TO_XYZ, linearRgb);
2020
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2021
+ x,
2022
+ y,
2023
+ z
2024
+ ], true);
2025
+ } else if (cs === "rec2020") {
2026
+ const ALPHA = 1.09929682680944;
2027
+ const BETA = .018053968510807;
2028
+ const REC_COEF = .45;
2029
+ const rgb = [
2030
+ r,
2031
+ g,
2032
+ b
2033
+ ].map((c) => {
2034
+ let cl;
2035
+ if (c < BETA * REC_COEF * DEC) cl = c / (REC_COEF * DEC);
2036
+ else cl = Math.pow((c + ALPHA - 1) / ALPHA, 1 / REC_COEF);
2037
+ return cl;
2038
+ });
2039
+ [x, y, z] = transformMatrix(MATRIX_REC2020_TO_XYZ, rgb);
2040
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2041
+ x,
2042
+ y,
2043
+ z
2044
+ ], true);
2045
+ } else if (cs === "a98-rgb") {
2046
+ const POW_A98 = 563 / 256;
2047
+ const rgb = [
2048
+ r,
2049
+ g,
2050
+ b
2051
+ ].map((c) => {
2052
+ return Math.pow(c, POW_A98);
2053
+ });
2054
+ [x, y, z] = transformMatrix(MATRIX_A98_TO_XYZ, rgb);
2055
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2056
+ x,
2057
+ y,
2058
+ z
2059
+ ], true);
2060
+ } else if (cs === "prophoto-rgb") {
2061
+ const POW_PROPHOTO = 1.8;
2062
+ const rgb = [
2063
+ r,
2064
+ g,
2065
+ b
2066
+ ].map((c) => {
2067
+ let cl;
2068
+ if (c > 1 / (HEX * DUO)) cl = Math.pow(c, POW_PROPHOTO);
2069
+ else cl = c / HEX;
2070
+ return cl;
2071
+ });
2072
+ [x, y, z] = transformMatrix(MATRIX_PROPHOTO_TO_XYZ_D50, rgb);
2073
+ if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
2074
+ x,
2075
+ y,
2076
+ z
2077
+ ], true);
2078
+ } else if (/^xyz(?:-d(?:50|65))?$/.test(cs)) {
2079
+ [x, y, z] = [
2080
+ r,
2081
+ g,
2082
+ b
2083
+ ];
2084
+ if (cs === "xyz-d50") {
2085
+ if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
2086
+ x,
2087
+ y,
2088
+ z
2089
+ ]);
2090
+ } else if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2091
+ x,
2092
+ y,
2093
+ z
2094
+ ], true);
2095
+ } else {
2096
+ [x, y, z] = transformRgbToXyz([
2097
+ r * MAX_RGB,
2098
+ g * MAX_RGB,
2099
+ b * MAX_RGB
2100
+ ]);
2101
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2102
+ x,
2103
+ y,
2104
+ z
2105
+ ], true);
2106
+ }
2107
+ return [
2108
+ d50 ? "xyz-d50" : "xyz-d65",
2109
+ roundToPrecision(x, HEX),
2110
+ roundToPrecision(y, HEX),
2111
+ roundToPrecision(z, HEX),
2112
+ format === "mixValue" && v4 === "none" ? v4 : alpha
2113
+ ];
2114
+ };
2115
+ /**
2116
+ * parse color value
2117
+ * @param value - CSS color value
2118
+ * @param [opt] - options
2119
+ * @returns parsed color
2120
+ * - ['xyz-(d50|d65)', x, y, z, alpha], ['rgb', r, g, b, alpha]
2121
+ * - value, '(empty)', NullObject
2122
+ */
2123
+ var parseColorValue = (value, opt = {}) => {
2124
+ if (isString(value)) value = value.toLowerCase().trim();
2125
+ else throw new TypeError(`${value} is not a string.`);
2126
+ const { d50 = false, format = "", nullable = false } = opt;
2127
+ if (!REG_COLOR.test(value)) {
2128
+ const res = resolveInvalidColorValue(format, nullable);
2129
+ if (res instanceof NullObject) return res;
2130
+ if (isString(res)) return res;
2131
+ return res;
2132
+ }
2133
+ let x = 0;
2134
+ let y = 0;
2135
+ let z = 0;
2136
+ let alpha = 0;
2137
+ if (REG_CURRENT.test(value)) {
2138
+ if (format === "computedValue") return [
2139
+ "rgb",
2140
+ 0,
2141
+ 0,
2142
+ 0,
2143
+ 0
2144
+ ];
2145
+ if (format === "specifiedValue") return value;
2146
+ } else if (/^[a-z]+$/.test(value)) if (Object.hasOwn(NAMED_COLORS, value)) {
2147
+ if (format === "specifiedValue") return value;
2148
+ const [r, g, b] = NAMED_COLORS[value];
2149
+ alpha = 1;
2150
+ if (format === "computedValue") return [
2151
+ "rgb",
2152
+ r,
2153
+ g,
2154
+ b,
2155
+ alpha
2156
+ ];
2157
+ [x, y, z] = transformRgbToXyz([
2158
+ r,
2159
+ g,
2160
+ b
2161
+ ], true);
2162
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2163
+ x,
2164
+ y,
2165
+ z
2166
+ ], true);
2167
+ } else switch (format) {
2168
+ case VAL_COMP:
2169
+ if (nullable && value !== "transparent") return new NullObject();
2170
+ return [
2171
+ "rgb",
2172
+ 0,
2173
+ 0,
2174
+ 0,
2175
+ 0
2176
+ ];
2177
+ case VAL_SPEC:
2178
+ if (value === "transparent") return value;
2179
+ return "";
2180
+ case VAL_MIX:
2181
+ if (value === "transparent") return [
2182
+ "rgb",
2183
+ 0,
2184
+ 0,
2185
+ 0,
2186
+ 0
2187
+ ];
2188
+ return new NullObject();
2189
+ default:
2190
+ }
2191
+ else if (value[0] === "#") {
2192
+ if (REG_SPEC.test(format)) return ["rgb", ...convertHexToRgb(value)];
2193
+ [x, y, z, alpha] = convertHexToXyz(value);
2194
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2195
+ x,
2196
+ y,
2197
+ z
2198
+ ], true);
2199
+ } else if (value.startsWith("lab")) {
2200
+ if (REG_SPEC.test(format)) return parseLab(value, opt);
2201
+ [, x, y, z, alpha] = parseLab(value);
2202
+ if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
2203
+ x,
2204
+ y,
2205
+ z
2206
+ ], true);
2207
+ } else if (value.startsWith("lch")) {
2208
+ if (REG_SPEC.test(format)) return parseLch(value, opt);
2209
+ [, x, y, z, alpha] = parseLch(value);
2210
+ if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
2211
+ x,
2212
+ y,
2213
+ z
2214
+ ], true);
2215
+ } else if (value.startsWith("oklab")) {
2216
+ if (REG_SPEC.test(format)) return parseOklab(value, opt);
2217
+ [, x, y, z, alpha] = parseOklab(value);
2218
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2219
+ x,
2220
+ y,
2221
+ z
2222
+ ], true);
2223
+ } else if (value.startsWith("oklch")) {
2224
+ if (REG_SPEC.test(format)) return parseOklch(value, opt);
2225
+ [, x, y, z, alpha] = parseOklch(value);
2226
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2227
+ x,
2228
+ y,
2229
+ z
2230
+ ], true);
2231
+ } else {
2232
+ let r, g, b;
2233
+ if (value.startsWith("hsl")) [, r, g, b, alpha] = parseHsl(value);
2234
+ else if (value.startsWith("hwb")) [, r, g, b, alpha] = parseHwb(value);
2235
+ else [, r, g, b, alpha] = parseRgb(value, opt);
2236
+ if (REG_SPEC.test(format)) return [
2237
+ "rgb",
2238
+ Math.round(r),
2239
+ Math.round(g),
2240
+ Math.round(b),
2241
+ alpha
2242
+ ];
2243
+ [x, y, z] = transformRgbToXyz([
2244
+ r,
2245
+ g,
2246
+ b
2247
+ ]);
2248
+ if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
2249
+ x,
2250
+ y,
2251
+ z
2252
+ ], true);
2253
+ }
2254
+ return [
2255
+ d50 ? "xyz-d50" : "xyz-d65",
2256
+ roundToPrecision(x, HEX),
2257
+ roundToPrecision(y, HEX),
2258
+ roundToPrecision(z, HEX),
2259
+ alpha
2260
+ ];
2261
+ };
2262
+ /**
2263
+ * resolve color value
2264
+ * @param value - CSS color value
2265
+ * @param [opt] - options
2266
+ * @returns resolved color
2267
+ * - [cs, v1, v2, v3, alpha], value, '(empty)', NullObject
2268
+ */
2269
+ var resolveColorValue = (value, opt = {}) => {
2270
+ if (isString(value)) value = value.toLowerCase().trim();
2271
+ else throw new TypeError(`${value} is not a string.`);
2272
+ const { colorSpace = "", format = "", nullable = false } = opt;
2273
+ const cacheKey = createCacheKey({
2274
+ namespace: NAMESPACE,
2275
+ name: "resolveColorValue",
2276
+ value
2277
+ }, opt);
2278
+ const cachedResult = getCache(cacheKey);
2279
+ if (cachedResult instanceof CacheItem) {
2280
+ if (cachedResult.isNull) return cachedResult;
2281
+ const cachedItem = cachedResult.item;
2282
+ if (isString(cachedItem)) return cachedItem;
2283
+ return cachedItem;
2284
+ }
2285
+ if (!REG_COLOR.test(value)) {
2286
+ const res = resolveInvalidColorValue(format, nullable);
2287
+ if (res instanceof NullObject) {
2288
+ setCache(cacheKey, null);
2289
+ return res;
2290
+ }
2291
+ setCache(cacheKey, res);
2292
+ if (isString(res)) return res;
2293
+ return res;
2294
+ }
2295
+ let cs = "";
2296
+ let r = 0;
2297
+ let g = 0;
2298
+ let b = 0;
2299
+ let alpha = 0;
2300
+ if (REG_CURRENT.test(value)) {
2301
+ if (format === "specifiedValue") {
2302
+ setCache(cacheKey, value);
2303
+ return value;
2304
+ }
2305
+ } else if (/^[a-z]+$/.test(value)) if (Object.hasOwn(NAMED_COLORS, value)) {
2306
+ if (format === "specifiedValue") {
2307
+ setCache(cacheKey, value);
2308
+ return value;
2309
+ }
2310
+ [r, g, b] = NAMED_COLORS[value];
2311
+ alpha = 1;
2312
+ } else switch (format) {
2313
+ case VAL_SPEC: {
2314
+ if (value === "transparent") {
2315
+ setCache(cacheKey, value);
2316
+ return value;
2317
+ }
2318
+ const res = "";
2319
+ setCache(cacheKey, res);
2320
+ return res;
2321
+ }
2322
+ case VAL_MIX:
2323
+ if (value === "transparent") {
2324
+ const res = [
2325
+ "rgb",
2326
+ 0,
2327
+ 0,
2328
+ 0,
2329
+ 0
2330
+ ];
2331
+ setCache(cacheKey, res);
2332
+ return res;
2333
+ }
2334
+ setCache(cacheKey, null);
2335
+ return new NullObject();
2336
+ case VAL_COMP:
2337
+ default: {
2338
+ if (nullable && value !== "transparent") {
2339
+ setCache(cacheKey, null);
2340
+ return new NullObject();
2341
+ }
2342
+ const res = [
2343
+ "rgb",
2344
+ 0,
2345
+ 0,
2346
+ 0,
2347
+ 0
2348
+ ];
2349
+ setCache(cacheKey, res);
2350
+ return res;
2351
+ }
2352
+ }
2353
+ else if (value[0] === "#") [r, g, b, alpha] = convertHexToRgb(value);
2354
+ else if (value.startsWith("hsl")) [, r, g, b, alpha] = parseHsl(value, opt);
2355
+ else if (value.startsWith("hwb")) [, r, g, b, alpha] = parseHwb(value, opt);
2356
+ else if (/^l(?:ab|ch)/.test(value)) {
2357
+ let x, y, z;
2358
+ if (value.startsWith("lab")) [cs, x, y, z, alpha] = parseLab(value, opt);
2359
+ else [cs, x, y, z, alpha] = parseLch(value, opt);
2360
+ if (REG_SPEC.test(format)) {
2361
+ const res = [
2362
+ cs,
2363
+ x,
2364
+ y,
2365
+ z,
2366
+ alpha
2367
+ ];
2368
+ setCache(cacheKey, res);
2369
+ return res;
2370
+ }
2371
+ [r, g, b] = transformXyzD50ToRgb([
2372
+ x,
2373
+ y,
2374
+ z
2375
+ ]);
2376
+ } else if (/^okl(?:ab|ch)/.test(value)) {
2377
+ let x, y, z;
2378
+ if (value.startsWith("oklab")) [cs, x, y, z, alpha] = parseOklab(value, opt);
2379
+ else [cs, x, y, z, alpha] = parseOklch(value, opt);
2380
+ if (REG_SPEC.test(format)) {
2381
+ const res = [
2382
+ cs,
2383
+ x,
2384
+ y,
2385
+ z,
2386
+ alpha
2387
+ ];
2388
+ setCache(cacheKey, res);
2389
+ return res;
2390
+ }
2391
+ [r, g, b] = transformXyzToRgb([
2392
+ x,
2393
+ y,
2394
+ z
2395
+ ]);
2396
+ } else [, r, g, b, alpha] = parseRgb(value, opt);
2397
+ if (format === "mixValue" && colorSpace === "srgb") {
2398
+ const res = [
2399
+ "srgb",
2400
+ r / MAX_RGB,
2401
+ g / MAX_RGB,
2402
+ b / MAX_RGB,
2403
+ alpha
2404
+ ];
2405
+ setCache(cacheKey, res);
2406
+ return res;
2407
+ }
2408
+ const res = [
2409
+ "rgb",
2410
+ Math.round(r),
2411
+ Math.round(g),
2412
+ Math.round(b),
2413
+ alpha
2414
+ ];
2415
+ setCache(cacheKey, res);
2416
+ return res;
2417
+ };
2418
+ /**
2419
+ * resolve color()
2420
+ * @param value - color function value
2421
+ * @param [opt] - options
2422
+ * @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)', NullObject
2423
+ */
2424
+ var resolveColorFunc = (value, opt = {}) => {
2425
+ if (isString(value)) value = value.toLowerCase().trim();
2426
+ else throw new TypeError(`${value} is not a string.`);
2427
+ const { colorSpace = "", format = "", nullable = false } = opt;
2428
+ const cacheKey = createCacheKey({
2429
+ namespace: NAMESPACE,
2430
+ name: "resolveColorFunc",
2431
+ value
2432
+ }, opt);
2433
+ const cachedResult = getCache(cacheKey);
2434
+ if (cachedResult instanceof CacheItem) {
2435
+ if (cachedResult.isNull) return cachedResult;
2436
+ const cachedItem = cachedResult.item;
2437
+ if (isString(cachedItem)) return cachedItem;
2438
+ return cachedItem;
2439
+ }
2440
+ if (!REG_FN_COLOR.test(value)) {
2441
+ const res = resolveInvalidColorValue(format, nullable);
2442
+ if (res instanceof NullObject) {
2443
+ setCache(cacheKey, null);
2444
+ return res;
2445
+ }
2446
+ setCache(cacheKey, res);
2447
+ if (isString(res)) return res;
2448
+ return res;
2449
+ }
2450
+ const [cs, v1, v2, v3, v4] = parseColorFunc(value, opt);
2451
+ if (REG_SPEC.test(format) || format === "mixValue" && cs === colorSpace) {
2452
+ const res = [
2453
+ cs,
2454
+ v1,
2455
+ v2,
2456
+ v3,
2457
+ v4
2458
+ ];
2459
+ setCache(cacheKey, res);
2460
+ return res;
2461
+ }
2462
+ const x = parseFloat(`${v1}`);
2463
+ const y = parseFloat(`${v2}`);
2464
+ const z = parseFloat(`${v3}`);
2465
+ const alpha = parseAlpha(`${v4}`);
2466
+ const [r, g, b] = transformXyzToRgb([
2467
+ x,
2468
+ y,
2469
+ z
2470
+ ], true);
2471
+ const res = [
2472
+ "rgb",
2473
+ r,
2474
+ g,
2475
+ b,
2476
+ alpha
2477
+ ];
2478
+ setCache(cacheKey, res);
2479
+ return res;
2480
+ };
2481
+ /**
2482
+ * convert color value to linear rgb
2483
+ * @param value - CSS color value
2484
+ * @param [opt] - options
2485
+ * @returns ColorChannels | NullObject - [r, g, b, alpha] r|g|b|alpha: 0..1
2486
+ */
2487
+ var convertColorToLinearRgb = (value, opt = {}) => {
2488
+ if (isString(value)) value = value.trim();
2489
+ else throw new TypeError(`${value} is not a string.`);
2490
+ const { colorSpace = "", format = "" } = opt;
2491
+ let cs = "";
2492
+ let r, g, b, alpha, x, y, z;
2493
+ if (format === "mixValue") {
2494
+ let xyz;
2495
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2496
+ else xyz = parseColorValue(value, opt);
2497
+ if (xyz instanceof NullObject) return xyz;
2498
+ [cs, x, y, z, alpha] = xyz;
2499
+ if (cs === colorSpace) return [
2500
+ x,
2501
+ y,
2502
+ z,
2503
+ alpha
2504
+ ];
2505
+ [r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, [
2506
+ x,
2507
+ y,
2508
+ z
2509
+ ], true);
2510
+ } else if (value.startsWith("color(")) {
2511
+ const [, val] = value.match(REG_FN_COLOR);
2512
+ const [cs] = val.match(/[^\s,/]+/g);
2513
+ if (cs === "srgb-linear") [, r, g, b, alpha] = resolveColorFunc(value, { format: VAL_COMP });
2514
+ else {
2515
+ [, x, y, z, alpha] = parseColorFunc(value);
2516
+ [r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, [
2517
+ x,
2518
+ y,
2519
+ z
2520
+ ], true);
2521
+ }
2522
+ } else {
2523
+ [, x, y, z, alpha] = parseColorValue(value);
2524
+ [r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, [
2525
+ x,
2526
+ y,
2527
+ z
2528
+ ], true);
2529
+ }
2530
+ return [
2531
+ Math.min(Math.max(r, 0), 1),
2532
+ Math.min(Math.max(g, 0), 1),
2533
+ Math.min(Math.max(b, 0), 1),
2534
+ alpha
2535
+ ];
2536
+ };
2537
+ /**
2538
+ * convert color value to rgb
2539
+ * @param value - CSS color value
2540
+ * @param [opt] - options
2541
+ * @returns ColorChannels | NullObject
2542
+ * - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
2543
+ */
2544
+ var convertColorToRgb = (value, opt = {}) => {
2545
+ if (isString(value)) value = value.trim();
2546
+ else throw new TypeError(`${value} is not a string.`);
2547
+ const { format = "" } = opt;
2548
+ let r, g, b, alpha;
2549
+ if (format === "mixValue") {
2550
+ let rgb;
2551
+ if (value.startsWith("color(")) rgb = resolveColorFunc(value, opt);
2552
+ else rgb = resolveColorValue(value, opt);
2553
+ if (rgb instanceof NullObject) return rgb;
2554
+ [, r, g, b, alpha] = rgb;
2555
+ } else if (value.startsWith("color(")) {
2556
+ const [, val] = value.match(REG_FN_COLOR);
2557
+ const [cs] = val.match(/[^\s,/]+/g);
2558
+ if (cs === "srgb") {
2559
+ [, r, g, b, alpha] = resolveColorFunc(value, { format: VAL_COMP });
2560
+ r *= MAX_RGB;
2561
+ g *= MAX_RGB;
2562
+ b *= MAX_RGB;
2563
+ } else [, r, g, b, alpha] = resolveColorFunc(value);
2564
+ } else if (/^(?:ok)?l(?:ab|ch)/.test(value)) {
2565
+ [r, g, b, alpha] = convertColorToLinearRgb(value);
2566
+ [r, g, b] = transformLinearRgbToRgb([
2567
+ r,
2568
+ g,
2569
+ b
2570
+ ]);
2571
+ } else [, r, g, b, alpha] = resolveColorValue(value, { format: VAL_COMP });
2572
+ return [
2573
+ r,
2574
+ g,
2575
+ b,
2576
+ alpha
2577
+ ];
2578
+ };
2579
+ /**
2580
+ * convert color value to xyz
2581
+ * @param value - CSS color value
2582
+ * @param [opt] - options
2583
+ * @returns ColorChannels | NullObject - [x, y, z, alpha]
2584
+ */
2585
+ var convertColorToXyz = (value, opt = {}) => {
2586
+ if (isString(value)) value = value.trim();
2587
+ else throw new TypeError(`${value} is not a string.`);
2588
+ const { d50 = false, format = "" } = opt;
2589
+ let x, y, z, alpha;
2590
+ if (format === "mixValue") {
2591
+ let xyz;
2592
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2593
+ else xyz = parseColorValue(value, opt);
2594
+ if (xyz instanceof NullObject) return xyz;
2595
+ [, x, y, z, alpha] = xyz;
2596
+ } else if (value.startsWith("color(")) {
2597
+ const [, val] = value.match(REG_FN_COLOR);
2598
+ const [cs] = val.match(/[^\s,/]+/g);
2599
+ if (d50) if (cs === "xyz-d50") [, x, y, z, alpha] = resolveColorFunc(value, { format: VAL_COMP });
2600
+ else [, x, y, z, alpha] = parseColorFunc(value, opt);
2601
+ else if (/^xyz(?:-d65)?$/.test(cs)) [, x, y, z, alpha] = resolveColorFunc(value, { format: VAL_COMP });
2602
+ else [, x, y, z, alpha] = parseColorFunc(value);
2603
+ } else [, x, y, z, alpha] = parseColorValue(value, opt);
2604
+ return [
2605
+ x,
2606
+ y,
2607
+ z,
2608
+ alpha
2609
+ ];
2610
+ };
2611
+ /**
2612
+ * convert color value to hsl
2613
+ * @param value - CSS color value
2614
+ * @param [opt] - options
2615
+ * @returns ColorChannels | NullObject - [h, s, l, alpha], hue may be powerless
2616
+ */
2617
+ var convertColorToHsl = (value, opt = {}) => {
2618
+ if (isString(value)) value = value.trim();
2619
+ else throw new TypeError(`${value} is not a string.`);
2620
+ const { format = "" } = opt;
2621
+ let h, s, l, alpha;
2622
+ if (REG_HSL.test(value)) {
2623
+ [, h, s, l, alpha] = parseHsl(value, { format: "hsl" });
2624
+ if (format === "hsl") return [
2625
+ Math.round(h),
2626
+ Math.round(s),
2627
+ Math.round(l),
2628
+ alpha
2629
+ ];
2630
+ return [
2631
+ h,
2632
+ s,
2633
+ l,
2634
+ alpha
2635
+ ];
2636
+ }
2637
+ let x, y, z;
2638
+ if (format === "mixValue") {
2639
+ let xyz;
2640
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2641
+ else xyz = parseColorValue(value, opt);
2642
+ if (xyz instanceof NullObject) return xyz;
2643
+ [, x, y, z, alpha] = xyz;
2644
+ } else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
2645
+ else [, x, y, z, alpha] = parseColorValue(value);
2646
+ [h, s, l] = transformXyzToHsl([
2647
+ x,
2648
+ y,
2649
+ z
2650
+ ], true);
2651
+ if (format === "hsl") return [
2652
+ Math.round(h),
2653
+ Math.round(s),
2654
+ Math.round(l),
2655
+ alpha
2656
+ ];
2657
+ return [
2658
+ format === "mixValue" && s === 0 ? NONE : h,
2659
+ s,
2660
+ l,
2661
+ alpha
2662
+ ];
2663
+ };
2664
+ /**
2665
+ * convert color value to hwb
2666
+ * @param value - CSS color value
2667
+ * @param [opt] - options
2668
+ * @returns ColorChannels | NullObject - [h, w, b, alpha], hue may be powerless
2669
+ */
2670
+ var convertColorToHwb = (value, opt = {}) => {
2671
+ if (isString(value)) value = value.trim();
2672
+ else throw new TypeError(`${value} is not a string.`);
2673
+ const { format = "" } = opt;
2674
+ let h, w, b, alpha;
2675
+ if (REG_HWB.test(value)) {
2676
+ [, h, w, b, alpha] = parseHwb(value, { format: "hwb" });
2677
+ if (format === "hwb") return [
2678
+ Math.round(h),
2679
+ Math.round(w),
2680
+ Math.round(b),
2681
+ alpha
2682
+ ];
2683
+ return [
2684
+ h,
2685
+ w,
2686
+ b,
2687
+ alpha
2688
+ ];
2689
+ }
2690
+ let x, y, z;
2691
+ if (format === "mixValue") {
2692
+ let xyz;
2693
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2694
+ else xyz = parseColorValue(value, opt);
2695
+ if (xyz instanceof NullObject) return xyz;
2696
+ [, x, y, z, alpha] = xyz;
2697
+ } else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
2698
+ else [, x, y, z, alpha] = parseColorValue(value);
2699
+ [h, w, b] = transformXyzToHwb([
2700
+ x,
2701
+ y,
2702
+ z
2703
+ ], true);
2704
+ if (format === "hwb") return [
2705
+ Math.round(h),
2706
+ Math.round(w),
2707
+ Math.round(b),
2708
+ alpha
2709
+ ];
2710
+ return [
2711
+ format === "mixValue" && w + b >= 100 ? NONE : h,
2712
+ w,
2713
+ b,
2714
+ alpha
2715
+ ];
2716
+ };
2717
+ /**
2718
+ * convert color value to lab
2719
+ * @param value - CSS color value
2720
+ * @param [opt] - options
2721
+ * @returns ColorChannels | NullObject - [l, a, b, alpha]
2722
+ */
2723
+ var convertColorToLab = (value, opt = {}) => {
2724
+ if (isString(value)) value = value.trim();
2725
+ else throw new TypeError(`${value} is not a string.`);
2726
+ const { format = "" } = opt;
2727
+ let l, a, b, alpha;
2728
+ if (REG_LAB.test(value)) {
2729
+ [, l, a, b, alpha] = parseLab(value, { format: VAL_COMP });
2730
+ return [
2731
+ l,
2732
+ a,
2733
+ b,
2734
+ alpha
2735
+ ];
2736
+ }
2737
+ let x, y, z;
2738
+ if (format === "mixValue") {
2739
+ let xyz;
2740
+ opt.d50 = true;
2741
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2742
+ else xyz = parseColorValue(value, opt);
2743
+ if (xyz instanceof NullObject) return xyz;
2744
+ [, x, y, z, alpha] = xyz;
2745
+ } else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value, { d50: true });
2746
+ else [, x, y, z, alpha] = parseColorValue(value, { d50: true });
2747
+ [l, a, b] = transformXyzD50ToLab([
2748
+ x,
2749
+ y,
2750
+ z
2751
+ ], true);
2752
+ return [
2753
+ l,
2754
+ a,
2755
+ b,
2756
+ alpha
2757
+ ];
2758
+ };
2759
+ /**
2760
+ * convert color value to lch
2761
+ * @param value - CSS color value
2762
+ * @param [opt] - options
2763
+ * @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
2764
+ */
2765
+ var convertColorToLch = (value, opt = {}) => {
2766
+ if (isString(value)) value = value.trim();
2767
+ else throw new TypeError(`${value} is not a string.`);
2768
+ const { format = "" } = opt;
2769
+ let l, c, h, alpha;
2770
+ if (REG_LCH.test(value)) {
2771
+ [, l, c, h, alpha] = parseLch(value, { format: VAL_COMP });
2772
+ return [
2773
+ l,
2774
+ c,
2775
+ h,
2776
+ alpha
2777
+ ];
2778
+ }
2779
+ let x, y, z;
2780
+ if (format === "mixValue") {
2781
+ let xyz;
2782
+ opt.d50 = true;
2783
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2784
+ else xyz = parseColorValue(value, opt);
2785
+ if (xyz instanceof NullObject) return xyz;
2786
+ [, x, y, z, alpha] = xyz;
2787
+ } else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value, { d50: true });
2788
+ else [, x, y, z, alpha] = parseColorValue(value, { d50: true });
2789
+ [l, c, h] = transformXyzD50ToLch([
2790
+ x,
2791
+ y,
2792
+ z
2793
+ ], true);
2794
+ return [
2795
+ l,
2796
+ c,
2797
+ format === "mixValue" && c === 0 ? NONE : h,
2798
+ alpha
2799
+ ];
2800
+ };
2801
+ /**
2802
+ * convert color value to oklab
2803
+ * @param value - CSS color value
2804
+ * @param [opt] - options
2805
+ * @returns ColorChannels | NullObject - [l, a, b, alpha]
2806
+ */
2807
+ var convertColorToOklab = (value, opt = {}) => {
2808
+ if (isString(value)) value = value.trim();
2809
+ else throw new TypeError(`${value} is not a string.`);
2810
+ const { format = "" } = opt;
2811
+ let l, a, b, alpha;
2812
+ if (REG_OKLAB.test(value)) {
2813
+ [, l, a, b, alpha] = parseOklab(value, { format: VAL_COMP });
2814
+ return [
2815
+ l,
2816
+ a,
2817
+ b,
2818
+ alpha
2819
+ ];
2820
+ }
2821
+ let x, y, z;
2822
+ if (format === "mixValue") {
2823
+ let xyz;
2824
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2825
+ else xyz = parseColorValue(value, opt);
2826
+ if (xyz instanceof NullObject) return xyz;
2827
+ [, x, y, z, alpha] = xyz;
2828
+ } else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
2829
+ else [, x, y, z, alpha] = parseColorValue(value);
2830
+ [l, a, b] = transformXyzToOklab([
2831
+ x,
2832
+ y,
2833
+ z
2834
+ ], true);
2835
+ return [
2836
+ l,
2837
+ a,
2838
+ b,
2839
+ alpha
2840
+ ];
2841
+ };
2842
+ /**
2843
+ * convert color value to oklch
2844
+ * @param value - CSS color value
2845
+ * @param [opt] - options
2846
+ * @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
2847
+ */
2848
+ var convertColorToOklch = (value, opt = {}) => {
2849
+ if (isString(value)) value = value.trim();
2850
+ else throw new TypeError(`${value} is not a string.`);
2851
+ const { format = "" } = opt;
2852
+ let l, c, h, alpha;
2853
+ if (REG_OKLCH.test(value)) {
2854
+ [, l, c, h, alpha] = parseOklch(value, { format: VAL_COMP });
2855
+ return [
2856
+ l,
2857
+ c,
2858
+ h,
2859
+ alpha
2860
+ ];
2861
+ }
2862
+ let x, y, z;
2863
+ if (format === "mixValue") {
2864
+ let xyz;
2865
+ if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
2866
+ else xyz = parseColorValue(value, opt);
2867
+ if (xyz instanceof NullObject) return xyz;
2868
+ [, x, y, z, alpha] = xyz;
2869
+ } else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
2870
+ else [, x, y, z, alpha] = parseColorValue(value);
2871
+ [l, c, h] = transformXyzToOklch([
2872
+ x,
2873
+ y,
2874
+ z
2875
+ ], true);
2876
+ return [
2877
+ l,
2878
+ c,
2879
+ format === "mixValue" && c === 0 ? NONE : h,
2880
+ alpha
2881
+ ];
2882
+ };
2883
+ /**
2884
+ * resolve color-mix()
2885
+ * @param value - color-mix color value
2886
+ * @param [opt] - options
2887
+ * @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)'
2888
+ */
2889
+ var resolveColorMix = (value, opt = {}) => {
2890
+ if (isString(value)) value = value.toLowerCase().trim();
2891
+ else throw new TypeError(`${value} is not a string.`);
2892
+ const { format = "", nullable = false } = opt;
2893
+ const cacheKey = createCacheKey({
2894
+ namespace: NAMESPACE,
2895
+ name: "resolveColorMix",
2896
+ value
2897
+ }, opt);
2898
+ const cachedResult = getCache(cacheKey);
2899
+ if (cachedResult instanceof CacheItem) {
2900
+ if (cachedResult.isNull) return cachedResult;
2901
+ const cachedItem = cachedResult.item;
2902
+ if (isString(cachedItem)) return cachedItem;
2903
+ return cachedItem;
2904
+ }
2905
+ const nestedItems = [];
2906
+ let colorSpace = "";
2907
+ let hueArc = "";
2908
+ let colorA = "";
2909
+ let pctA = "";
2910
+ let colorB = "";
2911
+ let pctB = "";
2912
+ let parsed = false;
2913
+ if (!REG_MIX.test(value)) if (value.startsWith("color-mix(") && REG_MIX_NEST.test(value)) {
2914
+ const items = value.match(REG_MIX_NEST);
2915
+ for (const item of items) if (item) {
2916
+ let val = resolveColorMix(item, { format: format === "specifiedValue" ? format : VAL_COMP });
2917
+ if (Array.isArray(val)) {
2918
+ const [cs, v1, v2, v3, v4] = val;
2919
+ if (v1 === 0 && v2 === 0 && v3 === 0 && v4 === 0) {
2920
+ value = "";
2921
+ break;
2922
+ }
2923
+ if (REG_MIX_CS_RGB_XYZ.test(cs)) if (v4 === 1) val = `color(${cs} ${v1} ${v2} ${v3})`;
2924
+ else val = `color(${cs} ${v1} ${v2} ${v3} / ${v4})`;
2925
+ else if (v4 === 1) val = `${cs}(${v1} ${v2} ${v3})`;
2926
+ else val = `${cs}(${v1} ${v2} ${v3} / ${v4})`;
2927
+ } else if (!REG_MIX.test(val)) {
2928
+ value = "";
2929
+ break;
2930
+ }
2931
+ nestedItems.push(val);
2932
+ value = value.replace(item, val);
2933
+ }
2934
+ if (!value) return cacheInvalidColorValue(cacheKey, format, nullable);
2935
+ } else if (value.startsWith("color-mix(") && value.endsWith(")") && value.includes("light-dark(")) {
2936
+ const [csPart = "", partA = "", partB = ""] = splitValue(value.replace(FN_MIX, "").replace(/\)$/, ""), { delimiter: "," });
2937
+ const [colorPartA = "", pctPartA = ""] = splitValue(partA);
2938
+ const [colorPartB = "", pctPartB = ""] = splitValue(partB);
2939
+ const specifiedColorA = resolveColor(colorPartA, { format: VAL_SPEC });
2940
+ const specifiedColorB = resolveColor(colorPartB, { format: VAL_SPEC });
2941
+ if (REG_MIX_IN_CS.test(csPart) && specifiedColorA && specifiedColorB) if (format === "specifiedValue") {
2942
+ const [, cs] = csPart.match(REG_MIX_IN_CS);
2943
+ if (REG_CS_HUE.test(cs)) [, colorSpace, hueArc] = cs.match(REG_CS_HUE);
2944
+ else colorSpace = cs;
2945
+ colorA = specifiedColorA;
2946
+ if (pctPartA) pctA = pctPartA;
2947
+ colorB = specifiedColorB;
2948
+ if (pctPartB) pctB = pctPartB;
2949
+ value = value.replace(colorPartA, specifiedColorA).replace(colorPartB, specifiedColorB);
2950
+ parsed = true;
2951
+ } else {
2952
+ const resolvedColorA = resolveColor(colorPartA, opt);
2953
+ const resolvedColorB = resolveColor(colorPartB, opt);
2954
+ if (isString(resolvedColorA) && isString(resolvedColorB)) value = value.replace(colorPartA, resolvedColorA).replace(colorPartB, resolvedColorB);
2955
+ }
2956
+ else return cacheInvalidColorValue(cacheKey, format, nullable);
2957
+ } else return cacheInvalidColorValue(cacheKey, format, nullable);
2958
+ if (nestedItems.length && format === "specifiedValue") {
2959
+ const [, cs] = value.match(REG_MIX_START);
2960
+ if (REG_CS_HUE.test(cs)) [, colorSpace, hueArc] = cs.match(REG_CS_HUE);
2961
+ else colorSpace = cs;
2962
+ if (nestedItems.length === 2) {
2963
+ let [itemA, itemB] = nestedItems;
2964
+ itemA = itemA.replace(/(?=[()])/g, "\\");
2965
+ itemB = itemB.replace(/(?=[()])/g, "\\");
2966
+ const regA = new RegExp(`(${itemA})(?:\\s+(${PCT}))?`);
2967
+ const regB = new RegExp(`(${itemB})(?:\\s+(${PCT}))?`);
2968
+ [, colorA, pctA] = value.match(regA);
2969
+ [, colorB, pctB] = value.match(regB);
2970
+ } else {
2971
+ let [item] = nestedItems;
2972
+ item = item.replace(/(?=[()])/g, "\\");
2973
+ const itemPart = `${item}(?:\\s+${PCT})?`;
2974
+ const itemPartCapt = `(${item})(?:\\s+(${PCT}))?`;
2975
+ const regItemPart = new RegExp(`^${itemPartCapt}$`);
2976
+ if (new RegExp(`${itemPartCapt}\\s*\\)$`).test(value)) {
2977
+ const reg = new RegExp(`(${SYN_MIX_PART})\\s*,\\s*(${itemPart})\\s*\\)$`);
2978
+ const [, colorPartA, colorPartB] = value.match(reg);
2979
+ [, colorA, pctA] = colorPartA.match(REG_MIX_COLOR_PART);
2980
+ [, colorB, pctB] = colorPartB.match(regItemPart);
2981
+ } else {
2982
+ const reg = new RegExp(`(${itemPart})\\s*,\\s*(${SYN_MIX_PART})\\s*\\)$`);
2983
+ const [, colorPartA, colorPartB] = value.match(reg);
2984
+ [, colorA, pctA] = colorPartA.match(regItemPart);
2985
+ [, colorB, pctB] = colorPartB.match(REG_MIX_COLOR_PART);
2986
+ }
2987
+ }
2988
+ } else if (!parsed) {
2989
+ const [, cs, colorPartA, colorPartB] = value.match(REG_MIX_CAPT);
2990
+ [, colorA, pctA] = colorPartA.match(REG_MIX_COLOR_PART);
2991
+ [, colorB, pctB] = colorPartB.match(REG_MIX_COLOR_PART);
2992
+ if (REG_CS_HUE.test(cs)) [, colorSpace, hueArc] = cs.match(REG_CS_HUE);
2993
+ else colorSpace = cs;
2994
+ }
2995
+ let pA, pB, m;
2996
+ if (pctA && pctB) {
2997
+ const p1 = parseFloat(pctA) / MAX_PCT;
2998
+ const p2 = parseFloat(pctB) / MAX_PCT;
2999
+ if (p1 < 0 || p1 > 1 || p2 < 0 || p2 > 1 || p1 === 0 && p2 === 0) return cacheInvalidColorValue(cacheKey, format, nullable);
3000
+ const factor = p1 + p2;
3001
+ pA = p1 / factor;
3002
+ pB = p2 / factor;
3003
+ m = factor < 1 ? factor : 1;
3004
+ } else {
3005
+ if (pctA) {
3006
+ pA = parseFloat(pctA) / MAX_PCT;
3007
+ if (pA < 0 || pA > 1) return cacheInvalidColorValue(cacheKey, format, nullable);
3008
+ pB = 1 - pA;
3009
+ } else if (pctB) {
3010
+ pB = parseFloat(pctB) / MAX_PCT;
3011
+ if (pB < 0 || pB > 1) return cacheInvalidColorValue(cacheKey, format, nullable);
3012
+ pA = 1 - pB;
3013
+ } else {
3014
+ pA = HALF;
3015
+ pB = HALF;
3016
+ }
3017
+ m = 1;
3018
+ }
3019
+ if (colorSpace === "xyz") colorSpace = "xyz-d65";
3020
+ if (format === "specifiedValue") {
3021
+ let valueA = "";
3022
+ let valueB = "";
3023
+ if (colorA.startsWith("color-mix(") || colorA.startsWith("light-dark(")) valueA = colorA;
3024
+ else if (colorA.startsWith("color(")) {
3025
+ const [cs, v1, v2, v3, v4] = parseColorFunc(colorA, opt);
3026
+ if (v4 === 1) valueA = `color(${cs} ${v1} ${v2} ${v3})`;
3027
+ else valueA = `color(${cs} ${v1} ${v2} ${v3} / ${v4})`;
3028
+ } else {
3029
+ const val = parseColorValue(colorA, opt);
3030
+ if (Array.isArray(val)) {
3031
+ const [cs, v1, v2, v3, v4] = val;
3032
+ if (v4 === 1) if (cs === "rgb") valueA = `${cs}(${v1}, ${v2}, ${v3})`;
3033
+ else valueA = `${cs}(${v1} ${v2} ${v3})`;
3034
+ else if (cs === "rgb") valueA = `${cs}a(${v1}, ${v2}, ${v3}, ${v4})`;
3035
+ else valueA = `${cs}(${v1} ${v2} ${v3} / ${v4})`;
3036
+ } else {
3037
+ if (!isString(val) || !val) {
3038
+ setCache(cacheKey, "");
3039
+ return "";
3040
+ }
3041
+ valueA = val;
3042
+ }
3043
+ }
3044
+ if (colorB.startsWith("color-mix(") || colorB.startsWith("light-dark(")) valueB = colorB;
3045
+ else if (colorB.startsWith("color(")) {
3046
+ const [cs, v1, v2, v3, v4] = parseColorFunc(colorB, opt);
3047
+ if (v4 === 1) valueB = `color(${cs} ${v1} ${v2} ${v3})`;
3048
+ else valueB = `color(${cs} ${v1} ${v2} ${v3} / ${v4})`;
3049
+ } else {
3050
+ const val = parseColorValue(colorB, opt);
3051
+ if (Array.isArray(val)) {
3052
+ const [cs, v1, v2, v3, v4] = val;
3053
+ if (v4 === 1) if (cs === "rgb") valueB = `${cs}(${v1}, ${v2}, ${v3})`;
3054
+ else valueB = `${cs}(${v1} ${v2} ${v3})`;
3055
+ else if (cs === "rgb") valueB = `${cs}a(${v1}, ${v2}, ${v3}, ${v4})`;
3056
+ else valueB = `${cs}(${v1} ${v2} ${v3} / ${v4})`;
3057
+ } else {
3058
+ if (!isString(val) || !val) {
3059
+ setCache(cacheKey, "");
3060
+ return "";
3061
+ }
3062
+ valueB = val;
3063
+ }
3064
+ }
3065
+ if (pctA && pctB) {
3066
+ valueA += ` ${parseFloat(pctA)}%`;
3067
+ valueB += ` ${parseFloat(pctB)}%`;
3068
+ } else if (pctA) {
3069
+ const pA = parseFloat(pctA);
3070
+ if (pA !== MAX_PCT * HALF) valueA += ` ${pA}%`;
3071
+ } else if (pctB) {
3072
+ const pA = MAX_PCT - parseFloat(pctB);
3073
+ if (pA !== MAX_PCT * HALF) valueA += ` ${pA}%`;
3074
+ }
3075
+ if (hueArc) {
3076
+ const res = `color-mix(in ${colorSpace} ${hueArc} hue, ${valueA}, ${valueB})`;
3077
+ setCache(cacheKey, res);
3078
+ return res;
3079
+ } else {
3080
+ const res = `color-mix(in ${colorSpace}, ${valueA}, ${valueB})`;
3081
+ setCache(cacheKey, res);
3082
+ return res;
3083
+ }
3084
+ }
3085
+ let r = 0;
3086
+ let g = 0;
3087
+ let b = 0;
3088
+ let alpha = 0;
3089
+ if (/^srgb(?:-linear)?$/.test(colorSpace)) {
3090
+ let rgbA, rgbB;
3091
+ if (colorSpace === "srgb") {
3092
+ if (REG_CURRENT.test(colorA)) rgbA = [
3093
+ NONE,
3094
+ NONE,
3095
+ NONE,
3096
+ NONE
3097
+ ];
3098
+ else rgbA = convertColorToRgb(colorA, {
3099
+ colorSpace,
3100
+ format: VAL_MIX
3101
+ });
3102
+ if (REG_CURRENT.test(colorB)) rgbB = [
3103
+ NONE,
3104
+ NONE,
3105
+ NONE,
3106
+ NONE
3107
+ ];
3108
+ else rgbB = convertColorToRgb(colorB, {
3109
+ colorSpace,
3110
+ format: VAL_MIX
3111
+ });
3112
+ } else {
3113
+ if (REG_CURRENT.test(colorA)) rgbA = [
3114
+ NONE,
3115
+ NONE,
3116
+ NONE,
3117
+ NONE
3118
+ ];
3119
+ else rgbA = convertColorToLinearRgb(colorA, {
3120
+ colorSpace,
3121
+ format: VAL_MIX
3122
+ });
3123
+ if (REG_CURRENT.test(colorB)) rgbB = [
3124
+ NONE,
3125
+ NONE,
3126
+ NONE,
3127
+ NONE
3128
+ ];
3129
+ else rgbB = convertColorToLinearRgb(colorB, {
3130
+ colorSpace,
3131
+ format: VAL_MIX
3132
+ });
3133
+ }
3134
+ if (rgbA instanceof NullObject || rgbB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
3135
+ const [rrA, ggA, bbA, aaA] = rgbA;
3136
+ const [rrB, ggB, bbB, aaB] = rgbB;
3137
+ const rNone = rrA === "none" && rrB === "none";
3138
+ const gNone = ggA === "none" && ggB === "none";
3139
+ const bNone = bbA === "none" && bbB === "none";
3140
+ const alphaNone = aaA === "none" && aaB === "none";
3141
+ const [[rA, gA, bA, alphaA], [rB, gB, bB, alphaB]] = normalizeColorComponents([
3142
+ rrA,
3143
+ ggA,
3144
+ bbA,
3145
+ aaA
3146
+ ], [
3147
+ rrB,
3148
+ ggB,
3149
+ bbB,
3150
+ aaB
3151
+ ], true);
3152
+ const factorA = alphaA * pA;
3153
+ const factorB = alphaB * pB;
3154
+ alpha = factorA + factorB;
3155
+ if (alpha === 0) {
3156
+ r = rA * pA + rB * pB;
3157
+ g = gA * pA + gB * pB;
3158
+ b = bA * pA + bB * pB;
3159
+ } else {
3160
+ r = (rA * factorA + rB * factorB) / alpha;
3161
+ g = (gA * factorA + gB * factorB) / alpha;
3162
+ b = (bA * factorA + bB * factorB) / alpha;
3163
+ alpha = parseFloat(alpha.toFixed(3));
3164
+ }
3165
+ if (format === "computedValue") {
3166
+ const res = [
3167
+ colorSpace,
3168
+ rNone ? NONE : roundToPrecision(r, HEX),
3169
+ gNone ? NONE : roundToPrecision(g, HEX),
3170
+ bNone ? NONE : roundToPrecision(b, HEX),
3171
+ alphaNone ? NONE : alpha * m
3172
+ ];
3173
+ setCache(cacheKey, res);
3174
+ return res;
3175
+ }
3176
+ r *= MAX_RGB;
3177
+ g *= MAX_RGB;
3178
+ b *= MAX_RGB;
3179
+ } else if (REG_CS_XYZ.test(colorSpace)) {
3180
+ let xyzA, xyzB;
3181
+ if (REG_CURRENT.test(colorA)) xyzA = [
3182
+ NONE,
3183
+ NONE,
3184
+ NONE,
3185
+ NONE
3186
+ ];
3187
+ else xyzA = convertColorToXyz(colorA, {
3188
+ colorSpace,
3189
+ d50: colorSpace === "xyz-d50",
3190
+ format: VAL_MIX
3191
+ });
3192
+ if (REG_CURRENT.test(colorB)) xyzB = [
3193
+ NONE,
3194
+ NONE,
3195
+ NONE,
3196
+ NONE
3197
+ ];
3198
+ else xyzB = convertColorToXyz(colorB, {
3199
+ colorSpace,
3200
+ d50: colorSpace === "xyz-d50",
3201
+ format: VAL_MIX
3202
+ });
3203
+ if (xyzA instanceof NullObject || xyzB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
3204
+ const [xxA, yyA, zzA, aaA] = xyzA;
3205
+ const [xxB, yyB, zzB, aaB] = xyzB;
3206
+ const xNone = xxA === "none" && xxB === "none";
3207
+ const yNone = yyA === "none" && yyB === "none";
3208
+ const zNone = zzA === "none" && zzB === "none";
3209
+ const alphaNone = aaA === "none" && aaB === "none";
3210
+ const [[xA, yA, zA, alphaA], [xB, yB, zB, alphaB]] = normalizeColorComponents([
3211
+ xxA,
3212
+ yyA,
3213
+ zzA,
3214
+ aaA
3215
+ ], [
3216
+ xxB,
3217
+ yyB,
3218
+ zzB,
3219
+ aaB
3220
+ ], true);
3221
+ const factorA = alphaA * pA;
3222
+ const factorB = alphaB * pB;
3223
+ alpha = factorA + factorB;
3224
+ let x, y, z;
3225
+ if (alpha === 0) {
3226
+ x = xA * pA + xB * pB;
3227
+ y = yA * pA + yB * pB;
3228
+ z = zA * pA + zB * pB;
3229
+ } else {
3230
+ x = (xA * factorA + xB * factorB) / alpha;
3231
+ y = (yA * factorA + yB * factorB) / alpha;
3232
+ z = (zA * factorA + zB * factorB) / alpha;
3233
+ alpha = parseFloat(alpha.toFixed(3));
3234
+ }
3235
+ if (format === "computedValue") {
3236
+ const res = [
3237
+ colorSpace,
3238
+ xNone ? NONE : roundToPrecision(x, HEX),
3239
+ yNone ? NONE : roundToPrecision(y, HEX),
3240
+ zNone ? NONE : roundToPrecision(z, HEX),
3241
+ alphaNone ? NONE : alpha * m
3242
+ ];
3243
+ setCache(cacheKey, res);
3244
+ return res;
3245
+ }
3246
+ if (colorSpace === "xyz-d50") [r, g, b] = transformXyzD50ToRgb([
3247
+ x,
3248
+ y,
3249
+ z
3250
+ ], true);
3251
+ else [r, g, b] = transformXyzToRgb([
3252
+ x,
3253
+ y,
3254
+ z
3255
+ ], true);
3256
+ } else if (/^h(?:sl|wb)$/.test(colorSpace)) {
3257
+ let hslA, hslB;
3258
+ if (colorSpace === "hsl") {
3259
+ if (REG_CURRENT.test(colorA)) hslA = [
3260
+ NONE,
3261
+ NONE,
3262
+ NONE,
3263
+ NONE
3264
+ ];
3265
+ else hslA = convertColorToHsl(colorA, {
3266
+ colorSpace,
3267
+ format: VAL_MIX
3268
+ });
3269
+ if (REG_CURRENT.test(colorB)) hslB = [
3270
+ NONE,
3271
+ NONE,
3272
+ NONE,
3273
+ NONE
3274
+ ];
3275
+ else hslB = convertColorToHsl(colorB, {
3276
+ colorSpace,
3277
+ format: VAL_MIX
3278
+ });
3279
+ } else {
3280
+ if (REG_CURRENT.test(colorA)) hslA = [
3281
+ NONE,
3282
+ NONE,
3283
+ NONE,
3284
+ NONE
3285
+ ];
3286
+ else hslA = convertColorToHwb(colorA, {
3287
+ colorSpace,
3288
+ format: VAL_MIX
3289
+ });
3290
+ if (REG_CURRENT.test(colorB)) hslB = [
3291
+ NONE,
3292
+ NONE,
3293
+ NONE,
3294
+ NONE
3295
+ ];
3296
+ else hslB = convertColorToHwb(colorB, {
3297
+ colorSpace,
3298
+ format: VAL_MIX
3299
+ });
3300
+ }
3301
+ if (hslA instanceof NullObject || hslB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
3302
+ const [hhA, ssA, llA, aaA] = hslA;
3303
+ const [hhB, ssB, llB, aaB] = hslB;
3304
+ const alphaNone = aaA === "none" && aaB === "none";
3305
+ let [[hA, sA, lA, alphaA], [hB, sB, lB, alphaB]] = normalizeColorComponents([
3306
+ hhA,
3307
+ ssA,
3308
+ llA,
3309
+ aaA
3310
+ ], [
3311
+ hhB,
3312
+ ssB,
3313
+ llB,
3314
+ aaB
3315
+ ], true);
3316
+ if (hueArc) [hA, hB] = interpolateHue(hA, hB, hueArc);
3317
+ const factorA = alphaA * pA;
3318
+ const factorB = alphaB * pB;
3319
+ alpha = factorA + factorB;
3320
+ const h = (hA * pA + hB * pB) % DEG;
3321
+ let s, l;
3322
+ if (alpha === 0) {
3323
+ s = sA * pA + sB * pB;
3324
+ l = lA * pA + lB * pB;
3325
+ } else {
3326
+ s = (sA * factorA + sB * factorB) / alpha;
3327
+ l = (lA * factorA + lB * factorB) / alpha;
3328
+ alpha = parseFloat(alpha.toFixed(3));
3329
+ }
3330
+ [r, g, b] = convertColorToRgb(`${colorSpace}(${h} ${s} ${l})`);
3331
+ if (format === "computedValue") {
3332
+ const res = [
3333
+ "srgb",
3334
+ roundToPrecision(r / MAX_RGB, HEX),
3335
+ roundToPrecision(g / MAX_RGB, HEX),
3336
+ roundToPrecision(b / MAX_RGB, HEX),
3337
+ alphaNone ? NONE : alpha * m
3338
+ ];
3339
+ setCache(cacheKey, res);
3340
+ return res;
3341
+ }
3342
+ } else if (/^(?:ok)?lch$/.test(colorSpace)) {
3343
+ let lchA, lchB;
3344
+ if (colorSpace === "lch") {
3345
+ if (REG_CURRENT.test(colorA)) lchA = [
3346
+ NONE,
3347
+ NONE,
3348
+ NONE,
3349
+ NONE
3350
+ ];
3351
+ else lchA = convertColorToLch(colorA, {
3352
+ colorSpace,
3353
+ format: VAL_MIX
3354
+ });
3355
+ if (REG_CURRENT.test(colorB)) lchB = [
3356
+ NONE,
3357
+ NONE,
3358
+ NONE,
3359
+ NONE
3360
+ ];
3361
+ else lchB = convertColorToLch(colorB, {
3362
+ colorSpace,
3363
+ format: VAL_MIX
3364
+ });
3365
+ } else {
3366
+ if (REG_CURRENT.test(colorA)) lchA = [
3367
+ NONE,
3368
+ NONE,
3369
+ NONE,
3370
+ NONE
3371
+ ];
3372
+ else lchA = convertColorToOklch(colorA, {
3373
+ colorSpace,
3374
+ format: VAL_MIX
3375
+ });
3376
+ if (REG_CURRENT.test(colorB)) lchB = [
3377
+ NONE,
3378
+ NONE,
3379
+ NONE,
3380
+ NONE
3381
+ ];
3382
+ else lchB = convertColorToOklch(colorB, {
3383
+ colorSpace,
3384
+ format: VAL_MIX
3385
+ });
3386
+ }
3387
+ if (lchA instanceof NullObject || lchB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
3388
+ const [llA, ccA, hhA, aaA] = lchA;
3389
+ const [llB, ccB, hhB, aaB] = lchB;
3390
+ const lNone = llA === "none" && llB === "none";
3391
+ const cNone = ccA === "none" && ccB === "none";
3392
+ const hNone = hhA === "none" && hhB === "none";
3393
+ const alphaNone = aaA === "none" && aaB === "none";
3394
+ let [[lA, cA, hA, alphaA], [lB, cB, hB, alphaB]] = normalizeColorComponents([
3395
+ llA,
3396
+ ccA,
3397
+ hhA,
3398
+ aaA
3399
+ ], [
3400
+ llB,
3401
+ ccB,
3402
+ hhB,
3403
+ aaB
3404
+ ], true);
3405
+ if (hueArc) [hA, hB] = interpolateHue(hA, hB, hueArc);
3406
+ const factorA = alphaA * pA;
3407
+ const factorB = alphaB * pB;
3408
+ alpha = factorA + factorB;
3409
+ const h = (hA * pA + hB * pB) % DEG;
3410
+ let l, c;
3411
+ if (alpha === 0) {
3412
+ l = lA * pA + lB * pB;
3413
+ c = cA * pA + cB * pB;
3414
+ } else {
3415
+ l = (lA * factorA + lB * factorB) / alpha;
3416
+ c = (cA * factorA + cB * factorB) / alpha;
3417
+ alpha = parseFloat(alpha.toFixed(3));
3418
+ }
3419
+ if (format === "computedValue") {
3420
+ const res = [
3421
+ colorSpace,
3422
+ lNone ? NONE : roundToPrecision(l, HEX),
3423
+ cNone ? NONE : roundToPrecision(c, HEX),
3424
+ hNone ? NONE : roundToPrecision(h, HEX),
3425
+ alphaNone ? NONE : alpha * m
3426
+ ];
3427
+ setCache(cacheKey, res);
3428
+ return res;
3429
+ }
3430
+ [, r, g, b] = resolveColorValue(`${colorSpace}(${l} ${c} ${h})`);
3431
+ } else {
3432
+ let labA, labB;
3433
+ if (colorSpace === "lab") {
3434
+ if (REG_CURRENT.test(colorA)) labA = [
3435
+ NONE,
3436
+ NONE,
3437
+ NONE,
3438
+ NONE
3439
+ ];
3440
+ else labA = convertColorToLab(colorA, {
3441
+ colorSpace,
3442
+ format: VAL_MIX
3443
+ });
3444
+ if (REG_CURRENT.test(colorB)) labB = [
3445
+ NONE,
3446
+ NONE,
3447
+ NONE,
3448
+ NONE
3449
+ ];
3450
+ else labB = convertColorToLab(colorB, {
3451
+ colorSpace,
3452
+ format: VAL_MIX
3453
+ });
3454
+ } else {
3455
+ if (REG_CURRENT.test(colorA)) labA = [
3456
+ NONE,
3457
+ NONE,
3458
+ NONE,
3459
+ NONE
3460
+ ];
3461
+ else labA = convertColorToOklab(colorA, {
3462
+ colorSpace,
3463
+ format: VAL_MIX
3464
+ });
3465
+ if (REG_CURRENT.test(colorB)) labB = [
3466
+ NONE,
3467
+ NONE,
3468
+ NONE,
3469
+ NONE
3470
+ ];
3471
+ else labB = convertColorToOklab(colorB, {
3472
+ colorSpace,
3473
+ format: VAL_MIX
3474
+ });
3475
+ }
3476
+ if (labA instanceof NullObject || labB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
3477
+ const [llA, aaA, bbA, alA] = labA;
3478
+ const [llB, aaB, bbB, alB] = labB;
3479
+ const lNone = llA === "none" && llB === "none";
3480
+ const aNone = aaA === "none" && aaB === "none";
3481
+ const bNone = bbA === "none" && bbB === "none";
3482
+ const alphaNone = alA === "none" && alB === "none";
3483
+ const [[lA, aA, bA, alphaA], [lB, aB, bB, alphaB]] = normalizeColorComponents([
3484
+ llA,
3485
+ aaA,
3486
+ bbA,
3487
+ alA
3488
+ ], [
3489
+ llB,
3490
+ aaB,
3491
+ bbB,
3492
+ alB
3493
+ ], true);
3494
+ const factorA = alphaA * pA;
3495
+ const factorB = alphaB * pB;
3496
+ alpha = factorA + factorB;
3497
+ let l, aO, bO;
3498
+ if (alpha === 0) {
3499
+ l = lA * pA + lB * pB;
3500
+ aO = aA * pA + aB * pB;
3501
+ bO = bA * pA + bB * pB;
3502
+ } else {
3503
+ l = (lA * factorA + lB * factorB) / alpha;
3504
+ aO = (aA * factorA + aB * factorB) / alpha;
3505
+ bO = (bA * factorA + bB * factorB) / alpha;
3506
+ alpha = parseFloat(alpha.toFixed(3));
3507
+ }
3508
+ if (format === "computedValue") {
3509
+ const res = [
3510
+ colorSpace,
3511
+ lNone ? NONE : roundToPrecision(l, HEX),
3512
+ aNone ? NONE : roundToPrecision(aO, HEX),
3513
+ bNone ? NONE : roundToPrecision(bO, HEX),
3514
+ alphaNone ? NONE : alpha * m
3515
+ ];
3516
+ setCache(cacheKey, res);
3517
+ return res;
3518
+ }
3519
+ [, r, g, b] = resolveColorValue(`${colorSpace}(${l} ${aO} ${bO})`);
3520
+ }
3521
+ const res = [
3522
+ "rgb",
3523
+ Math.round(r),
3524
+ Math.round(g),
3525
+ Math.round(b),
3526
+ parseFloat((alpha * m).toFixed(3))
3527
+ ];
3528
+ setCache(cacheKey, res);
3529
+ return res;
3530
+ };
3531
+ //#endregion
3532
+ export { NAMED_COLORS, convertColorToHsl, convertColorToHwb, convertColorToLab, convertColorToLch, convertColorToOklab, convertColorToOklch, convertColorToRgb, convertRgbToHex, numberToHexString, parseColorFunc, parseColorValue, resolveColorFunc, resolveColorMix, resolveColorValue };
3533
+
3534
+ //# sourceMappingURL=color.js.map
node_modules/@asamuzakjp/css-color/dist/esm/js/color.js.map ADDED
The diff for this file is too large to render. See raw diff