@thednp/color-picker 1.0.1 → 2.0.0-alpha10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/.eslintrc.cjs +199 -0
  2. package/.lgtm.yml +9 -0
  3. package/.prettierrc.json +15 -0
  4. package/.stylelintrc.json +236 -0
  5. package/README.md +55 -72
  6. package/compile.js +51 -0
  7. package/cypress/e2e/color-palette.cy.ts +128 -0
  8. package/cypress/e2e/color-picker.cy.ts +909 -0
  9. package/cypress/fixtures/colorNamesFrench.js +3 -0
  10. package/cypress/fixtures/componentLabelsFrench.js +21 -0
  11. package/cypress/fixtures/format.js +3 -0
  12. package/cypress/fixtures/getMarkup.js +35 -0
  13. package/cypress/fixtures/getRandomInt.js +6 -0
  14. package/cypress/fixtures/sampleWebcolors.js +18 -0
  15. package/cypress/fixtures/testSample.js +8 -0
  16. package/cypress/plugins/esbuild-istanbul.ts +50 -0
  17. package/cypress/plugins/tsCompile.ts +34 -0
  18. package/cypress/support/commands.ts +0 -0
  19. package/cypress/support/e2e.ts +21 -0
  20. package/cypress/test.html +23 -0
  21. package/cypress.config.ts +29 -0
  22. package/dist/css/color-picker.css +25 -54
  23. package/dist/css/color-picker.min.css +2 -2
  24. package/dist/css/color-picker.rtl.css +25 -54
  25. package/dist/css/color-picker.rtl.min.css +2 -2
  26. package/dist/js/color-picker.cjs +8 -0
  27. package/dist/js/color-picker.cjs.map +1 -0
  28. package/dist/js/color-picker.d.ts +296 -0
  29. package/dist/js/color-picker.js +5 -3570
  30. package/dist/js/color-picker.js.map +1 -0
  31. package/dist/js/color-picker.mjs +2618 -0
  32. package/dist/js/color-picker.mjs.map +1 -0
  33. package/dts.config.ts +15 -0
  34. package/package.json +116 -108
  35. package/src/scss/_variables.scss +0 -1
  36. package/src/scss/color-picker.rtl.scss +4 -0
  37. package/src/scss/color-picker.scss +93 -51
  38. package/src/ts/colorPalette.ts +89 -0
  39. package/src/{js/color-picker.js → ts/index.ts} +498 -509
  40. package/src/ts/interface/ColorNames.ts +20 -0
  41. package/src/ts/interface/colorPickerLabels.ts +20 -0
  42. package/src/ts/interface/colorPickerOptions.ts +11 -0
  43. package/src/ts/interface/paletteOptions.ts +6 -0
  44. package/src/ts/util/colorNames.ts +21 -0
  45. package/src/{js/util/colorPickerLabels.js → ts/util/colorPickerLabels.ts} +4 -2
  46. package/src/ts/util/getColorControls.ts +90 -0
  47. package/src/{js/util/getColorForm.js → ts/util/getColorForm.ts} +28 -18
  48. package/src/{js/util/getColorMenu.js → ts/util/getColorMenu.ts} +21 -30
  49. package/src/ts/util/isValidJSON.ts +19 -0
  50. package/src/{js/util/setMarkup.js → ts/util/setMarkup.ts} +61 -50
  51. package/tsconfig.json +29 -0
  52. package/vite.config.ts +34 -0
  53. package/dist/js/color-esm.js +0 -1164
  54. package/dist/js/color-esm.min.js +0 -2
  55. package/dist/js/color-palette-esm.js +0 -1235
  56. package/dist/js/color-palette-esm.min.js +0 -2
  57. package/dist/js/color-palette.js +0 -1243
  58. package/dist/js/color-palette.min.js +0 -2
  59. package/dist/js/color-picker-element-esm.js +0 -3718
  60. package/dist/js/color-picker-element-esm.min.js +0 -2
  61. package/dist/js/color-picker-element.js +0 -3726
  62. package/dist/js/color-picker-element.min.js +0 -2
  63. package/dist/js/color-picker-esm.js +0 -3565
  64. package/dist/js/color-picker-esm.min.js +0 -2
  65. package/dist/js/color-picker.min.js +0 -2
  66. package/dist/js/color.js +0 -1172
  67. package/dist/js/color.min.js +0 -2
  68. package/src/js/color-palette.js +0 -75
  69. package/src/js/color-picker-element.js +0 -107
  70. package/src/js/color.js +0 -1104
  71. package/src/js/index.js +0 -8
  72. package/src/js/util/colorNames.js +0 -6
  73. package/src/js/util/getColorControls.js +0 -103
  74. package/src/js/util/isValidJSON.js +0 -13
  75. package/src/js/util/nonColors.js +0 -5
  76. package/src/js/util/roundPart.js +0 -9
  77. package/src/js/util/setCSSProperties.js +0 -12
  78. package/src/js/util/tabindex.js +0 -3
  79. package/src/js/util/toggleCEAttr.js +0 -70
  80. package/src/js/util/version.js +0 -5
  81. package/src/js/version.js +0 -5
  82. package/types/cp.d.ts +0 -558
  83. package/types/index.d.ts +0 -44
  84. package/types/source/source.ts +0 -4
  85. package/types/source/types.d.ts +0 -92
  86. /package/src/{js/util/vHidden.js → ts/util/vHidden.ts} +0 -0
