@nsshunt/stsrest01client 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4032 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const node_fs = require("node:fs");
4
+ const require$$1 = require("path");
5
+ const require$$2 = require("os");
6
+ const require$$3 = require("crypto");
7
+ const axios = require("axios");
8
+ const stsutils = require("@nsshunt/stsutils");
9
+ function getDefaultExportFromCjs(x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
11
+ }
12
+ function getAugmentedNamespace(n) {
13
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
14
+ var f = n.default;
15
+ if (typeof f == "function") {
16
+ var a = function a2() {
17
+ var isInstance = false;
18
+ try {
19
+ isInstance = this instanceof a2;
20
+ } catch {
21
+ }
22
+ if (isInstance) {
23
+ return Reflect.construct(f, arguments, this.constructor);
24
+ }
25
+ return f.apply(this, arguments);
26
+ };
27
+ a.prototype = f.prototype;
28
+ } else a = {};
29
+ Object.defineProperty(a, "__esModule", { value: true });
30
+ Object.keys(n).forEach(function(k) {
31
+ var d = Object.getOwnPropertyDescriptor(n, k);
32
+ Object.defineProperty(a, k, d.get ? d : {
33
+ enumerable: true,
34
+ get: function() {
35
+ return n[k];
36
+ }
37
+ });
38
+ });
39
+ return a;
40
+ }
41
+ var main = { exports: {} };
42
+ const __viteBrowserExternal = {};
43
+ const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
44
+ __proto__: null,
45
+ default: __viteBrowserExternal
46
+ }, Symbol.toStringTag, { value: "Module" }));
47
+ const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
48
+ const version = "17.2.4";
49
+ const require$$4 = {
50
+ version
51
+ };
52
+ var hasRequiredMain;
53
+ function requireMain() {
54
+ if (hasRequiredMain) return main.exports;
55
+ hasRequiredMain = 1;
56
+ const fs = require$$0;
57
+ const path = require$$1;
58
+ const os = require$$2;
59
+ const crypto2 = require$$3;
60
+ const packageJson = require$$4;
61
+ const version2 = packageJson.version;
62
+ const TIPS = [
63
+ "🔐 encrypt with Dotenvx: https://dotenvx.com",
64
+ "🔐 prevent committing .env to code: https://dotenvx.com/precommit",
65
+ "🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
66
+ "📡 add observability to secrets: https://dotenvx.com/ops",
67
+ "👥 sync secrets across teammates & machines: https://dotenvx.com/ops",
68
+ "🗂️ backup and recover secrets: https://dotenvx.com/ops",
69
+ "✅ audit secrets and track compliance: https://dotenvx.com/ops",
70
+ "🔄 add secrets lifecycle management: https://dotenvx.com/ops",
71
+ "🔑 add access controls to secrets: https://dotenvx.com/ops",
72
+ "🛠️ run anywhere with `dotenvx run -- yourcommand`",
73
+ "⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
74
+ "⚙️ enable debug logging with { debug: true }",
75
+ "⚙️ override existing env vars with { override: true }",
76
+ "⚙️ suppress all logs with { quiet: true }",
77
+ "⚙️ write to custom object with { processEnv: myObject }",
78
+ "⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
79
+ ];
80
+ function _getRandomTip() {
81
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
82
+ }
83
+ function parseBoolean(value) {
84
+ if (typeof value === "string") {
85
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
86
+ }
87
+ return Boolean(value);
88
+ }
89
+ function supportsAnsi() {
90
+ return process.stdout.isTTY;
91
+ }
92
+ function dim(text) {
93
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
94
+ }
95
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
96
+ function parse(src) {
97
+ const obj = {};
98
+ let lines = src.toString();
99
+ lines = lines.replace(/\r\n?/mg, "\n");
100
+ let match;
101
+ while ((match = LINE.exec(lines)) != null) {
102
+ const key = match[1];
103
+ let value = match[2] || "";
104
+ value = value.trim();
105
+ const maybeQuote = value[0];
106
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
107
+ if (maybeQuote === '"') {
108
+ value = value.replace(/\\n/g, "\n");
109
+ value = value.replace(/\\r/g, "\r");
110
+ }
111
+ obj[key] = value;
112
+ }
113
+ return obj;
114
+ }
115
+ function _parseVault(options) {
116
+ options = options || {};
117
+ const vaultPath = _vaultPath(options);
118
+ options.path = vaultPath;
119
+ const result = DotenvModule.configDotenv(options);
120
+ if (!result.parsed) {
121
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
122
+ err.code = "MISSING_DATA";
123
+ throw err;
124
+ }
125
+ const keys = _dotenvKey(options).split(",");
126
+ const length = keys.length;
127
+ let decrypted;
128
+ for (let i = 0; i < length; i++) {
129
+ try {
130
+ const key = keys[i].trim();
131
+ const attrs = _instructions(result, key);
132
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
133
+ break;
134
+ } catch (error) {
135
+ if (i + 1 >= length) {
136
+ throw error;
137
+ }
138
+ }
139
+ }
140
+ return DotenvModule.parse(decrypted);
141
+ }
142
+ function _warn(message) {
143
+ console.error(`[dotenv@${version2}][WARN] ${message}`);
144
+ }
145
+ function _debug(message) {
146
+ console.log(`[dotenv@${version2}][DEBUG] ${message}`);
147
+ }
148
+ function _log(message) {
149
+ console.log(`[dotenv@${version2}] ${message}`);
150
+ }
151
+ function _dotenvKey(options) {
152
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
153
+ return options.DOTENV_KEY;
154
+ }
155
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
156
+ return process.env.DOTENV_KEY;
157
+ }
158
+ return "";
159
+ }
160
+ function _instructions(result, dotenvKey) {
161
+ let uri;
162
+ try {
163
+ uri = new URL(dotenvKey);
164
+ } catch (error) {
165
+ if (error.code === "ERR_INVALID_URL") {
166
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
167
+ err.code = "INVALID_DOTENV_KEY";
168
+ throw err;
169
+ }
170
+ throw error;
171
+ }
172
+ const key = uri.password;
173
+ if (!key) {
174
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
175
+ err.code = "INVALID_DOTENV_KEY";
176
+ throw err;
177
+ }
178
+ const environment = uri.searchParams.get("environment");
179
+ if (!environment) {
180
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
181
+ err.code = "INVALID_DOTENV_KEY";
182
+ throw err;
183
+ }
184
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
185
+ const ciphertext = result.parsed[environmentKey];
186
+ if (!ciphertext) {
187
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
188
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
189
+ throw err;
190
+ }
191
+ return { ciphertext, key };
192
+ }
193
+ function _vaultPath(options) {
194
+ let possibleVaultPath = null;
195
+ if (options && options.path && options.path.length > 0) {
196
+ if (Array.isArray(options.path)) {
197
+ for (const filepath of options.path) {
198
+ if (fs.existsSync(filepath)) {
199
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
200
+ }
201
+ }
202
+ } else {
203
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
204
+ }
205
+ } else {
206
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
207
+ }
208
+ if (fs.existsSync(possibleVaultPath)) {
209
+ return possibleVaultPath;
210
+ }
211
+ return null;
212
+ }
213
+ function _resolveHome(envPath) {
214
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
215
+ }
216
+ function _configVault(options) {
217
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
218
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
219
+ if (debug || !quiet) {
220
+ _log("Loading env from encrypted .env.vault");
221
+ }
222
+ const parsed = DotenvModule._parseVault(options);
223
+ let processEnv = process.env;
224
+ if (options && options.processEnv != null) {
225
+ processEnv = options.processEnv;
226
+ }
227
+ DotenvModule.populate(processEnv, parsed, options);
228
+ return { parsed };
229
+ }
230
+ function configDotenv(options) {
231
+ const dotenvPath = path.resolve(process.cwd(), ".env");
232
+ let encoding = "utf8";
233
+ let processEnv = process.env;
234
+ if (options && options.processEnv != null) {
235
+ processEnv = options.processEnv;
236
+ }
237
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
238
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
239
+ if (options && options.encoding) {
240
+ encoding = options.encoding;
241
+ } else {
242
+ if (debug) {
243
+ _debug("No encoding is specified. UTF-8 is used by default");
244
+ }
245
+ }
246
+ let optionPaths = [dotenvPath];
247
+ if (options && options.path) {
248
+ if (!Array.isArray(options.path)) {
249
+ optionPaths = [_resolveHome(options.path)];
250
+ } else {
251
+ optionPaths = [];
252
+ for (const filepath of options.path) {
253
+ optionPaths.push(_resolveHome(filepath));
254
+ }
255
+ }
256
+ }
257
+ let lastError;
258
+ const parsedAll = {};
259
+ for (const path2 of optionPaths) {
260
+ try {
261
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
262
+ DotenvModule.populate(parsedAll, parsed, options);
263
+ } catch (e) {
264
+ if (debug) {
265
+ _debug(`Failed to load ${path2} ${e.message}`);
266
+ }
267
+ lastError = e;
268
+ }
269
+ }
270
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
271
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
272
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
273
+ if (debug || !quiet) {
274
+ const keysCount = Object.keys(populated).length;
275
+ const shortPaths = [];
276
+ for (const filePath of optionPaths) {
277
+ try {
278
+ const relative = path.relative(process.cwd(), filePath);
279
+ shortPaths.push(relative);
280
+ } catch (e) {
281
+ if (debug) {
282
+ _debug(`Failed to load ${filePath} ${e.message}`);
283
+ }
284
+ lastError = e;
285
+ }
286
+ }
287
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
288
+ }
289
+ if (lastError) {
290
+ return { parsed: parsedAll, error: lastError };
291
+ } else {
292
+ return { parsed: parsedAll };
293
+ }
294
+ }
295
+ function config(options) {
296
+ if (_dotenvKey(options).length === 0) {
297
+ return DotenvModule.configDotenv(options);
298
+ }
299
+ const vaultPath = _vaultPath(options);
300
+ if (!vaultPath) {
301
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
302
+ return DotenvModule.configDotenv(options);
303
+ }
304
+ return DotenvModule._configVault(options);
305
+ }
306
+ function decrypt(encrypted, keyStr) {
307
+ const key = Buffer.from(keyStr.slice(-64), "hex");
308
+ let ciphertext = Buffer.from(encrypted, "base64");
309
+ const nonce = ciphertext.subarray(0, 12);
310
+ const authTag = ciphertext.subarray(-16);
311
+ ciphertext = ciphertext.subarray(12, -16);
312
+ try {
313
+ const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
314
+ aesgcm.setAuthTag(authTag);
315
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
316
+ } catch (error) {
317
+ const isRange = error instanceof RangeError;
318
+ const invalidKeyLength = error.message === "Invalid key length";
319
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
320
+ if (isRange || invalidKeyLength) {
321
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
322
+ err.code = "INVALID_DOTENV_KEY";
323
+ throw err;
324
+ } else if (decryptionFailed) {
325
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
326
+ err.code = "DECRYPTION_FAILED";
327
+ throw err;
328
+ } else {
329
+ throw error;
330
+ }
331
+ }
332
+ }
333
+ function populate(processEnv, parsed, options = {}) {
334
+ const debug = Boolean(options && options.debug);
335
+ const override = Boolean(options && options.override);
336
+ const populated = {};
337
+ if (typeof parsed !== "object") {
338
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
339
+ err.code = "OBJECT_REQUIRED";
340
+ throw err;
341
+ }
342
+ for (const key of Object.keys(parsed)) {
343
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
344
+ if (override === true) {
345
+ processEnv[key] = parsed[key];
346
+ populated[key] = parsed[key];
347
+ }
348
+ if (debug) {
349
+ if (override === true) {
350
+ _debug(`"${key}" is already defined and WAS overwritten`);
351
+ } else {
352
+ _debug(`"${key}" is already defined and was NOT overwritten`);
353
+ }
354
+ }
355
+ } else {
356
+ processEnv[key] = parsed[key];
357
+ populated[key] = parsed[key];
358
+ }
359
+ }
360
+ return populated;
361
+ }
362
+ const DotenvModule = {
363
+ configDotenv,
364
+ _configVault,
365
+ _parseVault,
366
+ config,
367
+ decrypt,
368
+ parse,
369
+ populate
370
+ };
371
+ main.exports.configDotenv = DotenvModule.configDotenv;
372
+ main.exports._configVault = DotenvModule._configVault;
373
+ main.exports._parseVault = DotenvModule._parseVault;
374
+ main.exports.config = DotenvModule.config;
375
+ main.exports.decrypt = DotenvModule.decrypt;
376
+ main.exports.parse = DotenvModule.parse;
377
+ main.exports.populate = DotenvModule.populate;
378
+ main.exports = DotenvModule;
379
+ return main.exports;
380
+ }
381
+ var mainExports = requireMain();
382
+ const dotenv = /* @__PURE__ */ getDefaultExportFromCjs(mainExports);
383
+ var ansiStyles$1 = { exports: {} };
384
+ var colorName$1;
385
+ var hasRequiredColorName$1;
386
+ function requireColorName$1() {
387
+ if (hasRequiredColorName$1) return colorName$1;
388
+ hasRequiredColorName$1 = 1;
389
+ colorName$1 = {
390
+ "aliceblue": [240, 248, 255],
391
+ "antiquewhite": [250, 235, 215],
392
+ "aqua": [0, 255, 255],
393
+ "aquamarine": [127, 255, 212],
394
+ "azure": [240, 255, 255],
395
+ "beige": [245, 245, 220],
396
+ "bisque": [255, 228, 196],
397
+ "black": [0, 0, 0],
398
+ "blanchedalmond": [255, 235, 205],
399
+ "blue": [0, 0, 255],
400
+ "blueviolet": [138, 43, 226],
401
+ "brown": [165, 42, 42],
402
+ "burlywood": [222, 184, 135],
403
+ "cadetblue": [95, 158, 160],
404
+ "chartreuse": [127, 255, 0],
405
+ "chocolate": [210, 105, 30],
406
+ "coral": [255, 127, 80],
407
+ "cornflowerblue": [100, 149, 237],
408
+ "cornsilk": [255, 248, 220],
409
+ "crimson": [220, 20, 60],
410
+ "cyan": [0, 255, 255],
411
+ "darkblue": [0, 0, 139],
412
+ "darkcyan": [0, 139, 139],
413
+ "darkgoldenrod": [184, 134, 11],
414
+ "darkgray": [169, 169, 169],
415
+ "darkgreen": [0, 100, 0],
416
+ "darkgrey": [169, 169, 169],
417
+ "darkkhaki": [189, 183, 107],
418
+ "darkmagenta": [139, 0, 139],
419
+ "darkolivegreen": [85, 107, 47],
420
+ "darkorange": [255, 140, 0],
421
+ "darkorchid": [153, 50, 204],
422
+ "darkred": [139, 0, 0],
423
+ "darksalmon": [233, 150, 122],
424
+ "darkseagreen": [143, 188, 143],
425
+ "darkslateblue": [72, 61, 139],
426
+ "darkslategray": [47, 79, 79],
427
+ "darkslategrey": [47, 79, 79],
428
+ "darkturquoise": [0, 206, 209],
429
+ "darkviolet": [148, 0, 211],
430
+ "deeppink": [255, 20, 147],
431
+ "deepskyblue": [0, 191, 255],
432
+ "dimgray": [105, 105, 105],
433
+ "dimgrey": [105, 105, 105],
434
+ "dodgerblue": [30, 144, 255],
435
+ "firebrick": [178, 34, 34],
436
+ "floralwhite": [255, 250, 240],
437
+ "forestgreen": [34, 139, 34],
438
+ "fuchsia": [255, 0, 255],
439
+ "gainsboro": [220, 220, 220],
440
+ "ghostwhite": [248, 248, 255],
441
+ "gold": [255, 215, 0],
442
+ "goldenrod": [218, 165, 32],
443
+ "gray": [128, 128, 128],
444
+ "green": [0, 128, 0],
445
+ "greenyellow": [173, 255, 47],
446
+ "grey": [128, 128, 128],
447
+ "honeydew": [240, 255, 240],
448
+ "hotpink": [255, 105, 180],
449
+ "indianred": [205, 92, 92],
450
+ "indigo": [75, 0, 130],
451
+ "ivory": [255, 255, 240],
452
+ "khaki": [240, 230, 140],
453
+ "lavender": [230, 230, 250],
454
+ "lavenderblush": [255, 240, 245],
455
+ "lawngreen": [124, 252, 0],
456
+ "lemonchiffon": [255, 250, 205],
457
+ "lightblue": [173, 216, 230],
458
+ "lightcoral": [240, 128, 128],
459
+ "lightcyan": [224, 255, 255],
460
+ "lightgoldenrodyellow": [250, 250, 210],
461
+ "lightgray": [211, 211, 211],
462
+ "lightgreen": [144, 238, 144],
463
+ "lightgrey": [211, 211, 211],
464
+ "lightpink": [255, 182, 193],
465
+ "lightsalmon": [255, 160, 122],
466
+ "lightseagreen": [32, 178, 170],
467
+ "lightskyblue": [135, 206, 250],
468
+ "lightslategray": [119, 136, 153],
469
+ "lightslategrey": [119, 136, 153],
470
+ "lightsteelblue": [176, 196, 222],
471
+ "lightyellow": [255, 255, 224],
472
+ "lime": [0, 255, 0],
473
+ "limegreen": [50, 205, 50],
474
+ "linen": [250, 240, 230],
475
+ "magenta": [255, 0, 255],
476
+ "maroon": [128, 0, 0],
477
+ "mediumaquamarine": [102, 205, 170],
478
+ "mediumblue": [0, 0, 205],
479
+ "mediumorchid": [186, 85, 211],
480
+ "mediumpurple": [147, 112, 219],
481
+ "mediumseagreen": [60, 179, 113],
482
+ "mediumslateblue": [123, 104, 238],
483
+ "mediumspringgreen": [0, 250, 154],
484
+ "mediumturquoise": [72, 209, 204],
485
+ "mediumvioletred": [199, 21, 133],
486
+ "midnightblue": [25, 25, 112],
487
+ "mintcream": [245, 255, 250],
488
+ "mistyrose": [255, 228, 225],
489
+ "moccasin": [255, 228, 181],
490
+ "navajowhite": [255, 222, 173],
491
+ "navy": [0, 0, 128],
492
+ "oldlace": [253, 245, 230],
493
+ "olive": [128, 128, 0],
494
+ "olivedrab": [107, 142, 35],
495
+ "orange": [255, 165, 0],
496
+ "orangered": [255, 69, 0],
497
+ "orchid": [218, 112, 214],
498
+ "palegoldenrod": [238, 232, 170],
499
+ "palegreen": [152, 251, 152],
500
+ "paleturquoise": [175, 238, 238],
501
+ "palevioletred": [219, 112, 147],
502
+ "papayawhip": [255, 239, 213],
503
+ "peachpuff": [255, 218, 185],
504
+ "peru": [205, 133, 63],
505
+ "pink": [255, 192, 203],
506
+ "plum": [221, 160, 221],
507
+ "powderblue": [176, 224, 230],
508
+ "purple": [128, 0, 128],
509
+ "rebeccapurple": [102, 51, 153],
510
+ "red": [255, 0, 0],
511
+ "rosybrown": [188, 143, 143],
512
+ "royalblue": [65, 105, 225],
513
+ "saddlebrown": [139, 69, 19],
514
+ "salmon": [250, 128, 114],
515
+ "sandybrown": [244, 164, 96],
516
+ "seagreen": [46, 139, 87],
517
+ "seashell": [255, 245, 238],
518
+ "sienna": [160, 82, 45],
519
+ "silver": [192, 192, 192],
520
+ "skyblue": [135, 206, 235],
521
+ "slateblue": [106, 90, 205],
522
+ "slategray": [112, 128, 144],
523
+ "slategrey": [112, 128, 144],
524
+ "snow": [255, 250, 250],
525
+ "springgreen": [0, 255, 127],
526
+ "steelblue": [70, 130, 180],
527
+ "tan": [210, 180, 140],
528
+ "teal": [0, 128, 128],
529
+ "thistle": [216, 191, 216],
530
+ "tomato": [255, 99, 71],
531
+ "turquoise": [64, 224, 208],
532
+ "violet": [238, 130, 238],
533
+ "wheat": [245, 222, 179],
534
+ "white": [255, 255, 255],
535
+ "whitesmoke": [245, 245, 245],
536
+ "yellow": [255, 255, 0],
537
+ "yellowgreen": [154, 205, 50]
538
+ };
539
+ return colorName$1;
540
+ }
541
+ var conversions$1;
542
+ var hasRequiredConversions$1;
543
+ function requireConversions$1() {
544
+ if (hasRequiredConversions$1) return conversions$1;
545
+ hasRequiredConversions$1 = 1;
546
+ const cssKeywords = requireColorName$1();
547
+ const reverseKeywords = {};
548
+ for (const key of Object.keys(cssKeywords)) {
549
+ reverseKeywords[cssKeywords[key]] = key;
550
+ }
551
+ const convert = {
552
+ rgb: { channels: 3, labels: "rgb" },
553
+ hsl: { channels: 3, labels: "hsl" },
554
+ hsv: { channels: 3, labels: "hsv" },
555
+ hwb: { channels: 3, labels: "hwb" },
556
+ cmyk: { channels: 4, labels: "cmyk" },
557
+ xyz: { channels: 3, labels: "xyz" },
558
+ lab: { channels: 3, labels: "lab" },
559
+ lch: { channels: 3, labels: "lch" },
560
+ hex: { channels: 1, labels: ["hex"] },
561
+ keyword: { channels: 1, labels: ["keyword"] },
562
+ ansi16: { channels: 1, labels: ["ansi16"] },
563
+ ansi256: { channels: 1, labels: ["ansi256"] },
564
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
565
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
566
+ gray: { channels: 1, labels: ["gray"] }
567
+ };
568
+ conversions$1 = convert;
569
+ for (const model of Object.keys(convert)) {
570
+ if (!("channels" in convert[model])) {
571
+ throw new Error("missing channels property: " + model);
572
+ }
573
+ if (!("labels" in convert[model])) {
574
+ throw new Error("missing channel labels property: " + model);
575
+ }
576
+ if (convert[model].labels.length !== convert[model].channels) {
577
+ throw new Error("channel and label counts mismatch: " + model);
578
+ }
579
+ const { channels, labels } = convert[model];
580
+ delete convert[model].channels;
581
+ delete convert[model].labels;
582
+ Object.defineProperty(convert[model], "channels", { value: channels });
583
+ Object.defineProperty(convert[model], "labels", { value: labels });
584
+ }
585
+ convert.rgb.hsl = function(rgb) {
586
+ const r = rgb[0] / 255;
587
+ const g = rgb[1] / 255;
588
+ const b = rgb[2] / 255;
589
+ const min = Math.min(r, g, b);
590
+ const max = Math.max(r, g, b);
591
+ const delta = max - min;
592
+ let h;
593
+ let s;
594
+ if (max === min) {
595
+ h = 0;
596
+ } else if (r === max) {
597
+ h = (g - b) / delta;
598
+ } else if (g === max) {
599
+ h = 2 + (b - r) / delta;
600
+ } else if (b === max) {
601
+ h = 4 + (r - g) / delta;
602
+ }
603
+ h = Math.min(h * 60, 360);
604
+ if (h < 0) {
605
+ h += 360;
606
+ }
607
+ const l = (min + max) / 2;
608
+ if (max === min) {
609
+ s = 0;
610
+ } else if (l <= 0.5) {
611
+ s = delta / (max + min);
612
+ } else {
613
+ s = delta / (2 - max - min);
614
+ }
615
+ return [h, s * 100, l * 100];
616
+ };
617
+ convert.rgb.hsv = function(rgb) {
618
+ let rdif;
619
+ let gdif;
620
+ let bdif;
621
+ let h;
622
+ let s;
623
+ const r = rgb[0] / 255;
624
+ const g = rgb[1] / 255;
625
+ const b = rgb[2] / 255;
626
+ const v = Math.max(r, g, b);
627
+ const diff = v - Math.min(r, g, b);
628
+ const diffc = function(c) {
629
+ return (v - c) / 6 / diff + 1 / 2;
630
+ };
631
+ if (diff === 0) {
632
+ h = 0;
633
+ s = 0;
634
+ } else {
635
+ s = diff / v;
636
+ rdif = diffc(r);
637
+ gdif = diffc(g);
638
+ bdif = diffc(b);
639
+ if (r === v) {
640
+ h = bdif - gdif;
641
+ } else if (g === v) {
642
+ h = 1 / 3 + rdif - bdif;
643
+ } else if (b === v) {
644
+ h = 2 / 3 + gdif - rdif;
645
+ }
646
+ if (h < 0) {
647
+ h += 1;
648
+ } else if (h > 1) {
649
+ h -= 1;
650
+ }
651
+ }
652
+ return [
653
+ h * 360,
654
+ s * 100,
655
+ v * 100
656
+ ];
657
+ };
658
+ convert.rgb.hwb = function(rgb) {
659
+ const r = rgb[0];
660
+ const g = rgb[1];
661
+ let b = rgb[2];
662
+ const h = convert.rgb.hsl(rgb)[0];
663
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
664
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
665
+ return [h, w * 100, b * 100];
666
+ };
667
+ convert.rgb.cmyk = function(rgb) {
668
+ const r = rgb[0] / 255;
669
+ const g = rgb[1] / 255;
670
+ const b = rgb[2] / 255;
671
+ const k = Math.min(1 - r, 1 - g, 1 - b);
672
+ const c = (1 - r - k) / (1 - k) || 0;
673
+ const m = (1 - g - k) / (1 - k) || 0;
674
+ const y = (1 - b - k) / (1 - k) || 0;
675
+ return [c * 100, m * 100, y * 100, k * 100];
676
+ };
677
+ function comparativeDistance(x, y) {
678
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
679
+ }
680
+ convert.rgb.keyword = function(rgb) {
681
+ const reversed = reverseKeywords[rgb];
682
+ if (reversed) {
683
+ return reversed;
684
+ }
685
+ let currentClosestDistance = Infinity;
686
+ let currentClosestKeyword;
687
+ for (const keyword of Object.keys(cssKeywords)) {
688
+ const value = cssKeywords[keyword];
689
+ const distance = comparativeDistance(rgb, value);
690
+ if (distance < currentClosestDistance) {
691
+ currentClosestDistance = distance;
692
+ currentClosestKeyword = keyword;
693
+ }
694
+ }
695
+ return currentClosestKeyword;
696
+ };
697
+ convert.keyword.rgb = function(keyword) {
698
+ return cssKeywords[keyword];
699
+ };
700
+ convert.rgb.xyz = function(rgb) {
701
+ let r = rgb[0] / 255;
702
+ let g = rgb[1] / 255;
703
+ let b = rgb[2] / 255;
704
+ r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
705
+ g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
706
+ b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
707
+ const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
708
+ const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
709
+ const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
710
+ return [x * 100, y * 100, z * 100];
711
+ };
712
+ convert.rgb.lab = function(rgb) {
713
+ const xyz = convert.rgb.xyz(rgb);
714
+ let x = xyz[0];
715
+ let y = xyz[1];
716
+ let z = xyz[2];
717
+ x /= 95.047;
718
+ y /= 100;
719
+ z /= 108.883;
720
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
721
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
722
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
723
+ const l = 116 * y - 16;
724
+ const a = 500 * (x - y);
725
+ const b = 200 * (y - z);
726
+ return [l, a, b];
727
+ };
728
+ convert.hsl.rgb = function(hsl) {
729
+ const h = hsl[0] / 360;
730
+ const s = hsl[1] / 100;
731
+ const l = hsl[2] / 100;
732
+ let t2;
733
+ let t3;
734
+ let val;
735
+ if (s === 0) {
736
+ val = l * 255;
737
+ return [val, val, val];
738
+ }
739
+ if (l < 0.5) {
740
+ t2 = l * (1 + s);
741
+ } else {
742
+ t2 = l + s - l * s;
743
+ }
744
+ const t1 = 2 * l - t2;
745
+ const rgb = [0, 0, 0];
746
+ for (let i = 0; i < 3; i++) {
747
+ t3 = h + 1 / 3 * -(i - 1);
748
+ if (t3 < 0) {
749
+ t3++;
750
+ }
751
+ if (t3 > 1) {
752
+ t3--;
753
+ }
754
+ if (6 * t3 < 1) {
755
+ val = t1 + (t2 - t1) * 6 * t3;
756
+ } else if (2 * t3 < 1) {
757
+ val = t2;
758
+ } else if (3 * t3 < 2) {
759
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
760
+ } else {
761
+ val = t1;
762
+ }
763
+ rgb[i] = val * 255;
764
+ }
765
+ return rgb;
766
+ };
767
+ convert.hsl.hsv = function(hsl) {
768
+ const h = hsl[0];
769
+ let s = hsl[1] / 100;
770
+ let l = hsl[2] / 100;
771
+ let smin = s;
772
+ const lmin = Math.max(l, 0.01);
773
+ l *= 2;
774
+ s *= l <= 1 ? l : 2 - l;
775
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
776
+ const v = (l + s) / 2;
777
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
778
+ return [h, sv * 100, v * 100];
779
+ };
780
+ convert.hsv.rgb = function(hsv) {
781
+ const h = hsv[0] / 60;
782
+ const s = hsv[1] / 100;
783
+ let v = hsv[2] / 100;
784
+ const hi = Math.floor(h) % 6;
785
+ const f = h - Math.floor(h);
786
+ const p = 255 * v * (1 - s);
787
+ const q = 255 * v * (1 - s * f);
788
+ const t = 255 * v * (1 - s * (1 - f));
789
+ v *= 255;
790
+ switch (hi) {
791
+ case 0:
792
+ return [v, t, p];
793
+ case 1:
794
+ return [q, v, p];
795
+ case 2:
796
+ return [p, v, t];
797
+ case 3:
798
+ return [p, q, v];
799
+ case 4:
800
+ return [t, p, v];
801
+ case 5:
802
+ return [v, p, q];
803
+ }
804
+ };
805
+ convert.hsv.hsl = function(hsv) {
806
+ const h = hsv[0];
807
+ const s = hsv[1] / 100;
808
+ const v = hsv[2] / 100;
809
+ const vmin = Math.max(v, 0.01);
810
+ let sl;
811
+ let l;
812
+ l = (2 - s) * v;
813
+ const lmin = (2 - s) * vmin;
814
+ sl = s * vmin;
815
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
816
+ sl = sl || 0;
817
+ l /= 2;
818
+ return [h, sl * 100, l * 100];
819
+ };
820
+ convert.hwb.rgb = function(hwb) {
821
+ const h = hwb[0] / 360;
822
+ let wh = hwb[1] / 100;
823
+ let bl = hwb[2] / 100;
824
+ const ratio = wh + bl;
825
+ let f;
826
+ if (ratio > 1) {
827
+ wh /= ratio;
828
+ bl /= ratio;
829
+ }
830
+ const i = Math.floor(6 * h);
831
+ const v = 1 - bl;
832
+ f = 6 * h - i;
833
+ if ((i & 1) !== 0) {
834
+ f = 1 - f;
835
+ }
836
+ const n = wh + f * (v - wh);
837
+ let r;
838
+ let g;
839
+ let b;
840
+ switch (i) {
841
+ default:
842
+ case 6:
843
+ case 0:
844
+ r = v;
845
+ g = n;
846
+ b = wh;
847
+ break;
848
+ case 1:
849
+ r = n;
850
+ g = v;
851
+ b = wh;
852
+ break;
853
+ case 2:
854
+ r = wh;
855
+ g = v;
856
+ b = n;
857
+ break;
858
+ case 3:
859
+ r = wh;
860
+ g = n;
861
+ b = v;
862
+ break;
863
+ case 4:
864
+ r = n;
865
+ g = wh;
866
+ b = v;
867
+ break;
868
+ case 5:
869
+ r = v;
870
+ g = wh;
871
+ b = n;
872
+ break;
873
+ }
874
+ return [r * 255, g * 255, b * 255];
875
+ };
876
+ convert.cmyk.rgb = function(cmyk) {
877
+ const c = cmyk[0] / 100;
878
+ const m = cmyk[1] / 100;
879
+ const y = cmyk[2] / 100;
880
+ const k = cmyk[3] / 100;
881
+ const r = 1 - Math.min(1, c * (1 - k) + k);
882
+ const g = 1 - Math.min(1, m * (1 - k) + k);
883
+ const b = 1 - Math.min(1, y * (1 - k) + k);
884
+ return [r * 255, g * 255, b * 255];
885
+ };
886
+ convert.xyz.rgb = function(xyz) {
887
+ const x = xyz[0] / 100;
888
+ const y = xyz[1] / 100;
889
+ const z = xyz[2] / 100;
890
+ let r;
891
+ let g;
892
+ let b;
893
+ r = x * 3.2406 + y * -1.5372 + z * -0.4986;
894
+ g = x * -0.9689 + y * 1.8758 + z * 0.0415;
895
+ b = x * 0.0557 + y * -0.204 + z * 1.057;
896
+ r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
897
+ g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
898
+ b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
899
+ r = Math.min(Math.max(0, r), 1);
900
+ g = Math.min(Math.max(0, g), 1);
901
+ b = Math.min(Math.max(0, b), 1);
902
+ return [r * 255, g * 255, b * 255];
903
+ };
904
+ convert.xyz.lab = function(xyz) {
905
+ let x = xyz[0];
906
+ let y = xyz[1];
907
+ let z = xyz[2];
908
+ x /= 95.047;
909
+ y /= 100;
910
+ z /= 108.883;
911
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
912
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
913
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
914
+ const l = 116 * y - 16;
915
+ const a = 500 * (x - y);
916
+ const b = 200 * (y - z);
917
+ return [l, a, b];
918
+ };
919
+ convert.lab.xyz = function(lab) {
920
+ const l = lab[0];
921
+ const a = lab[1];
922
+ const b = lab[2];
923
+ let x;
924
+ let y;
925
+ let z;
926
+ y = (l + 16) / 116;
927
+ x = a / 500 + y;
928
+ z = y - b / 200;
929
+ const y2 = y ** 3;
930
+ const x2 = x ** 3;
931
+ const z2 = z ** 3;
932
+ y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
933
+ x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
934
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
935
+ x *= 95.047;
936
+ y *= 100;
937
+ z *= 108.883;
938
+ return [x, y, z];
939
+ };
940
+ convert.lab.lch = function(lab) {
941
+ const l = lab[0];
942
+ const a = lab[1];
943
+ const b = lab[2];
944
+ let h;
945
+ const hr = Math.atan2(b, a);
946
+ h = hr * 360 / 2 / Math.PI;
947
+ if (h < 0) {
948
+ h += 360;
949
+ }
950
+ const c = Math.sqrt(a * a + b * b);
951
+ return [l, c, h];
952
+ };
953
+ convert.lch.lab = function(lch) {
954
+ const l = lch[0];
955
+ const c = lch[1];
956
+ const h = lch[2];
957
+ const hr = h / 360 * 2 * Math.PI;
958
+ const a = c * Math.cos(hr);
959
+ const b = c * Math.sin(hr);
960
+ return [l, a, b];
961
+ };
962
+ convert.rgb.ansi16 = function(args, saturation = null) {
963
+ const [r, g, b] = args;
964
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
965
+ value = Math.round(value / 50);
966
+ if (value === 0) {
967
+ return 30;
968
+ }
969
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
970
+ if (value === 2) {
971
+ ansi += 60;
972
+ }
973
+ return ansi;
974
+ };
975
+ convert.hsv.ansi16 = function(args) {
976
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
977
+ };
978
+ convert.rgb.ansi256 = function(args) {
979
+ const r = args[0];
980
+ const g = args[1];
981
+ const b = args[2];
982
+ if (r === g && g === b) {
983
+ if (r < 8) {
984
+ return 16;
985
+ }
986
+ if (r > 248) {
987
+ return 231;
988
+ }
989
+ return Math.round((r - 8) / 247 * 24) + 232;
990
+ }
991
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
992
+ return ansi;
993
+ };
994
+ convert.ansi16.rgb = function(args) {
995
+ let color = args % 10;
996
+ if (color === 0 || color === 7) {
997
+ if (args > 50) {
998
+ color += 3.5;
999
+ }
1000
+ color = color / 10.5 * 255;
1001
+ return [color, color, color];
1002
+ }
1003
+ const mult = (~~(args > 50) + 1) * 0.5;
1004
+ const r = (color & 1) * mult * 255;
1005
+ const g = (color >> 1 & 1) * mult * 255;
1006
+ const b = (color >> 2 & 1) * mult * 255;
1007
+ return [r, g, b];
1008
+ };
1009
+ convert.ansi256.rgb = function(args) {
1010
+ if (args >= 232) {
1011
+ const c = (args - 232) * 10 + 8;
1012
+ return [c, c, c];
1013
+ }
1014
+ args -= 16;
1015
+ let rem;
1016
+ const r = Math.floor(args / 36) / 5 * 255;
1017
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1018
+ const b = rem % 6 / 5 * 255;
1019
+ return [r, g, b];
1020
+ };
1021
+ convert.rgb.hex = function(args) {
1022
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
1023
+ const string = integer.toString(16).toUpperCase();
1024
+ return "000000".substring(string.length) + string;
1025
+ };
1026
+ convert.hex.rgb = function(args) {
1027
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1028
+ if (!match) {
1029
+ return [0, 0, 0];
1030
+ }
1031
+ let colorString = match[0];
1032
+ if (match[0].length === 3) {
1033
+ colorString = colorString.split("").map((char) => {
1034
+ return char + char;
1035
+ }).join("");
1036
+ }
1037
+ const integer = parseInt(colorString, 16);
1038
+ const r = integer >> 16 & 255;
1039
+ const g = integer >> 8 & 255;
1040
+ const b = integer & 255;
1041
+ return [r, g, b];
1042
+ };
1043
+ convert.rgb.hcg = function(rgb) {
1044
+ const r = rgb[0] / 255;
1045
+ const g = rgb[1] / 255;
1046
+ const b = rgb[2] / 255;
1047
+ const max = Math.max(Math.max(r, g), b);
1048
+ const min = Math.min(Math.min(r, g), b);
1049
+ const chroma = max - min;
1050
+ let grayscale;
1051
+ let hue;
1052
+ if (chroma < 1) {
1053
+ grayscale = min / (1 - chroma);
1054
+ } else {
1055
+ grayscale = 0;
1056
+ }
1057
+ if (chroma <= 0) {
1058
+ hue = 0;
1059
+ } else if (max === r) {
1060
+ hue = (g - b) / chroma % 6;
1061
+ } else if (max === g) {
1062
+ hue = 2 + (b - r) / chroma;
1063
+ } else {
1064
+ hue = 4 + (r - g) / chroma;
1065
+ }
1066
+ hue /= 6;
1067
+ hue %= 1;
1068
+ return [hue * 360, chroma * 100, grayscale * 100];
1069
+ };
1070
+ convert.hsl.hcg = function(hsl) {
1071
+ const s = hsl[1] / 100;
1072
+ const l = hsl[2] / 100;
1073
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
1074
+ let f = 0;
1075
+ if (c < 1) {
1076
+ f = (l - 0.5 * c) / (1 - c);
1077
+ }
1078
+ return [hsl[0], c * 100, f * 100];
1079
+ };
1080
+ convert.hsv.hcg = function(hsv) {
1081
+ const s = hsv[1] / 100;
1082
+ const v = hsv[2] / 100;
1083
+ const c = s * v;
1084
+ let f = 0;
1085
+ if (c < 1) {
1086
+ f = (v - c) / (1 - c);
1087
+ }
1088
+ return [hsv[0], c * 100, f * 100];
1089
+ };
1090
+ convert.hcg.rgb = function(hcg) {
1091
+ const h = hcg[0] / 360;
1092
+ const c = hcg[1] / 100;
1093
+ const g = hcg[2] / 100;
1094
+ if (c === 0) {
1095
+ return [g * 255, g * 255, g * 255];
1096
+ }
1097
+ const pure = [0, 0, 0];
1098
+ const hi = h % 1 * 6;
1099
+ const v = hi % 1;
1100
+ const w = 1 - v;
1101
+ let mg = 0;
1102
+ switch (Math.floor(hi)) {
1103
+ case 0:
1104
+ pure[0] = 1;
1105
+ pure[1] = v;
1106
+ pure[2] = 0;
1107
+ break;
1108
+ case 1:
1109
+ pure[0] = w;
1110
+ pure[1] = 1;
1111
+ pure[2] = 0;
1112
+ break;
1113
+ case 2:
1114
+ pure[0] = 0;
1115
+ pure[1] = 1;
1116
+ pure[2] = v;
1117
+ break;
1118
+ case 3:
1119
+ pure[0] = 0;
1120
+ pure[1] = w;
1121
+ pure[2] = 1;
1122
+ break;
1123
+ case 4:
1124
+ pure[0] = v;
1125
+ pure[1] = 0;
1126
+ pure[2] = 1;
1127
+ break;
1128
+ default:
1129
+ pure[0] = 1;
1130
+ pure[1] = 0;
1131
+ pure[2] = w;
1132
+ }
1133
+ mg = (1 - c) * g;
1134
+ return [
1135
+ (c * pure[0] + mg) * 255,
1136
+ (c * pure[1] + mg) * 255,
1137
+ (c * pure[2] + mg) * 255
1138
+ ];
1139
+ };
1140
+ convert.hcg.hsv = function(hcg) {
1141
+ const c = hcg[1] / 100;
1142
+ const g = hcg[2] / 100;
1143
+ const v = c + g * (1 - c);
1144
+ let f = 0;
1145
+ if (v > 0) {
1146
+ f = c / v;
1147
+ }
1148
+ return [hcg[0], f * 100, v * 100];
1149
+ };
1150
+ convert.hcg.hsl = function(hcg) {
1151
+ const c = hcg[1] / 100;
1152
+ const g = hcg[2] / 100;
1153
+ const l = g * (1 - c) + 0.5 * c;
1154
+ let s = 0;
1155
+ if (l > 0 && l < 0.5) {
1156
+ s = c / (2 * l);
1157
+ } else if (l >= 0.5 && l < 1) {
1158
+ s = c / (2 * (1 - l));
1159
+ }
1160
+ return [hcg[0], s * 100, l * 100];
1161
+ };
1162
+ convert.hcg.hwb = function(hcg) {
1163
+ const c = hcg[1] / 100;
1164
+ const g = hcg[2] / 100;
1165
+ const v = c + g * (1 - c);
1166
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
1167
+ };
1168
+ convert.hwb.hcg = function(hwb) {
1169
+ const w = hwb[1] / 100;
1170
+ const b = hwb[2] / 100;
1171
+ const v = 1 - b;
1172
+ const c = v - w;
1173
+ let g = 0;
1174
+ if (c < 1) {
1175
+ g = (v - c) / (1 - c);
1176
+ }
1177
+ return [hwb[0], c * 100, g * 100];
1178
+ };
1179
+ convert.apple.rgb = function(apple) {
1180
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
1181
+ };
1182
+ convert.rgb.apple = function(rgb) {
1183
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
1184
+ };
1185
+ convert.gray.rgb = function(args) {
1186
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1187
+ };
1188
+ convert.gray.hsl = function(args) {
1189
+ return [0, 0, args[0]];
1190
+ };
1191
+ convert.gray.hsv = convert.gray.hsl;
1192
+ convert.gray.hwb = function(gray) {
1193
+ return [0, 100, gray[0]];
1194
+ };
1195
+ convert.gray.cmyk = function(gray) {
1196
+ return [0, 0, 0, gray[0]];
1197
+ };
1198
+ convert.gray.lab = function(gray) {
1199
+ return [gray[0], 0, 0];
1200
+ };
1201
+ convert.gray.hex = function(gray) {
1202
+ const val = Math.round(gray[0] / 100 * 255) & 255;
1203
+ const integer = (val << 16) + (val << 8) + val;
1204
+ const string = integer.toString(16).toUpperCase();
1205
+ return "000000".substring(string.length) + string;
1206
+ };
1207
+ convert.rgb.gray = function(rgb) {
1208
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1209
+ return [val / 255 * 100];
1210
+ };
1211
+ return conversions$1;
1212
+ }
1213
+ var route$1;
1214
+ var hasRequiredRoute$1;
1215
+ function requireRoute$1() {
1216
+ if (hasRequiredRoute$1) return route$1;
1217
+ hasRequiredRoute$1 = 1;
1218
+ const conversions2 = requireConversions$1();
1219
+ function buildGraph() {
1220
+ const graph = {};
1221
+ const models = Object.keys(conversions2);
1222
+ for (let len = models.length, i = 0; i < len; i++) {
1223
+ graph[models[i]] = {
1224
+ // http://jsperf.com/1-vs-infinity
1225
+ // micro-opt, but this is simple.
1226
+ distance: -1,
1227
+ parent: null
1228
+ };
1229
+ }
1230
+ return graph;
1231
+ }
1232
+ function deriveBFS(fromModel) {
1233
+ const graph = buildGraph();
1234
+ const queue = [fromModel];
1235
+ graph[fromModel].distance = 0;
1236
+ while (queue.length) {
1237
+ const current = queue.pop();
1238
+ const adjacents = Object.keys(conversions2[current]);
1239
+ for (let len = adjacents.length, i = 0; i < len; i++) {
1240
+ const adjacent = adjacents[i];
1241
+ const node = graph[adjacent];
1242
+ if (node.distance === -1) {
1243
+ node.distance = graph[current].distance + 1;
1244
+ node.parent = current;
1245
+ queue.unshift(adjacent);
1246
+ }
1247
+ }
1248
+ }
1249
+ return graph;
1250
+ }
1251
+ function link(from, to) {
1252
+ return function(args) {
1253
+ return to(from(args));
1254
+ };
1255
+ }
1256
+ function wrapConversion(toModel, graph) {
1257
+ const path = [graph[toModel].parent, toModel];
1258
+ let fn = conversions2[graph[toModel].parent][toModel];
1259
+ let cur = graph[toModel].parent;
1260
+ while (graph[cur].parent) {
1261
+ path.unshift(graph[cur].parent);
1262
+ fn = link(conversions2[graph[cur].parent][cur], fn);
1263
+ cur = graph[cur].parent;
1264
+ }
1265
+ fn.conversion = path;
1266
+ return fn;
1267
+ }
1268
+ route$1 = function(fromModel) {
1269
+ const graph = deriveBFS(fromModel);
1270
+ const conversion = {};
1271
+ const models = Object.keys(graph);
1272
+ for (let len = models.length, i = 0; i < len; i++) {
1273
+ const toModel = models[i];
1274
+ const node = graph[toModel];
1275
+ if (node.parent === null) {
1276
+ continue;
1277
+ }
1278
+ conversion[toModel] = wrapConversion(toModel, graph);
1279
+ }
1280
+ return conversion;
1281
+ };
1282
+ return route$1;
1283
+ }
1284
+ var colorConvert$1;
1285
+ var hasRequiredColorConvert$1;
1286
+ function requireColorConvert$1() {
1287
+ if (hasRequiredColorConvert$1) return colorConvert$1;
1288
+ hasRequiredColorConvert$1 = 1;
1289
+ const conversions2 = requireConversions$1();
1290
+ const route2 = requireRoute$1();
1291
+ const convert = {};
1292
+ const models = Object.keys(conversions2);
1293
+ function wrapRaw(fn) {
1294
+ const wrappedFn = function(...args) {
1295
+ const arg0 = args[0];
1296
+ if (arg0 === void 0 || arg0 === null) {
1297
+ return arg0;
1298
+ }
1299
+ if (arg0.length > 1) {
1300
+ args = arg0;
1301
+ }
1302
+ return fn(args);
1303
+ };
1304
+ if ("conversion" in fn) {
1305
+ wrappedFn.conversion = fn.conversion;
1306
+ }
1307
+ return wrappedFn;
1308
+ }
1309
+ function wrapRounded(fn) {
1310
+ const wrappedFn = function(...args) {
1311
+ const arg0 = args[0];
1312
+ if (arg0 === void 0 || arg0 === null) {
1313
+ return arg0;
1314
+ }
1315
+ if (arg0.length > 1) {
1316
+ args = arg0;
1317
+ }
1318
+ const result = fn(args);
1319
+ if (typeof result === "object") {
1320
+ for (let len = result.length, i = 0; i < len; i++) {
1321
+ result[i] = Math.round(result[i]);
1322
+ }
1323
+ }
1324
+ return result;
1325
+ };
1326
+ if ("conversion" in fn) {
1327
+ wrappedFn.conversion = fn.conversion;
1328
+ }
1329
+ return wrappedFn;
1330
+ }
1331
+ models.forEach((fromModel) => {
1332
+ convert[fromModel] = {};
1333
+ Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
1334
+ Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
1335
+ const routes = route2(fromModel);
1336
+ const routeModels = Object.keys(routes);
1337
+ routeModels.forEach((toModel) => {
1338
+ const fn = routes[toModel];
1339
+ convert[fromModel][toModel] = wrapRounded(fn);
1340
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1341
+ });
1342
+ });
1343
+ colorConvert$1 = convert;
1344
+ return colorConvert$1;
1345
+ }
1346
+ ansiStyles$1.exports;
1347
+ var hasRequiredAnsiStyles$1;
1348
+ function requireAnsiStyles$1() {
1349
+ if (hasRequiredAnsiStyles$1) return ansiStyles$1.exports;
1350
+ hasRequiredAnsiStyles$1 = 1;
1351
+ (function(module2) {
1352
+ const wrapAnsi16 = (fn, offset) => (...args) => {
1353
+ const code = fn(...args);
1354
+ return `\x1B[${code + offset}m`;
1355
+ };
1356
+ const wrapAnsi256 = (fn, offset) => (...args) => {
1357
+ const code = fn(...args);
1358
+ return `\x1B[${38 + offset};5;${code}m`;
1359
+ };
1360
+ const wrapAnsi16m = (fn, offset) => (...args) => {
1361
+ const rgb = fn(...args);
1362
+ return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1363
+ };
1364
+ const ansi2ansi = (n) => n;
1365
+ const rgb2rgb = (r, g, b) => [r, g, b];
1366
+ const setLazyProperty = (object, property, get) => {
1367
+ Object.defineProperty(object, property, {
1368
+ get: () => {
1369
+ const value = get();
1370
+ Object.defineProperty(object, property, {
1371
+ value,
1372
+ enumerable: true,
1373
+ configurable: true
1374
+ });
1375
+ return value;
1376
+ },
1377
+ enumerable: true,
1378
+ configurable: true
1379
+ });
1380
+ };
1381
+ let colorConvert2;
1382
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1383
+ if (colorConvert2 === void 0) {
1384
+ colorConvert2 = requireColorConvert$1();
1385
+ }
1386
+ const offset = isBackground ? 10 : 0;
1387
+ const styles = {};
1388
+ for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
1389
+ const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1390
+ if (sourceSpace === targetSpace) {
1391
+ styles[name] = wrap(identity, offset);
1392
+ } else if (typeof suite === "object") {
1393
+ styles[name] = wrap(suite[targetSpace], offset);
1394
+ }
1395
+ }
1396
+ return styles;
1397
+ };
1398
+ function assembleStyles() {
1399
+ const codes = /* @__PURE__ */ new Map();
1400
+ const styles = {
1401
+ modifier: {
1402
+ reset: [0, 0],
1403
+ // 21 isn't widely supported and 22 does the same thing
1404
+ bold: [1, 22],
1405
+ dim: [2, 22],
1406
+ italic: [3, 23],
1407
+ underline: [4, 24],
1408
+ inverse: [7, 27],
1409
+ hidden: [8, 28],
1410
+ strikethrough: [9, 29]
1411
+ },
1412
+ color: {
1413
+ black: [30, 39],
1414
+ red: [31, 39],
1415
+ green: [32, 39],
1416
+ yellow: [33, 39],
1417
+ blue: [34, 39],
1418
+ magenta: [35, 39],
1419
+ cyan: [36, 39],
1420
+ white: [37, 39],
1421
+ // Bright color
1422
+ blackBright: [90, 39],
1423
+ redBright: [91, 39],
1424
+ greenBright: [92, 39],
1425
+ yellowBright: [93, 39],
1426
+ blueBright: [94, 39],
1427
+ magentaBright: [95, 39],
1428
+ cyanBright: [96, 39],
1429
+ whiteBright: [97, 39]
1430
+ },
1431
+ bgColor: {
1432
+ bgBlack: [40, 49],
1433
+ bgRed: [41, 49],
1434
+ bgGreen: [42, 49],
1435
+ bgYellow: [43, 49],
1436
+ bgBlue: [44, 49],
1437
+ bgMagenta: [45, 49],
1438
+ bgCyan: [46, 49],
1439
+ bgWhite: [47, 49],
1440
+ // Bright color
1441
+ bgBlackBright: [100, 49],
1442
+ bgRedBright: [101, 49],
1443
+ bgGreenBright: [102, 49],
1444
+ bgYellowBright: [103, 49],
1445
+ bgBlueBright: [104, 49],
1446
+ bgMagentaBright: [105, 49],
1447
+ bgCyanBright: [106, 49],
1448
+ bgWhiteBright: [107, 49]
1449
+ }
1450
+ };
1451
+ styles.color.gray = styles.color.blackBright;
1452
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1453
+ styles.color.grey = styles.color.blackBright;
1454
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1455
+ for (const [groupName, group] of Object.entries(styles)) {
1456
+ for (const [styleName, style] of Object.entries(group)) {
1457
+ styles[styleName] = {
1458
+ open: `\x1B[${style[0]}m`,
1459
+ close: `\x1B[${style[1]}m`
1460
+ };
1461
+ group[styleName] = styles[styleName];
1462
+ codes.set(style[0], style[1]);
1463
+ }
1464
+ Object.defineProperty(styles, groupName, {
1465
+ value: group,
1466
+ enumerable: false
1467
+ });
1468
+ }
1469
+ Object.defineProperty(styles, "codes", {
1470
+ value: codes,
1471
+ enumerable: false
1472
+ });
1473
+ styles.color.close = "\x1B[39m";
1474
+ styles.bgColor.close = "\x1B[49m";
1475
+ setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1476
+ setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1477
+ setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1478
+ setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1479
+ setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1480
+ setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1481
+ return styles;
1482
+ }
1483
+ Object.defineProperty(module2, "exports", {
1484
+ enumerable: true,
1485
+ get: assembleStyles
1486
+ });
1487
+ })(ansiStyles$1);
1488
+ return ansiStyles$1.exports;
1489
+ }
1490
+ var browser$1;
1491
+ var hasRequiredBrowser$1;
1492
+ function requireBrowser$1() {
1493
+ if (hasRequiredBrowser$1) return browser$1;
1494
+ hasRequiredBrowser$1 = 1;
1495
+ browser$1 = {
1496
+ stdout: false,
1497
+ stderr: false
1498
+ };
1499
+ return browser$1;
1500
+ }
1501
+ var util$1;
1502
+ var hasRequiredUtil$1;
1503
+ function requireUtil$1() {
1504
+ if (hasRequiredUtil$1) return util$1;
1505
+ hasRequiredUtil$1 = 1;
1506
+ const stringReplaceAll = (string, substring, replacer) => {
1507
+ let index = string.indexOf(substring);
1508
+ if (index === -1) {
1509
+ return string;
1510
+ }
1511
+ const substringLength = substring.length;
1512
+ let endIndex = 0;
1513
+ let returnValue = "";
1514
+ do {
1515
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1516
+ endIndex = index + substringLength;
1517
+ index = string.indexOf(substring, endIndex);
1518
+ } while (index !== -1);
1519
+ returnValue += string.substr(endIndex);
1520
+ return returnValue;
1521
+ };
1522
+ const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
1523
+ let endIndex = 0;
1524
+ let returnValue = "";
1525
+ do {
1526
+ const gotCR = string[index - 1] === "\r";
1527
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1528
+ endIndex = index + 1;
1529
+ index = string.indexOf("\n", endIndex);
1530
+ } while (index !== -1);
1531
+ returnValue += string.substr(endIndex);
1532
+ return returnValue;
1533
+ };
1534
+ util$1 = {
1535
+ stringReplaceAll,
1536
+ stringEncaseCRLFWithFirstIndex
1537
+ };
1538
+ return util$1;
1539
+ }
1540
+ var templates$1;
1541
+ var hasRequiredTemplates$1;
1542
+ function requireTemplates$1() {
1543
+ if (hasRequiredTemplates$1) return templates$1;
1544
+ hasRequiredTemplates$1 = 1;
1545
+ const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1546
+ const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1547
+ const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1548
+ const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1549
+ const ESCAPES = /* @__PURE__ */ new Map([
1550
+ ["n", "\n"],
1551
+ ["r", "\r"],
1552
+ ["t", " "],
1553
+ ["b", "\b"],
1554
+ ["f", "\f"],
1555
+ ["v", "\v"],
1556
+ ["0", "\0"],
1557
+ ["\\", "\\"],
1558
+ ["e", "\x1B"],
1559
+ ["a", "\x07"]
1560
+ ]);
1561
+ function unescape(c) {
1562
+ const u = c[0] === "u";
1563
+ const bracket = c[1] === "{";
1564
+ if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
1565
+ return String.fromCharCode(parseInt(c.slice(1), 16));
1566
+ }
1567
+ if (u && bracket) {
1568
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1569
+ }
1570
+ return ESCAPES.get(c) || c;
1571
+ }
1572
+ function parseArguments(name, arguments_) {
1573
+ const results = [];
1574
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
1575
+ let matches;
1576
+ for (const chunk of chunks) {
1577
+ const number = Number(chunk);
1578
+ if (!Number.isNaN(number)) {
1579
+ results.push(number);
1580
+ } else if (matches = chunk.match(STRING_REGEX)) {
1581
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
1582
+ } else {
1583
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1584
+ }
1585
+ }
1586
+ return results;
1587
+ }
1588
+ function parseStyle(style) {
1589
+ STYLE_REGEX.lastIndex = 0;
1590
+ const results = [];
1591
+ let matches;
1592
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
1593
+ const name = matches[1];
1594
+ if (matches[2]) {
1595
+ const args = parseArguments(name, matches[2]);
1596
+ results.push([name].concat(args));
1597
+ } else {
1598
+ results.push([name]);
1599
+ }
1600
+ }
1601
+ return results;
1602
+ }
1603
+ function buildStyle(chalk2, styles) {
1604
+ const enabled = {};
1605
+ for (const layer of styles) {
1606
+ for (const style of layer.styles) {
1607
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
1608
+ }
1609
+ }
1610
+ let current = chalk2;
1611
+ for (const [styleName, styles2] of Object.entries(enabled)) {
1612
+ if (!Array.isArray(styles2)) {
1613
+ continue;
1614
+ }
1615
+ if (!(styleName in current)) {
1616
+ throw new Error(`Unknown Chalk style: ${styleName}`);
1617
+ }
1618
+ current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
1619
+ }
1620
+ return current;
1621
+ }
1622
+ templates$1 = (chalk2, temporary) => {
1623
+ const styles = [];
1624
+ const chunks = [];
1625
+ let chunk = [];
1626
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1627
+ if (escapeCharacter) {
1628
+ chunk.push(unescape(escapeCharacter));
1629
+ } else if (style) {
1630
+ const string = chunk.join("");
1631
+ chunk = [];
1632
+ chunks.push(styles.length === 0 ? string : buildStyle(chalk2, styles)(string));
1633
+ styles.push({ inverse, styles: parseStyle(style) });
1634
+ } else if (close) {
1635
+ if (styles.length === 0) {
1636
+ throw new Error("Found extraneous } in Chalk template literal");
1637
+ }
1638
+ chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
1639
+ chunk = [];
1640
+ styles.pop();
1641
+ } else {
1642
+ chunk.push(character);
1643
+ }
1644
+ });
1645
+ chunks.push(chunk.join(""));
1646
+ if (styles.length > 0) {
1647
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
1648
+ throw new Error(errMessage);
1649
+ }
1650
+ return chunks.join("");
1651
+ };
1652
+ return templates$1;
1653
+ }
1654
+ var source$1;
1655
+ var hasRequiredSource$1;
1656
+ function requireSource$1() {
1657
+ if (hasRequiredSource$1) return source$1;
1658
+ hasRequiredSource$1 = 1;
1659
+ const ansiStyles2 = requireAnsiStyles$1();
1660
+ const { stdout: stdoutColor, stderr: stderrColor } = requireBrowser$1();
1661
+ const {
1662
+ stringReplaceAll,
1663
+ stringEncaseCRLFWithFirstIndex
1664
+ } = requireUtil$1();
1665
+ const { isArray } = Array;
1666
+ const levelMapping = [
1667
+ "ansi",
1668
+ "ansi",
1669
+ "ansi256",
1670
+ "ansi16m"
1671
+ ];
1672
+ const styles = /* @__PURE__ */ Object.create(null);
1673
+ const applyOptions = (object, options = {}) => {
1674
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1675
+ throw new Error("The `level` option should be an integer from 0 to 3");
1676
+ }
1677
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
1678
+ object.level = options.level === void 0 ? colorLevel : options.level;
1679
+ };
1680
+ class ChalkClass {
1681
+ constructor(options) {
1682
+ return chalkFactory(options);
1683
+ }
1684
+ }
1685
+ const chalkFactory = (options) => {
1686
+ const chalk3 = {};
1687
+ applyOptions(chalk3, options);
1688
+ chalk3.template = (...arguments_) => chalkTag(chalk3.template, ...arguments_);
1689
+ Object.setPrototypeOf(chalk3, Chalk.prototype);
1690
+ Object.setPrototypeOf(chalk3.template, chalk3);
1691
+ chalk3.template.constructor = () => {
1692
+ throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1693
+ };
1694
+ chalk3.template.Instance = ChalkClass;
1695
+ return chalk3.template;
1696
+ };
1697
+ function Chalk(options) {
1698
+ return chalkFactory(options);
1699
+ }
1700
+ for (const [styleName, style] of Object.entries(ansiStyles2)) {
1701
+ styles[styleName] = {
1702
+ get() {
1703
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1704
+ Object.defineProperty(this, styleName, { value: builder });
1705
+ return builder;
1706
+ }
1707
+ };
1708
+ }
1709
+ styles.visible = {
1710
+ get() {
1711
+ const builder = createBuilder(this, this._styler, true);
1712
+ Object.defineProperty(this, "visible", { value: builder });
1713
+ return builder;
1714
+ }
1715
+ };
1716
+ const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1717
+ for (const model of usedModels) {
1718
+ styles[model] = {
1719
+ get() {
1720
+ const { level } = this;
1721
+ return function(...arguments_) {
1722
+ const styler = createStyler(ansiStyles2.color[levelMapping[level]][model](...arguments_), ansiStyles2.color.close, this._styler);
1723
+ return createBuilder(this, styler, this._isEmpty);
1724
+ };
1725
+ }
1726
+ };
1727
+ }
1728
+ for (const model of usedModels) {
1729
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1730
+ styles[bgModel] = {
1731
+ get() {
1732
+ const { level } = this;
1733
+ return function(...arguments_) {
1734
+ const styler = createStyler(ansiStyles2.bgColor[levelMapping[level]][model](...arguments_), ansiStyles2.bgColor.close, this._styler);
1735
+ return createBuilder(this, styler, this._isEmpty);
1736
+ };
1737
+ }
1738
+ };
1739
+ }
1740
+ const proto = Object.defineProperties(() => {
1741
+ }, {
1742
+ ...styles,
1743
+ level: {
1744
+ enumerable: true,
1745
+ get() {
1746
+ return this._generator.level;
1747
+ },
1748
+ set(level) {
1749
+ this._generator.level = level;
1750
+ }
1751
+ }
1752
+ });
1753
+ const createStyler = (open, close, parent) => {
1754
+ let openAll;
1755
+ let closeAll;
1756
+ if (parent === void 0) {
1757
+ openAll = open;
1758
+ closeAll = close;
1759
+ } else {
1760
+ openAll = parent.openAll + open;
1761
+ closeAll = close + parent.closeAll;
1762
+ }
1763
+ return {
1764
+ open,
1765
+ close,
1766
+ openAll,
1767
+ closeAll,
1768
+ parent
1769
+ };
1770
+ };
1771
+ const createBuilder = (self, _styler, _isEmpty) => {
1772
+ const builder = (...arguments_) => {
1773
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1774
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
1775
+ }
1776
+ return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1777
+ };
1778
+ Object.setPrototypeOf(builder, proto);
1779
+ builder._generator = self;
1780
+ builder._styler = _styler;
1781
+ builder._isEmpty = _isEmpty;
1782
+ return builder;
1783
+ };
1784
+ const applyStyle = (self, string) => {
1785
+ if (self.level <= 0 || !string) {
1786
+ return self._isEmpty ? "" : string;
1787
+ }
1788
+ let styler = self._styler;
1789
+ if (styler === void 0) {
1790
+ return string;
1791
+ }
1792
+ const { openAll, closeAll } = styler;
1793
+ if (string.indexOf("\x1B") !== -1) {
1794
+ while (styler !== void 0) {
1795
+ string = stringReplaceAll(string, styler.close, styler.open);
1796
+ styler = styler.parent;
1797
+ }
1798
+ }
1799
+ const lfIndex = string.indexOf("\n");
1800
+ if (lfIndex !== -1) {
1801
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1802
+ }
1803
+ return openAll + string + closeAll;
1804
+ };
1805
+ let template;
1806
+ const chalkTag = (chalk3, ...strings) => {
1807
+ const [firstString] = strings;
1808
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
1809
+ return strings.join(" ");
1810
+ }
1811
+ const arguments_ = strings.slice(1);
1812
+ const parts = [firstString.raw[0]];
1813
+ for (let i = 1; i < firstString.length; i++) {
1814
+ parts.push(
1815
+ String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
1816
+ String(firstString.raw[i])
1817
+ );
1818
+ }
1819
+ if (template === void 0) {
1820
+ template = requireTemplates$1();
1821
+ }
1822
+ return template(chalk3, parts.join(""));
1823
+ };
1824
+ Object.defineProperties(Chalk.prototype, styles);
1825
+ const chalk2 = Chalk();
1826
+ chalk2.supportsColor = stdoutColor;
1827
+ chalk2.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1828
+ chalk2.stderr.supportsColor = stderrColor;
1829
+ source$1 = chalk2;
1830
+ return source$1;
1831
+ }
1832
+ requireSource$1();
1833
+ const envOptions = {};
1834
+ function SetupConfig(envOptions2, logger) {
1835
+ const envfile = process.env.STSENVFILE === void 0 ? "/.env" : process.env.STSENVFILE;
1836
+ dotenv.config({ path: envfile });
1837
+ const defconfig = {
1838
+ // Node runtime environment
1839
+ isProduction: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "production" ? true : false,
1840
+ isTest: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "test" ? true : false,
1841
+ dbuser: process.env.DB_USER === void 0 ? "postgres" : process.env.DB_USER,
1842
+ dbpassword: process.env.DB_PASSWORD === void 0 ? "postgres" : process.env.DB_PASSWORD,
1843
+ dbpasswordfile: process.env.DB_PASSWORD_FILE,
1844
+ dbhost: process.env.DB_HOST === void 0 ? "localhost:5432" : process.env.DB_HOST,
1845
+ database: process.env.DB_DATABASE === void 0 ? "stsrestmsdb01" : process.env.DB_DATABASE,
1846
+ databaseUrl: process.env.DATABASE_URL,
1847
+ connectionString: "",
1848
+ defaultDatabaseConnectionString: "",
1849
+ STSServerType: process.env.STS_SERVER_TYPE === void 0 ? "EXPRESS_TLS" : process.env.STS_SERVER_TYPE,
1850
+ logToFile: process.env.LOG_TO_FILE === void 0 ? false : process.env.LOG_TO_FILE === "true" ? true : false,
1851
+ logFilePath: process.env.LOG_FILE_PATH === void 0 ? "/var/lib/sts" : process.env.LOG_FILE_PATH,
1852
+ logFileFormat: process.env.LOG_FILE_FORMAT === void 0 ? "csv" : process.env.LOG_FILE_FORMAT,
1853
+ poolSize: process.env.POOL_SIZE === void 0 ? 500 : parseInt(process.env.POOL_SIZE),
1854
+ useCPUs: process.env.MAX_CPU === void 0 ? -1 : parseFloat(process.env.MAX_CPU),
1855
+ respawnOnFail: process.env.RESPAWN === void 0 ? true : process.env.RESPAWN === "true" ? true : false,
1856
+ defaultDatabaseEntries: process.env.DEFAULT_DB_ENTRIES === void 0 ? 1e4 : parseInt(process.env.DEFAULT_DB_ENTRIES),
1857
+ useRedisDatabaseCache: process.env.USE_REDIS_DATABASE_CACHE === void 0 ? false : process.env.USE_REDIS_DATABASE_CACHE === "true" ? true : false,
1858
+ useSocketIoRedisAdaptor: process.env.USE_SOCKET_IO_REDIS_ADAPTOR === void 0 ? false : process.env.USE_SOCKET_IO_REDIS_ADAPTOR === "true" ? true : false,
1859
+ socketIoRedisAdaptorUrl: process.env.SOCKET_IO_REDIS_ADAPTOR_URL === void 0 ? "redis://localhost:6379" : process.env.SOCKET_IO_REDIS_ADAPTOR_URL,
1860
+ useRedisInstrumentationTransport: process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === void 0 ? false : process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === "true" ? true : false,
1861
+ redisInstrumentationTransportUrl: process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL,
1862
+ redisDatabaseCacheEndFlush: process.env.REDIS_DATABASE_CACHE_END_FLUSH === void 0 ? false : process.env.REDIS_DATABASE_CACHE_END_FLUSH === "true" ? true : false,
1863
+ redisDatabaseCacheUrl: process.env.REDIS_DATABASE_CACHE_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_DATABASE_CACHE_URL,
1864
+ defaultDatabaseMinExtraDataSize: process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE === void 0 ? 0 : parseInt(process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE),
1865
+ defaultDatabaseMaxExtraDataSize: process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE === void 0 ? 2e3 : parseInt(process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE),
1866
+ rest01endpoint: process.env.REST01_ENDPOINT === void 0 ? "https://localhost" : process.env.REST01_ENDPOINT,
1867
+ rest01hostport: process.env.REST01_HOST_PORT === void 0 ? "3003" : process.env.REST01_HOST_PORT,
1868
+ rest01port: process.env.REST01_PORT === void 0 ? "3003" : process.env.REST01_PORT,
1869
+ rest01apiroot: process.env.REST01_APIROOT === void 0 ? "/stsrest01/v1" : process.env.REST01_APIROOT,
1870
+ rest01prometheussupport: process.env.REST01_PROM_SUPPORT === void 0 ? true : process.env.REST01_PROM_SUPPORT === "true" ? true : false,
1871
+ rest01prometheusclusterport: process.env.REST01_PROM_CLUSTER_PORT === void 0 ? "3013" : process.env.REST01_PROM_CLUSTER_PORT,
1872
+ rest01servicename: process.env.REST01_SERVICE_NAME === void 0 ? "STSRest01" : process.env.REST01_SERVICE_NAME,
1873
+ rest01serviceversion: process.env.REST01_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.REST01_SERVICE_VERSION,
1874
+ stsfhirendpoint: process.env.STSFHIR_ENDPOINT === void 0 ? "https://localhost" : process.env.STSFHIR_ENDPOINT,
1875
+ stsfhirhostport: process.env.STSFHIR_HOST_PORT === void 0 ? "3005" : process.env.STSFHIR_HOST_PORT,
1876
+ stsfhirport: process.env.STSFHIR_PORT === void 0 ? "3005" : process.env.STSFHIR_PORT,
1877
+ stsfhirapiroot: process.env.STSFHIR_APIROOT === void 0 ? "/stsfhir/r5" : process.env.STSFHIR_APIROOT,
1878
+ stsfhirprometheussupport: process.env.STSFHIR_PROM_SUPPORT === void 0 ? true : process.env.STSFHIR_PROM_SUPPORT === "true" ? true : false,
1879
+ stsfhirprometheusclusterport: process.env.STSFHIR_PROM_CLUSTER_PORT === void 0 ? "3015" : process.env.STSFHIR_PROM_CLUSTER_PORT,
1880
+ stsfhirservicename: process.env.STSFHIR_SERVICE_NAME === void 0 ? "STSFHIR" : process.env.STSFHIR_SERVICE_NAME,
1881
+ stsfhirserviceversion: process.env.STSFHIR_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.STSFHIR_SERVICE_VERSION,
1882
+ ststccendpoint: process.env.STSTCC_ENDPOINT === void 0 ? "https://localhost" : process.env.STSTCC_ENDPOINT,
1883
+ ststcchostport: process.env.STSTCC_HOST_PORT === void 0 ? "3024" : process.env.STSTCC_HOST_PORT,
1884
+ ststccport: process.env.STSTCC_PORT === void 0 ? "3024" : process.env.STSTCC_PORT,
1885
+ ststccapiroot: process.env.STSTCC_APIROOT === void 0 ? "/ststcc/v1" : process.env.STSTCC_APIROOT,
1886
+ ststccprometheussupport: process.env.STSTCC_PROM_SUPPORT === void 0 ? true : process.env.STSTCC_PROM_SUPPORT === "true" ? true : false,
1887
+ ststccprometheusclusterport: process.env.STSTCC_PROM_CLUSTER_PORT === void 0 ? "3025" : process.env.STSTCC_PROM_CLUSTER_PORT,
1888
+ ststccservicename: process.env.STSTCC_SERVICE_NAME === void 0 ? "STSTCC" : process.env.STSTCC_SERVICE_NAME,
1889
+ ststccserviceversion: process.env.STSTCC_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.STSTCC_SERVICE_VERSION,
1890
+ imendpoint: process.env.IM_ENDPOINT === void 0 ? "https://localhost" : process.env.IM_ENDPOINT,
1891
+ imhostport: process.env.IM_HOST_PORT === void 0 ? "3001" : process.env.IM_HOST_PORT,
1892
+ import: process.env.IM_PORT === void 0 ? "3001" : process.env.IM_PORT,
1893
+ imapiroot: process.env.IM_APIROOT === void 0 ? "/stsinstrumentmanager/v1" : process.env.IM_APIROOT,
1894
+ imprometheussupport: process.env.IM_PROM_SUPPORT === void 0 ? true : process.env.IM_PROM_SUPPORT === "true" ? true : false,
1895
+ imprometheusclusterport: process.env.IM_PROM_CLUSTER_PORT === void 0 ? "3011" : process.env.IM_PROM_CLUSTER_PORT,
1896
+ imservicename: process.env.IM_SERVICE_NAME === void 0 ? "STSInstrumentManager" : process.env.IM_SERVICE_NAME,
1897
+ imserviceversion: process.env.IM_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.IM_SERVICE_VERSION,
1898
+ imRedisKeepAliveProcessorUrl: process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL,
1899
+ imRedisMessageProcessorUrl: process.env.IM_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_MESSAGE_PROCESSOR_URL,
1900
+ asendpoint: process.env.AS_ENDPOINT === void 0 ? "https://localhost" : process.env.AS_ENDPOINT,
1901
+ ashostport: process.env.AS_HOST_PORT === void 0 ? "3002" : process.env.AS_HOST_PORT,
1902
+ asport: process.env.AS_PORT === void 0 ? "3002" : process.env.AS_PORT,
1903
+ asapiroot: process.env.AS_API_ROOT === void 0 ? "/stsauth/v1.0" : process.env.AS_API_ROOT,
1904
+ asoauthapiroot: process.env.AS_OAUTH_API_ROOT === void 0 ? "/oauth2/v2.0" : process.env.AS_OAUTH_API_ROOT,
1905
+ asadminapiroot: process.env.AS_ADMIN_API_ROOT === void 0 ? "/admin/v1.0" : process.env.AS_ADMIN_API_ROOT,
1906
+ asprometheussupport: process.env.AS_PROM_SUPPORT === void 0 ? true : process.env.AS_PROM_SUPPORT === "true" ? true : false,
1907
+ asprometheusclusterport: process.env.AS_PROM_CLUSTER_PORT === void 0 ? "3012" : process.env.AS_PROM_CLUSTER_PORT,
1908
+ asservicename: process.env.AS_SERVICE_NAME === void 0 ? "STSAuth" : process.env.AS_SERVICE_NAME,
1909
+ asserviceversion: process.env.AS_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.AS_SERVICE_VERSION,
1910
+ asjwksjsonpath: process.env.AS_JWKS_JSON_PATH === void 0 ? "/.well-known/jwks.json" : process.env.AS_JWKS_JSON_PATH,
1911
+ asjwkskeyrotationtime: process.env.AS_JWKS_KEY_ROTATION_TIME === void 0 ? 86400 : parseInt(process.env.AS_JWKS_KEY_ROTATION_TIME),
1912
+ asjwkskeypurgetimeoffset: process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET === void 0 ? 300 : parseInt(process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET),
1913
+ asjwkskeycount: process.env.AS_JWKS_KEY_COUNT === void 0 ? 4 : parseInt(process.env.AS_JWKS_KEY_COUNT),
1914
+ asaccesstokenexpire: process.env.AS_ACCESS_TOKEN_EXPIRE === void 0 ? 43200 : parseInt(process.env.AS_ACCESS_TOKEN_EXPIRE),
1915
+ authorizeendpoint: process.env.AUTHORIZE_ENDPOINT === void 0 ? "https://localhost" : process.env.AUTHORIZE_ENDPOINT,
1916
+ authorizeport: process.env.AUTHORIZE_PORT === void 0 ? "3010" : process.env.AUTHORIZE_PORT,
1917
+ authorizeapiroot: process.env.AUTHORIZE_API_ROOT === void 0 ? "/stsa" : process.env.AUTHORIZE_API_ROOT,
1918
+ authorizeapi: process.env.AUTHORIZE_API === void 0 ? "/authorize" : process.env.AUTHORIZE_API,
1919
+ brokerendpoint: process.env.BROKER_ENDPOINT === void 0 ? "https://localhost" : process.env.BROKER_ENDPOINT,
1920
+ brokerhostport: process.env.BROKER_HOST_PORT === void 0 ? "3006" : process.env.BROKER_HOST_PORT,
1921
+ brokerport: process.env.BROKER_PORT === void 0 ? "3006" : process.env.BROKER_PORT,
1922
+ brokerapiroot: process.env.BROKER_APIROOT === void 0 ? "/stsbroker/v1.0" : process.env.BROKER_APIROOT,
1923
+ brokerprometheussupport: process.env.BROKER_PROM_SUPPORT === void 0 ? true : process.env.BROKER_PROM_SUPPORT === "true" ? true : false,
1924
+ brokerprometheusclusterport: process.env.BROKER_PROM_CLUSTER_PORT === void 0 ? "3016" : process.env.BROKER_PROM_CLUSTER_PORT,
1925
+ brokerservicename: process.env.BROKER_SERVICE_NAME === void 0 ? "STSBroker" : process.env.BROKER_SERVICE_NAME,
1926
+ brokerserviceversion: process.env.BROKER_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.BROKER_SERVICE_VERSION,
1927
+ trnendpoint: process.env.TRN_ENDPOINT === void 0 ? "https://localhost" : process.env.TRN_ENDPOINT,
1928
+ trnhostport: process.env.TRN_HOST_PORT === void 0 ? "3007" : process.env.TRN_HOST_PORT,
1929
+ trnport: process.env.TRN_PORT === void 0 ? "3007" : process.env.TRN_PORT,
1930
+ trnapiroot: process.env.TRN_APIROOT === void 0 ? "/ststrn/v1.0" : process.env.TRN_APIROOT,
1931
+ trnprometheussupport: process.env.TRN_PROM_SUPPORT === void 0 ? true : process.env.TRN_PROM_SUPPORT === "true" ? true : false,
1932
+ trnprometheusclusterport: process.env.TRN_PROM_CLUSTER_PORT === void 0 ? "3017" : process.env.TRN_PROM_CLUSTER_PORT,
1933
+ trnservicename: process.env.TRN_SERVICE_NAME === void 0 ? "STSTestRunnerNode" : process.env.TRN_SERVICE_NAME,
1934
+ trnserviceversion: process.env.TRN_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.TRN_SERVICE_VERSION,
1935
+ trnautostartdelay: process.env.TRN_AUTO_START_DELAY === void 0 ? 0 : parseInt(process.env.TRN_AUTO_START_DELAY),
1936
+ trnautostartconfig: process.env.TRN_AUTO_START_CONFIG === void 0 ? "" : process.env.TRN_AUTO_START_CONFIG,
1937
+ trnRedisMessageProcessorUrl: process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL,
1938
+ lambdaendpoint: process.env.LAMBDA_ENDPOINT === void 0 ? "https://localhost" : process.env.LAMBDA_ENDPOINT,
1939
+ lambdahostport: process.env.LAMBDA_HOST_PORT === void 0 ? "3009" : process.env.LAMBDA_HOST_PORT,
1940
+ lambdaport: process.env.LAMBDA_PORT === void 0 ? "3009" : process.env.LAMBDA_PORT,
1941
+ lambdaapiroot: process.env.LAMBDA_APIROOT === void 0 ? "/stslambda/v1.0" : process.env.LAMBDA_APIROOT,
1942
+ lambdaprometheussupport: process.env.LAMBDA_PROM_SUPPORT === void 0 ? true : process.env.LAMBDA_PROM_SUPPORT === "true" ? true : false,
1943
+ lambdaprometheusclusterport: process.env.LAMBDA_PROM_CLUSTER_PORT === void 0 ? "3019" : process.env.LAMBDA_PROM_CLUSTER_PORT,
1944
+ lambdaservicename: process.env.LAMBDA_SERVICE_NAME === void 0 ? "STSLambda" : process.env.LAMBDA_SERVICE_NAME,
1945
+ lambdaserviceversion: process.env.LAMBDA_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.LAMBDA_SERVICE_VERSION,
1946
+ publishinterval: process.env.PUBLISH_INTERVAL === void 0 ? 1e3 : parseInt(process.env.PUBLISH_INTERVAL),
1947
+ publishtimeout: process.env.PUBLISH_TIMEOUT === void 0 ? 750 : parseInt(process.env.PUBLISH_TIMEOUT),
1948
+ transport: process.env.TRANSPORT === void 0 ? "RESTAPI" : process.env.TRANSPORT,
1949
+ useSecureCookies: process.env.USE_SECURE_COOKIES === void 0 ? false : process.env.USE_SECURE_COOKIES === "true" ? true : false,
1950
+ keepAlive: process.env.KEEP_ALIVE === void 0 ? true : process.env.KEEP_ALIVE === "true" ? true : false,
1951
+ maxSockets: process.env.MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.MAX_SOCKETS),
1952
+ maxTotalSockets: process.env.MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.MAX_TOTAL_SOCKETS),
1953
+ maxFreeSockets: process.env.MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.MAX_FREE_SOCKETS),
1954
+ timeout: process.env.TIMEOUT === void 0 ? 1e4 : parseInt(process.env.TIMEOUT),
1955
+ maxPayloadSize: process.env.MAX_PAYLOAD_SIZE === void 0 ? "50mb" : process.env.MAX_PAYLOAD_SIZE,
1956
+ instrumentationObservationInterval: process.env.INSTRUMENTATION_OBSERVATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.INSTRUMENTATION_OBSERVATION_INTERVAL),
1957
+ instrumentationTimeWindow: process.env.INSTRUMENTATION_TIME_WINDOW === void 0 ? 600 : parseInt(process.env.INSTRUMENTATION_TIME_WINDOW),
1958
+ authJWTAccessTokenTimeout: process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT === void 0 ? 600 : parseInt(process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT),
1959
+ authJWTRefreshTokenTimeout: process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT),
1960
+ authCookieTimeout: process.env.AUTH_COOKIE_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_COOKIE_TIMEOUT),
1961
+ masterProcessExitTime: process.env.MASTER_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.MASTER_PROCESS_EXIT_TIME),
1962
+ childProcessExitTime: process.env.CHILD_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.CHILD_PROCESS_EXIT_TIME),
1963
+ systemInformationInterval: process.env.SYSTEM_INFORMATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.SYSTEM_INFORMATION_INTERVAL),
1964
+ ignoresocketio: process.env.IGNORE_SOCKETIO === void 0 ? true : process.env.IGNORE_SOCKETIO === "true" ? true : false,
1965
+ httpsserverkeypath: process.env.HTTPS_SERVER_KEY_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.key" : process.env.HTTPS_SERVER_KEY_PATH,
1966
+ httpsservercertpath: process.env.HTTPS_SERVER_CERT_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.cert" : process.env.HTTPS_SERVER_CERT_PATH,
1967
+ tsjwkskeys: process.env.TS_JWKS_KEYS === void 0 ? 3 : parseInt(process.env.TS_JWKS_KEYS),
1968
+ jwksAuthConfigCache: process.env.JWKS_AUTH_CONFIG_CACHE === void 0 ? true : process.env.JWKS_AUTH_CONFIG_CACHE === "true" ? true : false,
1969
+ jwksAuthConfigCacheMaxEntries: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES === void 0 ? 5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES),
1970
+ jwksAuthConfigCacheMaxAge: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE === void 0 ? 6e5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE),
1971
+ jwksAuthConfigRateLimit: process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === void 0 ? true : process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === "true" ? true : false,
1972
+ jwksAuthConfigRateLimitRequestsPerMinute: process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE === void 0 ? 10 : parseInt(process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE),
1973
+ jwksAuthConfigTimeout: process.env.JWKS_AUTH_CONFIG_TIMEOUT === void 0 ? 3e4 : parseInt(process.env.JWKS_AUTH_CONFIG_TIMEOUT),
1974
+ influxDB_APIToken: process.env.INFLUXDB_API_TOKEN === void 0 ? "password" : process.env.INFLUXDB_API_TOKEN,
1975
+ influxDB_APITokenFile: process.env.INFLUXDB_API_TOKEN_FILE,
1976
+ influxDB_Url: process.env.INFLUXDB_URL === void 0 ? "http://localhost:8086" : process.env.INFLUXDB_URL,
1977
+ influxDB_Org: process.env.INFLUXDB_ORG === void 0 ? "my-org" : process.env.INFLUXDB_ORG,
1978
+ influxDB_Bucket: process.env.INFLUXDB_BUCKET === void 0 ? "TestBucket01" : process.env.INFLUXDB_BUCKET,
1979
+ influxDB_keepAlive: process.env.INFLUXDB_KEEP_ALIVE === void 0 ? true : process.env.INFLUXDB_KEEP_ALIVE === "true" ? true : false,
1980
+ influxDB_maxSockets: process.env.INFLUXDB_MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.INFLUXDB_MAX_SOCKETS),
1981
+ influxDB_maxTotalSockets: process.env.INFLUXDB_MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.INFLUXDB_MAX_TOTAL_SOCKETS),
1982
+ influxDB_maxFreeSockets: process.env.INFLUXDB_MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.INFLUXDB_MAX_FREE_SOCKETS),
1983
+ influxDB_timeout: process.env.INFLUXDB_TIMEOUT === void 0 ? 1e4 : parseInt(process.env.INFLUXDB_TIMEOUT),
1984
+ influxDB_rejectUnauthorized: process.env.INFLUXDB_REJECT_UNAUTHORIZED === void 0 ? true : process.env.INFLUXDB_REJECT_UNAUTHORIZED === "true" ? true : false,
1985
+ influxDB_writeDataPointFlushTimeout: process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT === void 0 ? 1e3 : parseInt(process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT),
1986
+ kafka_clientId: process.env.KAFKA_CLIENT_ID === void 0 ? "myclient" : process.env.KAFKA_CLIENT_ID,
1987
+ kafka_brokers: process.env.KAFKA_BROKERS === void 0 ? "localhost:9092" : process.env.KAFKA_BROKERS,
1988
+ kafka_admin_timeout: process.env.KAFKA_ADMIN_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_ADMIN_TIMEOUT),
1989
+ kafka_connection_timeout: process.env.KAFKA_CONNECTION_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_CONNECTION_TIMEOUT),
1990
+ kafka_request_timeout: process.env.KAFKA_REQUEST_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_REQUEST_TIMEOUT),
1991
+ kafka_log_level: process.env.KAFKA_LOG_LEVEL === void 0 ? "nothing" : process.env.KAFKA_LOG_LEVEL,
1992
+ kafka_keep_alive: process.env.KAFKA_KEEP_ALIVE === void 0 ? 3e4 : parseInt(process.env.KAFKA_KEEP_ALIVE),
1993
+ kafka_use_ssl: process.env.KAFKA_USE_SSL === void 0 ? false : process.env.KAFKA_USE_SSL === "true" ? true : false,
1994
+ kafka_ssl_rejectUnauthorized: process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === void 0 ? true : process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === "true" ? true : false,
1995
+ kafka_ssl_cafile: process.env.KAFKA_SSL_CAFILE === void 0 ? "/my/custom/ca.crt" : process.env.KAFKA_SSL_CAFILE,
1996
+ kafka_ssl_keyfile: process.env.KAFKA_SSL_KEYFILE === void 0 ? "/my/custom/client-key.pem" : process.env.KAFKA_SSL_KEYFILE,
1997
+ kafka_ssl_certfile: process.env.KAFKA_SSL_CERTFILE === void 0 ? "/my/custom/client-cert.pem" : process.env.KAFKA_SSL_CERTFILE,
1998
+ kafka_consume_from_beginning: process.env.KAFKA_CONSUME_FROM_BEGINNING === void 0 ? true : process.env.KAFKA_CONSUME_FROM_BEGINNING === "true" ? true : false,
1999
+ observabilityPublishMode: process.env.OBSERVABILITY_PUBLISH_MODE === void 0 ? "PROXY" : process.env.OBSERVABILITY_PUBLISH_MODE,
2000
+ stsUiTermObservabilityConsumptionMode: process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE === void 0 ? "PROXY" : process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE
2001
+ };
2002
+ const ReadFile = (passwordFile) => {
2003
+ try {
2004
+ node_fs.accessSync(passwordFile, node_fs.constants.R_OK);
2005
+ const data = node_fs.readFileSync(passwordFile, "utf8");
2006
+ if (logger) ;
2007
+ return data;
2008
+ } catch (err) {
2009
+ return "";
2010
+ }
2011
+ };
2012
+ const fileconfig = [
2013
+ { fileprop: "dbpasswordfile", prop: "dbpassword" },
2014
+ // JWKS secret file processing
2015
+ { fileprop: "tsjwksstorepathfile", prop: "tsjwksstorepath" },
2016
+ // InfluxDB file processing
2017
+ { fileprop: "influxDB_APITokenFile", prop: "influxDB_APIToken" }
2018
+ ];
2019
+ fileconfig.forEach((v) => {
2020
+ if (defconfig[v.fileprop] !== void 0) {
2021
+ defconfig[v.prop] = ReadFile(defconfig[v.fileprop]);
2022
+ }
2023
+ });
2024
+ for (const [key, val] of Object.entries(defconfig)) {
2025
+ envOptions2[key] = val;
2026
+ }
2027
+ }
2028
+ function $SetupOptions(envOptions2) {
2029
+ SetupConfig(envOptions2);
2030
+ const options = envOptions2;
2031
+ if (options.dbhost) {
2032
+ const hosts = options.dbhost.split(",");
2033
+ envOptions2.connectionString = hosts.map((host) => {
2034
+ return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/${options.database}`;
2035
+ }).join(",");
2036
+ envOptions2.defaultDatabaseConnectionString = hosts.map((host) => {
2037
+ return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/postgres`;
2038
+ }).join(",");
2039
+ }
2040
+ }
2041
+ const envOptionsHandler = {
2042
+ get(target, prop, receiver) {
2043
+ if (Object.keys(target).length === 0) {
2044
+ $SetupOptions(target);
2045
+ }
2046
+ return Reflect.get(target, prop, receiver);
2047
+ }
2048
+ };
2049
+ const goptions = new Proxy(envOptions, envOptionsHandler);
2050
+ const byteToHex = [];
2051
+ for (let i = 0; i < 256; ++i) {
2052
+ byteToHex.push((i + 256).toString(16).slice(1));
2053
+ }
2054
+ function unsafeStringify(arr, offset = 0) {
2055
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
2056
+ }
2057
+ let getRandomValues;
2058
+ const rnds8 = new Uint8Array(16);
2059
+ function rng() {
2060
+ if (!getRandomValues) {
2061
+ if (typeof crypto === "undefined" || !crypto.getRandomValues) {
2062
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2063
+ }
2064
+ getRandomValues = crypto.getRandomValues.bind(crypto);
2065
+ }
2066
+ return getRandomValues(rnds8);
2067
+ }
2068
+ const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2069
+ const native = { randomUUID };
2070
+ function _v4(options, buf, offset) {
2071
+ options = options || {};
2072
+ const rnds = options.random ?? options.rng?.() ?? rng();
2073
+ if (rnds.length < 16) {
2074
+ throw new Error("Random bytes length must be >= 16");
2075
+ }
2076
+ rnds[6] = rnds[6] & 15 | 64;
2077
+ rnds[8] = rnds[8] & 63 | 128;
2078
+ return unsafeStringify(rnds);
2079
+ }
2080
+ function v4(options, buf, offset) {
2081
+ if (native.randomUUID && true && !options) {
2082
+ return native.randomUUID();
2083
+ }
2084
+ return _v4(options);
2085
+ }
2086
+ const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
2087
+ var ansiStyles = { exports: {} };
2088
+ var colorName;
2089
+ var hasRequiredColorName;
2090
+ function requireColorName() {
2091
+ if (hasRequiredColorName) return colorName;
2092
+ hasRequiredColorName = 1;
2093
+ colorName = {
2094
+ "aliceblue": [240, 248, 255],
2095
+ "antiquewhite": [250, 235, 215],
2096
+ "aqua": [0, 255, 255],
2097
+ "aquamarine": [127, 255, 212],
2098
+ "azure": [240, 255, 255],
2099
+ "beige": [245, 245, 220],
2100
+ "bisque": [255, 228, 196],
2101
+ "black": [0, 0, 0],
2102
+ "blanchedalmond": [255, 235, 205],
2103
+ "blue": [0, 0, 255],
2104
+ "blueviolet": [138, 43, 226],
2105
+ "brown": [165, 42, 42],
2106
+ "burlywood": [222, 184, 135],
2107
+ "cadetblue": [95, 158, 160],
2108
+ "chartreuse": [127, 255, 0],
2109
+ "chocolate": [210, 105, 30],
2110
+ "coral": [255, 127, 80],
2111
+ "cornflowerblue": [100, 149, 237],
2112
+ "cornsilk": [255, 248, 220],
2113
+ "crimson": [220, 20, 60],
2114
+ "cyan": [0, 255, 255],
2115
+ "darkblue": [0, 0, 139],
2116
+ "darkcyan": [0, 139, 139],
2117
+ "darkgoldenrod": [184, 134, 11],
2118
+ "darkgray": [169, 169, 169],
2119
+ "darkgreen": [0, 100, 0],
2120
+ "darkgrey": [169, 169, 169],
2121
+ "darkkhaki": [189, 183, 107],
2122
+ "darkmagenta": [139, 0, 139],
2123
+ "darkolivegreen": [85, 107, 47],
2124
+ "darkorange": [255, 140, 0],
2125
+ "darkorchid": [153, 50, 204],
2126
+ "darkred": [139, 0, 0],
2127
+ "darksalmon": [233, 150, 122],
2128
+ "darkseagreen": [143, 188, 143],
2129
+ "darkslateblue": [72, 61, 139],
2130
+ "darkslategray": [47, 79, 79],
2131
+ "darkslategrey": [47, 79, 79],
2132
+ "darkturquoise": [0, 206, 209],
2133
+ "darkviolet": [148, 0, 211],
2134
+ "deeppink": [255, 20, 147],
2135
+ "deepskyblue": [0, 191, 255],
2136
+ "dimgray": [105, 105, 105],
2137
+ "dimgrey": [105, 105, 105],
2138
+ "dodgerblue": [30, 144, 255],
2139
+ "firebrick": [178, 34, 34],
2140
+ "floralwhite": [255, 250, 240],
2141
+ "forestgreen": [34, 139, 34],
2142
+ "fuchsia": [255, 0, 255],
2143
+ "gainsboro": [220, 220, 220],
2144
+ "ghostwhite": [248, 248, 255],
2145
+ "gold": [255, 215, 0],
2146
+ "goldenrod": [218, 165, 32],
2147
+ "gray": [128, 128, 128],
2148
+ "green": [0, 128, 0],
2149
+ "greenyellow": [173, 255, 47],
2150
+ "grey": [128, 128, 128],
2151
+ "honeydew": [240, 255, 240],
2152
+ "hotpink": [255, 105, 180],
2153
+ "indianred": [205, 92, 92],
2154
+ "indigo": [75, 0, 130],
2155
+ "ivory": [255, 255, 240],
2156
+ "khaki": [240, 230, 140],
2157
+ "lavender": [230, 230, 250],
2158
+ "lavenderblush": [255, 240, 245],
2159
+ "lawngreen": [124, 252, 0],
2160
+ "lemonchiffon": [255, 250, 205],
2161
+ "lightblue": [173, 216, 230],
2162
+ "lightcoral": [240, 128, 128],
2163
+ "lightcyan": [224, 255, 255],
2164
+ "lightgoldenrodyellow": [250, 250, 210],
2165
+ "lightgray": [211, 211, 211],
2166
+ "lightgreen": [144, 238, 144],
2167
+ "lightgrey": [211, 211, 211],
2168
+ "lightpink": [255, 182, 193],
2169
+ "lightsalmon": [255, 160, 122],
2170
+ "lightseagreen": [32, 178, 170],
2171
+ "lightskyblue": [135, 206, 250],
2172
+ "lightslategray": [119, 136, 153],
2173
+ "lightslategrey": [119, 136, 153],
2174
+ "lightsteelblue": [176, 196, 222],
2175
+ "lightyellow": [255, 255, 224],
2176
+ "lime": [0, 255, 0],
2177
+ "limegreen": [50, 205, 50],
2178
+ "linen": [250, 240, 230],
2179
+ "magenta": [255, 0, 255],
2180
+ "maroon": [128, 0, 0],
2181
+ "mediumaquamarine": [102, 205, 170],
2182
+ "mediumblue": [0, 0, 205],
2183
+ "mediumorchid": [186, 85, 211],
2184
+ "mediumpurple": [147, 112, 219],
2185
+ "mediumseagreen": [60, 179, 113],
2186
+ "mediumslateblue": [123, 104, 238],
2187
+ "mediumspringgreen": [0, 250, 154],
2188
+ "mediumturquoise": [72, 209, 204],
2189
+ "mediumvioletred": [199, 21, 133],
2190
+ "midnightblue": [25, 25, 112],
2191
+ "mintcream": [245, 255, 250],
2192
+ "mistyrose": [255, 228, 225],
2193
+ "moccasin": [255, 228, 181],
2194
+ "navajowhite": [255, 222, 173],
2195
+ "navy": [0, 0, 128],
2196
+ "oldlace": [253, 245, 230],
2197
+ "olive": [128, 128, 0],
2198
+ "olivedrab": [107, 142, 35],
2199
+ "orange": [255, 165, 0],
2200
+ "orangered": [255, 69, 0],
2201
+ "orchid": [218, 112, 214],
2202
+ "palegoldenrod": [238, 232, 170],
2203
+ "palegreen": [152, 251, 152],
2204
+ "paleturquoise": [175, 238, 238],
2205
+ "palevioletred": [219, 112, 147],
2206
+ "papayawhip": [255, 239, 213],
2207
+ "peachpuff": [255, 218, 185],
2208
+ "peru": [205, 133, 63],
2209
+ "pink": [255, 192, 203],
2210
+ "plum": [221, 160, 221],
2211
+ "powderblue": [176, 224, 230],
2212
+ "purple": [128, 0, 128],
2213
+ "rebeccapurple": [102, 51, 153],
2214
+ "red": [255, 0, 0],
2215
+ "rosybrown": [188, 143, 143],
2216
+ "royalblue": [65, 105, 225],
2217
+ "saddlebrown": [139, 69, 19],
2218
+ "salmon": [250, 128, 114],
2219
+ "sandybrown": [244, 164, 96],
2220
+ "seagreen": [46, 139, 87],
2221
+ "seashell": [255, 245, 238],
2222
+ "sienna": [160, 82, 45],
2223
+ "silver": [192, 192, 192],
2224
+ "skyblue": [135, 206, 235],
2225
+ "slateblue": [106, 90, 205],
2226
+ "slategray": [112, 128, 144],
2227
+ "slategrey": [112, 128, 144],
2228
+ "snow": [255, 250, 250],
2229
+ "springgreen": [0, 255, 127],
2230
+ "steelblue": [70, 130, 180],
2231
+ "tan": [210, 180, 140],
2232
+ "teal": [0, 128, 128],
2233
+ "thistle": [216, 191, 216],
2234
+ "tomato": [255, 99, 71],
2235
+ "turquoise": [64, 224, 208],
2236
+ "violet": [238, 130, 238],
2237
+ "wheat": [245, 222, 179],
2238
+ "white": [255, 255, 255],
2239
+ "whitesmoke": [245, 245, 245],
2240
+ "yellow": [255, 255, 0],
2241
+ "yellowgreen": [154, 205, 50]
2242
+ };
2243
+ return colorName;
2244
+ }
2245
+ var conversions;
2246
+ var hasRequiredConversions;
2247
+ function requireConversions() {
2248
+ if (hasRequiredConversions) return conversions;
2249
+ hasRequiredConversions = 1;
2250
+ const cssKeywords = requireColorName();
2251
+ const reverseKeywords = {};
2252
+ for (const key of Object.keys(cssKeywords)) {
2253
+ reverseKeywords[cssKeywords[key]] = key;
2254
+ }
2255
+ const convert = {
2256
+ rgb: { channels: 3, labels: "rgb" },
2257
+ hsl: { channels: 3, labels: "hsl" },
2258
+ hsv: { channels: 3, labels: "hsv" },
2259
+ hwb: { channels: 3, labels: "hwb" },
2260
+ cmyk: { channels: 4, labels: "cmyk" },
2261
+ xyz: { channels: 3, labels: "xyz" },
2262
+ lab: { channels: 3, labels: "lab" },
2263
+ lch: { channels: 3, labels: "lch" },
2264
+ hex: { channels: 1, labels: ["hex"] },
2265
+ keyword: { channels: 1, labels: ["keyword"] },
2266
+ ansi16: { channels: 1, labels: ["ansi16"] },
2267
+ ansi256: { channels: 1, labels: ["ansi256"] },
2268
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
2269
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
2270
+ gray: { channels: 1, labels: ["gray"] }
2271
+ };
2272
+ conversions = convert;
2273
+ for (const model of Object.keys(convert)) {
2274
+ if (!("channels" in convert[model])) {
2275
+ throw new Error("missing channels property: " + model);
2276
+ }
2277
+ if (!("labels" in convert[model])) {
2278
+ throw new Error("missing channel labels property: " + model);
2279
+ }
2280
+ if (convert[model].labels.length !== convert[model].channels) {
2281
+ throw new Error("channel and label counts mismatch: " + model);
2282
+ }
2283
+ const { channels, labels } = convert[model];
2284
+ delete convert[model].channels;
2285
+ delete convert[model].labels;
2286
+ Object.defineProperty(convert[model], "channels", { value: channels });
2287
+ Object.defineProperty(convert[model], "labels", { value: labels });
2288
+ }
2289
+ convert.rgb.hsl = function(rgb) {
2290
+ const r = rgb[0] / 255;
2291
+ const g = rgb[1] / 255;
2292
+ const b = rgb[2] / 255;
2293
+ const min = Math.min(r, g, b);
2294
+ const max = Math.max(r, g, b);
2295
+ const delta = max - min;
2296
+ let h;
2297
+ let s;
2298
+ if (max === min) {
2299
+ h = 0;
2300
+ } else if (r === max) {
2301
+ h = (g - b) / delta;
2302
+ } else if (g === max) {
2303
+ h = 2 + (b - r) / delta;
2304
+ } else if (b === max) {
2305
+ h = 4 + (r - g) / delta;
2306
+ }
2307
+ h = Math.min(h * 60, 360);
2308
+ if (h < 0) {
2309
+ h += 360;
2310
+ }
2311
+ const l = (min + max) / 2;
2312
+ if (max === min) {
2313
+ s = 0;
2314
+ } else if (l <= 0.5) {
2315
+ s = delta / (max + min);
2316
+ } else {
2317
+ s = delta / (2 - max - min);
2318
+ }
2319
+ return [h, s * 100, l * 100];
2320
+ };
2321
+ convert.rgb.hsv = function(rgb) {
2322
+ let rdif;
2323
+ let gdif;
2324
+ let bdif;
2325
+ let h;
2326
+ let s;
2327
+ const r = rgb[0] / 255;
2328
+ const g = rgb[1] / 255;
2329
+ const b = rgb[2] / 255;
2330
+ const v = Math.max(r, g, b);
2331
+ const diff = v - Math.min(r, g, b);
2332
+ const diffc = function(c) {
2333
+ return (v - c) / 6 / diff + 1 / 2;
2334
+ };
2335
+ if (diff === 0) {
2336
+ h = 0;
2337
+ s = 0;
2338
+ } else {
2339
+ s = diff / v;
2340
+ rdif = diffc(r);
2341
+ gdif = diffc(g);
2342
+ bdif = diffc(b);
2343
+ if (r === v) {
2344
+ h = bdif - gdif;
2345
+ } else if (g === v) {
2346
+ h = 1 / 3 + rdif - bdif;
2347
+ } else if (b === v) {
2348
+ h = 2 / 3 + gdif - rdif;
2349
+ }
2350
+ if (h < 0) {
2351
+ h += 1;
2352
+ } else if (h > 1) {
2353
+ h -= 1;
2354
+ }
2355
+ }
2356
+ return [
2357
+ h * 360,
2358
+ s * 100,
2359
+ v * 100
2360
+ ];
2361
+ };
2362
+ convert.rgb.hwb = function(rgb) {
2363
+ const r = rgb[0];
2364
+ const g = rgb[1];
2365
+ let b = rgb[2];
2366
+ const h = convert.rgb.hsl(rgb)[0];
2367
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
2368
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
2369
+ return [h, w * 100, b * 100];
2370
+ };
2371
+ convert.rgb.cmyk = function(rgb) {
2372
+ const r = rgb[0] / 255;
2373
+ const g = rgb[1] / 255;
2374
+ const b = rgb[2] / 255;
2375
+ const k = Math.min(1 - r, 1 - g, 1 - b);
2376
+ const c = (1 - r - k) / (1 - k) || 0;
2377
+ const m = (1 - g - k) / (1 - k) || 0;
2378
+ const y = (1 - b - k) / (1 - k) || 0;
2379
+ return [c * 100, m * 100, y * 100, k * 100];
2380
+ };
2381
+ function comparativeDistance(x, y) {
2382
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
2383
+ }
2384
+ convert.rgb.keyword = function(rgb) {
2385
+ const reversed = reverseKeywords[rgb];
2386
+ if (reversed) {
2387
+ return reversed;
2388
+ }
2389
+ let currentClosestDistance = Infinity;
2390
+ let currentClosestKeyword;
2391
+ for (const keyword of Object.keys(cssKeywords)) {
2392
+ const value = cssKeywords[keyword];
2393
+ const distance = comparativeDistance(rgb, value);
2394
+ if (distance < currentClosestDistance) {
2395
+ currentClosestDistance = distance;
2396
+ currentClosestKeyword = keyword;
2397
+ }
2398
+ }
2399
+ return currentClosestKeyword;
2400
+ };
2401
+ convert.keyword.rgb = function(keyword) {
2402
+ return cssKeywords[keyword];
2403
+ };
2404
+ convert.rgb.xyz = function(rgb) {
2405
+ let r = rgb[0] / 255;
2406
+ let g = rgb[1] / 255;
2407
+ let b = rgb[2] / 255;
2408
+ r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
2409
+ g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
2410
+ b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
2411
+ const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
2412
+ const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
2413
+ const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
2414
+ return [x * 100, y * 100, z * 100];
2415
+ };
2416
+ convert.rgb.lab = function(rgb) {
2417
+ const xyz = convert.rgb.xyz(rgb);
2418
+ let x = xyz[0];
2419
+ let y = xyz[1];
2420
+ let z = xyz[2];
2421
+ x /= 95.047;
2422
+ y /= 100;
2423
+ z /= 108.883;
2424
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
2425
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
2426
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
2427
+ const l = 116 * y - 16;
2428
+ const a = 500 * (x - y);
2429
+ const b = 200 * (y - z);
2430
+ return [l, a, b];
2431
+ };
2432
+ convert.hsl.rgb = function(hsl) {
2433
+ const h = hsl[0] / 360;
2434
+ const s = hsl[1] / 100;
2435
+ const l = hsl[2] / 100;
2436
+ let t2;
2437
+ let t3;
2438
+ let val;
2439
+ if (s === 0) {
2440
+ val = l * 255;
2441
+ return [val, val, val];
2442
+ }
2443
+ if (l < 0.5) {
2444
+ t2 = l * (1 + s);
2445
+ } else {
2446
+ t2 = l + s - l * s;
2447
+ }
2448
+ const t1 = 2 * l - t2;
2449
+ const rgb = [0, 0, 0];
2450
+ for (let i = 0; i < 3; i++) {
2451
+ t3 = h + 1 / 3 * -(i - 1);
2452
+ if (t3 < 0) {
2453
+ t3++;
2454
+ }
2455
+ if (t3 > 1) {
2456
+ t3--;
2457
+ }
2458
+ if (6 * t3 < 1) {
2459
+ val = t1 + (t2 - t1) * 6 * t3;
2460
+ } else if (2 * t3 < 1) {
2461
+ val = t2;
2462
+ } else if (3 * t3 < 2) {
2463
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
2464
+ } else {
2465
+ val = t1;
2466
+ }
2467
+ rgb[i] = val * 255;
2468
+ }
2469
+ return rgb;
2470
+ };
2471
+ convert.hsl.hsv = function(hsl) {
2472
+ const h = hsl[0];
2473
+ let s = hsl[1] / 100;
2474
+ let l = hsl[2] / 100;
2475
+ let smin = s;
2476
+ const lmin = Math.max(l, 0.01);
2477
+ l *= 2;
2478
+ s *= l <= 1 ? l : 2 - l;
2479
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
2480
+ const v = (l + s) / 2;
2481
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
2482
+ return [h, sv * 100, v * 100];
2483
+ };
2484
+ convert.hsv.rgb = function(hsv) {
2485
+ const h = hsv[0] / 60;
2486
+ const s = hsv[1] / 100;
2487
+ let v = hsv[2] / 100;
2488
+ const hi = Math.floor(h) % 6;
2489
+ const f = h - Math.floor(h);
2490
+ const p = 255 * v * (1 - s);
2491
+ const q = 255 * v * (1 - s * f);
2492
+ const t = 255 * v * (1 - s * (1 - f));
2493
+ v *= 255;
2494
+ switch (hi) {
2495
+ case 0:
2496
+ return [v, t, p];
2497
+ case 1:
2498
+ return [q, v, p];
2499
+ case 2:
2500
+ return [p, v, t];
2501
+ case 3:
2502
+ return [p, q, v];
2503
+ case 4:
2504
+ return [t, p, v];
2505
+ case 5:
2506
+ return [v, p, q];
2507
+ }
2508
+ };
2509
+ convert.hsv.hsl = function(hsv) {
2510
+ const h = hsv[0];
2511
+ const s = hsv[1] / 100;
2512
+ const v = hsv[2] / 100;
2513
+ const vmin = Math.max(v, 0.01);
2514
+ let sl;
2515
+ let l;
2516
+ l = (2 - s) * v;
2517
+ const lmin = (2 - s) * vmin;
2518
+ sl = s * vmin;
2519
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
2520
+ sl = sl || 0;
2521
+ l /= 2;
2522
+ return [h, sl * 100, l * 100];
2523
+ };
2524
+ convert.hwb.rgb = function(hwb) {
2525
+ const h = hwb[0] / 360;
2526
+ let wh = hwb[1] / 100;
2527
+ let bl = hwb[2] / 100;
2528
+ const ratio = wh + bl;
2529
+ let f;
2530
+ if (ratio > 1) {
2531
+ wh /= ratio;
2532
+ bl /= ratio;
2533
+ }
2534
+ const i = Math.floor(6 * h);
2535
+ const v = 1 - bl;
2536
+ f = 6 * h - i;
2537
+ if ((i & 1) !== 0) {
2538
+ f = 1 - f;
2539
+ }
2540
+ const n = wh + f * (v - wh);
2541
+ let r;
2542
+ let g;
2543
+ let b;
2544
+ switch (i) {
2545
+ default:
2546
+ case 6:
2547
+ case 0:
2548
+ r = v;
2549
+ g = n;
2550
+ b = wh;
2551
+ break;
2552
+ case 1:
2553
+ r = n;
2554
+ g = v;
2555
+ b = wh;
2556
+ break;
2557
+ case 2:
2558
+ r = wh;
2559
+ g = v;
2560
+ b = n;
2561
+ break;
2562
+ case 3:
2563
+ r = wh;
2564
+ g = n;
2565
+ b = v;
2566
+ break;
2567
+ case 4:
2568
+ r = n;
2569
+ g = wh;
2570
+ b = v;
2571
+ break;
2572
+ case 5:
2573
+ r = v;
2574
+ g = wh;
2575
+ b = n;
2576
+ break;
2577
+ }
2578
+ return [r * 255, g * 255, b * 255];
2579
+ };
2580
+ convert.cmyk.rgb = function(cmyk) {
2581
+ const c = cmyk[0] / 100;
2582
+ const m = cmyk[1] / 100;
2583
+ const y = cmyk[2] / 100;
2584
+ const k = cmyk[3] / 100;
2585
+ const r = 1 - Math.min(1, c * (1 - k) + k);
2586
+ const g = 1 - Math.min(1, m * (1 - k) + k);
2587
+ const b = 1 - Math.min(1, y * (1 - k) + k);
2588
+ return [r * 255, g * 255, b * 255];
2589
+ };
2590
+ convert.xyz.rgb = function(xyz) {
2591
+ const x = xyz[0] / 100;
2592
+ const y = xyz[1] / 100;
2593
+ const z = xyz[2] / 100;
2594
+ let r;
2595
+ let g;
2596
+ let b;
2597
+ r = x * 3.2406 + y * -1.5372 + z * -0.4986;
2598
+ g = x * -0.9689 + y * 1.8758 + z * 0.0415;
2599
+ b = x * 0.0557 + y * -0.204 + z * 1.057;
2600
+ r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
2601
+ g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
2602
+ b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
2603
+ r = Math.min(Math.max(0, r), 1);
2604
+ g = Math.min(Math.max(0, g), 1);
2605
+ b = Math.min(Math.max(0, b), 1);
2606
+ return [r * 255, g * 255, b * 255];
2607
+ };
2608
+ convert.xyz.lab = function(xyz) {
2609
+ let x = xyz[0];
2610
+ let y = xyz[1];
2611
+ let z = xyz[2];
2612
+ x /= 95.047;
2613
+ y /= 100;
2614
+ z /= 108.883;
2615
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
2616
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
2617
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
2618
+ const l = 116 * y - 16;
2619
+ const a = 500 * (x - y);
2620
+ const b = 200 * (y - z);
2621
+ return [l, a, b];
2622
+ };
2623
+ convert.lab.xyz = function(lab) {
2624
+ const l = lab[0];
2625
+ const a = lab[1];
2626
+ const b = lab[2];
2627
+ let x;
2628
+ let y;
2629
+ let z;
2630
+ y = (l + 16) / 116;
2631
+ x = a / 500 + y;
2632
+ z = y - b / 200;
2633
+ const y2 = y ** 3;
2634
+ const x2 = x ** 3;
2635
+ const z2 = z ** 3;
2636
+ y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
2637
+ x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
2638
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
2639
+ x *= 95.047;
2640
+ y *= 100;
2641
+ z *= 108.883;
2642
+ return [x, y, z];
2643
+ };
2644
+ convert.lab.lch = function(lab) {
2645
+ const l = lab[0];
2646
+ const a = lab[1];
2647
+ const b = lab[2];
2648
+ let h;
2649
+ const hr = Math.atan2(b, a);
2650
+ h = hr * 360 / 2 / Math.PI;
2651
+ if (h < 0) {
2652
+ h += 360;
2653
+ }
2654
+ const c = Math.sqrt(a * a + b * b);
2655
+ return [l, c, h];
2656
+ };
2657
+ convert.lch.lab = function(lch) {
2658
+ const l = lch[0];
2659
+ const c = lch[1];
2660
+ const h = lch[2];
2661
+ const hr = h / 360 * 2 * Math.PI;
2662
+ const a = c * Math.cos(hr);
2663
+ const b = c * Math.sin(hr);
2664
+ return [l, a, b];
2665
+ };
2666
+ convert.rgb.ansi16 = function(args, saturation = null) {
2667
+ const [r, g, b] = args;
2668
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
2669
+ value = Math.round(value / 50);
2670
+ if (value === 0) {
2671
+ return 30;
2672
+ }
2673
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
2674
+ if (value === 2) {
2675
+ ansi += 60;
2676
+ }
2677
+ return ansi;
2678
+ };
2679
+ convert.hsv.ansi16 = function(args) {
2680
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
2681
+ };
2682
+ convert.rgb.ansi256 = function(args) {
2683
+ const r = args[0];
2684
+ const g = args[1];
2685
+ const b = args[2];
2686
+ if (r === g && g === b) {
2687
+ if (r < 8) {
2688
+ return 16;
2689
+ }
2690
+ if (r > 248) {
2691
+ return 231;
2692
+ }
2693
+ return Math.round((r - 8) / 247 * 24) + 232;
2694
+ }
2695
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
2696
+ return ansi;
2697
+ };
2698
+ convert.ansi16.rgb = function(args) {
2699
+ let color = args % 10;
2700
+ if (color === 0 || color === 7) {
2701
+ if (args > 50) {
2702
+ color += 3.5;
2703
+ }
2704
+ color = color / 10.5 * 255;
2705
+ return [color, color, color];
2706
+ }
2707
+ const mult = (~~(args > 50) + 1) * 0.5;
2708
+ const r = (color & 1) * mult * 255;
2709
+ const g = (color >> 1 & 1) * mult * 255;
2710
+ const b = (color >> 2 & 1) * mult * 255;
2711
+ return [r, g, b];
2712
+ };
2713
+ convert.ansi256.rgb = function(args) {
2714
+ if (args >= 232) {
2715
+ const c = (args - 232) * 10 + 8;
2716
+ return [c, c, c];
2717
+ }
2718
+ args -= 16;
2719
+ let rem;
2720
+ const r = Math.floor(args / 36) / 5 * 255;
2721
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
2722
+ const b = rem % 6 / 5 * 255;
2723
+ return [r, g, b];
2724
+ };
2725
+ convert.rgb.hex = function(args) {
2726
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
2727
+ const string = integer.toString(16).toUpperCase();
2728
+ return "000000".substring(string.length) + string;
2729
+ };
2730
+ convert.hex.rgb = function(args) {
2731
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
2732
+ if (!match) {
2733
+ return [0, 0, 0];
2734
+ }
2735
+ let colorString = match[0];
2736
+ if (match[0].length === 3) {
2737
+ colorString = colorString.split("").map((char) => {
2738
+ return char + char;
2739
+ }).join("");
2740
+ }
2741
+ const integer = parseInt(colorString, 16);
2742
+ const r = integer >> 16 & 255;
2743
+ const g = integer >> 8 & 255;
2744
+ const b = integer & 255;
2745
+ return [r, g, b];
2746
+ };
2747
+ convert.rgb.hcg = function(rgb) {
2748
+ const r = rgb[0] / 255;
2749
+ const g = rgb[1] / 255;
2750
+ const b = rgb[2] / 255;
2751
+ const max = Math.max(Math.max(r, g), b);
2752
+ const min = Math.min(Math.min(r, g), b);
2753
+ const chroma = max - min;
2754
+ let grayscale;
2755
+ let hue;
2756
+ if (chroma < 1) {
2757
+ grayscale = min / (1 - chroma);
2758
+ } else {
2759
+ grayscale = 0;
2760
+ }
2761
+ if (chroma <= 0) {
2762
+ hue = 0;
2763
+ } else if (max === r) {
2764
+ hue = (g - b) / chroma % 6;
2765
+ } else if (max === g) {
2766
+ hue = 2 + (b - r) / chroma;
2767
+ } else {
2768
+ hue = 4 + (r - g) / chroma;
2769
+ }
2770
+ hue /= 6;
2771
+ hue %= 1;
2772
+ return [hue * 360, chroma * 100, grayscale * 100];
2773
+ };
2774
+ convert.hsl.hcg = function(hsl) {
2775
+ const s = hsl[1] / 100;
2776
+ const l = hsl[2] / 100;
2777
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
2778
+ let f = 0;
2779
+ if (c < 1) {
2780
+ f = (l - 0.5 * c) / (1 - c);
2781
+ }
2782
+ return [hsl[0], c * 100, f * 100];
2783
+ };
2784
+ convert.hsv.hcg = function(hsv) {
2785
+ const s = hsv[1] / 100;
2786
+ const v = hsv[2] / 100;
2787
+ const c = s * v;
2788
+ let f = 0;
2789
+ if (c < 1) {
2790
+ f = (v - c) / (1 - c);
2791
+ }
2792
+ return [hsv[0], c * 100, f * 100];
2793
+ };
2794
+ convert.hcg.rgb = function(hcg) {
2795
+ const h = hcg[0] / 360;
2796
+ const c = hcg[1] / 100;
2797
+ const g = hcg[2] / 100;
2798
+ if (c === 0) {
2799
+ return [g * 255, g * 255, g * 255];
2800
+ }
2801
+ const pure = [0, 0, 0];
2802
+ const hi = h % 1 * 6;
2803
+ const v = hi % 1;
2804
+ const w = 1 - v;
2805
+ let mg = 0;
2806
+ switch (Math.floor(hi)) {
2807
+ case 0:
2808
+ pure[0] = 1;
2809
+ pure[1] = v;
2810
+ pure[2] = 0;
2811
+ break;
2812
+ case 1:
2813
+ pure[0] = w;
2814
+ pure[1] = 1;
2815
+ pure[2] = 0;
2816
+ break;
2817
+ case 2:
2818
+ pure[0] = 0;
2819
+ pure[1] = 1;
2820
+ pure[2] = v;
2821
+ break;
2822
+ case 3:
2823
+ pure[0] = 0;
2824
+ pure[1] = w;
2825
+ pure[2] = 1;
2826
+ break;
2827
+ case 4:
2828
+ pure[0] = v;
2829
+ pure[1] = 0;
2830
+ pure[2] = 1;
2831
+ break;
2832
+ default:
2833
+ pure[0] = 1;
2834
+ pure[1] = 0;
2835
+ pure[2] = w;
2836
+ }
2837
+ mg = (1 - c) * g;
2838
+ return [
2839
+ (c * pure[0] + mg) * 255,
2840
+ (c * pure[1] + mg) * 255,
2841
+ (c * pure[2] + mg) * 255
2842
+ ];
2843
+ };
2844
+ convert.hcg.hsv = function(hcg) {
2845
+ const c = hcg[1] / 100;
2846
+ const g = hcg[2] / 100;
2847
+ const v = c + g * (1 - c);
2848
+ let f = 0;
2849
+ if (v > 0) {
2850
+ f = c / v;
2851
+ }
2852
+ return [hcg[0], f * 100, v * 100];
2853
+ };
2854
+ convert.hcg.hsl = function(hcg) {
2855
+ const c = hcg[1] / 100;
2856
+ const g = hcg[2] / 100;
2857
+ const l = g * (1 - c) + 0.5 * c;
2858
+ let s = 0;
2859
+ if (l > 0 && l < 0.5) {
2860
+ s = c / (2 * l);
2861
+ } else if (l >= 0.5 && l < 1) {
2862
+ s = c / (2 * (1 - l));
2863
+ }
2864
+ return [hcg[0], s * 100, l * 100];
2865
+ };
2866
+ convert.hcg.hwb = function(hcg) {
2867
+ const c = hcg[1] / 100;
2868
+ const g = hcg[2] / 100;
2869
+ const v = c + g * (1 - c);
2870
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
2871
+ };
2872
+ convert.hwb.hcg = function(hwb) {
2873
+ const w = hwb[1] / 100;
2874
+ const b = hwb[2] / 100;
2875
+ const v = 1 - b;
2876
+ const c = v - w;
2877
+ let g = 0;
2878
+ if (c < 1) {
2879
+ g = (v - c) / (1 - c);
2880
+ }
2881
+ return [hwb[0], c * 100, g * 100];
2882
+ };
2883
+ convert.apple.rgb = function(apple) {
2884
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
2885
+ };
2886
+ convert.rgb.apple = function(rgb) {
2887
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
2888
+ };
2889
+ convert.gray.rgb = function(args) {
2890
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
2891
+ };
2892
+ convert.gray.hsl = function(args) {
2893
+ return [0, 0, args[0]];
2894
+ };
2895
+ convert.gray.hsv = convert.gray.hsl;
2896
+ convert.gray.hwb = function(gray) {
2897
+ return [0, 100, gray[0]];
2898
+ };
2899
+ convert.gray.cmyk = function(gray) {
2900
+ return [0, 0, 0, gray[0]];
2901
+ };
2902
+ convert.gray.lab = function(gray) {
2903
+ return [gray[0], 0, 0];
2904
+ };
2905
+ convert.gray.hex = function(gray) {
2906
+ const val = Math.round(gray[0] / 100 * 255) & 255;
2907
+ const integer = (val << 16) + (val << 8) + val;
2908
+ const string = integer.toString(16).toUpperCase();
2909
+ return "000000".substring(string.length) + string;
2910
+ };
2911
+ convert.rgb.gray = function(rgb) {
2912
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
2913
+ return [val / 255 * 100];
2914
+ };
2915
+ return conversions;
2916
+ }
2917
+ var route;
2918
+ var hasRequiredRoute;
2919
+ function requireRoute() {
2920
+ if (hasRequiredRoute) return route;
2921
+ hasRequiredRoute = 1;
2922
+ const conversions2 = requireConversions();
2923
+ function buildGraph() {
2924
+ const graph = {};
2925
+ const models = Object.keys(conversions2);
2926
+ for (let len = models.length, i = 0; i < len; i++) {
2927
+ graph[models[i]] = {
2928
+ // http://jsperf.com/1-vs-infinity
2929
+ // micro-opt, but this is simple.
2930
+ distance: -1,
2931
+ parent: null
2932
+ };
2933
+ }
2934
+ return graph;
2935
+ }
2936
+ function deriveBFS(fromModel) {
2937
+ const graph = buildGraph();
2938
+ const queue = [fromModel];
2939
+ graph[fromModel].distance = 0;
2940
+ while (queue.length) {
2941
+ const current = queue.pop();
2942
+ const adjacents = Object.keys(conversions2[current]);
2943
+ for (let len = adjacents.length, i = 0; i < len; i++) {
2944
+ const adjacent = adjacents[i];
2945
+ const node = graph[adjacent];
2946
+ if (node.distance === -1) {
2947
+ node.distance = graph[current].distance + 1;
2948
+ node.parent = current;
2949
+ queue.unshift(adjacent);
2950
+ }
2951
+ }
2952
+ }
2953
+ return graph;
2954
+ }
2955
+ function link(from, to) {
2956
+ return function(args) {
2957
+ return to(from(args));
2958
+ };
2959
+ }
2960
+ function wrapConversion(toModel, graph) {
2961
+ const path = [graph[toModel].parent, toModel];
2962
+ let fn = conversions2[graph[toModel].parent][toModel];
2963
+ let cur = graph[toModel].parent;
2964
+ while (graph[cur].parent) {
2965
+ path.unshift(graph[cur].parent);
2966
+ fn = link(conversions2[graph[cur].parent][cur], fn);
2967
+ cur = graph[cur].parent;
2968
+ }
2969
+ fn.conversion = path;
2970
+ return fn;
2971
+ }
2972
+ route = function(fromModel) {
2973
+ const graph = deriveBFS(fromModel);
2974
+ const conversion = {};
2975
+ const models = Object.keys(graph);
2976
+ for (let len = models.length, i = 0; i < len; i++) {
2977
+ const toModel = models[i];
2978
+ const node = graph[toModel];
2979
+ if (node.parent === null) {
2980
+ continue;
2981
+ }
2982
+ conversion[toModel] = wrapConversion(toModel, graph);
2983
+ }
2984
+ return conversion;
2985
+ };
2986
+ return route;
2987
+ }
2988
+ var colorConvert;
2989
+ var hasRequiredColorConvert;
2990
+ function requireColorConvert() {
2991
+ if (hasRequiredColorConvert) return colorConvert;
2992
+ hasRequiredColorConvert = 1;
2993
+ const conversions2 = requireConversions();
2994
+ const route2 = requireRoute();
2995
+ const convert = {};
2996
+ const models = Object.keys(conversions2);
2997
+ function wrapRaw(fn) {
2998
+ const wrappedFn = function(...args) {
2999
+ const arg0 = args[0];
3000
+ if (arg0 === void 0 || arg0 === null) {
3001
+ return arg0;
3002
+ }
3003
+ if (arg0.length > 1) {
3004
+ args = arg0;
3005
+ }
3006
+ return fn(args);
3007
+ };
3008
+ if ("conversion" in fn) {
3009
+ wrappedFn.conversion = fn.conversion;
3010
+ }
3011
+ return wrappedFn;
3012
+ }
3013
+ function wrapRounded(fn) {
3014
+ const wrappedFn = function(...args) {
3015
+ const arg0 = args[0];
3016
+ if (arg0 === void 0 || arg0 === null) {
3017
+ return arg0;
3018
+ }
3019
+ if (arg0.length > 1) {
3020
+ args = arg0;
3021
+ }
3022
+ const result = fn(args);
3023
+ if (typeof result === "object") {
3024
+ for (let len = result.length, i = 0; i < len; i++) {
3025
+ result[i] = Math.round(result[i]);
3026
+ }
3027
+ }
3028
+ return result;
3029
+ };
3030
+ if ("conversion" in fn) {
3031
+ wrappedFn.conversion = fn.conversion;
3032
+ }
3033
+ return wrappedFn;
3034
+ }
3035
+ models.forEach((fromModel) => {
3036
+ convert[fromModel] = {};
3037
+ Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
3038
+ Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
3039
+ const routes = route2(fromModel);
3040
+ const routeModels = Object.keys(routes);
3041
+ routeModels.forEach((toModel) => {
3042
+ const fn = routes[toModel];
3043
+ convert[fromModel][toModel] = wrapRounded(fn);
3044
+ convert[fromModel][toModel].raw = wrapRaw(fn);
3045
+ });
3046
+ });
3047
+ colorConvert = convert;
3048
+ return colorConvert;
3049
+ }
3050
+ ansiStyles.exports;
3051
+ var hasRequiredAnsiStyles;
3052
+ function requireAnsiStyles() {
3053
+ if (hasRequiredAnsiStyles) return ansiStyles.exports;
3054
+ hasRequiredAnsiStyles = 1;
3055
+ (function(module2) {
3056
+ const wrapAnsi16 = (fn, offset) => (...args) => {
3057
+ const code = fn(...args);
3058
+ return `\x1B[${code + offset}m`;
3059
+ };
3060
+ const wrapAnsi256 = (fn, offset) => (...args) => {
3061
+ const code = fn(...args);
3062
+ return `\x1B[${38 + offset};5;${code}m`;
3063
+ };
3064
+ const wrapAnsi16m = (fn, offset) => (...args) => {
3065
+ const rgb = fn(...args);
3066
+ return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
3067
+ };
3068
+ const ansi2ansi = (n) => n;
3069
+ const rgb2rgb = (r, g, b) => [r, g, b];
3070
+ const setLazyProperty = (object, property, get) => {
3071
+ Object.defineProperty(object, property, {
3072
+ get: () => {
3073
+ const value = get();
3074
+ Object.defineProperty(object, property, {
3075
+ value,
3076
+ enumerable: true,
3077
+ configurable: true
3078
+ });
3079
+ return value;
3080
+ },
3081
+ enumerable: true,
3082
+ configurable: true
3083
+ });
3084
+ };
3085
+ let colorConvert2;
3086
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
3087
+ if (colorConvert2 === void 0) {
3088
+ colorConvert2 = requireColorConvert();
3089
+ }
3090
+ const offset = isBackground ? 10 : 0;
3091
+ const styles = {};
3092
+ for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
3093
+ const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
3094
+ if (sourceSpace === targetSpace) {
3095
+ styles[name] = wrap(identity, offset);
3096
+ } else if (typeof suite === "object") {
3097
+ styles[name] = wrap(suite[targetSpace], offset);
3098
+ }
3099
+ }
3100
+ return styles;
3101
+ };
3102
+ function assembleStyles() {
3103
+ const codes = /* @__PURE__ */ new Map();
3104
+ const styles = {
3105
+ modifier: {
3106
+ reset: [0, 0],
3107
+ // 21 isn't widely supported and 22 does the same thing
3108
+ bold: [1, 22],
3109
+ dim: [2, 22],
3110
+ italic: [3, 23],
3111
+ underline: [4, 24],
3112
+ inverse: [7, 27],
3113
+ hidden: [8, 28],
3114
+ strikethrough: [9, 29]
3115
+ },
3116
+ color: {
3117
+ black: [30, 39],
3118
+ red: [31, 39],
3119
+ green: [32, 39],
3120
+ yellow: [33, 39],
3121
+ blue: [34, 39],
3122
+ magenta: [35, 39],
3123
+ cyan: [36, 39],
3124
+ white: [37, 39],
3125
+ // Bright color
3126
+ blackBright: [90, 39],
3127
+ redBright: [91, 39],
3128
+ greenBright: [92, 39],
3129
+ yellowBright: [93, 39],
3130
+ blueBright: [94, 39],
3131
+ magentaBright: [95, 39],
3132
+ cyanBright: [96, 39],
3133
+ whiteBright: [97, 39]
3134
+ },
3135
+ bgColor: {
3136
+ bgBlack: [40, 49],
3137
+ bgRed: [41, 49],
3138
+ bgGreen: [42, 49],
3139
+ bgYellow: [43, 49],
3140
+ bgBlue: [44, 49],
3141
+ bgMagenta: [45, 49],
3142
+ bgCyan: [46, 49],
3143
+ bgWhite: [47, 49],
3144
+ // Bright color
3145
+ bgBlackBright: [100, 49],
3146
+ bgRedBright: [101, 49],
3147
+ bgGreenBright: [102, 49],
3148
+ bgYellowBright: [103, 49],
3149
+ bgBlueBright: [104, 49],
3150
+ bgMagentaBright: [105, 49],
3151
+ bgCyanBright: [106, 49],
3152
+ bgWhiteBright: [107, 49]
3153
+ }
3154
+ };
3155
+ styles.color.gray = styles.color.blackBright;
3156
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
3157
+ styles.color.grey = styles.color.blackBright;
3158
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
3159
+ for (const [groupName, group] of Object.entries(styles)) {
3160
+ for (const [styleName, style] of Object.entries(group)) {
3161
+ styles[styleName] = {
3162
+ open: `\x1B[${style[0]}m`,
3163
+ close: `\x1B[${style[1]}m`
3164
+ };
3165
+ group[styleName] = styles[styleName];
3166
+ codes.set(style[0], style[1]);
3167
+ }
3168
+ Object.defineProperty(styles, groupName, {
3169
+ value: group,
3170
+ enumerable: false
3171
+ });
3172
+ }
3173
+ Object.defineProperty(styles, "codes", {
3174
+ value: codes,
3175
+ enumerable: false
3176
+ });
3177
+ styles.color.close = "\x1B[39m";
3178
+ styles.bgColor.close = "\x1B[49m";
3179
+ setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
3180
+ setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
3181
+ setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
3182
+ setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
3183
+ setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
3184
+ setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
3185
+ return styles;
3186
+ }
3187
+ Object.defineProperty(module2, "exports", {
3188
+ enumerable: true,
3189
+ get: assembleStyles
3190
+ });
3191
+ })(ansiStyles);
3192
+ return ansiStyles.exports;
3193
+ }
3194
+ var browser;
3195
+ var hasRequiredBrowser;
3196
+ function requireBrowser() {
3197
+ if (hasRequiredBrowser) return browser;
3198
+ hasRequiredBrowser = 1;
3199
+ browser = {
3200
+ stdout: false,
3201
+ stderr: false
3202
+ };
3203
+ return browser;
3204
+ }
3205
+ var util;
3206
+ var hasRequiredUtil;
3207
+ function requireUtil() {
3208
+ if (hasRequiredUtil) return util;
3209
+ hasRequiredUtil = 1;
3210
+ const stringReplaceAll = (string, substring, replacer) => {
3211
+ let index = string.indexOf(substring);
3212
+ if (index === -1) {
3213
+ return string;
3214
+ }
3215
+ const substringLength = substring.length;
3216
+ let endIndex = 0;
3217
+ let returnValue = "";
3218
+ do {
3219
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
3220
+ endIndex = index + substringLength;
3221
+ index = string.indexOf(substring, endIndex);
3222
+ } while (index !== -1);
3223
+ returnValue += string.substr(endIndex);
3224
+ return returnValue;
3225
+ };
3226
+ const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
3227
+ let endIndex = 0;
3228
+ let returnValue = "";
3229
+ do {
3230
+ const gotCR = string[index - 1] === "\r";
3231
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
3232
+ endIndex = index + 1;
3233
+ index = string.indexOf("\n", endIndex);
3234
+ } while (index !== -1);
3235
+ returnValue += string.substr(endIndex);
3236
+ return returnValue;
3237
+ };
3238
+ util = {
3239
+ stringReplaceAll,
3240
+ stringEncaseCRLFWithFirstIndex
3241
+ };
3242
+ return util;
3243
+ }
3244
+ var templates;
3245
+ var hasRequiredTemplates;
3246
+ function requireTemplates() {
3247
+ if (hasRequiredTemplates) return templates;
3248
+ hasRequiredTemplates = 1;
3249
+ const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
3250
+ const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
3251
+ const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
3252
+ const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
3253
+ const ESCAPES = /* @__PURE__ */ new Map([
3254
+ ["n", "\n"],
3255
+ ["r", "\r"],
3256
+ ["t", " "],
3257
+ ["b", "\b"],
3258
+ ["f", "\f"],
3259
+ ["v", "\v"],
3260
+ ["0", "\0"],
3261
+ ["\\", "\\"],
3262
+ ["e", "\x1B"],
3263
+ ["a", "\x07"]
3264
+ ]);
3265
+ function unescape(c) {
3266
+ const u = c[0] === "u";
3267
+ const bracket = c[1] === "{";
3268
+ if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
3269
+ return String.fromCharCode(parseInt(c.slice(1), 16));
3270
+ }
3271
+ if (u && bracket) {
3272
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
3273
+ }
3274
+ return ESCAPES.get(c) || c;
3275
+ }
3276
+ function parseArguments(name, arguments_) {
3277
+ const results = [];
3278
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
3279
+ let matches;
3280
+ for (const chunk of chunks) {
3281
+ const number = Number(chunk);
3282
+ if (!Number.isNaN(number)) {
3283
+ results.push(number);
3284
+ } else if (matches = chunk.match(STRING_REGEX)) {
3285
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
3286
+ } else {
3287
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
3288
+ }
3289
+ }
3290
+ return results;
3291
+ }
3292
+ function parseStyle(style) {
3293
+ STYLE_REGEX.lastIndex = 0;
3294
+ const results = [];
3295
+ let matches;
3296
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
3297
+ const name = matches[1];
3298
+ if (matches[2]) {
3299
+ const args = parseArguments(name, matches[2]);
3300
+ results.push([name].concat(args));
3301
+ } else {
3302
+ results.push([name]);
3303
+ }
3304
+ }
3305
+ return results;
3306
+ }
3307
+ function buildStyle(chalk2, styles) {
3308
+ const enabled = {};
3309
+ for (const layer of styles) {
3310
+ for (const style of layer.styles) {
3311
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
3312
+ }
3313
+ }
3314
+ let current = chalk2;
3315
+ for (const [styleName, styles2] of Object.entries(enabled)) {
3316
+ if (!Array.isArray(styles2)) {
3317
+ continue;
3318
+ }
3319
+ if (!(styleName in current)) {
3320
+ throw new Error(`Unknown Chalk style: ${styleName}`);
3321
+ }
3322
+ current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
3323
+ }
3324
+ return current;
3325
+ }
3326
+ templates = (chalk2, temporary) => {
3327
+ const styles = [];
3328
+ const chunks = [];
3329
+ let chunk = [];
3330
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
3331
+ if (escapeCharacter) {
3332
+ chunk.push(unescape(escapeCharacter));
3333
+ } else if (style) {
3334
+ const string = chunk.join("");
3335
+ chunk = [];
3336
+ chunks.push(styles.length === 0 ? string : buildStyle(chalk2, styles)(string));
3337
+ styles.push({ inverse, styles: parseStyle(style) });
3338
+ } else if (close) {
3339
+ if (styles.length === 0) {
3340
+ throw new Error("Found extraneous } in Chalk template literal");
3341
+ }
3342
+ chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
3343
+ chunk = [];
3344
+ styles.pop();
3345
+ } else {
3346
+ chunk.push(character);
3347
+ }
3348
+ });
3349
+ chunks.push(chunk.join(""));
3350
+ if (styles.length > 0) {
3351
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
3352
+ throw new Error(errMessage);
3353
+ }
3354
+ return chunks.join("");
3355
+ };
3356
+ return templates;
3357
+ }
3358
+ var source;
3359
+ var hasRequiredSource;
3360
+ function requireSource() {
3361
+ if (hasRequiredSource) return source;
3362
+ hasRequiredSource = 1;
3363
+ const ansiStyles2 = requireAnsiStyles();
3364
+ const { stdout: stdoutColor, stderr: stderrColor } = requireBrowser();
3365
+ const {
3366
+ stringReplaceAll,
3367
+ stringEncaseCRLFWithFirstIndex
3368
+ } = requireUtil();
3369
+ const { isArray } = Array;
3370
+ const levelMapping = [
3371
+ "ansi",
3372
+ "ansi",
3373
+ "ansi256",
3374
+ "ansi16m"
3375
+ ];
3376
+ const styles = /* @__PURE__ */ Object.create(null);
3377
+ const applyOptions = (object, options = {}) => {
3378
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
3379
+ throw new Error("The `level` option should be an integer from 0 to 3");
3380
+ }
3381
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
3382
+ object.level = options.level === void 0 ? colorLevel : options.level;
3383
+ };
3384
+ class ChalkClass {
3385
+ constructor(options) {
3386
+ return chalkFactory(options);
3387
+ }
3388
+ }
3389
+ const chalkFactory = (options) => {
3390
+ const chalk3 = {};
3391
+ applyOptions(chalk3, options);
3392
+ chalk3.template = (...arguments_) => chalkTag(chalk3.template, ...arguments_);
3393
+ Object.setPrototypeOf(chalk3, Chalk.prototype);
3394
+ Object.setPrototypeOf(chalk3.template, chalk3);
3395
+ chalk3.template.constructor = () => {
3396
+ throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
3397
+ };
3398
+ chalk3.template.Instance = ChalkClass;
3399
+ return chalk3.template;
3400
+ };
3401
+ function Chalk(options) {
3402
+ return chalkFactory(options);
3403
+ }
3404
+ for (const [styleName, style] of Object.entries(ansiStyles2)) {
3405
+ styles[styleName] = {
3406
+ get() {
3407
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
3408
+ Object.defineProperty(this, styleName, { value: builder });
3409
+ return builder;
3410
+ }
3411
+ };
3412
+ }
3413
+ styles.visible = {
3414
+ get() {
3415
+ const builder = createBuilder(this, this._styler, true);
3416
+ Object.defineProperty(this, "visible", { value: builder });
3417
+ return builder;
3418
+ }
3419
+ };
3420
+ const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
3421
+ for (const model of usedModels) {
3422
+ styles[model] = {
3423
+ get() {
3424
+ const { level } = this;
3425
+ return function(...arguments_) {
3426
+ const styler = createStyler(ansiStyles2.color[levelMapping[level]][model](...arguments_), ansiStyles2.color.close, this._styler);
3427
+ return createBuilder(this, styler, this._isEmpty);
3428
+ };
3429
+ }
3430
+ };
3431
+ }
3432
+ for (const model of usedModels) {
3433
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
3434
+ styles[bgModel] = {
3435
+ get() {
3436
+ const { level } = this;
3437
+ return function(...arguments_) {
3438
+ const styler = createStyler(ansiStyles2.bgColor[levelMapping[level]][model](...arguments_), ansiStyles2.bgColor.close, this._styler);
3439
+ return createBuilder(this, styler, this._isEmpty);
3440
+ };
3441
+ }
3442
+ };
3443
+ }
3444
+ const proto = Object.defineProperties(() => {
3445
+ }, {
3446
+ ...styles,
3447
+ level: {
3448
+ enumerable: true,
3449
+ get() {
3450
+ return this._generator.level;
3451
+ },
3452
+ set(level) {
3453
+ this._generator.level = level;
3454
+ }
3455
+ }
3456
+ });
3457
+ const createStyler = (open, close, parent) => {
3458
+ let openAll;
3459
+ let closeAll;
3460
+ if (parent === void 0) {
3461
+ openAll = open;
3462
+ closeAll = close;
3463
+ } else {
3464
+ openAll = parent.openAll + open;
3465
+ closeAll = close + parent.closeAll;
3466
+ }
3467
+ return {
3468
+ open,
3469
+ close,
3470
+ openAll,
3471
+ closeAll,
3472
+ parent
3473
+ };
3474
+ };
3475
+ const createBuilder = (self, _styler, _isEmpty) => {
3476
+ const builder = (...arguments_) => {
3477
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
3478
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
3479
+ }
3480
+ return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
3481
+ };
3482
+ Object.setPrototypeOf(builder, proto);
3483
+ builder._generator = self;
3484
+ builder._styler = _styler;
3485
+ builder._isEmpty = _isEmpty;
3486
+ return builder;
3487
+ };
3488
+ const applyStyle = (self, string) => {
3489
+ if (self.level <= 0 || !string) {
3490
+ return self._isEmpty ? "" : string;
3491
+ }
3492
+ let styler = self._styler;
3493
+ if (styler === void 0) {
3494
+ return string;
3495
+ }
3496
+ const { openAll, closeAll } = styler;
3497
+ if (string.indexOf("\x1B") !== -1) {
3498
+ while (styler !== void 0) {
3499
+ string = stringReplaceAll(string, styler.close, styler.open);
3500
+ styler = styler.parent;
3501
+ }
3502
+ }
3503
+ const lfIndex = string.indexOf("\n");
3504
+ if (lfIndex !== -1) {
3505
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
3506
+ }
3507
+ return openAll + string + closeAll;
3508
+ };
3509
+ let template;
3510
+ const chalkTag = (chalk3, ...strings) => {
3511
+ const [firstString] = strings;
3512
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
3513
+ return strings.join(" ");
3514
+ }
3515
+ const arguments_ = strings.slice(1);
3516
+ const parts = [firstString.raw[0]];
3517
+ for (let i = 1; i < firstString.length; i++) {
3518
+ parts.push(
3519
+ String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
3520
+ String(firstString.raw[i])
3521
+ );
3522
+ }
3523
+ if (template === void 0) {
3524
+ template = requireTemplates();
3525
+ }
3526
+ return template(chalk3, parts.join(""));
3527
+ };
3528
+ Object.defineProperties(Chalk.prototype, styles);
3529
+ const chalk2 = Chalk();
3530
+ chalk2.supportsColor = stdoutColor;
3531
+ chalk2.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
3532
+ chalk2.stderr.supportsColor = stderrColor;
3533
+ source = chalk2;
3534
+ return source;
3535
+ }
3536
+ var sourceExports = requireSource();
3537
+ const chalk = /* @__PURE__ */ getDefaultExportFromCjs(sourceExports);
3538
+ var StatusCodes;
3539
+ (function(StatusCodes2) {
3540
+ StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
3541
+ StatusCodes2[StatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
3542
+ StatusCodes2[StatusCodes2["PROCESSING"] = 102] = "PROCESSING";
3543
+ StatusCodes2[StatusCodes2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
3544
+ StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
3545
+ StatusCodes2[StatusCodes2["CREATED"] = 201] = "CREATED";
3546
+ StatusCodes2[StatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
3547
+ StatusCodes2[StatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
3548
+ StatusCodes2[StatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
3549
+ StatusCodes2[StatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
3550
+ StatusCodes2[StatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
3551
+ StatusCodes2[StatusCodes2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
3552
+ StatusCodes2[StatusCodes2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
3553
+ StatusCodes2[StatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
3554
+ StatusCodes2[StatusCodes2["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY";
3555
+ StatusCodes2[StatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
3556
+ StatusCodes2[StatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
3557
+ StatusCodes2[StatusCodes2["USE_PROXY"] = 305] = "USE_PROXY";
3558
+ StatusCodes2[StatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
3559
+ StatusCodes2[StatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
3560
+ StatusCodes2[StatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
3561
+ StatusCodes2[StatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
3562
+ StatusCodes2[StatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
3563
+ StatusCodes2[StatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
3564
+ StatusCodes2[StatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
3565
+ StatusCodes2[StatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
3566
+ StatusCodes2[StatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
3567
+ StatusCodes2[StatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
3568
+ StatusCodes2[StatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
3569
+ StatusCodes2[StatusCodes2["CONFLICT"] = 409] = "CONFLICT";
3570
+ StatusCodes2[StatusCodes2["GONE"] = 410] = "GONE";
3571
+ StatusCodes2[StatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
3572
+ StatusCodes2[StatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
3573
+ StatusCodes2[StatusCodes2["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG";
3574
+ StatusCodes2[StatusCodes2["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
3575
+ StatusCodes2[StatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
3576
+ StatusCodes2[StatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
3577
+ StatusCodes2[StatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
3578
+ StatusCodes2[StatusCodes2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
3579
+ StatusCodes2[StatusCodes2["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE";
3580
+ StatusCodes2[StatusCodes2["METHOD_FAILURE"] = 420] = "METHOD_FAILURE";
3581
+ StatusCodes2[StatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
3582
+ StatusCodes2[StatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
3583
+ StatusCodes2[StatusCodes2["LOCKED"] = 423] = "LOCKED";
3584
+ StatusCodes2[StatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
3585
+ StatusCodes2[StatusCodes2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
3586
+ StatusCodes2[StatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
3587
+ StatusCodes2[StatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
3588
+ StatusCodes2[StatusCodes2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
3589
+ StatusCodes2[StatusCodes2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
3590
+ StatusCodes2[StatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
3591
+ StatusCodes2[StatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
3592
+ StatusCodes2[StatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
3593
+ StatusCodes2[StatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
3594
+ StatusCodes2[StatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
3595
+ StatusCodes2[StatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
3596
+ StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
3597
+ StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
3598
+ })(StatusCodes || (StatusCodes = {}));
3599
+ class AxiosClient {
3600
+ #options;
3601
+ #DUMMY_USER = "USR_user01@stsmda.com.au";
3602
+ //@@ needs to come from headers ??
3603
+ #invokeMethods = {};
3604
+ #maxRetries = 5;
3605
+ #sleepDuration = [50, 100, 200, 500, 1e3, 2e3, 5e3];
3606
+ #NoRetryStatusCodes = [
3607
+ StatusCodes.NOT_FOUND,
3608
+ StatusCodes.CONFLICT
3609
+ ];
3610
+ #accessToken = null;
3611
+ #noRetries = false;
3612
+ constructor(options) {
3613
+ this.#options = options;
3614
+ }
3615
+ get options() {
3616
+ return this.#options;
3617
+ }
3618
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3619
+ #LogDebugMessage = (message) => {
3620
+ this.#options.logger.debug(message);
3621
+ };
3622
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3623
+ #LogErrorMessage = (message) => {
3624
+ this.#options.logger.error(message);
3625
+ };
3626
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3627
+ HandleError = (error) => {
3628
+ this.#LogDebugMessage(chalk.red(`HandleError(): Error: [${error}]`));
3629
+ let responseCode = 500;
3630
+ if (axios.isAxiosError(error)) {
3631
+ const axiosError = error;
3632
+ if (axiosError.response) {
3633
+ responseCode = axiosError.response.status;
3634
+ this.#LogDebugMessage(chalk.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
3635
+ if (axiosError.response.headers) {
3636
+ this.#LogErrorMessage(chalk.red(` headers: [${JSON.stringify(axiosError.response.headers)}]`));
3637
+ }
3638
+ if (axiosError.response.data) {
3639
+ this.#LogErrorMessage(chalk.red(` data: [${JSON.stringify(axiosError.response.data)}]`));
3640
+ }
3641
+ try {
3642
+ if (axiosError.response.config) {
3643
+ this.#LogErrorMessage(chalk.red(` config: [${JSON.stringify(axiosError.response.config)}]`));
3644
+ }
3645
+ } catch (innererror) {
3646
+ this.#LogErrorMessage(chalk.red(` could not get response config, error: [${innererror}]`));
3647
+ }
3648
+ } else {
3649
+ this.#LogDebugMessage(chalk.red(`AXIOS Error = [${axiosError}]`));
3650
+ }
3651
+ }
3652
+ return responseCode;
3653
+ };
3654
+ #TestMode = (metaData, errorCb) => {
3655
+ const { id, url, httpVerb, filters, retries } = metaData;
3656
+ if (retries < 1) {
3657
+ errorCb(401, new Error(`Testing Error Only. Error Code: [401], Message ID: [${id}, url: [${url}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
3658
+ return true;
3659
+ }
3660
+ if (retries < 2) {
3661
+ errorCb(500, new Error(`Testing Error Only. Error Code: [500], Message ID: [${id}, url: [${url}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
3662
+ return true;
3663
+ }
3664
+ return false;
3665
+ };
3666
+ #__InvokeResourceAPI = async (metaData, errorCb) => {
3667
+ try {
3668
+ const { url, httpVerb, resource, filters } = metaData;
3669
+ if (this.#options.testingMode) {
3670
+ if (this.#TestMode(metaData, errorCb)) {
3671
+ return null;
3672
+ }
3673
+ }
3674
+ let accessToken = null;
3675
+ if (this.#accessToken) {
3676
+ accessToken = this.#accessToken;
3677
+ this.#accessToken = null;
3678
+ } else {
3679
+ accessToken = await this.#options.GetAccessToken();
3680
+ }
3681
+ let requestConfig = new stsutils.STSAxiosConfig(url, httpVerb).withDefaultHeaders().withAuthHeaders(accessToken, this.#DUMMY_USER);
3682
+ if (!(httpVerb.localeCompare("get") === 0 || httpVerb.localeCompare("head") === 0)) {
3683
+ requestConfig.withData(filters ? filters : resource ? resource : void 0);
3684
+ }
3685
+ if (isNode && this.#options.agentManager) {
3686
+ requestConfig.withAgentManager(this.#options.agentManager);
3687
+ }
3688
+ return await axios(requestConfig.config);
3689
+ } catch (error) {
3690
+ const responseCode = this.HandleError(error);
3691
+ errorCb(responseCode, error);
3692
+ return null;
3693
+ }
3694
+ };
3695
+ WithAccessToken = (accessToken) => {
3696
+ this.#accessToken = accessToken;
3697
+ return this;
3698
+ };
3699
+ WithNoRetries = () => {
3700
+ this.#noRetries = true;
3701
+ return this;
3702
+ };
3703
+ InvokeResourceAPI = async (url, httpVerb, resource, filters, searchParams, errorCb) => {
3704
+ const id = v4();
3705
+ this.#invokeMethods[id] = {
3706
+ id,
3707
+ retries: 0,
3708
+ testFailIndexBefore: 1,
3709
+ url,
3710
+ httpVerb,
3711
+ resource,
3712
+ filters,
3713
+ searchParams,
3714
+ errorCb
3715
+ };
3716
+ let returnError = null;
3717
+ const InvokeAPI = async (id2) => {
3718
+ const metadataRecord = this.#invokeMethods[id2];
3719
+ let performRetry = false;
3720
+ const returnData = await this.#__InvokeResourceAPI(metadataRecord, (statusCode, error) => {
3721
+ if (this.#noRetries === false) {
3722
+ const noRetryIndex = this.#NoRetryStatusCodes.indexOf(statusCode);
3723
+ if (noRetryIndex === -1) {
3724
+ if (statusCode === StatusCodes.UNAUTHORIZED) {
3725
+ this.#options.ResetAccessToken();
3726
+ if (this.#options.clientTelemetryEvents) {
3727
+ this.#options.clientTelemetryEvents.AuthenticationErrorInc();
3728
+ }
3729
+ }
3730
+ if (isNode && this.#options.agentManager) {
3731
+ this.#options.agentManager.ResetAgent();
3732
+ }
3733
+ performRetry = true;
3734
+ } else {
3735
+ returnError = error;
3736
+ }
3737
+ } else {
3738
+ returnError = error;
3739
+ this.#noRetries = false;
3740
+ }
3741
+ });
3742
+ return {
3743
+ response: returnData,
3744
+ retry: performRetry
3745
+ };
3746
+ };
3747
+ let retVal = null;
3748
+ while (this.#invokeMethods[id].retries < this.#maxRetries) {
3749
+ retVal = await InvokeAPI(id);
3750
+ if (retVal.retry === false) {
3751
+ delete this.#invokeMethods[id];
3752
+ break;
3753
+ } else {
3754
+ await stsutils.Sleep(this.#sleepDuration[this.#invokeMethods[id].retries]);
3755
+ this.#invokeMethods[id].retries++;
3756
+ if (this.#options.clientTelemetryEvents) {
3757
+ this.#options.clientTelemetryEvents.RetryInc();
3758
+ }
3759
+ }
3760
+ }
3761
+ if (retVal) {
3762
+ if (retVal.retry === true) {
3763
+ errorCb(new Error(`#InvokeResourceAPI(): Max retries exceeded. Max Retries: [${this.#invokeMethods[id].retries}]`));
3764
+ delete this.#invokeMethods[id];
3765
+ return null;
3766
+ } else {
3767
+ if (returnError) {
3768
+ errorCb(returnError);
3769
+ }
3770
+ return retVal.response;
3771
+ }
3772
+ } else {
3773
+ if (returnError) {
3774
+ errorCb(returnError);
3775
+ }
3776
+ return null;
3777
+ }
3778
+ };
3779
+ }
3780
+ class STSRest01Client {
3781
+ #axiosClient;
3782
+ #options;
3783
+ constructor(options) {
3784
+ this.#options = options;
3785
+ this.#axiosClient = new AxiosClient({
3786
+ logger: options.logger,
3787
+ testingMode: options.testingMode,
3788
+ GetAccessToken: options.GetAccessToken,
3789
+ ResetAccessToken: options.ResetAccessToken,
3790
+ agentManager: options.agentManager,
3791
+ clientTelemetryEvents: options.clientTelemetryEvents
3792
+ });
3793
+ }
3794
+ HandleError = (error) => {
3795
+ return this.#axiosClient.HandleError(error);
3796
+ };
3797
+ WithNoRetries = () => {
3798
+ this.#axiosClient.WithNoRetries();
3799
+ return this;
3800
+ };
3801
+ WithAccessToken = (accessToken) => {
3802
+ this.#axiosClient.WithAccessToken(accessToken);
3803
+ return this;
3804
+ };
3805
+ // --- [ Resource ] -------------------------------------------------------------------------------------------------------------------
3806
+ // --- [ POST.Resource ] -------------------------------------------------------------------------------------------------------------------
3807
+ PostResourceAR = async (resource, errorCb) => {
3808
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources`;
3809
+ return await this.#axiosClient.InvokeResourceAPI(url, "post", resource, null, null, errorCb);
3810
+ };
3811
+ PostResourceDBR = async (resource, errorCb) => {
3812
+ return (await this.PostResourceAR(resource, errorCb))?.data.detail ?? null;
3813
+ };
3814
+ PostResource = async (resource, errorCb) => {
3815
+ return (await this.PostResourceDBR(resource, errorCb))?.resdesc ?? null;
3816
+ };
3817
+ // --- [ PUT.Resources ] ------------------------------------------------------------------------------------------------------------------
3818
+ PutResourcesAR = async (resources, errorCb) => {
3819
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources`;
3820
+ return await this.#axiosClient.InvokeResourceAPI(url, "put", resources, null, null, errorCb);
3821
+ };
3822
+ PutResourcesDBR = async (resources, errorCb) => {
3823
+ return (await this.PutResourcesAR(resources, errorCb))?.data.map((r) => r.detail) ?? null;
3824
+ };
3825
+ PutResources = async (resources, errorCb) => {
3826
+ return (await this.PutResourcesDBR(resources, errorCb))?.map((r) => r.resdesc) ?? null;
3827
+ };
3828
+ // --- [ PUT.Resource ] -------------------------------------------------------------------------------------------------------------------
3829
+ PutResourceAR = async (resource, errorCb) => {
3830
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resource.resname}`;
3831
+ return this.#axiosClient.InvokeResourceAPI(url, "put", resource, null, null, errorCb);
3832
+ };
3833
+ PutResourceDBR = async (resource, errorCb) => {
3834
+ return (await this.PutResourceAR(resource, errorCb))?.data.detail ?? null;
3835
+ };
3836
+ PutResource = async (resource, errorCb) => {
3837
+ return (await this.PutResourceDBR(resource, errorCb))?.resdesc ?? null;
3838
+ };
3839
+ // --- [ PATCH.Resources ] ------------------------------------------------------------------------------------------------------------------
3840
+ PatchResourcesAR = async (resources, errorCb) => {
3841
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources`;
3842
+ return await this.#axiosClient.InvokeResourceAPI(url, "patch", resources, null, null, errorCb);
3843
+ };
3844
+ PatchResourcesDBR = async (resources, errorCb) => {
3845
+ return (await this.PatchResourcesAR(resources, errorCb))?.data.map((r) => r.detail) ?? null;
3846
+ };
3847
+ PatchResources = async (resources, errorCb) => {
3848
+ return (await this.PatchResourcesDBR(resources, errorCb))?.map((r) => r.resdesc) ?? null;
3849
+ };
3850
+ // --- [ PATCH.Resource ] -------------------------------------------------------------------------------------------------------------------
3851
+ PatchResourceAR = async (resource, errorCb) => {
3852
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resource.resname}`;
3853
+ return this.#axiosClient.InvokeResourceAPI(url, "patch", resource, null, null, errorCb);
3854
+ };
3855
+ PatchResourceDBR = async (resource, errorCb) => {
3856
+ return (await this.PatchResourceAR(resource, errorCb))?.data.detail ?? null;
3857
+ };
3858
+ PatchResource = async (resource, errorCb) => {
3859
+ return (await this.PatchResourceDBR(resource, errorCb))?.resdesc ?? null;
3860
+ };
3861
+ // --- [ DELETE.Resources ] -------------------------------------------------------------------------------------------------------------------
3862
+ DeleteResourcesAR = async (resources, errorCb) => {
3863
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources`;
3864
+ return await this.#axiosClient.InvokeResourceAPI(url, "delete", resources, null, null, errorCb);
3865
+ };
3866
+ DeleteResourcesDBR = async (resources, errorCb) => {
3867
+ return (await this.DeleteResourcesAR(resources, errorCb))?.data.map((r) => r.detail) ?? null;
3868
+ };
3869
+ DeleteResources = async (resources, errorCb) => {
3870
+ return (await this.DeleteResourcesDBR(resources, errorCb))?.map((r) => r.resdesc) ?? null;
3871
+ };
3872
+ // --- [ DELETE.Resource ] -------------------------------------------------------------------------------------------------------------------
3873
+ DeleteResourceAR = async (resource, errorCb) => {
3874
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resource.resname}`;
3875
+ return this.#axiosClient.InvokeResourceAPI(url, "delete", resource, null, null, errorCb);
3876
+ };
3877
+ DeleteResourceDBR = async (resource, errorCb) => {
3878
+ return (await this.DeleteResourceAR(resource, errorCb))?.data.detail ?? null;
3879
+ };
3880
+ DeleteResource = async (resource, errorCb) => {
3881
+ return (await this.DeleteResourceDBR(resource, errorCb))?.resdesc ?? null;
3882
+ };
3883
+ // --- [ GET.Resource ] -------------------------------------------------------------------------------------------------------------------
3884
+ GetResourceAR = async (resource, filters, errorCb) => {
3885
+ let url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resource.resname}`;
3886
+ if (filters && filters.localeCompare("") !== 0) {
3887
+ url = `${url}?${filters}`;
3888
+ }
3889
+ return this.#axiosClient.InvokeResourceAPI(url, "get", null, null, null, errorCb);
3890
+ };
3891
+ GetResourceDBR = async (resource, filters, errorCb) => {
3892
+ return (await this.GetResourceAR(resource, filters, errorCb))?.data.detail ?? null;
3893
+ };
3894
+ GetResource = async (resource, filters, errorCb) => {
3895
+ return (await this.GetResourceDBR(resource, filters, errorCb))?.resdesc ?? null;
3896
+ };
3897
+ // --- [ GET.Resources ] -------------------------------------------------------------------------------------------------------------------
3898
+ GetResourcesAR = async (filters, errorCb) => {
3899
+ let url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources`;
3900
+ if (filters && filters.localeCompare("") !== 0) {
3901
+ url = `${url}?${filters}`;
3902
+ }
3903
+ return this.#axiosClient.InvokeResourceAPI(url, "get", null, null, null, errorCb);
3904
+ };
3905
+ GetResourcesDBR = async (filters, errorCb) => {
3906
+ return (await this.GetResourcesAR(filters, errorCb))?.data.detail ?? null;
3907
+ };
3908
+ GetResources = async (filters, errorCb) => {
3909
+ return (await this.GetResourcesDBR(filters, errorCb))?.map((r) => r.resdesc) ?? null;
3910
+ };
3911
+ // --- [ Entity ] -------------------------------------------------------------------------------------------------------------------
3912
+ #checkResName = (resourceEntities) => {
3913
+ let resName = "";
3914
+ resourceEntities.forEach((re) => {
3915
+ resName = resName.localeCompare("") === 0 ? re.resname : resName;
3916
+ if (resName.localeCompare(re.resname) !== 0) {
3917
+ throw new Error(`Invalid batch provided. resname not all equal. Previous checked value: [${resName}, current value: [${re.resname}]`);
3918
+ } else {
3919
+ resName = re.resname;
3920
+ }
3921
+ });
3922
+ return resName;
3923
+ };
3924
+ // --- [ POST.Entitiy ] -------------------------------------------------------------------------------------------------------------------
3925
+ PostEntityAR = async (resourceEntity, errorCb) => {
3926
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resourceEntity.resname}/entities`;
3927
+ return this.#axiosClient.InvokeResourceAPI(url, "post", resourceEntity, null, null, errorCb);
3928
+ };
3929
+ PostEntityDBR = async (resourceEntity, errorCb) => {
3930
+ return (await this.PostEntityAR(resourceEntity, errorCb))?.data.detail ?? null;
3931
+ };
3932
+ PostEntity = async (resourceEntity, errorCb) => {
3933
+ return (await this.PostEntityDBR(resourceEntity, errorCb))?.entvalue ?? null;
3934
+ };
3935
+ // --- [ PUT.Entities ] -----------------------------------------------------------------------------------------------------------------
3936
+ PutEntitiesAR = async (resourceEntities, errorCb) => {
3937
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${this.#checkResName(resourceEntities)}/entities`;
3938
+ return this.#axiosClient.InvokeResourceAPI(url, "put", resourceEntities, null, null, errorCb);
3939
+ };
3940
+ PutEntitiesDBR = async (resourceEntities, errorCb) => {
3941
+ return (await this.PutEntitiesAR(resourceEntities, errorCb))?.data.map((r) => r.detail) ?? null;
3942
+ };
3943
+ PutEntities = async (resourceEntities, errorCb) => {
3944
+ return (await this.PutEntitiesDBR(resourceEntities, errorCb))?.map((r) => r.entvalue) ?? null;
3945
+ };
3946
+ // --- [ PUT.Entity ] -------------------------------------------------------------------------------------------------------------------
3947
+ PutEntityAR = async (entity, errorCb) => {
3948
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${entity.resname}/entities/${entity.entname}`;
3949
+ return this.#axiosClient.InvokeResourceAPI(url, "put", entity, null, null, errorCb);
3950
+ };
3951
+ PutEntityDBR = async (resourceEntity, errorCb) => {
3952
+ return (await this.PutEntityAR(resourceEntity, errorCb))?.data.detail ?? null;
3953
+ };
3954
+ PutEntity = async (resourceEntity, errorCb) => {
3955
+ return (await this.PutEntityDBR(resourceEntity, errorCb))?.entvalue ?? null;
3956
+ };
3957
+ // --- [ PATCH.Entities ] -----------------------------------------------------------------------------------------------------------------
3958
+ PatchEntitiesAR = async (resourceEntities, errorCb) => {
3959
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${this.#checkResName(resourceEntities)}/entities`;
3960
+ return this.#axiosClient.InvokeResourceAPI(url, "patch", resourceEntities, null, null, errorCb);
3961
+ };
3962
+ PatchEntitiesDBR = async (resourceEntities, errorCb) => {
3963
+ return (await this.PatchEntitiesAR(resourceEntities, errorCb))?.data.map((r) => r.detail) ?? null;
3964
+ };
3965
+ PatchEntities = async (resourceEntities, errorCb) => {
3966
+ return (await this.PatchEntitiesDBR(resourceEntities, errorCb))?.map((r) => r.entvalue) ?? null;
3967
+ };
3968
+ // --- [ PATCH.Entity ] -------------------------------------------------------------------------------------------------------------------
3969
+ PatchEntityAR = async (resourceEntity, errorCb) => {
3970
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resourceEntity.resname}/entities/${resourceEntity.entname}`;
3971
+ return this.#axiosClient.InvokeResourceAPI(url, "patch", resourceEntity, null, null, errorCb);
3972
+ };
3973
+ PatchEntityDBR = async (resourceEntity, errorCb) => {
3974
+ return (await this.PatchEntityAR(resourceEntity, errorCb))?.data.detail ?? null;
3975
+ };
3976
+ PatchEntity = async (resourceEntity, errorCb) => {
3977
+ return (await this.PatchEntityDBR(resourceEntity, errorCb))?.entvalue ?? null;
3978
+ };
3979
+ // --- [ DELETE.Entity ] -------------------------------------------------------------------------------------------------------------------
3980
+ DeleteEntitiesAR = async (resourceEntities, errorCb) => {
3981
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${this.#checkResName(resourceEntities)}/entities`;
3982
+ return this.#axiosClient.InvokeResourceAPI(url, "delete", resourceEntities, null, null, errorCb);
3983
+ };
3984
+ DeleteEntitiesDBR = async (resourceEntities, errorCb) => {
3985
+ return (await this.DeleteEntitiesAR(resourceEntities, errorCb))?.data.map((r) => r.detail) ?? null;
3986
+ };
3987
+ DeleteEntities = async (resourceEntities, errorCb) => {
3988
+ return (await this.DeleteEntitiesDBR(resourceEntities, errorCb))?.map((r) => r.entvalue) ?? null;
3989
+ };
3990
+ // --- [ DELETE.Entity ] -------------------------------------------------------------------------------------------------------------------
3991
+ DeleteEntityAR = async (resourceEntity, errorCb) => {
3992
+ const url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resourceEntity.resname}/entities/${resourceEntity.entname}`;
3993
+ return this.#axiosClient.InvokeResourceAPI(url, "delete", resourceEntity, null, null, errorCb);
3994
+ };
3995
+ DeleteEntityDBR = async (resourceEntity, errorCb) => {
3996
+ return (await this.DeleteEntityAR(resourceEntity, errorCb))?.data.detail ?? null;
3997
+ };
3998
+ DeleteEntity = async (resourceEntity, errorCb) => {
3999
+ return (await this.DeleteEntityDBR(resourceEntity, errorCb))?.entvalue ?? null;
4000
+ };
4001
+ // --- [ GET.Entity ] -------------------------------------------------------------------------------------------------------------------
4002
+ GetEntityAR = async (resourceEntity, filters, errorCb) => {
4003
+ let url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resourceEntity.resname}/entities/${resourceEntity.entname}`;
4004
+ if (filters && filters.localeCompare("") !== 0) {
4005
+ url = `${url}?${filters}`;
4006
+ }
4007
+ return this.#axiosClient.InvokeResourceAPI(url, "get", null, null, null, errorCb);
4008
+ };
4009
+ GetEntityDBR = async (resourceEntity, filters, errorCb) => {
4010
+ return (await this.GetEntityAR(resourceEntity, filters, errorCb))?.data.detail ?? null;
4011
+ };
4012
+ GetEntity = async (resourceEntity, filters, errorCb) => {
4013
+ return (await this.GetEntityDBR(resourceEntity, filters, errorCb))?.entvalue ?? null;
4014
+ };
4015
+ // --- [ GET.Entities ] -------------------------------------------------------------------------------------------------------------------
4016
+ GetEntitiesAR = async (resource, filters, errorCb) => {
4017
+ let url = `${this.#options.endpoint}${goptions.rest01apiroot}/resources/${resource.resname}/entities`;
4018
+ if (filters && filters.localeCompare("") !== 0) {
4019
+ url = `${url}?${filters}`;
4020
+ }
4021
+ return this.#axiosClient.InvokeResourceAPI(url, "get", null, null, null, errorCb);
4022
+ };
4023
+ GetEntitiesDBR = async (resource, filters, errorCb) => {
4024
+ return (await this.GetEntitiesAR(resource, filters, errorCb))?.data.detail ?? null;
4025
+ };
4026
+ GetEntities = async (resource, filters, errorCb) => {
4027
+ return (await this.GetEntitiesDBR(resource, filters, errorCb))?.map((r) => r.entvalue) ?? null;
4028
+ };
4029
+ }
4030
+ exports.AxiosClient = AxiosClient;
4031
+ exports.STSRest01Client = STSRest01Client;
4032
+ //# sourceMappingURL=stsrest01client.cjs.map