@salty-css/react 0.0.1-alpha.24 → 0.0.1-alpha.240

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/helpers.js ADDED
@@ -0,0 +1,1156 @@
1
+ var A = Object.defineProperty;
2
+ var S = (e, t, n) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var _ = (e, t, n) => S(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const k = {
5
+ aliceblue: [240, 248, 255],
6
+ antiquewhite: [250, 235, 215],
7
+ aqua: [0, 255, 255],
8
+ aquamarine: [127, 255, 212],
9
+ azure: [240, 255, 255],
10
+ beige: [245, 245, 220],
11
+ bisque: [255, 228, 196],
12
+ black: [0, 0, 0],
13
+ blanchedalmond: [255, 235, 205],
14
+ blue: [0, 0, 255],
15
+ blueviolet: [138, 43, 226],
16
+ brown: [165, 42, 42],
17
+ burlywood: [222, 184, 135],
18
+ cadetblue: [95, 158, 160],
19
+ chartreuse: [127, 255, 0],
20
+ chocolate: [210, 105, 30],
21
+ coral: [255, 127, 80],
22
+ cornflowerblue: [100, 149, 237],
23
+ cornsilk: [255, 248, 220],
24
+ crimson: [220, 20, 60],
25
+ cyan: [0, 255, 255],
26
+ darkblue: [0, 0, 139],
27
+ darkcyan: [0, 139, 139],
28
+ darkgoldenrod: [184, 134, 11],
29
+ darkgray: [169, 169, 169],
30
+ darkgreen: [0, 100, 0],
31
+ darkgrey: [169, 169, 169],
32
+ darkkhaki: [189, 183, 107],
33
+ darkmagenta: [139, 0, 139],
34
+ darkolivegreen: [85, 107, 47],
35
+ darkorange: [255, 140, 0],
36
+ darkorchid: [153, 50, 204],
37
+ darkred: [139, 0, 0],
38
+ darksalmon: [233, 150, 122],
39
+ darkseagreen: [143, 188, 143],
40
+ darkslateblue: [72, 61, 139],
41
+ darkslategray: [47, 79, 79],
42
+ darkslategrey: [47, 79, 79],
43
+ darkturquoise: [0, 206, 209],
44
+ darkviolet: [148, 0, 211],
45
+ deeppink: [255, 20, 147],
46
+ deepskyblue: [0, 191, 255],
47
+ dimgray: [105, 105, 105],
48
+ dimgrey: [105, 105, 105],
49
+ dodgerblue: [30, 144, 255],
50
+ firebrick: [178, 34, 34],
51
+ floralwhite: [255, 250, 240],
52
+ forestgreen: [34, 139, 34],
53
+ fuchsia: [255, 0, 255],
54
+ gainsboro: [220, 220, 220],
55
+ ghostwhite: [248, 248, 255],
56
+ gold: [255, 215, 0],
57
+ goldenrod: [218, 165, 32],
58
+ gray: [128, 128, 128],
59
+ green: [0, 128, 0],
60
+ greenyellow: [173, 255, 47],
61
+ grey: [128, 128, 128],
62
+ honeydew: [240, 255, 240],
63
+ hotpink: [255, 105, 180],
64
+ indianred: [205, 92, 92],
65
+ indigo: [75, 0, 130],
66
+ ivory: [255, 255, 240],
67
+ khaki: [240, 230, 140],
68
+ lavender: [230, 230, 250],
69
+ lavenderblush: [255, 240, 245],
70
+ lawngreen: [124, 252, 0],
71
+ lemonchiffon: [255, 250, 205],
72
+ lightblue: [173, 216, 230],
73
+ lightcoral: [240, 128, 128],
74
+ lightcyan: [224, 255, 255],
75
+ lightgoldenrodyellow: [250, 250, 210],
76
+ lightgray: [211, 211, 211],
77
+ lightgreen: [144, 238, 144],
78
+ lightgrey: [211, 211, 211],
79
+ lightpink: [255, 182, 193],
80
+ lightsalmon: [255, 160, 122],
81
+ lightseagreen: [32, 178, 170],
82
+ lightskyblue: [135, 206, 250],
83
+ lightslategray: [119, 136, 153],
84
+ lightslategrey: [119, 136, 153],
85
+ lightsteelblue: [176, 196, 222],
86
+ lightyellow: [255, 255, 224],
87
+ lime: [0, 255, 0],
88
+ limegreen: [50, 205, 50],
89
+ linen: [250, 240, 230],
90
+ magenta: [255, 0, 255],
91
+ maroon: [128, 0, 0],
92
+ mediumaquamarine: [102, 205, 170],
93
+ mediumblue: [0, 0, 205],
94
+ mediumorchid: [186, 85, 211],
95
+ mediumpurple: [147, 112, 219],
96
+ mediumseagreen: [60, 179, 113],
97
+ mediumslateblue: [123, 104, 238],
98
+ mediumspringgreen: [0, 250, 154],
99
+ mediumturquoise: [72, 209, 204],
100
+ mediumvioletred: [199, 21, 133],
101
+ midnightblue: [25, 25, 112],
102
+ mintcream: [245, 255, 250],
103
+ mistyrose: [255, 228, 225],
104
+ moccasin: [255, 228, 181],
105
+ navajowhite: [255, 222, 173],
106
+ navy: [0, 0, 128],
107
+ oldlace: [253, 245, 230],
108
+ olive: [128, 128, 0],
109
+ olivedrab: [107, 142, 35],
110
+ orange: [255, 165, 0],
111
+ orangered: [255, 69, 0],
112
+ orchid: [218, 112, 214],
113
+ palegoldenrod: [238, 232, 170],
114
+ palegreen: [152, 251, 152],
115
+ paleturquoise: [175, 238, 238],
116
+ palevioletred: [219, 112, 147],
117
+ papayawhip: [255, 239, 213],
118
+ peachpuff: [255, 218, 185],
119
+ peru: [205, 133, 63],
120
+ pink: [255, 192, 203],
121
+ plum: [221, 160, 221],
122
+ powderblue: [176, 224, 230],
123
+ purple: [128, 0, 128],
124
+ rebeccapurple: [102, 51, 153],
125
+ red: [255, 0, 0],
126
+ rosybrown: [188, 143, 143],
127
+ royalblue: [65, 105, 225],
128
+ saddlebrown: [139, 69, 19],
129
+ salmon: [250, 128, 114],
130
+ sandybrown: [244, 164, 96],
131
+ seagreen: [46, 139, 87],
132
+ seashell: [255, 245, 238],
133
+ sienna: [160, 82, 45],
134
+ silver: [192, 192, 192],
135
+ skyblue: [135, 206, 235],
136
+ slateblue: [106, 90, 205],
137
+ slategray: [112, 128, 144],
138
+ slategrey: [112, 128, 144],
139
+ snow: [255, 250, 250],
140
+ springgreen: [0, 255, 127],
141
+ steelblue: [70, 130, 180],
142
+ tan: [210, 180, 140],
143
+ teal: [0, 128, 128],
144
+ thistle: [216, 191, 216],
145
+ tomato: [255, 99, 71],
146
+ turquoise: [64, 224, 208],
147
+ violet: [238, 130, 238],
148
+ wheat: [245, 222, 179],
149
+ white: [255, 255, 255],
150
+ whitesmoke: [245, 245, 245],
151
+ yellow: [255, 255, 0],
152
+ yellowgreen: [154, 205, 50]
153
+ }, O = /* @__PURE__ */ Object.create(null);
154
+ for (const e in k)
155
+ Object.hasOwn(k, e) && (O[k[e]] = e);
156
+ const d = {
157
+ to: {},
158
+ get: {}
159
+ };
160
+ d.get = function(e) {
161
+ const t = e.slice(0, 3).toLowerCase();
162
+ let n, r;
163
+ switch (t) {
164
+ case "hsl": {
165
+ n = d.get.hsl(e), r = "hsl";
166
+ break;
167
+ }
168
+ case "hwb": {
169
+ n = d.get.hwb(e), r = "hwb";
170
+ break;
171
+ }
172
+ default: {
173
+ n = d.get.rgb(e), r = "rgb";
174
+ break;
175
+ }
176
+ }
177
+ return n ? { model: r, value: n } : null;
178
+ };
179
+ d.get.rgb = function(e) {
180
+ if (!e)
181
+ return null;
182
+ const t = /^#([a-f\d]{3,4})$/i, n = /^#([a-f\d]{6})([a-f\d]{2})?$/i, r = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/, o = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/, l = /^(\w+)$/;
183
+ let s = [0, 0, 0, 1], a, i, u;
184
+ if (a = e.match(n)) {
185
+ for (u = a[2], a = a[1], i = 0; i < 3; i++) {
186
+ const m = i * 2;
187
+ s[i] = Number.parseInt(a.slice(m, m + 2), 16);
188
+ }
189
+ u && (s[3] = Number.parseInt(u, 16) / 255);
190
+ } else if (a = e.match(t)) {
191
+ for (a = a[1], u = a[3], i = 0; i < 3; i++)
192
+ s[i] = Number.parseInt(a[i] + a[i], 16);
193
+ u && (s[3] = Number.parseInt(u + u, 16) / 255);
194
+ } else if (a = e.match(r)) {
195
+ for (i = 0; i < 3; i++)
196
+ s[i] = Number.parseInt(a[i + 1], 10);
197
+ a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
198
+ } else if (a = e.match(o)) {
199
+ for (i = 0; i < 3; i++)
200
+ s[i] = Math.round(Number.parseFloat(a[i + 1]) * 2.55);
201
+ a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
202
+ } else return (a = e.match(l)) ? a[1] === "transparent" ? [0, 0, 0, 0] : Object.hasOwn(k, a[1]) ? (s = k[a[1]], s[3] = 1, s) : null : null;
203
+ for (i = 0; i < 3; i++)
204
+ s[i] = w(s[i], 0, 255);
205
+ return s[3] = w(s[3], 0, 1), s;
206
+ };
207
+ d.get.hsl = function(e) {
208
+ if (!e)
209
+ return null;
210
+ const t = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, n = e.match(t);
211
+ if (n) {
212
+ const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = w(Number.parseFloat(n[2]), 0, 100), s = w(Number.parseFloat(n[3]), 0, 100), a = w(Number.isNaN(r) ? 1 : r, 0, 1);
213
+ return [o, l, s, a];
214
+ }
215
+ return null;
216
+ };
217
+ d.get.hwb = function(e) {
218
+ if (!e)
219
+ return null;
220
+ const t = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, n = e.match(t);
221
+ if (n) {
222
+ const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = w(Number.parseFloat(n[2]), 0, 100), s = w(Number.parseFloat(n[3]), 0, 100), a = w(Number.isNaN(r) ? 1 : r, 0, 1);
223
+ return [o, l, s, a];
224
+ }
225
+ return null;
226
+ };
227
+ d.to.hex = function(...e) {
228
+ return "#" + x(e[0]) + x(e[1]) + x(e[2]) + (e[3] < 1 ? x(Math.round(e[3] * 255)) : "");
229
+ };
230
+ d.to.rgb = function(...e) {
231
+ return e.length < 4 || e[3] === 1 ? "rgb(" + Math.round(e[0]) + ", " + Math.round(e[1]) + ", " + Math.round(e[2]) + ")" : "rgba(" + Math.round(e[0]) + ", " + Math.round(e[1]) + ", " + Math.round(e[2]) + ", " + e[3] + ")";
232
+ };
233
+ d.to.rgb.percent = function(...e) {
234
+ const t = Math.round(e[0] / 255 * 100), n = Math.round(e[1] / 255 * 100), r = Math.round(e[2] / 255 * 100);
235
+ return e.length < 4 || e[3] === 1 ? "rgb(" + t + "%, " + n + "%, " + r + "%)" : "rgba(" + t + "%, " + n + "%, " + r + "%, " + e[3] + ")";
236
+ };
237
+ d.to.hsl = function(...e) {
238
+ return e.length < 4 || e[3] === 1 ? "hsl(" + e[0] + ", " + e[1] + "%, " + e[2] + "%)" : "hsla(" + e[0] + ", " + e[1] + "%, " + e[2] + "%, " + e[3] + ")";
239
+ };
240
+ d.to.hwb = function(...e) {
241
+ let t = "";
242
+ return e.length >= 4 && e[3] !== 1 && (t = ", " + e[3]), "hwb(" + e[0] + ", " + e[1] + "%, " + e[2] + "%" + t + ")";
243
+ };
244
+ d.to.keyword = function(...e) {
245
+ return O[e.slice(0, 3)];
246
+ };
247
+ function w(e, t, n) {
248
+ return Math.min(Math.max(t, e), n);
249
+ }
250
+ function x(e) {
251
+ const t = Math.round(e).toString(16).toUpperCase();
252
+ return t.length < 2 ? "0" + t : t;
253
+ }
254
+ const M = {
255
+ aliceblue: [240, 248, 255],
256
+ antiquewhite: [250, 235, 215],
257
+ aqua: [0, 255, 255],
258
+ aquamarine: [127, 255, 212],
259
+ azure: [240, 255, 255],
260
+ beige: [245, 245, 220],
261
+ bisque: [255, 228, 196],
262
+ black: [0, 0, 0],
263
+ blanchedalmond: [255, 235, 205],
264
+ blue: [0, 0, 255],
265
+ blueviolet: [138, 43, 226],
266
+ brown: [165, 42, 42],
267
+ burlywood: [222, 184, 135],
268
+ cadetblue: [95, 158, 160],
269
+ chartreuse: [127, 255, 0],
270
+ chocolate: [210, 105, 30],
271
+ coral: [255, 127, 80],
272
+ cornflowerblue: [100, 149, 237],
273
+ cornsilk: [255, 248, 220],
274
+ crimson: [220, 20, 60],
275
+ cyan: [0, 255, 255],
276
+ darkblue: [0, 0, 139],
277
+ darkcyan: [0, 139, 139],
278
+ darkgoldenrod: [184, 134, 11],
279
+ darkgray: [169, 169, 169],
280
+ darkgreen: [0, 100, 0],
281
+ darkgrey: [169, 169, 169],
282
+ darkkhaki: [189, 183, 107],
283
+ darkmagenta: [139, 0, 139],
284
+ darkolivegreen: [85, 107, 47],
285
+ darkorange: [255, 140, 0],
286
+ darkorchid: [153, 50, 204],
287
+ darkred: [139, 0, 0],
288
+ darksalmon: [233, 150, 122],
289
+ darkseagreen: [143, 188, 143],
290
+ darkslateblue: [72, 61, 139],
291
+ darkslategray: [47, 79, 79],
292
+ darkslategrey: [47, 79, 79],
293
+ darkturquoise: [0, 206, 209],
294
+ darkviolet: [148, 0, 211],
295
+ deeppink: [255, 20, 147],
296
+ deepskyblue: [0, 191, 255],
297
+ dimgray: [105, 105, 105],
298
+ dimgrey: [105, 105, 105],
299
+ dodgerblue: [30, 144, 255],
300
+ firebrick: [178, 34, 34],
301
+ floralwhite: [255, 250, 240],
302
+ forestgreen: [34, 139, 34],
303
+ fuchsia: [255, 0, 255],
304
+ gainsboro: [220, 220, 220],
305
+ ghostwhite: [248, 248, 255],
306
+ gold: [255, 215, 0],
307
+ goldenrod: [218, 165, 32],
308
+ gray: [128, 128, 128],
309
+ green: [0, 128, 0],
310
+ greenyellow: [173, 255, 47],
311
+ grey: [128, 128, 128],
312
+ honeydew: [240, 255, 240],
313
+ hotpink: [255, 105, 180],
314
+ indianred: [205, 92, 92],
315
+ indigo: [75, 0, 130],
316
+ ivory: [255, 255, 240],
317
+ khaki: [240, 230, 140],
318
+ lavender: [230, 230, 250],
319
+ lavenderblush: [255, 240, 245],
320
+ lawngreen: [124, 252, 0],
321
+ lemonchiffon: [255, 250, 205],
322
+ lightblue: [173, 216, 230],
323
+ lightcoral: [240, 128, 128],
324
+ lightcyan: [224, 255, 255],
325
+ lightgoldenrodyellow: [250, 250, 210],
326
+ lightgray: [211, 211, 211],
327
+ lightgreen: [144, 238, 144],
328
+ lightgrey: [211, 211, 211],
329
+ lightpink: [255, 182, 193],
330
+ lightsalmon: [255, 160, 122],
331
+ lightseagreen: [32, 178, 170],
332
+ lightskyblue: [135, 206, 250],
333
+ lightslategray: [119, 136, 153],
334
+ lightslategrey: [119, 136, 153],
335
+ lightsteelblue: [176, 196, 222],
336
+ lightyellow: [255, 255, 224],
337
+ lime: [0, 255, 0],
338
+ limegreen: [50, 205, 50],
339
+ linen: [250, 240, 230],
340
+ magenta: [255, 0, 255],
341
+ maroon: [128, 0, 0],
342
+ mediumaquamarine: [102, 205, 170],
343
+ mediumblue: [0, 0, 205],
344
+ mediumorchid: [186, 85, 211],
345
+ mediumpurple: [147, 112, 219],
346
+ mediumseagreen: [60, 179, 113],
347
+ mediumslateblue: [123, 104, 238],
348
+ mediumspringgreen: [0, 250, 154],
349
+ mediumturquoise: [72, 209, 204],
350
+ mediumvioletred: [199, 21, 133],
351
+ midnightblue: [25, 25, 112],
352
+ mintcream: [245, 255, 250],
353
+ mistyrose: [255, 228, 225],
354
+ moccasin: [255, 228, 181],
355
+ navajowhite: [255, 222, 173],
356
+ navy: [0, 0, 128],
357
+ oldlace: [253, 245, 230],
358
+ olive: [128, 128, 0],
359
+ olivedrab: [107, 142, 35],
360
+ orange: [255, 165, 0],
361
+ orangered: [255, 69, 0],
362
+ orchid: [218, 112, 214],
363
+ palegoldenrod: [238, 232, 170],
364
+ palegreen: [152, 251, 152],
365
+ paleturquoise: [175, 238, 238],
366
+ palevioletred: [219, 112, 147],
367
+ papayawhip: [255, 239, 213],
368
+ peachpuff: [255, 218, 185],
369
+ peru: [205, 133, 63],
370
+ pink: [255, 192, 203],
371
+ plum: [221, 160, 221],
372
+ powderblue: [176, 224, 230],
373
+ purple: [128, 0, 128],
374
+ rebeccapurple: [102, 51, 153],
375
+ red: [255, 0, 0],
376
+ rosybrown: [188, 143, 143],
377
+ royalblue: [65, 105, 225],
378
+ saddlebrown: [139, 69, 19],
379
+ salmon: [250, 128, 114],
380
+ sandybrown: [244, 164, 96],
381
+ seagreen: [46, 139, 87],
382
+ seashell: [255, 245, 238],
383
+ sienna: [160, 82, 45],
384
+ silver: [192, 192, 192],
385
+ skyblue: [135, 206, 235],
386
+ slateblue: [106, 90, 205],
387
+ slategray: [112, 128, 144],
388
+ slategrey: [112, 128, 144],
389
+ snow: [255, 250, 250],
390
+ springgreen: [0, 255, 127],
391
+ steelblue: [70, 130, 180],
392
+ tan: [210, 180, 140],
393
+ teal: [0, 128, 128],
394
+ thistle: [216, 191, 216],
395
+ tomato: [255, 99, 71],
396
+ turquoise: [64, 224, 208],
397
+ violet: [238, 130, 238],
398
+ wheat: [245, 222, 179],
399
+ white: [255, 255, 255],
400
+ whitesmoke: [245, 245, 245],
401
+ yellow: [255, 255, 0],
402
+ yellowgreen: [154, 205, 50]
403
+ }, q = {};
404
+ for (const e of Object.keys(M))
405
+ q[M[e]] = e;
406
+ const c = {
407
+ rgb: { channels: 3, labels: "rgb" },
408
+ hsl: { channels: 3, labels: "hsl" },
409
+ hsv: { channels: 3, labels: "hsv" },
410
+ hwb: { channels: 3, labels: "hwb" },
411
+ cmyk: { channels: 4, labels: "cmyk" },
412
+ xyz: { channels: 3, labels: "xyz" },
413
+ lab: { channels: 3, labels: "lab" },
414
+ lch: { channels: 3, labels: "lch" },
415
+ hex: { channels: 1, labels: ["hex"] },
416
+ keyword: { channels: 1, labels: ["keyword"] },
417
+ ansi16: { channels: 1, labels: ["ansi16"] },
418
+ ansi256: { channels: 1, labels: ["ansi256"] },
419
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
420
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
421
+ gray: { channels: 1, labels: ["gray"] }
422
+ }, y = (6 / 29) ** 3;
423
+ for (const e of Object.keys(c)) {
424
+ if (!("channels" in c[e]))
425
+ throw new Error("missing channels property: " + e);
426
+ if (!("labels" in c[e]))
427
+ throw new Error("missing channel labels property: " + e);
428
+ if (c[e].labels.length !== c[e].channels)
429
+ throw new Error("channel and label counts mismatch: " + e);
430
+ const { channels: t, labels: n } = c[e];
431
+ delete c[e].channels, delete c[e].labels, Object.defineProperty(c[e], "channels", { value: t }), Object.defineProperty(c[e], "labels", { value: n });
432
+ }
433
+ c.rgb.hsl = function(e) {
434
+ const t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, o = Math.min(t, n, r), l = Math.max(t, n, r), s = l - o;
435
+ let a, i;
436
+ switch (l) {
437
+ case o: {
438
+ a = 0;
439
+ break;
440
+ }
441
+ case t: {
442
+ a = (n - r) / s;
443
+ break;
444
+ }
445
+ case n: {
446
+ a = 2 + (r - t) / s;
447
+ break;
448
+ }
449
+ case r: {
450
+ a = 4 + (t - n) / s;
451
+ break;
452
+ }
453
+ }
454
+ a = Math.min(a * 60, 360), a < 0 && (a += 360);
455
+ const u = (o + l) / 2;
456
+ return l === o ? i = 0 : u <= 0.5 ? i = s / (l + o) : i = s / (2 - l - o), [a, i * 100, u * 100];
457
+ };
458
+ c.rgb.hsv = function(e) {
459
+ let t, n, r, o, l;
460
+ const s = e[0] / 255, a = e[1] / 255, i = e[2] / 255, u = Math.max(s, a, i), m = u - Math.min(s, a, i), p = function(z) {
461
+ return (u - z) / 6 / m + 1 / 2;
462
+ };
463
+ if (m === 0)
464
+ o = 0, l = 0;
465
+ else {
466
+ switch (l = m / u, t = p(s), n = p(a), r = p(i), u) {
467
+ case s: {
468
+ o = r - n;
469
+ break;
470
+ }
471
+ case a: {
472
+ o = 1 / 3 + t - r;
473
+ break;
474
+ }
475
+ case i: {
476
+ o = 2 / 3 + n - t;
477
+ break;
478
+ }
479
+ }
480
+ o < 0 ? o += 1 : o > 1 && (o -= 1);
481
+ }
482
+ return [
483
+ o * 360,
484
+ l * 100,
485
+ u * 100
486
+ ];
487
+ };
488
+ c.rgb.hwb = function(e) {
489
+ const t = e[0], n = e[1];
490
+ let r = e[2];
491
+ const o = c.rgb.hsl(e)[0], l = 1 / 255 * Math.min(t, Math.min(n, r));
492
+ return r = 1 - 1 / 255 * Math.max(t, Math.max(n, r)), [o, l * 100, r * 100];
493
+ };
494
+ c.rgb.cmyk = function(e) {
495
+ const t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, o = Math.min(1 - t, 1 - n, 1 - r), l = (1 - t - o) / (1 - o) || 0, s = (1 - n - o) / (1 - o) || 0, a = (1 - r - o) / (1 - o) || 0;
496
+ return [l * 100, s * 100, a * 100, o * 100];
497
+ };
498
+ function P(e, t) {
499
+ return (e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2 + (e[2] - t[2]) ** 2;
500
+ }
501
+ c.rgb.keyword = function(e) {
502
+ const t = q[e];
503
+ if (t)
504
+ return t;
505
+ let n = Number.POSITIVE_INFINITY, r;
506
+ for (const o of Object.keys(M)) {
507
+ const l = M[o], s = P(e, l);
508
+ s < n && (n = s, r = o);
509
+ }
510
+ return r;
511
+ };
512
+ c.keyword.rgb = function(e) {
513
+ return M[e];
514
+ };
515
+ c.rgb.xyz = function(e) {
516
+ let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255;
517
+ t = t > 0.04045 ? ((t + 0.055) / 1.055) ** 2.4 : t / 12.92, n = n > 0.04045 ? ((n + 0.055) / 1.055) ** 2.4 : n / 12.92, r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
518
+ const o = t * 0.4124564 + n * 0.3575761 + r * 0.1804375, l = t * 0.2126729 + n * 0.7151522 + r * 0.072175, s = t * 0.0193339 + n * 0.119192 + r * 0.9503041;
519
+ return [o * 100, l * 100, s * 100];
520
+ };
521
+ c.rgb.lab = function(e) {
522
+ const t = c.rgb.xyz(e);
523
+ let n = t[0], r = t[1], o = t[2];
524
+ n /= 95.047, r /= 100, o /= 108.883, n = n > y ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > y ? r ** (1 / 3) : 7.787 * r + 16 / 116, o = o > y ? o ** (1 / 3) : 7.787 * o + 16 / 116;
525
+ const l = 116 * r - 16, s = 500 * (n - r), a = 200 * (r - o);
526
+ return [l, s, a];
527
+ };
528
+ c.hsl.rgb = function(e) {
529
+ const t = e[0] / 360, n = e[1] / 100, r = e[2] / 100;
530
+ let o, l;
531
+ if (n === 0)
532
+ return l = r * 255, [l, l, l];
533
+ const s = r < 0.5 ? r * (1 + n) : r + n - r * n, a = 2 * r - s, i = [0, 0, 0];
534
+ for (let u = 0; u < 3; u++)
535
+ o = t + 1 / 3 * -(u - 1), o < 0 && o++, o > 1 && o--, 6 * o < 1 ? l = a + (s - a) * 6 * o : 2 * o < 1 ? l = s : 3 * o < 2 ? l = a + (s - a) * (2 / 3 - o) * 6 : l = a, i[u] = l * 255;
536
+ return i;
537
+ };
538
+ c.hsl.hsv = function(e) {
539
+ const t = e[0];
540
+ let n = e[1] / 100, r = e[2] / 100, o = n;
541
+ const l = Math.max(r, 0.01);
542
+ r *= 2, n *= r <= 1 ? r : 2 - r, o *= l <= 1 ? l : 2 - l;
543
+ const s = (r + n) / 2, a = r === 0 ? 2 * o / (l + o) : 2 * n / (r + n);
544
+ return [t, a * 100, s * 100];
545
+ };
546
+ c.hsv.rgb = function(e) {
547
+ const t = e[0] / 60, n = e[1] / 100;
548
+ let r = e[2] / 100;
549
+ const o = Math.floor(t) % 6, l = t - Math.floor(t), s = 255 * r * (1 - n), a = 255 * r * (1 - n * l), i = 255 * r * (1 - n * (1 - l));
550
+ switch (r *= 255, o) {
551
+ case 0:
552
+ return [r, i, s];
553
+ case 1:
554
+ return [a, r, s];
555
+ case 2:
556
+ return [s, r, i];
557
+ case 3:
558
+ return [s, a, r];
559
+ case 4:
560
+ return [i, s, r];
561
+ case 5:
562
+ return [r, s, a];
563
+ }
564
+ };
565
+ c.hsv.hsl = function(e) {
566
+ const t = e[0], n = e[1] / 100, r = e[2] / 100, o = Math.max(r, 0.01);
567
+ let l, s;
568
+ s = (2 - n) * r;
569
+ const a = (2 - n) * o;
570
+ return l = n * o, l /= a <= 1 ? a : 2 - a, l = l || 0, s /= 2, [t, l * 100, s * 100];
571
+ };
572
+ c.hwb.rgb = function(e) {
573
+ const t = e[0] / 360;
574
+ let n = e[1] / 100, r = e[2] / 100;
575
+ const o = n + r;
576
+ let l;
577
+ o > 1 && (n /= o, r /= o);
578
+ const s = Math.floor(6 * t), a = 1 - r;
579
+ l = 6 * t - s, (s & 1) !== 0 && (l = 1 - l);
580
+ const i = n + l * (a - n);
581
+ let u, m, p;
582
+ switch (s) {
583
+ default:
584
+ case 6:
585
+ case 0: {
586
+ u = a, m = i, p = n;
587
+ break;
588
+ }
589
+ case 1: {
590
+ u = i, m = a, p = n;
591
+ break;
592
+ }
593
+ case 2: {
594
+ u = n, m = a, p = i;
595
+ break;
596
+ }
597
+ case 3: {
598
+ u = n, m = i, p = a;
599
+ break;
600
+ }
601
+ case 4: {
602
+ u = i, m = n, p = a;
603
+ break;
604
+ }
605
+ case 5: {
606
+ u = a, m = n, p = i;
607
+ break;
608
+ }
609
+ }
610
+ return [u * 255, m * 255, p * 255];
611
+ };
612
+ c.cmyk.rgb = function(e) {
613
+ const t = e[0] / 100, n = e[1] / 100, r = e[2] / 100, o = e[3] / 100, l = 1 - Math.min(1, t * (1 - o) + o), s = 1 - Math.min(1, n * (1 - o) + o), a = 1 - Math.min(1, r * (1 - o) + o);
614
+ return [l * 255, s * 255, a * 255];
615
+ };
616
+ c.xyz.rgb = function(e) {
617
+ const t = e[0] / 100, n = e[1] / 100, r = e[2] / 100;
618
+ let o, l, s;
619
+ return o = t * 3.2404542 + n * -1.5371385 + r * -0.4985314, l = t * -0.969266 + n * 1.8760108 + r * 0.041556, s = t * 0.0556434 + n * -0.2040259 + r * 1.0572252, o = o > 31308e-7 ? 1.055 * o ** (1 / 2.4) - 0.055 : o * 12.92, l = l > 31308e-7 ? 1.055 * l ** (1 / 2.4) - 0.055 : l * 12.92, s = s > 31308e-7 ? 1.055 * s ** (1 / 2.4) - 0.055 : s * 12.92, o = Math.min(Math.max(0, o), 1), l = Math.min(Math.max(0, l), 1), s = Math.min(Math.max(0, s), 1), [o * 255, l * 255, s * 255];
620
+ };
621
+ c.xyz.lab = function(e) {
622
+ let t = e[0], n = e[1], r = e[2];
623
+ t /= 95.047, n /= 100, r /= 108.883, t = t > y ? t ** (1 / 3) : 7.787 * t + 16 / 116, n = n > y ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > y ? r ** (1 / 3) : 7.787 * r + 16 / 116;
624
+ const o = 116 * n - 16, l = 500 * (t - n), s = 200 * (n - r);
625
+ return [o, l, s];
626
+ };
627
+ c.lab.xyz = function(e) {
628
+ const t = e[0], n = e[1], r = e[2];
629
+ let o, l, s;
630
+ l = (t + 16) / 116, o = n / 500 + l, s = l - r / 200;
631
+ const a = l ** 3, i = o ** 3, u = s ** 3;
632
+ return l = a > y ? a : (l - 16 / 116) / 7.787, o = i > y ? i : (o - 16 / 116) / 7.787, s = u > y ? u : (s - 16 / 116) / 7.787, o *= 95.047, l *= 100, s *= 108.883, [o, l, s];
633
+ };
634
+ c.lab.lch = function(e) {
635
+ const t = e[0], n = e[1], r = e[2];
636
+ let o;
637
+ o = Math.atan2(r, n) * 360 / 2 / Math.PI, o < 0 && (o += 360);
638
+ const s = Math.sqrt(n * n + r * r);
639
+ return [t, s, o];
640
+ };
641
+ c.lch.lab = function(e) {
642
+ const t = e[0], n = e[1], o = e[2] / 360 * 2 * Math.PI, l = n * Math.cos(o), s = n * Math.sin(o);
643
+ return [t, l, s];
644
+ };
645
+ c.rgb.ansi16 = function(e, t = null) {
646
+ const [n, r, o] = e;
647
+ let l = t === null ? c.rgb.hsv(e)[2] : t;
648
+ if (l = Math.round(l / 50), l === 0)
649
+ return 30;
650
+ let s = 30 + (Math.round(o / 255) << 2 | Math.round(r / 255) << 1 | Math.round(n / 255));
651
+ return l === 2 && (s += 60), s;
652
+ };
653
+ c.hsv.ansi16 = function(e) {
654
+ return c.rgb.ansi16(c.hsv.rgb(e), e[2]);
655
+ };
656
+ c.rgb.ansi256 = function(e) {
657
+ const t = e[0], n = e[1], r = e[2];
658
+ return t >> 4 === n >> 4 && n >> 4 === r >> 4 ? t < 8 ? 16 : t > 248 ? 231 : Math.round((t - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(t / 255 * 5) + 6 * Math.round(n / 255 * 5) + Math.round(r / 255 * 5);
659
+ };
660
+ c.ansi16.rgb = function(e) {
661
+ e = e[0];
662
+ let t = e % 10;
663
+ if (t === 0 || t === 7)
664
+ return e > 50 && (t += 3.5), t = t / 10.5 * 255, [t, t, t];
665
+ const n = (Math.trunc(e > 50) + 1) * 0.5, r = (t & 1) * n * 255, o = (t >> 1 & 1) * n * 255, l = (t >> 2 & 1) * n * 255;
666
+ return [r, o, l];
667
+ };
668
+ c.ansi256.rgb = function(e) {
669
+ if (e = e[0], e >= 232) {
670
+ const l = (e - 232) * 10 + 8;
671
+ return [l, l, l];
672
+ }
673
+ e -= 16;
674
+ let t;
675
+ const n = Math.floor(e / 36) / 5 * 255, r = Math.floor((t = e % 36) / 6) / 5 * 255, o = t % 6 / 5 * 255;
676
+ return [n, r, o];
677
+ };
678
+ c.rgb.hex = function(e) {
679
+ const n = (((Math.round(e[0]) & 255) << 16) + ((Math.round(e[1]) & 255) << 8) + (Math.round(e[2]) & 255)).toString(16).toUpperCase();
680
+ return "000000".slice(n.length) + n;
681
+ };
682
+ c.hex.rgb = function(e) {
683
+ const t = e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
684
+ if (!t)
685
+ return [0, 0, 0];
686
+ let n = t[0];
687
+ t[0].length === 3 && (n = [...n].map((a) => a + a).join(""));
688
+ const r = Number.parseInt(n, 16), o = r >> 16 & 255, l = r >> 8 & 255, s = r & 255;
689
+ return [o, l, s];
690
+ };
691
+ c.rgb.hcg = function(e) {
692
+ const t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, o = Math.max(Math.max(t, n), r), l = Math.min(Math.min(t, n), r), s = o - l;
693
+ let a;
694
+ const i = s < 1 ? l / (1 - s) : 0;
695
+ return s <= 0 ? a = 0 : o === t ? a = (n - r) / s % 6 : o === n ? a = 2 + (r - t) / s : a = 4 + (t - n) / s, a /= 6, a %= 1, [a * 360, s * 100, i * 100];
696
+ };
697
+ c.hsl.hcg = function(e) {
698
+ const t = e[1] / 100, n = e[2] / 100, r = n < 0.5 ? 2 * t * n : 2 * t * (1 - n);
699
+ let o = 0;
700
+ return r < 1 && (o = (n - 0.5 * r) / (1 - r)), [e[0], r * 100, o * 100];
701
+ };
702
+ c.hsv.hcg = function(e) {
703
+ const t = e[1] / 100, n = e[2] / 100, r = t * n;
704
+ let o = 0;
705
+ return r < 1 && (o = (n - r) / (1 - r)), [e[0], r * 100, o * 100];
706
+ };
707
+ c.hcg.rgb = function(e) {
708
+ const t = e[0] / 360, n = e[1] / 100, r = e[2] / 100;
709
+ if (n === 0)
710
+ return [r * 255, r * 255, r * 255];
711
+ const o = [0, 0, 0], l = t % 1 * 6, s = l % 1, a = 1 - s;
712
+ let i = 0;
713
+ switch (Math.floor(l)) {
714
+ case 0: {
715
+ o[0] = 1, o[1] = s, o[2] = 0;
716
+ break;
717
+ }
718
+ case 1: {
719
+ o[0] = a, o[1] = 1, o[2] = 0;
720
+ break;
721
+ }
722
+ case 2: {
723
+ o[0] = 0, o[1] = 1, o[2] = s;
724
+ break;
725
+ }
726
+ case 3: {
727
+ o[0] = 0, o[1] = a, o[2] = 1;
728
+ break;
729
+ }
730
+ case 4: {
731
+ o[0] = s, o[1] = 0, o[2] = 1;
732
+ break;
733
+ }
734
+ default:
735
+ o[0] = 1, o[1] = 0, o[2] = a;
736
+ }
737
+ return i = (1 - n) * r, [
738
+ (n * o[0] + i) * 255,
739
+ (n * o[1] + i) * 255,
740
+ (n * o[2] + i) * 255
741
+ ];
742
+ };
743
+ c.hcg.hsv = function(e) {
744
+ const t = e[1] / 100, n = e[2] / 100, r = t + n * (1 - t);
745
+ let o = 0;
746
+ return r > 0 && (o = t / r), [e[0], o * 100, r * 100];
747
+ };
748
+ c.hcg.hsl = function(e) {
749
+ const t = e[1] / 100, r = e[2] / 100 * (1 - t) + 0.5 * t;
750
+ let o = 0;
751
+ return r > 0 && r < 0.5 ? o = t / (2 * r) : r >= 0.5 && r < 1 && (o = t / (2 * (1 - r))), [e[0], o * 100, r * 100];
752
+ };
753
+ c.hcg.hwb = function(e) {
754
+ const t = e[1] / 100, n = e[2] / 100, r = t + n * (1 - t);
755
+ return [e[0], (r - t) * 100, (1 - r) * 100];
756
+ };
757
+ c.hwb.hcg = function(e) {
758
+ const t = e[1] / 100, r = 1 - e[2] / 100, o = r - t;
759
+ let l = 0;
760
+ return o < 1 && (l = (r - o) / (1 - o)), [e[0], o * 100, l * 100];
761
+ };
762
+ c.apple.rgb = function(e) {
763
+ return [e[0] / 65535 * 255, e[1] / 65535 * 255, e[2] / 65535 * 255];
764
+ };
765
+ c.rgb.apple = function(e) {
766
+ return [e[0] / 255 * 65535, e[1] / 255 * 65535, e[2] / 255 * 65535];
767
+ };
768
+ c.gray.rgb = function(e) {
769
+ return [e[0] / 100 * 255, e[0] / 100 * 255, e[0] / 100 * 255];
770
+ };
771
+ c.gray.hsl = function(e) {
772
+ return [0, 0, e[0]];
773
+ };
774
+ c.gray.hsv = c.gray.hsl;
775
+ c.gray.hwb = function(e) {
776
+ return [0, 100, e[0]];
777
+ };
778
+ c.gray.cmyk = function(e) {
779
+ return [0, 0, 0, e[0]];
780
+ };
781
+ c.gray.lab = function(e) {
782
+ return [e[0], 0, 0];
783
+ };
784
+ c.gray.hex = function(e) {
785
+ const t = Math.round(e[0] / 100 * 255) & 255, r = ((t << 16) + (t << 8) + t).toString(16).toUpperCase();
786
+ return "000000".slice(r.length) + r;
787
+ };
788
+ c.rgb.gray = function(e) {
789
+ return [(e[0] + e[1] + e[2]) / 3 / 255 * 100];
790
+ };
791
+ function $() {
792
+ const e = {}, t = Object.keys(c);
793
+ for (let { length: n } = t, r = 0; r < n; r++)
794
+ e[t[r]] = {
795
+ // http://jsperf.com/1-vs-infinity
796
+ // micro-opt, but this is simple.
797
+ distance: -1,
798
+ parent: null
799
+ };
800
+ return e;
801
+ }
802
+ function I(e) {
803
+ const t = $(), n = [e];
804
+ for (t[e].distance = 0; n.length > 0; ) {
805
+ const r = n.pop(), o = Object.keys(c[r]);
806
+ for (let { length: l } = o, s = 0; s < l; s++) {
807
+ const a = o[s], i = t[a];
808
+ i.distance === -1 && (i.distance = t[r].distance + 1, i.parent = r, n.unshift(a));
809
+ }
810
+ }
811
+ return t;
812
+ }
813
+ function j(e, t) {
814
+ return function(n) {
815
+ return t(e(n));
816
+ };
817
+ }
818
+ function E(e, t) {
819
+ const n = [t[e].parent, e];
820
+ let r = c[t[e].parent][e], o = t[e].parent;
821
+ for (; t[o].parent; )
822
+ n.unshift(t[o].parent), r = j(c[t[o].parent][o], r), o = t[o].parent;
823
+ return r.conversion = n, r;
824
+ }
825
+ function U(e) {
826
+ const t = I(e), n = {}, r = Object.keys(t);
827
+ for (let { length: o } = r, l = 0; l < o; l++) {
828
+ const s = r[l];
829
+ t[s].parent !== null && (n[s] = E(s, t));
830
+ }
831
+ return n;
832
+ }
833
+ const g = {}, T = Object.keys(c);
834
+ function V(e) {
835
+ const t = function(...n) {
836
+ const r = n[0];
837
+ return r == null ? r : (r.length > 1 && (n = r), e(n));
838
+ };
839
+ return "conversion" in e && (t.conversion = e.conversion), t;
840
+ }
841
+ function D(e) {
842
+ const t = function(...n) {
843
+ const r = n[0];
844
+ if (r == null)
845
+ return r;
846
+ r.length > 1 && (n = r);
847
+ const o = e(n);
848
+ if (typeof o == "object")
849
+ for (let { length: l } = o, s = 0; s < l; s++)
850
+ o[s] = Math.round(o[s]);
851
+ return o;
852
+ };
853
+ return "conversion" in e && (t.conversion = e.conversion), t;
854
+ }
855
+ for (const e of T) {
856
+ g[e] = {}, Object.defineProperty(g[e], "channels", { value: c[e].channels }), Object.defineProperty(g[e], "labels", { value: c[e].labels });
857
+ const t = U(e), n = Object.keys(t);
858
+ for (const r of n) {
859
+ const o = t[r];
860
+ g[e][r] = D(o), g[e][r].raw = V(o);
861
+ }
862
+ }
863
+ const C = [
864
+ // To be honest, I don't really feel like keyword belongs in color convert, but eh.
865
+ "keyword",
866
+ // Gray conflicts with some method names, and has its own method defined.
867
+ "gray",
868
+ // Shouldn't really be in color-convert either...
869
+ "hex"
870
+ ], F = {};
871
+ for (const e of Object.keys(g))
872
+ F[[...g[e].labels].sort().join("")] = e;
873
+ const v = {};
874
+ function b(e, t) {
875
+ if (!(this instanceof b))
876
+ return new b(e, t);
877
+ if (t && t in C && (t = null), t && !(t in g))
878
+ throw new Error("Unknown model: " + t);
879
+ let n, r;
880
+ if (e == null)
881
+ this.model = "rgb", this.color = [0, 0, 0], this.valpha = 1;
882
+ else if (e instanceof b)
883
+ this.model = e.model, this.color = [...e.color], this.valpha = e.valpha;
884
+ else if (typeof e == "string") {
885
+ const o = d.get(e);
886
+ if (o === null)
887
+ throw new Error("Unable to parse color from string: " + e);
888
+ this.model = o.model, r = g[this.model].channels, this.color = o.value.slice(0, r), this.valpha = typeof o.value[r] == "number" ? o.value[r] : 1;
889
+ } else if (e.length > 0) {
890
+ this.model = t || "rgb", r = g[this.model].channels;
891
+ const o = Array.prototype.slice.call(e, 0, r);
892
+ this.color = N(o, r), this.valpha = typeof e[r] == "number" ? e[r] : 1;
893
+ } else if (typeof e == "number")
894
+ this.model = "rgb", this.color = [
895
+ e >> 16 & 255,
896
+ e >> 8 & 255,
897
+ e & 255
898
+ ], this.valpha = 1;
899
+ else {
900
+ this.valpha = 1;
901
+ const o = Object.keys(e);
902
+ "alpha" in e && (o.splice(o.indexOf("alpha"), 1), this.valpha = typeof e.alpha == "number" ? e.alpha : 0);
903
+ const l = o.sort().join("");
904
+ if (!(l in F))
905
+ throw new Error("Unable to parse color from object: " + JSON.stringify(e));
906
+ this.model = F[l];
907
+ const { labels: s } = g[this.model], a = [];
908
+ for (n = 0; n < s.length; n++)
909
+ a.push(e[s[n]]);
910
+ this.color = N(a);
911
+ }
912
+ if (v[this.model])
913
+ for (r = g[this.model].channels, n = 0; n < r; n++) {
914
+ const o = v[this.model][n];
915
+ o && (this.color[n] = o(this.color[n]));
916
+ }
917
+ this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
918
+ }
919
+ b.prototype = {
920
+ toString() {
921
+ return this.string();
922
+ },
923
+ toJSON() {
924
+ return this[this.model]();
925
+ },
926
+ string(e) {
927
+ let t = this.model in d.to ? this : this.rgb();
928
+ t = t.round(typeof e == "number" ? e : 1);
929
+ const n = t.valpha === 1 ? t.color : [...t.color, this.valpha];
930
+ return d.to[t.model](...n);
931
+ },
932
+ percentString(e) {
933
+ const t = this.rgb().round(typeof e == "number" ? e : 1), n = t.valpha === 1 ? t.color : [...t.color, this.valpha];
934
+ return d.to.rgb.percent(...n);
935
+ },
936
+ array() {
937
+ return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
938
+ },
939
+ object() {
940
+ const e = {}, { channels: t } = g[this.model], { labels: n } = g[this.model];
941
+ for (let r = 0; r < t; r++)
942
+ e[n[r]] = this.color[r];
943
+ return this.valpha !== 1 && (e.alpha = this.valpha), e;
944
+ },
945
+ unitArray() {
946
+ const e = this.rgb().color;
947
+ return e[0] /= 255, e[1] /= 255, e[2] /= 255, this.valpha !== 1 && e.push(this.valpha), e;
948
+ },
949
+ unitObject() {
950
+ const e = this.rgb().object();
951
+ return e.r /= 255, e.g /= 255, e.b /= 255, this.valpha !== 1 && (e.alpha = this.valpha), e;
952
+ },
953
+ round(e) {
954
+ return e = Math.max(e || 0, 0), new b([...this.color.map(B(e)), this.valpha], this.model);
955
+ },
956
+ alpha(e) {
957
+ return e !== void 0 ? new b([...this.color, Math.max(0, Math.min(1, e))], this.model) : this.valpha;
958
+ },
959
+ // Rgb
960
+ red: h("rgb", 0, f(255)),
961
+ green: h("rgb", 1, f(255)),
962
+ blue: h("rgb", 2, f(255)),
963
+ hue: h(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (e) => (e % 360 + 360) % 360),
964
+ saturationl: h("hsl", 1, f(100)),
965
+ lightness: h("hsl", 2, f(100)),
966
+ saturationv: h("hsv", 1, f(100)),
967
+ value: h("hsv", 2, f(100)),
968
+ chroma: h("hcg", 1, f(100)),
969
+ gray: h("hcg", 2, f(100)),
970
+ white: h("hwb", 1, f(100)),
971
+ wblack: h("hwb", 2, f(100)),
972
+ cyan: h("cmyk", 0, f(100)),
973
+ magenta: h("cmyk", 1, f(100)),
974
+ yellow: h("cmyk", 2, f(100)),
975
+ black: h("cmyk", 3, f(100)),
976
+ x: h("xyz", 0, f(95.047)),
977
+ y: h("xyz", 1, f(100)),
978
+ z: h("xyz", 2, f(108.833)),
979
+ l: h("lab", 0, f(100)),
980
+ a: h("lab", 1),
981
+ b: h("lab", 2),
982
+ keyword(e) {
983
+ return e !== void 0 ? new b(e) : g[this.model].keyword(this.color);
984
+ },
985
+ hex(e) {
986
+ return e !== void 0 ? new b(e) : d.to.hex(...this.rgb().round().color);
987
+ },
988
+ hexa(e) {
989
+ if (e !== void 0)
990
+ return new b(e);
991
+ const t = this.rgb().round().color;
992
+ let n = Math.round(this.valpha * 255).toString(16).toUpperCase();
993
+ return n.length === 1 && (n = "0" + n), d.to.hex(...t) + n;
994
+ },
995
+ rgbNumber() {
996
+ const e = this.rgb().color;
997
+ return (e[0] & 255) << 16 | (e[1] & 255) << 8 | e[2] & 255;
998
+ },
999
+ luminosity() {
1000
+ const e = this.rgb().color, t = [];
1001
+ for (const [n, r] of e.entries()) {
1002
+ const o = r / 255;
1003
+ t[n] = o <= 0.04045 ? o / 12.92 : ((o + 0.055) / 1.055) ** 2.4;
1004
+ }
1005
+ return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
1006
+ },
1007
+ contrast(e) {
1008
+ const t = this.luminosity(), n = e.luminosity();
1009
+ return t > n ? (t + 0.05) / (n + 0.05) : (n + 0.05) / (t + 0.05);
1010
+ },
1011
+ level(e) {
1012
+ const t = this.contrast(e);
1013
+ return t >= 7 ? "AAA" : t >= 4.5 ? "AA" : "";
1014
+ },
1015
+ isDark() {
1016
+ const e = this.rgb().color;
1017
+ return (e[0] * 2126 + e[1] * 7152 + e[2] * 722) / 1e4 < 128;
1018
+ },
1019
+ isLight() {
1020
+ return !this.isDark();
1021
+ },
1022
+ negate() {
1023
+ const e = this.rgb();
1024
+ for (let t = 0; t < 3; t++)
1025
+ e.color[t] = 255 - e.color[t];
1026
+ return e;
1027
+ },
1028
+ lighten(e) {
1029
+ const t = this.hsl();
1030
+ return t.color[2] += t.color[2] * e, t;
1031
+ },
1032
+ darken(e) {
1033
+ const t = this.hsl();
1034
+ return t.color[2] -= t.color[2] * e, t;
1035
+ },
1036
+ saturate(e) {
1037
+ const t = this.hsl();
1038
+ return t.color[1] += t.color[1] * e, t;
1039
+ },
1040
+ desaturate(e) {
1041
+ const t = this.hsl();
1042
+ return t.color[1] -= t.color[1] * e, t;
1043
+ },
1044
+ whiten(e) {
1045
+ const t = this.hwb();
1046
+ return t.color[1] += t.color[1] * e, t;
1047
+ },
1048
+ blacken(e) {
1049
+ const t = this.hwb();
1050
+ return t.color[2] += t.color[2] * e, t;
1051
+ },
1052
+ grayscale() {
1053
+ const e = this.rgb().color, t = e[0] * 0.3 + e[1] * 0.59 + e[2] * 0.11;
1054
+ return b.rgb(t, t, t);
1055
+ },
1056
+ fade(e) {
1057
+ return this.alpha(this.valpha - this.valpha * e);
1058
+ },
1059
+ opaquer(e) {
1060
+ return this.alpha(this.valpha + this.valpha * e);
1061
+ },
1062
+ rotate(e) {
1063
+ const t = this.hsl();
1064
+ let n = t.color[0];
1065
+ return n = (n + e) % 360, n = n < 0 ? 360 + n : n, t.color[0] = n, t;
1066
+ },
1067
+ mix(e, t) {
1068
+ if (!e || !e.rgb)
1069
+ throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof e);
1070
+ const n = e.rgb(), r = this.rgb(), o = t === void 0 ? 0.5 : t, l = 2 * o - 1, s = n.alpha() - r.alpha(), a = ((l * s === -1 ? l : (l + s) / (1 + l * s)) + 1) / 2, i = 1 - a;
1071
+ return b.rgb(
1072
+ a * n.red() + i * r.red(),
1073
+ a * n.green() + i * r.green(),
1074
+ a * n.blue() + i * r.blue(),
1075
+ n.alpha() * o + r.alpha() * (1 - o)
1076
+ );
1077
+ }
1078
+ };
1079
+ for (const e of Object.keys(g)) {
1080
+ if (C.includes(e))
1081
+ continue;
1082
+ const { channels: t } = g[e];
1083
+ b.prototype[e] = function(...n) {
1084
+ return this.model === e ? new b(this) : n.length > 0 ? new b(n, e) : new b([...L(g[this.model][e].raw(this.color)), this.valpha], e);
1085
+ }, b[e] = function(...n) {
1086
+ let r = n[0];
1087
+ return typeof r == "number" && (r = N(n, t)), new b(r, e);
1088
+ };
1089
+ }
1090
+ function K(e, t) {
1091
+ return Number(e.toFixed(t));
1092
+ }
1093
+ function B(e) {
1094
+ return function(t) {
1095
+ return K(t, e);
1096
+ };
1097
+ }
1098
+ function h(e, t, n) {
1099
+ e = Array.isArray(e) ? e : [e];
1100
+ for (const r of e)
1101
+ (v[r] || (v[r] = []))[t] = n;
1102
+ return e = e[0], function(r) {
1103
+ let o;
1104
+ return r !== void 0 ? (n && (r = n(r)), o = this[e](), o.color[t] = r, o) : (o = this[e]().color[t], n && (o = n(o)), o);
1105
+ };
1106
+ }
1107
+ function f(e) {
1108
+ return function(t) {
1109
+ return Math.max(0, Math.min(e, t));
1110
+ };
1111
+ }
1112
+ function L(e) {
1113
+ return Array.isArray(e) ? e : [e];
1114
+ }
1115
+ function N(e, t) {
1116
+ for (let n = 0; n < t; n++)
1117
+ typeof e[n] != "number" && (e[n] = 0);
1118
+ return e;
1119
+ }
1120
+ class R {
1121
+ constructor(t) {
1122
+ _(this, "isColor", !0);
1123
+ _(this, "currentColor");
1124
+ this.base = t;
1125
+ const n = this._resolveBaseColor(t);
1126
+ return this.currentColor = b(n), this._createProxy();
1127
+ }
1128
+ _createProxy() {
1129
+ return new Proxy(this, {
1130
+ get(t, n) {
1131
+ return n in t ? t[n] : n in t.currentColor ? t._handleColorMethod(n) : t[n];
1132
+ }
1133
+ });
1134
+ }
1135
+ _resolveBaseColor(t) {
1136
+ if (typeof t != "string" || !/\{[^{}]+\}/g.test(t)) return t;
1137
+ if (typeof saltyConfig > "u") return "transparent";
1138
+ const { staticVariables: r } = saltyConfig;
1139
+ return r ? t.replace(/^\{|\}$/g, "").split(".").reduce((s, a) => s[a], r) : "transparent";
1140
+ }
1141
+ _handleColorMethod(t) {
1142
+ const n = this.currentColor;
1143
+ return typeof n[t] != "function" ? n[t] : (...r) => (this.currentColor = n[t](...r), this._createProxy());
1144
+ }
1145
+ toString() {
1146
+ return this.currentColor.toString();
1147
+ }
1148
+ }
1149
+ const G = (e) => new R(e), H = (e) => (t) => {
1150
+ const { screenSize: n, axis: r = "horizontal", minMultiplier: o = 0.5, maxMultiplier: l = 1.5 } = e, s = Math.round(t / n * 1e4) / 100, a = r === "vertical" ? "vh" : "vw", i = Math.round(o * t), u = Math.round(l * t);
1151
+ return `clamp(${i}px, ${s}${a}, ${u}px)`;
1152
+ };
1153
+ export {
1154
+ G as color,
1155
+ H as defineViewportClamp
1156
+ };