@nsshunt/stsoauth2plugin 1.0.44 → 1.0.46
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.
package/dist/stsoauth2plugin.mjs
CHANGED
|
@@ -43,7 +43,6 @@ import "colors";
|
|
|
43
43
|
import axios from "axios";
|
|
44
44
|
import { Gauge } from "@nsshunt/stsinstrumentation";
|
|
45
45
|
const STSOAuth2ManagerPluginKey = Symbol();
|
|
46
|
-
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
47
46
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
48
47
|
function getDefaultExportFromCjs(x) {
|
|
49
48
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -74,6 +73,1436 @@ function getAugmentedNamespace(n) {
|
|
|
74
73
|
});
|
|
75
74
|
return a;
|
|
76
75
|
}
|
|
76
|
+
var ansiStyles$1 = { exports: {} };
|
|
77
|
+
var colorName;
|
|
78
|
+
var hasRequiredColorName;
|
|
79
|
+
function requireColorName() {
|
|
80
|
+
if (hasRequiredColorName)
|
|
81
|
+
return colorName;
|
|
82
|
+
hasRequiredColorName = 1;
|
|
83
|
+
colorName = {
|
|
84
|
+
"aliceblue": [240, 248, 255],
|
|
85
|
+
"antiquewhite": [250, 235, 215],
|
|
86
|
+
"aqua": [0, 255, 255],
|
|
87
|
+
"aquamarine": [127, 255, 212],
|
|
88
|
+
"azure": [240, 255, 255],
|
|
89
|
+
"beige": [245, 245, 220],
|
|
90
|
+
"bisque": [255, 228, 196],
|
|
91
|
+
"black": [0, 0, 0],
|
|
92
|
+
"blanchedalmond": [255, 235, 205],
|
|
93
|
+
"blue": [0, 0, 255],
|
|
94
|
+
"blueviolet": [138, 43, 226],
|
|
95
|
+
"brown": [165, 42, 42],
|
|
96
|
+
"burlywood": [222, 184, 135],
|
|
97
|
+
"cadetblue": [95, 158, 160],
|
|
98
|
+
"chartreuse": [127, 255, 0],
|
|
99
|
+
"chocolate": [210, 105, 30],
|
|
100
|
+
"coral": [255, 127, 80],
|
|
101
|
+
"cornflowerblue": [100, 149, 237],
|
|
102
|
+
"cornsilk": [255, 248, 220],
|
|
103
|
+
"crimson": [220, 20, 60],
|
|
104
|
+
"cyan": [0, 255, 255],
|
|
105
|
+
"darkblue": [0, 0, 139],
|
|
106
|
+
"darkcyan": [0, 139, 139],
|
|
107
|
+
"darkgoldenrod": [184, 134, 11],
|
|
108
|
+
"darkgray": [169, 169, 169],
|
|
109
|
+
"darkgreen": [0, 100, 0],
|
|
110
|
+
"darkgrey": [169, 169, 169],
|
|
111
|
+
"darkkhaki": [189, 183, 107],
|
|
112
|
+
"darkmagenta": [139, 0, 139],
|
|
113
|
+
"darkolivegreen": [85, 107, 47],
|
|
114
|
+
"darkorange": [255, 140, 0],
|
|
115
|
+
"darkorchid": [153, 50, 204],
|
|
116
|
+
"darkred": [139, 0, 0],
|
|
117
|
+
"darksalmon": [233, 150, 122],
|
|
118
|
+
"darkseagreen": [143, 188, 143],
|
|
119
|
+
"darkslateblue": [72, 61, 139],
|
|
120
|
+
"darkslategray": [47, 79, 79],
|
|
121
|
+
"darkslategrey": [47, 79, 79],
|
|
122
|
+
"darkturquoise": [0, 206, 209],
|
|
123
|
+
"darkviolet": [148, 0, 211],
|
|
124
|
+
"deeppink": [255, 20, 147],
|
|
125
|
+
"deepskyblue": [0, 191, 255],
|
|
126
|
+
"dimgray": [105, 105, 105],
|
|
127
|
+
"dimgrey": [105, 105, 105],
|
|
128
|
+
"dodgerblue": [30, 144, 255],
|
|
129
|
+
"firebrick": [178, 34, 34],
|
|
130
|
+
"floralwhite": [255, 250, 240],
|
|
131
|
+
"forestgreen": [34, 139, 34],
|
|
132
|
+
"fuchsia": [255, 0, 255],
|
|
133
|
+
"gainsboro": [220, 220, 220],
|
|
134
|
+
"ghostwhite": [248, 248, 255],
|
|
135
|
+
"gold": [255, 215, 0],
|
|
136
|
+
"goldenrod": [218, 165, 32],
|
|
137
|
+
"gray": [128, 128, 128],
|
|
138
|
+
"green": [0, 128, 0],
|
|
139
|
+
"greenyellow": [173, 255, 47],
|
|
140
|
+
"grey": [128, 128, 128],
|
|
141
|
+
"honeydew": [240, 255, 240],
|
|
142
|
+
"hotpink": [255, 105, 180],
|
|
143
|
+
"indianred": [205, 92, 92],
|
|
144
|
+
"indigo": [75, 0, 130],
|
|
145
|
+
"ivory": [255, 255, 240],
|
|
146
|
+
"khaki": [240, 230, 140],
|
|
147
|
+
"lavender": [230, 230, 250],
|
|
148
|
+
"lavenderblush": [255, 240, 245],
|
|
149
|
+
"lawngreen": [124, 252, 0],
|
|
150
|
+
"lemonchiffon": [255, 250, 205],
|
|
151
|
+
"lightblue": [173, 216, 230],
|
|
152
|
+
"lightcoral": [240, 128, 128],
|
|
153
|
+
"lightcyan": [224, 255, 255],
|
|
154
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
155
|
+
"lightgray": [211, 211, 211],
|
|
156
|
+
"lightgreen": [144, 238, 144],
|
|
157
|
+
"lightgrey": [211, 211, 211],
|
|
158
|
+
"lightpink": [255, 182, 193],
|
|
159
|
+
"lightsalmon": [255, 160, 122],
|
|
160
|
+
"lightseagreen": [32, 178, 170],
|
|
161
|
+
"lightskyblue": [135, 206, 250],
|
|
162
|
+
"lightslategray": [119, 136, 153],
|
|
163
|
+
"lightslategrey": [119, 136, 153],
|
|
164
|
+
"lightsteelblue": [176, 196, 222],
|
|
165
|
+
"lightyellow": [255, 255, 224],
|
|
166
|
+
"lime": [0, 255, 0],
|
|
167
|
+
"limegreen": [50, 205, 50],
|
|
168
|
+
"linen": [250, 240, 230],
|
|
169
|
+
"magenta": [255, 0, 255],
|
|
170
|
+
"maroon": [128, 0, 0],
|
|
171
|
+
"mediumaquamarine": [102, 205, 170],
|
|
172
|
+
"mediumblue": [0, 0, 205],
|
|
173
|
+
"mediumorchid": [186, 85, 211],
|
|
174
|
+
"mediumpurple": [147, 112, 219],
|
|
175
|
+
"mediumseagreen": [60, 179, 113],
|
|
176
|
+
"mediumslateblue": [123, 104, 238],
|
|
177
|
+
"mediumspringgreen": [0, 250, 154],
|
|
178
|
+
"mediumturquoise": [72, 209, 204],
|
|
179
|
+
"mediumvioletred": [199, 21, 133],
|
|
180
|
+
"midnightblue": [25, 25, 112],
|
|
181
|
+
"mintcream": [245, 255, 250],
|
|
182
|
+
"mistyrose": [255, 228, 225],
|
|
183
|
+
"moccasin": [255, 228, 181],
|
|
184
|
+
"navajowhite": [255, 222, 173],
|
|
185
|
+
"navy": [0, 0, 128],
|
|
186
|
+
"oldlace": [253, 245, 230],
|
|
187
|
+
"olive": [128, 128, 0],
|
|
188
|
+
"olivedrab": [107, 142, 35],
|
|
189
|
+
"orange": [255, 165, 0],
|
|
190
|
+
"orangered": [255, 69, 0],
|
|
191
|
+
"orchid": [218, 112, 214],
|
|
192
|
+
"palegoldenrod": [238, 232, 170],
|
|
193
|
+
"palegreen": [152, 251, 152],
|
|
194
|
+
"paleturquoise": [175, 238, 238],
|
|
195
|
+
"palevioletred": [219, 112, 147],
|
|
196
|
+
"papayawhip": [255, 239, 213],
|
|
197
|
+
"peachpuff": [255, 218, 185],
|
|
198
|
+
"peru": [205, 133, 63],
|
|
199
|
+
"pink": [255, 192, 203],
|
|
200
|
+
"plum": [221, 160, 221],
|
|
201
|
+
"powderblue": [176, 224, 230],
|
|
202
|
+
"purple": [128, 0, 128],
|
|
203
|
+
"rebeccapurple": [102, 51, 153],
|
|
204
|
+
"red": [255, 0, 0],
|
|
205
|
+
"rosybrown": [188, 143, 143],
|
|
206
|
+
"royalblue": [65, 105, 225],
|
|
207
|
+
"saddlebrown": [139, 69, 19],
|
|
208
|
+
"salmon": [250, 128, 114],
|
|
209
|
+
"sandybrown": [244, 164, 96],
|
|
210
|
+
"seagreen": [46, 139, 87],
|
|
211
|
+
"seashell": [255, 245, 238],
|
|
212
|
+
"sienna": [160, 82, 45],
|
|
213
|
+
"silver": [192, 192, 192],
|
|
214
|
+
"skyblue": [135, 206, 235],
|
|
215
|
+
"slateblue": [106, 90, 205],
|
|
216
|
+
"slategray": [112, 128, 144],
|
|
217
|
+
"slategrey": [112, 128, 144],
|
|
218
|
+
"snow": [255, 250, 250],
|
|
219
|
+
"springgreen": [0, 255, 127],
|
|
220
|
+
"steelblue": [70, 130, 180],
|
|
221
|
+
"tan": [210, 180, 140],
|
|
222
|
+
"teal": [0, 128, 128],
|
|
223
|
+
"thistle": [216, 191, 216],
|
|
224
|
+
"tomato": [255, 99, 71],
|
|
225
|
+
"turquoise": [64, 224, 208],
|
|
226
|
+
"violet": [238, 130, 238],
|
|
227
|
+
"wheat": [245, 222, 179],
|
|
228
|
+
"white": [255, 255, 255],
|
|
229
|
+
"whitesmoke": [245, 245, 245],
|
|
230
|
+
"yellow": [255, 255, 0],
|
|
231
|
+
"yellowgreen": [154, 205, 50]
|
|
232
|
+
};
|
|
233
|
+
return colorName;
|
|
234
|
+
}
|
|
235
|
+
var conversions;
|
|
236
|
+
var hasRequiredConversions;
|
|
237
|
+
function requireConversions() {
|
|
238
|
+
if (hasRequiredConversions)
|
|
239
|
+
return conversions;
|
|
240
|
+
hasRequiredConversions = 1;
|
|
241
|
+
const cssKeywords = requireColorName();
|
|
242
|
+
const reverseKeywords = {};
|
|
243
|
+
for (const key of Object.keys(cssKeywords)) {
|
|
244
|
+
reverseKeywords[cssKeywords[key]] = key;
|
|
245
|
+
}
|
|
246
|
+
const convert = {
|
|
247
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
248
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
249
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
250
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
251
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
252
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
253
|
+
lab: { channels: 3, labels: "lab" },
|
|
254
|
+
lch: { channels: 3, labels: "lch" },
|
|
255
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
256
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
257
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
258
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
259
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
260
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
261
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
262
|
+
};
|
|
263
|
+
conversions = convert;
|
|
264
|
+
for (const model of Object.keys(convert)) {
|
|
265
|
+
if (!("channels" in convert[model])) {
|
|
266
|
+
throw new Error("missing channels property: " + model);
|
|
267
|
+
}
|
|
268
|
+
if (!("labels" in convert[model])) {
|
|
269
|
+
throw new Error("missing channel labels property: " + model);
|
|
270
|
+
}
|
|
271
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
272
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
273
|
+
}
|
|
274
|
+
const { channels, labels } = convert[model];
|
|
275
|
+
delete convert[model].channels;
|
|
276
|
+
delete convert[model].labels;
|
|
277
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
278
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
279
|
+
}
|
|
280
|
+
convert.rgb.hsl = function(rgb) {
|
|
281
|
+
const r = rgb[0] / 255;
|
|
282
|
+
const g = rgb[1] / 255;
|
|
283
|
+
const b = rgb[2] / 255;
|
|
284
|
+
const min = Math.min(r, g, b);
|
|
285
|
+
const max = Math.max(r, g, b);
|
|
286
|
+
const delta = max - min;
|
|
287
|
+
let h;
|
|
288
|
+
let s;
|
|
289
|
+
if (max === min) {
|
|
290
|
+
h = 0;
|
|
291
|
+
} else if (r === max) {
|
|
292
|
+
h = (g - b) / delta;
|
|
293
|
+
} else if (g === max) {
|
|
294
|
+
h = 2 + (b - r) / delta;
|
|
295
|
+
} else if (b === max) {
|
|
296
|
+
h = 4 + (r - g) / delta;
|
|
297
|
+
}
|
|
298
|
+
h = Math.min(h * 60, 360);
|
|
299
|
+
if (h < 0) {
|
|
300
|
+
h += 360;
|
|
301
|
+
}
|
|
302
|
+
const l = (min + max) / 2;
|
|
303
|
+
if (max === min) {
|
|
304
|
+
s = 0;
|
|
305
|
+
} else if (l <= 0.5) {
|
|
306
|
+
s = delta / (max + min);
|
|
307
|
+
} else {
|
|
308
|
+
s = delta / (2 - max - min);
|
|
309
|
+
}
|
|
310
|
+
return [h, s * 100, l * 100];
|
|
311
|
+
};
|
|
312
|
+
convert.rgb.hsv = function(rgb) {
|
|
313
|
+
let rdif;
|
|
314
|
+
let gdif;
|
|
315
|
+
let bdif;
|
|
316
|
+
let h;
|
|
317
|
+
let s;
|
|
318
|
+
const r = rgb[0] / 255;
|
|
319
|
+
const g = rgb[1] / 255;
|
|
320
|
+
const b = rgb[2] / 255;
|
|
321
|
+
const v = Math.max(r, g, b);
|
|
322
|
+
const diff = v - Math.min(r, g, b);
|
|
323
|
+
const diffc = function(c) {
|
|
324
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
325
|
+
};
|
|
326
|
+
if (diff === 0) {
|
|
327
|
+
h = 0;
|
|
328
|
+
s = 0;
|
|
329
|
+
} else {
|
|
330
|
+
s = diff / v;
|
|
331
|
+
rdif = diffc(r);
|
|
332
|
+
gdif = diffc(g);
|
|
333
|
+
bdif = diffc(b);
|
|
334
|
+
if (r === v) {
|
|
335
|
+
h = bdif - gdif;
|
|
336
|
+
} else if (g === v) {
|
|
337
|
+
h = 1 / 3 + rdif - bdif;
|
|
338
|
+
} else if (b === v) {
|
|
339
|
+
h = 2 / 3 + gdif - rdif;
|
|
340
|
+
}
|
|
341
|
+
if (h < 0) {
|
|
342
|
+
h += 1;
|
|
343
|
+
} else if (h > 1) {
|
|
344
|
+
h -= 1;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return [
|
|
348
|
+
h * 360,
|
|
349
|
+
s * 100,
|
|
350
|
+
v * 100
|
|
351
|
+
];
|
|
352
|
+
};
|
|
353
|
+
convert.rgb.hwb = function(rgb) {
|
|
354
|
+
const r = rgb[0];
|
|
355
|
+
const g = rgb[1];
|
|
356
|
+
let b = rgb[2];
|
|
357
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
358
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
359
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
360
|
+
return [h, w * 100, b * 100];
|
|
361
|
+
};
|
|
362
|
+
convert.rgb.cmyk = function(rgb) {
|
|
363
|
+
const r = rgb[0] / 255;
|
|
364
|
+
const g = rgb[1] / 255;
|
|
365
|
+
const b = rgb[2] / 255;
|
|
366
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
367
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
368
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
369
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
370
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
371
|
+
};
|
|
372
|
+
function comparativeDistance(x, y) {
|
|
373
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
374
|
+
}
|
|
375
|
+
convert.rgb.keyword = function(rgb) {
|
|
376
|
+
const reversed = reverseKeywords[rgb];
|
|
377
|
+
if (reversed) {
|
|
378
|
+
return reversed;
|
|
379
|
+
}
|
|
380
|
+
let currentClosestDistance = Infinity;
|
|
381
|
+
let currentClosestKeyword;
|
|
382
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
|
383
|
+
const value = cssKeywords[keyword];
|
|
384
|
+
const distance = comparativeDistance(rgb, value);
|
|
385
|
+
if (distance < currentClosestDistance) {
|
|
386
|
+
currentClosestDistance = distance;
|
|
387
|
+
currentClosestKeyword = keyword;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return currentClosestKeyword;
|
|
391
|
+
};
|
|
392
|
+
convert.keyword.rgb = function(keyword) {
|
|
393
|
+
return cssKeywords[keyword];
|
|
394
|
+
};
|
|
395
|
+
convert.rgb.xyz = function(rgb) {
|
|
396
|
+
let r = rgb[0] / 255;
|
|
397
|
+
let g = rgb[1] / 255;
|
|
398
|
+
let b = rgb[2] / 255;
|
|
399
|
+
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
400
|
+
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
401
|
+
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
402
|
+
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
403
|
+
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
404
|
+
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
405
|
+
return [x * 100, y * 100, z * 100];
|
|
406
|
+
};
|
|
407
|
+
convert.rgb.lab = function(rgb) {
|
|
408
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
409
|
+
let x = xyz[0];
|
|
410
|
+
let y = xyz[1];
|
|
411
|
+
let z = xyz[2];
|
|
412
|
+
x /= 95.047;
|
|
413
|
+
y /= 100;
|
|
414
|
+
z /= 108.883;
|
|
415
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
416
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
417
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
418
|
+
const l = 116 * y - 16;
|
|
419
|
+
const a = 500 * (x - y);
|
|
420
|
+
const b = 200 * (y - z);
|
|
421
|
+
return [l, a, b];
|
|
422
|
+
};
|
|
423
|
+
convert.hsl.rgb = function(hsl) {
|
|
424
|
+
const h = hsl[0] / 360;
|
|
425
|
+
const s = hsl[1] / 100;
|
|
426
|
+
const l = hsl[2] / 100;
|
|
427
|
+
let t2;
|
|
428
|
+
let t3;
|
|
429
|
+
let val;
|
|
430
|
+
if (s === 0) {
|
|
431
|
+
val = l * 255;
|
|
432
|
+
return [val, val, val];
|
|
433
|
+
}
|
|
434
|
+
if (l < 0.5) {
|
|
435
|
+
t2 = l * (1 + s);
|
|
436
|
+
} else {
|
|
437
|
+
t2 = l + s - l * s;
|
|
438
|
+
}
|
|
439
|
+
const t1 = 2 * l - t2;
|
|
440
|
+
const rgb = [0, 0, 0];
|
|
441
|
+
for (let i = 0; i < 3; i++) {
|
|
442
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
443
|
+
if (t3 < 0) {
|
|
444
|
+
t3++;
|
|
445
|
+
}
|
|
446
|
+
if (t3 > 1) {
|
|
447
|
+
t3--;
|
|
448
|
+
}
|
|
449
|
+
if (6 * t3 < 1) {
|
|
450
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
451
|
+
} else if (2 * t3 < 1) {
|
|
452
|
+
val = t2;
|
|
453
|
+
} else if (3 * t3 < 2) {
|
|
454
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
455
|
+
} else {
|
|
456
|
+
val = t1;
|
|
457
|
+
}
|
|
458
|
+
rgb[i] = val * 255;
|
|
459
|
+
}
|
|
460
|
+
return rgb;
|
|
461
|
+
};
|
|
462
|
+
convert.hsl.hsv = function(hsl) {
|
|
463
|
+
const h = hsl[0];
|
|
464
|
+
let s = hsl[1] / 100;
|
|
465
|
+
let l = hsl[2] / 100;
|
|
466
|
+
let smin = s;
|
|
467
|
+
const lmin = Math.max(l, 0.01);
|
|
468
|
+
l *= 2;
|
|
469
|
+
s *= l <= 1 ? l : 2 - l;
|
|
470
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
471
|
+
const v = (l + s) / 2;
|
|
472
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
473
|
+
return [h, sv * 100, v * 100];
|
|
474
|
+
};
|
|
475
|
+
convert.hsv.rgb = function(hsv) {
|
|
476
|
+
const h = hsv[0] / 60;
|
|
477
|
+
const s = hsv[1] / 100;
|
|
478
|
+
let v = hsv[2] / 100;
|
|
479
|
+
const hi = Math.floor(h) % 6;
|
|
480
|
+
const f = h - Math.floor(h);
|
|
481
|
+
const p = 255 * v * (1 - s);
|
|
482
|
+
const q = 255 * v * (1 - s * f);
|
|
483
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
484
|
+
v *= 255;
|
|
485
|
+
switch (hi) {
|
|
486
|
+
case 0:
|
|
487
|
+
return [v, t, p];
|
|
488
|
+
case 1:
|
|
489
|
+
return [q, v, p];
|
|
490
|
+
case 2:
|
|
491
|
+
return [p, v, t];
|
|
492
|
+
case 3:
|
|
493
|
+
return [p, q, v];
|
|
494
|
+
case 4:
|
|
495
|
+
return [t, p, v];
|
|
496
|
+
case 5:
|
|
497
|
+
return [v, p, q];
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
convert.hsv.hsl = function(hsv) {
|
|
501
|
+
const h = hsv[0];
|
|
502
|
+
const s = hsv[1] / 100;
|
|
503
|
+
const v = hsv[2] / 100;
|
|
504
|
+
const vmin = Math.max(v, 0.01);
|
|
505
|
+
let sl;
|
|
506
|
+
let l;
|
|
507
|
+
l = (2 - s) * v;
|
|
508
|
+
const lmin = (2 - s) * vmin;
|
|
509
|
+
sl = s * vmin;
|
|
510
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
511
|
+
sl = sl || 0;
|
|
512
|
+
l /= 2;
|
|
513
|
+
return [h, sl * 100, l * 100];
|
|
514
|
+
};
|
|
515
|
+
convert.hwb.rgb = function(hwb) {
|
|
516
|
+
const h = hwb[0] / 360;
|
|
517
|
+
let wh = hwb[1] / 100;
|
|
518
|
+
let bl = hwb[2] / 100;
|
|
519
|
+
const ratio = wh + bl;
|
|
520
|
+
let f;
|
|
521
|
+
if (ratio > 1) {
|
|
522
|
+
wh /= ratio;
|
|
523
|
+
bl /= ratio;
|
|
524
|
+
}
|
|
525
|
+
const i = Math.floor(6 * h);
|
|
526
|
+
const v = 1 - bl;
|
|
527
|
+
f = 6 * h - i;
|
|
528
|
+
if ((i & 1) !== 0) {
|
|
529
|
+
f = 1 - f;
|
|
530
|
+
}
|
|
531
|
+
const n = wh + f * (v - wh);
|
|
532
|
+
let r;
|
|
533
|
+
let g;
|
|
534
|
+
let b;
|
|
535
|
+
switch (i) {
|
|
536
|
+
default:
|
|
537
|
+
case 6:
|
|
538
|
+
case 0:
|
|
539
|
+
r = v;
|
|
540
|
+
g = n;
|
|
541
|
+
b = wh;
|
|
542
|
+
break;
|
|
543
|
+
case 1:
|
|
544
|
+
r = n;
|
|
545
|
+
g = v;
|
|
546
|
+
b = wh;
|
|
547
|
+
break;
|
|
548
|
+
case 2:
|
|
549
|
+
r = wh;
|
|
550
|
+
g = v;
|
|
551
|
+
b = n;
|
|
552
|
+
break;
|
|
553
|
+
case 3:
|
|
554
|
+
r = wh;
|
|
555
|
+
g = n;
|
|
556
|
+
b = v;
|
|
557
|
+
break;
|
|
558
|
+
case 4:
|
|
559
|
+
r = n;
|
|
560
|
+
g = wh;
|
|
561
|
+
b = v;
|
|
562
|
+
break;
|
|
563
|
+
case 5:
|
|
564
|
+
r = v;
|
|
565
|
+
g = wh;
|
|
566
|
+
b = n;
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
return [r * 255, g * 255, b * 255];
|
|
570
|
+
};
|
|
571
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
572
|
+
const c = cmyk[0] / 100;
|
|
573
|
+
const m = cmyk[1] / 100;
|
|
574
|
+
const y = cmyk[2] / 100;
|
|
575
|
+
const k = cmyk[3] / 100;
|
|
576
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
577
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
578
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
579
|
+
return [r * 255, g * 255, b * 255];
|
|
580
|
+
};
|
|
581
|
+
convert.xyz.rgb = function(xyz) {
|
|
582
|
+
const x = xyz[0] / 100;
|
|
583
|
+
const y = xyz[1] / 100;
|
|
584
|
+
const z = xyz[2] / 100;
|
|
585
|
+
let r;
|
|
586
|
+
let g;
|
|
587
|
+
let b;
|
|
588
|
+
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
589
|
+
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
590
|
+
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
591
|
+
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
592
|
+
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
593
|
+
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
594
|
+
r = Math.min(Math.max(0, r), 1);
|
|
595
|
+
g = Math.min(Math.max(0, g), 1);
|
|
596
|
+
b = Math.min(Math.max(0, b), 1);
|
|
597
|
+
return [r * 255, g * 255, b * 255];
|
|
598
|
+
};
|
|
599
|
+
convert.xyz.lab = function(xyz) {
|
|
600
|
+
let x = xyz[0];
|
|
601
|
+
let y = xyz[1];
|
|
602
|
+
let z = xyz[2];
|
|
603
|
+
x /= 95.047;
|
|
604
|
+
y /= 100;
|
|
605
|
+
z /= 108.883;
|
|
606
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
607
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
608
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
609
|
+
const l = 116 * y - 16;
|
|
610
|
+
const a = 500 * (x - y);
|
|
611
|
+
const b = 200 * (y - z);
|
|
612
|
+
return [l, a, b];
|
|
613
|
+
};
|
|
614
|
+
convert.lab.xyz = function(lab) {
|
|
615
|
+
const l = lab[0];
|
|
616
|
+
const a = lab[1];
|
|
617
|
+
const b = lab[2];
|
|
618
|
+
let x;
|
|
619
|
+
let y;
|
|
620
|
+
let z;
|
|
621
|
+
y = (l + 16) / 116;
|
|
622
|
+
x = a / 500 + y;
|
|
623
|
+
z = y - b / 200;
|
|
624
|
+
const y2 = y ** 3;
|
|
625
|
+
const x2 = x ** 3;
|
|
626
|
+
const z2 = z ** 3;
|
|
627
|
+
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
628
|
+
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
629
|
+
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
630
|
+
x *= 95.047;
|
|
631
|
+
y *= 100;
|
|
632
|
+
z *= 108.883;
|
|
633
|
+
return [x, y, z];
|
|
634
|
+
};
|
|
635
|
+
convert.lab.lch = function(lab) {
|
|
636
|
+
const l = lab[0];
|
|
637
|
+
const a = lab[1];
|
|
638
|
+
const b = lab[2];
|
|
639
|
+
let h;
|
|
640
|
+
const hr = Math.atan2(b, a);
|
|
641
|
+
h = hr * 360 / 2 / Math.PI;
|
|
642
|
+
if (h < 0) {
|
|
643
|
+
h += 360;
|
|
644
|
+
}
|
|
645
|
+
const c = Math.sqrt(a * a + b * b);
|
|
646
|
+
return [l, c, h];
|
|
647
|
+
};
|
|
648
|
+
convert.lch.lab = function(lch) {
|
|
649
|
+
const l = lch[0];
|
|
650
|
+
const c = lch[1];
|
|
651
|
+
const h = lch[2];
|
|
652
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
653
|
+
const a = c * Math.cos(hr);
|
|
654
|
+
const b = c * Math.sin(hr);
|
|
655
|
+
return [l, a, b];
|
|
656
|
+
};
|
|
657
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
658
|
+
const [r, g, b] = args;
|
|
659
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
660
|
+
value = Math.round(value / 50);
|
|
661
|
+
if (value === 0) {
|
|
662
|
+
return 30;
|
|
663
|
+
}
|
|
664
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
665
|
+
if (value === 2) {
|
|
666
|
+
ansi += 60;
|
|
667
|
+
}
|
|
668
|
+
return ansi;
|
|
669
|
+
};
|
|
670
|
+
convert.hsv.ansi16 = function(args) {
|
|
671
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
672
|
+
};
|
|
673
|
+
convert.rgb.ansi256 = function(args) {
|
|
674
|
+
const r = args[0];
|
|
675
|
+
const g = args[1];
|
|
676
|
+
const b = args[2];
|
|
677
|
+
if (r === g && g === b) {
|
|
678
|
+
if (r < 8) {
|
|
679
|
+
return 16;
|
|
680
|
+
}
|
|
681
|
+
if (r > 248) {
|
|
682
|
+
return 231;
|
|
683
|
+
}
|
|
684
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
685
|
+
}
|
|
686
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
687
|
+
return ansi;
|
|
688
|
+
};
|
|
689
|
+
convert.ansi16.rgb = function(args) {
|
|
690
|
+
let color = args % 10;
|
|
691
|
+
if (color === 0 || color === 7) {
|
|
692
|
+
if (args > 50) {
|
|
693
|
+
color += 3.5;
|
|
694
|
+
}
|
|
695
|
+
color = color / 10.5 * 255;
|
|
696
|
+
return [color, color, color];
|
|
697
|
+
}
|
|
698
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
699
|
+
const r = (color & 1) * mult * 255;
|
|
700
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
701
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
702
|
+
return [r, g, b];
|
|
703
|
+
};
|
|
704
|
+
convert.ansi256.rgb = function(args) {
|
|
705
|
+
if (args >= 232) {
|
|
706
|
+
const c = (args - 232) * 10 + 8;
|
|
707
|
+
return [c, c, c];
|
|
708
|
+
}
|
|
709
|
+
args -= 16;
|
|
710
|
+
let rem;
|
|
711
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
712
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
713
|
+
const b = rem % 6 / 5 * 255;
|
|
714
|
+
return [r, g, b];
|
|
715
|
+
};
|
|
716
|
+
convert.rgb.hex = function(args) {
|
|
717
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
718
|
+
const string = integer.toString(16).toUpperCase();
|
|
719
|
+
return "000000".substring(string.length) + string;
|
|
720
|
+
};
|
|
721
|
+
convert.hex.rgb = function(args) {
|
|
722
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
723
|
+
if (!match) {
|
|
724
|
+
return [0, 0, 0];
|
|
725
|
+
}
|
|
726
|
+
let colorString = match[0];
|
|
727
|
+
if (match[0].length === 3) {
|
|
728
|
+
colorString = colorString.split("").map((char) => {
|
|
729
|
+
return char + char;
|
|
730
|
+
}).join("");
|
|
731
|
+
}
|
|
732
|
+
const integer = parseInt(colorString, 16);
|
|
733
|
+
const r = integer >> 16 & 255;
|
|
734
|
+
const g = integer >> 8 & 255;
|
|
735
|
+
const b = integer & 255;
|
|
736
|
+
return [r, g, b];
|
|
737
|
+
};
|
|
738
|
+
convert.rgb.hcg = function(rgb) {
|
|
739
|
+
const r = rgb[0] / 255;
|
|
740
|
+
const g = rgb[1] / 255;
|
|
741
|
+
const b = rgb[2] / 255;
|
|
742
|
+
const max = Math.max(Math.max(r, g), b);
|
|
743
|
+
const min = Math.min(Math.min(r, g), b);
|
|
744
|
+
const chroma = max - min;
|
|
745
|
+
let grayscale;
|
|
746
|
+
let hue;
|
|
747
|
+
if (chroma < 1) {
|
|
748
|
+
grayscale = min / (1 - chroma);
|
|
749
|
+
} else {
|
|
750
|
+
grayscale = 0;
|
|
751
|
+
}
|
|
752
|
+
if (chroma <= 0) {
|
|
753
|
+
hue = 0;
|
|
754
|
+
} else if (max === r) {
|
|
755
|
+
hue = (g - b) / chroma % 6;
|
|
756
|
+
} else if (max === g) {
|
|
757
|
+
hue = 2 + (b - r) / chroma;
|
|
758
|
+
} else {
|
|
759
|
+
hue = 4 + (r - g) / chroma;
|
|
760
|
+
}
|
|
761
|
+
hue /= 6;
|
|
762
|
+
hue %= 1;
|
|
763
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
764
|
+
};
|
|
765
|
+
convert.hsl.hcg = function(hsl) {
|
|
766
|
+
const s = hsl[1] / 100;
|
|
767
|
+
const l = hsl[2] / 100;
|
|
768
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
769
|
+
let f = 0;
|
|
770
|
+
if (c < 1) {
|
|
771
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
772
|
+
}
|
|
773
|
+
return [hsl[0], c * 100, f * 100];
|
|
774
|
+
};
|
|
775
|
+
convert.hsv.hcg = function(hsv) {
|
|
776
|
+
const s = hsv[1] / 100;
|
|
777
|
+
const v = hsv[2] / 100;
|
|
778
|
+
const c = s * v;
|
|
779
|
+
let f = 0;
|
|
780
|
+
if (c < 1) {
|
|
781
|
+
f = (v - c) / (1 - c);
|
|
782
|
+
}
|
|
783
|
+
return [hsv[0], c * 100, f * 100];
|
|
784
|
+
};
|
|
785
|
+
convert.hcg.rgb = function(hcg) {
|
|
786
|
+
const h = hcg[0] / 360;
|
|
787
|
+
const c = hcg[1] / 100;
|
|
788
|
+
const g = hcg[2] / 100;
|
|
789
|
+
if (c === 0) {
|
|
790
|
+
return [g * 255, g * 255, g * 255];
|
|
791
|
+
}
|
|
792
|
+
const pure = [0, 0, 0];
|
|
793
|
+
const hi = h % 1 * 6;
|
|
794
|
+
const v = hi % 1;
|
|
795
|
+
const w = 1 - v;
|
|
796
|
+
let mg = 0;
|
|
797
|
+
switch (Math.floor(hi)) {
|
|
798
|
+
case 0:
|
|
799
|
+
pure[0] = 1;
|
|
800
|
+
pure[1] = v;
|
|
801
|
+
pure[2] = 0;
|
|
802
|
+
break;
|
|
803
|
+
case 1:
|
|
804
|
+
pure[0] = w;
|
|
805
|
+
pure[1] = 1;
|
|
806
|
+
pure[2] = 0;
|
|
807
|
+
break;
|
|
808
|
+
case 2:
|
|
809
|
+
pure[0] = 0;
|
|
810
|
+
pure[1] = 1;
|
|
811
|
+
pure[2] = v;
|
|
812
|
+
break;
|
|
813
|
+
case 3:
|
|
814
|
+
pure[0] = 0;
|
|
815
|
+
pure[1] = w;
|
|
816
|
+
pure[2] = 1;
|
|
817
|
+
break;
|
|
818
|
+
case 4:
|
|
819
|
+
pure[0] = v;
|
|
820
|
+
pure[1] = 0;
|
|
821
|
+
pure[2] = 1;
|
|
822
|
+
break;
|
|
823
|
+
default:
|
|
824
|
+
pure[0] = 1;
|
|
825
|
+
pure[1] = 0;
|
|
826
|
+
pure[2] = w;
|
|
827
|
+
}
|
|
828
|
+
mg = (1 - c) * g;
|
|
829
|
+
return [
|
|
830
|
+
(c * pure[0] + mg) * 255,
|
|
831
|
+
(c * pure[1] + mg) * 255,
|
|
832
|
+
(c * pure[2] + mg) * 255
|
|
833
|
+
];
|
|
834
|
+
};
|
|
835
|
+
convert.hcg.hsv = function(hcg) {
|
|
836
|
+
const c = hcg[1] / 100;
|
|
837
|
+
const g = hcg[2] / 100;
|
|
838
|
+
const v = c + g * (1 - c);
|
|
839
|
+
let f = 0;
|
|
840
|
+
if (v > 0) {
|
|
841
|
+
f = c / v;
|
|
842
|
+
}
|
|
843
|
+
return [hcg[0], f * 100, v * 100];
|
|
844
|
+
};
|
|
845
|
+
convert.hcg.hsl = function(hcg) {
|
|
846
|
+
const c = hcg[1] / 100;
|
|
847
|
+
const g = hcg[2] / 100;
|
|
848
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
849
|
+
let s = 0;
|
|
850
|
+
if (l > 0 && l < 0.5) {
|
|
851
|
+
s = c / (2 * l);
|
|
852
|
+
} else if (l >= 0.5 && l < 1) {
|
|
853
|
+
s = c / (2 * (1 - l));
|
|
854
|
+
}
|
|
855
|
+
return [hcg[0], s * 100, l * 100];
|
|
856
|
+
};
|
|
857
|
+
convert.hcg.hwb = function(hcg) {
|
|
858
|
+
const c = hcg[1] / 100;
|
|
859
|
+
const g = hcg[2] / 100;
|
|
860
|
+
const v = c + g * (1 - c);
|
|
861
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
862
|
+
};
|
|
863
|
+
convert.hwb.hcg = function(hwb) {
|
|
864
|
+
const w = hwb[1] / 100;
|
|
865
|
+
const b = hwb[2] / 100;
|
|
866
|
+
const v = 1 - b;
|
|
867
|
+
const c = v - w;
|
|
868
|
+
let g = 0;
|
|
869
|
+
if (c < 1) {
|
|
870
|
+
g = (v - c) / (1 - c);
|
|
871
|
+
}
|
|
872
|
+
return [hwb[0], c * 100, g * 100];
|
|
873
|
+
};
|
|
874
|
+
convert.apple.rgb = function(apple) {
|
|
875
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
876
|
+
};
|
|
877
|
+
convert.rgb.apple = function(rgb) {
|
|
878
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
879
|
+
};
|
|
880
|
+
convert.gray.rgb = function(args) {
|
|
881
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
882
|
+
};
|
|
883
|
+
convert.gray.hsl = function(args) {
|
|
884
|
+
return [0, 0, args[0]];
|
|
885
|
+
};
|
|
886
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
887
|
+
convert.gray.hwb = function(gray) {
|
|
888
|
+
return [0, 100, gray[0]];
|
|
889
|
+
};
|
|
890
|
+
convert.gray.cmyk = function(gray) {
|
|
891
|
+
return [0, 0, 0, gray[0]];
|
|
892
|
+
};
|
|
893
|
+
convert.gray.lab = function(gray) {
|
|
894
|
+
return [gray[0], 0, 0];
|
|
895
|
+
};
|
|
896
|
+
convert.gray.hex = function(gray) {
|
|
897
|
+
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
898
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
899
|
+
const string = integer.toString(16).toUpperCase();
|
|
900
|
+
return "000000".substring(string.length) + string;
|
|
901
|
+
};
|
|
902
|
+
convert.rgb.gray = function(rgb) {
|
|
903
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
904
|
+
return [val / 255 * 100];
|
|
905
|
+
};
|
|
906
|
+
return conversions;
|
|
907
|
+
}
|
|
908
|
+
var route;
|
|
909
|
+
var hasRequiredRoute;
|
|
910
|
+
function requireRoute() {
|
|
911
|
+
if (hasRequiredRoute)
|
|
912
|
+
return route;
|
|
913
|
+
hasRequiredRoute = 1;
|
|
914
|
+
const conversions2 = requireConversions();
|
|
915
|
+
function buildGraph() {
|
|
916
|
+
const graph = {};
|
|
917
|
+
const models = Object.keys(conversions2);
|
|
918
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
919
|
+
graph[models[i]] = {
|
|
920
|
+
// http://jsperf.com/1-vs-infinity
|
|
921
|
+
// micro-opt, but this is simple.
|
|
922
|
+
distance: -1,
|
|
923
|
+
parent: null
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
return graph;
|
|
927
|
+
}
|
|
928
|
+
function deriveBFS(fromModel) {
|
|
929
|
+
const graph = buildGraph();
|
|
930
|
+
const queue = [fromModel];
|
|
931
|
+
graph[fromModel].distance = 0;
|
|
932
|
+
while (queue.length) {
|
|
933
|
+
const current = queue.pop();
|
|
934
|
+
const adjacents = Object.keys(conversions2[current]);
|
|
935
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
936
|
+
const adjacent = adjacents[i];
|
|
937
|
+
const node = graph[adjacent];
|
|
938
|
+
if (node.distance === -1) {
|
|
939
|
+
node.distance = graph[current].distance + 1;
|
|
940
|
+
node.parent = current;
|
|
941
|
+
queue.unshift(adjacent);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return graph;
|
|
946
|
+
}
|
|
947
|
+
function link(from, to) {
|
|
948
|
+
return function(args) {
|
|
949
|
+
return to(from(args));
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
function wrapConversion(toModel, graph) {
|
|
953
|
+
const path = [graph[toModel].parent, toModel];
|
|
954
|
+
let fn = conversions2[graph[toModel].parent][toModel];
|
|
955
|
+
let cur = graph[toModel].parent;
|
|
956
|
+
while (graph[cur].parent) {
|
|
957
|
+
path.unshift(graph[cur].parent);
|
|
958
|
+
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
959
|
+
cur = graph[cur].parent;
|
|
960
|
+
}
|
|
961
|
+
fn.conversion = path;
|
|
962
|
+
return fn;
|
|
963
|
+
}
|
|
964
|
+
route = function(fromModel) {
|
|
965
|
+
const graph = deriveBFS(fromModel);
|
|
966
|
+
const conversion = {};
|
|
967
|
+
const models = Object.keys(graph);
|
|
968
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
969
|
+
const toModel = models[i];
|
|
970
|
+
const node = graph[toModel];
|
|
971
|
+
if (node.parent === null) {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
975
|
+
}
|
|
976
|
+
return conversion;
|
|
977
|
+
};
|
|
978
|
+
return route;
|
|
979
|
+
}
|
|
980
|
+
var colorConvert;
|
|
981
|
+
var hasRequiredColorConvert;
|
|
982
|
+
function requireColorConvert() {
|
|
983
|
+
if (hasRequiredColorConvert)
|
|
984
|
+
return colorConvert;
|
|
985
|
+
hasRequiredColorConvert = 1;
|
|
986
|
+
const conversions2 = requireConversions();
|
|
987
|
+
const route2 = requireRoute();
|
|
988
|
+
const convert = {};
|
|
989
|
+
const models = Object.keys(conversions2);
|
|
990
|
+
function wrapRaw(fn) {
|
|
991
|
+
const wrappedFn = function(...args) {
|
|
992
|
+
const arg0 = args[0];
|
|
993
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
994
|
+
return arg0;
|
|
995
|
+
}
|
|
996
|
+
if (arg0.length > 1) {
|
|
997
|
+
args = arg0;
|
|
998
|
+
}
|
|
999
|
+
return fn(args);
|
|
1000
|
+
};
|
|
1001
|
+
if ("conversion" in fn) {
|
|
1002
|
+
wrappedFn.conversion = fn.conversion;
|
|
1003
|
+
}
|
|
1004
|
+
return wrappedFn;
|
|
1005
|
+
}
|
|
1006
|
+
function wrapRounded(fn) {
|
|
1007
|
+
const wrappedFn = function(...args) {
|
|
1008
|
+
const arg0 = args[0];
|
|
1009
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
1010
|
+
return arg0;
|
|
1011
|
+
}
|
|
1012
|
+
if (arg0.length > 1) {
|
|
1013
|
+
args = arg0;
|
|
1014
|
+
}
|
|
1015
|
+
const result = fn(args);
|
|
1016
|
+
if (typeof result === "object") {
|
|
1017
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
|
1018
|
+
result[i] = Math.round(result[i]);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
return result;
|
|
1022
|
+
};
|
|
1023
|
+
if ("conversion" in fn) {
|
|
1024
|
+
wrappedFn.conversion = fn.conversion;
|
|
1025
|
+
}
|
|
1026
|
+
return wrappedFn;
|
|
1027
|
+
}
|
|
1028
|
+
models.forEach((fromModel) => {
|
|
1029
|
+
convert[fromModel] = {};
|
|
1030
|
+
Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
|
|
1031
|
+
Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
|
|
1032
|
+
const routes = route2(fromModel);
|
|
1033
|
+
const routeModels = Object.keys(routes);
|
|
1034
|
+
routeModels.forEach((toModel) => {
|
|
1035
|
+
const fn = routes[toModel];
|
|
1036
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
1037
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
colorConvert = convert;
|
|
1041
|
+
return colorConvert;
|
|
1042
|
+
}
|
|
1043
|
+
ansiStyles$1.exports;
|
|
1044
|
+
(function(module) {
|
|
1045
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
1046
|
+
const code = fn(...args);
|
|
1047
|
+
return `\x1B[${code + offset}m`;
|
|
1048
|
+
};
|
|
1049
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
1050
|
+
const code = fn(...args);
|
|
1051
|
+
return `\x1B[${38 + offset};5;${code}m`;
|
|
1052
|
+
};
|
|
1053
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1054
|
+
const rgb = fn(...args);
|
|
1055
|
+
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1056
|
+
};
|
|
1057
|
+
const ansi2ansi = (n) => n;
|
|
1058
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1059
|
+
const setLazyProperty = (object, property, get) => {
|
|
1060
|
+
Object.defineProperty(object, property, {
|
|
1061
|
+
get: () => {
|
|
1062
|
+
const value = get();
|
|
1063
|
+
Object.defineProperty(object, property, {
|
|
1064
|
+
value,
|
|
1065
|
+
enumerable: true,
|
|
1066
|
+
configurable: true
|
|
1067
|
+
});
|
|
1068
|
+
return value;
|
|
1069
|
+
},
|
|
1070
|
+
enumerable: true,
|
|
1071
|
+
configurable: true
|
|
1072
|
+
});
|
|
1073
|
+
};
|
|
1074
|
+
let colorConvert2;
|
|
1075
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1076
|
+
if (colorConvert2 === void 0) {
|
|
1077
|
+
colorConvert2 = requireColorConvert();
|
|
1078
|
+
}
|
|
1079
|
+
const offset = isBackground ? 10 : 0;
|
|
1080
|
+
const styles2 = {};
|
|
1081
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
1082
|
+
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1083
|
+
if (sourceSpace === targetSpace) {
|
|
1084
|
+
styles2[name] = wrap(identity, offset);
|
|
1085
|
+
} else if (typeof suite === "object") {
|
|
1086
|
+
styles2[name] = wrap(suite[targetSpace], offset);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return styles2;
|
|
1090
|
+
};
|
|
1091
|
+
function assembleStyles() {
|
|
1092
|
+
const codes = /* @__PURE__ */ new Map();
|
|
1093
|
+
const styles2 = {
|
|
1094
|
+
modifier: {
|
|
1095
|
+
reset: [0, 0],
|
|
1096
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
1097
|
+
bold: [1, 22],
|
|
1098
|
+
dim: [2, 22],
|
|
1099
|
+
italic: [3, 23],
|
|
1100
|
+
underline: [4, 24],
|
|
1101
|
+
inverse: [7, 27],
|
|
1102
|
+
hidden: [8, 28],
|
|
1103
|
+
strikethrough: [9, 29]
|
|
1104
|
+
},
|
|
1105
|
+
color: {
|
|
1106
|
+
black: [30, 39],
|
|
1107
|
+
red: [31, 39],
|
|
1108
|
+
green: [32, 39],
|
|
1109
|
+
yellow: [33, 39],
|
|
1110
|
+
blue: [34, 39],
|
|
1111
|
+
magenta: [35, 39],
|
|
1112
|
+
cyan: [36, 39],
|
|
1113
|
+
white: [37, 39],
|
|
1114
|
+
// Bright color
|
|
1115
|
+
blackBright: [90, 39],
|
|
1116
|
+
redBright: [91, 39],
|
|
1117
|
+
greenBright: [92, 39],
|
|
1118
|
+
yellowBright: [93, 39],
|
|
1119
|
+
blueBright: [94, 39],
|
|
1120
|
+
magentaBright: [95, 39],
|
|
1121
|
+
cyanBright: [96, 39],
|
|
1122
|
+
whiteBright: [97, 39]
|
|
1123
|
+
},
|
|
1124
|
+
bgColor: {
|
|
1125
|
+
bgBlack: [40, 49],
|
|
1126
|
+
bgRed: [41, 49],
|
|
1127
|
+
bgGreen: [42, 49],
|
|
1128
|
+
bgYellow: [43, 49],
|
|
1129
|
+
bgBlue: [44, 49],
|
|
1130
|
+
bgMagenta: [45, 49],
|
|
1131
|
+
bgCyan: [46, 49],
|
|
1132
|
+
bgWhite: [47, 49],
|
|
1133
|
+
// Bright color
|
|
1134
|
+
bgBlackBright: [100, 49],
|
|
1135
|
+
bgRedBright: [101, 49],
|
|
1136
|
+
bgGreenBright: [102, 49],
|
|
1137
|
+
bgYellowBright: [103, 49],
|
|
1138
|
+
bgBlueBright: [104, 49],
|
|
1139
|
+
bgMagentaBright: [105, 49],
|
|
1140
|
+
bgCyanBright: [106, 49],
|
|
1141
|
+
bgWhiteBright: [107, 49]
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
styles2.color.gray = styles2.color.blackBright;
|
|
1145
|
+
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
1146
|
+
styles2.color.grey = styles2.color.blackBright;
|
|
1147
|
+
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
1148
|
+
for (const [groupName, group] of Object.entries(styles2)) {
|
|
1149
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
1150
|
+
styles2[styleName] = {
|
|
1151
|
+
open: `\x1B[${style[0]}m`,
|
|
1152
|
+
close: `\x1B[${style[1]}m`
|
|
1153
|
+
};
|
|
1154
|
+
group[styleName] = styles2[styleName];
|
|
1155
|
+
codes.set(style[0], style[1]);
|
|
1156
|
+
}
|
|
1157
|
+
Object.defineProperty(styles2, groupName, {
|
|
1158
|
+
value: group,
|
|
1159
|
+
enumerable: false
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
Object.defineProperty(styles2, "codes", {
|
|
1163
|
+
value: codes,
|
|
1164
|
+
enumerable: false
|
|
1165
|
+
});
|
|
1166
|
+
styles2.color.close = "\x1B[39m";
|
|
1167
|
+
styles2.bgColor.close = "\x1B[49m";
|
|
1168
|
+
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1169
|
+
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1170
|
+
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1171
|
+
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1172
|
+
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1173
|
+
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1174
|
+
return styles2;
|
|
1175
|
+
}
|
|
1176
|
+
Object.defineProperty(module, "exports", {
|
|
1177
|
+
enumerable: true,
|
|
1178
|
+
get: assembleStyles
|
|
1179
|
+
});
|
|
1180
|
+
})(ansiStyles$1);
|
|
1181
|
+
var ansiStylesExports = ansiStyles$1.exports;
|
|
1182
|
+
var browser = {
|
|
1183
|
+
stdout: false,
|
|
1184
|
+
stderr: false
|
|
1185
|
+
};
|
|
1186
|
+
const stringReplaceAll$1 = (string, substring, replacer) => {
|
|
1187
|
+
let index = string.indexOf(substring);
|
|
1188
|
+
if (index === -1) {
|
|
1189
|
+
return string;
|
|
1190
|
+
}
|
|
1191
|
+
const substringLength = substring.length;
|
|
1192
|
+
let endIndex = 0;
|
|
1193
|
+
let returnValue = "";
|
|
1194
|
+
do {
|
|
1195
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1196
|
+
endIndex = index + substringLength;
|
|
1197
|
+
index = string.indexOf(substring, endIndex);
|
|
1198
|
+
} while (index !== -1);
|
|
1199
|
+
returnValue += string.substr(endIndex);
|
|
1200
|
+
return returnValue;
|
|
1201
|
+
};
|
|
1202
|
+
const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
|
|
1203
|
+
let endIndex = 0;
|
|
1204
|
+
let returnValue = "";
|
|
1205
|
+
do {
|
|
1206
|
+
const gotCR = string[index - 1] === "\r";
|
|
1207
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1208
|
+
endIndex = index + 1;
|
|
1209
|
+
index = string.indexOf("\n", endIndex);
|
|
1210
|
+
} while (index !== -1);
|
|
1211
|
+
returnValue += string.substr(endIndex);
|
|
1212
|
+
return returnValue;
|
|
1213
|
+
};
|
|
1214
|
+
var util = {
|
|
1215
|
+
stringReplaceAll: stringReplaceAll$1,
|
|
1216
|
+
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
|
|
1217
|
+
};
|
|
1218
|
+
var templates;
|
|
1219
|
+
var hasRequiredTemplates;
|
|
1220
|
+
function requireTemplates() {
|
|
1221
|
+
if (hasRequiredTemplates)
|
|
1222
|
+
return templates;
|
|
1223
|
+
hasRequiredTemplates = 1;
|
|
1224
|
+
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;
|
|
1225
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1226
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1227
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1228
|
+
const ESCAPES = /* @__PURE__ */ new Map([
|
|
1229
|
+
["n", "\n"],
|
|
1230
|
+
["r", "\r"],
|
|
1231
|
+
["t", " "],
|
|
1232
|
+
["b", "\b"],
|
|
1233
|
+
["f", "\f"],
|
|
1234
|
+
["v", "\v"],
|
|
1235
|
+
["0", "\0"],
|
|
1236
|
+
["\\", "\\"],
|
|
1237
|
+
["e", "\x1B"],
|
|
1238
|
+
["a", "\x07"]
|
|
1239
|
+
]);
|
|
1240
|
+
function unescape2(c) {
|
|
1241
|
+
const u = c[0] === "u";
|
|
1242
|
+
const bracket = c[1] === "{";
|
|
1243
|
+
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1244
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1245
|
+
}
|
|
1246
|
+
if (u && bracket) {
|
|
1247
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1248
|
+
}
|
|
1249
|
+
return ESCAPES.get(c) || c;
|
|
1250
|
+
}
|
|
1251
|
+
function parseArguments(name, arguments_) {
|
|
1252
|
+
const results = [];
|
|
1253
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1254
|
+
let matches;
|
|
1255
|
+
for (const chunk of chunks) {
|
|
1256
|
+
const number = Number(chunk);
|
|
1257
|
+
if (!Number.isNaN(number)) {
|
|
1258
|
+
results.push(number);
|
|
1259
|
+
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1260
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape2, character) => escape2 ? unescape2(escape2) : character));
|
|
1261
|
+
} else {
|
|
1262
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
return results;
|
|
1266
|
+
}
|
|
1267
|
+
function parseStyle(style) {
|
|
1268
|
+
STYLE_REGEX.lastIndex = 0;
|
|
1269
|
+
const results = [];
|
|
1270
|
+
let matches;
|
|
1271
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1272
|
+
const name = matches[1];
|
|
1273
|
+
if (matches[2]) {
|
|
1274
|
+
const args = parseArguments(name, matches[2]);
|
|
1275
|
+
results.push([name].concat(args));
|
|
1276
|
+
} else {
|
|
1277
|
+
results.push([name]);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return results;
|
|
1281
|
+
}
|
|
1282
|
+
function buildStyle(chalk2, styles2) {
|
|
1283
|
+
const enabled = {};
|
|
1284
|
+
for (const layer of styles2) {
|
|
1285
|
+
for (const style of layer.styles) {
|
|
1286
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
let current = chalk2;
|
|
1290
|
+
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
1291
|
+
if (!Array.isArray(styles3)) {
|
|
1292
|
+
continue;
|
|
1293
|
+
}
|
|
1294
|
+
if (!(styleName in current)) {
|
|
1295
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1296
|
+
}
|
|
1297
|
+
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
1298
|
+
}
|
|
1299
|
+
return current;
|
|
1300
|
+
}
|
|
1301
|
+
templates = (chalk2, temporary) => {
|
|
1302
|
+
const styles2 = [];
|
|
1303
|
+
const chunks = [];
|
|
1304
|
+
let chunk = [];
|
|
1305
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1306
|
+
if (escapeCharacter) {
|
|
1307
|
+
chunk.push(unescape2(escapeCharacter));
|
|
1308
|
+
} else if (style) {
|
|
1309
|
+
const string = chunk.join("");
|
|
1310
|
+
chunk = [];
|
|
1311
|
+
chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
|
|
1312
|
+
styles2.push({ inverse, styles: parseStyle(style) });
|
|
1313
|
+
} else if (close) {
|
|
1314
|
+
if (styles2.length === 0) {
|
|
1315
|
+
throw new Error("Found extraneous } in Chalk template literal");
|
|
1316
|
+
}
|
|
1317
|
+
chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
|
|
1318
|
+
chunk = [];
|
|
1319
|
+
styles2.pop();
|
|
1320
|
+
} else {
|
|
1321
|
+
chunk.push(character);
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
chunks.push(chunk.join(""));
|
|
1325
|
+
if (styles2.length > 0) {
|
|
1326
|
+
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1327
|
+
throw new Error(errMessage);
|
|
1328
|
+
}
|
|
1329
|
+
return chunks.join("");
|
|
1330
|
+
};
|
|
1331
|
+
return templates;
|
|
1332
|
+
}
|
|
1333
|
+
const ansiStyles = ansiStylesExports;
|
|
1334
|
+
const { stdout: stdoutColor, stderr: stderrColor } = browser;
|
|
1335
|
+
const {
|
|
1336
|
+
stringReplaceAll,
|
|
1337
|
+
stringEncaseCRLFWithFirstIndex
|
|
1338
|
+
} = util;
|
|
1339
|
+
const { isArray } = Array;
|
|
1340
|
+
const levelMapping = [
|
|
1341
|
+
"ansi",
|
|
1342
|
+
"ansi",
|
|
1343
|
+
"ansi256",
|
|
1344
|
+
"ansi16m"
|
|
1345
|
+
];
|
|
1346
|
+
const styles = /* @__PURE__ */ Object.create(null);
|
|
1347
|
+
const applyOptions = (object, options = {}) => {
|
|
1348
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1349
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1350
|
+
}
|
|
1351
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1352
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1353
|
+
};
|
|
1354
|
+
class ChalkClass {
|
|
1355
|
+
constructor(options) {
|
|
1356
|
+
return chalkFactory(options);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
const chalkFactory = (options) => {
|
|
1360
|
+
const chalk2 = {};
|
|
1361
|
+
applyOptions(chalk2, options);
|
|
1362
|
+
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
|
1363
|
+
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
1364
|
+
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1365
|
+
chalk2.template.constructor = () => {
|
|
1366
|
+
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1367
|
+
};
|
|
1368
|
+
chalk2.template.Instance = ChalkClass;
|
|
1369
|
+
return chalk2.template;
|
|
1370
|
+
};
|
|
1371
|
+
function Chalk(options) {
|
|
1372
|
+
return chalkFactory(options);
|
|
1373
|
+
}
|
|
1374
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
1375
|
+
styles[styleName] = {
|
|
1376
|
+
get() {
|
|
1377
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
1378
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
1379
|
+
return builder;
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
styles.visible = {
|
|
1384
|
+
get() {
|
|
1385
|
+
const builder = createBuilder(this, this._styler, true);
|
|
1386
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
1387
|
+
return builder;
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1391
|
+
for (const model of usedModels) {
|
|
1392
|
+
styles[model] = {
|
|
1393
|
+
get() {
|
|
1394
|
+
const { level } = this;
|
|
1395
|
+
return function(...arguments_) {
|
|
1396
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
1397
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
for (const model of usedModels) {
|
|
1403
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1404
|
+
styles[bgModel] = {
|
|
1405
|
+
get() {
|
|
1406
|
+
const { level } = this;
|
|
1407
|
+
return function(...arguments_) {
|
|
1408
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
1409
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
const proto = Object.defineProperties(() => {
|
|
1415
|
+
}, {
|
|
1416
|
+
...styles,
|
|
1417
|
+
level: {
|
|
1418
|
+
enumerable: true,
|
|
1419
|
+
get() {
|
|
1420
|
+
return this._generator.level;
|
|
1421
|
+
},
|
|
1422
|
+
set(level) {
|
|
1423
|
+
this._generator.level = level;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
const createStyler = (open, close, parent) => {
|
|
1428
|
+
let openAll;
|
|
1429
|
+
let closeAll;
|
|
1430
|
+
if (parent === void 0) {
|
|
1431
|
+
openAll = open;
|
|
1432
|
+
closeAll = close;
|
|
1433
|
+
} else {
|
|
1434
|
+
openAll = parent.openAll + open;
|
|
1435
|
+
closeAll = close + parent.closeAll;
|
|
1436
|
+
}
|
|
1437
|
+
return {
|
|
1438
|
+
open,
|
|
1439
|
+
close,
|
|
1440
|
+
openAll,
|
|
1441
|
+
closeAll,
|
|
1442
|
+
parent
|
|
1443
|
+
};
|
|
1444
|
+
};
|
|
1445
|
+
const createBuilder = (self2, _styler, _isEmpty) => {
|
|
1446
|
+
const builder = (...arguments_) => {
|
|
1447
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
1448
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
1449
|
+
}
|
|
1450
|
+
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1451
|
+
};
|
|
1452
|
+
Object.setPrototypeOf(builder, proto);
|
|
1453
|
+
builder._generator = self2;
|
|
1454
|
+
builder._styler = _styler;
|
|
1455
|
+
builder._isEmpty = _isEmpty;
|
|
1456
|
+
return builder;
|
|
1457
|
+
};
|
|
1458
|
+
const applyStyle = (self2, string) => {
|
|
1459
|
+
if (self2.level <= 0 || !string) {
|
|
1460
|
+
return self2._isEmpty ? "" : string;
|
|
1461
|
+
}
|
|
1462
|
+
let styler = self2._styler;
|
|
1463
|
+
if (styler === void 0) {
|
|
1464
|
+
return string;
|
|
1465
|
+
}
|
|
1466
|
+
const { openAll, closeAll } = styler;
|
|
1467
|
+
if (string.indexOf("\x1B") !== -1) {
|
|
1468
|
+
while (styler !== void 0) {
|
|
1469
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
1470
|
+
styler = styler.parent;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
const lfIndex = string.indexOf("\n");
|
|
1474
|
+
if (lfIndex !== -1) {
|
|
1475
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1476
|
+
}
|
|
1477
|
+
return openAll + string + closeAll;
|
|
1478
|
+
};
|
|
1479
|
+
let template;
|
|
1480
|
+
const chalkTag = (chalk2, ...strings) => {
|
|
1481
|
+
const [firstString] = strings;
|
|
1482
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
1483
|
+
return strings.join(" ");
|
|
1484
|
+
}
|
|
1485
|
+
const arguments_ = strings.slice(1);
|
|
1486
|
+
const parts = [firstString.raw[0]];
|
|
1487
|
+
for (let i = 1; i < firstString.length; i++) {
|
|
1488
|
+
parts.push(
|
|
1489
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1490
|
+
String(firstString.raw[i])
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
if (template === void 0) {
|
|
1494
|
+
template = requireTemplates();
|
|
1495
|
+
}
|
|
1496
|
+
return template(chalk2, parts.join(""));
|
|
1497
|
+
};
|
|
1498
|
+
Object.defineProperties(Chalk.prototype, styles);
|
|
1499
|
+
const chalk = Chalk();
|
|
1500
|
+
chalk.supportsColor = stdoutColor;
|
|
1501
|
+
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1502
|
+
chalk.stderr.supportsColor = stderrColor;
|
|
1503
|
+
var source = chalk;
|
|
1504
|
+
const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
|
|
1505
|
+
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
77
1506
|
var sha256$1 = { exports: {} };
|
|
78
1507
|
function commonjsRequire(path) {
|
|
79
1508
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
@@ -1254,9 +2683,9 @@ class STSOAuth2Manager {
|
|
|
1254
2683
|
}
|
|
1255
2684
|
const str = to.query;
|
|
1256
2685
|
if (str[OAuth2ParameterType.CODE] || str[OAuth2ParameterType.ERROR]) {
|
|
1257
|
-
debug$1(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]
|
|
2686
|
+
debug$1(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
|
|
1258
2687
|
const retVal = await oAuth2Manager.HandleRedirect(str);
|
|
1259
|
-
debug$1(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]
|
|
2688
|
+
debug$1(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
|
|
1260
2689
|
if (retVal) {
|
|
1261
2690
|
next({
|
|
1262
2691
|
path: "/",
|
|
@@ -1333,7 +2762,7 @@ class STSOAuth2Manager {
|
|
|
1333
2762
|
debug$1(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
|
|
1334
2763
|
return response.payload;
|
|
1335
2764
|
} catch (error) {
|
|
1336
|
-
console.log(`RestoreSession Error: ${error}`);
|
|
2765
|
+
console.log(chalk$1.red(`RestoreSession Error: ${error}`));
|
|
1337
2766
|
return false;
|
|
1338
2767
|
}
|
|
1339
2768
|
});
|
|
@@ -1348,18 +2777,18 @@ class STSOAuth2Manager {
|
|
|
1348
2777
|
return response.payload.authorizeOptionsClientCopy;
|
|
1349
2778
|
}
|
|
1350
2779
|
} catch (error) {
|
|
1351
|
-
console.log(`Authorize Error: ${error}`);
|
|
2780
|
+
console.log(chalk$1.red(`Authorize Error: ${error}`));
|
|
1352
2781
|
}
|
|
1353
2782
|
return {};
|
|
1354
2783
|
});
|
|
1355
2784
|
__publicField(this, "HandleRedirect", async (queryVars) => {
|
|
1356
2785
|
try {
|
|
1357
|
-
debug$1(`STSOAuth2Manager:HandleRedirect
|
|
2786
|
+
debug$1(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
|
|
1358
2787
|
let response = null;
|
|
1359
2788
|
if (queryVars[OAuth2ParameterType.CODE]) {
|
|
1360
2789
|
const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
1361
2790
|
__privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
1362
|
-
debug$1(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command
|
|
2791
|
+
debug$1(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
|
|
1363
2792
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
|
|
1364
2793
|
queryVars,
|
|
1365
2794
|
authorizeOptions
|
|
@@ -1367,10 +2796,10 @@ class STSOAuth2Manager {
|
|
|
1367
2796
|
} else {
|
|
1368
2797
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
|
|
1369
2798
|
}
|
|
1370
|
-
debug$1(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]
|
|
2799
|
+
debug$1(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
|
|
1371
2800
|
return response.payload;
|
|
1372
2801
|
} catch (error) {
|
|
1373
|
-
console.log(`HandleRedirect Error: ${error}`);
|
|
2802
|
+
console.log(chalk$1.red(`HandleRedirect Error: ${error}`));
|
|
1374
2803
|
return false;
|
|
1375
2804
|
}
|
|
1376
2805
|
});
|
|
@@ -1379,7 +2808,7 @@ class STSOAuth2Manager {
|
|
|
1379
2808
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
|
|
1380
2809
|
return response.payload;
|
|
1381
2810
|
} catch (error) {
|
|
1382
|
-
console.log(`Logout Error: ${error}`);
|
|
2811
|
+
console.log(chalk$1.red(`Logout Error: ${error}`));
|
|
1383
2812
|
return false;
|
|
1384
2813
|
}
|
|
1385
2814
|
});
|
|
@@ -1389,7 +2818,7 @@ class STSOAuth2Manager {
|
|
|
1389
2818
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
|
|
1390
2819
|
return response.payload;
|
|
1391
2820
|
} catch (error) {
|
|
1392
|
-
console.log(`InvokeExternalAPI Error: ${error}`);
|
|
2821
|
+
console.log(chalk$1.red(`InvokeExternalAPI Error: ${error}`));
|
|
1393
2822
|
return null;
|
|
1394
2823
|
}
|
|
1395
2824
|
});
|
|
@@ -1420,10 +2849,10 @@ class STSOAuth2Manager {
|
|
|
1420
2849
|
}
|
|
1421
2850
|
if (!isNode) {
|
|
1422
2851
|
__privateGet(this, _worker).onmessage = (data) => {
|
|
1423
|
-
console.log(`this.#worker.onmessage = [${data}]`);
|
|
2852
|
+
console.log(chalk$1.green(`this.#worker.onmessage = [${data}]`));
|
|
1424
2853
|
};
|
|
1425
2854
|
__privateGet(this, _worker).onerror = function(error) {
|
|
1426
|
-
console.log(`this.#worker.onerror = [${JSON.stringify(error)}]`);
|
|
2855
|
+
console.log(chalk$1.green(`this.#worker.onerror = [${JSON.stringify(error)}]`));
|
|
1427
2856
|
};
|
|
1428
2857
|
}
|
|
1429
2858
|
let workerMessage;
|
|
@@ -1468,7 +2897,7 @@ class STSOAuth2Manager {
|
|
|
1468
2897
|
const response: IOauth2ListenerMessageResponse = await this.#PostMessage({ command: IOauth2ListenerCommand.ID_TOKEN });
|
|
1469
2898
|
return response.payload;
|
|
1470
2899
|
} catch (error) {
|
|
1471
|
-
console.log(`Logout Error: ${error}`);
|
|
2900
|
+
console.log(chalk.red(`Logout Error: ${error}`));
|
|
1472
2901
|
return null;
|
|
1473
2902
|
}
|
|
1474
2903
|
}
|
|
@@ -1735,7 +3164,7 @@ class STSOAuth2Worker {
|
|
|
1735
3164
|
// Ensure cookies are passed to the service
|
|
1736
3165
|
timeout: __privateGet(this, _options2).timeout
|
|
1737
3166
|
};
|
|
1738
|
-
debug(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]
|
|
3167
|
+
debug(chalk$1.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
|
|
1739
3168
|
if (isNode) {
|
|
1740
3169
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
1741
3170
|
}
|
|
@@ -1812,20 +3241,20 @@ class STSOAuth2Worker {
|
|
|
1812
3241
|
__privateAdd(this, _HandleRedirect, async (payload) => {
|
|
1813
3242
|
const queryVars = payload.queryVars;
|
|
1814
3243
|
const authorizeOptions = payload.authorizeOptions;
|
|
1815
|
-
debug(`#HandleRedirect: HandleRedirect
|
|
1816
|
-
debug(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]
|
|
3244
|
+
debug(chalk$1.magenta(`#HandleRedirect: HandleRedirect`));
|
|
3245
|
+
debug(chalk$1.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
|
|
1817
3246
|
if (queryVars[OAuth2ParameterType.CODE]) {
|
|
1818
3247
|
const response = queryVars;
|
|
1819
3248
|
console.log(`authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
|
|
1820
3249
|
const redirectState = response.state;
|
|
1821
3250
|
const authorizeOptionsState = authorizeOptions.state;
|
|
1822
3251
|
if (authorizeOptionsState.localeCompare(redirectState) === 0) {
|
|
1823
|
-
console.log("redirected state (from queryVars) matched previously saved transaction authorizeOptions state");
|
|
3252
|
+
console.log(chalk$1.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
|
|
1824
3253
|
return await __privateGet(this, _GetToken).call(this, authorizeOptions, response);
|
|
1825
3254
|
} else {
|
|
1826
|
-
console.log("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state");
|
|
1827
|
-
console.log(`authorizeOptionsState: [${authorizeOptionsState}]`);
|
|
1828
|
-
console.log(`redirectState: [${redirectState}]`);
|
|
3255
|
+
console.log(chalk$1.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
|
|
3256
|
+
console.log(chalk$1.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
|
|
3257
|
+
console.log(chalk$1.red(`redirectState: [${redirectState}]`));
|
|
1829
3258
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
1830
3259
|
return false;
|
|
1831
3260
|
}
|
|
@@ -1858,7 +3287,7 @@ class STSOAuth2Worker {
|
|
|
1858
3287
|
*/
|
|
1859
3288
|
// Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
|
|
1860
3289
|
__privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
|
|
1861
|
-
debug(`#GetTokenFromBroker
|
|
3290
|
+
debug(chalk$1.magenta(`#GetTokenFromBroker`));
|
|
1862
3291
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
1863
3292
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
|
|
1864
3293
|
try {
|
|
@@ -1870,15 +3299,15 @@ class STSOAuth2Worker {
|
|
|
1870
3299
|
// Ensure cookies are passed to the service
|
|
1871
3300
|
timeout: __privateGet(this, _options2).timeout
|
|
1872
3301
|
};
|
|
1873
|
-
debug(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]
|
|
3302
|
+
debug(chalk$1.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
|
|
1874
3303
|
if (isNode) {
|
|
1875
3304
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
1876
3305
|
}
|
|
1877
|
-
debug(`#GetTokenFromBroker: axios API call
|
|
3306
|
+
debug(chalk$1.magenta(`#GetTokenFromBroker: axios API call`));
|
|
1878
3307
|
const retVal = await axios(rConfig);
|
|
1879
|
-
debug(`#GetTokenFromBroker: axios API call result: [${retVal.status}]
|
|
3308
|
+
debug(chalk$1.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
|
|
1880
3309
|
if (retVal.status === StatusCodes.OK) {
|
|
1881
|
-
debug(`#GetTokenFromBroker: storing tokens
|
|
3310
|
+
debug(chalk$1.magenta(`#GetTokenFromBroker: storing tokens`));
|
|
1882
3311
|
const tokenResponse = retVal.data;
|
|
1883
3312
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, tokenResponse.id_token);
|
|
1884
3313
|
const newSessionData = {
|
|
@@ -1890,18 +3319,18 @@ class STSOAuth2Worker {
|
|
|
1890
3319
|
__privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
|
|
1891
3320
|
return true;
|
|
1892
3321
|
} else if (retVal.status === StatusCodes.UNAUTHORIZED) {
|
|
1893
|
-
debug(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]
|
|
3322
|
+
debug(chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
|
|
1894
3323
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
1895
3324
|
return false;
|
|
1896
3325
|
} else {
|
|
1897
|
-
debug(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]
|
|
3326
|
+
debug(chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
|
|
1898
3327
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
1899
3328
|
console.log("Could not obtain access_token from token end-point:-");
|
|
1900
3329
|
console.log(JSON.stringify(retVal.data));
|
|
1901
3330
|
return false;
|
|
1902
3331
|
}
|
|
1903
3332
|
} catch (error) {
|
|
1904
|
-
debug(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]
|
|
3333
|
+
debug(chalk$1.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
|
|
1905
3334
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
1906
3335
|
return false;
|
|
1907
3336
|
}
|
|
@@ -1960,7 +3389,7 @@ class STSOAuth2Worker {
|
|
|
1960
3389
|
};
|
|
1961
3390
|
return await __privateGet(this, _GetTokenFromBroker).call(this, refreshFlowParameters);
|
|
1962
3391
|
} else {
|
|
1963
|
-
debug(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore
|
|
3392
|
+
debug(chalk$1.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
|
|
1964
3393
|
return false;
|
|
1965
3394
|
}
|
|
1966
3395
|
});
|
|
@@ -1995,7 +3424,7 @@ class STSOAuth2Worker {
|
|
|
1995
3424
|
// Ensure cookies are passed to the service
|
|
1996
3425
|
timeout: __privateGet(this, _options2).timeout
|
|
1997
3426
|
};
|
|
1998
|
-
debug(`#Logout: request config: [${rConfig}]
|
|
3427
|
+
debug(chalk$1.magenta(`#Logout: request config: [${rConfig}]`));
|
|
1999
3428
|
if (isNode) {
|
|
2000
3429
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
2001
3430
|
}
|