@@ -0,0 +1,2618 @@
1
+ const _t = "aria-description", Nt = "aria-expanded", Ee = "aria-hidden", St = "aria-selected", tt = "aria-valuenow", et = "aria-valuetext", Me = "change", Te = "DOMContentLoaded", Re = "focusin", Oe = "focusout", zt = "keydown", De = "keyup", Et = "click", Fe = "pointerdown", ue = "pointermove", Ie = "pointerup", Ke = "resize", Ve = "scroll", Be = "touchmove", j = "ArrowDown", ot = "ArrowUp", ht = "ArrowLeft", U = "ArrowRight", je = "Enter", qe = "Escape", Wt = "Space", Ge = "transitionDuration", Ue = "transitionProperty", X = "tabindex", _e = navigator.userAgentData, mt = _e, { userAgent: ze } = navigator, vt = ze, Jt = /iPhone|iPad|iPod|Android/i;
2
+ mt ? mt.brands.some((o) => Jt.test(o.brand)) : Jt.test(vt);
3
+ const Xt = /(iPhone|iPod|iPad)/;
4
+ mt ? mt.brands.some((o) => Xt.test(o.brand)) : (
5
+ /* istanbul ignore next */
6
+ Xt.test(vt)
7
+ );
8
+ vt && vt.includes("Firefox");
9
+ const { head: kt } = document;
10
+ ["webkitPerspective", "perspective"].some((o) => o in kt.style);
11
+ const Bt = (o, t, e, s) => {
12
+ const r = s || !1;
13
+ o.addEventListener(t, e, r);
14
+ }, jt = (o, t, e, s) => {
15
+ const r = s || !1;
16
+ o.removeEventListener(t, e, r);
17
+ }, We = (o, t, e, s) => {
18
+ const r = (n) => {
19
+ (n.target === o || n.currentTarget === o) && (e.apply(o, [n]), jt(o, t, r, s));
20
+ };
21
+ Bt(o, t, r, s);
22
+ }, Je = () => {
23
+ };
24
+ (() => {
25
+ let o = !1;
26
+ try {
27
+ const t = Object.defineProperty({}, "passive", {
28
+ get: () => (o = !0, o)
29
+ });
30
+ We(document, Te, Je, t);
31
+ } catch {
32
+ }
33
+ return o;
34
+ })();
35
+ ["webkitTransform", "transform"].some((o) => o in kt.style);
36
+ ["webkitAnimation", "animation"].some((o) => o in kt.style);
37
+ ["webkitTransition", "transition"].some((o) => o in kt.style);
38
+ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), Pt = (o, t) => o.removeAttribute(t), q = (o, ...t) => {
39
+ o.classList.add(...t);
40
+ }, O = (o, ...t) => {
41
+ o.classList.remove(...t);
42
+ }, T = (o, t) => o.classList.contains(t), qt = (o) => o != null && typeof o == "object" || !1, Y = (o) => qt(o) && typeof o.nodeType == "number" && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].some((t) => o.nodeType === t) || !1, at = (o) => Y(o) && o.nodeType === 1 || !1, W = /* @__PURE__ */ new Map(), ct = {
43
+ data: W,
44
+ /**
45
+ * Sets web components data.
46
+ *
47
+ * @param element target element
48
+ * @param component the component's name or a unique key
49
+ * @param instance the component instance
50
+ */
51
+ set: (o, t, e) => {
52
+ at(o) && (W.has(t) || W.set(t, /* @__PURE__ */ new Map()), W.get(t).set(o, e));
53
+ },
54
+ /**
55
+ * Returns all instances for specified component.
56
+ *
57
+ * @param component the component's name or a unique key
58
+ * @returns all the component instances
59
+ */
60
+ getAllFor: (o) => W.get(o) || null,
61
+ /**
62
+ * Returns the instance associated with the target.
63
+ *
64
+ * @param element target element
65
+ * @param component the component's name or a unique key
66
+ * @returns the instance
67
+ */
68
+ get: (o, t) => {
69
+ if (!at(o) || !t)
70
+ return null;
71
+ const e = ct.getAllFor(t);
72
+ return o && e && e.get(o) || null;
73
+ },
74
+ /**
75
+ * Removes web components data.
76
+ *
77
+ * @param element target element
78
+ * @param component the component's name or a unique key
79
+ */
80
+ remove: (o, t) => {
81
+ const e = ct.getAllFor(t);
82
+ !e || !at(o) || (e.delete(o), e.size === 0 && W.delete(t));
83
+ }
84
+ }, Xe = (o, t) => ct.get(o, t), B = (o) => typeof o == "string" || !1, Ze = (o) => qt(o) && o.constructor.name === "Window" || !1, be = (o) => Y(o) && o.nodeType === 9 || !1, V = (o) => Ze(o) ? o.document : be(o) ? o : Y(o) ? o.ownerDocument : window.document, K = (o, ...t) => Object.assign(o, ...t), x = (o) => {
85
+ if (!o)
86
+ return;
87
+ if (B(o))
88
+ return V().createElement(o);
89
+ const { tagName: t } = o, e = x(t);
90
+ if (!e)
91
+ return;
92
+ const s = { ...o };
93
+ return delete s.tagName, K(e, s);
94
+ }, Mt = (o, t) => {
95
+ if (!o || !t)
96
+ return;
97
+ if (B(t))
98
+ return V().createElementNS(o, t);
99
+ const { tagName: e } = t, s = Mt(o, e);
100
+ if (!s)
101
+ return;
102
+ const r = { ...t };
103
+ return delete r.tagName, K(s, r);
104
+ }, Ye = (o, t) => o.dispatchEvent(t), Tt = (o, t) => {
105
+ const e = getComputedStyle(o), s = t.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
106
+ return e.getPropertyValue(s);
107
+ }, Qe = (o) => {
108
+ const t = Tt(o, Ue), e = Tt(o, Ge), s = e.includes("ms") ? (
109
+ /* istanbul ignore next */
110
+ 1
111
+ ) : 1e3, r = t && t !== "none" ? parseFloat(e) * s : (
112
+ /* istanbul ignore next */
113
+ 0
114
+ );
115
+ return Number.isNaN(r) ? (
116
+ /* istanbul ignore next */
117
+ 0
118
+ ) : r;
119
+ }, _ = (o, t) => o.focus(t), Zt = (o) => ["true", !0].includes(o) ? !0 : ["false", !1].includes(o) ? !1 : ["null", "", null, void 0].includes(o) ? null : o !== "" && !Number.isNaN(+o) ? +o : o, pt = (o) => Object.entries(o), to = (o) => o.toLowerCase(), eo = (o, t, e, s) => {
120
+ const r = { ...e }, n = { ...o.dataset }, i = { ...t }, a = {}, l = "title";
121
+ return pt(n).forEach(([c, h]) => {
122
+ const b = s && typeof c == "string" && c.includes(s) ? c.replace(s, "").replace(/[A-Z]/g, (u) => to(u)) : c;
123
+ a[b] = Zt(h);
124
+ }), pt(r).forEach(([c, h]) => {
125
+ r[c] = Zt(h);
126
+ }), pt(t).forEach(([c, h]) => {
127
+ c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ? yt(o, l) : h;
128
+ }), i;
129
+ }, Yt = (o) => Object.fromEntries(o), oo = (o) => o.offsetHeight, D = (o, t) => {
130
+ pt(t).forEach(([e, s]) => {
131
+ if (s && B(e) && e.includes("--"))
132
+ o.style.setProperty(e, s);
133
+ else {
134
+ const r = {};
135
+ r[e] = s, K(o.style, r);
136
+ }
137
+ });
138
+ }, so = (o) => qt(o) && o.constructor.name === "Map" || !1, pe = (o) => o.toUpperCase(), gt = (o, t) => {
139
+ const { width: e, height: s, top: r, right: n, bottom: i, left: a } = o.getBoundingClientRect();
140
+ let l = 1, c = 1;
141
+ if (t && at(o)) {
142
+ const { offsetWidth: h, offsetHeight: b } = o;
143
+ l = h > 0 ? Math.round(e) / h : (
144
+ /* istanbul ignore next */
145
+ 1
146
+ ), c = b > 0 ? Math.round(s) / b : (
147
+ /* istanbul ignore next */
148
+ 1
149
+ );
150
+ }
151
+ return {
152
+ width: e / l,
153
+ height: s / c,
154
+ top: r / c,
155
+ right: n / l,
156
+ bottom: i / c,
157
+ left: a / l,
158
+ x: a / l,
159
+ y: r / c
160
+ };
161
+ }, Ct = (o) => V(o).documentElement;
162
+ let Qt = 0, te = 0;
163
+ const J = /* @__PURE__ */ new Map(), de = (o, t) => {
164
+ let e = t ? Qt : te;
165
+ if (t) {
166
+ const s = de(o), r = J.get(s) || /* @__PURE__ */ new Map();
167
+ J.has(s) || J.set(s, r), so(r) && !r.has(t) ? (r.set(t, e), Qt += 1) : e = r.get(t);
168
+ } else {
169
+ const s = o.id || o;
170
+ J.has(s) ? e = J.get(s) : (J.set(s, e), te += 1);
171
+ }
172
+ return e;
173
+ }, ro = (o) => {
174
+ var t;
175
+ return o ? be(o) ? o.defaultView : Y(o) ? (t = o?.ownerDocument) == null ? void 0 : t.defaultView : o : window;
176
+ }, Lt = (o) => Array.isArray(o) || !1, fe = (o, t) => o ? o.closest(t) || // break out of `ShadowRoot`
177
+ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Y(t) ? t : V()).querySelector(o), st = (o, t) => (t && Y(t) ? t : V()).getElementsByClassName(
178
+ o
179
+ ), Gt = ["transparent", "currentColor", "inherit", "revert", "initial"], v = (o) => {
180
+ const t = Math.floor(o);
181
+ return o - t < 0.5 ? t : Math.round(o);
182
+ }, wt = [
183
+ [
184
+ "aliceblue",
185
+ {
186
+ r: 240,
187
+ g: 248,
188
+ b: 255
189
+ }
190
+ ],
191
+ [
192
+ "antiquewhite",
193
+ {
194
+ r: 250,
195
+ g: 235,
196
+ b: 215
197
+ }
198
+ ],
199
+ [
200
+ "aqua",
201
+ {
202
+ r: 0,
203
+ g: 255,
204
+ b: 255
205
+ }
206
+ ],
207
+ [
208
+ "aquamarine",
209
+ {
210
+ r: 127,
211
+ g: 255,
212
+ b: 212
213
+ }
214
+ ],
215
+ [
216
+ "azure",
217
+ {
218
+ r: 240,
219
+ g: 255,
220
+ b: 255
221
+ }
222
+ ],
223
+ [
224
+ "beige",
225
+ {
226
+ r: 245,
227
+ g: 245,
228
+ b: 220
229
+ }
230
+ ],
231
+ [
232
+ "bisque",
233
+ {
234
+ r: 255,
235
+ g: 228,
236
+ b: 196
237
+ }
238
+ ],
239
+ [
240
+ "black",
241
+ {
242
+ r: 0,
243
+ g: 0,
244
+ b: 0
245
+ }
246
+ ],
247
+ [
248
+ "blanchedalmond",
249
+ {
250
+ r: 255,
251
+ g: 235,
252
+ b: 205
253
+ }
254
+ ],
255
+ [
256
+ "blue",
257
+ {
258
+ r: 0,
259
+ g: 0,
260
+ b: 255
261
+ }
262
+ ],
263
+ [
264
+ "blueviolet",
265
+ {
266
+ r: 138,
267
+ g: 43,
268
+ b: 226
269
+ }
270
+ ],
271
+ [
272
+ "brown",
273
+ {
274
+ r: 165,
275
+ g: 42,
276
+ b: 42
277
+ }
278
+ ],
279
+ [
280
+ "burlywood",
281
+ {
282
+ r: 222,
283
+ g: 184,
284
+ b: 135
285
+ }
286
+ ],
287
+ [
288
+ "cadetblue",
289
+ {
290
+ r: 95,
291
+ g: 158,
292
+ b: 160
293
+ }
294
+ ],
295
+ [
296
+ "chartreuse",
297
+ {
298
+ r: 127,
299
+ g: 255,
300
+ b: 0
301
+ }
302
+ ],
303
+ [
304
+ "chocolate",
305
+ {
306
+ r: 210,
307
+ g: 105,
308
+ b: 30
309
+ }
310
+ ],
311
+ [
312
+ "coral",
313
+ {
314
+ r: 255,
315
+ g: 127,
316
+ b: 80
317
+ }
318
+ ],
319
+ [
320
+ "cornflowerblue",
321
+ {
322
+ r: 100,
323
+ g: 149,
324
+ b: 237
325
+ }
326
+ ],
327
+ [
328
+ "cornsilk",
329
+ {
330
+ r: 255,
331
+ g: 248,
332
+ b: 220
333
+ }
334
+ ],
335
+ [
336
+ "crimson",
337
+ {
338
+ r: 220,
339
+ g: 20,
340
+ b: 60
341
+ }
342
+ ],
343
+ [
344
+ "cyan",
345
+ {
346
+ r: 0,
347
+ g: 255,
348
+ b: 255
349
+ }
350
+ ],
351
+ [
352
+ "darkblue",
353
+ {
354
+ r: 0,
355
+ g: 0,
356
+ b: 139
357
+ }
358
+ ],
359
+ [
360
+ "darkcyan",
361
+ {
362
+ r: 0,
363
+ g: 139,
364
+ b: 139
365
+ }
366
+ ],
367
+ [
368
+ "darkgoldenrod",
369
+ {
370
+ r: 184,
371
+ g: 134,
372
+ b: 11
373
+ }
374
+ ],
375
+ [
376
+ "darkgray",
377
+ {
378
+ r: 169,
379
+ g: 169,
380
+ b: 169
381
+ }
382
+ ],
383
+ [
384
+ "darkgreen",
385
+ {
386
+ r: 0,
387
+ g: 100,
388
+ b: 0
389
+ }
390
+ ],
391
+ [
392
+ "darkgrey",
393
+ {
394
+ r: 169,
395
+ g: 169,
396
+ b: 169
397
+ }
398
+ ],
399
+ [
400
+ "darkkhaki",
401
+ {
402
+ r: 189,
403
+ g: 183,
404
+ b: 107
405
+ }
406
+ ],
407
+ [
408
+ "darkmagenta",
409
+ {
410
+ r: 139,
411
+ g: 0,
412
+ b: 139
413
+ }
414
+ ],
415
+ [
416
+ "darkolivegreen",
417
+ {
418
+ r: 85,
419
+ g: 107,
420
+ b: 47
421
+ }
422
+ ],
423
+ [
424
+ "darkorange",
425
+ {
426
+ r: 255,
427
+ g: 140,
428
+ b: 0
429
+ }
430
+ ],
431
+ [
432
+ "darkorchid",
433
+ {
434
+ r: 153,
435
+ g: 50,
436
+ b: 204
437
+ }
438
+ ],
439
+ [
440
+ "darkred",
441
+ {
442
+ r: 139,
443
+ g: 0,
444
+ b: 0
445
+ }
446
+ ],
447
+ [
448
+ "darksalmon",
449
+ {
450
+ r: 233,
451
+ g: 150,
452
+ b: 122
453
+ }
454
+ ],
455
+ [
456
+ "darkseagreen",
457
+ {
458
+ r: 143,
459
+ g: 188,
460
+ b: 143
461
+ }
462
+ ],
463
+ [
464
+ "darkslateblue",
465
+ {
466
+ r: 72,
467
+ g: 61,
468
+ b: 139
469
+ }
470
+ ],
471
+ [
472
+ "darkslategray",
473
+ {
474
+ r: 47,
475
+ g: 79,
476
+ b: 79
477
+ }
478
+ ],
479
+ [
480
+ "darkslategrey",
481
+ {
482
+ r: 47,
483
+ g: 79,
484
+ b: 79
485
+ }
486
+ ],
487
+ [
488
+ "darkturquoise",
489
+ {
490
+ r: 0,
491
+ g: 206,
492
+ b: 209
493
+ }
494
+ ],
495
+ [
496
+ "darkviolet",
497
+ {
498
+ r: 148,
499
+ g: 0,
500
+ b: 211
501
+ }
502
+ ],
503
+ [
504
+ "deeppink",
505
+ {
506
+ r: 255,
507
+ g: 20,
508
+ b: 147
509
+ }
510
+ ],
511
+ [
512
+ "deepskyblue",
513
+ {
514
+ r: 0,
515
+ g: 191,
516
+ b: 255
517
+ }
518
+ ],
519
+ [
520
+ "dimgray",
521
+ {
522
+ r: 105,
523
+ g: 105,
524
+ b: 105
525
+ }
526
+ ],
527
+ [
528
+ "dimgrey",
529
+ {
530
+ r: 105,
531
+ g: 105,
532
+ b: 105
533
+ }
534
+ ],
535
+ [
536
+ "dodgerblue",
537
+ {
538
+ r: 30,
539
+ g: 144,
540
+ b: 255
541
+ }
542
+ ],
543
+ [
544
+ "firebrick",
545
+ {
546
+ r: 178,
547
+ g: 34,
548
+ b: 34
549
+ }
550
+ ],
551
+ [
552
+ "floralwhite",
553
+ {
554
+ r: 255,
555
+ g: 250,
556
+ b: 240
557
+ }
558
+ ],
559
+ [
560
+ "forestgreen",
561
+ {
562
+ r: 34,
563
+ g: 139,
564
+ b: 34
565
+ }
566
+ ],
567
+ [
568
+ "fuchsia",
569
+ {
570
+ r: 255,
571
+ g: 0,
572
+ b: 255
573
+ }
574
+ ],
575
+ [
576
+ "gainsboro",
577
+ {
578
+ r: 220,
579
+ g: 220,
580
+ b: 220
581
+ }
582
+ ],
583
+ [
584
+ "ghostwhite",
585
+ {
586
+ r: 248,
587
+ g: 248,
588
+ b: 255
589
+ }
590
+ ],
591
+ [
592
+ "goldenrod",
593
+ {
594
+ r: 218,
595
+ g: 165,
596
+ b: 32
597
+ }
598
+ ],
599
+ [
600
+ "gold",
601
+ {
602
+ r: 255,
603
+ g: 215,
604
+ b: 0
605
+ }
606
+ ],
607
+ [
608
+ "gray",
609
+ {
610
+ r: 128,
611
+ g: 128,
612
+ b: 128
613
+ }
614
+ ],
615
+ [
616
+ "green",
617
+ {
618
+ r: 0,
619
+ g: 128,
620
+ b: 0
621
+ }
622
+ ],
623
+ [
624
+ "greenyellow",
625
+ {
626
+ r: 173,
627
+ g: 255,
628
+ b: 47
629
+ }
630
+ ],
631
+ [
632
+ "grey",
633
+ {
634
+ r: 128,
635
+ g: 128,
636
+ b: 128
637
+ }
638
+ ],
639
+ [
640
+ "honeydew",
641
+ {
642
+ r: 240,
643
+ g: 255,
644
+ b: 240
645
+ }
646
+ ],
647
+ [
648
+ "hotpink",
649
+ {
650
+ r: 255,
651
+ g: 105,
652
+ b: 180
653
+ }
654
+ ],
655
+ [
656
+ "indianred",
657
+ {
658
+ r: 205,
659
+ g: 92,
660
+ b: 92
661
+ }
662
+ ],
663
+ [
664
+ "indigo",
665
+ {
666
+ r: 75,
667
+ g: 0,
668
+ b: 130
669
+ }
670
+ ],
671
+ [
672
+ "ivory",
673
+ {
674
+ r: 255,
675
+ g: 255,
676
+ b: 240
677
+ }
678
+ ],
679
+ [
680
+ "khaki",
681
+ {
682
+ r: 240,
683
+ g: 230,
684
+ b: 140
685
+ }
686
+ ],
687
+ [
688
+ "lavenderblush",
689
+ {
690
+ r: 255,
691
+ g: 240,
692
+ b: 245
693
+ }
694
+ ],
695
+ [
696
+ "lavender",
697
+ {
698
+ r: 230,
699
+ g: 230,
700
+ b: 250
701
+ }
702
+ ],
703
+ [
704
+ "lawngreen",
705
+ {
706
+ r: 124,
707
+ g: 252,
708
+ b: 0
709
+ }
710
+ ],
711
+ [
712
+ "lemonchiffon",
713
+ {
714
+ r: 255,
715
+ g: 250,
716
+ b: 205
717
+ }
718
+ ],
719
+ [
720
+ "lightblue",
721
+ {
722
+ r: 173,
723
+ g: 216,
724
+ b: 230
725
+ }
726
+ ],
727
+ [
728
+ "lightcoral",
729
+ {
730
+ r: 240,
731
+ g: 128,
732
+ b: 128
733
+ }
734
+ ],
735
+ [
736
+ "lightcyan",
737
+ {
738
+ r: 224,
739
+ g: 255,
740
+ b: 255
741
+ }
742
+ ],
743
+ [
744
+ "lightgoldenrodyellow",
745
+ {
746
+ r: 250,
747
+ g: 250,
748
+ b: 210
749
+ }
750
+ ],
751
+ [
752
+ "lightgray",
753
+ {
754
+ r: 211,
755
+ g: 211,
756
+ b: 211
757
+ }
758
+ ],
759
+ [
760
+ "lightgreen",
761
+ {
762
+ r: 144,
763
+ g: 238,
764
+ b: 144
765
+ }
766
+ ],
767
+ [
768
+ "lightgrey",
769
+ {
770
+ r: 211,
771
+ g: 211,
772
+ b: 211
773
+ }
774
+ ],
775
+ [
776
+ "lightpink",
777
+ {
778
+ r: 255,
779
+ g: 182,
780
+ b: 193
781
+ }
782
+ ],
783
+ [
784
+ "lightsalmon",
785
+ {
786
+ r: 255,
787
+ g: 160,
788
+ b: 122
789
+ }
790
+ ],
791
+ [
792
+ "lightseagreen",
793
+ {
794
+ r: 32,
795
+ g: 178,
796
+ b: 170
797
+ }
798
+ ],
799
+ [
800
+ "lightskyblue",
801
+ {
802
+ r: 135,
803
+ g: 206,
804
+ b: 250
805
+ }
806
+ ],
807
+ [
808
+ "lightslategray",
809
+ {
810
+ r: 119,
811
+ g: 136,
812
+ b: 153
813
+ }
814
+ ],
815
+ [
816
+ "lightslategrey",
817
+ {
818
+ r: 119,
819
+ g: 136,
820
+ b: 153
821
+ }
822
+ ],
823
+ [
824
+ "lightsteelblue",
825
+ {
826
+ r: 176,
827
+ g: 196,
828
+ b: 222
829
+ }
830
+ ],
831
+ [
832
+ "lightyellow",
833
+ {
834
+ r: 255,
835
+ g: 255,
836
+ b: 224
837
+ }
838
+ ],
839
+ [
840
+ "lime",
841
+ {
842
+ r: 0,
843
+ g: 255,
844
+ b: 0
845
+ }
846
+ ],
847
+ [
848
+ "limegreen",
849
+ {
850
+ r: 50,
851
+ g: 205,
852
+ b: 50
853
+ }
854
+ ],
855
+ [
856
+ "linen",
857
+ {
858
+ r: 250,
859
+ g: 240,
860
+ b: 230
861
+ }
862
+ ],
863
+ [
864
+ "magenta",
865
+ {
866
+ r: 255,
867
+ g: 0,
868
+ b: 255
869
+ }
870
+ ],
871
+ [
872
+ "maroon",
873
+ {
874
+ r: 128,
875
+ g: 0,
876
+ b: 0
877
+ }
878
+ ],
879
+ [
880
+ "mediumaquamarine",
881
+ {
882
+ r: 102,
883
+ g: 205,
884
+ b: 170
885
+ }
886
+ ],
887
+ [
888
+ "mediumblue",
889
+ {
890
+ r: 0,
891
+ g: 0,
892
+ b: 205
893
+ }
894
+ ],
895
+ [
896
+ "mediumorchid",
897
+ {
898
+ r: 186,
899
+ g: 85,
900
+ b: 211
901
+ }
902
+ ],
903
+ [
904
+ "mediumpurple",
905
+ {
906
+ r: 147,
907
+ g: 112,
908
+ b: 219
909
+ }
910
+ ],
911
+ [
912
+ "mediumseagreen",
913
+ {
914
+ r: 60,
915
+ g: 179,
916
+ b: 113
917
+ }
918
+ ],
919
+ [
920
+ "mediumslateblue",
921
+ {
922
+ r: 123,
923
+ g: 104,
924
+ b: 238
925
+ }
926
+ ],
927
+ [
928
+ "mediumspringgreen",
929
+ {
930
+ r: 0,
931
+ g: 250,
932
+ b: 154
933
+ }
934
+ ],
935
+ [
936
+ "mediumturquoise",
937
+ {
938
+ r: 72,
939
+ g: 209,
940
+ b: 204
941
+ }
942
+ ],
943
+ [
944
+ "mediumvioletred",
945
+ {
946
+ r: 199,
947
+ g: 21,
948
+ b: 133
949
+ }
950
+ ],
951
+ [
952
+ "midnightblue",
953
+ {
954
+ r: 25,
955
+ g: 25,
956
+ b: 112
957
+ }
958
+ ],
959
+ [
960
+ "mintcream",
961
+ {
962
+ r: 245,
963
+ g: 255,
964
+ b: 250
965
+ }
966
+ ],
967
+ [
968
+ "mistyrose",
969
+ {
970
+ r: 255,
971
+ g: 228,
972
+ b: 225
973
+ }
974
+ ],
975
+ [
976
+ "moccasin",
977
+ {
978
+ r: 255,
979
+ g: 228,
980
+ b: 181
981
+ }
982
+ ],
983
+ [
984
+ "navajowhite",
985
+ {
986
+ r: 255,
987
+ g: 222,
988
+ b: 173
989
+ }
990
+ ],
991
+ [
992
+ "navy",
993
+ {
994
+ r: 0,
995
+ g: 0,
996
+ b: 128
997
+ }
998
+ ],
999
+ [
1000
+ "oldlace",
1001
+ {
1002
+ r: 253,
1003
+ g: 245,
1004
+ b: 230
1005
+ }
1006
+ ],
1007
+ [
1008
+ "olive",
1009
+ {
1010
+ r: 128,
1011
+ g: 128,
1012
+ b: 0
1013
+ }
1014
+ ],
1015
+ [
1016
+ "olivedrab",
1017
+ {
1018
+ r: 107,
1019
+ g: 142,
1020
+ b: 35
1021
+ }
1022
+ ],
1023
+ [
1024
+ "orange",
1025
+ {
1026
+ r: 255,
1027
+ g: 165,
1028
+ b: 0
1029
+ }
1030
+ ],
1031
+ [
1032
+ "orangered",
1033
+ {
1034
+ r: 255,
1035
+ g: 69,
1036
+ b: 0
1037
+ }
1038
+ ],
1039
+ [
1040
+ "orchid",
1041
+ {
1042
+ r: 218,
1043
+ g: 112,
1044
+ b: 214
1045
+ }
1046
+ ],
1047
+ [
1048
+ "palegoldenrod",
1049
+ {
1050
+ r: 238,
1051
+ g: 232,
1052
+ b: 170
1053
+ }
1054
+ ],
1055
+ [
1056
+ "palegreen",
1057
+ {
1058
+ r: 152,
1059
+ g: 251,
1060
+ b: 152
1061
+ }
1062
+ ],
1063
+ [
1064
+ "paleturquoise",
1065
+ {
1066
+ r: 175,
1067
+ g: 238,
1068
+ b: 238
1069
+ }
1070
+ ],
1071
+ [
1072
+ "palevioletred",
1073
+ {
1074
+ r: 219,
1075
+ g: 112,
1076
+ b: 147
1077
+ }
1078
+ ],
1079
+ [
1080
+ "papayawhip",
1081
+ {
1082
+ r: 255,
1083
+ g: 239,
1084
+ b: 213
1085
+ }
1086
+ ],
1087
+ [
1088
+ "peachpuff",
1089
+ {
1090
+ r: 255,
1091
+ g: 218,
1092
+ b: 185
1093
+ }
1094
+ ],
1095
+ [
1096
+ "peru",
1097
+ {
1098
+ r: 205,
1099
+ g: 133,
1100
+ b: 63
1101
+ }
1102
+ ],
1103
+ [
1104
+ "pink",
1105
+ {
1106
+ r: 255,
1107
+ g: 192,
1108
+ b: 203
1109
+ }
1110
+ ],
1111
+ [
1112
+ "plum",
1113
+ {
1114
+ r: 221,
1115
+ g: 160,
1116
+ b: 221
1117
+ }
1118
+ ],
1119
+ [
1120
+ "powderblue",
1121
+ {
1122
+ r: 176,
1123
+ g: 224,
1124
+ b: 230
1125
+ }
1126
+ ],
1127
+ [
1128
+ "purple",
1129
+ {
1130
+ r: 128,
1131
+ g: 0,
1132
+ b: 128
1133
+ }
1134
+ ],
1135
+ [
1136
+ "rebeccapurple",
1137
+ {
1138
+ r: 102,
1139
+ g: 51,
1140
+ b: 153
1141
+ }
1142
+ ],
1143
+ [
1144
+ "red",
1145
+ {
1146
+ r: 255,
1147
+ g: 0,
1148
+ b: 0
1149
+ }
1150
+ ],
1151
+ [
1152
+ "rosybrown",
1153
+ {
1154
+ r: 188,
1155
+ g: 143,
1156
+ b: 143
1157
+ }
1158
+ ],
1159
+ [
1160
+ "royalblue",
1161
+ {
1162
+ r: 65,
1163
+ g: 105,
1164
+ b: 225
1165
+ }
1166
+ ],
1167
+ [
1168
+ "saddlebrown",
1169
+ {
1170
+ r: 139,
1171
+ g: 69,
1172
+ b: 19
1173
+ }
1174
+ ],
1175
+ [
1176
+ "salmon",
1177
+ {
1178
+ r: 250,
1179
+ g: 128,
1180
+ b: 114
1181
+ }
1182
+ ],
1183
+ [
1184
+ "sandybrown",
1185
+ {
1186
+ r: 244,
1187
+ g: 164,
1188
+ b: 96
1189
+ }
1190
+ ],
1191
+ [
1192
+ "seagreen",
1193
+ {
1194
+ r: 46,
1195
+ g: 139,
1196
+ b: 87
1197
+ }
1198
+ ],
1199
+ [
1200
+ "seashell",
1201
+ {
1202
+ r: 255,
1203
+ g: 245,
1204
+ b: 238
1205
+ }
1206
+ ],
1207
+ [
1208
+ "sienna",
1209
+ {
1210
+ r: 160,
1211
+ g: 82,
1212
+ b: 45
1213
+ }
1214
+ ],
1215
+ [
1216
+ "silver",
1217
+ {
1218
+ r: 192,
1219
+ g: 192,
1220
+ b: 192
1221
+ }
1222
+ ],
1223
+ [
1224
+ "skyblue",
1225
+ {
1226
+ r: 135,
1227
+ g: 206,
1228
+ b: 235
1229
+ }
1230
+ ],
1231
+ [
1232
+ "slateblue",
1233
+ {
1234
+ r: 106,
1235
+ g: 90,
1236
+ b: 205
1237
+ }
1238
+ ],
1239
+ [
1240
+ "slategray",
1241
+ {
1242
+ r: 112,
1243
+ g: 128,
1244
+ b: 144
1245
+ }
1246
+ ],
1247
+ [
1248
+ "slategrey",
1249
+ {
1250
+ r: 112,
1251
+ g: 128,
1252
+ b: 144
1253
+ }
1254
+ ],
1255
+ [
1256
+ "snow",
1257
+ {
1258
+ r: 255,
1259
+ g: 250,
1260
+ b: 250
1261
+ }
1262
+ ],
1263
+ [
1264
+ "springgreen",
1265
+ {
1266
+ r: 0,
1267
+ g: 255,
1268
+ b: 127
1269
+ }
1270
+ ],
1271
+ [
1272
+ "steelblue",
1273
+ {
1274
+ r: 70,
1275
+ g: 130,
1276
+ b: 180
1277
+ }
1278
+ ],
1279
+ [
1280
+ "tan",
1281
+ {
1282
+ r: 210,
1283
+ g: 180,
1284
+ b: 140
1285
+ }
1286
+ ],
1287
+ [
1288
+ "teal",
1289
+ {
1290
+ r: 0,
1291
+ g: 128,
1292
+ b: 128
1293
+ }
1294
+ ],
1295
+ [
1296
+ "thistle",
1297
+ {
1298
+ r: 216,
1299
+ g: 191,
1300
+ b: 216
1301
+ }
1302
+ ],
1303
+ [
1304
+ "tomato",
1305
+ {
1306
+ r: 255,
1307
+ g: 99,
1308
+ b: 71
1309
+ }
1310
+ ],
1311
+ [
1312
+ "turquoise",
1313
+ {
1314
+ r: 64,
1315
+ g: 224,
1316
+ b: 208
1317
+ }
1318
+ ],
1319
+ [
1320
+ "violet",
1321
+ {
1322
+ r: 238,
1323
+ g: 130,
1324
+ b: 238
1325
+ }
1326
+ ],
1327
+ [
1328
+ "wheat",
1329
+ {
1330
+ r: 245,
1331
+ g: 222,
1332
+ b: 179
1333
+ }
1334
+ ],
1335
+ [
1336
+ "white",
1337
+ {
1338
+ r: 255,
1339
+ g: 255,
1340
+ b: 255
1341
+ }
1342
+ ],
1343
+ [
1344
+ "whitesmoke",
1345
+ {
1346
+ r: 245,
1347
+ g: 245,
1348
+ b: 245
1349
+ }
1350
+ ],
1351
+ [
1352
+ "yellow",
1353
+ {
1354
+ r: 255,
1355
+ g: 255,
1356
+ b: 0
1357
+ }
1358
+ ],
1359
+ [
1360
+ "yellowgreen",
1361
+ {
1362
+ r: 154,
1363
+ g: 205,
1364
+ b: 50
1365
+ }
1366
+ ]
1367
+ ], me = "deg|rad|grad|turn", ve = "[-\\+]?\\d+%?", we = "[-\\+]?\\d*\\.\\d+%?", $e = `[-\\+]?\\d*\\.?\\d+(?:${me})?`, dt = `(?:${we})|(?:${ve})`, Rt = `(?:${dt})|(?:${$e}?)`, no = "(?:[\\s|\\(\\s|\\s\\(\\s]+)?", io = "(?:[\\s|\\)\\s]+)?", ee = "(?:[,|\\s]+)", ao = "(?:[,|\\/\\s]*)?", rt = `${no}(${Rt})${ee}(${dt})${ee}(${dt})${ao}(${dt})?${io}`, I = {
1368
+ CSS_UNIT: new RegExp(Rt),
1369
+ ANGLES: me,
1370
+ CSS_ANGLE: $e,
1371
+ CSS_INTEGER: ve,
1372
+ CSS_NUMBER: we,
1373
+ CSS_UNIT2: Rt,
1374
+ PERMISSIVE_MATCH: rt,
1375
+ hwb: new RegExp(`hwb${rt}`),
1376
+ rgb: new RegExp(`rgb(?:a)?${rt}`),
1377
+ hsl: new RegExp(`hsl(?:a)?${rt}`),
1378
+ hsv: new RegExp(`hsv(?:a)?${rt}`),
1379
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1380
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1381
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1382
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1383
+ }, ke = (o) => Gt.includes(o), nt = (o, t) => o !== null && typeof o == "object" && Object.keys(t).every((e) => e in o), ye = (o) => `${o}`.includes(".") && parseFloat(o) === 1, $t = (o) => typeof o == "string" && o.includes("%"), H = (o) => !!I.CSS_UNIT.exec(`${o}`), xe = ["rgb", "hex", "hsl", "hsv", "hwb"], Se = (o) => Gt.includes(o) || ["#", ...xe].some((t) => o.includes(t)) ? !1 : wt.some(([t]) => o === t), R = (o, t) => {
1384
+ let e = o;
1385
+ if (typeof o == "number" && Math.min(o, 0) === 0 && // round values to 6 decimals Math.round(N * (10 ** 6)) / 10 ** 6
1386
+ Math.max(o, 1) === 1)
1387
+ return o;
1388
+ ye(o) && (e = "100%");
1389
+ const s = $t(e);
1390
+ return e = t === 360 ? parseFloat(e) : Math.min(t, Math.max(0, parseFloat(e))), s && (e = e * t / 100), Math.abs(e - t) < 1e-6 ? 1 : (t === 360 ? e = (e < 0 ? e % t + t : e % t) / t : e = e % t / t, e);
1391
+ }, Ot = (o) => {
1392
+ let t = parseFloat(o);
1393
+ return (Number.isNaN(t) || t < 0 || t > 1) && (t = 1), t;
1394
+ }, ut = (o) => Math.min(1, Math.max(0, o)), G = (o) => o.length === 1 ? `0${o}` : String(o), Pe = (o) => {
1395
+ const [[, t]] = wt.filter(([e]) => e === o.toLowerCase());
1396
+ return t;
1397
+ }, N = (o) => parseInt(o, 16), Dt = (o) => N(o) / 255, Ce = (o) => v(o * 255).toString(16), oe = (o, t, e) => {
1398
+ const s = Math.max(o, t, e), r = Math.min(o, t, e);
1399
+ let n = 0, i = 0;
1400
+ const a = (s + r) / 2;
1401
+ if (s === r)
1402
+ i = 0, n = 0;
1403
+ else {
1404
+ const l = s - r;
1405
+ i = a > 0.5 ? l / (2 - s - r) : l / (s + r), s === o && (n = (t - e) / l + (t < e ? 6 : 0)), s === t && (n = (e - o) / l + 2), s === e && (n = (o - t) / l + 4), n /= 6;
1406
+ }
1407
+ return { h: n, s: i, l: a };
1408
+ }, ft = (o, t, e) => {
1409
+ let s = e;
1410
+ return s < 0 && (s += 1), s > 1 && (s -= 1), s < 1 / 6 ? o + (t - o) * (6 * s) : s < 1 / 2 ? t : s < 2 / 3 ? o + (t - o) * (2 / 3 - s) * 6 : o;
1411
+ }, lt = (o, t, e) => {
1412
+ let s = 0, r = 0, n = 0;
1413
+ if (t === 0)
1414
+ r = e, n = e, s = e;
1415
+ else if (e) {
1416
+ const i = e < 0.5 ? e * (1 + t) : e + t - e * t, a = 2 * e - i;
1417
+ s = ft(a, i, o + 1 / 3), r = ft(a, i, o), n = ft(a, i, o - 1 / 3);
1418
+ }
1419
+ return { r: s, g: r, b: n };
1420
+ }, se = (o, t, e) => {
1421
+ let s = 0, r = 0;
1422
+ const n = Math.min(o, t, e), i = Math.max(o, t, e), a = 1 - i;
1423
+ if (i === n)
1424
+ return { h: 0, w: n, b: a };
1425
+ o === n ? (s = t - e, r = 3) : (s = t === n ? e - o : o - t, r = t === n ? 5 : 1);
1426
+ const l = (r - s / (i - n)) / 6;
1427
+ return {
1428
+ h: l === 1 ? 0 : l,
1429
+ w: n,
1430
+ b: a
1431
+ };
1432
+ }, Le = (o, t, e) => {
1433
+ if (t + e >= 1) {
1434
+ const i = t / (t + e);
1435
+ return { r: i, g: i, b: i };
1436
+ }
1437
+ let { r: s, g: r, b: n } = lt(o, 1, 0.5);
1438
+ return [s, r, n] = [s, r, n].map((i) => i * (1 - t - e) + t), { r: s, g: r, b: n };
1439
+ }, re = (o, t, e) => {
1440
+ const s = Math.max(o, t, e), r = Math.min(o, t, e);
1441
+ let n = 0;
1442
+ const i = s, a = s - r, l = s === 0 ? 0 : a / s;
1443
+ return s === r ? n = 0 : (o === s && (n = (t - e) / a + (t < e ? 6 : 0)), t === s && (n = (e - o) / a + 2), e === s && (n = (o - t) / a + 4), n /= 6), { h: n, s: l, v: i };
1444
+ }, Ft = (o, t, e) => {
1445
+ const s = o * 6, r = t, n = e, i = Math.floor(s), a = s - i, l = n * (1 - r), c = n * (1 - a * r), h = n * (1 - (1 - a) * r), b = i % 6, u = [n, c, l, l, h, n][b], d = [h, n, n, c, l, l][b], g = [l, l, h, n, n, c][b];
1446
+ return { r: u, g: d, b: g };
1447
+ }, ne = (o, t, e, s) => {
1448
+ const r = [
1449
+ G(v(o).toString(16)),
1450
+ G(v(t).toString(16)),
1451
+ G(v(e).toString(16))
1452
+ ];
1453
+ return s && r[0].charAt(0) === r[0].charAt(1) && r[1].charAt(0) === r[1].charAt(1) && r[2].charAt(0) === r[2].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) : r.join("");
1454
+ }, At = (o, t, e, s, r) => {
1455
+ const n = [
1456
+ G(v(o).toString(16)),
1457
+ G(v(t).toString(16)),
1458
+ G(v(e).toString(16)),
1459
+ G(Ce(s))
1460
+ ];
1461
+ return r && n[0].charAt(0) === n[0].charAt(1) && n[1].charAt(0) === n[1].charAt(1) && n[2].charAt(0) === n[2].charAt(1) && n[3].charAt(0) === n[3].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) + n[3].charAt(0) : n.join("");
1462
+ }, Ae = (o) => {
1463
+ const t = String(o).trim().toLowerCase();
1464
+ if (Se(t))
1465
+ return Object.assign(Pe(t), {
1466
+ a: 1,
1467
+ format: "rgb",
1468
+ ok: !0
1469
+ });
1470
+ if (ke(t))
1471
+ return {
1472
+ r: 0,
1473
+ g: 0,
1474
+ b: 0,
1475
+ a: t === "transparent" ? 0 : 1,
1476
+ format: "rgb",
1477
+ ok: !0
1478
+ };
1479
+ let [, e, s, r, n] = I.rgb.exec(t) || [];
1480
+ return e && s && r ? {
1481
+ r: e,
1482
+ g: s,
1483
+ b: r,
1484
+ a: n !== void 0 ? n : 1,
1485
+ format: "rgb",
1486
+ ok: !0
1487
+ } : ([, e, s, r, n] = I.hsl.exec(t) || [], e && s && r ? {
1488
+ h: e,
1489
+ s,
1490
+ l: r,
1491
+ a: n !== void 0 ? n : 1,
1492
+ format: "hsl",
1493
+ ok: !0
1494
+ } : ([, e, s, r, n] = I.hsv.exec(t) || [], e && s && r ? {
1495
+ h: e,
1496
+ s,
1497
+ v: r,
1498
+ a: n !== void 0 ? n : 1,
1499
+ format: "hsv",
1500
+ ok: !0
1501
+ } : ([, e, s, r, n] = I.hwb.exec(t) || [], e && s && r ? {
1502
+ h: e,
1503
+ w: s,
1504
+ b: r,
1505
+ a: n !== void 0 ? n : 1,
1506
+ format: "hwb",
1507
+ ok: !0
1508
+ } : ([, e, s, r, n] = I.hex8.exec(t) || [], e && s && r && n ? {
1509
+ r: N(e),
1510
+ g: N(s),
1511
+ b: N(r),
1512
+ a: Dt(n),
1513
+ format: "hex",
1514
+ ok: !0
1515
+ } : ([, e, s, r] = I.hex6.exec(t) || [], e && s && r ? {
1516
+ r: N(e),
1517
+ g: N(s),
1518
+ b: N(r),
1519
+ a: 1,
1520
+ format: "hex",
1521
+ ok: !0
1522
+ } : ([, e, s, r, n] = I.hex4.exec(t) || [], e && s && r && n ? {
1523
+ r: N(e + e),
1524
+ g: N(s + s),
1525
+ b: N(r + r),
1526
+ a: Dt(n + n),
1527
+ format: "hex",
1528
+ ok: !0
1529
+ } : ([, e, s, r] = I.hex3.exec(t) || [], e && s && r ? {
1530
+ r: N(e + e),
1531
+ g: N(s + s),
1532
+ b: N(r + r),
1533
+ a: 1,
1534
+ format: "hex",
1535
+ ok: !0
1536
+ } : {
1537
+ r: 0,
1538
+ g: 0,
1539
+ b: 0,
1540
+ a: 1,
1541
+ format: "rgb",
1542
+ ok: !o
1543
+ })))))));
1544
+ }, ie = (o) => {
1545
+ let t = { r: 0, g: 0, b: 0 }, e = o, s = 1, r, n, i, a, l, c, h, b, u = "rgb", d = !1;
1546
+ return (!e || typeof e == "string") && (e = Ae(e), d = e.ok), nt(e, t) && H(e.r) && H(e.g) && H(e.b) && ({ r: h, g: b, b: l } = e, [h, b, l] = [h, b, l].map((g) => R(g, $t(g) ? 100 : 255)), t = { r: h, g: b, b: l }, u = "format" in e ? e.format : "rgb"), nt(e, { h: 0, s: 0, v: 0 }) && H(e.h) && H(e.s) && H(e.v) && ({ h: c, s: r, v: n } = e, c = R(c, 360), r = R(r, 100), n = R(n, 100), t = Ft(c, r, n), u = "hsv"), nt(e, { h: 0, s: 0, l: 0 }) && H(e.h) && H(e.s) && H(e.l) && ({ h: c, s: r, l: i } = e, c = R(c, 360), r = R(r, 100), i = R(i, 100), t = lt(c, r, i), u = "hsl"), nt(e, { h: 0, w: 0, b: 0 }) && H(e.h) && H(e.w) && H(e.b) && ({ h: c, w: a, b: l } = e, c = R(c, 360), a = R(a, 100), l = R(l, 100), t = Le(c, a, l), u = "hwb"), H(e.a) && (s = e.a, s = $t(s) || parseFloat(`${s}`) > 1 ? R(s, 100) : s), {
1547
+ r: t.r,
1548
+ g: t.g,
1549
+ b: t.b,
1550
+ a: Ot(s),
1551
+ format: u,
1552
+ ok: d
1553
+ };
1554
+ }, lo = "1.0.8";
1555
+ class y {
1556
+ // bring main utilities to front
1557
+ static matchers = I;
1558
+ static isOnePointZero = ye;
1559
+ static isPercentage = $t;
1560
+ static isValidCSSUnit = H;
1561
+ static isNonColor = ke;
1562
+ static isColorName = Se;
1563
+ static isColorType = nt;
1564
+ static pad2 = G;
1565
+ static clamp01 = ut;
1566
+ static bound01 = R;
1567
+ static boundAlpha = Ot;
1568
+ static getRGBFromName = Pe;
1569
+ static convertHexToDecimal = Dt;
1570
+ static convertDecimalToHex = Ce;
1571
+ static rgbToHsl = oe;
1572
+ static rgbToHex = ne;
1573
+ static rgbToHsv = re;
1574
+ static rgbToHwb = se;
1575
+ static rgbaToHex = At;
1576
+ static hslToRgb = Ft;
1577
+ static hsvToRgb = Ft;
1578
+ static hueToRgb = ft;
1579
+ static hwbToRgb = Le;
1580
+ static parseIntFromHex = N;
1581
+ static stringInputToObject = Ae;
1582
+ static inputToRGB = ie;
1583
+ static roundPart = v;
1584
+ static webColors = wt;
1585
+ static nonColors = Gt;
1586
+ static version = lo;
1587
+ // main public properties
1588
+ r;
1589
+ g;
1590
+ b;
1591
+ a;
1592
+ format;
1593
+ ok;
1594
+ originalInput;
1595
+ // main public methods
1596
+ constructor(t, e) {
1597
+ const s = e && xe.includes(e) ? e : "", { r, g: n, b: i, a, ok: l, format: c } = ie(t);
1598
+ this.originalInput = t, this.r = r, this.g = n, this.b = i, this.a = a, this.ok = l, this.format = s || c;
1599
+ }
1600
+ /**
1601
+ * Checks if the current input value is a valid colour.
1602
+ */
1603
+ get isValid() {
1604
+ return this.ok;
1605
+ }
1606
+ /**
1607
+ * Checks if the current colour requires a light text colour.
1608
+ */
1609
+ get isDark() {
1610
+ return this.brightness < 120;
1611
+ }
1612
+ /**
1613
+ * Returns the perceived luminance of a colour.
1614
+ *
1615
+ * @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
1616
+ */
1617
+ get luminance() {
1618
+ const { r: t, g: e, b: s } = this;
1619
+ let r = 0, n = 0, i = 0;
1620
+ return t <= 0.03928 ? r = t / 12.92 : r = ((t + 0.055) / 1.055) ** 2.4, e <= 0.03928 ? n = e / 12.92 : n = ((e + 0.055) / 1.055) ** 2.4, s <= 0.03928 ? i = s / 12.92 : i = ((s + 0.055) / 1.055) ** 2.4, 0.2126 * r + 0.7152 * n + 0.0722 * i;
1621
+ }
1622
+ /**
1623
+ * Returns the perceived brightness of the colour.
1624
+ */
1625
+ get brightness() {
1626
+ const { r: t, g: e, b: s } = this.toRgb();
1627
+ return (t * 299 + e * 587 + s * 114) / 1e3;
1628
+ }
1629
+ /**
1630
+ * Returns the web colour name closest to the current colour.
1631
+ */
1632
+ get name() {
1633
+ const { r: t, g: e, b: s } = this.toRgb(), [r] = wt.map(([n, i]) => {
1634
+ const a = (
1635
+ // ((rgb.r - r) ** 2 + (rgb.g - g) ** 2 + (rgb.b - b) ** 2) ** 0.5; // standard
1636
+ (((i.r - t) * 0.3) ** 2 + ((i.g - e) * 0.6) ** 2 + ((i.b - s) * 0.1) ** 2) ** 0.5
1637
+ );
1638
+ return [n, a];
1639
+ }).find(([, n], i, a) => n === Math.min(...a.map(([, l]) => l)));
1640
+ return r;
1641
+ }
1642
+ /**
1643
+ * Returns the colour as an RGBA object.
1644
+ */
1645
+ toRgb() {
1646
+ let { r: t, g: e, b: s, a: r } = this;
1647
+ return [t, e, s] = [t, e, s].map((n) => v(n * 255 * 100) / 100), r = v(r * 100) / 100, {
1648
+ r: t,
1649
+ g: e,
1650
+ b: s,
1651
+ a: r
1652
+ };
1653
+ }
1654
+ /**
1655
+ * Returns the RGBA values concatenated into a CSS3 Module string format.
1656
+ * * rgb(255,255,255)
1657
+ * * rgba(255,255,255,0.5)
1658
+ */
1659
+ toRgbString() {
1660
+ const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(v);
1661
+ return r === 1 ? `rgb(${n}, ${i}, ${a})` : `rgba(${n}, ${i}, ${a}, ${r})`;
1662
+ }
1663
+ /**
1664
+ * Returns the RGBA values concatenated into a CSS4 Module string format.
1665
+ * * rgb(255 255 255)
1666
+ * * rgb(255 255 255 / 50%)
1667
+ */
1668
+ toRgbCSS4String() {
1669
+ const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(v), l = r === 1 ? "" : ` / ${v(r * 100)}%`;
1670
+ return `rgb(${n} ${i} ${a}${l})`;
1671
+ }
1672
+ /**
1673
+ * Returns the hexadecimal value of the colour. When the parameter is *true*
1674
+ * it will find a 3 characters shorthand of the decimal value.
1675
+ */
1676
+ toHex(t) {
1677
+ const { r: e, g: s, b: r, a: n } = this.toRgb();
1678
+ return n === 1 ? ne(e, s, r, t) : At(e, s, r, n, t);
1679
+ }
1680
+ /**
1681
+ * Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
1682
+ * it will find a 3 characters shorthand of the value.
1683
+ */
1684
+ toHexString(t) {
1685
+ return `#${this.toHex(t)}`;
1686
+ }
1687
+ /**
1688
+ * Returns the HEX8 value of the colour.
1689
+ */
1690
+ toHex8(t) {
1691
+ const { r: e, g: s, b: r, a: n } = this.toRgb();
1692
+ return At(e, s, r, n, t);
1693
+ }
1694
+ /**
1695
+ * Returns the HEX8 value of the colour.
1696
+ */
1697
+ toHex8String(t) {
1698
+ return `#${this.toHex8(t)}`;
1699
+ }
1700
+ /**
1701
+ * Returns the colour as a HSVA object.
1702
+ */
1703
+ toHsv() {
1704
+ const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } = re(t, e, s);
1705
+ return {
1706
+ h: n,
1707
+ s: i,
1708
+ v: a,
1709
+ a: r
1710
+ };
1711
+ }
1712
+ /**
1713
+ * Returns the colour as an HSLA object.
1714
+ */
1715
+ toHsl() {
1716
+ const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } = oe(t, e, s);
1717
+ return {
1718
+ h: n,
1719
+ s: i,
1720
+ l: a,
1721
+ a: r
1722
+ };
1723
+ }
1724
+ /**
1725
+ * Returns the HSLA values concatenated into a CSS3 Module format string.
1726
+ * * `hsl(150, 100%, 50%)`
1727
+ * * `hsla(150, 100%, 50%, 0.5)`
1728
+ */
1729
+ toHslString() {
1730
+ let { h: t, s: e, l: s, a: r } = this.toHsl();
1731
+ return t = v(t * 360), e = v(e * 100), s = v(s * 100), r = v(r * 100) / 100, r === 1 ? `hsl(${t}, ${e}%, ${s}%)` : `hsla(${t}, ${e}%, ${s}%, ${r})`;
1732
+ }
1733
+ /**
1734
+ * Returns the HSLA values concatenated into a CSS4 Module format string.
1735
+ * * `hsl(150deg 100% 50%)`
1736
+ * * `hsl(150deg 100% 50% / 50%)`
1737
+ */
1738
+ toHslCSS4String() {
1739
+ let { h: t, s: e, l: s, a: r } = this.toHsl();
1740
+ t = v(t * 360), e = v(e * 100), s = v(s * 100), r = v(r * 100);
1741
+ const n = r < 100 ? ` / ${v(r)}%` : "";
1742
+ return `hsl(${t}deg ${e}% ${s}%${n})`;
1743
+ }
1744
+ /**
1745
+ * Returns the colour as an HWBA object.
1746
+ */
1747
+ toHwb() {
1748
+ const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } = se(t, e, s);
1749
+ return {
1750
+ h: n,
1751
+ w: i,
1752
+ b: a,
1753
+ a: r
1754
+ };
1755
+ }
1756
+ /**
1757
+ * Returns the HWBA values concatenated into a string.
1758
+ */
1759
+ toHwbString() {
1760
+ let { h: t, w: e, b: s, a: r } = this.toHwb();
1761
+ t = v(t * 360), e = v(e * 100), s = v(s * 100), r = v(r * 100);
1762
+ const n = r < 100 ? ` / ${v(r)}%` : "";
1763
+ return `hwb(${t}deg ${e}% ${s}%${n})`;
1764
+ }
1765
+ /**
1766
+ * Sets the alpha value of the current colour.
1767
+ */
1768
+ setAlpha(t) {
1769
+ return typeof t != "number" ? this : (this.a = Ot(t), this);
1770
+ }
1771
+ /**
1772
+ * Saturate the colour with a given amount.
1773
+ */
1774
+ saturate(t) {
1775
+ if (typeof t != "number")
1776
+ return this;
1777
+ const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(e, ut(s + t / 100), r);
1778
+ return Object.assign(this, { r: n, g: i, b: a }), this;
1779
+ }
1780
+ /**
1781
+ * Desaturate the colour with a given amount.
1782
+ */
1783
+ desaturate(t) {
1784
+ return typeof t == "number" ? this.saturate(-t) : this;
1785
+ }
1786
+ /**
1787
+ * Completely desaturates a colour into greyscale.
1788
+ * Same as calling `desaturate(100)`
1789
+ */
1790
+ greyscale() {
1791
+ return this.saturate(-100);
1792
+ }
1793
+ /**
1794
+ * Increase the colour lightness with a given amount.
1795
+ */
1796
+ lighten(t) {
1797
+ if (typeof t != "number")
1798
+ return this;
1799
+ const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(e, s, ut(r + t / 100));
1800
+ return Object.assign(this, { r: n, g: i, b: a }), this;
1801
+ }
1802
+ /**
1803
+ * Decrease the colour lightness with a given amount.
1804
+ */
1805
+ darken(t) {
1806
+ return typeof t == "number" ? this.lighten(-t) : this;
1807
+ }
1808
+ /**
1809
+ * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
1810
+ * Values outside of this range will be wrapped into this range.
1811
+ */
1812
+ spin(t) {
1813
+ if (typeof t != "number")
1814
+ return this;
1815
+ const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(ut((e * 360 + t) % 360 / 360), s, r);
1816
+ return Object.assign(this, { r: n, g: i, b: a }), this;
1817
+ }
1818
+ /** Returns a clone of the current `Color` instance. */
1819
+ clone() {
1820
+ return new y(this);
1821
+ }
1822
+ /**
1823
+ * Returns the colour value in CSS valid string format.
1824
+ */
1825
+ toString(t) {
1826
+ const { format: e } = this;
1827
+ return e === "hex" ? this.toHexString(t) : e === "hsl" ? this.toHslString() : e === "hwb" ? this.toHwbString() : this.toRgbString();
1828
+ }
1829
+ }
1830
+ class It {
1831
+ static Color = y;
1832
+ hue;
1833
+ hueSteps;
1834
+ lightSteps;
1835
+ saturation;
1836
+ colors;
1837
+ /**
1838
+ * The `hue` parameter is optional, which would be set to 0.
1839
+ * * `args.hue` the starting Hue [0, 360]
1840
+ * * `args.hueSteps` Hue Steps Count [5, 24]
1841
+ * * `args.lightSteps` Lightness Steps Count [5, 12]
1842
+ * * `args.saturation` Saturation [0, 100]
1843
+ */
1844
+ constructor(...t) {
1845
+ let e = 0, s = 12, r = 10, n = [0.5], i = 100;
1846
+ if (t.length === 4)
1847
+ [e, s, r, i] = t;
1848
+ else if (t.length === 3)
1849
+ [e, s, r] = t;
1850
+ else if (t.length === 2 && ([s, r] = t, [s, r].some((g) => g < 1)))
1851
+ throw TypeError("ColorPalette: the two minimum arguments must be numbers higher than 0.");
1852
+ const a = [], l = 360 / s, c = y.roundPart((r - (r % 2 ? 1 : 0)) / 2), h = [0.25, 0.2, 0.15, 0.11, 0.09, 0.075], b = [
1853
+ [1, 2, 3],
1854
+ [4, 5],
1855
+ [6, 7],
1856
+ [8, 9],
1857
+ [10, 11],
1858
+ [12, 13]
1859
+ ], u = b.find((g) => g.includes(r)), d = u ? h[b.indexOf(u)] : 100 / (r + (r % 2 ? 0 : 1)) / 100;
1860
+ for (let g = 1; g < c + 1; g += 1)
1861
+ n = [...n, 0.5 + d * g];
1862
+ for (let g = 1; g < r - c; g += 1)
1863
+ n = [0.5 - d * g, ...n];
1864
+ for (let g = 0; g < s; g += 1) {
1865
+ const p = (e + g * l) % 360 / 360;
1866
+ n.forEach((f) => {
1867
+ const w = new y({ h: p, s: 1, l: f });
1868
+ a.push(i < 100 ? w.saturate(i - 100) : w);
1869
+ });
1870
+ }
1871
+ this.hue = e, this.hueSteps = s, this.lightSteps = r, this.saturation = i, this.colors = a;
1872
+ }
1873
+ }
1874
+ const Kt = {
1875
+ pickerLabel: "Colour Picker",
1876
+ appearanceLabel: "Colour Appearance",
1877
+ valueLabel: "Colour Value",
1878
+ toggleLabel: "Select Colour",
1879
+ presetsLabel: "Colour Presets",
1880
+ defaultsLabel: "Colour Defaults",
1881
+ formatLabel: "Format",
1882
+ alphaLabel: "Alpha",
1883
+ hexLabel: "Hexadecimal",
1884
+ hueLabel: "Hue",
1885
+ whitenessLabel: "Whiteness",
1886
+ blacknessLabel: "Blackness",
1887
+ saturationLabel: "Saturation",
1888
+ lightnessLabel: "Lightness",
1889
+ redLabel: "Red",
1890
+ greenLabel: "Green",
1891
+ blueLabel: "Blue"
1892
+ }, it = [
1893
+ "white",
1894
+ "black",
1895
+ "grey",
1896
+ "red",
1897
+ "orange",
1898
+ "brown",
1899
+ "gold",
1900
+ "olive",
1901
+ "yellow",
1902
+ "lime",
1903
+ "green",
1904
+ "teal",
1905
+ "cyan",
1906
+ "blue",
1907
+ "violet",
1908
+ "magenta",
1909
+ "pink"
1910
+ ], ae = (o) => {
1911
+ if (!B(o))
1912
+ return !1;
1913
+ try {
1914
+ JSON.parse(o);
1915
+ } catch {
1916
+ return !1;
1917
+ }
1918
+ return !0;
1919
+ }, Vt = "v-hidden", co = (o) => {
1920
+ const { format: t, id: e, componentLabels: s } = o, r = x({
1921
+ tagName: "div",
1922
+ className: `color-form ${t}`
1923
+ });
1924
+ let n = ["hex"];
1925
+ return t === "rgb" ? n = ["red", "green", "blue", "alpha"] : t === "hsl" ? n = ["hue", "saturation", "lightness", "alpha"] : t === "hwb" && (n = ["hue", "whiteness", "blackness", "alpha"]), n.forEach((i) => {
1926
+ const [a] = t === "hex" ? ["#"] : pe(i).split(""), l = `color_${t}_${i}_${e}`, c = s[`${i}Label`], h = x({ tagName: "label" });
1927
+ m(h, "for", l), h.append(
1928
+ x({
1929
+ tagName: "span",
1930
+ ariaHidden: "true",
1931
+ innerText: `${a}:`
1932
+ }),
1933
+ x({
1934
+ tagName: "span",
1935
+ className: Vt,
1936
+ innerText: c
1937
+ })
1938
+ );
1939
+ const b = x({
1940
+ tagName: "input",
1941
+ id: l,
1942
+ // name: cID, - prevent saving the value to a form
1943
+ type: t === "hex" ? "text" : "number",
1944
+ value: i === "alpha" ? "100" : "0",
1945
+ className: `color-input ${i}`,
1946
+ autocomplete: "off",
1947
+ spellcheck: !1
1948
+ });
1949
+ let u = "100", d = "1";
1950
+ i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")), K(b, {
1951
+ min: "0",
1952
+ max: u,
1953
+ step: d
1954
+ }), r.append(h, b);
1955
+ }), r;
1956
+ }, ho = (o) => {
1957
+ const { format: t, componentLabels: e } = o, { hueLabel: s, alphaLabel: r, lightnessLabel: n, saturationLabel: i, whitenessLabel: a, blacknessLabel: l } = e, c = t === "hsl" ? 360 : 100, h = t === "hsl" ? 100 : 360, b = 100;
1958
+ let u = t === "hsl" ? `${s} & ${n}` : `${n} & ${i}`;
1959
+ u = t === "hwb" ? `${a} & ${l}` : u;
1960
+ const d = t === "hsl" ? `${i}` : `${s}`, g = x({
1961
+ tagName: "div",
1962
+ className: `color-controls ${t}`
1963
+ }), p = "color-pointer", f = "color-slider";
1964
+ return [
1965
+ {
1966
+ i: 1,
1967
+ c: p,
1968
+ l: u,
1969
+ min: 0,
1970
+ max: c
1971
+ },
1972
+ {
1973
+ i: 2,
1974
+ c: f,
1975
+ l: d,
1976
+ min: 0,
1977
+ max: h
1978
+ },
1979
+ {
1980
+ i: 3,
1981
+ c: f,
1982
+ l: r,
1983
+ min: 0,
1984
+ max: b
1985
+ }
1986
+ ].forEach(($) => {
1987
+ const { i: S, c: L, l: P, min: C, max: M } = $, E = x({
1988
+ tagName: "div",
1989
+ className: "color-control",
1990
+ role: "presentation"
1991
+ });
1992
+ E.append(
1993
+ x({
1994
+ tagName: "div",
1995
+ className: `visual-control visual-control${S}`
1996
+ })
1997
+ );
1998
+ const A = x({
1999
+ tagName: "div",
2000
+ className: `${L} knob`,
2001
+ ariaLive: "polite",
2002
+ ariaLabel: P,
2003
+ role: "slider",
2004
+ tabIndex: 0,
2005
+ ariaValueMin: `${C}`,
2006
+ ariaValueMax: `${M}`
2007
+ });
2008
+ E.append(A), g.append(E);
2009
+ }), g;
2010
+ }, le = (o, t, e) => {
2011
+ const { input: s, format: r, componentLabels: n } = o, { defaultsLabel: i, presetsLabel: a } = n, l = e === "color-options", c = t instanceof It, h = l ? a : i, b = c ? t.colors : t, u = b.length, { lightSteps: d } = c ? t : { lightSteps: null }, g = d || [9, 10].find((A) => u >= A * 2 && !(u % A)) || 5, p = l && u > g;
2012
+ let f = 2;
2013
+ f = p && u > g * 2 ? 3 : f, f = p && u > g * 3 ? 4 : f, f = p && u > g * 4 ? 5 : f;
2014
+ const w = f - (u <= g * 3 ? 1 : 2), $ = p && u > w * g;
2015
+ let S = e;
2016
+ S += $ ? " scrollable" : "", S += p ? " multiline" : "";
2017
+ const L = p ? "1px" : "0.25rem";
2018
+ let P = p ? 1.75 : 2;
2019
+ P = g > 5 && p ? 1.5 : P;
2020
+ const C = `${w * P}rem`, M = `calc(${f} * ${P}rem + ${f - 1} * ${L})`, E = x({
2021
+ tagName: "ul",
2022
+ className: S,
2023
+ role: "listbox",
2024
+ ariaLabel: h
2025
+ });
2026
+ return $ && D(E, {
2027
+ "--grid-item-size": `${P}rem`,
2028
+ "--grid-fit": `${g}`,
2029
+ "--grid-gap": L,
2030
+ "--grid-height": C,
2031
+ "--grid-hover-height": M
2032
+ }), b.forEach((A) => {
2033
+ let [F, Q] = typeof A == "string" ? A.trim().split(":") : [];
2034
+ A instanceof y && (F = A.toHexString(), Q = F);
2035
+ const Ut = new y(A instanceof y ? A : F, r).toString() === yt(s, "value"), xt = x({
2036
+ tagName: "li",
2037
+ className: `color-option${Ut ? " active" : ""}`,
2038
+ innerText: `${Q || F}`,
2039
+ tabIndex: 0,
2040
+ role: "option",
2041
+ ariaSelected: Ut ? "true" : "false"
2042
+ });
2043
+ m(xt, "data-value", `${F}`), l && D(xt, { backgroundColor: F }), E.append(xt);
2044
+ }), E;
2045
+ }, go = (o) => {
2046
+ const { input: t, parent: e, format: s, id: r, componentLabels: n, colorKeywords: i, colorPresets: a } = o, l = yt(t, "value") || "#fff", { nonColors: c } = y, { toggleLabel: h, pickerLabel: b, formatLabel: u, hexLabel: d } = n, g = c.includes(l) ? "#fff" : l;
2047
+ o.color = new y(g, s);
2048
+ const p = s === "hex" ? d : pe(s), f = x({
2049
+ id: `picker-btn-${r}`,
2050
+ tagName: "button",
2051
+ type: "button",
2052
+ className: "picker-toggle btn-appearance",
2053
+ ariaExpanded: "false",
2054
+ ariaHasPopup: "true"
2055
+ });
2056
+ f.append(
2057
+ x({
2058
+ tagName: "span",
2059
+ className: Vt,
2060
+ innerText: `${b}. ${u}: ${p}`
2061
+ })
2062
+ );
2063
+ const w = x({
2064
+ tagName: "div",
2065
+ className: "color-dropdown picker",
2066
+ role: "group",
2067
+ ariaLabelledBy: `picker-btn-${r}`
2068
+ }), $ = ho(o), S = co(o);
2069
+ if (w.append($, S), t.before(f), e.append(w), i || a) {
2070
+ const L = x({
2071
+ tagName: "div",
2072
+ className: "color-dropdown scrollable menu"
2073
+ });
2074
+ a && L.append(le(o, a, "color-options")), i && i.length && L.append(le(o, i, "color-defaults"));
2075
+ const P = x({
2076
+ tagName: "button",
2077
+ type: "button",
2078
+ className: "menu-toggle btn-appearance",
2079
+ tabIndex: -1,
2080
+ ariaExpanded: "false",
2081
+ ariaHasPopup: "true"
2082
+ }), C = encodeURI("http://www.w3.org/2000/svg"), M = Mt(C, {
2083
+ tagName: "svg"
2084
+ });
2085
+ m(M, "xmlns", C), m(M, "viewBox", "0 0 512 512"), m(M, Ee, "true");
2086
+ const E = Mt(C, {
2087
+ tagName: "path"
2088
+ });
2089
+ m(E, "d", "M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"), m(E, "fill", "#fff"), M.append(E), P.append(
2090
+ x({
2091
+ tagName: "span",
2092
+ className: Vt,
2093
+ innerText: `${h}`
2094
+ }),
2095
+ M
2096
+ ), e.append(P, L);
2097
+ }
2098
+ i && c.includes(l) && (o.value = l), m(t, X, "-1");
2099
+ }, uo = "2.0.0-alpha10", Z = "color-picker", bo = `[data-function="${Z}"]`, ce = `.${Z}`, po = {
2100
+ componentLabels: Kt,
2101
+ colorLabels: it,
2102
+ format: "rgb",
2103
+ colorPresets: !1,
2104
+ colorKeywords: !1
2105
+ }, { roundPart: k, nonColors: bt } = y, fo = (o) => Xe(o, Z), mo = (o) => new vo(o), he = (o, t) => {
2106
+ const e = t ? Bt : jt, { input: s, pickerToggle: r, menuToggle: n } = o;
2107
+ e(s, Re, o.showPicker), e(r, Et, o.togglePicker), n && e(n, Et, o.toggleMenu);
2108
+ }, He = (o, t) => {
2109
+ const e = t ? Bt : jt, { input: s, colorMenu: r, parent: n } = o, i = V(s), a = ro(i);
2110
+ e(o.controls, Fe, o.pointerDown), o.controlKnobs.forEach((l) => e(l, zt, o.handleKnobs)), e(a, Ve, o.handleScroll), e(a, Ke, o.update), [s, ...o.inputs].forEach((l) => e(l, Me, o.changeHandler)), r && (e(r, Et, o.menuClickHandler), e(r, zt, o.menuKeyHandler)), e(i, ue, o.pointerMove), e(i, Ie, o.pointerUp), e(n, Oe, o.handleFocusOut), e(i, De, o.handleDismiss);
2111
+ }, ge = (o) => {
2112
+ Ye(o.input, new CustomEvent("colorpicker.change"));
2113
+ }, Ne = (o) => {
2114
+ o && ["bottom", "top"].forEach((t) => O(o, t));
2115
+ }, Ht = (o, t) => {
2116
+ const { colorPicker: e, colorMenu: s, menuToggle: r, pickerToggle: n, parent: i } = o, a = t === e, l = a ? s : e, c = a ? r : n, h = a ? n : r;
2117
+ T(i, "open") || q(i, "open"), l && (O(l, "show"), Ne(l)), q(t, "bottom"), oo(t), q(t, "show"), a && o.update(), o.isOpen || (He(o, !0), o.updateDropdownPosition(), o.isOpen = !0, m(o.input, X, "0"), r && m(r, X, "0")), m(h, Nt, "true"), c && m(c, Nt, "false");
2118
+ };
2119
+ class vo {
2120
+ // bring utils to staic
2121
+ static Color = y;
2122
+ static ColorPalette = It;
2123
+ static getInstance = fo;
2124
+ static init = mo;
2125
+ static selector = bo;
2126
+ // utils important for render
2127
+ static roundPart = k;
2128
+ static setElementStyle = D;
2129
+ static setAttribute = m;
2130
+ static getBoundingClientRect = gt;
2131
+ static version = uo;
2132
+ static colorNames = it;
2133
+ static colorPickerLabels = Kt;
2134
+ id;
2135
+ input;
2136
+ color;
2137
+ format = "rgb";
2138
+ parent;
2139
+ dragElement;
2140
+ isOpen = !1;
2141
+ controlPositions;
2142
+ colorLabels = Yt(it.map((t) => [t, t]));
2143
+ colorKeywords;
2144
+ colorPresets;
2145
+ componentLabels;
2146
+ pickerToggle;
2147
+ menuToggle;
2148
+ colorPicker;
2149
+ colorMenu;
2150
+ controls;
2151
+ inputs;
2152
+ controlKnobs;
2153
+ visuals;
2154
+ /**
2155
+ * Returns a new `ColorPicker` instance. The target of this constructor
2156
+ * must be an `HTMLInputElement`.
2157
+ *
2158
+ * @param target the target `<input>` element
2159
+ * @param config instance options
2160
+ */
2161
+ constructor(t, e) {
2162
+ const s = z(t);
2163
+ if (typeof t > "u")
2164
+ throw new TypeError("ColorPicker target not specified.");
2165
+ if (B(t) && !s)
2166
+ throw new TypeError(`ColorPicker target "${t}" cannot be found.`);
2167
+ this.input = s;
2168
+ const r = fe(s, ce);
2169
+ if (!r)
2170
+ throw new TypeError("ColorPicker requires a specific markup to work.");
2171
+ this.parent = r, this.id = de(s, Z), this.dragElement = void 0, this.isOpen = !1, this.controlPositions = {
2172
+ c1x: 0,
2173
+ c1y: 0,
2174
+ c2y: 0,
2175
+ c3y: 0
2176
+ }, this.colorKeywords = !1, this.colorPresets = !1;
2177
+ const { format: n, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } = eo(
2178
+ s,
2179
+ po,
2180
+ e || {}
2181
+ );
2182
+ let h = it;
2183
+ Lt(a) && a.length === 17 ? h = a : B(a) && a.split(",").length === 17 && (h = a.split(",")), K(this.colorLabels, Yt(h.map((p, f) => [it[f], p])));
2184
+ const b = B(i) && ae(i) ? JSON.parse(i) : i;
2185
+ if (this.componentLabels = K({ ...Kt }, b), this.color = new y(s.value || "#fff", n), this.format = n, Lt(l) && l.length ? this.colorKeywords = l : B(l) && l.length && (this.colorKeywords = l.split(",").map((p) => p.trim())), Lt(c) && c.length)
2186
+ this.colorPresets = c;
2187
+ else if (c && ae(c)) {
2188
+ const { hue: p, hueSteps: f, lightSteps: w, saturation: $ } = JSON.parse(c);
2189
+ this.colorPresets = new It(p, f, w, $);
2190
+ } else
2191
+ B(c) && (this.colorPresets = c.split(",").map((p) => p.trim()));
2192
+ go(this);
2193
+ const [u, d] = st("color-dropdown", r);
2194
+ this.pickerToggle = z(".picker-toggle", r), this.menuToggle = z(".menu-toggle", r), this.colorPicker = u, this.colorMenu = d, this.inputs = [...st("color-input", r)];
2195
+ const [g] = st("color-controls", r);
2196
+ this.controls = g, this.controlKnobs = [...st("knob", g)], this.visuals = [...st("visual-control", g)], this.update(), he(this, !0), ct.set(s, Z, this);
2197
+ }
2198
+ /** Returns the current colour value */
2199
+ get value() {
2200
+ return this.input.value;
2201
+ }
2202
+ /**
2203
+ * Sets a new colour value.
2204
+ *
2205
+ * @param {string} v new colour value
2206
+ */
2207
+ set value(t) {
2208
+ this.input.value = t;
2209
+ }
2210
+ /** Check if the colour presets include any non-colour. */
2211
+ get hasNonColor() {
2212
+ return this.colorKeywords instanceof Array && this.colorKeywords.some((t) => bt.includes(t));
2213
+ }
2214
+ /** Returns hexadecimal value of the current colour. */
2215
+ get hex() {
2216
+ return this.color.toHex(!0);
2217
+ }
2218
+ /** Returns the current colour value in {h,s,v,a} object format. */
2219
+ get hsv() {
2220
+ return this.color.toHsv();
2221
+ }
2222
+ /** Returns the current colour value in {h,s,l,a} object format. */
2223
+ get hsl() {
2224
+ return this.color.toHsl();
2225
+ }
2226
+ /** Returns the current colour value in {h,w,b,a} object format. */
2227
+ get hwb() {
2228
+ return this.color.toHwb();
2229
+ }
2230
+ /** Returns the current colour value in {r,g,b,a} object format. */
2231
+ get rgb() {
2232
+ return this.color.toRgb();
2233
+ }
2234
+ /** Returns the current colour brightness. */
2235
+ get brightness() {
2236
+ return this.color.brightness;
2237
+ }
2238
+ /** Returns the current colour luminance. */
2239
+ get luminance() {
2240
+ return this.color.luminance;
2241
+ }
2242
+ /** Checks if the current colour requires a light text colour. */
2243
+ get isDark() {
2244
+ const { color: t, brightness: e } = this;
2245
+ return e < 120 && t.a > 0.33;
2246
+ }
2247
+ /** Checks if the current input value is a valid colour. */
2248
+ get isValid() {
2249
+ const t = this.input.value;
2250
+ return t !== "" && new y(t).isValid;
2251
+ }
2252
+ /** Returns the colour appearance, usually the closest colour name for the current value. */
2253
+ get appearance() {
2254
+ const { colorLabels: t, hsl: e, hsv: s, format: r } = this, n = k(e.h * 360), i = r === "hsl" ? e.s : s.s, a = k(i * 100), l = k(e.l * 100), c = s.v * 100;
2255
+ let h = "black";
2256
+ if (l === 100 && a === 0)
2257
+ h = t.white;
2258
+ else if (l === 0)
2259
+ h = t.black;
2260
+ else if (a === 0)
2261
+ h = t.grey;
2262
+ else if (n < 15 || n >= 345)
2263
+ h = t.red;
2264
+ else if (n >= 15 && n < 45)
2265
+ h = c > 80 && a > 80 ? t.orange : t.brown;
2266
+ else if (n >= 45 && n < 75) {
2267
+ const b = n > 46 && n < 54 && c < 80 && a > 90, u = n >= 54 && n < 75 && c < 80;
2268
+ h = b ? t.gold : t.yellow, h = u ? t.olive : h;
2269
+ } else
2270
+ n >= 75 && n < 155 ? h = c < 68 ? t.green : t.lime : n >= 155 && n < 175 ? h = t.teal : n >= 175 && n < 195 ? h = t.cyan : n >= 195 && n < 255 ? h = t.blue : n >= 255 && n < 270 ? h = t.violet : n >= 270 && n < 295 ? h = t.magenta : n >= 295 && n < 345 && (h = t.pink);
2271
+ return h;
2272
+ }
2273
+ /** Updates `ColorPicker` visuals. */
2274
+ updateVisuals() {
2275
+ const { controlPositions: t, visuals: e } = this, [s, r, n] = e, { offsetHeight: i } = s, a = t.c2y / i, { r: l, g: c, b: h } = new y({ h: a, s: 1, l: 0.5 }).toRgb(), b = "linear-gradient(rgb(255,255,255) 0%, rgb(255,255,255) 100%)", u = 1 - t.c3y / i, d = k(u * 100) / 100, g = new y({
2276
+ h: a,
2277
+ s: 1,
2278
+ l: 0.5,
2279
+ a: u
2280
+ }).toRgbString(), p = `linear-gradient(
2281
+ rgb(255,0,0) 0%, rgb(255,255,0) 16.67%,
2282
+ rgb(0,255,0) 33.33%, rgb(0,255,255) 50%,
2283
+ rgb(0,0,255) 66.67%, rgb(255,0,255) 83.33%,
2284
+ rgb(255,0,0) 100%)`;
2285
+ D(s, {
2286
+ background: `linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,${d}) 100%),
2287
+ linear-gradient(to right, rgba(255,255,255,${d}) 0%, ${g} 100%),
2288
+ ${b}`
2289
+ }), D(r, { background: p }), D(n, {
2290
+ background: `linear-gradient(rgba(${l},${c},${h},1) 0%,rgba(${l},${c},${h},0) 100%)`
2291
+ });
2292
+ }
2293
+ /**
2294
+ * The `ColorPicker` *focusout* event listener when open.
2295
+ *
2296
+ * @param e
2297
+ * @this {ColorPicker}
2298
+ */
2299
+ handleFocusOut = ({ relatedTarget: t }) => {
2300
+ t && !this.parent.contains(t) && this.hide(!0);
2301
+ };
2302
+ /**
2303
+ * The `ColorPicker` *keyup* event listener when open.
2304
+ *
2305
+ * @param e
2306
+ * @this {ColorPicker}
2307
+ */
2308
+ handleDismiss = ({ code: t }) => {
2309
+ this.isOpen && t === qe && this.hide();
2310
+ };
2311
+ /**
2312
+ * The `ColorPicker` *scroll* event listener when open.
2313
+ *
2314
+ * @param e
2315
+ */
2316
+ handleScroll = (t) => {
2317
+ const { activeElement: e } = V(this.input);
2318
+ this.updateDropdownPosition(), ([ue, Be].includes(t.type) && this.dragElement || e && this.controlKnobs.includes(e)) && (t.stopPropagation(), t.preventDefault());
2319
+ };
2320
+ /**
2321
+ * The `ColorPicker` keyboard event listener for menu navigation.
2322
+ *
2323
+ * @param e
2324
+ */
2325
+ menuKeyHandler = (t) => {
2326
+ const { target: e, code: s } = t, { previousElementSibling: r, nextElementSibling: n, parentElement: i } = e, a = i && T(i, "color-options"), l = i ? [...i.children] : [], c = a && Tt(i, "grid-template-columns").split(" ").length, h = l.indexOf(e), b = h > -1 && c && l[h - c], u = h > -1 && c && l[h + c];
2327
+ [j, ot, Wt].includes(s) && t.preventDefault(), a ? b && s === ot ? _(b) : u && s === j ? _(u) : r && s === ht ? _(r) : n && s === U && _(n) : r && [ht, ot].includes(s) ? _(r) : n && [U, j].includes(s) && _(n), [je, Wt].includes(s) && this.menuClickHandler(t);
2328
+ };
2329
+ /**
2330
+ * The `ColorPicker` click event listener for the colour menu presets / defaults.
2331
+ *
2332
+ * @param e
2333
+ * @this {ColorPicker}
2334
+ */
2335
+ menuClickHandler = (t) => {
2336
+ const { target: e } = t, { colorMenu: s } = this, r = (yt(e, "data-value") || "").trim();
2337
+ if (!r.length)
2338
+ return;
2339
+ const n = z("li.active", s);
2340
+ let i = r;
2341
+ i = bt.includes(i) ? "white" : i, i = i === "transparent" ? "rgba(0,0,0,0)" : i;
2342
+ const { r: a, g: l, b: c, a: h } = new y(i);
2343
+ K(this.color, {
2344
+ r: a,
2345
+ g: l,
2346
+ b: c,
2347
+ a: h
2348
+ }), this.update(), n !== e && (n && (O(n, "active"), Pt(n, St)), q(e, "active"), m(e, St, "true"), bt.includes(r) && (this.value = r), ge(this));
2349
+ };
2350
+ /**
2351
+ * The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
2352
+ *
2353
+ * @param e
2354
+ */
2355
+ pointerDown = (t) => {
2356
+ if (t.button !== 0)
2357
+ return;
2358
+ const { target: e, pageX: s, pageY: r } = t, { colorMenu: n, visuals: i, controlKnobs: a } = this, [l, c, h] = i, [b, u, d] = a, g = a.includes(e) ? e.previousElementSibling : e, p = gt(g), f = Ct(l), w = s - f.scrollLeft - p.left, $ = r - f.scrollTop - p.top;
2359
+ if (e === l || e === b ? (this.dragElement = g, this.changeControl1(w, $)) : e === c || e === u ? (this.dragElement = g, this.changeControl2($)) : (e === h || e === d) && (this.dragElement = g, this.changeAlpha($)), n) {
2360
+ const S = z("li.active", n);
2361
+ S && (O(S, "active"), Pt(S, St));
2362
+ }
2363
+ t.preventDefault();
2364
+ };
2365
+ /**
2366
+ * The `ColorPicker` *touchend* / *mouseup* events listener for control knobs.
2367
+ *
2368
+ * @param e
2369
+ * @this
2370
+ */
2371
+ pointerUp = ({ target: t }) => {
2372
+ const { parent: e } = this, s = V(e), r = z(`${ce}.open`, s) !== null, n = s.getSelection();
2373
+ !this.dragElement && (!n || !n.toString().length) && !e.contains(t) && this.hide(r), this.dragElement = void 0;
2374
+ };
2375
+ /**
2376
+ * The `ColorPicker` *touchmove* / *mousemove* events listener for control knobs.
2377
+ *
2378
+ * @param {PointerEvent} e
2379
+ */
2380
+ pointerMove = (t) => {
2381
+ const { dragElement: e, visuals: s } = this, [r, n, i] = s, { pageX: a, pageY: l } = t;
2382
+ if (!e)
2383
+ return;
2384
+ const c = gt(e), h = Ct(r), b = a - h.scrollLeft - c.left, u = l - h.scrollTop - c.top;
2385
+ e === r && this.changeControl1(b, u), e === n && this.changeControl2(u), e === i && this.changeAlpha(u);
2386
+ };
2387
+ /**
2388
+ * The `ColorPicker` *keydown* event listener for control knobs.
2389
+ *
2390
+ * @param e
2391
+ */
2392
+ handleKnobs = (t) => {
2393
+ const { target: e, code: s } = t;
2394
+ if (![ot, j, ht, U].includes(s))
2395
+ return;
2396
+ t.preventDefault();
2397
+ const { controlKnobs: r, visuals: n } = this, { offsetWidth: i, offsetHeight: a } = n[0], [l, c, h] = r, { activeElement: b } = V(l), u = r.find((g) => g === b), d = a / 360;
2398
+ if (u) {
2399
+ let g = 0, p = 0;
2400
+ if (e === l) {
2401
+ const f = i / 100;
2402
+ [ht, U].includes(s) ? this.controlPositions.c1x += s === U ? f : -f : [ot, j].includes(s) && (this.controlPositions.c1y += s === j ? d : -d), g = this.controlPositions.c1x, p = this.controlPositions.c1y, this.changeControl1(g, p);
2403
+ } else
2404
+ e === c ? (this.controlPositions.c2y += [j, U].includes(s) ? d : -d, p = this.controlPositions.c2y, this.changeControl2(p)) : e === h && (this.controlPositions.c3y += [j, U].includes(s) ? d : -d, p = this.controlPositions.c3y, this.changeAlpha(p));
2405
+ this.handleScroll(t);
2406
+ }
2407
+ };
2408
+ /** The event listener of the colour form inputs. */
2409
+ changeHandler = () => {
2410
+ let t;
2411
+ const { inputs: e, format: s, value: r, input: n, controlPositions: i, visuals: a } = this, { activeElement: l } = V(n), { offsetHeight: c } = a[0], [h, , , b] = e, [u, d, g, p] = s === "rgb" ? e.map(($) => parseFloat($.value) / ($ === b ? 100 : 1)) : e.map(($) => parseFloat($.value) / ($ !== h ? 100 : 360)), f = this.hasNonColor && bt.includes(r), w = b ? p : 1 - i.c3y / c;
2412
+ if (l === n || l && e.includes(l)) {
2413
+ l === n ? f ? t = r === "transparent" ? "rgba(0,0,0,0)" : "rgb(0,0,0)" : t = r : s === "hex" ? t = h.value : s === "hsl" ? t = {
2414
+ h: u,
2415
+ s: d,
2416
+ l: g,
2417
+ a: w
2418
+ } : s === "hwb" ? t = {
2419
+ h: u,
2420
+ w: d,
2421
+ b: g,
2422
+ a: w
2423
+ } : t = {
2424
+ r: u,
2425
+ g: d,
2426
+ b: g,
2427
+ a: w
2428
+ };
2429
+ const { r: $, g: S, b: L, a: P } = new y(t);
2430
+ K(this.color, {
2431
+ r: $,
2432
+ g: S,
2433
+ b: L,
2434
+ a: P
2435
+ }), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === n && f && (this.value = r);
2436
+ }
2437
+ };
2438
+ /**
2439
+ * Updates `ColorPicker` first control:
2440
+ * * `lightness` and `saturation` for HEX/RGB;
2441
+ * * `lightness` and `hue` for HSL.
2442
+ *
2443
+ * @param X the X component of the offset
2444
+ * @param Y the Y component of the offset
2445
+ */
2446
+ changeControl1(t, e) {
2447
+ let [s, r] = [0, 0];
2448
+ const { controlPositions: n, visuals: i } = this, { offsetHeight: a, offsetWidth: l } = i[0];
2449
+ t > l ? s = l : t >= 0 && (s = t), e > a ? r = a : e >= 0 && (r = e);
2450
+ const c = n.c2y / a, h = s / l, b = 1 - r / a, u = 1 - n.c3y / a, { r: d, g, b: p, a: f } = new y({
2451
+ h: c,
2452
+ s: h,
2453
+ v: b,
2454
+ a: u
2455
+ });
2456
+ K(this.color, {
2457
+ r: d,
2458
+ g,
2459
+ b: p,
2460
+ a: f
2461
+ }), this.controlPositions.c1x = s, this.controlPositions.c1y = r, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2462
+ }
2463
+ /**
2464
+ * Updates `ColorPicker` second control:
2465
+ * * `hue` for HEX/RGB/HWB;
2466
+ * * `saturation` for HSL.
2467
+ *
2468
+ * @param Y the Y offset
2469
+ */
2470
+ changeControl2(t) {
2471
+ const { controlPositions: e, visuals: s } = this, { offsetHeight: r, offsetWidth: n } = s[0];
2472
+ let i = 0;
2473
+ t > r ? i = r : t >= 0 && (i = t);
2474
+ const a = i / r, l = e.c1x / n, c = 1 - e.c1y / r, h = 1 - e.c3y / r, { r: b, g: u, b: d, a: g } = new y({
2475
+ h: a,
2476
+ s: l,
2477
+ v: c,
2478
+ a: h
2479
+ });
2480
+ K(this.color, {
2481
+ r: b,
2482
+ g: u,
2483
+ b: d,
2484
+ a: g
2485
+ }), this.controlPositions.c2y = i, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2486
+ }
2487
+ /**
2488
+ * Updates `ColorPicker` last control,
2489
+ * the `alpha` channel.
2490
+ *
2491
+ * @param Y
2492
+ */
2493
+ changeAlpha(t) {
2494
+ const { visuals: e } = this, { offsetHeight: s } = e[0];
2495
+ let r = 0;
2496
+ t > s ? r = s : t >= 0 && (r = t);
2497
+ const n = 1 - r / s;
2498
+ this.color.setAlpha(n), this.controlPositions.c3y = r, this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals();
2499
+ }
2500
+ /**
2501
+ * Updates `ColorPicker` control positions on:
2502
+ * * initialization
2503
+ * * window resize
2504
+ */
2505
+ update = () => {
2506
+ this.updateDropdownPosition(), this.updateAppearance(), this.setControlPositions(), this.updateInputs(!0), this.updateControls(), this.updateVisuals();
2507
+ };
2508
+ /** Updates the open dropdown position on *scroll* event. */
2509
+ updateDropdownPosition() {
2510
+ const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l = Ct(t).clientHeight, h = T(e, "show") ? e : s;
2511
+ if (!h)
2512
+ return;
2513
+ const { offsetHeight: b } = h, u = l - i, d = n, g = n + b + a > l, p = n - b < 0;
2514
+ (T(h, "bottom") || !p) && u < d && g ? (O(h, "bottom"), q(h, "top")) : (O(h, "top"), q(h, "bottom"));
2515
+ }
2516
+ /** Updates control knobs' positions. */
2517
+ setControlPositions() {
2518
+ const { visuals: t, color: e, hsv: s } = this, { offsetHeight: r, offsetWidth: n } = t[0], i = e.a, a = s.h, l = s.s, c = s.v;
2519
+ this.controlPositions.c1x = l * n, this.controlPositions.c1y = (1 - c) * r, this.controlPositions.c2y = a * r, this.controlPositions.c3y = (1 - i) * r;
2520
+ }
2521
+ /** Update the visual appearance label and control knob labels. */
2522
+ updateAppearance() {
2523
+ const { componentLabels: t, color: e, parent: s, hsv: r, hex: n, format: i, controlKnobs: a } = this, { appearanceLabel: l, hexLabel: c, valueLabel: h } = t;
2524
+ let { r: b, g: u, b: d } = e.toRgb();
2525
+ const [g, p, f] = a, w = k(r.h * 360), $ = e.a, S = k(r.s * 100), L = k(r.v * 100), P = this.appearance;
2526
+ let C = `${c} ${n.split("").join(" ")}`;
2527
+ if (i === "hwb") {
2528
+ const { hwb: A } = this, F = k(A.w * 100), Q = k(A.b * 100);
2529
+ C = `HWB: ${w}°, ${F}%, ${Q}%`, m(g, et, `${F}% & ${Q}%`), m(g, tt, `${F}`), m(p, _t, `${h}: ${C}. ${l}: ${P}.`), m(p, et, `${w}%`), m(p, tt, `${w}`);
2530
+ } else
2531
+ [b, u, d] = [b, u, d].map(k), C = i === "hsl" ? `HSL: ${w}°, ${S}%, ${L}%` : C, C = i === "rgb" ? `RGB: ${b}, ${u}, ${d}` : C, m(g, et, `${L}% & ${S}%`), m(g, tt, `${L}`), m(p, _t, `${h}: ${C}. ${l}: ${P}.`), m(p, et, `${w}°`), m(p, tt, `${w}`);
2532
+ const M = k($ * 100);
2533
+ m(f, et, `${M}%`), m(f, tt, `${M}`);
2534
+ const E = e.toString();
2535
+ D(this.input, { backgroundColor: E }), this.isDark ? (T(s, "txt-light") && O(s, "txt-light"), T(s, "txt-dark") || q(s, "txt-dark")) : (T(s, "txt-dark") && O(s, "txt-dark"), T(s, "txt-light") || q(s, "txt-light"));
2536
+ }
2537
+ /** Updates the control knobs actual positions. */
2538
+ updateControls() {
2539
+ const { controlKnobs: t, controlPositions: e } = this;
2540
+ let { c1x: s, c1y: r, c2y: n, c3y: i } = e;
2541
+ const [a, l, c] = t;
2542
+ [s, r, n, i] = [s, r, n, i].map(k), D(a, {
2543
+ transform: `translate3d(${s - 4}px,${r - 4}px,0)`
2544
+ }), D(l, { transform: `translate3d(0,${n - 4}px,0)` }), D(c, { transform: `translate3d(0,${i - 4}px,0)` });
2545
+ }
2546
+ /**
2547
+ * Updates all color form inputs.
2548
+ *
2549
+ * @param isPrevented when `true`, the component original event is prevented
2550
+ */
2551
+ updateInputs(t) {
2552
+ const { value: e, format: s, inputs: r, color: n, hsl: i } = this, [a, l, c, h] = r, b = k(n.a * 100), u = k(i.h * 360);
2553
+ let d = n.toString();
2554
+ if (s === "hex")
2555
+ d = this.color.toHexString(!0), a.value = this.hex;
2556
+ else if (s === "hsl") {
2557
+ const g = k(i.l * 100), p = k(i.s * 100);
2558
+ d = this.color.toHslString(), a.value = `${u}`, l.value = `${p}`, c.value = `${g}`, h.value = `${b}`;
2559
+ } else if (s === "hwb") {
2560
+ const { w: g, b: p } = this.hwb, f = k(g * 100), w = k(p * 100);
2561
+ d = this.color.toHwbString(), a.value = `${u}`, l.value = `${f}`, c.value = `${w}`, h.value = `${b}`;
2562
+ } else if (s === "rgb") {
2563
+ let { r: g, g: p, b: f } = this.rgb;
2564
+ [g, p, f] = [g, p, f].map(k), d = this.color.toRgbString(), a.value = `${g}`, l.value = `${p}`, c.value = `${f}`, h.value = `${b}`;
2565
+ }
2566
+ this.value = d, !t && d !== e && ge(this);
2567
+ }
2568
+ /**
2569
+ * Toggle the `ColorPicker` dropdown visibility.
2570
+ *
2571
+ * @param e
2572
+ */
2573
+ togglePicker = (t) => {
2574
+ t && t.preventDefault();
2575
+ const { colorPicker: e } = this;
2576
+ this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
2577
+ };
2578
+ /** Shows the `ColorPicker` dropdown. */
2579
+ showPicker = () => {
2580
+ const { colorPicker: t } = this;
2581
+ ["top", "bottom"].some((e) => T(t, e)) || Ht(this, t);
2582
+ };
2583
+ /**
2584
+ * Toggles the visibility of the `ColorPicker` presets menu.
2585
+ *
2586
+ * @param e
2587
+ * @this {ColorPicker}
2588
+ */
2589
+ toggleMenu = (t) => {
2590
+ t && t.preventDefault();
2591
+ const { colorMenu: e } = this;
2592
+ this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
2593
+ };
2594
+ /**
2595
+ * Hides the currently open `ColorPicker` dropdown.
2596
+ *
2597
+ * @param {boolean=} focusPrevented
2598
+ */
2599
+ hide(t) {
2600
+ if (this.isOpen) {
2601
+ const { pickerToggle: e, menuToggle: s, colorPicker: r, colorMenu: n, parent: i, input: a } = this, l = T(r, "show"), c = l ? r : n, h = l ? e : s, b = c && Qe(c);
2602
+ this.value = this.color.toString(!0), c && (O(c, "show"), m(h, Nt, "false"), setTimeout(() => {
2603
+ Ne(c), z(".show", i) || (O(i, "open"), He(this), this.isOpen = !1);
2604
+ }, b)), t || _(e), m(a, X, "-1"), h === s && m(s, X, "-1");
2605
+ }
2606
+ }
2607
+ /** Removes `ColorPicker` from target `<input>`. */
2608
+ dispose() {
2609
+ const { input: t, parent: e } = this;
2610
+ this.hide(!0), he(this), [...e.children].forEach((s) => {
2611
+ s !== t && s.remove();
2612
+ }), Pt(t, X), D(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => O(e, s)), ct.remove(t, Z);
2613
+ }
2614
+ }
2615
+ export {
2616
+ vo as default
2617
+ };
2618
+ //# sourceMappingURL=color-picker.mjs.map