@nl-design-system-community/clippy-components 1.0.0 → 1.2.0

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.
Files changed (61) hide show
  1. package/dist/clippy-button/index.d.ts +25 -0
  2. package/dist/clippy-button/index.d.ts.map +1 -0
  3. package/dist/clippy-button/index.js +9 -0
  4. package/dist/clippy-code/index.d.ts +13 -0
  5. package/dist/clippy-code/index.d.ts.map +1 -0
  6. package/dist/clippy-code/index.js +21 -0
  7. package/dist/clippy-color-combobox/index.d.ts +46 -0
  8. package/dist/clippy-color-combobox/index.d.ts.map +1 -0
  9. package/dist/clippy-color-combobox/index.js +10 -0
  10. package/dist/clippy-color-combobox/lib.d.ts +19 -0
  11. package/dist/clippy-color-combobox/lib.d.ts.map +1 -0
  12. package/dist/clippy-color-combobox/messages/en.d.ts +10 -0
  13. package/dist/clippy-color-combobox/messages/en.d.ts.map +1 -0
  14. package/dist/clippy-color-combobox/messages/nl.d.ts +10 -0
  15. package/dist/clippy-color-combobox/messages/nl.d.ts.map +1 -0
  16. package/dist/clippy-combobox/index.d.ts +17 -23
  17. package/dist/clippy-combobox/index.d.ts.map +1 -0
  18. package/dist/clippy-combobox/index.js +8 -315
  19. package/dist/clippy-font-combobox/external.d.ts +3 -6
  20. package/dist/clippy-font-combobox/external.d.ts.map +1 -0
  21. package/dist/clippy-font-combobox/index.d.ts +9 -3
  22. package/dist/clippy-font-combobox/index.d.ts.map +1 -0
  23. package/dist/clippy-font-combobox/index.js +56 -34
  24. package/dist/clippy-heading/index.d.ts +14 -0
  25. package/dist/clippy-heading/index.d.ts.map +1 -0
  26. package/dist/clippy-heading/index.js +262 -0
  27. package/dist/clippy-html-image/index.d.ts +1 -0
  28. package/dist/clippy-html-image/index.d.ts.map +1 -0
  29. package/dist/clippy-html-image/index.js +11 -8
  30. package/dist/clippy-icon/index.d.ts +26 -0
  31. package/dist/clippy-icon/index.d.ts.map +1 -0
  32. package/dist/clippy-icon/index.js +40 -0
  33. package/dist/clippy-lang-combobox/index.d.ts +43 -0
  34. package/dist/clippy-lang-combobox/index.d.ts.map +1 -0
  35. package/dist/clippy-lang-combobox/index.js +290 -0
  36. package/dist/clippy-lang-combobox/languages.d.ts +202 -0
  37. package/dist/clippy-lang-combobox/languages.d.ts.map +1 -0
  38. package/dist/clippy-modal/index.d.ts +1 -0
  39. package/dist/clippy-modal/index.d.ts.map +1 -0
  40. package/dist/clippy-modal/index.js +85 -69
  41. package/dist/decorators-BGpMqJ7V.js +7 -0
  42. package/dist/en-B-D8DBsf.js +4 -0
  43. package/dist/external-Dtf6f6DP.js +4 -0
  44. package/dist/index-CT1z3SFL.js +106 -0
  45. package/dist/index-CaVpiaBC.js +52 -0
  46. package/dist/index-CmKtM5nD.js +379 -0
  47. package/dist/index-CtreqNZ6.js +3602 -0
  48. package/dist/index-D3FiqptQ.js +65 -0
  49. package/dist/lib/FormElement/index.d.ts +17 -0
  50. package/dist/lib/FormElement/index.d.ts.map +1 -0
  51. package/dist/lib/LocalizationMixin/index.d.ts +29 -0
  52. package/dist/lib/LocalizationMixin/index.d.ts.map +1 -0
  53. package/dist/lib/converters/index.d.ts +6 -0
  54. package/dist/lib/converters/index.d.ts.map +1 -0
  55. package/dist/lib/decorators.d.ts +12 -0
  56. package/dist/lib/decorators.d.ts.map +1 -0
  57. package/dist/nl-CJG2-yS5.js +11 -0
  58. package/package.json +13 -7
  59. package/dist/clippy-font-combobox/google-fonts.json.d.ts +0 -33283
  60. package/dist/external-lwd0iv80.js +0 -8
  61. package/dist/index.d.ts +0 -0
@@ -0,0 +1,3602 @@
1
+ import { s as Er } from "./decorators-BGpMqJ7V.js";
2
+ import { L as kr } from "./index-CaVpiaBC.js";
3
+ import { css as $r, html as Ar, unsafeCSS as Or } from "lit";
4
+ import { property as Pr } from "lit/decorators.js";
5
+ import { styleMap as Ir } from "lit/directives/style-map.js";
6
+ import { C as Y0 } from "./index-CmKtM5nD.js";
7
+ const Hr = (t, e, r) => {
8
+ const n = t[e];
9
+ return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((a, s) => {
10
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(s.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== r ? ". Note that variables only represent file names one level deep." : ""))));
11
+ });
12
+ }, jr = ".nl-color-sample{background-image:repeating-conic-gradient(var(--nl-color-sample-background-color, hsl(0, 0%, 90%)) 0% 25%,#fff 0% 50%);background-size:.5rem .5rem;block-size:var(--nl-color-sample-block-size);border-color:var(--nl-color-sample-border-color);border-radius:var(--nl-color-sample-border-radius);border-style:solid;border-width:var(--nl-color-sample-border-width);display:inline-block;forced-color-adjust:none;inline-size:var(--nl-color-sample-inline-size);pointer-events:none}";
13
+ function _e(t, e) {
14
+ let r = t.length, n, a, s = !1, i = !1;
15
+ Array.isArray(t[0]) ? n = /** @type {number[][]} */
16
+ t : (n = [
17
+ /** @type {number[]} */
18
+ t
19
+ ], r = n.length, s = !0), Array.isArray(e[0]) ? a = /** @type {number[][]} */
20
+ e : (a = e.length > 0 ? e.map((f) => [f]) : [[]], i = !0);
21
+ let o = a[0].length, l = a[0].map((f, u) => a.map((h) => h[u])), c = n.map((f) => l.map((u) => {
22
+ let h = 0;
23
+ if (!Array.isArray(f)) {
24
+ for (let m of u)
25
+ h += f * m;
26
+ return h;
27
+ }
28
+ for (let m = 0; m < f.length; m++)
29
+ h += f[m] * (u[m] || 0);
30
+ return h;
31
+ }));
32
+ return r === 1 && s && (c = c[0]), o === 1 && i ? r === 1 && s ? c[0] : c.map((f) => f[0]) : c;
33
+ }
34
+ function lt(t, e) {
35
+ return t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
36
+ }
37
+ function x(t, e, r = [0, 0, 0]) {
38
+ const n = lt(t, e[0]), a = lt(t, e[1]), s = lt(t, e[2]);
39
+ return r[0] = n, r[1] = a, r[2] = s, r;
40
+ }
41
+ function ye(t) {
42
+ return K(t) === "string";
43
+ }
44
+ function K(t) {
45
+ return (Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1] || "").toLowerCase();
46
+ }
47
+ function Et(t, { precision: e = 16, unit: r }) {
48
+ return L(t) ? "none" : (t = +kt(t, e), t + (r ?? ""));
49
+ }
50
+ function L(t) {
51
+ return t === null;
52
+ }
53
+ function z(t) {
54
+ return L(t) ? 0 : t;
55
+ }
56
+ function kt(t, e) {
57
+ if (t === 0)
58
+ return 0;
59
+ let r = ~~t, n = 0;
60
+ r && e && (n = ~~Math.log10(Math.abs(r)) + 1);
61
+ const a = 10 ** (e - n);
62
+ return Math.floor(t * a + 0.5) / a;
63
+ }
64
+ function Be(t, e, r) {
65
+ return isNaN(t) ? e : isNaN(e) ? t : t + (e - t) * r;
66
+ }
67
+ function N0(t, e, r) {
68
+ return (r - t) / (e - t);
69
+ }
70
+ function Ct(t, e, r) {
71
+ return !t || !e || t === e || t[0] === e[0] && t[1] === e[1] || isNaN(r) || r === null ? r : Be(e[0], e[1], N0(t[0], t[1], r));
72
+ }
73
+ function et(t, e, r) {
74
+ return Math.max(Math.min(r, e), t);
75
+ }
76
+ function tt(t, e) {
77
+ return Math.sign(t) === Math.sign(e) ? t : -t;
78
+ }
79
+ function E(t, e) {
80
+ return tt(Math.abs(t) ** e, t);
81
+ }
82
+ function $t(t, e) {
83
+ return e === 0 ? 0 : t / e;
84
+ }
85
+ function q0(t, e, r = 0, n = t.length) {
86
+ for (; r < n; ) {
87
+ const a = r + n >> 1;
88
+ t[a] < e ? r = a + 1 : n = a;
89
+ }
90
+ return r;
91
+ }
92
+ function ge(t, e) {
93
+ if (t instanceof e)
94
+ return !0;
95
+ const r = e.name;
96
+ for (; t; ) {
97
+ const n = Object.getPrototypeOf(t), a = n?.constructor?.name;
98
+ if (a === r)
99
+ return !0;
100
+ if (!a || a === "Object")
101
+ return !1;
102
+ t = n;
103
+ }
104
+ return !1;
105
+ }
106
+ var Dr = /* @__PURE__ */ Object.freeze({
107
+ __proto__: null,
108
+ bisectLeft: q0,
109
+ clamp: et,
110
+ copySign: tt,
111
+ interpolate: Be,
112
+ interpolateInv: N0,
113
+ isInstance: ge,
114
+ isNone: L,
115
+ isString: ye,
116
+ mapRange: Ct,
117
+ multiplyMatrices: _e,
118
+ multiply_v3_m3x3: x,
119
+ serializeNumber: Et,
120
+ skipNone: z,
121
+ spow: E,
122
+ toPrecision: kt,
123
+ type: K,
124
+ zdiv: $t
125
+ });
126
+ class Tr {
127
+ add(e, r, n) {
128
+ if (typeof arguments[0] != "string") {
129
+ for (var e in arguments[0])
130
+ this.add(e, arguments[0][e], arguments[1]);
131
+ return;
132
+ }
133
+ (Array.isArray(e) ? e : [e]).forEach(function(a) {
134
+ this[a] = this[a] || [], r && this[a][n ? "unshift" : "push"](r);
135
+ }, this);
136
+ }
137
+ run(e, r) {
138
+ this[e] = this[e] || [], this[e].forEach(function(n) {
139
+ n.call(r && r.context ? r.context : r, r);
140
+ });
141
+ }
142
+ }
143
+ const te = new Tr();
144
+ var N = {
145
+ gamut_mapping: "css",
146
+ precision: 5,
147
+ deltaE: "76",
148
+ // Default deltaE method
149
+ verbose: globalThis?.process?.env?.NODE_ENV?.toLowerCase() !== "test",
150
+ warn: function(e) {
151
+ this.verbose && globalThis?.console?.warn?.(e);
152
+ }
153
+ };
154
+ class Xt {
155
+ // Class properties - declared here so that type inference works
156
+ type;
157
+ coordMeta;
158
+ coordRange;
159
+ /** @type {[number, number]} */
160
+ range;
161
+ /**
162
+ * @param {any} type
163
+ * @param {import("./types.js").CoordMeta} coordMeta
164
+ */
165
+ constructor(e, r) {
166
+ if (typeof e == "object" && (this.coordMeta = e), r && (this.coordMeta = r, this.coordRange = r.range ?? r.refRange), typeof e == "string") {
167
+ let n = e.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);
168
+ if (!n)
169
+ throw new TypeError(`Cannot parse ${e} as a type definition.`);
170
+ this.type = n.groups.type;
171
+ let { min: a, max: s } = n.groups;
172
+ (a || s) && (this.range = [+a, +s]);
173
+ }
174
+ }
175
+ /** @returns {[number, number]} */
176
+ get computedRange() {
177
+ return this.range ? this.range : this.type === "<percentage>" ? this.percentageRange() : this.type === "<angle>" ? [0, 360] : null;
178
+ }
179
+ get unit() {
180
+ return this.type === "<percentage>" ? "%" : this.type === "<angle>" ? "deg" : "";
181
+ }
182
+ /**
183
+ * Map a number to the internal representation
184
+ * @param {number} number
185
+ */
186
+ resolve(e) {
187
+ if (this.type === "<angle>")
188
+ return e;
189
+ let r = this.computedRange, n = this.coordRange;
190
+ return this.type === "<percentage>" && (n ??= this.percentageRange()), Ct(r, n, e);
191
+ }
192
+ /**
193
+ * Serialize a number from the internal representation to a string
194
+ * @param {number} number
195
+ * @param {number} [precision]
196
+ */
197
+ serialize(e, r) {
198
+ let n = this.type === "<percentage>" ? this.percentageRange(100) : this.computedRange, a = this.unit;
199
+ return e = Ct(this.coordRange, n, e), Et(e, { unit: a, precision: r });
200
+ }
201
+ toString() {
202
+ let e = this.type;
203
+ if (this.range) {
204
+ let [r = "", n = ""] = this.range;
205
+ e += `[${r},${n}]`;
206
+ }
207
+ return e;
208
+ }
209
+ /**
210
+ * Returns a percentage range for values of this type
211
+ * @param {number} scale
212
+ * @returns {[number, number]}
213
+ */
214
+ percentageRange(e = 1) {
215
+ let r;
216
+ return this.coordMeta && this.coordMeta.range || this.coordRange && this.coordRange[0] >= 0 ? r = [0, 1] : r = [-1, 1], [r[0] * e, r[1] * e];
217
+ }
218
+ static get(e, r) {
219
+ return ge(e, this) ? e : new this(e, r);
220
+ }
221
+ }
222
+ const ct = /* @__PURE__ */ Symbol("instance");
223
+ class Ze {
224
+ // Class properties - declared here so that type inference works
225
+ type;
226
+ name;
227
+ spaceCoords;
228
+ /** @type {Type[][]} */
229
+ coords;
230
+ /** @type {string | undefined} */
231
+ id;
232
+ /** @type {boolean | undefined} */
233
+ alpha;
234
+ /**
235
+ * @param {FormatInterface} format
236
+ * @param {ColorSpace} space
237
+ */
238
+ constructor(e, r = e.space) {
239
+ e[ct] = this, this.type = "function", this.name = "color", Object.assign(this, e), this.space = r, this.type !== "custom" && (this.spaceCoords = Object.values(r.coords), this.coords || (this.coords = this.spaceCoords.map((n) => {
240
+ let a = ["<number>", "<percentage>"];
241
+ return n.type === "angle" && a.push("<angle>"), a;
242
+ })), this.coords = this.coords.map(
243
+ /** @param {string | string[] | Type[]} types */
244
+ (n, a) => {
245
+ let s = this.spaceCoords[a];
246
+ return typeof n == "string" && (n = n.trim().split(/\s*\|\s*/)), n.map((i) => Xt.get(i, s));
247
+ }
248
+ ));
249
+ }
250
+ /**
251
+ * @param {Coords} coords
252
+ * @param {number} precision
253
+ * @param {Type[]} types
254
+ */
255
+ serializeCoords(e, r, n) {
256
+ return n = e.map((a, s) => Xt.get(n?.[s] ?? this.coords[s][0], this.spaceCoords[s])), e.map((a, s) => n[s].serialize(a, r));
257
+ }
258
+ /**
259
+ * Validates the coordinates of a color against a format's coord grammar and
260
+ * maps the coordinates to the range or refRange of the coordinates.
261
+ * @param {Coords} coords
262
+ * @param {[string, string, string]} types
263
+ */
264
+ coerceCoords(e, r) {
265
+ return Object.entries(this.space.coords).map(([n, a], s) => {
266
+ let i = e[s];
267
+ if (L(i) || isNaN(i))
268
+ return i;
269
+ let o = r[s], l = this.coords[s].find((c) => c.type == o);
270
+ if (!l) {
271
+ let c = a.name || n;
272
+ throw new TypeError(
273
+ `${o ?? /** @type {any} */
274
+ i?.raw ?? i} not allowed for ${c} in ${this.name}()`
275
+ );
276
+ }
277
+ return i = l.resolve(i), l.range && (r[s] = l.toString()), i;
278
+ });
279
+ }
280
+ /**
281
+ * @returns {boolean | Required<FormatInterface>["serialize"]}
282
+ */
283
+ canSerialize() {
284
+ return this.type === "function" || /** @type {any} */
285
+ this.serialize;
286
+ }
287
+ /**
288
+ * @param {string} str
289
+ * @returns {(import("./types.js").ColorConstructor) | undefined | null}
290
+ */
291
+ parse(e) {
292
+ return null;
293
+ }
294
+ /**
295
+ * @param {Format | FormatInterface} format
296
+ * @param {RemoveFirstElement<ConstructorParameters<typeof Format>>} args
297
+ * @returns {Format}
298
+ */
299
+ static get(e, ...r) {
300
+ return !e || ge(e, this) ? (
301
+ /** @type {Format} */
302
+ e
303
+ ) : e[ct] ? e[ct] : new Ze(e, ...r);
304
+ }
305
+ }
306
+ const P = {
307
+ // for compatibility, the four-digit chromaticity-derived ones everyone else uses
308
+ D50: [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585],
309
+ D65: [0.3127 / 0.329, 1, (1 - 0.3127 - 0.329) / 0.329]
310
+ };
311
+ function _t(t) {
312
+ return Array.isArray(t) ? t : P[t];
313
+ }
314
+ function Je(t, e, r, n = {}) {
315
+ if (t = _t(t), e = _t(e), !t || !e)
316
+ throw new TypeError(
317
+ `Missing white point to convert ${t ? "" : "from"}${!t && !e ? "/" : ""}${e ? "" : "to"}`
318
+ );
319
+ if (t === e)
320
+ return r;
321
+ let a = { W1: t, W2: e, XYZ: r, options: n };
322
+ if (te.run("chromatic-adaptation-start", a), a.M || (a.W1 === P.D65 && a.W2 === P.D50 ? a.M = [
323
+ [1.0479297925449969, 0.022946870601609652, -0.05019226628920524],
324
+ [0.02962780877005599, 0.9904344267538799, -0.017073799063418826],
325
+ [-0.009243040646204504, 0.015055191490298152, 0.7518742814281371]
326
+ ] : a.W1 === P.D50 && a.W2 === P.D65 && (a.M = [
327
+ [0.955473421488075, -0.02309845494876471, 0.06325924320057072],
328
+ [-0.0283697093338637, 1.0099953980813041, 0.021041441191917323],
329
+ [0.012314014864481998, -0.020507649298898964, 1.330365926242124]
330
+ ])), te.run("chromatic-adaptation-end", a), a.M)
331
+ return x(a.XYZ, a.M);
332
+ throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.");
333
+ }
334
+ function X0(t, e) {
335
+ let r = {
336
+ str: String(t)?.trim(),
337
+ options: e
338
+ };
339
+ if (te.run("parse-start", r), r.color)
340
+ return r.color;
341
+ r.parsed = Nr(r.str);
342
+ let n, a = r.options ? r.options.parseMeta ?? r.options.meta : null;
343
+ if (r.parsed) {
344
+ let s = r.parsed.name, i, o, l = r.parsed.args, c = l.map((h, m) => r.parsed.argMeta[m]?.type);
345
+ if (s === "color") {
346
+ let h = l.shift();
347
+ c.shift();
348
+ let m = h.startsWith("--") ? h.substring(2) : `--${h}`, d = [h, m];
349
+ if (i = g.findFormat({ name: s, id: d, type: "function" }), !i) {
350
+ let M, p = h in g.registry ? h : m;
351
+ if (p in g.registry) {
352
+ let w = g.registry[p].formats?.color?.id;
353
+ w && (M = `Did you mean ${t.replace("color(" + h, "color(" + w)}?`);
354
+ }
355
+ throw new TypeError(
356
+ `Cannot parse ${r.str}. ` + (M ?? "Missing a plugin?")
357
+ );
358
+ }
359
+ o = i.space, i.id.startsWith("--") && !h.startsWith("--") && N.warn(
360
+ `${o.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${i.id}) instead of color(${h}).`
361
+ ), h.startsWith("--") && !i.id.startsWith("--") && N.warn(
362
+ `${o.name} is a standard space and supported in the CSS spec. Use color(${i.id}) instead of prefixed color(${h}).`
363
+ );
364
+ } else
365
+ i = g.findFormat({ name: s, type: "function" }), o = i.space;
366
+ a && Object.assign(a, {
367
+ format: i,
368
+ formatId: i.name,
369
+ types: c,
370
+ commas: r.parsed.commas
371
+ });
372
+ let f = 1;
373
+ r.parsed.lastAlpha && (f = r.parsed.args.pop(), a && (a.alphaType = c.pop()));
374
+ let u = i.coords.length;
375
+ if (l.length !== u)
376
+ throw new TypeError(
377
+ `Expected ${u} coordinates for ${o.id} in ${r.str}), got ${l.length}`
378
+ );
379
+ l = i.coerceCoords(l, c), n = { spaceId: o.id, coords: l, alpha: f };
380
+ } else
381
+ e: for (let s of g.all)
382
+ for (let i in s.formats) {
383
+ let o = s.formats[i];
384
+ if (o.type !== "custom" || o.test && !o.test(r.str))
385
+ continue;
386
+ let l = s.getFormat(o), c = l.parse(r.str);
387
+ if (c) {
388
+ a && Object.assign(a, { format: l, formatId: i }), n = c;
389
+ break e;
390
+ }
391
+ }
392
+ if (!n)
393
+ throw new TypeError(`Could not parse ${t} as a color. Missing a plugin?`);
394
+ return n.alpha = L(n.alpha) ? n.alpha : n.alpha === void 0 ? 1 : et(0, n.alpha, 1), n;
395
+ }
396
+ const G0 = {
397
+ "%": 0.01,
398
+ deg: 1,
399
+ grad: 0.9,
400
+ rad: 180 / Math.PI,
401
+ turn: 360
402
+ }, We = {
403
+ // Need to list calc(NaN) explicitly as otherwise its ending paren would terminate the function call
404
+ function: /^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,
405
+ number: /^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,
406
+ unitValue: RegExp(`(${Object.keys(G0).join("|")})$`),
407
+ // NOTE The -+ are not just for prefix, but also for idents, and e+N notation!
408
+ singleArgument: /\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g
409
+ };
410
+ function Yr(t) {
411
+ let e = {}, r = t.match(We.unitValue)?.[0], n = e.raw = t;
412
+ return r ? (e.type = r === "%" ? "<percentage>" : "<angle>", e.unit = r, e.unitless = Number(n.slice(0, -r.length)), n = e.unitless * G0[r]) : We.number.test(n) ? (n = Number(n), e.type = "<number>") : n === "none" ? n = null : n === "NaN" || n === "calc(NaN)" ? (n = NaN, e.type = "<number>") : e.type = "<ident>", { value: (
413
+ /** @type {number} */
414
+ n
415
+ ), meta: (
416
+ /** @type {ArgumentMeta} */
417
+ e
418
+ ) };
419
+ }
420
+ function Nr(t) {
421
+ if (!t)
422
+ return;
423
+ t = t.trim();
424
+ let e = t.match(We.function);
425
+ if (e) {
426
+ let r = [], n = [], a = !1, s = e[1].toLowerCase(), i = e[2].replace(We.singleArgument, (o, l) => {
427
+ let { value: c, meta: f } = Yr(l);
428
+ return (
429
+ // If there's a slash here, it's modern syntax
430
+ (o.startsWith("/") || // If there's still elements to process after there's already 3 in `args` (and the we're not dealing with "color()"), it's likely to be a legacy color like "hsl(0, 0%, 0%, 0.5)"
431
+ s !== "color" && r.length === 3) && (a = !0), r.push(c), n.push(f), ""
432
+ );
433
+ });
434
+ return {
435
+ name: s,
436
+ args: r,
437
+ argMeta: n,
438
+ lastAlpha: a,
439
+ commas: i.includes(","),
440
+ rawName: e[1],
441
+ rawArgs: e[2]
442
+ };
443
+ }
444
+ }
445
+ function C(t, e) {
446
+ if (Array.isArray(t))
447
+ return t.map((n) => C(n, e));
448
+ if (!t)
449
+ throw new TypeError("Empty color reference");
450
+ ye(t) && (t = X0(t, e));
451
+ let r = t.space || t.spaceId;
452
+ return typeof r == "string" && (t.space = g.get(r)), t.alpha === void 0 && (t.alpha = 1), t;
453
+ }
454
+ const qr = 75e-6;
455
+ class g {
456
+ constructor(e) {
457
+ this.id = e.id, this.name = e.name, this.base = e.base ? g.get(e.base) : null, this.aliases = e.aliases, this.base && (this.fromBase = e.fromBase, this.toBase = e.toBase);
458
+ let r = e.coords ?? this.base.coords;
459
+ for (let a in r)
460
+ "name" in r[a] || (r[a].name = a);
461
+ this.coords = r;
462
+ let n = e.white ?? this.base.white ?? "D65";
463
+ this.white = _t(n), this.formats = e.formats ?? {};
464
+ for (let a in this.formats) {
465
+ let s = this.formats[a];
466
+ s.type ||= "function", s.name ||= a;
467
+ }
468
+ this.formats.color?.id || (this.formats.color = {
469
+ ...this.formats.color ?? {},
470
+ id: e.cssId || this.id
471
+ }), e.gamutSpace ? this.gamutSpace = e.gamutSpace === "self" ? this : g.get(e.gamutSpace) : this.isPolar ? this.gamutSpace = this.base : this.gamutSpace = this, this.gamutSpace.isUnbounded && (this.inGamut = (a, s) => !0), this.referred = e.referred, Object.defineProperty(this, "path", {
472
+ value: Xr(this).reverse(),
473
+ writable: !1,
474
+ enumerable: !0,
475
+ configurable: !0
476
+ }), te.run("colorspace-init-end", this);
477
+ }
478
+ inGamut(e, { epsilon: r = qr } = {}) {
479
+ if (!this.equals(this.gamutSpace))
480
+ return e = this.to(this.gamutSpace, e), this.gamutSpace.inGamut(e, { epsilon: r });
481
+ let n = Object.values(this.coords);
482
+ return e.every((a, s) => {
483
+ let i = n[s];
484
+ if (i.type !== "angle" && i.range) {
485
+ if (L(a))
486
+ return !0;
487
+ let [o, l] = i.range;
488
+ return (o === void 0 || a >= o - r) && (l === void 0 || a <= l + r);
489
+ }
490
+ return !0;
491
+ });
492
+ }
493
+ get isUnbounded() {
494
+ return Object.values(this.coords).every((e) => !("range" in e));
495
+ }
496
+ get cssId() {
497
+ return this.formats?.color?.id || this.id;
498
+ }
499
+ get isPolar() {
500
+ for (let e in this.coords)
501
+ if (this.coords[e].type === "angle")
502
+ return !0;
503
+ return !1;
504
+ }
505
+ /**
506
+ * Lookup a format in this color space
507
+ * @param {string | object | Format} format - Format id if string. If object, it's converted to a `Format` object and returned.
508
+ * @returns {Format}
509
+ */
510
+ getFormat(e) {
511
+ if (!e)
512
+ return null;
513
+ e === "default" ? e = Object.values(this.formats)[0] : typeof e == "string" && (e = this.formats[e]);
514
+ let r = Ze.get(e, this);
515
+ return r !== e && e.name in this.formats && (this.formats[e.name] = r), r;
516
+ }
517
+ /**
518
+ * Check if this color space is the same as another color space reference.
519
+ * Allows proxying color space objects and comparing color spaces with ids.
520
+ * @param {string | ColorSpace} space ColorSpace object or id to compare to
521
+ * @returns {boolean}
522
+ */
523
+ equals(e) {
524
+ return e ? this === e || this.id === e || this.id === e.id : !1;
525
+ }
526
+ to(e, r) {
527
+ if (arguments.length === 1) {
528
+ const o = C(e);
529
+ [e, r] = [o.space, o.coords];
530
+ }
531
+ if (e = g.get(e), this.equals(e))
532
+ return r;
533
+ r = r.map((o) => L(o) ? 0 : o);
534
+ let n = this.path, a = e.path, s, i;
535
+ for (let o = 0; o < n.length && n[o].equals(a[o]); o++)
536
+ s = n[o], i = o;
537
+ if (!s)
538
+ throw new Error(
539
+ `Cannot convert between color spaces ${this} and ${e}: no connection space was found`
540
+ );
541
+ for (let o = n.length - 1; o > i; o--)
542
+ r = n[o].toBase(r);
543
+ for (let o = i + 1; o < a.length; o++)
544
+ r = a[o].fromBase(r);
545
+ return r;
546
+ }
547
+ from(e, r) {
548
+ if (arguments.length === 1) {
549
+ const n = C(e);
550
+ [e, r] = [n.space, n.coords];
551
+ }
552
+ return e = g.get(e), e.to(this, r);
553
+ }
554
+ toString() {
555
+ return `${this.name} (${this.id})`;
556
+ }
557
+ getMinCoords() {
558
+ let e = [];
559
+ for (let r in this.coords) {
560
+ let n = this.coords[r], a = n.range || n.refRange;
561
+ e.push(a?.min ?? 0);
562
+ }
563
+ return e;
564
+ }
565
+ static registry = {};
566
+ // Returns array of unique color spaces
567
+ static get all() {
568
+ return [...new Set(Object.values(g.registry))];
569
+ }
570
+ static register(e, r) {
571
+ if (arguments.length === 1 && (r = arguments[0], e = r.id), r = this.get(r), this.registry[e] && this.registry[e] !== r)
572
+ throw new Error(`Duplicate color space registration: '${e}'`);
573
+ if (this.registry[e] = r, arguments.length === 1 && r.aliases)
574
+ for (let n of r.aliases)
575
+ this.register(n, r);
576
+ return r;
577
+ }
578
+ /**
579
+ * Lookup ColorSpace object by name
580
+ * @param {ColorSpace | string} name
581
+ */
582
+ static get(e, ...r) {
583
+ if (!e || ge(e, this))
584
+ return e;
585
+ if (K(e) === "string") {
586
+ let a = g.registry[e.toLowerCase()];
587
+ if (!a)
588
+ throw new TypeError(`No color space found with id = "${e}"`);
589
+ return a;
590
+ }
591
+ if (r.length)
592
+ return g.get(...r);
593
+ throw new TypeError(`${e} is not a valid color space`);
594
+ }
595
+ /**
596
+ * Look up all color spaces for a format that matches certain criteria
597
+ * @param {object | string} filters
598
+ * @param {Array<ColorSpace>} [spaces=ColorSpace.all]
599
+ * @returns {Format | null}
600
+ */
601
+ static findFormat(e, r = g.all) {
602
+ if (!e)
603
+ return null;
604
+ typeof e == "string" && (e = { name: e });
605
+ for (let n of r)
606
+ for (let [a, s] of Object.entries(n.formats)) {
607
+ s.name ??= a, s.type ??= "function";
608
+ let i = (!e.name || s.name === e.name) && (!e.type || s.type === e.type);
609
+ if (e.id) {
610
+ let o = s.ids || [s.id], l = Array.isArray(e.id) ? e.id : [e.id];
611
+ i &&= l.some((c) => o.includes(c));
612
+ }
613
+ if (i) {
614
+ let o = Ze.get(s, n);
615
+ return o !== s && (n.formats[s.name] = o), o;
616
+ }
617
+ }
618
+ return null;
619
+ }
620
+ /**
621
+ * Get metadata about a coordinate of a color space
622
+ *
623
+ * @static
624
+ * @param {Array | string} ref
625
+ * @param {ColorSpace | string} [workingSpace]
626
+ * @return {Object}
627
+ */
628
+ static resolveCoord(e, r) {
629
+ let n = K(e), a, s;
630
+ if (n === "string" ? e.includes(".") ? [a, s] = e.split(".") : [a, s] = [, e] : Array.isArray(e) ? [a, s] = e : (a = e.space, s = e.coordId), a = g.get(a), a || (a = r), !a)
631
+ throw new TypeError(
632
+ `Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`
633
+ );
634
+ if (n = K(s), n === "number" || n === "string" && s >= 0) {
635
+ let l = Object.entries(a.coords)[s];
636
+ if (l)
637
+ return { space: a, id: l[0], index: s, ...l[1] };
638
+ }
639
+ a = g.get(a);
640
+ let i = s.toLowerCase(), o = 0;
641
+ for (let l in a.coords) {
642
+ let c = a.coords[l];
643
+ if (l.toLowerCase() === i || c.name?.toLowerCase() === i)
644
+ return { space: a, id: l, index: o, ...c };
645
+ o++;
646
+ }
647
+ throw new TypeError(
648
+ `No "${s}" coordinate found in ${a.name}. Its coordinates are: ${Object.keys(a.coords).join(", ")}`
649
+ );
650
+ }
651
+ static DEFAULT_FORMAT = {
652
+ type: "functions",
653
+ name: "color"
654
+ };
655
+ }
656
+ function Xr(t) {
657
+ let e = [t];
658
+ for (let r = t; r = r.base; )
659
+ e.push(r);
660
+ return e;
661
+ }
662
+ var A = new g({
663
+ id: "xyz-d65",
664
+ name: "XYZ D65",
665
+ coords: {
666
+ x: {
667
+ refRange: [0, 1],
668
+ name: "X"
669
+ },
670
+ y: {
671
+ refRange: [0, 1],
672
+ name: "Y"
673
+ },
674
+ z: {
675
+ refRange: [0, 1],
676
+ name: "Z"
677
+ }
678
+ },
679
+ white: "D65",
680
+ formats: {
681
+ color: {
682
+ ids: ["xyz-d65", "xyz"]
683
+ }
684
+ },
685
+ aliases: ["xyz"]
686
+ });
687
+ class O extends g {
688
+ /**
689
+ * Creates a new RGB ColorSpace.
690
+ * If coords are not specified, they will use the default RGB coords.
691
+ * Instead of `fromBase()` and `toBase()` functions,
692
+ * you can specify to/from XYZ matrices and have `toBase()` and `fromBase()` automatically generated.
693
+ * @param {RGBOptions} options
694
+ */
695
+ constructor(e) {
696
+ e.coords || (e.coords = {
697
+ r: {
698
+ range: [0, 1],
699
+ name: "Red"
700
+ },
701
+ g: {
702
+ range: [0, 1],
703
+ name: "Green"
704
+ },
705
+ b: {
706
+ range: [0, 1],
707
+ name: "Blue"
708
+ }
709
+ }), e.base || (e.base = A), e.toXYZ_M && e.fromXYZ_M && (e.toBase ??= (r) => {
710
+ let n = x(r, e.toXYZ_M);
711
+ return this.white !== this.base.white && (n = Je(this.white, this.base.white, n)), n;
712
+ }, e.fromBase ??= (r) => (r = Je(this.base.white, this.white, r), x(r, e.fromXYZ_M))), e.referred ??= "display", super(e);
713
+ }
714
+ }
715
+ function Z0(t, e = {}) {
716
+ if (Array.isArray(t))
717
+ return t.map((l) => Z0(l, e));
718
+ let { cssProperty: r = "background-color", element: n, ...a } = e, s = null;
719
+ try {
720
+ return C(t, a);
721
+ } catch (l) {
722
+ s = l;
723
+ }
724
+ let { CSS: i, getComputedStyle: o } = globalThis;
725
+ if (ye(t) && n && i && o && i.supports(r, t)) {
726
+ let l = n.style[r];
727
+ t !== l && (n.style[r] = t);
728
+ let c = o(n).getPropertyValue(r);
729
+ if (t !== l && (n.style[r] = l), c !== t)
730
+ try {
731
+ return C(c, a);
732
+ } catch (f) {
733
+ s = f;
734
+ }
735
+ else
736
+ s = {
737
+ message: "Color value is a valid CSS color, but it could not be resolved :("
738
+ };
739
+ }
740
+ return e.errorMeta && (e.errorMeta.error = s), null;
741
+ }
742
+ function ke(t, e) {
743
+ t = C(t);
744
+ let r = g.get(e, e?.space), n = e?.precision, a;
745
+ return !r || t.space.equals(r) ? a = t.coords.slice() : a = r.from(t), n === void 0 ? a : a.map((s) => kt(s, n));
746
+ }
747
+ function T(t, e) {
748
+ if (t = C(t), e === "alpha")
749
+ return t.alpha ?? 1;
750
+ let { space: r, index: n } = g.resolveCoord(e, t.space);
751
+ return ke(t, r)[n];
752
+ }
753
+ function At(t, e, r, n) {
754
+ return t = C(t), Array.isArray(e) && ([e, r, n] = [t.space, e, r]), e = g.get(e), t.coords = e === t.space ? r.slice() : e.to(t.space, r), n !== void 0 && (t.alpha = n), t;
755
+ }
756
+ At.returns = "color";
757
+ function F(t, e, r) {
758
+ if (t = C(t), arguments.length === 2 && K(arguments[1]) === "object") {
759
+ let n = arguments[1];
760
+ for (let a in n)
761
+ F(t, a, n[a]);
762
+ } else if (typeof r == "function" && (r = r(T(t, e))), e === "alpha")
763
+ t.alpha = r;
764
+ else {
765
+ let { space: n, index: a } = g.resolveCoord(e, t.space), s = ke(t, n);
766
+ s[a] = r, At(t, n, s);
767
+ }
768
+ return t;
769
+ }
770
+ F.returns = "color";
771
+ var Ot = new g({
772
+ id: "xyz-d50",
773
+ name: "XYZ D50",
774
+ white: "D50",
775
+ base: A,
776
+ fromBase: (t) => Je(A.white, "D50", t),
777
+ toBase: (t) => Je("D50", A.white, t)
778
+ });
779
+ const Gr = 216 / 24389, Gt = 24 / 116, Ie = 24389 / 27;
780
+ let ut = P.D50;
781
+ var Y = new g({
782
+ id: "lab",
783
+ name: "Lab",
784
+ coords: {
785
+ l: {
786
+ refRange: [0, 100],
787
+ name: "Lightness"
788
+ },
789
+ a: {
790
+ refRange: [-125, 125]
791
+ },
792
+ b: {
793
+ refRange: [-125, 125]
794
+ }
795
+ },
796
+ // Assuming XYZ is relative to D50, convert to CIE Lab
797
+ // from CIE standard, which now defines these as a rational fraction
798
+ white: ut,
799
+ base: Ot,
800
+ // Convert D50-adapted XYX to Lab
801
+ // CIE 15.3:2004 section 8.2.1.1
802
+ fromBase(t) {
803
+ let r = t.map((i, o) => i / ut[o]).map((i) => i > Gr ? Math.cbrt(i) : (Ie * i + 16) / 116), n = 116 * r[1] - 16, a = 500 * (r[0] - r[1]), s = 200 * (r[1] - r[2]);
804
+ return [n, a, s];
805
+ },
806
+ // Convert Lab to D50-adapted XYZ
807
+ // Same result as CIE 15.3:2004 Appendix D although the derivation is different
808
+ // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
809
+ toBase(t) {
810
+ let [e, r, n] = t, a = [];
811
+ return a[1] = (e + 16) / 116, a[0] = r / 500 + a[1], a[2] = a[1] - n / 200, [
812
+ a[0] > Gt ? Math.pow(a[0], 3) : (116 * a[0] - 16) / Ie,
813
+ t[0] > 8 ? Math.pow((t[0] + 16) / 116, 3) : t[0] / Ie,
814
+ a[2] > Gt ? Math.pow(a[2], 3) : (116 * a[2] - 16) / Ie
815
+ ].map((i, o) => i * ut[o]);
816
+ },
817
+ formats: {
818
+ lab: {
819
+ coords: [
820
+ "<percentage> | <number>",
821
+ "<number> | <percentage>",
822
+ "<number> | <percentage>"
823
+ ]
824
+ }
825
+ }
826
+ });
827
+ function X(t) {
828
+ return typeof t != "number" ? t : (t % 360 + 360) % 360;
829
+ }
830
+ function J0(t, e) {
831
+ let [r, n] = e, a = L(r), s = L(n);
832
+ if (a && s)
833
+ return [r, n];
834
+ if (a ? r = n : s && (n = r), t === "raw")
835
+ return e;
836
+ r = X(r), n = X(n);
837
+ let i = n - r;
838
+ return t === "increasing" ? i < 0 && (n += 360) : t === "decreasing" ? i > 0 && (r += 360) : t === "longer" ? -180 < i && i < 180 && (i > 0 ? r += 360 : n += 360) : t === "shorter" && (i > 180 ? r += 360 : i < -180 && (n += 360)), [r, n];
839
+ }
840
+ var q = new g({
841
+ id: "lch",
842
+ name: "LCH",
843
+ coords: {
844
+ l: {
845
+ refRange: [0, 100],
846
+ name: "Lightness"
847
+ },
848
+ c: {
849
+ refRange: [0, 150],
850
+ name: "Chroma"
851
+ },
852
+ h: {
853
+ refRange: [0, 360],
854
+ type: "angle",
855
+ name: "Hue"
856
+ }
857
+ },
858
+ base: Y,
859
+ fromBase(t) {
860
+ if (this.ε === void 0) {
861
+ let o = Object.values(this.base.coords)[1].refRange, l = o[1] - o[0];
862
+ this.ε = l / 1e5;
863
+ }
864
+ let [e, r, n] = t, a = Math.abs(r) < this.ε && Math.abs(n) < this.ε, s = a ? null : X(Math.atan2(n, r) * 180 / Math.PI), i = a ? 0 : Math.sqrt(r ** 2 + n ** 2);
865
+ return [e, i, s];
866
+ },
867
+ toBase(t) {
868
+ let [e, r, n] = t, a = null, s = null;
869
+ return L(n) || (r = r < 0 ? 0 : r, a = r * Math.cos(n * Math.PI / 180), s = r * Math.sin(n * Math.PI / 180)), [e, a, s];
870
+ },
871
+ formats: {
872
+ lch: {
873
+ coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
874
+ }
875
+ }
876
+ });
877
+ const Zt = 25 ** 7, Fe = Math.PI, Jt = 180 / Fe, ue = Fe / 180;
878
+ function Wt(t) {
879
+ const e = t * t;
880
+ return e * e * e * t;
881
+ }
882
+ function W0(t, e, { kL: r = 1, kC: n = 1, kH: a = 1 } = {}) {
883
+ [t, e] = C([t, e]);
884
+ let [s, i, o] = Y.from(t), l = q.from(Y, [s, i, o])[1], [c, f, u] = Y.from(e), h = q.from(Y, [c, f, u])[1];
885
+ l < 0 && (l = 0), h < 0 && (h = 0);
886
+ let m = (l + h) / 2, d = Wt(m), M = 0.5 * (1 - Math.sqrt(d / (d + Zt))), p = (1 + M) * i, w = (1 + M) * f, b = Math.sqrt(p ** 2 + o ** 2), y = Math.sqrt(w ** 2 + u ** 2), _ = p === 0 && o === 0 ? 0 : Math.atan2(o, p), S = w === 0 && u === 0 ? 0 : Math.atan2(u, w);
887
+ _ < 0 && (_ += 2 * Fe), S < 0 && (S += 2 * Fe), _ *= Jt, S *= Jt;
888
+ let I = c - s, H = y - b, B = S - _, j = _ + S, Q = Math.abs(B), G;
889
+ b * y === 0 ? G = 0 : Q <= 180 ? G = B : B > 180 ? G = B - 360 : B < -180 ? G = B + 360 : N.warn("the unthinkable has happened");
890
+ let J = 2 * Math.sqrt(y * b) * Math.sin(G * ue / 2), U = (s + c) / 2, W = (b + y) / 2, we = Wt(W), D;
891
+ b * y === 0 ? D = j : Q <= 180 ? D = j / 2 : j < 360 ? D = (j + 360) / 2 : D = (j - 360) / 2;
892
+ let Ae = (U - 50) ** 2, Oe = 1 + 0.015 * Ae / Math.sqrt(20 + Ae), le = 1 + 0.045 * W, V = 1;
893
+ V -= 0.17 * Math.cos((D - 30) * ue), V += 0.24 * Math.cos(2 * D * ue), V += 0.32 * Math.cos((3 * D + 6) * ue), V -= 0.2 * Math.cos((4 * D - 63) * ue);
894
+ let ce = 1 + 0.015 * W * V, st = 30 * Math.exp(-1 * ((D - 275) / 25) ** 2), Pe = 2 * Math.sqrt(we / (we + Zt)), Ce = -1 * Math.sin(2 * st * ue) * Pe, ae = (I / (r * Oe)) ** 2;
895
+ return ae += (H / (n * le)) ** 2, ae += (J / (a * ce)) ** 2, ae += Ce * (H / (n * le)) * (J / (a * ce)), Math.sqrt(ae);
896
+ }
897
+ const Zr = [
898
+ [0.819022437996703, 0.3619062600528904, -0.1288737815209879],
899
+ [0.0329836539323885, 0.9292868615863434, 0.0361446663506424],
900
+ [0.0481771893596242, 0.2642395317527308, 0.6335478284694309]
901
+ ], Jr = [
902
+ [1.2268798758459243, -0.5578149944602171, 0.2813910456659647],
903
+ [-0.0405757452148008, 1.112286803280317, -0.0717110580655164],
904
+ [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816]
905
+ ], Wr = [
906
+ [0.210454268309314, 0.7936177747023054, -0.0040720430116193],
907
+ [1.9779985324311684, -2.42859224204858, 0.450593709617411],
908
+ [0.0259040424655478, 0.7827717124575296, -0.8086757549230774]
909
+ ], ee = [
910
+ [1, 0.3963377773761749, 0.2158037573099136],
911
+ [1, -0.1055613458156586, -0.0638541728258133],
912
+ [1, -0.0894841775298119, -1.2914855480194092]
913
+ ];
914
+ var Z = new g({
915
+ id: "oklab",
916
+ name: "Oklab",
917
+ coords: {
918
+ l: {
919
+ refRange: [0, 1],
920
+ name: "Lightness"
921
+ },
922
+ a: {
923
+ refRange: [-0.4, 0.4]
924
+ },
925
+ b: {
926
+ refRange: [-0.4, 0.4]
927
+ }
928
+ },
929
+ // Note that XYZ is relative to D65
930
+ white: "D65",
931
+ base: A,
932
+ fromBase(t) {
933
+ let e = x(t, Zr);
934
+ return e[0] = Math.cbrt(e[0]), e[1] = Math.cbrt(e[1]), e[2] = Math.cbrt(e[2]), x(e, Wr, e);
935
+ },
936
+ toBase(t) {
937
+ let e = x(t, ee);
938
+ return e[0] = e[0] ** 3, e[1] = e[1] ** 3, e[2] = e[2] ** 3, x(e, Jr, e);
939
+ },
940
+ formats: {
941
+ oklab: {
942
+ coords: [
943
+ "<percentage> | <number>",
944
+ "<number> | <percentage>",
945
+ "<number> | <percentage>"
946
+ ]
947
+ }
948
+ }
949
+ });
950
+ function Lt(t, e) {
951
+ [t, e] = C([t, e]);
952
+ let [r, n, a] = Z.from(t), [s, i, o] = Z.from(e), l = r - s, c = n - i, f = a - o;
953
+ return Math.sqrt(l ** 2 + c ** 2 + f ** 2);
954
+ }
955
+ const Fr = 75e-6;
956
+ function ie(t, e, { epsilon: r = Fr } = {}) {
957
+ t = C(t), e || (e = t.space), e = g.get(e);
958
+ let n = t.coords;
959
+ return e !== t.space && (n = e.from(t)), e.inGamut(n, { epsilon: r });
960
+ }
961
+ function pe(t) {
962
+ return {
963
+ space: t.space,
964
+ coords: (
965
+ /** @type {Coords} */
966
+ t.coords.slice()
967
+ ),
968
+ alpha: t.alpha
969
+ };
970
+ }
971
+ function F0(t, e, r = "lab") {
972
+ r = g.get(r);
973
+ let n = r.from(t), a = r.from(e);
974
+ return Math.sqrt(
975
+ n.reduce((s, i, o) => {
976
+ let l = a[o];
977
+ return L(i) || L(l) ? s : s + (l - i) ** 2;
978
+ }, 0)
979
+ );
980
+ }
981
+ function Qr(t, e) {
982
+ return F0(t, e, "lab");
983
+ }
984
+ const Ur = Math.PI, Ft = Ur / 180;
985
+ function Vr(t, e, { l: r = 2, c: n = 1 } = {}) {
986
+ [t, e] = C([t, e]);
987
+ let [a, s, i] = Y.from(t), [, o, l] = q.from(Y, [a, s, i]), [c, f, u] = Y.from(e), h = q.from(Y, [c, f, u])[1];
988
+ o < 0 && (o = 0), h < 0 && (h = 0);
989
+ let m = a - c, d = o - h, M = s - f, p = i - u, w = M ** 2 + p ** 2 - d ** 2, b = 0.511;
990
+ a >= 16 && (b = 0.040975 * a / (1 + 0.01765 * a));
991
+ let y = 0.0638 * o / (1 + 0.0131 * o) + 0.638, _;
992
+ L(l) && (l = 0), l >= 164 && l <= 345 ? _ = 0.56 + Math.abs(0.2 * Math.cos((l + 168) * Ft)) : _ = 0.36 + Math.abs(0.4 * Math.cos((l + 35) * Ft));
993
+ let S = Math.pow(o, 4), I = Math.sqrt(S / (S + 1900)), H = y * (I * _ + 1 - I), B = (m / (r * b)) ** 2;
994
+ return B += (d / (n * y)) ** 2, B += w / H ** 2, Math.sqrt(B);
995
+ }
996
+ const Qt = 203;
997
+ var Pt = new g({
998
+ // Absolute CIE XYZ, with a D65 whitepoint,
999
+ // as used in most HDR colorspaces as a starting point.
1000
+ // SDR spaces are converted per BT.2048
1001
+ // so that diffuse, media white is 203 cd/m²
1002
+ id: "xyz-abs-d65",
1003
+ cssId: "--xyz-abs-d65",
1004
+ name: "Absolute XYZ D65",
1005
+ coords: {
1006
+ x: {
1007
+ refRange: [0, 9504.7],
1008
+ name: "Xa"
1009
+ },
1010
+ y: {
1011
+ refRange: [0, 1e4],
1012
+ name: "Ya"
1013
+ },
1014
+ z: {
1015
+ refRange: [0, 10888.3],
1016
+ name: "Za"
1017
+ }
1018
+ },
1019
+ base: A,
1020
+ fromBase(t) {
1021
+ return t.map((e) => e * Qt);
1022
+ },
1023
+ toBase(t) {
1024
+ return t.map((e) => e / Qt);
1025
+ }
1026
+ });
1027
+ const He = 1.15, je = 0.66, Ut = 2610 / 2 ** 14, Kr = 2 ** 14 / 2610, Vt = 3424 / 2 ** 12, Kt = 2413 / 2 ** 7, e0 = 2392 / 2 ** 7, en = 1.7 * 2523 / 2 ** 5, t0 = 2 ** 5 / (1.7 * 2523), De = -0.56, ft = 16295499532821565e-27, tn = [
1028
+ [0.41478972, 0.579999, 0.014648],
1029
+ [-0.20151, 1.120649, 0.0531008],
1030
+ [-0.0166008, 0.2648, 0.6684799]
1031
+ ], rn = [
1032
+ [1.9242264357876067, -1.0047923125953657, 0.037651404030618],
1033
+ [0.35031676209499907, 0.7264811939316552, -0.06538442294808501],
1034
+ [-0.09098281098284752, -0.3127282905230739, 1.5227665613052603]
1035
+ ], nn = [
1036
+ [0.5, 0.5, 0],
1037
+ [3.524, -4.066708, 0.542708],
1038
+ [0.199076, 1.096799, -1.295875]
1039
+ ], an = [
1040
+ [1, 0.13860504327153927, 0.05804731615611883],
1041
+ [1, -0.1386050432715393, -0.058047316156118904],
1042
+ [1, -0.09601924202631895, -0.811891896056039]
1043
+ ];
1044
+ var Q0 = new g({
1045
+ id: "jzazbz",
1046
+ name: "Jzazbz",
1047
+ coords: {
1048
+ jz: {
1049
+ refRange: [0, 1],
1050
+ name: "Jz"
1051
+ },
1052
+ az: {
1053
+ refRange: [-0.21, 0.21]
1054
+ },
1055
+ bz: {
1056
+ refRange: [-0.21, 0.21]
1057
+ }
1058
+ },
1059
+ base: Pt,
1060
+ fromBase(t) {
1061
+ let [e, r, n] = t, a = He * e - (He - 1) * n, s = je * r - (je - 1) * e, o = (
1062
+ /** @type {Vector3} } */
1063
+ x([a, s, n], tn).map(function(h) {
1064
+ let m = Vt + Kt * E(h / 1e4, Ut), d = 1 + e0 * E(h / 1e4, Ut);
1065
+ return E(m / d, en);
1066
+ })
1067
+ ), [l, c, f] = x(o, nn);
1068
+ return [(1 + De) * l / (1 + De * l) - ft, c, f];
1069
+ },
1070
+ toBase(t) {
1071
+ let [e, r, n] = t, a = (e + ft) / (1 + De - De * (e + ft)), i = (
1072
+ /** @type {Vector3} } */
1073
+ x([a, r, n], an).map(function(h) {
1074
+ let m = Vt - E(h, t0), d = e0 * E(h, t0) - Kt;
1075
+ return 1e4 * E(m / d, Kr);
1076
+ })
1077
+ ), [o, l, c] = x(i, rn), f = (o + (He - 1) * c) / He, u = (l + (je - 1) * f) / je;
1078
+ return [f, u, c];
1079
+ },
1080
+ formats: {
1081
+ // https://drafts.csswg.org/css-color-hdr/#Jzazbz
1082
+ jzazbz: {
1083
+ coords: [
1084
+ "<percentage> | <number>",
1085
+ "<number> | <percentage>",
1086
+ "<number> | <percentage>"
1087
+ ]
1088
+ }
1089
+ }
1090
+ }), Rt = new g({
1091
+ id: "jzczhz",
1092
+ name: "JzCzHz",
1093
+ coords: {
1094
+ jz: {
1095
+ refRange: [0, 1],
1096
+ name: "Jz"
1097
+ },
1098
+ cz: {
1099
+ refRange: [0, 0.26],
1100
+ name: "Chroma"
1101
+ },
1102
+ hz: {
1103
+ refRange: [0, 360],
1104
+ type: "angle",
1105
+ name: "Hue"
1106
+ }
1107
+ },
1108
+ base: Q0,
1109
+ fromBase: q.fromBase,
1110
+ toBase: q.toBase,
1111
+ formats: {
1112
+ // https://drafts.csswg.org/css-color-hdr/#JzCzhz
1113
+ jzczhz: {
1114
+ coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
1115
+ }
1116
+ }
1117
+ });
1118
+ function sn(t, e) {
1119
+ [t, e] = C([t, e]);
1120
+ let [r, n, a] = Rt.from(t), [s, i, o] = Rt.from(e), l = r - s, c = n - i;
1121
+ L(a) && L(o) ? (a = 0, o = 0) : L(a) ? a = o : L(o) && (o = a);
1122
+ let f = a - o, u = 2 * Math.sqrt(n * i) * Math.sin(f / 2 * (Math.PI / 180));
1123
+ return Math.sqrt(l ** 2 + c ** 2 + u ** 2);
1124
+ }
1125
+ const U0 = 3424 / 4096, V0 = 2413 / 128, K0 = 2392 / 128, r0 = 2610 / 16384, on = 2523 / 32, ln = 16384 / 2610, n0 = 32 / 2523, cn = [
1126
+ [0.3592832590121217, 0.6976051147779502, -0.035891593232029],
1127
+ [-0.1920808463704993, 1.100476797037432, 0.0753748658519118],
1128
+ [0.0070797844607479, 0.0748396662186362, 0.8433265453898765]
1129
+ ], un = [
1130
+ [2048 / 4096, 2048 / 4096, 0],
1131
+ [6610 / 4096, -13613 / 4096, 7003 / 4096],
1132
+ [17933 / 4096, -17390 / 4096, -543 / 4096]
1133
+ ], fn = [
1134
+ [0.9999999999999998, 0.0086090370379328, 0.111029625003026],
1135
+ [0.9999999999999998, -0.0086090370379328, -0.1110296250030259],
1136
+ [0.9999999999999998, 0.5600313357106791, -0.3206271749873188]
1137
+ ], hn = [
1138
+ [2.0701522183894223, -1.3263473389671563, 0.2066510476294053],
1139
+ [0.3647385209748072, 0.6805660249472273, -0.0453045459220347],
1140
+ [-0.0497472075358123, -0.0492609666966131, 1.1880659249923042]
1141
+ ];
1142
+ var vt = new g({
1143
+ id: "ictcp",
1144
+ name: "ICTCP",
1145
+ // From BT.2100-2 page 7:
1146
+ // During production, signal values are expected to exceed the
1147
+ // range E′ = [0.0 : 1.0]. This provides processing headroom and avoids
1148
+ // signal degradation during cascaded processing. Such values of E′,
1149
+ // below 0.0 or exceeding 1.0, should not be clipped during production
1150
+ // and exchange.
1151
+ // Values below 0.0 should not be clipped in reference displays (even
1152
+ // though they represent “negative” light) to allow the black level of
1153
+ // the signal (LB) to be properly set using test signals known as “PLUGE”
1154
+ coords: {
1155
+ i: {
1156
+ refRange: [0, 1],
1157
+ // Constant luminance,
1158
+ name: "I"
1159
+ },
1160
+ ct: {
1161
+ refRange: [-0.5, 0.5],
1162
+ // Full BT.2020 gamut in range [-0.5, 0.5]
1163
+ name: "CT"
1164
+ },
1165
+ cp: {
1166
+ refRange: [-0.5, 0.5],
1167
+ name: "CP"
1168
+ }
1169
+ },
1170
+ base: Pt,
1171
+ fromBase(t) {
1172
+ let e = x(t, cn);
1173
+ return mn(e);
1174
+ },
1175
+ toBase(t) {
1176
+ let e = dn(t);
1177
+ return x(e, hn);
1178
+ },
1179
+ formats: {
1180
+ ictcp: {
1181
+ coords: [
1182
+ "<percentage> | <number>",
1183
+ "<number> | <percentage>",
1184
+ "<number> | <percentage>"
1185
+ ]
1186
+ }
1187
+ }
1188
+ });
1189
+ function mn(t) {
1190
+ let e = (
1191
+ /** @type {Vector3} */
1192
+ t.map(function(r) {
1193
+ let n = U0 + V0 * (r / 1e4) ** r0, a = 1 + K0 * (r / 1e4) ** r0;
1194
+ return (n / a) ** on;
1195
+ })
1196
+ );
1197
+ return x(e, un);
1198
+ }
1199
+ function dn(t) {
1200
+ return (
1201
+ /** @type {Vector3} */
1202
+ x(t, fn).map(function(n) {
1203
+ let a = Math.max(n ** n0 - U0, 0), s = V0 - K0 * n ** n0;
1204
+ return 1e4 * (a / s) ** ln;
1205
+ })
1206
+ );
1207
+ }
1208
+ function gn(t, e) {
1209
+ [t, e] = C([t, e]);
1210
+ let [r, n, a] = vt.from(t), [s, i, o] = vt.from(e);
1211
+ return 720 * Math.sqrt((r - s) ** 2 + 0.25 * (n - i) ** 2 + (a - o) ** 2);
1212
+ }
1213
+ function pn(t, e) {
1214
+ [t, e] = C([t, e]);
1215
+ let r = 2, [n, a, s] = Z.from(t), [i, o, l] = Z.from(e), c = n - i, f = r * (a - o), u = r * (s - l);
1216
+ return Math.sqrt(c ** 2 + f ** 2 + u ** 2);
1217
+ }
1218
+ const bn = P.D65, er = 0.42, a0 = 1 / er, ht = 2 * Math.PI, tr = [
1219
+ [0.401288, 0.650173, -0.051461],
1220
+ [-0.250268, 1.204414, 0.045854],
1221
+ [-2079e-6, 0.048952, 0.953127]
1222
+ ], Mn = [
1223
+ [1.8620678550872327, -1.0112546305316843, 0.14918677544445175],
1224
+ [0.38752654323613717, 0.6214474419314753, -0.008973985167612518],
1225
+ [-0.015841498849333856, -0.03412293802851557, 1.0499644368778496]
1226
+ ], yn = [
1227
+ [460, 451, 288],
1228
+ [460, -891, -261],
1229
+ [460, -220, -6300]
1230
+ ], wn = {
1231
+ dark: [0.8, 0.525, 0.8],
1232
+ dim: [0.9, 0.59, 0.9],
1233
+ average: [1, 0.69, 1]
1234
+ }, se = {
1235
+ // Red, Yellow, Green, Blue, Red
1236
+ h: [20.14, 90, 164.25, 237.53, 380.14],
1237
+ e: [0.8, 0.7, 1, 1.2, 0.8],
1238
+ H: [0, 100, 200, 300, 400]
1239
+ }, Cn = 180 / Math.PI, s0 = Math.PI / 180;
1240
+ function rr(t, e) {
1241
+ return (
1242
+ /** @type {[number, number, number]} */
1243
+ t.map((n) => {
1244
+ const a = E(e * Math.abs(n) * 0.01, er);
1245
+ return 400 * tt(a, n) / (a + 27.13);
1246
+ })
1247
+ );
1248
+ }
1249
+ function _n(t, e) {
1250
+ const r = 100 / e * 27.13 ** a0;
1251
+ return (
1252
+ /** @type {[number, number, number]} */
1253
+ t.map((n) => {
1254
+ const a = Math.abs(n);
1255
+ return tt(r * E(a / (400 - a), a0), n);
1256
+ })
1257
+ );
1258
+ }
1259
+ function Ln(t) {
1260
+ let e = X(t);
1261
+ e <= se.h[0] && (e += 360);
1262
+ const r = q0(se.h, e) - 1, [n, a] = se.h.slice(r, r + 2), [s, i] = se.e.slice(r, r + 2), o = se.H[r], l = (e - n) / s;
1263
+ return o + 100 * l / (l + (a - e) / i);
1264
+ }
1265
+ function Rn(t) {
1266
+ let e = (t % 400 + 400) % 400;
1267
+ const r = Math.floor(0.01 * e);
1268
+ e = e % 100;
1269
+ const [n, a] = se.h.slice(r, r + 2), [s, i] = se.e.slice(r, r + 2);
1270
+ return X((e * (i * n - s * a) - 100 * n * i) / (e * (i - s) - 100 * i));
1271
+ }
1272
+ function nr(t, e, r, n, a) {
1273
+ const s = {};
1274
+ s.discounting = a, s.refWhite = t, s.surround = n;
1275
+ const i = (
1276
+ /** @type {Vector3} */
1277
+ t.map((p) => p * 100)
1278
+ );
1279
+ s.la = e, s.yb = r;
1280
+ const o = i[1], l = x(i, tr);
1281
+ let c = wn[s.surround];
1282
+ const f = c[0];
1283
+ s.c = c[1], s.nc = c[2];
1284
+ const h = (1 / (5 * s.la + 1)) ** 4;
1285
+ s.fl = h * s.la + 0.1 * (1 - h) * (1 - h) * Math.cbrt(5 * s.la), s.flRoot = s.fl ** 0.25, s.n = s.yb / o, s.z = 1.48 + Math.sqrt(s.n), s.nbb = 0.725 * s.n ** -0.2, s.ncb = s.nbb;
1286
+ const m = Math.max(Math.min(f * (1 - 1 / 3.6 * Math.exp((-s.la - 42) / 92)), 1), 0);
1287
+ s.dRgb = /** @type {[number, number, number]} */
1288
+ l.map((p) => Be(1, o / p, m)), s.dRgbInv = /** @type {[number, number, number]} */
1289
+ s.dRgb.map((p) => 1 / p);
1290
+ const d = (
1291
+ /** @type {[number, number, number]} */
1292
+ l.map((p, w) => p * s.dRgb[w])
1293
+ ), M = rr(d, s.fl);
1294
+ return s.aW = s.nbb * (2 * M[0] + M[1] + 0.05 * M[2]), s;
1295
+ }
1296
+ const i0 = nr(bn, 64 / Math.PI * 0.2, 20, "average", !1);
1297
+ function St(t, e) {
1298
+ if (!(t.J !== void 0 ^ t.Q !== void 0))
1299
+ throw new Error("Conversion requires one and only one: 'J' or 'Q'");
1300
+ if (!(t.C !== void 0 ^ t.M !== void 0 ^ t.s !== void 0))
1301
+ throw new Error("Conversion requires one and only one: 'C', 'M' or 's'");
1302
+ if (!(t.h !== void 0 ^ t.H !== void 0))
1303
+ throw new Error("Conversion requires one and only one: 'h' or 'H'");
1304
+ if (t.J === 0 || t.Q === 0)
1305
+ return [0, 0, 0];
1306
+ let r = 0;
1307
+ t.h !== void 0 ? r = X(t.h) * s0 : r = Rn(t.H) * s0;
1308
+ const n = Math.cos(r), a = Math.sin(r);
1309
+ let s = 0;
1310
+ t.J !== void 0 ? s = E(t.J, 1 / 2) * 0.1 : t.Q !== void 0 && (s = 0.25 * e.c * t.Q / ((e.aW + 4) * e.flRoot));
1311
+ let i = 0;
1312
+ t.C !== void 0 ? i = t.C / s : t.M !== void 0 ? i = t.M / e.flRoot / s : t.s !== void 0 && (i = 4e-4 * t.s ** 2 * (e.aW + 4) / e.c);
1313
+ const o = E(i * Math.pow(1.64 - Math.pow(0.29, e.n), -0.73), 10 / 9), l = 0.25 * (Math.cos(r + 2) + 3.8), c = e.aW * E(s, 2 / e.c / e.z), f = 5e4 / 13 * e.nc * e.ncb * l, u = c / e.nbb, h = 23 * (u + 0.305) * $t(o, 23 * f + o * (11 * n + 108 * a)), m = h * n, d = h * a, M = _n(
1314
+ /** @type {Vector3} */
1315
+ x([u, m, d], yn).map((p) => p * 1 / 1403),
1316
+ e.fl
1317
+ );
1318
+ return (
1319
+ /** @type {Vector3} */
1320
+ x(
1321
+ /** @type {Vector3} */
1322
+ M.map((p, w) => p * e.dRgbInv[w]),
1323
+ Mn
1324
+ ).map((p) => p / 100)
1325
+ );
1326
+ }
1327
+ function ar(t, e) {
1328
+ const r = (
1329
+ /** @type {Vector3} */
1330
+ t.map((y) => y * 100)
1331
+ ), n = rr(
1332
+ /** @type {[number, number, number]} */
1333
+ x(r, tr).map((y, _) => y * e.dRgb[_]),
1334
+ e.fl
1335
+ ), a = n[0] + (-12 * n[1] + n[2]) / 11, s = (n[0] + n[1] - 2 * n[2]) / 9, i = (Math.atan2(s, a) % ht + ht) % ht, o = 0.25 * (Math.cos(i + 2) + 3.8), l = 5e4 / 13 * e.nc * e.ncb * $t(o * Math.sqrt(a ** 2 + s ** 2), n[0] + n[1] + 1.05 * n[2] + 0.305), c = E(l, 0.9) * Math.pow(1.64 - Math.pow(0.29, e.n), 0.73), f = e.nbb * (2 * n[0] + n[1] + 0.05 * n[2]), u = E(f / e.aW, 0.5 * e.c * e.z), h = 100 * E(u, 2), m = 4 / e.c * u * (e.aW + 4) * e.flRoot, d = c * u, M = d * e.flRoot, p = X(i * Cn), w = Ln(p), b = 50 * E(e.c * c / (e.aW + 4), 1 / 2);
1336
+ return { J: h, C: d, h: p, s: b, Q: m, M, H: w };
1337
+ }
1338
+ var vn = new g({
1339
+ id: "cam16-jmh",
1340
+ cssId: "--cam16-jmh",
1341
+ name: "CAM16-JMh",
1342
+ coords: {
1343
+ j: {
1344
+ refRange: [0, 100],
1345
+ name: "J"
1346
+ },
1347
+ m: {
1348
+ refRange: [0, 105],
1349
+ name: "Colorfulness"
1350
+ },
1351
+ h: {
1352
+ refRange: [0, 360],
1353
+ type: "angle",
1354
+ name: "Hue"
1355
+ }
1356
+ },
1357
+ base: A,
1358
+ fromBase(t) {
1359
+ this.ε === void 0 && (this.ε = Object.values(this.coords)[1].refRange[1] / 1e5);
1360
+ const e = ar(t, i0), r = Math.abs(e.M) < this.ε;
1361
+ return [e.J, r ? 0 : e.M, r ? null : e.h];
1362
+ },
1363
+ toBase(t) {
1364
+ return St({ J: t[0], M: t[1], h: t[2] }, i0);
1365
+ }
1366
+ });
1367
+ const Sn = P.D65, xn = 216 / 24389, sr = 24389 / 27;
1368
+ function Bn(t) {
1369
+ return 116 * (t > xn ? Math.cbrt(t) : (sr * t + 16) / 116) - 16;
1370
+ }
1371
+ function xt(t) {
1372
+ return t > 8 ? Math.pow((t + 16) / 116, 3) : t / sr;
1373
+ }
1374
+ function zn(t, e) {
1375
+ let [r, n, a] = t, s = [], i = 0;
1376
+ if (a === 0)
1377
+ return [0, 0, 0];
1378
+ let o = xt(a);
1379
+ a > 0 ? i = 0.00379058511492914 * a ** 2 + 0.608983189401032 * a + 0.9155088574762233 : i = 9514440756550361e-21 * a ** 2 + 0.08693057439788597 * a - 21.928975842194614;
1380
+ const l = 2e-12, c = 15;
1381
+ let f = 0, u = 1 / 0;
1382
+ for (; f <= c; ) {
1383
+ s = St({ J: i, C: n, h: r }, e);
1384
+ const h = Math.abs(s[1] - o);
1385
+ if (h < u) {
1386
+ if (h <= l)
1387
+ return s;
1388
+ u = h;
1389
+ }
1390
+ i = i - (s[1] - o) * i / (2 * s[1]), f += 1;
1391
+ }
1392
+ return St({ J: i, C: n, h: r }, e);
1393
+ }
1394
+ function En(t, e) {
1395
+ const r = Bn(t[1]);
1396
+ if (r === 0)
1397
+ return [0, 0, 0];
1398
+ const n = ar(t, It);
1399
+ return [X(n.h), n.C, r];
1400
+ }
1401
+ const It = nr(
1402
+ Sn,
1403
+ 200 / Math.PI * xt(50),
1404
+ xt(50) * 100,
1405
+ "average",
1406
+ !1
1407
+ );
1408
+ var ze = new g({
1409
+ id: "hct",
1410
+ name: "HCT",
1411
+ coords: {
1412
+ h: {
1413
+ refRange: [0, 360],
1414
+ type: "angle",
1415
+ name: "Hue"
1416
+ },
1417
+ c: {
1418
+ refRange: [0, 145],
1419
+ name: "Colorfulness"
1420
+ },
1421
+ t: {
1422
+ refRange: [0, 100],
1423
+ name: "Tone"
1424
+ }
1425
+ },
1426
+ base: A,
1427
+ fromBase(t) {
1428
+ this.ε === void 0 && (this.ε = Object.values(this.coords)[1].refRange[1] / 1e5);
1429
+ let e = En(t);
1430
+ return e[1] < this.ε && (e[1] = 0, e[0] = null), e;
1431
+ },
1432
+ toBase(t) {
1433
+ return zn(t, It);
1434
+ },
1435
+ formats: {
1436
+ color: {
1437
+ id: "--hct",
1438
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
1439
+ }
1440
+ }
1441
+ });
1442
+ const kn = Math.PI / 180, o0 = [1, 7e-3, 0.0228];
1443
+ function l0(t) {
1444
+ t[1] < 0 && (t = ze.fromBase(ze.toBase(t)));
1445
+ const e = Math.log(Math.max(1 + o0[2] * t[1] * It.flRoot, 1)) / o0[2], r = t[0] * kn, n = e * Math.cos(r), a = e * Math.sin(r);
1446
+ return [t[2], n, a];
1447
+ }
1448
+ function $n(t, e) {
1449
+ [t, e] = C([t, e]);
1450
+ let [r, n, a] = l0(ze.from(t)), [s, i, o] = l0(ze.from(e));
1451
+ return Math.sqrt((r - s) ** 2 + (n - i) ** 2 + (a - o) ** 2);
1452
+ }
1453
+ var be = {
1454
+ deltaE76: Qr,
1455
+ deltaECMC: Vr,
1456
+ deltaE2000: W0,
1457
+ deltaEJz: sn,
1458
+ deltaEITP: gn,
1459
+ deltaEOK: Lt,
1460
+ deltaEOK2: pn,
1461
+ deltaEHCT: $n
1462
+ };
1463
+ function An(t) {
1464
+ const e = t ? Math.floor(Math.log10(Math.abs(t))) : 0;
1465
+ return Math.max(parseFloat(`1e${e - 2}`), 1e-6);
1466
+ }
1467
+ const c0 = {
1468
+ hct: {
1469
+ method: "hct.c",
1470
+ jnd: 2,
1471
+ deltaEMethod: "hct",
1472
+ blackWhiteClamp: {}
1473
+ },
1474
+ "hct-tonal": {
1475
+ method: "hct.c",
1476
+ jnd: 0,
1477
+ deltaEMethod: "hct",
1478
+ blackWhiteClamp: { channel: "hct.t", min: 0, max: 100 }
1479
+ }
1480
+ };
1481
+ function re(t, {
1482
+ method: e = N.gamut_mapping,
1483
+ space: r = void 0,
1484
+ deltaEMethod: n = "",
1485
+ jnd: a = 2,
1486
+ blackWhiteClamp: s = void 0
1487
+ } = {}) {
1488
+ if (t = C(t), ye(arguments[1]) ? r = arguments[1] : r || (r = t.space), r = g.get(r), ie(t, r, { epsilon: 0 }))
1489
+ return (
1490
+ /** @type {PlainColorObject} */
1491
+ t
1492
+ );
1493
+ let i;
1494
+ if (e === "css")
1495
+ i = On(t, { space: r });
1496
+ else {
1497
+ if (e !== "clip" && !ie(t, r)) {
1498
+ Object.prototype.hasOwnProperty.call(c0, e) && ({ method: e, jnd: a, deltaEMethod: n, blackWhiteClamp: s } = c0[e]);
1499
+ let o = W0;
1500
+ if (n !== "") {
1501
+ for (let c in be)
1502
+ if ("deltae" + n.toLowerCase() === c.toLowerCase()) {
1503
+ o = be[c];
1504
+ break;
1505
+ }
1506
+ }
1507
+ a === 0 && (a = 1e-16);
1508
+ let l = re(v(t, r), { method: "clip", space: r });
1509
+ if (o(t, l) > a) {
1510
+ if (s && Object.keys(s).length === 3) {
1511
+ let b = g.resolveCoord(s.channel), y = T(v(t, b.space), b.id);
1512
+ if (L(y) && (y = 0), y >= s.max)
1513
+ return v({ space: "xyz-d65", coords: P.D65 }, t.space);
1514
+ if (y <= s.min)
1515
+ return v({ space: "xyz-d65", coords: [0, 0, 0] }, t.space);
1516
+ }
1517
+ let c = g.resolveCoord(e), f = c.space, u = c.id, h = v(t, f);
1518
+ h.coords.forEach((b, y) => {
1519
+ L(b) && (h.coords[y] = 0);
1520
+ });
1521
+ let d = (c.range || c.refRange)[0], M = An(a), p = d, w = T(h, u);
1522
+ for (; w - p > M; ) {
1523
+ let b = pe(h);
1524
+ b = re(b, { space: r, method: "clip" }), o(h, b) - a < M ? p = T(h, u) : w = T(h, u), F(h, u, (p + w) / 2);
1525
+ }
1526
+ i = v(h, r);
1527
+ } else
1528
+ i = l;
1529
+ } else
1530
+ i = v(t, r);
1531
+ if (e === "clip" || // Dumb coord clipping
1532
+ // finish off smarter gamut mapping with clip to get rid of ε, see #17
1533
+ !ie(i, r, { epsilon: 0 })) {
1534
+ let o = Object.values(r.coords).map((l) => l.range || []);
1535
+ i.coords = /** @type {[number, number, number]} */
1536
+ i.coords.map((l, c) => {
1537
+ let [f, u] = o[c];
1538
+ return f !== void 0 && (l = Math.max(f, l)), u !== void 0 && (l = Math.min(l, u)), l;
1539
+ });
1540
+ }
1541
+ }
1542
+ return r !== t.space && (i = v(i, t.space)), t.coords = i.coords, /** @type {PlainColorObject} */
1543
+ t;
1544
+ }
1545
+ re.returns = "color";
1546
+ const u0 = {
1547
+ WHITE: { space: Z, coords: [1, 0, 0], alpha: 1 },
1548
+ BLACK: { space: Z, coords: [0, 0, 0], alpha: 1 }
1549
+ };
1550
+ function On(t, { space: e } = {}) {
1551
+ t = C(t), e || (e = t.space), e = g.get(e);
1552
+ const a = g.get("oklch");
1553
+ if (e.isUnbounded)
1554
+ return v(t, e);
1555
+ const s = v(t, a);
1556
+ let i = s.coords[0];
1557
+ if (i >= 1) {
1558
+ const d = v(u0.WHITE, e);
1559
+ return d.alpha = t.alpha, v(d, e);
1560
+ }
1561
+ if (i <= 0) {
1562
+ const d = v(u0.BLACK, e);
1563
+ return d.alpha = t.alpha, v(d, e);
1564
+ }
1565
+ if (ie(s, e, { epsilon: 0 }))
1566
+ return v(s, e);
1567
+ function o(d) {
1568
+ const M = v(d, e), p = Object.values(
1569
+ /** @type {ColorSpace} */
1570
+ e.coords
1571
+ );
1572
+ return M.coords = /** @type {[number, number, number]} */
1573
+ M.coords.map((w, b) => {
1574
+ if ("range" in p[b]) {
1575
+ const [y, _] = p[b].range;
1576
+ return et(y, w, _);
1577
+ }
1578
+ return w;
1579
+ }), M;
1580
+ }
1581
+ let l = 0, c = s.coords[1], f = !0, u = pe(s), h = o(u), m = Lt(h, u);
1582
+ if (m < 0.02)
1583
+ return h;
1584
+ for (; c - l > 1e-4; ) {
1585
+ const d = (l + c) / 2;
1586
+ if (u.coords[1] = d, f && ie(u, e, { epsilon: 0 }))
1587
+ l = d;
1588
+ else if (h = o(u), m = Lt(h, u), m < 0.02) {
1589
+ if (0.02 - m < 1e-4)
1590
+ break;
1591
+ f = !1, l = d;
1592
+ } else
1593
+ c = d;
1594
+ }
1595
+ return h;
1596
+ }
1597
+ function v(t, e, { inGamut: r } = {}) {
1598
+ t = C(t), e = g.get(e);
1599
+ let n = e.from(t), a = { space: e, coords: n, alpha: t.alpha };
1600
+ return r && (a = re(a, r === !0 ? void 0 : r)), a;
1601
+ }
1602
+ v.returns = "color";
1603
+ function ve(t, e = {}) {
1604
+ let {
1605
+ precision: r = N.precision,
1606
+ format: n,
1607
+ inGamut: a = !0,
1608
+ coords: s,
1609
+ alpha: i,
1610
+ commas: o
1611
+ } = e, l, c = (
1612
+ /** @type {PlainColorObject & ParseOptions} */
1613
+ C(t)
1614
+ ), f = n, u = c.parseMeta;
1615
+ u && !n && (u.format.canSerialize() && (n = u.format, f = u.formatId), s ??= u.types, i ??= u.alphaType, o ??= u.commas), f && (n = c.space.getFormat(n) ?? g.findFormat(f)), n || (n = c.space.getFormat("default") ?? g.DEFAULT_FORMAT, f = n.name), n && n.space && n.space !== c.space && (c = v(c, n.space));
1616
+ let h = c.coords.slice();
1617
+ if (a ||= n.toGamut, a && !ie(c) && (h = re(pe(c), a === !0 ? void 0 : a).coords), n.type === "custom")
1618
+ if (n.serialize)
1619
+ l = n.serialize(h, c.alpha, e);
1620
+ else
1621
+ throw new TypeError(
1622
+ `format ${f} can only be used to parse colors, not for serialization`
1623
+ );
1624
+ else {
1625
+ let m = n.name || "color", d = n.serializeCoords(h, r, s);
1626
+ if (m === "color") {
1627
+ let y = n.id || n.ids?.[0] || c.space.cssId || c.space.id;
1628
+ d.unshift(y);
1629
+ }
1630
+ let M = c.alpha;
1631
+ i !== void 0 && typeof i != "object" && (i = typeof i == "string" ? { type: i } : { include: i });
1632
+ let p = i?.type ?? "<number>", w = i?.include === !0 || n.alpha === !0 || i?.include !== !1 && n.alpha !== !1 && M < 1, b = "";
1633
+ if (o ??= n.commas, w) {
1634
+ if (r !== null) {
1635
+ let y;
1636
+ p === "<percentage>" && (y = "%", M *= 100), M = Et(M, { precision: r, unit: y });
1637
+ }
1638
+ b = `${o ? "," : " /"} ${M}`;
1639
+ }
1640
+ l = `${m}(${d.join(o ? ", " : " ")}${b})`;
1641
+ }
1642
+ return l;
1643
+ }
1644
+ const Pn = [
1645
+ [0.6369580483012914, 0.14461690358620832, 0.1688809751641721],
1646
+ [0.2627002120112671, 0.6779980715188708, 0.05930171646986196],
1647
+ [0, 0.028072693049087428, 1.060985057710791]
1648
+ ], In = [
1649
+ [1.716651187971268, -0.355670783776392, -0.25336628137366],
1650
+ [-0.666684351832489, 1.616481236634939, 0.0157685458139111],
1651
+ [0.017639857445311, -0.042770613257809, 0.942103121235474]
1652
+ ];
1653
+ var Ee = new O({
1654
+ id: "rec2020-linear",
1655
+ cssId: "--rec2020-linear",
1656
+ name: "Linear REC.2020",
1657
+ white: "D65",
1658
+ toXYZ_M: Pn,
1659
+ fromXYZ_M: In
1660
+ }), ir = new O({
1661
+ id: "rec2020",
1662
+ name: "REC.2020",
1663
+ base: Ee,
1664
+ // Reference electro-optical transfer function from Rec. ITU-R BT.1886 Annex 1
1665
+ // with b (black lift) = 0 and a (user gain) = 1
1666
+ // defined over the extended range, not clamped
1667
+ toBase(t) {
1668
+ return t.map(function(e) {
1669
+ let r = e < 0 ? -1 : 1, n = e * r;
1670
+ return r * Math.pow(n, 2.4);
1671
+ });
1672
+ },
1673
+ fromBase(t) {
1674
+ return t.map(function(e) {
1675
+ let r = e < 0 ? -1 : 1, n = e * r;
1676
+ return r * Math.pow(n, 1 / 2.4);
1677
+ });
1678
+ }
1679
+ });
1680
+ const Hn = [
1681
+ [0.4865709486482162, 0.26566769316909306, 0.1982172852343625],
1682
+ [0.2289745640697488, 0.6917385218365064, 0.079286914093745],
1683
+ [0, 0.04511338185890264, 1.043944368900976]
1684
+ ], jn = [
1685
+ [2.493496911941425, -0.9313836179191239, -0.40271078445071684],
1686
+ [-0.8294889695615747, 1.7626640603183463, 0.023624685841943577],
1687
+ [0.03584583024378447, -0.07617238926804182, 0.9568845240076872]
1688
+ ];
1689
+ var or = new O({
1690
+ id: "p3-linear",
1691
+ cssId: "display-p3-linear",
1692
+ name: "Linear P3",
1693
+ white: "D65",
1694
+ toXYZ_M: Hn,
1695
+ fromXYZ_M: jn
1696
+ });
1697
+ const Dn = [
1698
+ [0.41239079926595934, 0.357584339383878, 0.1804807884018343],
1699
+ [0.21263900587151027, 0.715168678767756, 0.07219231536073371],
1700
+ [0.01933081871559182, 0.11919477979462598, 0.9505321522496607]
1701
+ ], k = [
1702
+ [3.2409699419045226, -1.537383177570094, -0.4986107602930034],
1703
+ [-0.9692436362808796, 1.8759675015077202, 0.04155505740717559],
1704
+ [0.05563007969699366, -0.20397695888897652, 1.0569715142428786]
1705
+ ];
1706
+ var lr = new O({
1707
+ id: "srgb-linear",
1708
+ name: "Linear sRGB",
1709
+ white: "D65",
1710
+ toXYZ_M: Dn,
1711
+ fromXYZ_M: k
1712
+ }), f0 = {
1713
+ aliceblue: [240 / 255, 248 / 255, 1],
1714
+ antiquewhite: [250 / 255, 235 / 255, 215 / 255],
1715
+ aqua: [0, 1, 1],
1716
+ aquamarine: [127 / 255, 1, 212 / 255],
1717
+ azure: [240 / 255, 1, 1],
1718
+ beige: [245 / 255, 245 / 255, 220 / 255],
1719
+ bisque: [1, 228 / 255, 196 / 255],
1720
+ black: [0, 0, 0],
1721
+ blanchedalmond: [1, 235 / 255, 205 / 255],
1722
+ blue: [0, 0, 1],
1723
+ blueviolet: [138 / 255, 43 / 255, 226 / 255],
1724
+ brown: [165 / 255, 42 / 255, 42 / 255],
1725
+ burlywood: [222 / 255, 184 / 255, 135 / 255],
1726
+ cadetblue: [95 / 255, 158 / 255, 160 / 255],
1727
+ chartreuse: [127 / 255, 1, 0],
1728
+ chocolate: [210 / 255, 105 / 255, 30 / 255],
1729
+ coral: [1, 127 / 255, 80 / 255],
1730
+ cornflowerblue: [100 / 255, 149 / 255, 237 / 255],
1731
+ cornsilk: [1, 248 / 255, 220 / 255],
1732
+ crimson: [220 / 255, 20 / 255, 60 / 255],
1733
+ cyan: [0, 1, 1],
1734
+ darkblue: [0, 0, 139 / 255],
1735
+ darkcyan: [0, 139 / 255, 139 / 255],
1736
+ darkgoldenrod: [184 / 255, 134 / 255, 11 / 255],
1737
+ darkgray: [169 / 255, 169 / 255, 169 / 255],
1738
+ darkgreen: [0, 100 / 255, 0],
1739
+ darkgrey: [169 / 255, 169 / 255, 169 / 255],
1740
+ darkkhaki: [189 / 255, 183 / 255, 107 / 255],
1741
+ darkmagenta: [139 / 255, 0, 139 / 255],
1742
+ darkolivegreen: [85 / 255, 107 / 255, 47 / 255],
1743
+ darkorange: [1, 140 / 255, 0],
1744
+ darkorchid: [153 / 255, 50 / 255, 204 / 255],
1745
+ darkred: [139 / 255, 0, 0],
1746
+ darksalmon: [233 / 255, 150 / 255, 122 / 255],
1747
+ darkseagreen: [143 / 255, 188 / 255, 143 / 255],
1748
+ darkslateblue: [72 / 255, 61 / 255, 139 / 255],
1749
+ darkslategray: [47 / 255, 79 / 255, 79 / 255],
1750
+ darkslategrey: [47 / 255, 79 / 255, 79 / 255],
1751
+ darkturquoise: [0, 206 / 255, 209 / 255],
1752
+ darkviolet: [148 / 255, 0, 211 / 255],
1753
+ deeppink: [1, 20 / 255, 147 / 255],
1754
+ deepskyblue: [0, 191 / 255, 1],
1755
+ dimgray: [105 / 255, 105 / 255, 105 / 255],
1756
+ dimgrey: [105 / 255, 105 / 255, 105 / 255],
1757
+ dodgerblue: [30 / 255, 144 / 255, 1],
1758
+ firebrick: [178 / 255, 34 / 255, 34 / 255],
1759
+ floralwhite: [1, 250 / 255, 240 / 255],
1760
+ forestgreen: [34 / 255, 139 / 255, 34 / 255],
1761
+ fuchsia: [1, 0, 1],
1762
+ gainsboro: [220 / 255, 220 / 255, 220 / 255],
1763
+ ghostwhite: [248 / 255, 248 / 255, 1],
1764
+ gold: [1, 215 / 255, 0],
1765
+ goldenrod: [218 / 255, 165 / 255, 32 / 255],
1766
+ gray: [128 / 255, 128 / 255, 128 / 255],
1767
+ green: [0, 128 / 255, 0],
1768
+ greenyellow: [173 / 255, 1, 47 / 255],
1769
+ grey: [128 / 255, 128 / 255, 128 / 255],
1770
+ honeydew: [240 / 255, 1, 240 / 255],
1771
+ hotpink: [1, 105 / 255, 180 / 255],
1772
+ indianred: [205 / 255, 92 / 255, 92 / 255],
1773
+ indigo: [75 / 255, 0, 130 / 255],
1774
+ ivory: [1, 1, 240 / 255],
1775
+ khaki: [240 / 255, 230 / 255, 140 / 255],
1776
+ lavender: [230 / 255, 230 / 255, 250 / 255],
1777
+ lavenderblush: [1, 240 / 255, 245 / 255],
1778
+ lawngreen: [124 / 255, 252 / 255, 0],
1779
+ lemonchiffon: [1, 250 / 255, 205 / 255],
1780
+ lightblue: [173 / 255, 216 / 255, 230 / 255],
1781
+ lightcoral: [240 / 255, 128 / 255, 128 / 255],
1782
+ lightcyan: [224 / 255, 1, 1],
1783
+ lightgoldenrodyellow: [250 / 255, 250 / 255, 210 / 255],
1784
+ lightgray: [211 / 255, 211 / 255, 211 / 255],
1785
+ lightgreen: [144 / 255, 238 / 255, 144 / 255],
1786
+ lightgrey: [211 / 255, 211 / 255, 211 / 255],
1787
+ lightpink: [1, 182 / 255, 193 / 255],
1788
+ lightsalmon: [1, 160 / 255, 122 / 255],
1789
+ lightseagreen: [32 / 255, 178 / 255, 170 / 255],
1790
+ lightskyblue: [135 / 255, 206 / 255, 250 / 255],
1791
+ lightslategray: [119 / 255, 136 / 255, 153 / 255],
1792
+ lightslategrey: [119 / 255, 136 / 255, 153 / 255],
1793
+ lightsteelblue: [176 / 255, 196 / 255, 222 / 255],
1794
+ lightyellow: [1, 1, 224 / 255],
1795
+ lime: [0, 1, 0],
1796
+ limegreen: [50 / 255, 205 / 255, 50 / 255],
1797
+ linen: [250 / 255, 240 / 255, 230 / 255],
1798
+ magenta: [1, 0, 1],
1799
+ maroon: [128 / 255, 0, 0],
1800
+ mediumaquamarine: [102 / 255, 205 / 255, 170 / 255],
1801
+ mediumblue: [0, 0, 205 / 255],
1802
+ mediumorchid: [186 / 255, 85 / 255, 211 / 255],
1803
+ mediumpurple: [147 / 255, 112 / 255, 219 / 255],
1804
+ mediumseagreen: [60 / 255, 179 / 255, 113 / 255],
1805
+ mediumslateblue: [123 / 255, 104 / 255, 238 / 255],
1806
+ mediumspringgreen: [0, 250 / 255, 154 / 255],
1807
+ mediumturquoise: [72 / 255, 209 / 255, 204 / 255],
1808
+ mediumvioletred: [199 / 255, 21 / 255, 133 / 255],
1809
+ midnightblue: [25 / 255, 25 / 255, 112 / 255],
1810
+ mintcream: [245 / 255, 1, 250 / 255],
1811
+ mistyrose: [1, 228 / 255, 225 / 255],
1812
+ moccasin: [1, 228 / 255, 181 / 255],
1813
+ navajowhite: [1, 222 / 255, 173 / 255],
1814
+ navy: [0, 0, 128 / 255],
1815
+ oldlace: [253 / 255, 245 / 255, 230 / 255],
1816
+ olive: [128 / 255, 128 / 255, 0],
1817
+ olivedrab: [107 / 255, 142 / 255, 35 / 255],
1818
+ orange: [1, 165 / 255, 0],
1819
+ orangered: [1, 69 / 255, 0],
1820
+ orchid: [218 / 255, 112 / 255, 214 / 255],
1821
+ palegoldenrod: [238 / 255, 232 / 255, 170 / 255],
1822
+ palegreen: [152 / 255, 251 / 255, 152 / 255],
1823
+ paleturquoise: [175 / 255, 238 / 255, 238 / 255],
1824
+ palevioletred: [219 / 255, 112 / 255, 147 / 255],
1825
+ papayawhip: [1, 239 / 255, 213 / 255],
1826
+ peachpuff: [1, 218 / 255, 185 / 255],
1827
+ peru: [205 / 255, 133 / 255, 63 / 255],
1828
+ pink: [1, 192 / 255, 203 / 255],
1829
+ plum: [221 / 255, 160 / 255, 221 / 255],
1830
+ powderblue: [176 / 255, 224 / 255, 230 / 255],
1831
+ purple: [128 / 255, 0, 128 / 255],
1832
+ rebeccapurple: [102 / 255, 51 / 255, 153 / 255],
1833
+ red: [1, 0, 0],
1834
+ rosybrown: [188 / 255, 143 / 255, 143 / 255],
1835
+ royalblue: [65 / 255, 105 / 255, 225 / 255],
1836
+ saddlebrown: [139 / 255, 69 / 255, 19 / 255],
1837
+ salmon: [250 / 255, 128 / 255, 114 / 255],
1838
+ sandybrown: [244 / 255, 164 / 255, 96 / 255],
1839
+ seagreen: [46 / 255, 139 / 255, 87 / 255],
1840
+ seashell: [1, 245 / 255, 238 / 255],
1841
+ sienna: [160 / 255, 82 / 255, 45 / 255],
1842
+ silver: [192 / 255, 192 / 255, 192 / 255],
1843
+ skyblue: [135 / 255, 206 / 255, 235 / 255],
1844
+ slateblue: [106 / 255, 90 / 255, 205 / 255],
1845
+ slategray: [112 / 255, 128 / 255, 144 / 255],
1846
+ slategrey: [112 / 255, 128 / 255, 144 / 255],
1847
+ snow: [1, 250 / 255, 250 / 255],
1848
+ springgreen: [0, 1, 127 / 255],
1849
+ steelblue: [70 / 255, 130 / 255, 180 / 255],
1850
+ tan: [210 / 255, 180 / 255, 140 / 255],
1851
+ teal: [0, 128 / 255, 128 / 255],
1852
+ thistle: [216 / 255, 191 / 255, 216 / 255],
1853
+ tomato: [1, 99 / 255, 71 / 255],
1854
+ turquoise: [64 / 255, 224 / 255, 208 / 255],
1855
+ violet: [238 / 255, 130 / 255, 238 / 255],
1856
+ wheat: [245 / 255, 222 / 255, 179 / 255],
1857
+ white: [1, 1, 1],
1858
+ whitesmoke: [245 / 255, 245 / 255, 245 / 255],
1859
+ yellow: [1, 1, 0],
1860
+ yellowgreen: [154 / 255, 205 / 255, 50 / 255]
1861
+ };
1862
+ let h0 = Array(3).fill("<percentage> | <number>[0, 255]"), m0 = Array(3).fill("<number>[0, 255]");
1863
+ var oe = new O({
1864
+ id: "srgb",
1865
+ name: "sRGB",
1866
+ base: lr,
1867
+ fromBase: (t) => t.map((e) => {
1868
+ let r = e < 0 ? -1 : 1, n = e * r;
1869
+ return n > 31308e-7 ? r * (1.055 * n ** (1 / 2.4) - 0.055) : 12.92 * e;
1870
+ }),
1871
+ toBase: (t) => t.map((e) => {
1872
+ let r = e < 0 ? -1 : 1, n = e * r;
1873
+ return n <= 0.04045 ? e / 12.92 : r * ((n + 0.055) / 1.055) ** 2.4;
1874
+ }),
1875
+ formats: {
1876
+ rgb: {
1877
+ coords: h0
1878
+ },
1879
+ rgb_number: {
1880
+ name: "rgb",
1881
+ commas: !0,
1882
+ coords: m0,
1883
+ alpha: !1
1884
+ },
1885
+ color: {
1886
+ /* use defaults */
1887
+ },
1888
+ rgba: {
1889
+ coords: h0,
1890
+ commas: !0,
1891
+ alpha: !0
1892
+ },
1893
+ rgba_number: {
1894
+ name: "rgba",
1895
+ commas: !0,
1896
+ coords: m0
1897
+ },
1898
+ hex: {
1899
+ type: "custom",
1900
+ toGamut: !0,
1901
+ test: (t) => /^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(t),
1902
+ parse(t) {
1903
+ t.length <= 5 && (t = t.replace(/[a-f0-9]/gi, "$&$&"));
1904
+ let e = [];
1905
+ return t.replace(/[a-f0-9]{2}/gi, (r) => {
1906
+ e.push(parseInt(r, 16) / 255);
1907
+ }), {
1908
+ spaceId: "srgb",
1909
+ coords: (
1910
+ /** @type {Coords} */
1911
+ e.slice(0, 3)
1912
+ ),
1913
+ alpha: (
1914
+ /** @type {number} */
1915
+ e.slice(3)[0]
1916
+ )
1917
+ };
1918
+ },
1919
+ serialize: (t, e, {
1920
+ collapse: r = !0,
1921
+ // collapse to 3-4 digit hex when possible?
1922
+ alpha: n
1923
+ } = {}) => {
1924
+ (n !== !1 && e < 1 || n === !0) && t.push(e), t = /** @type {[number, number, number]} */
1925
+ t.map((i) => Math.round(i * 255));
1926
+ let a = r && t.every((i) => i % 17 === 0);
1927
+ return "#" + t.map((i) => a ? (i / 17).toString(16) : i.toString(16).padStart(2, "0")).join("");
1928
+ }
1929
+ },
1930
+ keyword: {
1931
+ type: "custom",
1932
+ test: (t) => /^[a-z]+$/i.test(t),
1933
+ parse(t) {
1934
+ t = t.toLowerCase();
1935
+ let e = { spaceId: "srgb", coords: null, alpha: 1 };
1936
+ if (t === "transparent" ? (e.coords = f0.black, e.alpha = 0) : e.coords = f0[t], e.coords)
1937
+ return e;
1938
+ }
1939
+ }
1940
+ }
1941
+ }), cr = new O({
1942
+ id: "p3",
1943
+ cssId: "display-p3",
1944
+ name: "P3",
1945
+ base: or,
1946
+ // Gamma encoding/decoding is the same as sRGB
1947
+ fromBase: oe.fromBase,
1948
+ toBase: oe.toBase
1949
+ });
1950
+ N.display_space = oe;
1951
+ let Tn;
1952
+ if (typeof CSS < "u" && CSS.supports)
1953
+ for (let t of [Y, ir, cr]) {
1954
+ let e = t.getMinCoords(), n = ve({ space: t, coords: e, alpha: 1 });
1955
+ if (CSS.supports("color", n)) {
1956
+ N.display_space = t;
1957
+ break;
1958
+ }
1959
+ }
1960
+ function Yn(t, { space: e = N.display_space, ...r } = {}) {
1961
+ t = C(t);
1962
+ let n = (
1963
+ /** @type {Display} */
1964
+ ve(t, r)
1965
+ );
1966
+ if (typeof CSS > "u" || CSS.supports(
1967
+ "color",
1968
+ /** @type {string} */
1969
+ n
1970
+ ) || !N.display_space)
1971
+ n = /** @type {Display} */
1972
+ new String(n), n.color = /** @type {PlainColorObject} */
1973
+ t;
1974
+ else {
1975
+ let a = (
1976
+ /** @type {PlainColorObject} */
1977
+ t
1978
+ );
1979
+ if ((t.coords.some(L) || L(t.alpha)) && !(Tn ??= CSS.supports("color", "hsl(none 50% 50%)")) && (a = pe(
1980
+ /** @type {PlainColorObject} */
1981
+ t
1982
+ ), a.coords = /** @type {[number, number, number]} */
1983
+ a.coords.map(z), a.alpha = z(a.alpha), n = ve(a, r), CSS.supports(
1984
+ "color",
1985
+ /** @type {string} */
1986
+ n
1987
+ )))
1988
+ return n = /** @type {Display} */
1989
+ new String(n), n.color = a, n;
1990
+ a = v(a, e), n = /** @type {Display} */
1991
+ new String(ve(a, r)), n.color = a;
1992
+ }
1993
+ return n;
1994
+ }
1995
+ function Nn(t, e, { space: r, hue: n = "shorter" } = {}) {
1996
+ t = C(t), r ||= t.space, r = g.get(r);
1997
+ let a = Object.values(r.coords);
1998
+ [t, e] = [t, e].map((c) => v(c, r));
1999
+ let [s, i] = [t, e].map((c) => c.coords), o = (
2000
+ /** @type {[number, number, number]} */
2001
+ s.map((c, f) => {
2002
+ let u = a[f], h = i[f];
2003
+ return u.type === "angle" && ([c, h] = J0(n, [c, h])), d0(c, h);
2004
+ })
2005
+ ), l = d0(t.alpha, e.alpha);
2006
+ return { space: (
2007
+ /** @type {ColorSpace} */
2008
+ r
2009
+ ), coords: o, alpha: l };
2010
+ }
2011
+ function d0(t, e) {
2012
+ return L(t) || L(e) ? t === e ? null : 0 : t - e;
2013
+ }
2014
+ function qn(t, e) {
2015
+ return t = C(t), e = C(e), t.space === e.space && t.alpha === e.alpha && t.coords.every((r, n) => r === e.coords[n]);
2016
+ }
2017
+ function ne(t) {
2018
+ return T(t, [A, "y"]);
2019
+ }
2020
+ function ur(t, e) {
2021
+ F(t, [A, "y"], e);
2022
+ }
2023
+ function Xn(t) {
2024
+ Object.defineProperty(t.prototype, "luminance", {
2025
+ get() {
2026
+ return ne(this);
2027
+ },
2028
+ set(e) {
2029
+ ur(this, e);
2030
+ }
2031
+ });
2032
+ }
2033
+ var Gn = /* @__PURE__ */ Object.freeze({
2034
+ __proto__: null,
2035
+ getLuminance: ne,
2036
+ register: Xn,
2037
+ setLuminance: ur
2038
+ });
2039
+ function Zn(t, e) {
2040
+ t = C(t), e = C(e);
2041
+ let r = Math.max(ne(t), 0), n = Math.max(ne(e), 0);
2042
+ return n > r && ([r, n] = [n, r]), (r + 0.05) / (n + 0.05);
2043
+ }
2044
+ const Jn = 0.56, Wn = 0.57, Fn = 0.62, Qn = 0.65, g0 = 0.022, Un = 1.414, Vn = 0.1, Kn = 5e-4, ea = 1.14, p0 = 0.027, ta = 1.14;
2045
+ function b0(t) {
2046
+ return t >= g0 ? t : t + (g0 - t) ** Un;
2047
+ }
2048
+ function fe(t) {
2049
+ let e = t < 0 ? -1 : 1, r = Math.abs(t);
2050
+ return e * Math.pow(r, 2.4);
2051
+ }
2052
+ function ra(t, e) {
2053
+ e = C(e), t = C(t);
2054
+ let r, n, a, s, i, o;
2055
+ e = v(e, "srgb"), [s, i, o] = e.coords.map((m) => L(m) ? 0 : m);
2056
+ let l = fe(s) * 0.2126729 + fe(i) * 0.7151522 + fe(o) * 0.072175;
2057
+ t = v(t, "srgb"), [s, i, o] = t.coords.map((m) => L(m) ? 0 : m);
2058
+ let c = fe(s) * 0.2126729 + fe(i) * 0.7151522 + fe(o) * 0.072175, f = b0(l), u = b0(c), h = u > f;
2059
+ return Math.abs(u - f) < Kn ? n = 0 : h ? (r = u ** Jn - f ** Wn, n = r * ea) : (r = u ** Qn - f ** Fn, n = r * ta), Math.abs(n) < Vn ? a = 0 : n > 0 ? a = n - p0 : a = n + p0, a * 100;
2060
+ }
2061
+ function na(t, e) {
2062
+ t = C(t), e = C(e);
2063
+ let r = Math.max(ne(t), 0), n = Math.max(ne(e), 0);
2064
+ n > r && ([r, n] = [n, r]);
2065
+ let a = r + n;
2066
+ return a === 0 ? 0 : (r - n) / a;
2067
+ }
2068
+ const aa = 5e4;
2069
+ function sa(t, e) {
2070
+ t = C(t), e = C(e);
2071
+ let r = Math.max(ne(t), 0), n = Math.max(ne(e), 0);
2072
+ return n > r && ([r, n] = [n, r]), n === 0 ? aa : (r - n) / n;
2073
+ }
2074
+ function ia(t, e) {
2075
+ t = C(t), e = C(e);
2076
+ let r = T(t, [Y, "l"]), n = T(e, [Y, "l"]);
2077
+ return Math.abs(r - n);
2078
+ }
2079
+ const oa = 216 / 24389, M0 = 24 / 116, Te = 24389 / 27;
2080
+ let mt = P.D65;
2081
+ var Bt = new g({
2082
+ id: "lab-d65",
2083
+ name: "Lab D65",
2084
+ coords: {
2085
+ l: {
2086
+ refRange: [0, 100],
2087
+ name: "Lightness"
2088
+ },
2089
+ a: {
2090
+ refRange: [-125, 125]
2091
+ },
2092
+ b: {
2093
+ refRange: [-125, 125]
2094
+ }
2095
+ },
2096
+ // Assuming XYZ is relative to D65, convert to CIE Lab
2097
+ // from CIE standard, which now defines these as a rational fraction
2098
+ white: mt,
2099
+ base: A,
2100
+ // Convert D65-adapted XYZ to Lab
2101
+ // CIE 15.3:2004 section 8.2.1.1
2102
+ fromBase(t) {
2103
+ let r = t.map((n, a) => n / mt[a]).map((n) => n > oa ? Math.cbrt(n) : (Te * n + 16) / 116);
2104
+ return [
2105
+ 116 * r[1] - 16,
2106
+ // L
2107
+ 500 * (r[0] - r[1]),
2108
+ // a
2109
+ 200 * (r[1] - r[2])
2110
+ // b
2111
+ ];
2112
+ },
2113
+ // Convert Lab to D65-adapted XYZ
2114
+ // Same result as CIE 15.3:2004 Appendix D although the derivation is different
2115
+ // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
2116
+ toBase(t) {
2117
+ let e = [];
2118
+ return e[1] = (t[0] + 16) / 116, e[0] = t[1] / 500 + e[1], e[2] = e[1] - t[2] / 200, [
2119
+ e[0] > M0 ? Math.pow(e[0], 3) : (116 * e[0] - 16) / Te,
2120
+ t[0] > 8 ? Math.pow((t[0] + 16) / 116, 3) : t[0] / Te,
2121
+ e[2] > M0 ? Math.pow(e[2], 3) : (116 * e[2] - 16) / Te
2122
+ ].map((n, a) => n * mt[a]);
2123
+ },
2124
+ formats: {
2125
+ "lab-d65": {
2126
+ coords: [
2127
+ "<number> | <percentage>",
2128
+ "<number> | <percentage>",
2129
+ "<number> | <percentage>"
2130
+ ]
2131
+ }
2132
+ }
2133
+ });
2134
+ const dt = Math.pow(5, 0.5) * 0.5 + 0.5;
2135
+ function la(t, e) {
2136
+ t = C(t), e = C(e);
2137
+ let r = T(t, [Bt, "l"]), n = T(e, [Bt, "l"]), a = Math.abs(Math.pow(r, dt) - Math.pow(n, dt)), s = Math.pow(a, 1 / dt) * Math.SQRT2 - 40;
2138
+ return s < 7.5 ? 0 : s;
2139
+ }
2140
+ var Xe = /* @__PURE__ */ Object.freeze({
2141
+ __proto__: null,
2142
+ contrastAPCA: ra,
2143
+ contrastDeltaPhi: la,
2144
+ contrastLstar: ia,
2145
+ contrastMichelson: na,
2146
+ contrastWCAG21: Zn,
2147
+ contrastWeber: sa
2148
+ });
2149
+ function ca(t, e, r) {
2150
+ ye(r) && (r = { algorithm: r });
2151
+ let { algorithm: n, ...a } = r || {};
2152
+ if (!n) {
2153
+ let s = Object.keys(Xe).map((i) => i.replace(/^contrast/, "")).join(", ");
2154
+ throw new TypeError(
2155
+ `contrast() function needs a contrast algorithm. Please specify one of: ${s}`
2156
+ );
2157
+ }
2158
+ t = C(t), e = C(e);
2159
+ for (let s in Xe)
2160
+ if ("contrast" + n.toLowerCase() === s.toLowerCase())
2161
+ return Xe[s](t, e, a);
2162
+ throw new TypeError(`Unknown contrast algorithm: ${n}`);
2163
+ }
2164
+ function rt(t) {
2165
+ let [e, r, n] = ke(t, A), a = e + 15 * r + 3 * n;
2166
+ return [4 * e / a, 9 * r / a];
2167
+ }
2168
+ function fr(t) {
2169
+ let [e, r, n] = ke(t, A), a = e + r + n;
2170
+ return [e / a, r / a];
2171
+ }
2172
+ function ua(t) {
2173
+ Object.defineProperty(t.prototype, "uv", {
2174
+ get() {
2175
+ return rt(this);
2176
+ }
2177
+ }), Object.defineProperty(t.prototype, "xy", {
2178
+ get() {
2179
+ return fr(this);
2180
+ }
2181
+ });
2182
+ }
2183
+ var fa = /* @__PURE__ */ Object.freeze({
2184
+ __proto__: null,
2185
+ register: ua,
2186
+ uv: rt,
2187
+ xy: fr
2188
+ });
2189
+ function Le(t, e, r = {}) {
2190
+ ye(r) && (r = { method: r });
2191
+ let { method: n = N.deltaE, ...a } = r;
2192
+ for (let s in be)
2193
+ if ("deltae" + n.toLowerCase() === s.toLowerCase())
2194
+ return be[s](t, e, a);
2195
+ throw new TypeError(`Unknown deltaE method: ${n}`);
2196
+ }
2197
+ function hr(t, e = 0.25) {
2198
+ let n = [g.get("oklch", "lch"), "l"];
2199
+ return F(t, n, (a) => a * (1 + e));
2200
+ }
2201
+ function mr(t, e = 0.25) {
2202
+ let n = [g.get("oklch", "lch"), "l"];
2203
+ return F(t, n, (a) => a * (1 - e));
2204
+ }
2205
+ hr.returns = "color";
2206
+ mr.returns = "color";
2207
+ var ha = /* @__PURE__ */ Object.freeze({
2208
+ __proto__: null,
2209
+ darken: mr,
2210
+ lighten: hr
2211
+ });
2212
+ function dr(t, e, r, n = {}) {
2213
+ return [t, e] = [C(t), C(e)], K(r) === "object" && ([r, n] = [0.5, r]), $e(t, e, n)(r ?? 0.5);
2214
+ }
2215
+ function gr(t, e, r = {}) {
2216
+ let n;
2217
+ Ht(t) && ([n, r] = [t, e], [t, e] = n.rangeArgs.colors);
2218
+ let { maxDeltaE: a, deltaEMethod: s, steps: i = 2, maxSteps: o = 1e3, ...l } = r;
2219
+ n || ([t, e] = [C(t), C(e)], n = $e(t, e, l));
2220
+ let c = Le(t, e), f = a > 0 ? Math.max(i, Math.ceil(c / a) + 1) : i, u = [];
2221
+ if (o !== void 0 && (f = Math.min(f, o)), f === 1)
2222
+ u = [{ p: 0.5, color: n(0.5) }];
2223
+ else {
2224
+ let h = 1 / (f - 1);
2225
+ u = Array.from({ length: f }, (m, d) => {
2226
+ let M = d * h;
2227
+ return { p: M, color: n(M) };
2228
+ });
2229
+ }
2230
+ if (a > 0) {
2231
+ let h = u.reduce((m, d, M) => {
2232
+ if (M === 0)
2233
+ return 0;
2234
+ let p = Le(d.color, u[M - 1].color, s);
2235
+ return Math.max(m, p);
2236
+ }, 0);
2237
+ for (; h > a; ) {
2238
+ h = 0;
2239
+ for (let m = 1; m < u.length && u.length < o; m++) {
2240
+ let d = u[m - 1], M = u[m], p = (M.p + d.p) / 2, w = n(p);
2241
+ h = Math.max(h, Le(w, d.color), Le(w, M.color)), u.splice(m, 0, { p, color: n(p) }), m++;
2242
+ }
2243
+ }
2244
+ }
2245
+ return u = u.map((h) => h.color), u;
2246
+ }
2247
+ function $e(t, e, r = {}) {
2248
+ if (Ht(t)) {
2249
+ let [l, c] = [t, e];
2250
+ return $e(...l.rangeArgs.colors, { ...l.rangeArgs.options, ...c });
2251
+ }
2252
+ let { space: n, outputSpace: a, progression: s, premultiplied: i } = r;
2253
+ t = C(t), e = C(e), t = pe(t), e = pe(e);
2254
+ let o = { colors: [t, e], options: r };
2255
+ if (n ? n = g.get(n) : n = g.registry[N.interpolationSpace] || t.space, a = a ? g.get(a) : n, t = v(t, n), e = v(e, n), t = re(t), e = re(e), n.coords.h && n.coords.h.type === "angle") {
2256
+ let l = r.hue = r.hue || "shorter", c = [n, "h"], [f, u] = [T(t, c), T(e, c)];
2257
+ L(f) && !L(u) ? f = u : L(u) && !L(f) && (u = f), [f, u] = J0(l, [f, u]), F(t, c, f), F(e, c, u);
2258
+ }
2259
+ return i && (t.coords = /** @type {[number, number, number]} */
2260
+ t.coords.map((l) => l * t.alpha), e.coords = /** @type {[number, number, number]} */
2261
+ e.coords.map((l) => l * e.alpha)), Object.assign(
2262
+ (l) => {
2263
+ l = s ? s(l) : l;
2264
+ let c = t.coords.map((h, m) => {
2265
+ let d = e.coords[m];
2266
+ return Be(h, d, l);
2267
+ }), f = Be(t.alpha, e.alpha, l), u = { space: n, coords: c, alpha: f };
2268
+ return i && (u.coords = u.coords.map((h) => h / f)), a !== n && (u = v(u, a)), u;
2269
+ },
2270
+ {
2271
+ rangeArgs: o
2272
+ }
2273
+ );
2274
+ }
2275
+ function Ht(t) {
2276
+ return K(t) === "function" && !!t.rangeArgs;
2277
+ }
2278
+ N.interpolationSpace = "lab";
2279
+ function ma(t) {
2280
+ t.defineFunction("mix", dr, { returns: "color" }), t.defineFunction("range", $e, { returns: "function<color>" }), t.defineFunction("steps", gr, { returns: "array<color>" });
2281
+ }
2282
+ var da = /* @__PURE__ */ Object.freeze({
2283
+ __proto__: null,
2284
+ isRange: Ht,
2285
+ mix: dr,
2286
+ range: $e,
2287
+ register: ma,
2288
+ steps: gr
2289
+ }), ga = new g({
2290
+ id: "hsl",
2291
+ name: "HSL",
2292
+ coords: {
2293
+ h: {
2294
+ refRange: [0, 360],
2295
+ type: "angle",
2296
+ name: "Hue"
2297
+ },
2298
+ s: {
2299
+ range: [0, 100],
2300
+ name: "Saturation"
2301
+ },
2302
+ l: {
2303
+ range: [0, 100],
2304
+ name: "Lightness"
2305
+ }
2306
+ },
2307
+ base: oe,
2308
+ // Adapted from https://drafts.csswg.org/css-color-4/better-rgbToHsl.js
2309
+ fromBase: (t) => {
2310
+ let e = Math.max(...t), r = Math.min(...t), [n, a, s] = t, [i, o, l] = [null, 0, (r + e) / 2], c = e - r;
2311
+ if (c !== 0) {
2312
+ switch (o = l === 0 || l === 1 ? 0 : (e - l) / Math.min(l, 1 - l), e) {
2313
+ case n:
2314
+ i = (a - s) / c + (a < s ? 6 : 0);
2315
+ break;
2316
+ case a:
2317
+ i = (s - n) / c + 2;
2318
+ break;
2319
+ case s:
2320
+ i = (n - a) / c + 4;
2321
+ }
2322
+ i = i * 60;
2323
+ }
2324
+ return o < 0 && (i += 180, o = Math.abs(o)), i >= 360 && (i -= 360), [i, o * 100, l * 100];
2325
+ },
2326
+ // Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative
2327
+ toBase: (t) => {
2328
+ let [e, r, n] = t;
2329
+ e = e % 360, e < 0 && (e += 360), r /= 100, n /= 100;
2330
+ function a(s) {
2331
+ let i = (s + e / 30) % 12, o = r * Math.min(n, 1 - n);
2332
+ return n - o * Math.max(-1, Math.min(i - 3, 9 - i, 1));
2333
+ }
2334
+ return [a(0), a(8), a(4)];
2335
+ },
2336
+ formats: {
2337
+ hsl: {
2338
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2339
+ },
2340
+ hsla: {
2341
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"],
2342
+ commas: !0,
2343
+ alpha: !0
2344
+ }
2345
+ }
2346
+ }), pr = new g({
2347
+ id: "hsv",
2348
+ name: "HSV",
2349
+ coords: {
2350
+ h: {
2351
+ refRange: [0, 360],
2352
+ type: "angle",
2353
+ name: "Hue"
2354
+ },
2355
+ s: {
2356
+ range: [0, 100],
2357
+ name: "Saturation"
2358
+ },
2359
+ v: {
2360
+ range: [0, 100],
2361
+ name: "Value"
2362
+ }
2363
+ },
2364
+ base: oe,
2365
+ // https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
2366
+ fromBase(t) {
2367
+ let e = Math.max(...t), r = Math.min(...t), [n, a, s] = t, [i, o, l] = [null, 0, e], c = e - r;
2368
+ if (c !== 0) {
2369
+ switch (e) {
2370
+ case n:
2371
+ i = (a - s) / c + (a < s ? 6 : 0);
2372
+ break;
2373
+ case a:
2374
+ i = (s - n) / c + 2;
2375
+ break;
2376
+ case s:
2377
+ i = (n - a) / c + 4;
2378
+ }
2379
+ i = i * 60;
2380
+ }
2381
+ return l && (o = c / l), i >= 360 && (i -= 360), [i, o * 100, l * 100];
2382
+ },
2383
+ // Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative
2384
+ toBase(t) {
2385
+ let [e, r, n] = t;
2386
+ e = e % 360, e < 0 && (e += 360), r /= 100, n /= 100;
2387
+ function a(s) {
2388
+ let i = (s + e / 60) % 6;
2389
+ return n - n * r * Math.max(0, Math.min(i, 4 - i, 1));
2390
+ }
2391
+ return [a(5), a(3), a(1)];
2392
+ },
2393
+ formats: {
2394
+ color: {
2395
+ id: "--hsv",
2396
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2397
+ }
2398
+ }
2399
+ }), pa = new g({
2400
+ id: "hwb",
2401
+ name: "HWB",
2402
+ coords: {
2403
+ h: {
2404
+ refRange: [0, 360],
2405
+ type: "angle",
2406
+ name: "Hue"
2407
+ },
2408
+ w: {
2409
+ range: [0, 100],
2410
+ name: "Whiteness"
2411
+ },
2412
+ b: {
2413
+ range: [0, 100],
2414
+ name: "Blackness"
2415
+ }
2416
+ },
2417
+ base: pr,
2418
+ fromBase(t) {
2419
+ let [e, r, n] = t;
2420
+ return [e, n * (100 - r) / 100, 100 - n];
2421
+ },
2422
+ toBase(t) {
2423
+ let [e, r, n] = t;
2424
+ r /= 100, n /= 100;
2425
+ let a = r + n;
2426
+ if (a >= 1) {
2427
+ let o = r / a;
2428
+ return [e, 0, o * 100];
2429
+ }
2430
+ let s = 1 - n, i = s === 0 ? 0 : 1 - r / s;
2431
+ return [e, i * 100, s * 100];
2432
+ },
2433
+ formats: {
2434
+ hwb: {
2435
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2436
+ }
2437
+ }
2438
+ });
2439
+ const ba = [
2440
+ [0.5766690429101305, 0.1855582379065463, 0.1882286462349947],
2441
+ [0.29734497525053605, 0.6273635662554661, 0.07529145849399788],
2442
+ [0.02703136138641234, 0.07068885253582723, 0.9913375368376388]
2443
+ ], Ma = [
2444
+ [2.0415879038107465, -0.5650069742788596, -0.34473135077832956],
2445
+ [-0.9692436362808795, 1.8759675015077202, 0.04155505740717557],
2446
+ [0.013444280632031142, -0.11836239223101838, 1.0151749943912054]
2447
+ ];
2448
+ var br = new O({
2449
+ id: "a98rgb-linear",
2450
+ cssId: "--a98-rgb-linear",
2451
+ name: "Linear Adobe® 98 RGB compatible",
2452
+ white: "D65",
2453
+ toXYZ_M: ba,
2454
+ fromXYZ_M: Ma
2455
+ }), ya = new O({
2456
+ id: "a98rgb",
2457
+ cssId: "a98-rgb",
2458
+ name: "Adobe® 98 RGB compatible",
2459
+ base: br,
2460
+ toBase: (t) => t.map((e) => Math.pow(Math.abs(e), 563 / 256) * Math.sign(e)),
2461
+ fromBase: (t) => t.map((e) => Math.pow(Math.abs(e), 256 / 563) * Math.sign(e))
2462
+ });
2463
+ const wa = [
2464
+ [0.7977666449006423, 0.13518129740053308, 0.0313477341283922],
2465
+ [0.2880748288194013, 0.711835234241873, 8993693872564e-17],
2466
+ [0, 0, 0.8251046025104602]
2467
+ ], Ca = [
2468
+ [1.3457868816471583, -0.25557208737979464, -0.05110186497554526],
2469
+ [-0.5446307051249019, 1.5082477428451468, 0.02052744743642139],
2470
+ [0, 0, 1.2119675456389452]
2471
+ ];
2472
+ var Mr = new O({
2473
+ id: "prophoto-linear",
2474
+ cssId: "--prophoto-rgb-linear",
2475
+ name: "Linear ProPhoto",
2476
+ white: "D50",
2477
+ base: Ot,
2478
+ toXYZ_M: wa,
2479
+ fromXYZ_M: Ca
2480
+ });
2481
+ const _a = 1 / 512, La = 16 / 512;
2482
+ var Ra = new O({
2483
+ id: "prophoto",
2484
+ cssId: "prophoto-rgb",
2485
+ name: "ProPhoto",
2486
+ base: Mr,
2487
+ toBase(t) {
2488
+ return t.map((e) => {
2489
+ let r = e < 0 ? -1 : 1, n = e * r;
2490
+ return n < La ? e / 16 : r * n ** 1.8;
2491
+ });
2492
+ },
2493
+ fromBase(t) {
2494
+ return t.map((e) => {
2495
+ let r = e < 0 ? -1 : 1, n = e * r;
2496
+ return n >= _a ? r * n ** (1 / 1.8) : 16 * e;
2497
+ });
2498
+ }
2499
+ });
2500
+ const Ye = 1.09929682680944, y0 = 0.018053968510807;
2501
+ var va = new O({
2502
+ id: "--rec2020-oetf",
2503
+ name: "REC.2020_Scene_Referred",
2504
+ base: Ee,
2505
+ referred: "scene",
2506
+ // Non-linear transfer function from Rec. ITU-R BT.2020-2 table 4
2507
+ toBase(t) {
2508
+ return t.map(function(e) {
2509
+ let r = e < 0 ? -1 : 1, n = e * r;
2510
+ return n < y0 * 4.5 ? e / 4.5 : r * Math.pow((n + Ye - 1) / Ye, 1 / 0.45);
2511
+ });
2512
+ },
2513
+ fromBase(t) {
2514
+ return t.map(function(e) {
2515
+ let r = e < 0 ? -1 : 1, n = e * r;
2516
+ return n >= y0 ? r * (Ye * Math.pow(n, 0.45) - (Ye - 1)) : 4.5 * e;
2517
+ });
2518
+ }
2519
+ }), Sa = new g({
2520
+ id: "oklch",
2521
+ name: "OkLCh",
2522
+ coords: {
2523
+ l: {
2524
+ refRange: [0, 1],
2525
+ name: "Lightness"
2526
+ },
2527
+ c: {
2528
+ refRange: [0, 0.4],
2529
+ name: "Chroma"
2530
+ },
2531
+ h: {
2532
+ refRange: [0, 360],
2533
+ type: "angle",
2534
+ name: "Hue"
2535
+ }
2536
+ },
2537
+ white: "D65",
2538
+ base: Z,
2539
+ fromBase: q.fromBase,
2540
+ toBase: q.toBase,
2541
+ formats: {
2542
+ oklch: {
2543
+ coords: ["<percentage> | <number>", "<number> | <percentage>", "<number> | <angle>"]
2544
+ }
2545
+ }
2546
+ });
2547
+ const Me = 2 * Math.PI, Qe = [
2548
+ [4.076741636075958, -3.307711539258063, 0.2309699031821043],
2549
+ [-1.2684379732850315, 2.609757349287688, -0.341319376002657],
2550
+ [-0.0041960761386756, -0.7034186179359362, 1.7076146940746117]
2551
+ ], Ue = [
2552
+ // Red
2553
+ [
2554
+ // Limit
2555
+ [-1.8817031, -0.80936501],
2556
+ // `Kn` coefficients
2557
+ [1.19086277, 1.76576728, 0.59662641, 0.75515197, 0.56771245]
2558
+ ],
2559
+ // Green
2560
+ [
2561
+ // Limit
2562
+ [1.8144408, -1.19445267],
2563
+ // `Kn` coefficients
2564
+ [0.73956515, -0.45954404, 0.08285427, 0.12541073, -0.14503204]
2565
+ ],
2566
+ // Blue
2567
+ [
2568
+ // Limit
2569
+ [0.13110758, 1.81333971],
2570
+ // `Kn` coefficients
2571
+ [1.35733652, -915799e-8, -1.1513021, -0.50559606, 692167e-8]
2572
+ ]
2573
+ ], gt = Number.MAX_VALUE, Se = 0.206, jt = 0.03, Re = (1 + Se) / (1 + jt);
2574
+ function $(t, e) {
2575
+ let r = t.length;
2576
+ if (r !== e.length)
2577
+ throw new Error(`Vectors of size ${r} and ${e.length} are not aligned`);
2578
+ let n = 0;
2579
+ return t.forEach((a, s) => {
2580
+ n += a * e[s];
2581
+ }), n;
2582
+ }
2583
+ function xe(t) {
2584
+ return 0.5 * (Re * t - Se + Math.sqrt((Re * t - Se) * (Re * t - Se) + 4 * jt * Re * t));
2585
+ }
2586
+ function de(t) {
2587
+ return (t ** 2 + Se * t) / (Re * (t + jt));
2588
+ }
2589
+ function Dt(t) {
2590
+ let [e, r] = t;
2591
+ return [r / e, r / (1 - e)];
2592
+ }
2593
+ function xa(t, e) {
2594
+ let r = 0.11516993 + 1 / (7.4477897 + 4.1590124 * e + t * (-2.19557347 + 1.75198401 * e + t * (-2.13704948 - 10.02301043 * e + t * (-4.24894561 + 5.38770819 * e + 4.69891013 * t)))), n = 0.11239642 + 1 / (1.6132032 - 0.68124379 * e + t * (0.40370612 + 0.90148123 * e + t * (-0.27087943 + 0.6122399 * e + t * (299215e-8 - 0.45399568 * e - 0.14661872 * t))));
2595
+ return [r, n];
2596
+ }
2597
+ function Tt(t, e) {
2598
+ let r = x(t, ee);
2599
+ return r[0] = r[0] ** 3, r[1] = r[1] ** 3, r[2] = r[2] ** 3, x(r, e, r);
2600
+ }
2601
+ function nt(t, e, r, n) {
2602
+ let a = za(t, e, r, n), s = Tt([1, a * t, a * e], r), i = E(1 / Math.max(...s), 1 / 3), o = i * a;
2603
+ return [i, o];
2604
+ }
2605
+ function Ba(t, e, r, n, a, s, i, o) {
2606
+ let l;
2607
+ if (o === void 0 && (o = nt(t, e, s, i)), (r - a) * o[1] - (o[0] - a) * n <= 0)
2608
+ l = o[1] * a / (n * o[0] + o[1] * (a - r));
2609
+ else {
2610
+ l = o[1] * (a - 1) / (n * (o[0] - 1) + o[1] * (a - r));
2611
+ let c = r - a, f = n, u = $(ee[0].slice(1), [t, e]), h = $(ee[1].slice(1), [t, e]), m = $(ee[2].slice(1), [t, e]), d = c + f * u, M = c + f * h, p = c + f * m, w = a * (1 - l) + l * r, b = l * n, y = w + b * u, _ = w + b * h, S = w + b * m, I = y ** 3, H = _ ** 3, B = S ** 3, j = 3 * d * y ** 2, Q = 3 * M * _ ** 2, G = 3 * p * S ** 2, J = 6 * d ** 2 * y, U = 6 * M ** 2 * _, W = 6 * p ** 2 * S, we = $(s[0], [I, H, B]) - 1, D = $(s[0], [j, Q, G]), Ae = $(s[0], [J, U, W]), Oe = D / (D * D - 0.5 * we * Ae), le = -we * Oe, V = $(s[1], [I, H, B]) - 1, ce = $(s[1], [j, Q, G]), st = $(s[1], [J, U, W]), Pe = ce / (ce * ce - 0.5 * V * st), Ce = -V * Pe, ae = $(s[2], [I, H, B]) - 1, it = $(s[2], [j, Q, G]), zr = $(s[2], [J, U, W]), qt = it / (it * it - 0.5 * ae * zr), ot = -ae * qt;
2612
+ le = Oe >= 0 ? le : gt, Ce = Pe >= 0 ? Ce : gt, ot = qt >= 0 ? ot : gt, l += Math.min(le, Math.min(Ce, ot));
2613
+ }
2614
+ return l;
2615
+ }
2616
+ function yr(t, e, r) {
2617
+ let [n, a, s] = t, i = nt(a, s, e, r), o = Ba(a, s, n, 1, n, e, r, i), l = Dt(i), c = o / Math.min(n * l[0], (1 - n) * l[1]), f = xa(a, s), u = n * f[0], h = (1 - n) * f[1], m = 0.9 * c * Math.sqrt(Math.sqrt(1 / (1 / u ** 4 + 1 / h ** 4)));
2618
+ return u = n * 0.4, h = (1 - n) * 0.8, [Math.sqrt(1 / (1 / u ** 2 + 1 / h ** 2)), m, o];
2619
+ }
2620
+ function za(t, e, r, n) {
2621
+ let a, s, i, o, l, c, f, u;
2622
+ $(n[0][0], [t, e]) > 1 ? ([a, s, i, o, l] = n[0][1], [c, f, u] = r[0]) : $(n[1][0], [t, e]) > 1 ? ([a, s, i, o, l] = n[1][1], [c, f, u] = r[1]) : ([a, s, i, o, l] = n[2][1], [c, f, u] = r[2]);
2623
+ let h = a + s * t + i * e + o * t ** 2 + l * t * e, m = $(ee[0].slice(1), [t, e]), d = $(ee[1].slice(1), [t, e]), M = $(ee[2].slice(1), [t, e]), p = 1 + h * m, w = 1 + h * d, b = 1 + h * M, y = p ** 3, _ = w ** 3, S = b ** 3, I = 3 * m * p ** 2, H = 3 * d * w ** 2, B = 3 * M * b ** 2, j = 6 * m ** 2 * p, Q = 6 * d ** 2 * w, G = 6 * M ** 2 * b, J = c * y + f * _ + u * S, U = c * I + f * H + u * B, W = c * j + f * Q + u * G;
2624
+ return h = h - J * U / (U ** 2 - 0.5 * J * W), h;
2625
+ }
2626
+ function Ea(t, e, r) {
2627
+ let [n, a, s] = t, i = de(s), o = null, l = null;
2628
+ if (n = X(n) / 360, i !== 0 && i !== 1 && a !== 0) {
2629
+ let c = Math.cos(Me * n), f = Math.sin(Me * n), [u, h, m] = yr([i, c, f], e, r), d = 0.8, M = 1.25, p, w, b, y;
2630
+ a < d ? (p = M * a, w = 0, b = d * u, y = 1 - b / h) : (p = 5 * (a - 0.8), w = h, b = 0.2 * h ** 2 * 1.25 ** 2 / u, y = 1 - b / (m - h));
2631
+ let _ = w + p * b / (1 - y * p);
2632
+ o = _ * c, l = _ * f;
2633
+ }
2634
+ return [i, o, l];
2635
+ }
2636
+ function ka(t, e, r) {
2637
+ let n = 1e-7, a = 1e-4, s = t[0], i = 0, o = xe(s), l = Math.sqrt(t[1] ** 2 + t[2] ** 2), c = 0.5 + Math.atan2(-t[2], -t[1]) / Me;
2638
+ if (o !== 0 && o !== 1 && l !== 0) {
2639
+ let u = t[1] / l, h = t[2] / l, [m, d, M] = yr([s, u, h], e, r), p = 0.8, w = 1.25, b, y, _, S;
2640
+ l < d ? (y = p * m, _ = 1 - y / d, S = l / (y + _ * l), i = S * p) : (b = d, y = 0.2 * d ** 2 * w ** 2 / m, _ = 1 - y / (M - d), S = (l - b) / (y + _ * (l - b)), i = p + 0.2 * S);
2641
+ }
2642
+ const f = Math.abs(i) < a;
2643
+ return f || o === 0 || Math.abs(1 - o) < n ? (c = null, f || (i = 0)) : c = X(c * 360), [c, i, o];
2644
+ }
2645
+ var $a = new g({
2646
+ id: "okhsl",
2647
+ name: "Okhsl",
2648
+ coords: {
2649
+ h: {
2650
+ refRange: [0, 360],
2651
+ type: "angle",
2652
+ name: "Hue"
2653
+ },
2654
+ s: {
2655
+ range: [0, 1],
2656
+ name: "Saturation"
2657
+ },
2658
+ l: {
2659
+ range: [0, 1],
2660
+ name: "Lightness"
2661
+ }
2662
+ },
2663
+ base: Z,
2664
+ gamutSpace: "self",
2665
+ // Convert Oklab to Okhsl
2666
+ fromBase(t) {
2667
+ return ka(t, Qe, Ue);
2668
+ },
2669
+ // Convert Okhsl to Oklab
2670
+ toBase(t) {
2671
+ return Ea(t, Qe, Ue);
2672
+ },
2673
+ formats: {
2674
+ color: {
2675
+ id: "--okhsl",
2676
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2677
+ }
2678
+ }
2679
+ }), wr = new g({
2680
+ id: "oklrab",
2681
+ name: "Oklrab",
2682
+ coords: {
2683
+ l: {
2684
+ refRange: [0, 1],
2685
+ name: "Lightness"
2686
+ },
2687
+ a: {
2688
+ refRange: [-0.4, 0.4]
2689
+ },
2690
+ b: {
2691
+ refRange: [-0.4, 0.4]
2692
+ }
2693
+ },
2694
+ // Note that XYZ is relative to D65
2695
+ white: "D65",
2696
+ base: Z,
2697
+ fromBase(t) {
2698
+ return [xe(t[0]), t[1], t[2]];
2699
+ },
2700
+ toBase(t) {
2701
+ return [de(t[0]), t[1], t[2]];
2702
+ },
2703
+ formats: {
2704
+ color: {
2705
+ coords: [
2706
+ "<percentage> | <number>",
2707
+ "<number> | <percentage>[-1,1]",
2708
+ "<number> | <percentage>[-1,1]"
2709
+ ]
2710
+ }
2711
+ }
2712
+ }), Aa = new g({
2713
+ id: "oklrch",
2714
+ name: "Oklrch",
2715
+ coords: {
2716
+ l: {
2717
+ refRange: [0, 1],
2718
+ name: "Lightness"
2719
+ },
2720
+ c: {
2721
+ refRange: [0, 0.4],
2722
+ name: "Chroma"
2723
+ },
2724
+ h: {
2725
+ refRange: [0, 360],
2726
+ type: "angle",
2727
+ name: "Hue"
2728
+ }
2729
+ },
2730
+ white: "D65",
2731
+ base: wr,
2732
+ fromBase: q.fromBase,
2733
+ toBase: q.toBase,
2734
+ formats: {
2735
+ color: {
2736
+ coords: [
2737
+ "<percentage> | <number>",
2738
+ "<number> | <percentage>[0,1]",
2739
+ "<number> | <angle>"
2740
+ ]
2741
+ }
2742
+ }
2743
+ });
2744
+ function Oa(t, e, r) {
2745
+ let [n, a, s] = t;
2746
+ n = X(n) / 360;
2747
+ let i = de(s), o = null, l = null;
2748
+ if (i !== 0 && a !== 0) {
2749
+ let c = Math.cos(Me * n), f = Math.sin(Me * n), u = nt(c, f, e, r), [h, m] = Dt(u), d = 0.5, M = 1 - d / h, p = 1 - a * d / (d + m - m * M * a), w = a * m * d / (d + m - m * M * a);
2750
+ i = s * p;
2751
+ let b = s * w, y = de(p), _ = w * y / p, S = de(i);
2752
+ b = b * S / i, i = S;
2753
+ let [I, H, B] = Tt([y, c * _, f * _], e), j = E(1 / Math.max(Math.max(I, H), Math.max(B, 0)), 1 / 3);
2754
+ i = i * j, b = b * j, o = b * c, l = b * f;
2755
+ }
2756
+ return [i, o, l];
2757
+ }
2758
+ function Pa(t, e, r) {
2759
+ let n = 1e-4, a = t[0], s = 0, i = xe(a), o = Math.sqrt(t[1] ** 2 + t[2] ** 2), l = 0.5 + Math.atan2(-t[2], -t[1]) / Me;
2760
+ if (a !== 0 && a !== 1 && o !== 0) {
2761
+ let c = t[1] / o, f = t[2] / o, u = nt(c, f, e, r), [h, m] = Dt(u), d = 0.5, M = 1 - d / h, p = m / (o + a * m), w = p * a, b = p * o, y = de(w), _ = b * y / w, [S, I, H] = Tt([y, c * _, f * _], e), B = E(1 / Math.max(Math.max(S, I), Math.max(H, 0)), 1 / 3);
2762
+ a = a / B, o = o / B, o = o * xe(a) / a, a = xe(a), i = a / w, s = (d + m) * b / (m * d + m * M * b);
2763
+ }
2764
+ return Math.abs(s) < n || i === 0 ? l = null : l = X(l * 360), [l, s, i];
2765
+ }
2766
+ var Ia = new g({
2767
+ id: "okhsv",
2768
+ name: "Okhsv",
2769
+ coords: {
2770
+ h: {
2771
+ refRange: [0, 360],
2772
+ type: "angle",
2773
+ name: "Hue"
2774
+ },
2775
+ s: {
2776
+ range: [0, 1],
2777
+ name: "Saturation"
2778
+ },
2779
+ v: {
2780
+ range: [0, 1],
2781
+ name: "Value"
2782
+ }
2783
+ },
2784
+ base: Z,
2785
+ gamutSpace: "self",
2786
+ // Convert Oklab to Okhsl
2787
+ fromBase(t) {
2788
+ return Pa(t, Qe, Ue);
2789
+ },
2790
+ // Convert Okhsl to Oklab
2791
+ toBase(t) {
2792
+ return Oa(t, Qe, Ue);
2793
+ },
2794
+ formats: {
2795
+ color: {
2796
+ id: "--okhsv",
2797
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2798
+ }
2799
+ }
2800
+ });
2801
+ let Cr = P.D65;
2802
+ const Ha = 216 / 24389, w0 = 24389 / 27, [C0, _0] = rt({ space: A, coords: Cr });
2803
+ var _r = new g({
2804
+ id: "luv",
2805
+ name: "Luv",
2806
+ coords: {
2807
+ l: {
2808
+ refRange: [0, 100],
2809
+ name: "Lightness"
2810
+ },
2811
+ // Reference ranges from https://facelessuser.github.io/coloraide/colors/luv/
2812
+ u: {
2813
+ refRange: [-215, 215]
2814
+ },
2815
+ v: {
2816
+ refRange: [-215, 215]
2817
+ }
2818
+ },
2819
+ white: Cr,
2820
+ base: A,
2821
+ // Convert D65-adapted XYZ to Luv
2822
+ // https://en.wikipedia.org/wiki/CIELUV#The_forward_transformation
2823
+ fromBase(t) {
2824
+ let e = (
2825
+ /** @type {[number, number, number]} */
2826
+ [
2827
+ z(t[0]),
2828
+ z(t[1]),
2829
+ z(t[2])
2830
+ ]
2831
+ ), r = e[1], [n, a] = rt({ space: A, coords: e });
2832
+ if (!Number.isFinite(n) || !Number.isFinite(a))
2833
+ return [0, 0, 0];
2834
+ let s = r <= Ha ? w0 * r : 116 * Math.cbrt(r) - 16;
2835
+ return [s, 13 * s * (n - C0), 13 * s * (a - _0)];
2836
+ },
2837
+ // Convert Luv to D65-adapted XYZ
2838
+ // https://en.wikipedia.org/wiki/CIELUV#The_reverse_transformation
2839
+ toBase(t) {
2840
+ let [e, r, n] = t;
2841
+ if (e === 0 || L(e))
2842
+ return [0, 0, 0];
2843
+ r = z(r), n = z(n);
2844
+ let a = r / (13 * e) + C0, s = n / (13 * e) + _0, i = e <= 8 ? e / w0 : Math.pow((e + 16) / 116, 3);
2845
+ return [i * (9 * a / (4 * s)), i, i * ((12 - 3 * a - 20 * s) / (4 * s))];
2846
+ },
2847
+ formats: {
2848
+ color: {
2849
+ id: "--luv",
2850
+ coords: [
2851
+ "<number> | <percentage>",
2852
+ "<number> | <percentage>",
2853
+ "<number> | <percentage>"
2854
+ ]
2855
+ }
2856
+ }
2857
+ }), Yt = new g({
2858
+ id: "lchuv",
2859
+ name: "LChuv",
2860
+ coords: {
2861
+ l: {
2862
+ refRange: [0, 100],
2863
+ name: "Lightness"
2864
+ },
2865
+ c: {
2866
+ refRange: [0, 220],
2867
+ name: "Chroma"
2868
+ },
2869
+ h: {
2870
+ refRange: [0, 360],
2871
+ type: "angle",
2872
+ name: "Hue"
2873
+ }
2874
+ },
2875
+ base: _r,
2876
+ fromBase: q.fromBase,
2877
+ toBase: q.toBase,
2878
+ formats: {
2879
+ color: {
2880
+ id: "--lchuv",
2881
+ coords: ["<number> | <percentage>", "<number> | <percentage>", "<number> | <angle>"]
2882
+ }
2883
+ }
2884
+ });
2885
+ const ja = 216 / 24389, Da = 24389 / 27, L0 = k[0][0], R0 = k[0][1], pt = k[0][2], v0 = k[1][0], S0 = k[1][1], bt = k[1][2], x0 = k[2][0], B0 = k[2][1], Mt = k[2][2];
2886
+ function he(t, e, r) {
2887
+ const n = e / (Math.sin(r) - t * Math.cos(r));
2888
+ return n < 0 ? 1 / 0 : n;
2889
+ }
2890
+ function Ve(t) {
2891
+ const e = Math.pow(t + 16, 3) / 1560896, r = e > ja ? e : t / Da, n = r * (284517 * L0 - 94839 * pt), a = r * (838422 * pt + 769860 * R0 + 731718 * L0), s = r * (632260 * pt - 126452 * R0), i = r * (284517 * v0 - 94839 * bt), o = r * (838422 * bt + 769860 * S0 + 731718 * v0), l = r * (632260 * bt - 126452 * S0), c = r * (284517 * x0 - 94839 * Mt), f = r * (838422 * Mt + 769860 * B0 + 731718 * x0), u = r * (632260 * Mt - 126452 * B0);
2892
+ return {
2893
+ r0s: n / s,
2894
+ r0i: a * t / s,
2895
+ r1s: n / (s + 126452),
2896
+ r1i: (a - 769860) * t / (s + 126452),
2897
+ g0s: i / l,
2898
+ g0i: o * t / l,
2899
+ g1s: i / (l + 126452),
2900
+ g1i: (o - 769860) * t / (l + 126452),
2901
+ b0s: c / u,
2902
+ b0i: f * t / u,
2903
+ b1s: c / (u + 126452),
2904
+ b1i: (f - 769860) * t / (u + 126452)
2905
+ };
2906
+ }
2907
+ function z0(t, e) {
2908
+ const r = e / 360 * Math.PI * 2, n = he(t.r0s, t.r0i, r), a = he(t.r1s, t.r1i, r), s = he(t.g0s, t.g0i, r), i = he(t.g1s, t.g1i, r), o = he(t.b0s, t.b0i, r), l = he(t.b1s, t.b1i, r);
2909
+ return Math.min(n, a, s, i, o, l);
2910
+ }
2911
+ var Ta = new g({
2912
+ id: "hsluv",
2913
+ name: "HSLuv",
2914
+ coords: {
2915
+ h: {
2916
+ refRange: [0, 360],
2917
+ type: "angle",
2918
+ name: "Hue"
2919
+ },
2920
+ s: {
2921
+ range: [0, 100],
2922
+ name: "Saturation"
2923
+ },
2924
+ l: {
2925
+ range: [0, 100],
2926
+ name: "Lightness"
2927
+ }
2928
+ },
2929
+ base: Yt,
2930
+ gamutSpace: oe,
2931
+ // Convert LCHuv to HSLuv
2932
+ fromBase(t) {
2933
+ let [e, r, n] = [z(t[0]), z(t[1]), z(t[2])], a;
2934
+ if (e > 99.9999999)
2935
+ a = 0, e = 100;
2936
+ else if (e < 1e-8)
2937
+ a = 0, e = 0;
2938
+ else {
2939
+ let s = Ve(e), i = z0(s, n);
2940
+ a = r / i * 100;
2941
+ }
2942
+ return [n, a, e];
2943
+ },
2944
+ // Convert HSLuv to LCHuv
2945
+ toBase(t) {
2946
+ let [e, r, n] = [z(t[0]), z(t[1]), z(t[2])], a;
2947
+ if (n > 99.9999999)
2948
+ n = 100, a = 0;
2949
+ else if (n < 1e-8)
2950
+ n = 0, a = 0;
2951
+ else {
2952
+ let s = Ve(n);
2953
+ a = z0(s, e) / 100 * r;
2954
+ }
2955
+ return [n, a, e];
2956
+ },
2957
+ formats: {
2958
+ color: {
2959
+ id: "--hsluv",
2960
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
2961
+ }
2962
+ }
2963
+ });
2964
+ k[0][0];
2965
+ k[0][1];
2966
+ k[0][2];
2967
+ k[1][0];
2968
+ k[1][1];
2969
+ k[1][2];
2970
+ k[2][0];
2971
+ k[2][1];
2972
+ k[2][2];
2973
+ function me(t, e) {
2974
+ return Math.abs(e) / Math.sqrt(Math.pow(t, 2) + 1);
2975
+ }
2976
+ function E0(t) {
2977
+ let e = me(t.r0s, t.r0i), r = me(t.r1s, t.r1i), n = me(t.g0s, t.g0i), a = me(t.g1s, t.g1i), s = me(t.b0s, t.b0i), i = me(t.b1s, t.b1i);
2978
+ return Math.min(e, r, n, a, s, i);
2979
+ }
2980
+ var Ya = new g({
2981
+ id: "hpluv",
2982
+ name: "HPLuv",
2983
+ coords: {
2984
+ h: {
2985
+ refRange: [0, 360],
2986
+ type: "angle",
2987
+ name: "Hue"
2988
+ },
2989
+ s: {
2990
+ range: [0, 100],
2991
+ name: "Saturation"
2992
+ },
2993
+ l: {
2994
+ range: [0, 100],
2995
+ name: "Lightness"
2996
+ }
2997
+ },
2998
+ base: Yt,
2999
+ gamutSpace: "self",
3000
+ // Convert LCHuv to HPLuv
3001
+ fromBase(t) {
3002
+ let [e, r, n] = [z(t[0]), z(t[1]), z(t[2])], a;
3003
+ if (e > 99.9999999)
3004
+ a = 0, e = 100;
3005
+ else if (e < 1e-8)
3006
+ a = 0, e = 0;
3007
+ else {
3008
+ let s = Ve(e), i = E0(s);
3009
+ a = r / i * 100;
3010
+ }
3011
+ return [n, a, e];
3012
+ },
3013
+ // Convert HPLuv to LCHuv
3014
+ toBase(t) {
3015
+ let [e, r, n] = [z(t[0]), z(t[1]), z(t[2])], a;
3016
+ if (n > 99.9999999)
3017
+ n = 100, a = 0;
3018
+ else if (n < 1e-8)
3019
+ n = 0, a = 0;
3020
+ else {
3021
+ let s = Ve(n);
3022
+ a = E0(s) / 100 * r;
3023
+ }
3024
+ return [n, a, e];
3025
+ },
3026
+ formats: {
3027
+ color: {
3028
+ id: "--hpluv",
3029
+ coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
3030
+ }
3031
+ }
3032
+ }), Nt = new O({
3033
+ id: "rec2100-linear",
3034
+ name: "Linear REC.2100",
3035
+ white: "D65",
3036
+ toBase: Ee.toBase,
3037
+ fromBase: Ee.fromBase
3038
+ });
3039
+ const k0 = 203, $0 = 2610 / 2 ** 14, Na = 2 ** 14 / 2610, qa = 2523 / 2 ** 5, A0 = 2 ** 5 / 2523, O0 = 3424 / 2 ** 12, P0 = 2413 / 2 ** 7, I0 = 2392 / 2 ** 7;
3040
+ var Xa = new O({
3041
+ id: "rec2100pq",
3042
+ cssId: "rec2100-pq",
3043
+ name: "REC.2100-PQ",
3044
+ base: Nt,
3045
+ toBase(t) {
3046
+ return t.map(function(e) {
3047
+ return (Math.max(e ** A0 - O0, 0) / (P0 - I0 * e ** A0)) ** Na * 1e4 / k0;
3048
+ });
3049
+ },
3050
+ fromBase(t) {
3051
+ return t.map(function(e) {
3052
+ let r = Math.max(e * k0 / 1e4, 0), n = O0 + P0 * r ** $0, a = 1 + I0 * r ** $0;
3053
+ return (n / a) ** qa;
3054
+ });
3055
+ }
3056
+ });
3057
+ const H0 = 0.17883277, j0 = 0.28466892, D0 = 0.55991073, yt = 3.7743;
3058
+ var Ga = new O({
3059
+ id: "rec2100hlg",
3060
+ cssId: "rec2100-hlg",
3061
+ name: "REC.2100-HLG",
3062
+ referred: "scene",
3063
+ base: Nt,
3064
+ toBase(t) {
3065
+ return t.map(function(e) {
3066
+ return e <= 0.5 ? e ** 2 / 3 * yt : (Math.exp((e - D0) / H0) + j0) / 12 * yt;
3067
+ });
3068
+ },
3069
+ fromBase(t) {
3070
+ return t.map(function(e) {
3071
+ return e /= yt, e <= 1 / 12 ? E(3 * e, 0.5) : H0 * Math.log(12 * e - j0) + D0;
3072
+ });
3073
+ }
3074
+ });
3075
+ const Lr = {};
3076
+ te.add("chromatic-adaptation-start", (t) => {
3077
+ t.options.method && (t.M = Rr(t.W1, t.W2, t.options.method));
3078
+ });
3079
+ te.add("chromatic-adaptation-end", (t) => {
3080
+ t.M || (t.M = Rr(t.W1, t.W2, t.options.method));
3081
+ });
3082
+ function at({ id: t, toCone_M: e, fromCone_M: r }) {
3083
+ Lr[t] = arguments[0];
3084
+ }
3085
+ function Rr(t, e, r = "Bradford") {
3086
+ let n = Lr[r], [a, s, i] = _e(n.toCone_M, t), [o, l, c] = _e(n.toCone_M, e), f = [
3087
+ [o / a, 0, 0],
3088
+ [0, l / s, 0],
3089
+ [0, 0, c / i]
3090
+ ], u = _e(f, n.toCone_M);
3091
+ return _e(n.fromCone_M, u);
3092
+ }
3093
+ at({
3094
+ id: "von Kries",
3095
+ toCone_M: [
3096
+ [0.40024, 0.7076, -0.08081],
3097
+ [-0.2263, 1.16532, 0.0457],
3098
+ [0, 0, 0.91822]
3099
+ ],
3100
+ fromCone_M: [
3101
+ [1.8599363874558397, -1.1293816185800916, 0.21989740959619328],
3102
+ [0.3611914362417676, 0.6388124632850422, -6370596838649899e-21],
3103
+ [0, 0, 1.0890636230968613]
3104
+ ]
3105
+ });
3106
+ at({
3107
+ id: "Bradford",
3108
+ // Convert an array of XYZ values in the range 0.0 - 1.0
3109
+ // to cone fundamentals
3110
+ toCone_M: [
3111
+ [0.8951, 0.2664, -0.1614],
3112
+ [-0.7502, 1.7135, 0.0367],
3113
+ [0.0389, -0.0685, 1.0296]
3114
+ ],
3115
+ // and back
3116
+ fromCone_M: [
3117
+ [0.9869929054667121, -0.14705425642099013, 0.15996265166373122],
3118
+ [0.4323052697233945, 0.5183602715367774, 0.049291228212855594],
3119
+ [-0.00852866457517732, 0.04004282165408486, 0.96848669578755]
3120
+ ]
3121
+ });
3122
+ at({
3123
+ id: "CAT02",
3124
+ // with complete chromatic adaptation to W2, so D = 1.0
3125
+ toCone_M: [
3126
+ [0.7328, 0.4296, -0.1624],
3127
+ [-0.7036, 1.6975, 61e-4],
3128
+ [3e-3, 0.0136, 0.9834]
3129
+ ],
3130
+ fromCone_M: [
3131
+ [1.0961238208355142, -0.27886900021828726, 0.18274517938277307],
3132
+ [0.4543690419753592, 0.4735331543074117, 0.07209780371722911],
3133
+ [-0.009627608738429355, -0.00569803121611342, 1.0153256399545427]
3134
+ ]
3135
+ });
3136
+ at({
3137
+ id: "CAT16",
3138
+ toCone_M: [
3139
+ [0.401288, 0.650173, -0.051461],
3140
+ [-0.250268, 1.204414, 0.045854],
3141
+ [-2079e-6, 0.048952, 0.953127]
3142
+ ],
3143
+ // the extra precision is needed to avoid roundtripping errors
3144
+ fromCone_M: [
3145
+ [1.862067855087233, -1.0112546305316845, 0.14918677544445172],
3146
+ [0.3875265432361372, 0.6214474419314753, -0.008973985167612521],
3147
+ [-0.01584149884933386, -0.03412293802851557, 1.0499644368778496]
3148
+ ]
3149
+ });
3150
+ Object.assign(P, {
3151
+ // whitepoint values from ASTM E308-01 with 10nm spacing, 1931 2 degree observer
3152
+ // all normalized to Y (luminance) = 1.00000
3153
+ // Illuminant A is a tungsten electric light, giving a very warm, orange light.
3154
+ A: [1.0985, 1, 0.35585],
3155
+ // Illuminant C was an early approximation to daylight: illuminant A with a blue filter.
3156
+ C: [0.98074, 1, 1.18232],
3157
+ // The daylight series of illuminants simulate natural daylight.
3158
+ // The color temperature (in degrees Kelvin/100) ranges from
3159
+ // cool, overcast daylight (D50) to bright, direct sunlight (D65).
3160
+ D55: [0.95682, 1, 0.92149],
3161
+ D75: [0.94972, 1, 1.22638],
3162
+ // Equal-energy illuminant, used in two-stage CAT16
3163
+ E: [1, 1, 1],
3164
+ // The F series of illuminants represent fluorescent lights
3165
+ F2: [0.99186, 1, 0.67393],
3166
+ F7: [0.95041, 1, 1.08747],
3167
+ F11: [1.00962, 1, 0.6435]
3168
+ });
3169
+ P.ACES = [0.32168 / 0.33767, 1, (1 - 0.32168 - 0.33767) / 0.33767];
3170
+ const Za = [
3171
+ [0.6624541811085053, 0.13400420645643313, 0.1561876870049078],
3172
+ [0.27222871678091454, 0.6740817658111484, 0.05368951740793705],
3173
+ [-0.005574649490394108, 0.004060733528982826, 1.0103391003129971]
3174
+ ], Ja = [
3175
+ [1.6410233796943257, -0.32480329418479, -0.23642469523761225],
3176
+ [-0.6636628587229829, 1.6153315916573379, 0.016756347685530137],
3177
+ [0.011721894328375376, -0.008284441996237409, 0.9883948585390215]
3178
+ ];
3179
+ var vr = new O({
3180
+ id: "acescg",
3181
+ cssId: "--acescg",
3182
+ name: "ACEScg",
3183
+ // ACEScg – A scene-referred, linear-light encoding of ACES Data
3184
+ // https://docs.acescentral.com/specifications/acescg/
3185
+ // uses the AP1 primaries, see section 4.3.1 Color primaries
3186
+ coords: {
3187
+ r: {
3188
+ range: [0, 65504],
3189
+ name: "Red"
3190
+ },
3191
+ g: {
3192
+ range: [0, 65504],
3193
+ name: "Green"
3194
+ },
3195
+ b: {
3196
+ range: [0, 65504],
3197
+ name: "Blue"
3198
+ }
3199
+ },
3200
+ referred: "scene",
3201
+ white: P.ACES,
3202
+ toXYZ_M: Za,
3203
+ fromXYZ_M: Ja
3204
+ });
3205
+ const Ne = 2 ** -16, wt = -0.35828683, qe = (Math.log2(65504) + 9.72) / 17.52;
3206
+ var Wa = new O({
3207
+ id: "acescc",
3208
+ cssId: "--acescc",
3209
+ name: "ACEScc",
3210
+ // see S-2014-003 ACEScc – A Logarithmic Encoding of ACES Data
3211
+ // https://docs.acescentral.com/specifications/acescc/
3212
+ // uses the AP1 primaries, see section 4.3.1 Color primaries
3213
+ // Appendix A: "Very small ACES scene referred values below 7 1/4 stops
3214
+ // below 18% middle gray are encoded as negative ACEScc values.
3215
+ // These values should be preserved per the encoding in Section 4.4
3216
+ // so that all positive ACES values are maintained."
3217
+ coords: {
3218
+ r: {
3219
+ range: [wt, qe],
3220
+ name: "Red"
3221
+ },
3222
+ g: {
3223
+ range: [wt, qe],
3224
+ name: "Green"
3225
+ },
3226
+ b: {
3227
+ range: [wt, qe],
3228
+ name: "Blue"
3229
+ }
3230
+ },
3231
+ referred: "scene",
3232
+ base: vr,
3233
+ // from section 4.4.2 Decoding Function
3234
+ toBase(t) {
3235
+ const e = -0.3013698630136986;
3236
+ return t.map(function(r) {
3237
+ return r <= e ? (2 ** (r * 17.52 - 9.72) - Ne) * 2 : r < qe ? 2 ** (r * 17.52 - 9.72) : 65504;
3238
+ });
3239
+ },
3240
+ // Non-linear encoding function from S-2014-003, section 4.4.1 Encoding Function
3241
+ fromBase(t) {
3242
+ return t.map(function(e) {
3243
+ return e <= 0 ? (Math.log2(Ne) + 9.72) / 17.52 : e < Ne ? (Math.log2(Ne + e * 0.5) + 9.72) / 17.52 : (Math.log2(e) + 9.72) / 17.52;
3244
+ });
3245
+ }
3246
+ // encoded media white (rgb 1,1,1) => linear [ 222.861, 222.861, 222.861 ]
3247
+ // encoded media black (rgb 0,0,0) => linear [ 0.0011857, 0.0011857, 0.0011857]
3248
+ }), T0 = /* @__PURE__ */ Object.freeze({
3249
+ __proto__: null,
3250
+ A98RGB: ya,
3251
+ A98RGB_Linear: br,
3252
+ ACEScc: Wa,
3253
+ ACEScg: vr,
3254
+ CAM16_JMh: vn,
3255
+ HCT: ze,
3256
+ HPLuv: Ya,
3257
+ HSL: ga,
3258
+ HSLuv: Ta,
3259
+ HSV: pr,
3260
+ HWB: pa,
3261
+ ICTCP: vt,
3262
+ JzCzHz: Rt,
3263
+ Jzazbz: Q0,
3264
+ LCH: q,
3265
+ LCHuv: Yt,
3266
+ Lab: Y,
3267
+ Lab_D65: Bt,
3268
+ Luv: _r,
3269
+ OKLCH: Sa,
3270
+ OKLab: Z,
3271
+ OKLrCH: Aa,
3272
+ OKLrab: wr,
3273
+ Okhsl: $a,
3274
+ Okhsv: Ia,
3275
+ P3: cr,
3276
+ P3_Linear: or,
3277
+ ProPhoto: Ra,
3278
+ ProPhoto_Linear: Mr,
3279
+ REC_2020: ir,
3280
+ REC_2020_Linear: Ee,
3281
+ REC_2020_Scene_Referred: va,
3282
+ REC_2100_HLG: Ga,
3283
+ REC_2100_Linear: Nt,
3284
+ REC_2100_PQ: Xa,
3285
+ XYZ_ABS_D65: Pt,
3286
+ XYZ_D50: Ot,
3287
+ XYZ_D65: A,
3288
+ sRGB: oe,
3289
+ sRGB_Linear: lr
3290
+ });
3291
+ class R {
3292
+ /**
3293
+ * Creates an instance of Color.
3294
+ * Signatures:
3295
+ * - `new Color(stringToParse)`
3296
+ * - `new Color(otherColor)`
3297
+ * - `new Color({space, coords, alpha})`
3298
+ * - `new Color(space, coords, alpha)`
3299
+ * - `new Color(spaceId, coords, alpha)`
3300
+ */
3301
+ constructor(...e) {
3302
+ let r;
3303
+ if (e.length === 1) {
3304
+ let i = {};
3305
+ typeof e[0] == "object" && Object.getPrototypeOf(e[0]).constructor === Object && (e[0] = { ...e[0] }), r = C(e[0], { parseMeta: i }), i.format && (this.parseMeta = i);
3306
+ }
3307
+ let n, a, s;
3308
+ r ? (n = r.space || r.spaceId, a = r.coords, s = r.alpha) : [n, a, s] = e, Object.defineProperty(this, "space", {
3309
+ value: g.get(n),
3310
+ writable: !1,
3311
+ enumerable: !0,
3312
+ configurable: !0
3313
+ // see note in https://262.ecma-international.org/8.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver
3314
+ }), this.coords = a ? a.slice() : [0, 0, 0], this.alpha = L(s) ? s : s === void 0 ? 1 : et(0, s, 1);
3315
+ for (let i in this.space.coords)
3316
+ Object.defineProperty(this, i, {
3317
+ get: () => this.get(i),
3318
+ set: (o) => this.set(i, o)
3319
+ });
3320
+ }
3321
+ get spaceId() {
3322
+ return this.space.id;
3323
+ }
3324
+ clone() {
3325
+ return new R(this.space, this.coords, this.alpha);
3326
+ }
3327
+ toJSON() {
3328
+ return {
3329
+ spaceId: this.spaceId,
3330
+ coords: this.coords,
3331
+ alpha: this.alpha
3332
+ };
3333
+ }
3334
+ display(...e) {
3335
+ let r = Yn(this, ...e);
3336
+ return r.color = new R(r.color), r;
3337
+ }
3338
+ /**
3339
+ * Get a color from the argument(s) passed
3340
+ * Basically gets us the same result as new Color(color) but doesn't clone an existing color object
3341
+ */
3342
+ static get(e, ...r) {
3343
+ return ge(e, this) ? e : new R(e, ...r);
3344
+ }
3345
+ /**
3346
+ * Get a color instance from the argument passed or `null` if resolution fails (instead of throwing an error).
3347
+ * Additionally, it supports passing an element to resolve complex CSS colors through the DOM (slow).
3348
+ * @see {@link tryColor} for more details
3349
+ */
3350
+ static try(e, r) {
3351
+ if (ge(e, this))
3352
+ return e;
3353
+ let n = Z0(e, r);
3354
+ return n ? new R(n) : null;
3355
+ }
3356
+ static defineFunction(e, r, n = r) {
3357
+ let { instance: a = !0, returns: s } = n, i = function(...o) {
3358
+ let l = r(...o);
3359
+ if (s === "color")
3360
+ l = R.get(l);
3361
+ else if (s === "function<color>") {
3362
+ let c = l;
3363
+ l = function(...f) {
3364
+ let u = c(...f);
3365
+ return R.get(u);
3366
+ }, Object.assign(l, c);
3367
+ } else s === "array<color>" && (l = l.map((c) => R.get(c)));
3368
+ return l;
3369
+ };
3370
+ e in R || (R[e] = i), a && (R.prototype[e] = function(...o) {
3371
+ return i(this, ...o);
3372
+ });
3373
+ }
3374
+ static defineFunctions(e) {
3375
+ for (let r in e)
3376
+ R.defineFunction(r, e[r], e[r]);
3377
+ }
3378
+ static extend(e) {
3379
+ if (e.register)
3380
+ e.register(R);
3381
+ else
3382
+ for (let r in e)
3383
+ R.defineFunction(r, e[r]);
3384
+ }
3385
+ }
3386
+ R.defineFunctions({
3387
+ get: T,
3388
+ getAll: ke,
3389
+ set: F,
3390
+ setAll: At,
3391
+ to: v,
3392
+ equals: qn,
3393
+ inGamut: ie,
3394
+ toGamut: re,
3395
+ distance: F0,
3396
+ deltas: Nn,
3397
+ toString: ve
3398
+ });
3399
+ Object.assign(R, {
3400
+ util: Dr,
3401
+ hooks: te,
3402
+ WHITES: P,
3403
+ Space: g,
3404
+ spaces: g.registry,
3405
+ parse: X0,
3406
+ // Global defaults one may want to configure
3407
+ defaults: N
3408
+ });
3409
+ for (let t of Object.keys(T0))
3410
+ g.register(T0[t]);
3411
+ for (let t in g.registry)
3412
+ zt(t, g.registry[t]);
3413
+ te.add("colorspace-init-end", (t) => {
3414
+ zt(t.id, t), t.aliases?.forEach((e) => {
3415
+ zt(e, t);
3416
+ });
3417
+ });
3418
+ function zt(t, e) {
3419
+ let r = t.replace(/-/g, "_");
3420
+ Object.defineProperty(R.prototype, r, {
3421
+ // Convert coords to coords in another colorspace and return them
3422
+ // Source colorspace: this.spaceId
3423
+ // Target colorspace: id
3424
+ get() {
3425
+ let n = this.getAll(t);
3426
+ if (typeof Proxy > "u")
3427
+ return n;
3428
+ let a = new Proxy(n, {
3429
+ has: (
3430
+ /** @param {string} property */
3431
+ (s, i) => {
3432
+ try {
3433
+ return g.resolveCoord([e, i]), !0;
3434
+ } catch {
3435
+ }
3436
+ return Reflect.has(s, i);
3437
+ }
3438
+ ),
3439
+ get: (s, i, o) => {
3440
+ if (i && typeof i != "symbol" && !(i in s) && i in a) {
3441
+ let { index: l } = g.resolveCoord([e, i]);
3442
+ if (l >= 0)
3443
+ return s[l];
3444
+ }
3445
+ return Reflect.get(s, i, o);
3446
+ },
3447
+ set: (s, i, o, l) => {
3448
+ if (i && typeof i != "symbol" && !(i in s) || Number(i) >= 0) {
3449
+ let { index: c } = g.resolveCoord([
3450
+ e,
3451
+ /** @type {string} */
3452
+ i
3453
+ ]);
3454
+ if (c >= 0)
3455
+ return s[c] = o, this.setAll(t, s), !0;
3456
+ }
3457
+ return Reflect.set(s, i, o, l);
3458
+ }
3459
+ });
3460
+ return a;
3461
+ },
3462
+ // Convert coords in another colorspace to internal coords and set them
3463
+ // Target colorspace: this.spaceId
3464
+ // Source colorspace: id
3465
+ set(n) {
3466
+ this.setAll(t, n);
3467
+ },
3468
+ configurable: !0,
3469
+ enumerable: !0
3470
+ });
3471
+ }
3472
+ R.extend(be);
3473
+ R.extend({ deltaE: Le });
3474
+ Object.assign(R, { deltaEMethods: be });
3475
+ R.extend(ha);
3476
+ R.extend({ contrast: ca });
3477
+ R.extend(fa);
3478
+ R.extend(Gn);
3479
+ R.extend(da);
3480
+ R.extend(Xe);
3481
+ const Fa = {
3482
+ RED: "red",
3483
+ ORANGE: "orange",
3484
+ YELLOW: "yellow",
3485
+ GREEN: "green",
3486
+ BLUE: "blue",
3487
+ PURPLE: "purple"
3488
+ }, Qa = [
3489
+ {
3490
+ name: "RED",
3491
+ hue: (t) => t < 30 || t > 315,
3492
+ rgb: ([t, e, r]) => t >= e + r
3493
+ },
3494
+ {
3495
+ name: "ORANGE",
3496
+ hue: (t) => t >= 30 && t <= 60,
3497
+ rgb: ([t, e, r]) => t > e && e > r && t > r
3498
+ },
3499
+ {
3500
+ name: "YELLOW",
3501
+ hue: (t) => t > 45 && t <= 75,
3502
+ rgb: ([t, e, r]) => t >= e && e >= r && Math.abs(t - e) < 100
3503
+ },
3504
+ {
3505
+ name: "GREEN",
3506
+ hue: (t) => t > 75 && t <= 180,
3507
+ rgb: ([t, e, r]) => e > t && e > r
3508
+ },
3509
+ {
3510
+ name: "BLUE",
3511
+ hue: (t) => t > 180 && t <= 270,
3512
+ rgb: ([t, e, r]) => r > t && r > e
3513
+ },
3514
+ {
3515
+ name: "PURPLE",
3516
+ hue: (t) => t > 270 && t <= 315,
3517
+ rgb: ([t, e, r]) => t > e && r > e
3518
+ }
3519
+ ], Ua = $r`
3520
+ .clippy-color-combobox__option {
3521
+ align-items: center;
3522
+ display: flex;
3523
+ }
3524
+ `;
3525
+ var Va = Object.defineProperty, Ka = Object.getOwnPropertyDescriptor, Sr = (t) => {
3526
+ throw TypeError(t);
3527
+ }, xr = (t, e, r, n) => {
3528
+ for (var a = n > 1 ? void 0 : n ? Ka(e, r) : e, s = t.length - 1, i; s >= 0; s--)
3529
+ (i = t[s]) && (a = (n ? i(e, r, a) : i(a)) || a);
3530
+ return n && a && Va(e, r, a), a;
3531
+ }, Br = (t, e, r) => e.has(t) || Sr("Cannot " + r), es = (t, e, r) => (Br(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ts = (t, e, r) => e.has(t) ? Sr("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), rs = (t, e, r, n) => (Br(t, e, "write to private field"), e.set(t, r), r), Ge;
3532
+ const ns = "clippy-color-combobox";
3533
+ class as extends Y0 {
3534
+ }
3535
+ let Ke = class extends kr(as) {
3536
+ constructor() {
3537
+ super(...arguments), this.translations = Fa, ts(this, Ge, []), this.filter = (t) => {
3538
+ const e = t.toLowerCase();
3539
+ return (r) => {
3540
+ const n = r.label.toLowerCase(), a = r.names;
3541
+ return n.includes(e) || a.some((s) => this.translations[s]?.includes(e));
3542
+ };
3543
+ };
3544
+ }
3545
+ set lang(t) {
3546
+ this.loadLocalizations(t).then(() => {
3547
+ super.lang = t;
3548
+ });
3549
+ }
3550
+ async loadLocalizations(t) {
3551
+ const r = t.split("-");
3552
+ let n;
3553
+ for (let a = r.length; a > 0; a--) {
3554
+ const s = r.slice(0, a).join("-");
3555
+ try {
3556
+ n = await Hr(/* @__PURE__ */ Object.assign({ "./messages/en.ts": () => import("./en-B-D8DBsf.js"), "./messages/nl.ts": () => import("./nl-CJG2-yS5.js") }), `./messages/${s}.ts`, 3).then((i) => i.default), this.translations = n || this.translations, this.lang = s;
3557
+ break;
3558
+ } catch {
3559
+ }
3560
+ }
3561
+ }
3562
+ get options() {
3563
+ return es(this, Ge);
3564
+ }
3565
+ set options(t) {
3566
+ rs(this, Ge, t.map(({ label: e, value: r }) => {
3567
+ const n = new R(r), a = Qa.filter(({ hue: s, rgb: i }) => n.h ? s(n.h) : i([n.r || 0, n.g || 0, n.b || 0])).map(({ name: s }) => s);
3568
+ return {
3569
+ color: n,
3570
+ label: e,
3571
+ names: a,
3572
+ value: r
3573
+ };
3574
+ }));
3575
+ }
3576
+ valueToQuery(t) {
3577
+ return Array.isArray(t) ? t[0] : t.split(",")[0];
3578
+ }
3579
+ renderEntry(t) {
3580
+ const e = t.color?.toString();
3581
+ return Ar`
3582
+ <span class="clippy-color-combobox__option">
3583
+ <svg role="img" xmlns="http://www.w3.org/2000/svg" class="nl-color-sample" style=${Ir({ color: e })}>
3584
+ <path d="M0 0H32V32H0Z" fill="currentcolor" />
3585
+ </svg>
3586
+ <span>${t.label}</span>
3587
+ </span>
3588
+ `;
3589
+ }
3590
+ };
3591
+ Ge = /* @__PURE__ */ new WeakMap();
3592
+ Ke.styles = [...Y0.styles, Ua, Or(jr)];
3593
+ xr([
3594
+ Pr({ type: Array })
3595
+ ], Ke.prototype, "options", 1);
3596
+ Ke = xr([
3597
+ Er(ns)
3598
+ ], Ke);
3599
+ export {
3600
+ Fa as C,
3601
+ Ke as a
3602
+ };