@fest-lib/image 0.1.4 → 0.1.6

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 (3) hide show
  1. package/dist/image.js +1008 -1769
  2. package/package.json +1 -1
  3. package/dist/index.js +0 -3401
package/dist/index.js DELETED
@@ -1,3401 +0,0 @@
1
- var Wo = "electronBridge", qo = { fast: {
2
- divisor: 4,
3
- filter: "blur(4px)",
4
- sampling: 128
5
- } }, Wr = (e, t) => {
6
- if (typeof e == "number") {
7
- if (t === 3) return {
8
- mode: "rgb",
9
- r: (e >> 8 & 15 | e >> 4 & 240) / 255,
10
- g: (e >> 4 & 15 | e & 240) / 255,
11
- b: (e & 15 | e << 4 & 240) / 255
12
- };
13
- if (t === 4) return {
14
- mode: "rgb",
15
- r: (e >> 12 & 15 | e >> 8 & 240) / 255,
16
- g: (e >> 8 & 15 | e >> 4 & 240) / 255,
17
- b: (e >> 4 & 15 | e & 240) / 255,
18
- alpha: (e & 15 | e << 4 & 240) / 255
19
- };
20
- if (t === 6) return {
21
- mode: "rgb",
22
- r: (e >> 16 & 255) / 255,
23
- g: (e >> 8 & 255) / 255,
24
- b: (e & 255) / 255
25
- };
26
- if (t === 8) return {
27
- mode: "rgb",
28
- r: (e >> 24 & 255) / 255,
29
- g: (e >> 16 & 255) / 255,
30
- b: (e >> 8 & 255) / 255,
31
- alpha: (e & 255) / 255
32
- };
33
- }
34
- }, Pa = {
35
- aliceblue: 15792383,
36
- antiquewhite: 16444375,
37
- aqua: 65535,
38
- aquamarine: 8388564,
39
- azure: 15794175,
40
- beige: 16119260,
41
- bisque: 16770244,
42
- black: 0,
43
- blanchedalmond: 16772045,
44
- blue: 255,
45
- blueviolet: 9055202,
46
- brown: 10824234,
47
- burlywood: 14596231,
48
- cadetblue: 6266528,
49
- chartreuse: 8388352,
50
- chocolate: 13789470,
51
- coral: 16744272,
52
- cornflowerblue: 6591981,
53
- cornsilk: 16775388,
54
- crimson: 14423100,
55
- cyan: 65535,
56
- darkblue: 139,
57
- darkcyan: 35723,
58
- darkgoldenrod: 12092939,
59
- darkgray: 11119017,
60
- darkgreen: 25600,
61
- darkgrey: 11119017,
62
- darkkhaki: 12433259,
63
- darkmagenta: 9109643,
64
- darkolivegreen: 5597999,
65
- darkorange: 16747520,
66
- darkorchid: 10040012,
67
- darkred: 9109504,
68
- darksalmon: 15308410,
69
- darkseagreen: 9419919,
70
- darkslateblue: 4734347,
71
- darkslategray: 3100495,
72
- darkslategrey: 3100495,
73
- darkturquoise: 52945,
74
- darkviolet: 9699539,
75
- deeppink: 16716947,
76
- deepskyblue: 49151,
77
- dimgray: 6908265,
78
- dimgrey: 6908265,
79
- dodgerblue: 2003199,
80
- firebrick: 11674146,
81
- floralwhite: 16775920,
82
- forestgreen: 2263842,
83
- fuchsia: 16711935,
84
- gainsboro: 14474460,
85
- ghostwhite: 16316671,
86
- gold: 16766720,
87
- goldenrod: 14329120,
88
- gray: 8421504,
89
- green: 32768,
90
- greenyellow: 11403055,
91
- grey: 8421504,
92
- honeydew: 15794160,
93
- hotpink: 16738740,
94
- indianred: 13458524,
95
- indigo: 4915330,
96
- ivory: 16777200,
97
- khaki: 15787660,
98
- lavender: 15132410,
99
- lavenderblush: 16773365,
100
- lawngreen: 8190976,
101
- lemonchiffon: 16775885,
102
- lightblue: 11393254,
103
- lightcoral: 15761536,
104
- lightcyan: 14745599,
105
- lightgoldenrodyellow: 16448210,
106
- lightgray: 13882323,
107
- lightgreen: 9498256,
108
- lightgrey: 13882323,
109
- lightpink: 16758465,
110
- lightsalmon: 16752762,
111
- lightseagreen: 2142890,
112
- lightskyblue: 8900346,
113
- lightslategray: 7833753,
114
- lightslategrey: 7833753,
115
- lightsteelblue: 11584734,
116
- lightyellow: 16777184,
117
- lime: 65280,
118
- limegreen: 3329330,
119
- linen: 16445670,
120
- magenta: 16711935,
121
- maroon: 8388608,
122
- mediumaquamarine: 6737322,
123
- mediumblue: 205,
124
- mediumorchid: 12211667,
125
- mediumpurple: 9662683,
126
- mediumseagreen: 3978097,
127
- mediumslateblue: 8087790,
128
- mediumspringgreen: 64154,
129
- mediumturquoise: 4772300,
130
- mediumvioletred: 13047173,
131
- midnightblue: 1644912,
132
- mintcream: 16121850,
133
- mistyrose: 16770273,
134
- moccasin: 16770229,
135
- navajowhite: 16768685,
136
- navy: 128,
137
- oldlace: 16643558,
138
- olive: 8421376,
139
- olivedrab: 7048739,
140
- orange: 16753920,
141
- orangered: 16729344,
142
- orchid: 14315734,
143
- palegoldenrod: 15657130,
144
- palegreen: 10025880,
145
- paleturquoise: 11529966,
146
- palevioletred: 14381203,
147
- papayawhip: 16773077,
148
- peachpuff: 16767673,
149
- peru: 13468991,
150
- pink: 16761035,
151
- plum: 14524637,
152
- powderblue: 11591910,
153
- purple: 8388736,
154
- rebeccapurple: 6697881,
155
- red: 16711680,
156
- rosybrown: 12357519,
157
- royalblue: 4286945,
158
- saddlebrown: 9127187,
159
- salmon: 16416882,
160
- sandybrown: 16032864,
161
- seagreen: 3050327,
162
- seashell: 16774638,
163
- sienna: 10506797,
164
- silver: 12632256,
165
- skyblue: 8900331,
166
- slateblue: 6970061,
167
- slategray: 7372944,
168
- slategrey: 7372944,
169
- snow: 16775930,
170
- springgreen: 65407,
171
- steelblue: 4620980,
172
- tan: 13808780,
173
- teal: 32896,
174
- thistle: 14204888,
175
- tomato: 16737095,
176
- turquoise: 4251856,
177
- violet: 15631086,
178
- wheat: 16113331,
179
- white: 16777215,
180
- whitesmoke: 16119285,
181
- yellow: 16776960,
182
- yellowgreen: 10145074
183
- }, $a = (e) => Wr(Pa[e.toLowerCase()], 6), Ca = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i, Aa = (e) => {
184
- let t;
185
- return (t = e.match(Ca)) ? Wr(parseInt(t[1], 16), t[1].length) : void 0;
186
- }, P = "([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)", Vo = `(?:${P}|none)`, le = `${P}%`, Do = `(?:${P}%|none)`, Vt = `(?:${P}%|${P})`, La = `(?:${P}%|${P}|none)`, Na = `(?:${P}(deg|grad|rad|turn)|${P})`, Fo = `(?:${P}(deg|grad|rad|turn)|${P}|none)`, Z = "\\s*,\\s*", Bo = new RegExp("^" + La + "$"), Ra = new RegExp(`^rgba?\\(\\s*${P}${Z}${P}${Z}${P}\\s*(?:,\\s*${Vt}\\s*)?\\)$`), Ia = new RegExp(`^rgba?\\(\\s*${le}${Z}${le}${Z}${le}\\s*(?:,\\s*${Vt}\\s*)?\\)$`), ja = (e) => {
187
- let t = { mode: "rgb" }, r;
188
- if (r = e.match(Ra))
189
- r[1] !== void 0 && (t.r = r[1] / 255), r[2] !== void 0 && (t.g = r[2] / 255), r[3] !== void 0 && (t.b = r[3] / 255);
190
- else if (r = e.match(Ia))
191
- r[1] !== void 0 && (t.r = r[1] / 100), r[2] !== void 0 && (t.g = r[2] / 100), r[3] !== void 0 && (t.b = r[3] / 100);
192
- else return;
193
- return r[4] !== void 0 ? t.alpha = Math.max(0, Math.min(1, r[4] / 100)) : r[5] !== void 0 && (t.alpha = Math.max(0, Math.min(1, +r[5]))), t;
194
- }, Ha = (e, t) => e === void 0 ? void 0 : typeof e != "object" ? Ua(e) : e.mode !== void 0 ? e : t ? {
195
- ...e,
196
- mode: t
197
- } : void 0, Dt = (e = "rgb") => (t) => (t = Ha(t, e)) !== void 0 ? t.mode === e ? t : C[t.mode][e] ? C[t.mode][e](t) : e === "rgb" ? C[t.mode].rgb(t) : C.rgb[e](C[t.mode].rgb(t)) : void 0, C = {}, qr = {}, Ee = [], Vr = {}, Oa = (e) => e, y = (e) => (C[e.mode] = {
198
- ...C[e.mode],
199
- ...e.toMode
200
- }, Object.keys(e.fromMode || {}).forEach((t) => {
201
- C[t] || (C[t] = {}), C[t][e.mode] = e.fromMode[t];
202
- }), e.ranges || (e.ranges = {}), e.difference || (e.difference = {}), e.channels.forEach((t) => {
203
- if (e.ranges[t] === void 0 && (e.ranges[t] = [0, 1]), !e.interpolate[t]) throw new Error(`Missing interpolator for: ${t}`);
204
- typeof e.interpolate[t] == "function" && (e.interpolate[t] = { use: e.interpolate[t] }), e.interpolate[t].fixup || (e.interpolate[t].fixup = Oa);
205
- }), qr[e.mode] = e, (e.parse || []).forEach((t) => {
206
- qa(t, e.mode);
207
- }), Dt(e.mode)), Wa = (e) => qr[e], qa = (e, t) => {
208
- if (typeof e == "string") {
209
- if (!t) throw new Error("'mode' required when 'parser' is a string");
210
- Vr[e] = t;
211
- } else typeof e == "function" && Ee.indexOf(e) < 0 && Ee.push(e);
212
- }, zt = /[^\x00-\x7F]|[a-zA-Z_]/, Va = /[^\x00-\x7F]|[-\w]/, u = {
213
- Function: "function",
214
- Ident: "ident",
215
- Number: "number",
216
- Percentage: "percentage",
217
- ParenClose: ")",
218
- None: "none",
219
- Hue: "hue",
220
- Alpha: "alpha"
221
- }, g = 0;
222
- function fe(e) {
223
- let t = e[g], r = e[g + 1];
224
- return t === "-" || t === "+" ? /\d/.test(r) || r === "." && /\d/.test(e[g + 2]) : t === "." ? /\d/.test(r) : /\d/.test(t);
225
- }
226
- function _t(e) {
227
- if (g >= e.length) return !1;
228
- let t = e[g];
229
- if (zt.test(t)) return !0;
230
- if (t === "-") {
231
- if (e.length - g < 2) return !1;
232
- let r = e[g + 1];
233
- return !!(r === "-" || zt.test(r));
234
- }
235
- return !1;
236
- }
237
- var Da = {
238
- deg: 1,
239
- rad: 180 / Math.PI,
240
- grad: 9 / 10,
241
- turn: 360
242
- };
243
- function oe(e) {
244
- let t = "";
245
- if ((e[g] === "-" || e[g] === "+") && (t += e[g++]), t += me(e), e[g] === "." && /\d/.test(e[g + 1]) && (t += e[g++] + me(e)), (e[g] === "e" || e[g] === "E") && ((e[g + 1] === "-" || e[g + 1] === "+") && /\d/.test(e[g + 2]) ? t += e[g++] + e[g++] + me(e) : /\d/.test(e[g + 1]) && (t += e[g++] + me(e))), _t(e)) {
246
- let r = Te(e);
247
- return r === "deg" || r === "rad" || r === "turn" || r === "grad" ? {
248
- type: u.Hue,
249
- value: t * Da[r]
250
- } : void 0;
251
- }
252
- return e[g] === "%" ? (g++, {
253
- type: u.Percentage,
254
- value: +t
255
- }) : {
256
- type: u.Number,
257
- value: +t
258
- };
259
- }
260
- function me(e) {
261
- let t = "";
262
- for (; /\d/.test(e[g]); ) t += e[g++];
263
- return t;
264
- }
265
- function Te(e) {
266
- let t = "";
267
- for (; g < e.length && Va.test(e[g]); ) t += e[g++];
268
- return t;
269
- }
270
- function Fa(e) {
271
- let t = Te(e);
272
- return e[g] === "(" ? (g++, {
273
- type: u.Function,
274
- value: t
275
- }) : t === "none" ? {
276
- type: u.None,
277
- value: void 0
278
- } : {
279
- type: u.Ident,
280
- value: t
281
- };
282
- }
283
- function Ba(e = "") {
284
- let t = e.trim(), r = [], a;
285
- for (g = 0; g < t.length; ) {
286
- if (a = t[g++], a === `
287
- ` || a === " " || a === " ") {
288
- for (; g < t.length && (t[g] === `
289
- ` || t[g] === " " || t[g] === " "); ) g++;
290
- continue;
291
- }
292
- if (a === ",") return;
293
- if (a === ")") {
294
- r.push({ type: u.ParenClose });
295
- continue;
296
- }
297
- if (a === "+") {
298
- if (g--, fe(t)) {
299
- r.push(oe(t));
300
- continue;
301
- }
302
- return;
303
- }
304
- if (a === "-") {
305
- if (g--, fe(t)) {
306
- r.push(oe(t));
307
- continue;
308
- }
309
- if (_t(t)) {
310
- r.push({
311
- type: u.Ident,
312
- value: Te(t)
313
- });
314
- continue;
315
- }
316
- return;
317
- }
318
- if (a === ".") {
319
- if (g--, fe(t)) {
320
- r.push(oe(t));
321
- continue;
322
- }
323
- return;
324
- }
325
- if (a === "/") {
326
- for (; g < t.length && (t[g] === `
327
- ` || t[g] === " " || t[g] === " "); ) g++;
328
- let n;
329
- if (fe(t) && (n = oe(t), n.type !== u.Hue)) {
330
- r.push({
331
- type: u.Alpha,
332
- value: n
333
- });
334
- continue;
335
- }
336
- if (_t(t) && Te(t) === "none") {
337
- r.push({
338
- type: u.Alpha,
339
- value: {
340
- type: u.None,
341
- value: void 0
342
- }
343
- });
344
- continue;
345
- }
346
- return;
347
- }
348
- if (/\d/.test(a)) {
349
- g--, r.push(oe(t));
350
- continue;
351
- }
352
- if (zt.test(a)) {
353
- g--, r.push(Fa(t));
354
- continue;
355
- }
356
- return;
357
- }
358
- return r;
359
- }
360
- function Xa(e) {
361
- e._i = 0;
362
- let t = e[e._i++];
363
- if (!t || t.type !== u.Function || t.value !== "color" || (t = e[e._i++], t.type !== u.Ident)) return;
364
- const r = Vr[t.value];
365
- if (!r) return;
366
- const a = { mode: r }, n = Dr(e, !1);
367
- if (!n) return;
368
- const i = Wa(r).channels;
369
- for (let o = 0, s, l; o < i.length; o++)
370
- s = n[o], l = i[o], s.type !== u.None && (a[l] = s.type === u.Number ? s.value : s.value / 100, l === "alpha" && (a[l] = Math.max(0, Math.min(1, a[l]))));
371
- return a;
372
- }
373
- function Dr(e, t) {
374
- const r = [];
375
- let a;
376
- for (; e._i < e.length; ) {
377
- if (a = e[e._i++], a.type === u.None || a.type === u.Number || a.type === u.Alpha || a.type === u.Percentage || t && a.type === u.Hue) {
378
- r.push(a);
379
- continue;
380
- }
381
- if (a.type === u.ParenClose) {
382
- if (e._i < e.length) return;
383
- continue;
384
- }
385
- return;
386
- }
387
- if (!(r.length < 3 || r.length > 4)) {
388
- if (r.length === 4) {
389
- if (r[3].type !== u.Alpha) return;
390
- r[3] = r[3].value;
391
- }
392
- return r.length === 3 && r.push({
393
- type: u.None,
394
- value: void 0
395
- }), r.every((n) => n.type !== u.Alpha) ? r : void 0;
396
- }
397
- }
398
- function Ya(e, t) {
399
- e._i = 0;
400
- let r = e[e._i++];
401
- if (!r || r.type !== u.Function) return;
402
- let a = Dr(e, t);
403
- if (a)
404
- return a.unshift(r.value), a;
405
- }
406
- var Ua = (e) => {
407
- if (typeof e != "string") return;
408
- const t = Ba(e), r = t ? Ya(t, !0) : void 0;
409
- let a, n = 0, i = Ee.length;
410
- for (; n < i; ) if ((a = Ee[n++](e, r)) !== void 0) return a;
411
- return t ? Xa(t) : void 0;
412
- };
413
- function Za(e, t) {
414
- if (!t || t[0] !== "rgb" && t[0] !== "rgba") return;
415
- const r = { mode: "rgb" }, [, a, n, i, o] = t;
416
- if (!(a.type === u.Hue || n.type === u.Hue || i.type === u.Hue))
417
- return a.type !== u.None && (r.r = a.type === u.Number ? a.value / 255 : a.value / 100), n.type !== u.None && (r.g = n.type === u.Number ? n.value / 255 : n.value / 100), i.type !== u.None && (r.b = i.type === u.Number ? i.value / 255 : i.value / 100), o.type !== u.None && (r.alpha = Math.min(1, Math.max(0, o.type === u.Number ? o.value : o.value / 100))), r;
418
- }
419
- var Ja = (e) => e === "transparent" ? {
420
- mode: "rgb",
421
- r: 0,
422
- g: 0,
423
- b: 0,
424
- alpha: 0
425
- } : void 0, Ga = (e, t, r) => e + r * (t - e), Ka = (e) => {
426
- let t = [];
427
- for (let r = 0; r < e.length - 1; r++) {
428
- let a = e[r], n = e[r + 1];
429
- a === void 0 && n === void 0 ? t.push(void 0) : a !== void 0 && n !== void 0 ? t.push([a, n]) : t.push(a !== void 0 ? [a, a] : [n, n]);
430
- }
431
- return t;
432
- }, Qa = (e) => (t) => {
433
- let r = Ka(t);
434
- return (a) => {
435
- let n = a * r.length, i = a >= 1 ? r.length - 1 : Math.max(Math.floor(n), 0), o = r[i];
436
- return o === void 0 ? void 0 : e(o[0], o[1], n - i);
437
- };
438
- }, h = Qa(Ga), S = (e) => {
439
- let t = !1, r = e.map((a) => a !== void 0 ? (t = !0, a) : 1);
440
- return t ? r : e;
441
- }, J = {
442
- mode: "rgb",
443
- channels: [
444
- "r",
445
- "g",
446
- "b",
447
- "alpha"
448
- ],
449
- parse: [
450
- Za,
451
- Aa,
452
- ja,
453
- $a,
454
- Ja,
455
- "srgb"
456
- ],
457
- serialize: "srgb",
458
- interpolate: {
459
- r: h,
460
- g: h,
461
- b: h,
462
- alpha: {
463
- use: h,
464
- fixup: S
465
- }
466
- },
467
- gamut: !0,
468
- white: {
469
- r: 1,
470
- g: 1,
471
- b: 1
472
- },
473
- black: {
474
- r: 0,
475
- g: 0,
476
- b: 0
477
- }
478
- }, Qe = (e = 0) => Math.pow(Math.abs(e), 563 / 256) * Math.sign(e), ur = (e) => {
479
- let t = Qe(e.r), r = Qe(e.g), a = Qe(e.b), n = {
480
- mode: "xyz65",
481
- x: 0.5766690429101305 * t + 0.1855582379065463 * r + 0.1882286462349947 * a,
482
- y: 0.297344975250536 * t + 0.6273635662554661 * r + 0.0752914584939979 * a,
483
- z: 0.0270313613864123 * t + 0.0706888525358272 * r + 0.9913375368376386 * a
484
- };
485
- return e.alpha !== void 0 && (n.alpha = e.alpha), n;
486
- }, et = (e) => Math.pow(Math.abs(e), 256 / 563) * Math.sign(e), cr = ({ x: e, y: t, z: r, alpha: a }) => {
487
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
488
- let n = {
489
- mode: "a98",
490
- r: et(e * 2.0415879038107465 - t * 0.5650069742788597 - 0.3447313507783297 * r),
491
- g: et(e * -0.9692436362808798 + t * 1.8759675015077206 + 0.0415550574071756 * r),
492
- b: et(e * 0.0134442806320312 - t * 0.1183623922310184 + 1.0151749943912058 * r)
493
- };
494
- return a !== void 0 && (n.alpha = a), n;
495
- }, tt = (e = 0) => {
496
- const t = Math.abs(e);
497
- return t <= 0.04045 ? e / 12.92 : (Math.sign(e) || 1) * Math.pow((t + 0.055) / 1.055, 2.4);
498
- }, G = ({ r: e, g: t, b: r, alpha: a }) => {
499
- let n = {
500
- mode: "lrgb",
501
- r: tt(e),
502
- g: tt(t),
503
- b: tt(r)
504
- };
505
- return a !== void 0 && (n.alpha = a), n;
506
- }, V = (e) => {
507
- let { r: t, g: r, b: a, alpha: n } = G(e), i = {
508
- mode: "xyz65",
509
- x: 0.4123907992659593 * t + 0.357584339383878 * r + 0.1804807884018343 * a,
510
- y: 0.2126390058715102 * t + 0.715168678767756 * r + 0.0721923153607337 * a,
511
- z: 0.0193308187155918 * t + 0.119194779794626 * r + 0.9505321522496607 * a
512
- };
513
- return n !== void 0 && (i.alpha = n), i;
514
- }, rt = (e = 0) => {
515
- const t = Math.abs(e);
516
- return t > 31308e-7 ? (Math.sign(e) || 1) * (1.055 * Math.pow(t, 1 / 2.4) - 0.055) : e * 12.92;
517
- }, K = ({ r: e, g: t, b: r, alpha: a }, n = "rgb") => {
518
- let i = {
519
- mode: n,
520
- r: rt(e),
521
- g: rt(t),
522
- b: rt(r)
523
- };
524
- return a !== void 0 && (i.alpha = a), i;
525
- }, D = ({ x: e, y: t, z: r, alpha: a }) => {
526
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
527
- let n = K({
528
- r: e * 3.2409699419045226 - t * 1.537383177570094 - 0.4986107602930034 * r,
529
- g: e * -0.9692436362808796 + t * 1.8759675015077204 + 0.0415550574071756 * r,
530
- b: e * 0.0556300796969936 - t * 0.2039769588889765 + 1.0569715142428784 * r
531
- });
532
- return a !== void 0 && (n.alpha = a), n;
533
- }, en = {
534
- ...J,
535
- mode: "a98",
536
- parse: ["a98-rgb"],
537
- serialize: "a98-rgb",
538
- fromMode: {
539
- rgb: (e) => cr(V(e)),
540
- xyz65: cr
541
- },
542
- toMode: {
543
- rgb: (e) => D(ur(e)),
544
- xyz65: ur
545
- }
546
- }, E = (e) => (e = e % 360) < 0 ? e + 360 : e, tn = (e, t) => e.map((r, a, n) => {
547
- if (r === void 0) return r;
548
- let i = E(r);
549
- return a === 0 || e[a - 1] === void 0 ? i : t(i - E(n[a - 1]));
550
- }).reduce((r, a) => !r.length || a === void 0 || r[r.length - 1] === void 0 ? (r.push(a), r) : (r.push(a + r[r.length - 1]), r), []), A = (e) => tn(e, (t) => Math.abs(t) <= 180 ? t : t - 360 * Math.sign(t)), k = [
551
- -0.14861,
552
- 1.78277,
553
- -0.29227,
554
- -0.90649,
555
- 1.97294,
556
- 0
557
- ], rn = Math.PI / 180, an = 180 / Math.PI, hr = k[3] * k[4], pr = k[1] * k[4], vr = k[1] * k[2] - k[0] * k[3], nn = ({ r: e, g: t, b: r, alpha: a }) => {
558
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
559
- let n = (vr * r + e * hr - t * pr) / (vr + hr - pr), i = r - n, o = (k[4] * (t - n) - k[2] * i) / k[3], s = {
560
- mode: "cubehelix",
561
- l: n,
562
- s: n === 0 || n === 1 ? void 0 : Math.sqrt(i * i + o * o) / (k[4] * n * (1 - n))
563
- };
564
- return s.s && (s.h = Math.atan2(o, i) * an - 120), a !== void 0 && (s.alpha = a), s;
565
- }, on = ({ h: e, s: t, l: r, alpha: a }) => {
566
- let n = { mode: "rgb" };
567
- e = (e === void 0 ? 0 : e + 120) * rn, r === void 0 && (r = 0);
568
- let i = t === void 0 ? 0 : t * r * (1 - r), o = Math.cos(e), s = Math.sin(e);
569
- return n.r = r + i * (k[0] * o + k[1] * s), n.g = r + i * (k[2] * o + k[3] * s), n.b = r + i * (k[4] * o + k[5] * s), a !== void 0 && (n.alpha = a), n;
570
- }, Re = (e, t) => {
571
- if (e.h === void 0 || t.h === void 0 || !e.s || !t.s) return 0;
572
- let r = E(e.h), a = E(t.h), n = Math.sin((a - r + 360) / 2 * Math.PI / 180);
573
- return 2 * Math.sqrt(e.s * t.s) * n;
574
- }, sn = (e, t) => {
575
- if (e.h === void 0 || t.h === void 0) return 0;
576
- let r = E(e.h), a = E(t.h);
577
- return Math.abs(a - r) > 180 ? r - (a - 360 * Math.sign(a - r)) : a - r;
578
- }, Ie = (e, t) => {
579
- if (e.h === void 0 || t.h === void 0 || !e.c || !t.c) return 0;
580
- let r = E(e.h), a = E(t.h), n = Math.sin((a - r + 360) / 2 * Math.PI / 180);
581
- return 2 * Math.sqrt(e.c * t.c) * n;
582
- }, L = (e) => {
583
- let t = e.reduce((a, n) => {
584
- if (n !== void 0) {
585
- let i = n * Math.PI / 180;
586
- a.sin += Math.sin(i), a.cos += Math.cos(i);
587
- }
588
- return a;
589
- }, {
590
- sin: 0,
591
- cos: 0
592
- }), r = Math.atan2(t.sin, t.cos) * 180 / Math.PI;
593
- return r < 0 ? 360 + r : r;
594
- }, ln = {
595
- mode: "cubehelix",
596
- channels: [
597
- "h",
598
- "s",
599
- "l",
600
- "alpha"
601
- ],
602
- parse: ["--cubehelix"],
603
- serialize: "--cubehelix",
604
- ranges: {
605
- h: [0, 360],
606
- s: [0, 4.614],
607
- l: [0, 1]
608
- },
609
- fromMode: { rgb: nn },
610
- toMode: { rgb: on },
611
- interpolate: {
612
- h: {
613
- use: h,
614
- fixup: A
615
- },
616
- s: h,
617
- l: h,
618
- alpha: {
619
- use: h,
620
- fixup: S
621
- }
622
- },
623
- difference: { h: Re },
624
- average: { h: L }
625
- }, I = ({ l: e, a: t, b: r, alpha: a }, n = "lch") => {
626
- t === void 0 && (t = 0), r === void 0 && (r = 0);
627
- let i = Math.sqrt(t * t + r * r), o = {
628
- mode: n,
629
- l: e,
630
- c: i
631
- };
632
- return i && (o.h = E(Math.atan2(r, t) * 180 / Math.PI)), a !== void 0 && (o.alpha = a), o;
633
- }, j = ({ l: e, c: t, h: r, alpha: a }, n = "lab") => {
634
- r === void 0 && (r = 0);
635
- let i = {
636
- mode: n,
637
- l: e,
638
- a: t ? t * Math.cos(r / 180 * Math.PI) : 0,
639
- b: t ? t * Math.sin(r / 180 * Math.PI) : 0
640
- };
641
- return a !== void 0 && (i.alpha = a), i;
642
- }, Fr = Math.pow(29, 3) / Math.pow(3, 3), Br = Math.pow(6, 3) / Math.pow(29, 3), x = {
643
- X: 0.3457 / 0.3585,
644
- Y: 1,
645
- Z: 0.2958 / 0.3585
646
- }, Y = {
647
- X: 0.3127 / 0.329,
648
- Y: 1,
649
- Z: 0.3583 / 0.329
650
- }, Xo = Math.pow(29, 3) / Math.pow(3, 3), Yo = Math.pow(6, 3) / Math.pow(29, 3), at = (e) => Math.pow(e, 3) > Br ? Math.pow(e, 3) : (116 * e - 16) / Fr, Xr = ({ l: e, a: t, b: r, alpha: a }) => {
651
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
652
- let n = (e + 16) / 116, i = t / 500 + n, o = n - r / 200, s = {
653
- mode: "xyz65",
654
- x: at(i) * Y.X,
655
- y: at(n) * Y.Y,
656
- z: at(o) * Y.Z
657
- };
658
- return a !== void 0 && (s.alpha = a), s;
659
- }, je = (e) => D(Xr(e)), nt = (e) => e > Br ? Math.cbrt(e) : (Fr * e + 16) / 116, Yr = ({ x: e, y: t, z: r, alpha: a }) => {
660
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
661
- let n = nt(e / Y.X), i = nt(t / Y.Y), o = nt(r / Y.Z), s = {
662
- mode: "lab65",
663
- l: 116 * i - 16,
664
- a: 500 * (n - i),
665
- b: 200 * (i - o)
666
- };
667
- return a !== void 0 && (s.alpha = a), s;
668
- }, He = (e) => {
669
- let t = Yr(V(e));
670
- return e.r === e.b && e.b === e.g && (t.a = t.b = 0), t;
671
- }, de = 26 / 180 * Math.PI, ze = Math.cos(de), _e = Math.sin(de), Ur = 100 / Math.log(139 / 100), Pt = ({ l: e, c: t, h: r, alpha: a }) => {
672
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
673
- let n = {
674
- mode: "lab65",
675
- l: (Math.exp(e * 1 / Ur) - 1) / 39e-4
676
- }, i = (Math.exp(0.0435 * t * 1 * 1) - 1) / 0.075, o = i * Math.cos(r / 180 * Math.PI - de), s = i * Math.sin(r / 180 * Math.PI - de);
677
- return n.a = o * ze - s / 0.83 * _e, n.b = o * _e + s / 0.83 * ze, a !== void 0 && (n.alpha = a), n;
678
- }, $t = ({ l: e, a: t, b: r, alpha: a }) => {
679
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
680
- let n = t * ze + r * _e, i = 0.83 * (r * ze - t * _e), o = Math.sqrt(n * n + i * i), s = {
681
- mode: "dlch",
682
- l: Ur / 1 * Math.log(1 + 39e-4 * e),
683
- c: Math.log(1 + 0.075 * o) / (0.0435 * 1 * 1)
684
- };
685
- return s.c && (s.h = E((Math.atan2(i, n) + de) / Math.PI * 180)), a !== void 0 && (s.alpha = a), s;
686
- }, fr = (e) => Pt(I(e, "dlch")), mr = (e) => j($t(e), "dlab"), dn = {
687
- mode: "dlab",
688
- parse: ["--din99o-lab"],
689
- serialize: "--din99o-lab",
690
- toMode: {
691
- lab65: fr,
692
- rgb: (e) => je(fr(e))
693
- },
694
- fromMode: {
695
- lab65: mr,
696
- rgb: (e) => mr(He(e))
697
- },
698
- channels: [
699
- "l",
700
- "a",
701
- "b",
702
- "alpha"
703
- ],
704
- ranges: {
705
- l: [0, 100],
706
- a: [-40.09, 45.501],
707
- b: [-40.469, 44.344]
708
- },
709
- interpolate: {
710
- l: h,
711
- a: h,
712
- b: h,
713
- alpha: {
714
- use: h,
715
- fixup: S
716
- }
717
- }
718
- }, un = {
719
- mode: "dlch",
720
- parse: ["--din99o-lch"],
721
- serialize: "--din99o-lch",
722
- toMode: {
723
- lab65: Pt,
724
- dlab: (e) => j(e, "dlab"),
725
- rgb: (e) => je(Pt(e))
726
- },
727
- fromMode: {
728
- lab65: $t,
729
- dlab: (e) => I(e, "dlch"),
730
- rgb: (e) => $t(He(e))
731
- },
732
- channels: [
733
- "l",
734
- "c",
735
- "h",
736
- "alpha"
737
- ],
738
- ranges: {
739
- l: [0, 100],
740
- c: [0, 51.484],
741
- h: [0, 360]
742
- },
743
- interpolate: {
744
- l: h,
745
- c: h,
746
- h: {
747
- use: h,
748
- fixup: A
749
- },
750
- alpha: {
751
- use: h,
752
- fixup: S
753
- }
754
- },
755
- difference: { h: Ie },
756
- average: { h: L }
757
- };
758
- function cn({ h: e, s: t, i: r, alpha: a }) {
759
- e = E(e !== void 0 ? e : 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
760
- let n = Math.abs(e / 60 % 2 - 1), i;
761
- switch (Math.floor(e / 60)) {
762
- case 0:
763
- i = {
764
- r: r * (1 + t * (3 / (2 - n) - 1)),
765
- g: r * (1 + t * (3 * (1 - n) / (2 - n) - 1)),
766
- b: r * (1 - t)
767
- };
768
- break;
769
- case 1:
770
- i = {
771
- r: r * (1 + t * (3 * (1 - n) / (2 - n) - 1)),
772
- g: r * (1 + t * (3 / (2 - n) - 1)),
773
- b: r * (1 - t)
774
- };
775
- break;
776
- case 2:
777
- i = {
778
- r: r * (1 - t),
779
- g: r * (1 + t * (3 / (2 - n) - 1)),
780
- b: r * (1 + t * (3 * (1 - n) / (2 - n) - 1))
781
- };
782
- break;
783
- case 3:
784
- i = {
785
- r: r * (1 - t),
786
- g: r * (1 + t * (3 * (1 - n) / (2 - n) - 1)),
787
- b: r * (1 + t * (3 / (2 - n) - 1))
788
- };
789
- break;
790
- case 4:
791
- i = {
792
- r: r * (1 + t * (3 * (1 - n) / (2 - n) - 1)),
793
- g: r * (1 - t),
794
- b: r * (1 + t * (3 / (2 - n) - 1))
795
- };
796
- break;
797
- case 5:
798
- i = {
799
- r: r * (1 + t * (3 / (2 - n) - 1)),
800
- g: r * (1 - t),
801
- b: r * (1 + t * (3 * (1 - n) / (2 - n) - 1))
802
- };
803
- break;
804
- default:
805
- i = {
806
- r: r * (1 - t),
807
- g: r * (1 - t),
808
- b: r * (1 - t)
809
- };
810
- }
811
- return i.mode = "rgb", a !== void 0 && (i.alpha = a), i;
812
- }
813
- function hn({ r: e, g: t, b: r, alpha: a }) {
814
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
815
- let n = Math.max(e, t, r), i = Math.min(e, t, r), o = {
816
- mode: "hsi",
817
- s: e + t + r === 0 ? 0 : 1 - 3 * i / (e + t + r),
818
- i: (e + t + r) / 3
819
- };
820
- return n - i !== 0 && (o.h = (n === e ? (t - r) / (n - i) + (t < r) * 6 : n === t ? (r - e) / (n - i) + 2 : (e - t) / (n - i) + 4) * 60), a !== void 0 && (o.alpha = a), o;
821
- }
822
- var pn = {
823
- mode: "hsi",
824
- toMode: { rgb: cn },
825
- parse: ["--hsi"],
826
- serialize: "--hsi",
827
- fromMode: { rgb: hn },
828
- channels: [
829
- "h",
830
- "s",
831
- "i",
832
- "alpha"
833
- ],
834
- ranges: { h: [0, 360] },
835
- gamut: "rgb",
836
- interpolate: {
837
- h: {
838
- use: h,
839
- fixup: A
840
- },
841
- s: h,
842
- i: h,
843
- alpha: {
844
- use: h,
845
- fixup: S
846
- }
847
- },
848
- difference: { h: Re },
849
- average: { h: L }
850
- };
851
- function vn({ h: e, s: t, l: r, alpha: a }) {
852
- e = E(e !== void 0 ? e : 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
853
- let n = r + t * (r < 0.5 ? r : 1 - r), i = n - (n - r) * 2 * Math.abs(e / 60 % 2 - 1), o;
854
- switch (Math.floor(e / 60)) {
855
- case 0:
856
- o = {
857
- r: n,
858
- g: i,
859
- b: 2 * r - n
860
- };
861
- break;
862
- case 1:
863
- o = {
864
- r: i,
865
- g: n,
866
- b: 2 * r - n
867
- };
868
- break;
869
- case 2:
870
- o = {
871
- r: 2 * r - n,
872
- g: n,
873
- b: i
874
- };
875
- break;
876
- case 3:
877
- o = {
878
- r: 2 * r - n,
879
- g: i,
880
- b: n
881
- };
882
- break;
883
- case 4:
884
- o = {
885
- r: i,
886
- g: 2 * r - n,
887
- b: n
888
- };
889
- break;
890
- case 5:
891
- o = {
892
- r: n,
893
- g: 2 * r - n,
894
- b: i
895
- };
896
- break;
897
- default:
898
- o = {
899
- r: 2 * r - n,
900
- g: 2 * r - n,
901
- b: 2 * r - n
902
- };
903
- }
904
- return o.mode = "rgb", a !== void 0 && (o.alpha = a), o;
905
- }
906
- function fn({ r: e, g: t, b: r, alpha: a }) {
907
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
908
- let n = Math.max(e, t, r), i = Math.min(e, t, r), o = {
909
- mode: "hsl",
910
- s: n === i ? 0 : (n - i) / (1 - Math.abs(n + i - 1)),
911
- l: 0.5 * (n + i)
912
- };
913
- return n - i !== 0 && (o.h = (n === e ? (t - r) / (n - i) + (t < r) * 6 : n === t ? (r - e) / (n - i) + 2 : (e - t) / (n - i) + 4) * 60), a !== void 0 && (o.alpha = a), o;
914
- }
915
- var mn = (e, t) => {
916
- switch (t) {
917
- case "deg":
918
- return +e;
919
- case "rad":
920
- return e / Math.PI * 180;
921
- case "grad":
922
- return e / 10 * 9;
923
- case "turn":
924
- return e * 360;
925
- }
926
- }, gn = new RegExp(`^hsla?\\(\\s*${Na}${Z}${le}${Z}${le}\\s*(?:,\\s*${Vt}\\s*)?\\)$`), bn = (e) => {
927
- let t = e.match(gn);
928
- if (!t) return;
929
- let r = { mode: "hsl" };
930
- return t[3] !== void 0 ? r.h = +t[3] : t[1] !== void 0 && t[2] !== void 0 && (r.h = mn(t[1], t[2])), t[4] !== void 0 && (r.s = Math.min(Math.max(0, t[4] / 100), 1)), t[5] !== void 0 && (r.l = Math.min(Math.max(0, t[5] / 100), 1)), t[6] !== void 0 ? r.alpha = Math.max(0, Math.min(1, t[6] / 100)) : t[7] !== void 0 && (r.alpha = Math.max(0, Math.min(1, +t[7]))), r;
931
- };
932
- function yn(e, t) {
933
- if (!t || t[0] !== "hsl" && t[0] !== "hsla") return;
934
- const r = { mode: "hsl" }, [, a, n, i, o] = t;
935
- if (a.type !== u.None) {
936
- if (a.type === u.Percentage) return;
937
- r.h = a.value;
938
- }
939
- if (n.type !== u.None) {
940
- if (n.type === u.Hue) return;
941
- r.s = n.value / 100;
942
- }
943
- if (i.type !== u.None) {
944
- if (i.type === u.Hue) return;
945
- r.l = i.value / 100;
946
- }
947
- return o.type !== u.None && (r.alpha = Math.min(1, Math.max(0, o.type === u.Number ? o.value : o.value / 100))), r;
948
- }
949
- var Zr = {
950
- mode: "hsl",
951
- toMode: { rgb: vn },
952
- fromMode: { rgb: fn },
953
- channels: [
954
- "h",
955
- "s",
956
- "l",
957
- "alpha"
958
- ],
959
- ranges: { h: [0, 360] },
960
- gamut: "rgb",
961
- parse: [yn, bn],
962
- serialize: (e) => `hsl(${e.h !== void 0 ? e.h : "none"} ${e.s !== void 0 ? e.s * 100 + "%" : "none"} ${e.l !== void 0 ? e.l * 100 + "%" : "none"}${e.alpha < 1 ? ` / ${e.alpha}` : ""})`,
963
- interpolate: {
964
- h: {
965
- use: h,
966
- fixup: A
967
- },
968
- s: h,
969
- l: h,
970
- alpha: {
971
- use: h,
972
- fixup: S
973
- }
974
- },
975
- difference: { h: Re },
976
- average: { h: L }
977
- };
978
- function Jr({ h: e, s: t, v: r, alpha: a }) {
979
- e = E(e !== void 0 ? e : 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
980
- let n = Math.abs(e / 60 % 2 - 1), i;
981
- switch (Math.floor(e / 60)) {
982
- case 0:
983
- i = {
984
- r,
985
- g: r * (1 - t * n),
986
- b: r * (1 - t)
987
- };
988
- break;
989
- case 1:
990
- i = {
991
- r: r * (1 - t * n),
992
- g: r,
993
- b: r * (1 - t)
994
- };
995
- break;
996
- case 2:
997
- i = {
998
- r: r * (1 - t),
999
- g: r,
1000
- b: r * (1 - t * n)
1001
- };
1002
- break;
1003
- case 3:
1004
- i = {
1005
- r: r * (1 - t),
1006
- g: r * (1 - t * n),
1007
- b: r
1008
- };
1009
- break;
1010
- case 4:
1011
- i = {
1012
- r: r * (1 - t * n),
1013
- g: r * (1 - t),
1014
- b: r
1015
- };
1016
- break;
1017
- case 5:
1018
- i = {
1019
- r,
1020
- g: r * (1 - t),
1021
- b: r * (1 - t * n)
1022
- };
1023
- break;
1024
- default:
1025
- i = {
1026
- r: r * (1 - t),
1027
- g: r * (1 - t),
1028
- b: r * (1 - t)
1029
- };
1030
- }
1031
- return i.mode = "rgb", a !== void 0 && (i.alpha = a), i;
1032
- }
1033
- function Gr({ r: e, g: t, b: r, alpha: a }) {
1034
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1035
- let n = Math.max(e, t, r), i = Math.min(e, t, r), o = {
1036
- mode: "hsv",
1037
- s: n === 0 ? 0 : 1 - i / n,
1038
- v: n
1039
- };
1040
- return n - i !== 0 && (o.h = (n === e ? (t - r) / (n - i) + (t < r) * 6 : n === t ? (r - e) / (n - i) + 2 : (e - t) / (n - i) + 4) * 60), a !== void 0 && (o.alpha = a), o;
1041
- }
1042
- var Kr = {
1043
- mode: "hsv",
1044
- toMode: { rgb: Jr },
1045
- parse: ["--hsv"],
1046
- serialize: "--hsv",
1047
- fromMode: { rgb: Gr },
1048
- channels: [
1049
- "h",
1050
- "s",
1051
- "v",
1052
- "alpha"
1053
- ],
1054
- ranges: { h: [0, 360] },
1055
- gamut: "rgb",
1056
- interpolate: {
1057
- h: {
1058
- use: h,
1059
- fixup: A
1060
- },
1061
- s: h,
1062
- v: h,
1063
- alpha: {
1064
- use: h,
1065
- fixup: S
1066
- }
1067
- },
1068
- difference: { h: Re },
1069
- average: { h: L }
1070
- };
1071
- function Mn({ h: e, w: t, b: r, alpha: a }) {
1072
- if (t === void 0 && (t = 0), r === void 0 && (r = 0), t + r > 1) {
1073
- let n = t + r;
1074
- t /= n, r /= n;
1075
- }
1076
- return Jr({
1077
- h: e,
1078
- s: r === 1 ? 1 : 1 - t / (1 - r),
1079
- v: 1 - r,
1080
- alpha: a
1081
- });
1082
- }
1083
- function wn(e) {
1084
- let t = Gr(e);
1085
- if (t === void 0) return;
1086
- let r = t.s !== void 0 ? t.s : 0, a = t.v !== void 0 ? t.v : 0, n = {
1087
- mode: "hwb",
1088
- w: (1 - r) * a,
1089
- b: 1 - a
1090
- };
1091
- return t.h !== void 0 && (n.h = t.h), t.alpha !== void 0 && (n.alpha = t.alpha), n;
1092
- }
1093
- function xn(e, t) {
1094
- if (!t || t[0] !== "hwb") return;
1095
- const r = { mode: "hwb" }, [, a, n, i, o] = t;
1096
- if (a.type !== u.None) {
1097
- if (a.type === u.Percentage) return;
1098
- r.h = a.value;
1099
- }
1100
- if (n.type !== u.None) {
1101
- if (n.type === u.Hue) return;
1102
- r.w = n.value / 100;
1103
- }
1104
- if (i.type !== u.None) {
1105
- if (i.type === u.Hue) return;
1106
- r.b = i.value / 100;
1107
- }
1108
- return o.type !== u.None && (r.alpha = Math.min(1, Math.max(0, o.type === u.Number ? o.value : o.value / 100))), r;
1109
- }
1110
- var Sn = {
1111
- mode: "hwb",
1112
- toMode: { rgb: Mn },
1113
- fromMode: { rgb: wn },
1114
- channels: [
1115
- "h",
1116
- "w",
1117
- "b",
1118
- "alpha"
1119
- ],
1120
- ranges: { h: [0, 360] },
1121
- gamut: "rgb",
1122
- parse: [xn],
1123
- serialize: (e) => `hwb(${e.h !== void 0 ? e.h : "none"} ${e.w !== void 0 ? e.w * 100 + "%" : "none"} ${e.b !== void 0 ? e.b * 100 + "%" : "none"}${e.alpha < 1 ? ` / ${e.alpha}` : ""})`,
1124
- interpolate: {
1125
- h: {
1126
- use: h,
1127
- fixup: A
1128
- },
1129
- w: h,
1130
- b: h,
1131
- alpha: {
1132
- use: h,
1133
- fixup: S
1134
- }
1135
- },
1136
- difference: { h: sn },
1137
- average: { h: L }
1138
- }, Oe = 0.1593017578125, Qr = 78.84375, We = 0.8359375, qe = 18.8515625, Ve = 18.6875;
1139
- function it(e) {
1140
- if (e < 0) return 0;
1141
- const t = Math.pow(e, 1 / Qr);
1142
- return 1e4 * Math.pow(Math.max(0, t - We) / (qe - Ve * t), 1 / Oe);
1143
- }
1144
- function ot(e) {
1145
- if (e < 0) return 0;
1146
- const t = Math.pow(e / 1e4, Oe);
1147
- return Math.pow((We + qe * t) / (1 + Ve * t), Qr);
1148
- }
1149
- var st = (e) => Math.max(e / 203, 0), gr = ({ i: e, t, p: r, alpha: a }) => {
1150
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1151
- const n = it(e + 0.008609037037932761 * t + 0.11102962500302593 * r), i = it(e - 0.00860903703793275 * t - 0.11102962500302599 * r), o = it(e + 0.5600313357106791 * t - 0.32062717498731885 * r), s = {
1152
- mode: "xyz65",
1153
- x: st(2.070152218389422 * n - 1.3263473389671556 * i + 0.2066510476294051 * o),
1154
- y: st(0.3647385209748074 * n + 0.680566024947227 * i - 0.0453045459220346 * o),
1155
- z: st(-0.049747207535812 * n - 0.0492609666966138 * i + 1.1880659249923042 * o)
1156
- };
1157
- return a !== void 0 && (s.alpha = a), s;
1158
- }, lt = (e = 0) => Math.max(e * 203, 0), br = ({ x: e, y: t, z: r, alpha: a }) => {
1159
- const n = lt(e), i = lt(t), o = lt(r), s = ot(0.3592832590121217 * n + 0.6976051147779502 * i - 0.0358915932320289 * o), l = ot(-0.1920808463704995 * n + 1.1004767970374323 * i + 0.0753748658519118 * o), d = ot(0.0070797844607477 * n + 0.0748396662186366 * i + 0.8433265453898765 * o), p = {
1160
- mode: "itp",
1161
- i: 0.5 * s + 0.5 * l,
1162
- t: 1.61376953125 * s - 3.323486328125 * l + 1.709716796875 * d,
1163
- p: 4.378173828125 * s - 4.24560546875 * l - 0.132568359375 * d
1164
- };
1165
- return a !== void 0 && (p.alpha = a), p;
1166
- }, kn = {
1167
- mode: "itp",
1168
- channels: [
1169
- "i",
1170
- "t",
1171
- "p",
1172
- "alpha"
1173
- ],
1174
- parse: ["--ictcp"],
1175
- serialize: "--ictcp",
1176
- toMode: {
1177
- xyz65: gr,
1178
- rgb: (e) => D(gr(e))
1179
- },
1180
- fromMode: {
1181
- xyz65: br,
1182
- rgb: (e) => br(V(e))
1183
- },
1184
- ranges: {
1185
- i: [0, 0.581],
1186
- t: [-0.369, 0.272],
1187
- p: [-0.164, 0.331]
1188
- },
1189
- interpolate: {
1190
- i: h,
1191
- t: h,
1192
- p: h,
1193
- alpha: {
1194
- use: h,
1195
- fixup: S
1196
- }
1197
- }
1198
- }, En = 134.03437499999998, Tn = 16295499532821565e-27, dt = (e) => {
1199
- if (e < 0) return 0;
1200
- let t = Math.pow(e / 1e4, Oe);
1201
- return Math.pow((We + qe * t) / (1 + Ve * t), En);
1202
- }, ut = (e = 0) => Math.max(e * 203, 0), ea = ({ x: e, y: t, z: r, alpha: a }) => {
1203
- e = ut(e), t = ut(t), r = ut(r);
1204
- let n = 1.15 * e - 0.15 * r, i = 0.66 * t + 0.34 * e, o = dt(0.41478972 * n + 0.579999 * i + 0.014648 * r), s = dt(-0.20151 * n + 1.120649 * i + 0.0531008 * r), l = dt(-0.0166008 * n + 0.2648 * i + 0.6684799 * r), d = (o + s) / 2, p = {
1205
- mode: "jab",
1206
- j: 0.44 * d / (1 - 0.56 * d) - Tn,
1207
- a: 3.524 * o - 4.066708 * s + 0.542708 * l,
1208
- b: 0.199076 * o + 1.096799 * s - 1.295875 * l
1209
- };
1210
- return a !== void 0 && (p.alpha = a), p;
1211
- }, zn = 134.03437499999998, yr = 16295499532821565e-27, ct = (e) => {
1212
- if (e < 0) return 0;
1213
- let t = Math.pow(e, 1 / zn);
1214
- return 1e4 * Math.pow((We - t) / (Ve * t - qe), 1 / Oe);
1215
- }, ht = (e) => e / 203, ta = ({ j: e, a: t, b: r, alpha: a }) => {
1216
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1217
- let n = (e + yr) / (0.44 + 0.56 * (e + yr)), i = ct(n + 0.13860504 * t + 0.058047316 * r), o = ct(n - 0.13860504 * t - 0.058047316 * r), s = ct(n - 0.096019242 * t - 0.8118919 * r), l = {
1218
- mode: "xyz65",
1219
- x: ht(1.661373024652174 * i - 0.914523081304348 * o + 0.23136208173913045 * s),
1220
- y: ht(-0.3250758611844533 * i + 1.571847026732543 * o - 0.21825383453227928 * s),
1221
- z: ht(-0.090982811 * i - 0.31272829 * o + 1.5227666 * s)
1222
- };
1223
- return a !== void 0 && (l.alpha = a), l;
1224
- }, ra = (e) => {
1225
- let t = ea(V(e));
1226
- return e.r === e.b && e.b === e.g && (t.a = t.b = 0), t;
1227
- }, aa = (e) => D(ta(e)), _n = {
1228
- mode: "jab",
1229
- channels: [
1230
- "j",
1231
- "a",
1232
- "b",
1233
- "alpha"
1234
- ],
1235
- parse: ["--jzazbz"],
1236
- serialize: "--jzazbz",
1237
- fromMode: {
1238
- rgb: ra,
1239
- xyz65: ea
1240
- },
1241
- toMode: {
1242
- rgb: aa,
1243
- xyz65: ta
1244
- },
1245
- ranges: {
1246
- j: [0, 0.222],
1247
- a: [-0.109, 0.129],
1248
- b: [-0.185, 0.134]
1249
- },
1250
- interpolate: {
1251
- j: h,
1252
- a: h,
1253
- b: h,
1254
- alpha: {
1255
- use: h,
1256
- fixup: S
1257
- }
1258
- }
1259
- }, Mr = ({ j: e, a: t, b: r, alpha: a }) => {
1260
- t === void 0 && (t = 0), r === void 0 && (r = 0);
1261
- let n = Math.sqrt(t * t + r * r), i = {
1262
- mode: "jch",
1263
- j: e,
1264
- c: n
1265
- };
1266
- return n && (i.h = E(Math.atan2(r, t) * 180 / Math.PI)), a !== void 0 && (i.alpha = a), i;
1267
- }, wr = ({ j: e, c: t, h: r, alpha: a }) => {
1268
- r === void 0 && (r = 0);
1269
- let n = {
1270
- mode: "jab",
1271
- j: e,
1272
- a: t ? t * Math.cos(r / 180 * Math.PI) : 0,
1273
- b: t ? t * Math.sin(r / 180 * Math.PI) : 0
1274
- };
1275
- return a !== void 0 && (n.alpha = a), n;
1276
- }, Pn = {
1277
- mode: "jch",
1278
- parse: ["--jzczhz"],
1279
- serialize: "--jzczhz",
1280
- toMode: {
1281
- jab: wr,
1282
- rgb: (e) => aa(wr(e))
1283
- },
1284
- fromMode: {
1285
- rgb: (e) => Mr(ra(e)),
1286
- jab: Mr
1287
- },
1288
- channels: [
1289
- "j",
1290
- "c",
1291
- "h",
1292
- "alpha"
1293
- ],
1294
- ranges: {
1295
- j: [0, 0.221],
1296
- c: [0, 0.19],
1297
- h: [0, 360]
1298
- },
1299
- interpolate: {
1300
- h: {
1301
- use: h,
1302
- fixup: A
1303
- },
1304
- c: h,
1305
- j: h,
1306
- alpha: {
1307
- use: h,
1308
- fixup: S
1309
- }
1310
- },
1311
- difference: { h: Ie },
1312
- average: { h: L }
1313
- }, De = Math.pow(29, 3) / Math.pow(3, 3), Ft = Math.pow(6, 3) / Math.pow(29, 3), pt = (e) => Math.pow(e, 3) > Ft ? Math.pow(e, 3) : (116 * e - 16) / De, Bt = ({ l: e, a: t, b: r, alpha: a }) => {
1314
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1315
- let n = (e + 16) / 116, i = t / 500 + n, o = n - r / 200, s = {
1316
- mode: "xyz50",
1317
- x: pt(i) * x.X,
1318
- y: pt(n) * x.Y,
1319
- z: pt(o) * x.Z
1320
- };
1321
- return a !== void 0 && (s.alpha = a), s;
1322
- }, he = ({ x: e, y: t, z: r, alpha: a }) => {
1323
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1324
- let n = K({
1325
- r: e * 3.1341359569958707 - t * 1.6173863321612538 - 0.4906619460083532 * r,
1326
- g: e * -0.978795502912089 + t * 1.916254567259524 + 0.03344273116131949 * r,
1327
- b: e * 0.07195537988411677 - t * 0.2289768264158322 + 1.405386058324125 * r
1328
- });
1329
- return a !== void 0 && (n.alpha = a), n;
1330
- }, na = (e) => he(Bt(e)), pe = (e) => {
1331
- let { r: t, g: r, b: a, alpha: n } = G(e), i = {
1332
- mode: "xyz50",
1333
- x: 0.436065742824811 * t + 0.3851514688337912 * r + 0.14307845442264197 * a,
1334
- y: 0.22249319175623702 * t + 0.7168870538238823 * r + 0.06061979053616537 * a,
1335
- z: 0.013923904500943465 * t + 0.09708128566574634 * r + 0.7140993584005155 * a
1336
- };
1337
- return n !== void 0 && (i.alpha = n), i;
1338
- }, vt = (e) => e > Ft ? Math.cbrt(e) : (De * e + 16) / 116, Xt = ({ x: e, y: t, z: r, alpha: a }) => {
1339
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1340
- let n = vt(e / x.X), i = vt(t / x.Y), o = vt(r / x.Z), s = {
1341
- mode: "lab",
1342
- l: 116 * i - 16,
1343
- a: 500 * (n - i),
1344
- b: 200 * (i - o)
1345
- };
1346
- return a !== void 0 && (s.alpha = a), s;
1347
- }, ia = (e) => {
1348
- let t = Xt(pe(e));
1349
- return e.r === e.b && e.b === e.g && (t.a = t.b = 0), t;
1350
- };
1351
- function $n(e, t) {
1352
- if (!t || t[0] !== "lab") return;
1353
- const r = { mode: "lab" }, [, a, n, i, o] = t;
1354
- if (!(a.type === u.Hue || n.type === u.Hue || i.type === u.Hue))
1355
- return a.type !== u.None && (r.l = Math.min(Math.max(0, a.value), 100)), n.type !== u.None && (r.a = n.type === u.Number ? n.value : n.value * 125 / 100), i.type !== u.None && (r.b = i.type === u.Number ? i.value : i.value * 125 / 100), o.type !== u.None && (r.alpha = Math.min(1, Math.max(0, o.type === u.Number ? o.value : o.value / 100))), r;
1356
- }
1357
- var Yt = {
1358
- mode: "lab",
1359
- toMode: {
1360
- xyz50: Bt,
1361
- rgb: na
1362
- },
1363
- fromMode: {
1364
- xyz50: Xt,
1365
- rgb: ia
1366
- },
1367
- channels: [
1368
- "l",
1369
- "a",
1370
- "b",
1371
- "alpha"
1372
- ],
1373
- ranges: {
1374
- l: [0, 100],
1375
- a: [-125, 125],
1376
- b: [-125, 125]
1377
- },
1378
- parse: [$n],
1379
- serialize: (e) => `lab(${e.l !== void 0 ? e.l : "none"} ${e.a !== void 0 ? e.a : "none"} ${e.b !== void 0 ? e.b : "none"}${e.alpha < 1 ? ` / ${e.alpha}` : ""})`,
1380
- interpolate: {
1381
- l: h,
1382
- a: h,
1383
- b: h,
1384
- alpha: {
1385
- use: h,
1386
- fixup: S
1387
- }
1388
- }
1389
- }, Cn = {
1390
- ...Yt,
1391
- mode: "lab65",
1392
- parse: ["--lab-d65"],
1393
- serialize: "--lab-d65",
1394
- toMode: {
1395
- xyz65: Xr,
1396
- rgb: je
1397
- },
1398
- fromMode: {
1399
- xyz65: Yr,
1400
- rgb: He
1401
- },
1402
- ranges: {
1403
- l: [0, 100],
1404
- a: [-125, 125],
1405
- b: [-125, 125]
1406
- }
1407
- };
1408
- function An(e, t) {
1409
- if (!t || t[0] !== "lch") return;
1410
- const r = { mode: "lch" }, [, a, n, i, o] = t;
1411
- if (a.type !== u.None) {
1412
- if (a.type === u.Hue) return;
1413
- r.l = Math.min(Math.max(0, a.value), 100);
1414
- }
1415
- if (n.type !== u.None && (r.c = Math.max(0, n.type === u.Number ? n.value : n.value * 150 / 100)), i.type !== u.None) {
1416
- if (i.type === u.Percentage) return;
1417
- r.h = i.value;
1418
- }
1419
- return o.type !== u.None && (r.alpha = Math.min(1, Math.max(0, o.type === u.Number ? o.value : o.value / 100))), r;
1420
- }
1421
- var Ut = {
1422
- mode: "lch",
1423
- toMode: {
1424
- lab: j,
1425
- rgb: (e) => na(j(e))
1426
- },
1427
- fromMode: {
1428
- rgb: (e) => I(ia(e)),
1429
- lab: I
1430
- },
1431
- channels: [
1432
- "l",
1433
- "c",
1434
- "h",
1435
- "alpha"
1436
- ],
1437
- ranges: {
1438
- l: [0, 100],
1439
- c: [0, 150],
1440
- h: [0, 360]
1441
- },
1442
- parse: [An],
1443
- serialize: (e) => `lch(${e.l !== void 0 ? e.l : "none"} ${e.c !== void 0 ? e.c : "none"} ${e.h !== void 0 ? e.h : "none"}${e.alpha < 1 ? ` / ${e.alpha}` : ""})`,
1444
- interpolate: {
1445
- h: {
1446
- use: h,
1447
- fixup: A
1448
- },
1449
- c: h,
1450
- l: h,
1451
- alpha: {
1452
- use: h,
1453
- fixup: S
1454
- }
1455
- },
1456
- difference: { h: Ie },
1457
- average: { h: L }
1458
- }, Ln = {
1459
- ...Ut,
1460
- mode: "lch65",
1461
- parse: ["--lch-d65"],
1462
- serialize: "--lch-d65",
1463
- toMode: {
1464
- lab65: (e) => j(e, "lab65"),
1465
- rgb: (e) => je(j(e, "lab65"))
1466
- },
1467
- fromMode: {
1468
- rgb: (e) => I(He(e), "lch65"),
1469
- lab65: (e) => I(e, "lch65")
1470
- },
1471
- ranges: {
1472
- l: [0, 100],
1473
- c: [0, 150],
1474
- h: [0, 360]
1475
- }
1476
- }, oa = ({ l: e, u: t, v: r, alpha: a }) => {
1477
- t === void 0 && (t = 0), r === void 0 && (r = 0);
1478
- let n = Math.sqrt(t * t + r * r), i = {
1479
- mode: "lchuv",
1480
- l: e,
1481
- c: n
1482
- };
1483
- return n && (i.h = E(Math.atan2(r, t) * 180 / Math.PI)), a !== void 0 && (i.alpha = a), i;
1484
- }, sa = ({ l: e, c: t, h: r, alpha: a }) => {
1485
- r === void 0 && (r = 0);
1486
- let n = {
1487
- mode: "luv",
1488
- l: e,
1489
- u: t ? t * Math.cos(r / 180 * Math.PI) : 0,
1490
- v: t ? t * Math.sin(r / 180 * Math.PI) : 0
1491
- };
1492
- return a !== void 0 && (n.alpha = a), n;
1493
- }, la = (e, t, r) => 4 * e / (e + 15 * t + 3 * r), da = (e, t, r) => 9 * t / (e + 15 * t + 3 * r), Nn = la(x.X, x.Y, x.Z), Rn = da(x.X, x.Y, x.Z), In = (e) => e <= Ft ? De * e : 116 * Math.cbrt(e) - 16, Ct = ({ x: e, y: t, z: r, alpha: a }) => {
1494
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1495
- let n = In(t / x.Y), i = la(e, t, r), o = da(e, t, r);
1496
- !isFinite(i) || !isFinite(o) ? n = i = o = 0 : (i = 13 * n * (i - Nn), o = 13 * n * (o - Rn));
1497
- let s = {
1498
- mode: "luv",
1499
- l: n,
1500
- u: i,
1501
- v: o
1502
- };
1503
- return a !== void 0 && (s.alpha = a), s;
1504
- }, jn = (e, t, r) => 4 * e / (e + 15 * t + 3 * r), Hn = (e, t, r) => 9 * t / (e + 15 * t + 3 * r), On = jn(x.X, x.Y, x.Z), Wn = Hn(x.X, x.Y, x.Z), At = ({ l: e, u: t, v: r, alpha: a }) => {
1505
- if (e === void 0 && (e = 0), e === 0) return {
1506
- mode: "xyz50",
1507
- x: 0,
1508
- y: 0,
1509
- z: 0
1510
- };
1511
- t === void 0 && (t = 0), r === void 0 && (r = 0);
1512
- let n = t / (13 * e) + On, i = r / (13 * e) + Wn, o = x.Y * (e <= 8 ? e / De : Math.pow((e + 16) / 116, 3)), s = {
1513
- mode: "xyz50",
1514
- x: o * (9 * n) / (4 * i),
1515
- y: o,
1516
- z: o * (12 - 3 * n - 20 * i) / (4 * i)
1517
- };
1518
- return a !== void 0 && (s.alpha = a), s;
1519
- }, qn = (e) => oa(Ct(pe(e))), Vn = (e) => he(At(sa(e))), Dn = {
1520
- mode: "lchuv",
1521
- toMode: {
1522
- luv: sa,
1523
- rgb: Vn
1524
- },
1525
- fromMode: {
1526
- rgb: qn,
1527
- luv: oa
1528
- },
1529
- channels: [
1530
- "l",
1531
- "c",
1532
- "h",
1533
- "alpha"
1534
- ],
1535
- parse: ["--lchuv"],
1536
- serialize: "--lchuv",
1537
- ranges: {
1538
- l: [0, 100],
1539
- c: [0, 176.956],
1540
- h: [0, 360]
1541
- },
1542
- interpolate: {
1543
- h: {
1544
- use: h,
1545
- fixup: A
1546
- },
1547
- c: h,
1548
- l: h,
1549
- alpha: {
1550
- use: h,
1551
- fixup: S
1552
- }
1553
- },
1554
- difference: { h: Ie },
1555
- average: { h: L }
1556
- }, Fn = {
1557
- ...J,
1558
- mode: "lrgb",
1559
- toMode: { rgb: K },
1560
- fromMode: { rgb: G },
1561
- parse: ["srgb-linear"],
1562
- serialize: "srgb-linear"
1563
- }, Bn = {
1564
- mode: "luv",
1565
- toMode: {
1566
- xyz50: At,
1567
- rgb: (e) => he(At(e))
1568
- },
1569
- fromMode: {
1570
- xyz50: Ct,
1571
- rgb: (e) => Ct(pe(e))
1572
- },
1573
- channels: [
1574
- "l",
1575
- "u",
1576
- "v",
1577
- "alpha"
1578
- ],
1579
- parse: ["--luv"],
1580
- serialize: "--luv",
1581
- ranges: {
1582
- l: [0, 100],
1583
- u: [-84.936, 175.042],
1584
- v: [-125.882, 87.243]
1585
- },
1586
- interpolate: {
1587
- l: h,
1588
- u: h,
1589
- v: h,
1590
- alpha: {
1591
- use: h,
1592
- fixup: S
1593
- }
1594
- }
1595
- }, ua = ({ r: e, g: t, b: r, alpha: a }) => {
1596
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1597
- let n = Math.cbrt(0.412221469470763 * e + 0.5363325372617348 * t + 0.0514459932675022 * r), i = Math.cbrt(0.2119034958178252 * e + 0.6806995506452344 * t + 0.1073969535369406 * r), o = Math.cbrt(0.0883024591900564 * e + 0.2817188391361215 * t + 0.6299787016738222 * r), s = {
1598
- mode: "oklab",
1599
- l: 0.210454268309314 * n + 0.7936177747023054 * i - 0.0040720430116193 * o,
1600
- a: 1.9779985324311684 * n - 2.42859224204858 * i + 0.450593709617411 * o,
1601
- b: 0.0259040424655478 * n + 0.7827717124575296 * i - 0.8086757549230774 * o
1602
- };
1603
- return a !== void 0 && (s.alpha = a), s;
1604
- }, Fe = (e) => {
1605
- let t = ua(G(e));
1606
- return e.r === e.b && e.b === e.g && (t.a = t.b = 0), t;
1607
- }, ve = ({ l: e, a: t, b: r, alpha: a }) => {
1608
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1609
- let n = Math.pow(e + 0.3963377773761749 * t + 0.2158037573099136 * r, 3), i = Math.pow(e - 0.1055613458156586 * t - 0.0638541728258133 * r, 3), o = Math.pow(e - 0.0894841775298119 * t - 1.2914855480194092 * r, 3), s = {
1610
- mode: "lrgb",
1611
- r: 4.076741636075957 * n - 3.3077115392580616 * i + 0.2309699031821044 * o,
1612
- g: -1.2684379732850317 * n + 2.6097573492876887 * i - 0.3413193760026573 * o,
1613
- b: -0.0041960761386756 * n - 0.7034186179359362 * i + 1.7076146940746117 * o
1614
- };
1615
- return a !== void 0 && (s.alpha = a), s;
1616
- }, Be = (e) => K(ve(e));
1617
- function Lt(e) {
1618
- const a = 1.170873786407767;
1619
- return 0.5 * (a * e - 0.206 + Math.sqrt((a * e - 0.206) * (a * e - 0.206) + 4 * 0.03 * a * e));
1620
- }
1621
- function Pe(e) {
1622
- return (e * e + 0.206 * e) / (1.206 / 1.03 * (e + 0.03));
1623
- }
1624
- function Xn(e, t) {
1625
- let r, a, n, i, o, s, l, d;
1626
- -1.88170328 * e - 0.80936493 * t > 1 ? (r = 1.19086277, a = 1.76576728, n = 0.59662641, i = 0.75515197, o = 0.56771245, s = 4.0767416621, l = -3.3077115913, d = 0.2309699292) : 1.81444104 * e - 1.19445276 * t > 1 ? (r = 0.73956515, a = -0.45954404, n = 0.08285427, i = 0.1254107, o = 0.14503204, s = -1.2684380046, l = 2.6097574011, d = -0.3413193965) : (r = 1.35733652, a = -915799e-8, n = -1.1513021, i = -0.50559606, o = 692167e-8, s = -0.0041960863, l = -0.7034186147, d = 1.707614701);
1627
- let p = r + a * e + n * t + i * e * e + o * e * t, v = 0.3963377774 * e + 0.2158037573 * t, c = -0.1055613458 * e - 0.0638541728 * t, m = -0.0894841775 * e - 1.291485548 * t;
1628
- {
1629
- let f = 1 + p * v, b = 1 + p * c, M = 1 + p * m, z = f * f * f, T = b * b * b, N = M * M * M, Q = 3 * v * f * f, ee = 3 * c * b * b, te = 3 * m * M * M, re = 6 * v * v * f, ae = 6 * c * c * b, ne = 6 * m * m * M, F = s * z + l * T + d * N, W = s * Q + l * ee + d * te, ie = s * re + l * ae + d * ne;
1630
- p = p - F * W / (W * W - 0.5 * F * ie);
1631
- }
1632
- return p;
1633
- }
1634
- function Zt(e, t) {
1635
- let r = Xn(e, t), a = ve({
1636
- l: 1,
1637
- a: r * e,
1638
- b: r * t
1639
- }), n = Math.cbrt(1 / Math.max(a.r, a.g, a.b));
1640
- return [n, n * r];
1641
- }
1642
- function Yn(e, t, r, a, n, i = null) {
1643
- i || (i = Zt(e, t));
1644
- let o;
1645
- if ((r - n) * i[1] - (i[0] - n) * a <= 0) o = i[1] * n / (a * i[0] + i[1] * (n - r));
1646
- else {
1647
- o = i[1] * (n - 1) / (a * (i[0] - 1) + i[1] * (n - r));
1648
- {
1649
- let s = r - n, l = a, d = 0.3963377774 * e + 0.2158037573 * t, p = -0.1055613458 * e - 0.0638541728 * t, v = -0.0894841775 * e - 1.291485548 * t, c = s + l * d, m = s + l * p, f = s + l * v;
1650
- {
1651
- let b = n * (1 - o) + o * r, M = o * a, z = b + M * d, T = b + M * p, N = b + M * v, Q = z * z * z, ee = T * T * T, te = N * N * N, re = 3 * c * z * z, ae = 3 * m * T * T, ne = 3 * f * N * N, F = 6 * c * c * z, W = 6 * m * m * T, ie = 6 * f * f * N, nr = 4.0767416621 * Q - 3.3077115913 * ee + 0.2309699292 * te - 1, Ye = 4.0767416621 * re - 3.3077115913 * ae + 0.2309699292 * ne, Ta = 4.0767416621 * F - 3.3077115913 * W + 0.2309699292 * ie, ir = Ye / (Ye * Ye - 0.5 * nr * Ta), Ue = -nr * ir, or = -1.2684380046 * Q + 2.6097574011 * ee - 0.3413193965 * te - 1, Ze = -1.2684380046 * re + 2.6097574011 * ae - 0.3413193965 * ne, za = -1.2684380046 * F + 2.6097574011 * W - 0.3413193965 * ie, sr = Ze / (Ze * Ze - 0.5 * or * za), Je = -or * sr, lr = -0.0041960863 * Q - 0.7034186147 * ee + 1.707614701 * te - 1, Ge = -0.0041960863 * re - 0.7034186147 * ae + 1.707614701 * ne, _a = -0.0041960863 * F - 0.7034186147 * W + 1.707614701 * ie, dr = Ge / (Ge * Ge - 0.5 * lr * _a), Ke = -lr * dr;
1652
- Ue = ir >= 0 ? Ue : 1e6, Je = sr >= 0 ? Je : 1e6, Ke = dr >= 0 ? Ke : 1e6, o += Math.min(Ue, Math.min(Je, Ke));
1653
- }
1654
- }
1655
- }
1656
- return o;
1657
- }
1658
- function Jt(e, t, r = null) {
1659
- r || (r = Zt(e, t));
1660
- let a = r[0], n = r[1];
1661
- return [n / a, n / (1 - a)];
1662
- }
1663
- function ca(e, t, r) {
1664
- let a = Zt(t, r), n = Yn(t, r, e, 1, e, a), i = Jt(t, r, a), o = 0.11516993 + 1 / (7.4477897 + 4.1590124 * r + t * (-2.19557347 + 1.75198401 * r + t * (-2.13704948 - 10.02301043 * r + t * (-4.24894561 + 5.38770819 * r + 4.69891013 * t)))), s = 0.11239642 + 1 / (1.6132032 - 0.68124379 * r + t * (0.40370612 + 0.90148123 * r + t * (-0.27087943 + 0.6122399 * r + t * (299215e-8 - 0.45399568 * r - 0.14661872 * t)))), l = n / Math.min(e * i[0], (1 - e) * i[1]), d = e * o, p = (1 - e) * s, v = 0.9 * l * Math.sqrt(Math.sqrt(1 / (1 / (d * d * d * d) + 1 / (p * p * p * p))));
1665
- return d = e * 0.4, p = (1 - e) * 0.8, [
1666
- Math.sqrt(1 / (1 / (d * d) + 1 / (p * p))),
1667
- v,
1668
- n
1669
- ];
1670
- }
1671
- function xr(e) {
1672
- const t = e.l !== void 0 ? e.l : 0, r = e.a !== void 0 ? e.a : 0, a = e.b !== void 0 ? e.b : 0, n = {
1673
- mode: "okhsl",
1674
- l: Lt(t)
1675
- };
1676
- e.alpha !== void 0 && (n.alpha = e.alpha);
1677
- let i = Math.sqrt(r * r + a * a);
1678
- if (!i)
1679
- return n.s = 0, n;
1680
- let [o, s, l] = ca(t, r / i, a / i), d;
1681
- if (i < s) {
1682
- let p = 0, v = 0.8 * o, c = 1 - v / s;
1683
- d = (i - p) / (v + c * (i - p)) * 0.8;
1684
- } else {
1685
- let p = s, v = 0.2 * s * s * 1.25 * 1.25 / o, c = 1 - v / (l - s);
1686
- d = 0.8 + 0.2 * ((i - p) / (v + c * (i - p)));
1687
- }
1688
- return d && (n.s = d, n.h = E(Math.atan2(a, r) * 180 / Math.PI)), n;
1689
- }
1690
- function Sr(e) {
1691
- let t = e.h !== void 0 ? e.h : 0, r = e.s !== void 0 ? e.s : 0, a = e.l !== void 0 ? e.l : 0;
1692
- const n = {
1693
- mode: "oklab",
1694
- l: Pe(a)
1695
- };
1696
- if (e.alpha !== void 0 && (n.alpha = e.alpha), !r || a === 1)
1697
- return n.a = n.b = 0, n;
1698
- let i = Math.cos(t / 180 * Math.PI), o = Math.sin(t / 180 * Math.PI), [s, l, d] = ca(n.l, i, o), p, v, c, m;
1699
- r < 0.8 ? (p = 1.25 * r, v = 0, c = 0.8 * s, m = 1 - c / l) : (p = 5 * (r - 0.8), v = l, c = 0.2 * l * l * 1.25 * 1.25 / s, m = 1 - c / (d - l));
1700
- let f = v + p * c / (1 - m * p);
1701
- return n.a = f * i, n.b = f * o, n;
1702
- }
1703
- var Un = {
1704
- ...Zr,
1705
- mode: "okhsl",
1706
- channels: [
1707
- "h",
1708
- "s",
1709
- "l",
1710
- "alpha"
1711
- ],
1712
- parse: ["--okhsl"],
1713
- serialize: "--okhsl",
1714
- fromMode: {
1715
- oklab: xr,
1716
- rgb: (e) => xr(Fe(e))
1717
- },
1718
- toMode: {
1719
- oklab: Sr,
1720
- rgb: (e) => Be(Sr(e))
1721
- }
1722
- };
1723
- function kr(e) {
1724
- let t = e.l !== void 0 ? e.l : 0, r = e.a !== void 0 ? e.a : 0, a = e.b !== void 0 ? e.b : 0, n = Math.sqrt(r * r + a * a), i = n ? r / n : 1, o = n ? a / n : 1, [s, l] = Jt(i, o), d = 0.5, p = 1 - d / s, v = l / (n + t * l), c = v * t, m = v * n, f = Pe(c), b = m * f / c, M = ve({
1725
- l: f,
1726
- a: i * b,
1727
- b: o * b
1728
- }), z = Math.cbrt(1 / Math.max(M.r, M.g, M.b, 0));
1729
- t = t / z, n = n / z * Lt(t) / t, t = Lt(t);
1730
- const T = {
1731
- mode: "okhsv",
1732
- s: n ? (d + l) * m / (l * d + l * p * m) : 0,
1733
- v: t ? t / c : 0
1734
- };
1735
- return T.s && (T.h = E(Math.atan2(a, r) * 180 / Math.PI)), e.alpha !== void 0 && (T.alpha = e.alpha), T;
1736
- }
1737
- function Er(e) {
1738
- const t = { mode: "oklab" };
1739
- e.alpha !== void 0 && (t.alpha = e.alpha);
1740
- const r = e.h !== void 0 ? e.h : 0, a = e.s !== void 0 ? e.s : 0, n = e.v !== void 0 ? e.v : 0, i = Math.cos(r / 180 * Math.PI), o = Math.sin(r / 180 * Math.PI), [s, l] = Jt(i, o), d = 0.5, p = 1 - d / s, v = 1 - a * d / (d + l - l * p * a), c = a * l * d / (d + l - l * p * a), m = Pe(v), f = c * m / v, b = ve({
1741
- l: m,
1742
- a: i * f,
1743
- b: o * f
1744
- }), M = Math.cbrt(1 / Math.max(b.r, b.g, b.b, 0)), z = Pe(n * v), T = c * z / v;
1745
- return t.l = z * M, t.a = T * i * M, t.b = T * o * M, t;
1746
- }
1747
- var Zn = {
1748
- ...Kr,
1749
- mode: "okhsv",
1750
- channels: [
1751
- "h",
1752
- "s",
1753
- "v",
1754
- "alpha"
1755
- ],
1756
- parse: ["--okhsv"],
1757
- serialize: "--okhsv",
1758
- fromMode: {
1759
- oklab: kr,
1760
- rgb: (e) => kr(Fe(e))
1761
- },
1762
- toMode: {
1763
- oklab: Er,
1764
- rgb: (e) => Be(Er(e))
1765
- }
1766
- };
1767
- function Jn(e, t) {
1768
- if (!t || t[0] !== "oklab") return;
1769
- const r = { mode: "oklab" }, [, a, n, i, o] = t;
1770
- if (!(a.type === u.Hue || n.type === u.Hue || i.type === u.Hue))
1771
- return a.type !== u.None && (r.l = Math.min(Math.max(0, a.type === u.Number ? a.value : a.value / 100), 1)), n.type !== u.None && (r.a = n.type === u.Number ? n.value : n.value * 0.4 / 100), i.type !== u.None && (r.b = i.type === u.Number ? i.value : i.value * 0.4 / 100), o.type !== u.None && (r.alpha = Math.min(1, Math.max(0, o.type === u.Number ? o.value : o.value / 100))), r;
1772
- }
1773
- var Gn = {
1774
- ...Yt,
1775
- mode: "oklab",
1776
- toMode: {
1777
- lrgb: ve,
1778
- rgb: Be
1779
- },
1780
- fromMode: {
1781
- lrgb: ua,
1782
- rgb: Fe
1783
- },
1784
- ranges: {
1785
- l: [0, 1],
1786
- a: [-0.4, 0.4],
1787
- b: [-0.4, 0.4]
1788
- },
1789
- parse: [Jn],
1790
- serialize: (e) => `oklab(${e.l !== void 0 ? e.l : "none"} ${e.a !== void 0 ? e.a : "none"} ${e.b !== void 0 ? e.b : "none"}${e.alpha < 1 ? ` / ${e.alpha}` : ""})`
1791
- };
1792
- function Kn(e, t) {
1793
- if (!t || t[0] !== "oklch") return;
1794
- const r = { mode: "oklch" }, [, a, n, i, o] = t;
1795
- if (a.type !== u.None) {
1796
- if (a.type === u.Hue) return;
1797
- r.l = Math.min(Math.max(0, a.type === u.Number ? a.value : a.value / 100), 1);
1798
- }
1799
- if (n.type !== u.None && (r.c = Math.max(0, n.type === u.Number ? n.value : n.value * 0.4 / 100)), i.type !== u.None) {
1800
- if (i.type === u.Percentage) return;
1801
- r.h = i.value;
1802
- }
1803
- return o.type !== u.None && (r.alpha = Math.min(1, Math.max(0, o.type === u.Number ? o.value : o.value / 100))), r;
1804
- }
1805
- var Qn = {
1806
- ...Ut,
1807
- mode: "oklch",
1808
- toMode: {
1809
- oklab: (e) => j(e, "oklab"),
1810
- rgb: (e) => Be(j(e, "oklab"))
1811
- },
1812
- fromMode: {
1813
- rgb: (e) => I(Fe(e), "oklch"),
1814
- oklab: (e) => I(e, "oklch")
1815
- },
1816
- parse: [Kn],
1817
- serialize: (e) => `oklch(${e.l !== void 0 ? e.l : "none"} ${e.c !== void 0 ? e.c : "none"} ${e.h !== void 0 ? e.h : "none"}${e.alpha < 1 ? ` / ${e.alpha}` : ""})`,
1818
- ranges: {
1819
- l: [0, 1],
1820
- c: [0, 0.4],
1821
- h: [0, 360]
1822
- }
1823
- }, Tr = (e) => {
1824
- let { r: t, g: r, b: a, alpha: n } = G(e), i = {
1825
- mode: "xyz65",
1826
- x: 0.486570948648216 * t + 0.265667693169093 * r + 0.1982172852343625 * a,
1827
- y: 0.2289745640697487 * t + 0.6917385218365062 * r + 0.079286914093745 * a,
1828
- z: 0 * t + 0.0451133818589026 * r + 1.043944368900976 * a
1829
- };
1830
- return n !== void 0 && (i.alpha = n), i;
1831
- }, zr = ({ x: e, y: t, z: r, alpha: a }) => {
1832
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1833
- let n = K({
1834
- r: e * 2.4934969119414263 - t * 0.9313836179191242 - 0.402710784450717 * r,
1835
- g: e * -0.8294889695615749 + t * 1.7626640603183465 + 0.0236246858419436 * r,
1836
- b: e * 0.0358458302437845 - t * 0.0761723892680418 + 0.9568845240076871 * r
1837
- }, "p3");
1838
- return a !== void 0 && (n.alpha = a), n;
1839
- }, ei = {
1840
- ...J,
1841
- mode: "p3",
1842
- parse: ["display-p3"],
1843
- serialize: "display-p3",
1844
- fromMode: {
1845
- rgb: (e) => zr(V(e)),
1846
- xyz65: zr
1847
- },
1848
- toMode: {
1849
- rgb: (e) => D(Tr(e)),
1850
- xyz65: Tr
1851
- }
1852
- }, ft = (e) => {
1853
- let t = Math.abs(e);
1854
- return t >= 1 / 512 ? Math.sign(e) * Math.pow(t, 1 / 1.8) : 16 * e;
1855
- }, _r = ({ x: e, y: t, z: r, alpha: a }) => {
1856
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1857
- let n = {
1858
- mode: "prophoto",
1859
- r: ft(e * 1.3457868816471585 - t * 0.2555720873797946 - 0.0511018649755453 * r),
1860
- g: ft(e * -0.5446307051249019 + t * 1.5082477428451466 + 0.0205274474364214 * r),
1861
- b: ft(e * 0 + t * 0 + 1.2119675456389452 * r)
1862
- };
1863
- return a !== void 0 && (n.alpha = a), n;
1864
- }, mt = (e = 0) => {
1865
- let t = Math.abs(e);
1866
- return t >= 16 / 512 ? Math.sign(e) * Math.pow(t, 1.8) : e / 16;
1867
- }, Pr = (e) => {
1868
- let t = mt(e.r), r = mt(e.g), a = mt(e.b), n = {
1869
- mode: "xyz50",
1870
- x: 0.7977666449006423 * t + 0.1351812974005331 * r + 0.0313477341283922 * a,
1871
- y: 0.2880748288194013 * t + 0.7118352342418731 * r + 899369387256e-16 * a,
1872
- z: 0 * t + 0 * r + 0.8251046025104602 * a
1873
- };
1874
- return e.alpha !== void 0 && (n.alpha = e.alpha), n;
1875
- }, ti = {
1876
- ...J,
1877
- mode: "prophoto",
1878
- parse: ["prophoto-rgb"],
1879
- serialize: "prophoto-rgb",
1880
- fromMode: {
1881
- xyz50: _r,
1882
- rgb: (e) => _r(pe(e))
1883
- },
1884
- toMode: {
1885
- xyz50: Pr,
1886
- rgb: (e) => he(Pr(e))
1887
- }
1888
- }, $r = 1.09929682680944, ri = 0.018053968510807, gt = (e) => {
1889
- const t = Math.abs(e);
1890
- return t > ri ? (Math.sign(e) || 1) * ($r * Math.pow(t, 0.45) - ($r - 1)) : 4.5 * e;
1891
- }, Cr = ({ x: e, y: t, z: r, alpha: a }) => {
1892
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1893
- let n = {
1894
- mode: "rec2020",
1895
- r: gt(e * 1.7166511879712683 - t * 0.3556707837763925 - 0.2533662813736599 * r),
1896
- g: gt(e * -0.6666843518324893 + t * 1.6164812366349395 + 0.0157685458139111 * r),
1897
- b: gt(e * 0.0176398574453108 - t * 0.0427706132578085 + 0.9421031212354739 * r)
1898
- };
1899
- return a !== void 0 && (n.alpha = a), n;
1900
- }, Ar = 1.09929682680944, ai = 0.018053968510807, bt = (e = 0) => {
1901
- let t = Math.abs(e);
1902
- return t < ai * 4.5 ? e / 4.5 : (Math.sign(e) || 1) * Math.pow((t + Ar - 1) / Ar, 1 / 0.45);
1903
- }, Lr = (e) => {
1904
- let t = bt(e.r), r = bt(e.g), a = bt(e.b), n = {
1905
- mode: "xyz65",
1906
- x: 0.6369580483012911 * t + 0.1446169035862083 * r + 0.1688809751641721 * a,
1907
- y: 0.262700212011267 * t + 0.6779980715188708 * r + 0.059301716469862 * a,
1908
- z: 0 * t + 0.0280726930490874 * r + 1.0609850577107909 * a
1909
- };
1910
- return e.alpha !== void 0 && (n.alpha = e.alpha), n;
1911
- }, ni = {
1912
- ...J,
1913
- mode: "rec2020",
1914
- fromMode: {
1915
- xyz65: Cr,
1916
- rgb: (e) => Cr(V(e))
1917
- },
1918
- toMode: {
1919
- xyz65: Lr,
1920
- rgb: (e) => D(Lr(e))
1921
- },
1922
- parse: ["rec2020"],
1923
- serialize: "rec2020"
1924
- }, q = 0.0037930732552754493, ha = Math.cbrt(q), yt = (e) => Math.cbrt(e) - ha, ii = (e) => {
1925
- const { r: t, g: r, b: a, alpha: n } = G(e), i = yt(0.3 * t + 0.622 * r + 0.078 * a + q), o = yt(0.23 * t + 0.692 * r + 0.078 * a + q), s = yt(0.2434226892454782 * t + 0.2047674442449682 * r + 0.5518098665095535 * a + q), l = {
1926
- mode: "xyb",
1927
- x: (i - o) / 2,
1928
- y: (i + o) / 2,
1929
- b: s - (i + o) / 2
1930
- };
1931
- return n !== void 0 && (l.alpha = n), l;
1932
- }, Mt = (e) => Math.pow(e + ha, 3), oi = ({ x: e, y: t, b: r, alpha: a }) => {
1933
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
1934
- const n = Mt(e + t) - q, i = Mt(t - e) - q, o = Mt(r + t) - q, s = K({
1935
- r: 11.031566904639861 * n - 9.866943908131562 * i - 0.16462299650829934 * o,
1936
- g: -3.2541473810744237 * n + 4.418770377582723 * i - 0.16462299650829934 * o,
1937
- b: -3.6588512867136815 * n + 2.7129230459360922 * i + 1.9459282407775895 * o
1938
- });
1939
- return a !== void 0 && (s.alpha = a), s;
1940
- }, si = {
1941
- mode: "xyb",
1942
- channels: [
1943
- "x",
1944
- "y",
1945
- "b",
1946
- "alpha"
1947
- ],
1948
- parse: ["--xyb"],
1949
- serialize: "--xyb",
1950
- toMode: { rgb: oi },
1951
- fromMode: { rgb: ii },
1952
- ranges: {
1953
- x: [-0.0154, 0.0281],
1954
- y: [0, 0.8453],
1955
- b: [-0.2778, 0.388]
1956
- },
1957
- interpolate: {
1958
- x: h,
1959
- y: h,
1960
- b: h,
1961
- alpha: {
1962
- use: h,
1963
- fixup: S
1964
- }
1965
- }
1966
- }, li = {
1967
- mode: "xyz50",
1968
- parse: ["xyz-d50"],
1969
- serialize: "xyz-d50",
1970
- toMode: {
1971
- rgb: he,
1972
- lab: Xt
1973
- },
1974
- fromMode: {
1975
- rgb: pe,
1976
- lab: Bt
1977
- },
1978
- channels: [
1979
- "x",
1980
- "y",
1981
- "z",
1982
- "alpha"
1983
- ],
1984
- ranges: {
1985
- x: [0, 0.964],
1986
- y: [0, 0.999],
1987
- z: [0, 0.825]
1988
- },
1989
- interpolate: {
1990
- x: h,
1991
- y: h,
1992
- z: h,
1993
- alpha: {
1994
- use: h,
1995
- fixup: S
1996
- }
1997
- }
1998
- }, di = (e) => {
1999
- let { x: t, y: r, z: a, alpha: n } = e;
2000
- t === void 0 && (t = 0), r === void 0 && (r = 0), a === void 0 && (a = 0);
2001
- let i = {
2002
- mode: "xyz50",
2003
- x: 1.0479298208405488 * t + 0.0229467933410191 * r - 0.0501922295431356 * a,
2004
- y: 0.0296278156881593 * t + 0.990434484573249 * r - 0.0170738250293851 * a,
2005
- z: -0.0092430581525912 * t + 0.0150551448965779 * r + 0.7518742899580008 * a
2006
- };
2007
- return n !== void 0 && (i.alpha = n), i;
2008
- }, ui = (e) => {
2009
- let { x: t, y: r, z: a, alpha: n } = e;
2010
- t === void 0 && (t = 0), r === void 0 && (r = 0), a === void 0 && (a = 0);
2011
- let i = {
2012
- mode: "xyz65",
2013
- x: 0.9554734527042182 * t - 0.0230985368742614 * r + 0.0632593086610217 * a,
2014
- y: -0.0283697069632081 * t + 1.0099954580058226 * r + 0.021041398966943 * a,
2015
- z: 0.0123140016883199 * t - 0.0205076964334779 * r + 1.3303659366080753 * a
2016
- };
2017
- return n !== void 0 && (i.alpha = n), i;
2018
- }, ci = {
2019
- mode: "xyz65",
2020
- toMode: {
2021
- rgb: D,
2022
- xyz50: di
2023
- },
2024
- fromMode: {
2025
- rgb: V,
2026
- xyz50: ui
2027
- },
2028
- ranges: {
2029
- x: [0, 0.95],
2030
- y: [0, 1],
2031
- z: [0, 1.088]
2032
- },
2033
- channels: [
2034
- "x",
2035
- "y",
2036
- "z",
2037
- "alpha"
2038
- ],
2039
- parse: ["xyz", "xyz-d65"],
2040
- serialize: "xyz-d65",
2041
- interpolate: {
2042
- x: h,
2043
- y: h,
2044
- z: h,
2045
- alpha: {
2046
- use: h,
2047
- fixup: S
2048
- }
2049
- }
2050
- }, hi = ({ r: e, g: t, b: r, alpha: a }) => {
2051
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
2052
- const n = {
2053
- mode: "yiq",
2054
- y: 0.29889531 * e + 0.58662247 * t + 0.11448223 * r,
2055
- i: 0.59597799 * e - 0.2741761 * t - 0.32180189 * r,
2056
- q: 0.21147017 * e - 0.52261711 * t + 0.31114694 * r
2057
- };
2058
- return a !== void 0 && (n.alpha = a), n;
2059
- }, pi = ({ y: e, i: t, q: r, alpha: a }) => {
2060
- e === void 0 && (e = 0), t === void 0 && (t = 0), r === void 0 && (r = 0);
2061
- const n = {
2062
- mode: "rgb",
2063
- r: e + 0.95608445 * t + 0.6208885 * r,
2064
- g: e - 0.27137664 * t - 0.6486059 * r,
2065
- b: e - 1.10561724 * t + 1.70250126 * r
2066
- };
2067
- return a !== void 0 && (n.alpha = a), n;
2068
- }, vi = {
2069
- mode: "yiq",
2070
- toMode: { rgb: pi },
2071
- fromMode: { rgb: hi },
2072
- channels: [
2073
- "y",
2074
- "i",
2075
- "q",
2076
- "alpha"
2077
- ],
2078
- parse: ["--yiq"],
2079
- serialize: "--yiq",
2080
- ranges: {
2081
- i: [-0.595, 0.595],
2082
- q: [-0.522, 0.522]
2083
- },
2084
- interpolate: {
2085
- y: h,
2086
- i: h,
2087
- q: h,
2088
- alpha: {
2089
- use: h,
2090
- fixup: S
2091
- }
2092
- }
2093
- }, fi = (e, t) => Math.round(e * (t = Math.pow(10, t))) / t, mi = (e = 4) => (t) => typeof t == "number" ? fi(t, e) : t, Uo = mi(2), gi = (e) => Math.max(0, Math.min(1, e || 0)), wt = (e) => Math.round(gi(e) * 255), bi = Dt("rgb"), Zo = Dt("hsl"), yi = (e) => {
2094
- if (e === void 0) return;
2095
- let t = wt(e.r), r = wt(e.g), a = wt(e.b);
2096
- return "#" + (1 << 24 | t << 16 | r << 8 | a).toString(16).slice(1);
2097
- }, pa = (e) => yi(bi(e)), Jo = y(en), Go = y(ln), Ko = y(dn), Qo = y(un), es = y(pn), ts = y(Zr), rs = y(Kr), as = y(Sn), ns = y(kn), is = y(_n), os = y(Pn), ss = y(Yt), ls = y(Cn), ds = y(Ut), us = y(Ln), cs = y(Dn), hs = y(Fn), ps = y(Bn), vs = y(Un), fs = y(Zn), ms = y(Gn), Nt = y(Qn), gs = y(ei), bs = y(ti), ys = y(ni), Ms = y(J), ws = y(si), xs = y(li), Ss = y(ci), ks = y(vi), va = (e, t = "l") => e.sort((r, a) => Math.sign(Nt({
2098
- mode: "rgb",
2099
- r: r[0],
2100
- g: r[1],
2101
- b: r[2]
2102
- })?.[t] - Nt({
2103
- mode: "rgb",
2104
- r: a[0],
2105
- g: a[1],
2106
- b: a[2]
2107
- })?.[t]) || 0), Gt = (e, t) => Math.hypot(e[0] - t[0], e[1] - t[1], e[2] - t[2]), Mi = (e, t) => {
2108
- let r = Array.from({ length: t.length }, () => ({
2109
- points: [],
2110
- mean: null
2111
- }));
2112
- return e.forEach((a) => {
2113
- let n = 1e4, i = 0;
2114
- t.forEach((o, s) => {
2115
- const l = Gt(a, o);
2116
- (typeof n > "u" || n > l) && (n = l, i = s);
2117
- }), r[i].points.push(a);
2118
- }), r;
2119
- }, wi = (e) => e?.length > 0 ? e.reduce((t, r) => [
2120
- r[0] + t[0],
2121
- r[1] + t[1],
2122
- r[2] + t[2]
2123
- ], [
2124
- 0,
2125
- 0,
2126
- 0
2127
- ]).map((t) => t / e.length) : [
2128
- 0,
2129
- 0,
2130
- 0
2131
- ], xi = (e, t) => {
2132
- let r = va(Si(e, t));
2133
- const a = 10;
2134
- for (let n = 0; n < a; n++) {
2135
- const i = Mi(e, r).map((o) => o.points.length > 0 ? wi(o.points) : null);
2136
- if (i.every((o, s) => o && Gt(o, r[s]) < 1e-3)) break;
2137
- r = i;
2138
- }
2139
- return r;
2140
- }, Si = (e, t) => {
2141
- const r = [e[Math.floor(Math.random() * e.length)]];
2142
- for (; r.length < t; ) {
2143
- const a = e.map((l) => Math.min(...r.map((d) => Gt(l, d)))), n = a.reduce((l, d) => l + d, 0), i = a.map((l) => l / n);
2144
- let o = 0;
2145
- const s = Math.random();
2146
- for (let l = 0; l < i.length; l++)
2147
- if (o += i[l], s < o) {
2148
- r.push(e[l]);
2149
- break;
2150
- }
2151
- }
2152
- return r;
2153
- }, ki = async (e) => {
2154
- const t = e instanceof Blob || e instanceof File ? e : await fetch(e)?.then?.((i) => i?.blob?.()), r = await createImageBitmap(t), a = new OffscreenCanvas(r.width, r.height), n = a.getContext("2d");
2155
- return n.filter = "blur(16px)", n?.drawImage?.(r, 0, 0, a.width, a.height), a;
2156
- }, Ei = async (e) => {
2157
- const t = await ki(e), r = new OffscreenCanvas(t.width * 0.125, t.height * 0.125), a = r.getContext("2d");
2158
- a?.drawImage?.(t, 0, 0, r.width, r.height);
2159
- const n = (a?.getImageData?.(0, 0, r.width, r.height, {
2160
- storageFormat: "float32",
2161
- pixelFormat: "rgba-float32",
2162
- colorSpace: "srgb"
2163
- })).data, i = r.width * r.height || 0, o = 1 / 255, s = [];
2164
- for (let l = 0; l < i; l++) {
2165
- const d = l * 4;
2166
- s.push(n instanceof Float32Array || n instanceof Float16Array ? [
2167
- n?.[d + 0] || 0,
2168
- n?.[d + 1] || 0,
2169
- n?.[d + 2] || 0
2170
- ] : [
2171
- (n?.[d + 0] || 0) * o,
2172
- (n?.[d + 1] || 0) * o,
2173
- (n?.[d + 2] || 0) * o
2174
- ]);
2175
- }
2176
- return s;
2177
- }, Ti = async (e) => {
2178
- const t = await Ei(e);
2179
- return va(xi(t, 4), "h");
2180
- }, zi = "rs-wallpaper-theme", _i = "rs-wallpaper-primary", Pi = "rs-wallpaper-theme-src", fa = zi, $i = _i, Nr = Pi, Ci = [
2181
- ["--color-primary", "primary"],
2182
- ["--color-secondary", "secondary"],
2183
- ["--color-tertiary", "tertiary"],
2184
- ["--base-color", "primary"],
2185
- ["--wf-md-primary", "primary"],
2186
- ["--wf-md-seed", "primary"],
2187
- ["--primary", "primary"],
2188
- ["--secondary", "secondary"],
2189
- ["--tertiary", "tertiary"]
2190
- ], Ai = (e) => {
2191
- const [t, r, a] = e;
2192
- if (![
2193
- t,
2194
- r,
2195
- a
2196
- ].every((o) => Number.isFinite(o))) return null;
2197
- const n = pa({
2198
- mode: "rgb",
2199
- r: t,
2200
- g: r,
2201
- b: a
2202
- });
2203
- if (!n) return null;
2204
- const i = Nt({
2205
- mode: "rgb",
2206
- r: t,
2207
- g: r,
2208
- b: a
2209
- });
2210
- return {
2211
- rgb: e,
2212
- hex: n,
2213
- l: i?.l ?? 0.5,
2214
- c: i?.c ?? 0,
2215
- h: i?.h ?? 0
2216
- };
2217
- }, Li = (e) => {
2218
- const t = e.map(Ai).filter(Boolean);
2219
- if (!t.length) return null;
2220
- const r = t.filter((d) => d.l >= 0.18 && d.l <= 0.88 && d.c >= 0.02).sort((d, p) => p.c - d.c || Math.abs(p.l - 0.55) - Math.abs(d.l - 0.55)), a = r.length ? r : [...t].sort((d, p) => p.c - d.c), n = a[0];
2221
- if (!n) return null;
2222
- const i = (d, p) => {
2223
- const v = Math.abs(d - p) % 360;
2224
- return v > 180 ? 360 - v : v;
2225
- }, o = (d) => {
2226
- const p = a.filter((v) => !d.includes(v));
2227
- if (!p.length) {
2228
- const v = d[d.length - 1] ?? n, c = pa({
2229
- mode: "oklch",
2230
- l: Math.min(0.85, Math.max(0.2, v.l + (d.length === 1 ? -0.12 : 0.1))),
2231
- c: Math.max(0.04, v.c * 0.85),
2232
- h: v.h
2233
- });
2234
- return {
2235
- ...v,
2236
- hex: c || v.hex,
2237
- l: v.l
2238
- };
2239
- }
2240
- return [...p].sort((v, c) => Math.min(...d.map((m) => i(c.h, m.h))) - Math.min(...d.map((m) => i(v.h, m.h))) || c.c - v.c)[0] ?? p[0];
2241
- }, s = o([n]), l = o([n, s]);
2242
- return {
2243
- primary: n.hex,
2244
- secondary: s.hex,
2245
- tertiary: l.hex
2246
- };
2247
- }, Ni = () => {
2248
- const e = /* @__PURE__ */ new Set();
2249
- return e.add(document.documentElement), document.querySelectorAll(".env-shell-root, .wf-demo-root, ui-window").forEach((t) => e.add(t)), [...e];
2250
- }, Me = (e) => {
2251
- for (const t of Ni()) for (const [r, a] of Ci) t.style.setProperty(r, e[a]);
2252
- document.querySelectorAll(".view-explorer, [data-view='explorer'], .view-viewer, [data-view='viewer'], .view-settings, [data-view='settings']").forEach((t) => {
2253
- t.style.setProperty("--color-primary", e.primary), t.style.setProperty("--base-color", e.primary), t.style.setProperty("--color-secondary", e.secondary), t.style.setProperty("--color-tertiary", e.tertiary);
2254
- });
2255
- try {
2256
- localStorage.setItem(fa, JSON.stringify(e)), localStorage.setItem($i, e.primary);
2257
- } catch {
2258
- }
2259
- document.dispatchEvent(new CustomEvent("u2-theme-change", { detail: {
2260
- source: "wallpaper",
2261
- seeds: e
2262
- } }));
2263
- }, Rt = () => {
2264
- try {
2265
- const e = localStorage.getItem(fa);
2266
- if (!e) return null;
2267
- const t = JSON.parse(e);
2268
- return !t?.primary || !t?.secondary || !t?.tertiary ? null : t;
2269
- } catch {
2270
- return null;
2271
- }
2272
- }, $e = async (e, t) => {
2273
- const r = typeof e == "string" ? e.slice(0, 2048) : `blob:${e.name || "wallpaper"}:${e.size}`;
2274
- if (!t?.force) try {
2275
- if (localStorage.getItem(Nr) === r) {
2276
- const a = Rt();
2277
- if (a)
2278
- return Me(a), a;
2279
- }
2280
- } catch {
2281
- }
2282
- try {
2283
- const a = await Ti(e), n = Li(a);
2284
- if (!n) return null;
2285
- Me(n);
2286
- try {
2287
- localStorage.setItem(Nr, r);
2288
- } catch {
2289
- }
2290
- return n;
2291
- } catch (a) {
2292
- console.warn("[fest/image] applyThemeFromWallpaper failed", a);
2293
- const n = Rt();
2294
- return n ? (Me(n), n) : null;
2295
- }
2296
- }, Ri = () => {
2297
- const e = Rt();
2298
- return e && Me(e), e;
2299
- }, Ii = /* @__PURE__ */ Symbol.for("dom.ts@__registeredCssProperties"), Rr = globalThis[Ii] ??= /* @__PURE__ */ new Set();
2300
- [
2301
- {
2302
- name: "--screen-width",
2303
- syntax: "<length-percentage>",
2304
- inherits: !0,
2305
- initialValue: "0px"
2306
- },
2307
- {
2308
- name: "--screen-height",
2309
- syntax: "<length-percentage>",
2310
- inherits: !0,
2311
- initialValue: "0px"
2312
- },
2313
- {
2314
- name: "--visual-width",
2315
- syntax: "<length-percentage>",
2316
- inherits: !0,
2317
- initialValue: "0px"
2318
- },
2319
- {
2320
- name: "--visual-height",
2321
- syntax: "<length-percentage>",
2322
- inherits: !0,
2323
- initialValue: "0px"
2324
- },
2325
- {
2326
- name: "--clip-ampl",
2327
- syntax: "<number>",
2328
- inherits: !0,
2329
- initialValue: "0"
2330
- },
2331
- {
2332
- name: "--clip-freq",
2333
- syntax: "<number>",
2334
- inherits: !0,
2335
- initialValue: "0"
2336
- },
2337
- {
2338
- name: "--avail-width",
2339
- syntax: "<length-percentage>",
2340
- inherits: !0,
2341
- initialValue: "0px"
2342
- },
2343
- {
2344
- name: "--avail-height",
2345
- syntax: "<length-percentage>",
2346
- inherits: !0,
2347
- initialValue: "0px"
2348
- },
2349
- {
2350
- name: "--pixel-ratio",
2351
- syntax: "<number>",
2352
- inherits: !0,
2353
- initialValue: "1"
2354
- },
2355
- {
2356
- name: "--percent",
2357
- syntax: "<number>",
2358
- inherits: !0,
2359
- initialValue: "0"
2360
- },
2361
- {
2362
- name: "--percent-x",
2363
- syntax: "<number>",
2364
- inherits: !0,
2365
- initialValue: "0"
2366
- },
2367
- {
2368
- name: "--percent-y",
2369
- syntax: "<number>",
2370
- inherits: !0,
2371
- initialValue: "0"
2372
- },
2373
- {
2374
- name: "--scroll-left",
2375
- syntax: "<number>",
2376
- inherits: !0,
2377
- initialValue: "0"
2378
- },
2379
- {
2380
- name: "--scroll-top",
2381
- syntax: "<number>",
2382
- inherits: !0,
2383
- initialValue: "0"
2384
- },
2385
- {
2386
- name: "--drag-x",
2387
- syntax: "<length>",
2388
- inherits: !1,
2389
- initialValue: "0px"
2390
- },
2391
- {
2392
- name: "--drag-y",
2393
- syntax: "<length>",
2394
- inherits: !1,
2395
- initialValue: "0px"
2396
- },
2397
- {
2398
- name: "--grid-r",
2399
- syntax: "<number>",
2400
- inherits: !1,
2401
- initialValue: "0"
2402
- },
2403
- {
2404
- name: "--grid-c",
2405
- syntax: "<number>",
2406
- inherits: !1,
2407
- initialValue: "0"
2408
- },
2409
- {
2410
- name: "--resize-x",
2411
- syntax: "<length>",
2412
- inherits: !1,
2413
- initialValue: "0px"
2414
- },
2415
- {
2416
- name: "--resize-y",
2417
- syntax: "<length>",
2418
- inherits: !1,
2419
- initialValue: "0px"
2420
- },
2421
- {
2422
- name: "--shift-x",
2423
- syntax: "<length>",
2424
- inherits: !1,
2425
- initialValue: "0px"
2426
- },
2427
- {
2428
- name: "--shift-y",
2429
- syntax: "<length>",
2430
- inherits: !1,
2431
- initialValue: "0px"
2432
- },
2433
- {
2434
- name: "--cs-grid-r",
2435
- syntax: "<number>",
2436
- inherits: !1,
2437
- initialValue: "0"
2438
- },
2439
- {
2440
- name: "--cs-grid-c",
2441
- syntax: "<number>",
2442
- inherits: !1,
2443
- initialValue: "0"
2444
- },
2445
- {
2446
- name: "--cs-p-grid-r",
2447
- syntax: "<number>",
2448
- inherits: !1,
2449
- initialValue: "0"
2450
- },
2451
- {
2452
- name: "--cs-p-grid-c",
2453
- syntax: "<number>",
2454
- inherits: !1,
2455
- initialValue: "0"
2456
- },
2457
- {
2458
- name: "--os-grid-r",
2459
- syntax: "<number>",
2460
- inherits: !1,
2461
- initialValue: "0"
2462
- },
2463
- {
2464
- name: "--os-grid-c",
2465
- syntax: "<number>",
2466
- inherits: !1,
2467
- initialValue: "0"
2468
- },
2469
- {
2470
- name: "--rv-grid-r",
2471
- syntax: "<number>",
2472
- inherits: !1,
2473
- initialValue: "0"
2474
- },
2475
- {
2476
- name: "--rv-grid-c",
2477
- syntax: "<number>",
2478
- inherits: !1,
2479
- initialValue: "0"
2480
- },
2481
- {
2482
- name: "--cell-x",
2483
- syntax: "<integer>",
2484
- inherits: !1,
2485
- initialValue: "0"
2486
- },
2487
- {
2488
- name: "--cell-y",
2489
- syntax: "<integer>",
2490
- inherits: !1,
2491
- initialValue: "0"
2492
- }
2493
- ].forEach((e) => {
2494
- if (typeof CSS > "u" || typeof CSS?.registerProperty != "function") return;
2495
- const t = String(e?.name || "").trim();
2496
- if (!(!t || Rr.has(t)))
2497
- try {
2498
- CSS.registerProperty(e);
2499
- } catch (r) {
2500
- String(r?.name || "").toLowerCase() !== "invalidmodificationerror" && console.warn(r);
2501
- } finally {
2502
- Rr.add(t);
2503
- }
2504
- });
2505
- function ji() {
2506
- const e = globalThis;
2507
- if (typeof e.HTMLElement == "function") return;
2508
- const t = class {
2509
- }, r = (a) => {
2510
- typeof e[a] != "function" && (e[a] = t);
2511
- };
2512
- r("EventTarget"), r("Node"), r("Element"), r("HTMLElement"), r("SVGElement"), r("Text"), r("Comment"), r("DocumentFragment"), r("ShadowRoot"), r("HTMLDocument"), r("Document"), r("HTMLBodyElement"), r("HTMLHeadElement"), r("HTMLCanvasElement"), r("HTMLInputElement"), r("HTMLLinkElement"), r("HTMLStyleElement"), r("HTMLPreElement"), r("HTMLDivElement"), r("CSSStyleRule"), r("CSSLayerBlockRule");
2513
- }
2514
- var Hi = (e, t = "value") => (typeof e == "object" || typeof e == "function") && e != null && (t in e || e?.[t] != null), ma = (e) => Hi(e, "value"), ga = (e) => e && e?.replace?.(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), ba = (e) => {
2515
- if (typeof e != "string") return null;
2516
- const t = [...e?.matchAll?.(/^\d+(\.\d+)?$/g)];
2517
- if (t?.length != 1) return null;
2518
- const r = parseFloat(t[0][0]);
2519
- return !Number.isNaN(r) && Number.isFinite(r) ? r : null;
2520
- };
2521
- ji();
2522
- var Oi = () => {
2523
- const e = {
2524
- canceled: !1,
2525
- rAFs: /* @__PURE__ */ new Set(),
2526
- last: null,
2527
- cancel() {
2528
- return this.canceled = !0, cancelAnimationFrame(this.last), this;
2529
- },
2530
- shedule(t) {
2531
- return this.rAFs.add(t), this;
2532
- }
2533
- };
2534
- return (async () => {
2535
- for (; !e?.canceled; )
2536
- await Promise.all((e?.rAFs?.values?.() ?? [])?.map?.((t) => Promise.try(t)?.catch?.(console.warn.bind(console)))), e.rAFs?.clear?.(), typeof requestAnimationFrame < "u" ? await new Promise((t) => {
2537
- e.last = requestAnimationFrame(t);
2538
- }) : await new Promise((t) => {
2539
- setTimeout(t, 16);
2540
- });
2541
- })(), e;
2542
- }, Es = typeof document < "u" ? document?.documentElement : null, Wi = /* @__PURE__ */ new Map();
2543
- typeof requestAnimationFrame < "u" && requestAnimationFrame(async () => {
2544
- for (; ; )
2545
- Wi.forEach((e) => e?.()), await new Promise((e) => requestAnimationFrame(e));
2546
- });
2547
- var qi = {};
2548
- function w(e, t, r, a = qi) {
2549
- e?.addEventListener?.(t, r, a);
2550
- const n = typeof e == "object" || typeof e == "function" && !e?.deref ? new WeakRef(e) : e;
2551
- return () => n?.deref?.()?.removeEventListener?.(t, r, a);
2552
- }
2553
- var Vi = /* @__PURE__ */ Symbol.for("dom.ts@zoomValues"), Ts = globalThis[Vi] ??= /* @__PURE__ */ new WeakMap(), Di = (e, t = 100) => typeof globalThis.requestIdleCallback == "function" ? globalThis.requestIdleCallback(e, { timeout: t }) : setTimeout(() => e({
2554
- didTimeout: !1,
2555
- timeRemaining: () => 0
2556
- }), 0), ya = () => {
2557
- const e = typeof matchMedia < "u" ? matchMedia("(orientation: landscape)")?.matches : !1, t = typeof window < "u" ? window.visualViewport : null, r = t ? {
2558
- "--vv-width": `${t.width}px`,
2559
- "--vv-height": `${t.height}px`,
2560
- "--vv-offset-left": `${t.offsetLeft}px`,
2561
- "--vv-offset-top": `${t.offsetTop}px`,
2562
- "--vv-scale": String(t.scale ?? 1)
2563
- } : {
2564
- "--vv-width": typeof window < "u" ? `${window.innerWidth}px` : "0px",
2565
- "--vv-height": typeof window < "u" ? `${window.innerHeight}px` : "0px",
2566
- "--vv-offset-left": "0px",
2567
- "--vv-offset-top": "0px",
2568
- "--vv-scale": "1"
2569
- };
2570
- if (typeof screen < "u") {
2571
- const a = screen?.availWidth + "px", n = screen?.availHeight + "px";
2572
- return {
2573
- "--screen-width": Math.min(screen?.width, screen?.availWidth) + "px",
2574
- "--screen-height": Math.min(screen?.height, screen?.availHeight) + "px",
2575
- "--avail-width": e ? n : a,
2576
- "--avail-height": e ? a : n,
2577
- "--view-height": Math.min(screen?.availHeight, window?.innerHeight) + "px",
2578
- "--pixel-ratio": String(devicePixelRatio || 1),
2579
- ...r
2580
- };
2581
- }
2582
- return {
2583
- "--screen-width": "0px",
2584
- "--screen-height": "0px",
2585
- "--avail-width": "0px",
2586
- "--avail-height": "0px",
2587
- "--view-height": "0px",
2588
- "--pixel-ratio": "1",
2589
- ...r
2590
- };
2591
- }, Ir = ya(), Fi = {
2592
- "portrait-primary": 0,
2593
- "landscape-primary": 1,
2594
- "portrait-secondary": 2,
2595
- "landscape-secondary": 3
2596
- }, Bi = (e) => {
2597
- const t = document.documentElement;
2598
- Object.assign(Ir, ya()), Object.entries(Ir).forEach(([r, a]) => {
2599
- const n = t?.style?.getPropertyValue(r);
2600
- (!n || n != a) && t?.style?.setProperty?.(r, a || "", "");
2601
- }), document.documentElement.style.setProperty("--orientation-secondary", screen?.orientation?.type?.endsWith?.("secondary") ? "1" : "0");
2602
- }, Xi = () => {
2603
- let e = screen?.orientation?.type || "portrait-primary";
2604
- return globalThis.matchMedia("((display-mode: fullscreen) or (display-mode: standalone) or (display-mode: window-controls-overlay))").matches || (matchMedia("(orientation: portrait)").matches ? e = e.replace("landscape", "portrait") : matchMedia("(orientation: landscape)").matches && (e = e.replace("portrait", "landscape"))), e;
2605
- }, xt = { passive: !0 }, Yi = (e) => {
2606
- let t = !1;
2607
- const r = () => {
2608
- t || (requestAnimationFrame(() => {
2609
- Bi(), e(), t = !1;
2610
- }), t = !0);
2611
- }, a = [];
2612
- return a.push(w(navigator?.virtualKeyboard, "geometrychange", r, xt)), a.push(w(window?.visualViewport, "scroll", r, xt)), a.push(w(window?.visualViewport, "resize", r, xt)), a.push(w(screen?.orientation, "change", r)), a.push(w(window, "resize", r)), a.push(w(document?.documentElement, "fullscreenchange", r)), a.push(w(document, "DOMContentLoaded", r)), a.push(w(matchMedia("(orientation: portrait)"), "change", r)), a.push(w(matchMedia("(orientation: landscape)"), "change", r)), r(), Di(() => r(), 100), () => a.forEach((n) => n());
2613
- }, zs = new OffscreenCanvas(1, 1).getContext("2d"), Ui = /* @__PURE__ */ Symbol.for("dom.ts@onBorderObserve"), _s = globalThis[Ui] ??= /* @__PURE__ */ new WeakMap(), Zi = /* @__PURE__ */ Symbol.for("dom.ts@onContentObserve"), Ps = globalThis[Zi] ??= /* @__PURE__ */ new WeakMap(), Ma = (e) => (typeof e?.current == "object" && (e = e?.element ?? e?.current ?? (typeof e?.self == "object" ? e?.self : null) ?? e), e), Ji = (e, t, r, a) => {
2614
- const n = new Set([...r.split(",") || [r]].map((o) => o.trim())), i = new MutationObserver((o, s) => {
2615
- for (const l of o) if (l.type == "childList") {
2616
- const d = Array.from(l.addedNodes) || [], p = Array.from(l.removedNodes) || [];
2617
- d.push(...Array.from(l.addedNodes || []).flatMap((v) => Array.from(v?.querySelectorAll?.(t) || []))), p.push(...Array.from(l.removedNodes || []).flatMap((v) => Array.from(v?.querySelectorAll?.(t) || []))), [...new Set(d)].filter((v) => v?.matches?.(t))?.map?.((v) => {
2618
- n.forEach((c) => {
2619
- a({
2620
- target: v,
2621
- type: "attributes",
2622
- attributeName: c,
2623
- oldValue: v?.getAttribute?.(c)
2624
- }, s);
2625
- });
2626
- });
2627
- } else l.target?.matches?.(t) && l.attributeName && n.has(l.attributeName) && a(l, s);
2628
- });
2629
- return i.observe(e = Ma(e), {
2630
- attributeOldValue: !0,
2631
- attributes: !0,
2632
- attributeFilter: [...n],
2633
- childList: !0,
2634
- subtree: !0,
2635
- characterData: !0
2636
- }), [...e.querySelectorAll(t)].map((o) => n.forEach((s) => a({
2637
- target: o,
2638
- type: "attributes",
2639
- attributeName: s,
2640
- oldValue: o?.getAttribute?.(s)
2641
- }, i))), i;
2642
- }, Gi = (e, t = "*", r = (a, n) => {
2643
- }) => {
2644
- const a = (c) => {
2645
- const m = Array.from(c || []) || [];
2646
- return m.push(...Array.from(c || []).flatMap((f) => Array.from(f?.querySelectorAll?.(t) || []))), [...Array.from(new Set(m).values())].filter((f) => f?.matches?.(t));
2647
- }, n = (c) => {
2648
- const m = p?.deref?.(), f = a(c.addedNodes), b = a(c.removedNodes);
2649
- (f.length > 0 || b.length > 0) && r?.({
2650
- type: c.type,
2651
- target: c.target,
2652
- attributeName: c.attributeName,
2653
- attributeNamespace: c.attributeNamespace,
2654
- nextSibling: c.nextSibling,
2655
- oldValue: c.oldValue,
2656
- previousSibling: c.previousSibling,
2657
- addedNodes: f,
2658
- removedNodes: b
2659
- }, m);
2660
- }, i = (c) => {
2661
- n({
2662
- addedNodes: [c?.target].filter((m) => !!m),
2663
- removedNodes: [c?.relatedTarget].filter((m) => !!m),
2664
- type: "childList",
2665
- target: c?.currentTarget
2666
- });
2667
- }, o = (c) => {
2668
- n({
2669
- addedNodes: [c?.relatedTarget].filter((m) => !!m),
2670
- removedNodes: [c?.target].filter((m) => !!m),
2671
- type: "childList",
2672
- target: c?.currentTarget
2673
- });
2674
- }, s = (c) => {
2675
- n({
2676
- addedNodes: [c?.target].filter((m) => !!m),
2677
- removedNodes: [c?.relatedTarget || document?.activeElement].filter((m) => !!m),
2678
- type: "childList",
2679
- target: c?.currentTarget
2680
- });
2681
- }, l = {
2682
- passive: !0,
2683
- capture: !1
2684
- };
2685
- if (t?.includes?.(":hover") && t?.includes?.(":active"))
2686
- return e.addEventListener("pointerover", i, l), e.addEventListener("pointerout", o, l), e.addEventListener("pointerdown", i, l), e.addEventListener("pointerup", o, l), e.addEventListener("pointercancel", o, l), { disconnect: () => {
2687
- e.removeEventListener("pointerover", i, l), e.removeEventListener("pointerout", o, l), e.removeEventListener("pointerdown", i, l), e.removeEventListener("pointerup", o, l), e.removeEventListener("pointercancel", o, l);
2688
- } };
2689
- if (t?.includes?.(":hover"))
2690
- return e.addEventListener("pointerover", i, l), e.addEventListener("pointerout", o, l), { disconnect: () => {
2691
- e.removeEventListener("pointerover", i, l), e.removeEventListener("pointerout", o, l);
2692
- } };
2693
- if (t?.includes?.(":active"))
2694
- return e.addEventListener("pointerdown", i, l), e.addEventListener("pointerup", o, l), e.addEventListener("pointercancel", o, l), { disconnect: () => {
2695
- e.removeEventListener("pointerdown", i, l), e.removeEventListener("pointerup", o, l), e.removeEventListener("pointercancel", o, l);
2696
- } };
2697
- if (t?.includes?.(":focus") && t?.includes?.(":focus-within") && t?.includes?.(":focus-visible"))
2698
- return e.addEventListener("focusin", i, l), e.addEventListener("focusout", o, l), e.addEventListener("click", s, l), { disconnect: () => {
2699
- e.removeEventListener("focusin", i, l), e.removeEventListener("focusout", o, l), e.removeEventListener("click", s, l);
2700
- } };
2701
- const d = new MutationObserver((c, m) => {
2702
- for (const f of c) f.type == "childList" && n(f);
2703
- }), p = new WeakRef(d);
2704
- (e?.element ?? e) instanceof Node && d.observe(e = Ma(e), {
2705
- childList: !0,
2706
- subtree: !0
2707
- });
2708
- const v = Array.from(e.querySelectorAll(t));
2709
- return v.length > 0 && r?.({
2710
- addedNodes: v,
2711
- removedNodes: []
2712
- }, d), d;
2713
- }, Ki = "DOM", St = typeof document < "u" ? document.createElement("style") : null;
2714
- St && (typeof document < "u" && document.querySelector("head")?.appendChild?.(St), St.dataset.owner = Ki);
2715
- var Xe = typeof CSSStyleValue < "u" && typeof CSSUnitValue < "u", U = (e) => Xe && e instanceof CSSStyleValue, X = (e) => Xe && e instanceof CSSUnitValue, R = (e, t, r, a = "") => {
2716
- if (!(!e || !t)) {
2717
- if (r == null) {
2718
- e.getPropertyValue(t) !== "" && e.removeProperty(t);
2719
- return;
2720
- }
2721
- e.getPropertyValue(t) !== r && e.setProperty(t, r, a);
2722
- }
2723
- }, Qi = (e, t, r, a = "") => {
2724
- if (!e || !t) return e;
2725
- const n = ga(t), i = e.style, o = e.attributeStyleMap ?? e.styleMap;
2726
- if (!Xe || !o) return wa(e, t, r, a);
2727
- let s = ma(r) && !(U(r) || X(r)) ? r?.value : r;
2728
- if (s == null)
2729
- return o.delete?.(n), i && R(i, n, null, a), e;
2730
- if (U(s)) {
2731
- const l = o.get(n);
2732
- if (X(s) && X(l)) {
2733
- if (l.value === s.value && l.unit === s.unit) return e;
2734
- } else if (l === s) return e;
2735
- return o.set(n, s), e;
2736
- }
2737
- if (typeof s == "number") if (CSS?.number && !n.startsWith("--")) {
2738
- const l = CSS.number(s), d = o.get(n);
2739
- return X(d) && d.value === l.value && d.unit === l.unit || o.set(n, l), e;
2740
- } else
2741
- return R(i, n, String(s), a), e;
2742
- if (typeof s == "string" && !U(s)) {
2743
- const l = ba(s);
2744
- if (typeof l == "number" && CSS?.number && !n.startsWith("--")) {
2745
- const d = CSS.number(l), p = o.get(n);
2746
- return X(p) && p.value === d.value && p.unit === d.unit || o.set(n, d), e;
2747
- } else
2748
- return R(i, n, s, a), e;
2749
- }
2750
- return R(i, n, String(s), a), e;
2751
- }, wa = (e, t, r, a = "") => {
2752
- if (!e || !t) return e;
2753
- const n = ga(t), i = e.style;
2754
- if (!i) return e;
2755
- let o = ma(r) && !(U(r) || X(r)) ? r?.value : r;
2756
- return typeof o == "string" && !U(o) && (o = ba(o) ?? o), o == null ? (R(i, n, null, a), e) : (U(o) || typeof o == "number", R(i, n, String(o), a), e);
2757
- }, eo = /* @__PURE__ */ Symbol.for("dom.ts@blobURLMap"), $s = globalThis[eo] ??= /* @__PURE__ */ new WeakMap(), to = /* @__PURE__ */ Symbol.for("dom.ts@cacheMap"), Cs = globalThis[to] ??= /* @__PURE__ */ new Map(), ro = /* @__PURE__ */ Symbol.for("dom.ts@adoptedSelectorMap"), As = globalThis[ro] ??= /* @__PURE__ */ new Map(), ao = /* @__PURE__ */ Symbol.for("dom.ts@adoptedShadowSelectorMap"), Ls = globalThis[ao] ??= /* @__PURE__ */ new WeakMap(), no = /* @__PURE__ */ Symbol.for("dom.ts@adoptedLayerMap"), Ns = globalThis[no] ??= /* @__PURE__ */ new Map(), io = /* @__PURE__ */ Symbol.for("dom.ts@adoptedShadowLayerMap"), Rs = globalThis[io] ??= /* @__PURE__ */ new WeakMap(), ge = (e, t, r, a = "") => Xe ? Qi(e, t, r, a) : wa(e, t, r, a), oo = /* @__PURE__ */ Symbol.for("dom.ts@adoptedMap"), Is = globalThis[oo] ??= /* @__PURE__ */ new Map(), so = /* @__PURE__ */ Symbol.for("dom.ts@adoptedBlobMap"), js = globalThis[so] ??= /* @__PURE__ */ new WeakMap(), lo = /* @__PURE__ */ Symbol.for("dom.ts@layerCounter"), Hs = globalThis[lo] ??= 0, uo = /* @__PURE__ */ new WeakMap(), co = /* @__PURE__ */ Symbol.for("dom.ts@namedStoreMaps"), It = globalThis[co] ??= /* @__PURE__ */ new Map(), ho = (e, t) => {
2758
- const r = [...e.entries() || []];
2759
- return new Map(r?.map?.(([a, n]) => [a, n?.get?.(t)])?.filter?.(([a, n]) => !!n) || []);
2760
- }, we = (e) => ({
2761
- storeSet: ho(It, e),
2762
- mixinSet: xe?.get?.(e),
2763
- behaviorSet: uo?.get?.(e)
2764
- }), po = /* @__PURE__ */ Symbol.for("dom.ts@boundMixinSet"), xe = globalThis[po] ??= /* @__PURE__ */ new WeakMap(), vo = /* @__PURE__ */ Symbol.for("dom.ts@mixinElements"), se = globalThis[vo] ??= /* @__PURE__ */ new WeakMap(), fo = /* @__PURE__ */ Symbol.for("dom.ts@mixinRegistry"), ue = globalThis[fo] ??= /* @__PURE__ */ new Map(), mo = /* @__PURE__ */ Symbol.for("dom.ts@mixinNamespace"), Ce = globalThis[mo] ??= /* @__PURE__ */ new WeakMap(), xa = (e, t) => {
2765
- typeof t == "string" && (t = ue?.get?.(t));
2766
- const r = /* @__PURE__ */ new Set([...e?.getAttribute?.("data-mixin")?.split?.(" ") || []]), a = new Set([...r].map((o) => ue?.get?.(o)).filter((o) => !!o)), n = xe?.get?.(e) ?? /* @__PURE__ */ new WeakSet();
2767
- se?.has?.(t) || se?.set?.(t, /* @__PURE__ */ new WeakSet()), xe?.has?.(e) || xe?.set?.(e, n);
2768
- const i = new WeakRef(e);
2769
- n?.has?.(t) || (a.has(t) || t?.disconnect?.(i, t, we(e)), (a.has(t) || !se?.get?.(t)?.has?.(e)) && (t?.connect?.(i, t, we(e)), r.add(Ce?.get?.(t)), n?.add?.(t), e?.setAttribute?.("data-mixin", [...r].filter((o) => !!o).join(" "))), se?.get?.(t)?.add?.(e)), n?.has?.(t) && (a.has(t) || (n?.delete?.(t), t?.disconnect?.(i, t, we(e))));
2770
- }, jt = /* @__PURE__ */ new Set(), go = (e = typeof document < "u" ? document : null) => {
2771
- if (e)
2772
- return jt?.has?.(e) || (jt?.add?.(e), Ji(e, "*", "data-mixin", (t) => Ht(t.target)), Gi(e, "[data-mixin]", (t) => {
2773
- for (const r of t.addedNodes) r instanceof HTMLElement && Ht(r);
2774
- })), e;
2775
- }, Ht = (e) => {
2776
- const t = /* @__PURE__ */ new Set([...e?.getAttribute?.("data-mixin")?.split?.(" ") || []]);
2777
- [...new Set([...t].map((r) => ue?.get?.(r)).filter((r) => !!r))].map?.((r) => xa(e, r));
2778
- }, bo = (e, t) => {
2779
- e.forEach((r) => t ? xa(r, t) : Ht(r));
2780
- }, yo = (e) => {
2781
- for (const t of jt) bo(t?.querySelectorAll?.("[data-mixin]"), e);
2782
- }, Mo = new FinalizationRegistry((e) => {
2783
- ue?.delete?.(e);
2784
- }), wo = (e, t) => {
2785
- if (!Ce?.has?.(t)) {
2786
- const r = e?.trim?.();
2787
- r && (Ce?.set?.(t, r), ue?.set?.(r, t), Mo?.register?.(t, r), yo(t));
2788
- }
2789
- };
2790
- go(typeof document < "u" ? document : null);
2791
- var Kt = class {
2792
- constructor(e = null) {
2793
- e && wo(e, this);
2794
- }
2795
- connect(e, t, r) {
2796
- return this;
2797
- }
2798
- disconnect(e, t, r) {
2799
- return this;
2800
- }
2801
- storeForElement(e) {
2802
- return It.get(this.name || "")?.get?.(e);
2803
- }
2804
- relatedForElement(e) {
2805
- return we(e);
2806
- }
2807
- get elements() {
2808
- return se?.get?.(this);
2809
- }
2810
- get storage() {
2811
- return It?.get?.(this.name || "");
2812
- }
2813
- get name() {
2814
- return Ce?.get?.(this);
2815
- }
2816
- };
2817
- function kt(e, t) {
2818
- const r = Math.min(e.x, t.x), a = Math.min(e.y, t.y), n = Math.max(e.x, t.x), i = Math.max(e.y, t.y);
2819
- return {
2820
- left: r,
2821
- top: a,
2822
- right: n,
2823
- bottom: i,
2824
- width: n - r,
2825
- height: i - a
2826
- };
2827
- }
2828
- var be = {
2829
- start: "junction-select:start",
2830
- move: "junction-select:move",
2831
- end: "junction-select:end",
2832
- cancel: "junction-select:cancel"
2833
- }, Et = {
2834
- start: "junction-drag:start",
2835
- move: "junction-drag:move",
2836
- end: "junction-drag:end"
2837
- }, Tt = {
2838
- start: "junction-resize:start",
2839
- move: "junction-resize:move",
2840
- end: "junction-resize:end"
2841
- }, xo = /* @__PURE__ */ Symbol.for("dom.ts@mixinDisposers"), Ae = globalThis[xo] ??= /* @__PURE__ */ new WeakMap(), _ = (e, t, r) => {
2842
- const a = Ae.get(e) ?? /* @__PURE__ */ new Map(), n = a.get(t) ?? [];
2843
- n.push(r), a.set(t, n), Ae.set(e, a);
2844
- }, Qt = (e, t) => {
2845
- const r = Ae.get(e), a = r?.get(t);
2846
- if (a) {
2847
- for (const n of a) try {
2848
- n();
2849
- } catch {
2850
- }
2851
- r.delete(t), r.size === 0 && Ae.delete(e);
2852
- }
2853
- }, B = (e, t) => {
2854
- const r = globalThis.getComputedStyle?.(e)?.getPropertyValue?.(t)?.trim?.() ?? "", a = parseFloat(r);
2855
- return Number.isFinite(a) ? a : 0;
2856
- }, Sa = (e, t, r) => {
2857
- const a = e.getAttribute(t)?.trim();
2858
- if (!a) return r;
2859
- const n = e.querySelector(a);
2860
- return n instanceof HTMLElement ? n : r;
2861
- }, So = class extends Kt {
2862
- constructor() {
2863
- super("ui-junction-select");
2864
- }
2865
- connect(e) {
2866
- const t = e?.deref?.();
2867
- if (!t) return this;
2868
- const r = document.createElement("div");
2869
- r.className = "ui-junction-select-overlay", r.setAttribute("data-junction-overlay", ""), r.style.cssText = "position:absolute;pointer-events:none;z-index:9999;box-sizing:border-box;border:1px dashed color-mix(in oklab, #3794ff 70%, transparent);background:color-mix(in oklab, #3794ff 14%, transparent);display:none;inset:auto;min-width:0;min-height:0;", globalThis.getComputedStyle?.(t)?.position === "static" && (t.style.position = "relative"), t.appendChild(r);
2870
- let n = !1, i = {
2871
- x: 0,
2872
- y: 0
2873
- }, o = {
2874
- x: 0,
2875
- y: 0
2876
- };
2877
- const s = (f) => {
2878
- const b = t.getBoundingClientRect();
2879
- return {
2880
- x: f.clientX - b.left,
2881
- y: f.clientY - b.top
2882
- };
2883
- }, l = () => {
2884
- const f = kt(i, o);
2885
- if (f.width < 1 && f.height < 1) {
2886
- r.style.display = "none";
2887
- return;
2888
- }
2889
- r.style.display = "block", r.style.left = `${f.left}px`, r.style.top = `${f.top}px`, r.style.width = `${f.width}px`, r.style.height = `${f.height}px`;
2890
- }, d = (f) => {
2891
- f.button === 0 && (f.target?.closest?.("[data-junction-ignore-select], [data-junction-drag-handle], [data-junction-resize-handle], button, a, input, textarea, select") || (f.target === t || t.contains(f.target)) && (n = !0, i = s(f), o = { ...i }, t.setPointerCapture(f.pointerId), t.dispatchEvent(new CustomEvent(be.start, {
2892
- bubbles: !0,
2893
- detail: {
2894
- a: { ...i },
2895
- b: { ...o },
2896
- host: t
2897
- }
2898
- })), l()));
2899
- }, p = (f) => {
2900
- if (!n) return;
2901
- o = s(f), l();
2902
- const b = kt(i, o);
2903
- t.dispatchEvent(new CustomEvent(be.move, {
2904
- bubbles: !0,
2905
- detail: {
2906
- a: { ...i },
2907
- b: { ...o },
2908
- box: b,
2909
- host: t
2910
- }
2911
- }));
2912
- }, v = (f) => {
2913
- if (!n) return;
2914
- n = !1;
2915
- try {
2916
- t.releasePointerCapture(f.pointerId);
2917
- } catch {
2918
- }
2919
- const b = kt(i, o);
2920
- t.dispatchEvent(new CustomEvent(be.end, {
2921
- bubbles: !0,
2922
- detail: {
2923
- a: { ...i },
2924
- b: { ...o },
2925
- box: b,
2926
- host: t
2927
- }
2928
- }));
2929
- }, c = (f) => {
2930
- n && v(f);
2931
- }, m = (f) => {
2932
- if (n) {
2933
- n = !1, r.style.display = "none";
2934
- try {
2935
- t.releasePointerCapture(f.pointerId);
2936
- } catch {
2937
- }
2938
- t.dispatchEvent(new CustomEvent(be.cancel, {
2939
- bubbles: !0,
2940
- detail: { host: t }
2941
- }));
2942
- }
2943
- };
2944
- return _(t, "ui-junction-select", () => {
2945
- r.remove();
2946
- }), _(t, "ui-junction-select", w(t, "pointerdown", d)), _(t, "ui-junction-select", w(t, "pointermove", p)), _(t, "ui-junction-select", w(t, "pointerup", c)), _(t, "ui-junction-select", w(t, "pointercancel", m)), this;
2947
- }
2948
- disconnect(e) {
2949
- const t = e?.deref?.();
2950
- return t && Qt(t, "ui-junction-select"), this;
2951
- }
2952
- }, ko = class extends Kt {
2953
- constructor() {
2954
- super("ui-junction-drag");
2955
- }
2956
- connect(e) {
2957
- const t = e?.deref?.();
2958
- if (!t) return this;
2959
- ge(t, "--jx-drag-x", B(t, "--jx-drag-x")), ge(t, "--jx-drag-y", B(t, "--jx-drag-y"));
2960
- const r = t.style.transform;
2961
- (!t.style.transform || t.style.transform === "none") && (t.style.transform = "translate3d(calc(var(--jx-drag-x, 0) * 1px), calc(var(--jx-drag-y, 0) * 1px), 0)");
2962
- const a = Sa(t, "data-junction-drag-handle", t);
2963
- let n = !1, i = 0, o = 0, s = 0, l = 0;
2964
- const d = (c) => {
2965
- c.button === 0 && (c.target !== a && !a.contains(c.target) || (n = !0, i = c.clientX, o = c.clientY, s = B(t, "--jx-drag-x"), l = B(t, "--jx-drag-y"), a.setPointerCapture(c.pointerId), t.dispatchEvent(new CustomEvent(Et.start, {
2966
- bubbles: !0,
2967
- detail: {
2968
- host: t,
2969
- clientX: c.clientX,
2970
- clientY: c.clientY,
2971
- baseX: s,
2972
- baseY: l
2973
- }
2974
- }))));
2975
- }, p = (c) => {
2976
- if (!n) return;
2977
- const m = c.clientX - i, f = c.clientY - o, b = s + m, M = l + f;
2978
- ge(t, "--jx-drag-x", b), ge(t, "--jx-drag-y", M), t.dispatchEvent(new CustomEvent(Et.move, {
2979
- bubbles: !0,
2980
- detail: {
2981
- host: t,
2982
- dx: m,
2983
- dy: f,
2984
- x: b,
2985
- y: M
2986
- }
2987
- }));
2988
- }, v = (c) => {
2989
- if (n) {
2990
- n = !1;
2991
- try {
2992
- a.releasePointerCapture(c.pointerId);
2993
- } catch {
2994
- }
2995
- t.dispatchEvent(new CustomEvent(Et.end, {
2996
- bubbles: !0,
2997
- detail: {
2998
- host: t,
2999
- x: B(t, "--jx-drag-x"),
3000
- y: B(t, "--jx-drag-y")
3001
- }
3002
- }));
3003
- }
3004
- };
3005
- return _(t, "ui-junction-drag", () => {
3006
- t.style.transform = r;
3007
- }), _(t, "ui-junction-drag", w(a, "pointerdown", d)), _(t, "ui-junction-drag", w(a, "pointermove", p)), _(t, "ui-junction-drag", w(a, "pointerup", v)), _(t, "ui-junction-drag", w(a, "pointercancel", v)), this;
3008
- }
3009
- disconnect(e) {
3010
- const t = e?.deref?.();
3011
- return t && Qt(t, "ui-junction-drag"), this;
3012
- }
3013
- }, Eo = class extends Kt {
3014
- constructor() {
3015
- super("ui-junction-resize");
3016
- }
3017
- connect(e) {
3018
- const t = e?.deref?.();
3019
- if (!t) return this;
3020
- const r = Sa(t, "data-junction-resize-handle", t);
3021
- let a = !1, n = 0, i = 0, o = 0, s = 0;
3022
- const l = Math.max(120, parseFloat(t.getAttribute("data-junction-resize-min-w") || "") || 120), d = Math.max(80, parseFloat(t.getAttribute("data-junction-resize-min-h") || "") || 80), p = (m) => {
3023
- m.button === 0 && (m.target !== r && !r.contains(m.target) || (a = !0, n = m.clientX, i = m.clientY, o = t.offsetWidth, s = t.offsetHeight, r.setPointerCapture(m.pointerId), t.dispatchEvent(new CustomEvent(Tt.start, {
3024
- bubbles: !0,
3025
- detail: {
3026
- host: t,
3027
- width: o,
3028
- height: s
3029
- }
3030
- }))));
3031
- }, v = (m) => {
3032
- if (!a) return;
3033
- const f = Math.max(l, o + (m.clientX - n)), b = Math.max(d, s + (m.clientY - i));
3034
- t.style.width = `${f}px`, t.style.height = `${b}px`, t.dispatchEvent(new CustomEvent(Tt.move, {
3035
- bubbles: !0,
3036
- detail: {
3037
- host: t,
3038
- width: f,
3039
- height: b
3040
- }
3041
- }));
3042
- }, c = (m) => {
3043
- if (a) {
3044
- a = !1;
3045
- try {
3046
- r.releasePointerCapture(m.pointerId);
3047
- } catch {
3048
- }
3049
- t.dispatchEvent(new CustomEvent(Tt.end, {
3050
- bubbles: !0,
3051
- detail: {
3052
- host: t,
3053
- width: t.offsetWidth,
3054
- height: t.offsetHeight
3055
- }
3056
- }));
3057
- }
3058
- };
3059
- return _(t, "ui-junction-resize", w(r, "pointerdown", p)), _(t, "ui-junction-resize", w(r, "pointermove", v)), _(t, "ui-junction-resize", w(r, "pointerup", c)), _(t, "ui-junction-resize", w(r, "pointercancel", c)), this;
3060
- }
3061
- disconnect(e) {
3062
- const t = e?.deref?.();
3063
- return t && Qt(t, "ui-junction-resize"), this;
3064
- }
3065
- };
3066
- new So();
3067
- new ko();
3068
- new Eo();
3069
- var ye = /* @__PURE__ */ new WeakMap(), To = /* @__PURE__ */ new Map([]), jr = Oi(), Se = (e) => e?.naturalWidth || e?.width || 1, ke = (e) => e?.naturalHeight || e?.height || 1, zo = (e) => {
3070
- const t = {
3071
- alpha: !0,
3072
- desynchronized: !0,
3073
- powerPreference: "high-performance",
3074
- preserveDrawingBuffer: !0
3075
- };
3076
- for (const r of [
3077
- "rec2100-hlg",
3078
- "display-p3",
3079
- "srgb"
3080
- ]) try {
3081
- const a = e.getContext("2d", {
3082
- ...t,
3083
- colorSpace: r
3084
- });
3085
- if (a) return a;
3086
- } catch {
3087
- }
3088
- try {
3089
- return e.getContext("2d", t);
3090
- } catch {
3091
- return e.getContext("2d");
3092
- }
3093
- }, Os = (e, t) => {
3094
- To.set(e, t);
3095
- }, _o = (e, t, r = 1, a, n = 0) => {
3096
- const i = e.canvas;
3097
- e.translate(i.width / 2, i.height / 2), e.rotate((-n || 0) * (Math.PI * 0.5)), e.rotate((1 - a) * (Math.PI / 2)), e.translate(-(Se(t) / 2) * r, -(ke(t) / 2) * r);
3098
- }, Po = (e) => {
3099
- if (!ye.has(e) && (e instanceof Blob || e instanceof File || e instanceof OffscreenCanvas || e instanceof ImageBitmap || e instanceof Image)) {
3100
- const t = createImageBitmap(e).catch((r) => {
3101
- throw ye.delete(e), r;
3102
- });
3103
- ye.set(e, t);
3104
- }
3105
- return ye.get(e);
3106
- }, $o = /* @__PURE__ */ new WeakMap(), Co = (e, t) => $o?.getOrInsertComputed?.(e, () => e?.bind?.(t)), Ot = null;
3107
- typeof HTMLCanvasElement < "u" ? Ot = class extends HTMLCanvasElement {
3108
- static observedAttributes = [
3109
- "data-src",
3110
- "data-orient",
3111
- "orient"
3112
- ];
3113
- ctx = null;
3114
- image = null;
3115
- #e = [1, 1];
3116
- #t = "";
3117
- #r = "";
3118
- get #n() {
3119
- const t = this.getAttribute("data-orient") ?? this.getAttribute("orient") ?? "0", r = Number.parseInt(t, 10);
3120
- return Number.isFinite(r) ? r : 0;
3121
- }
3122
- set #n(t) {
3123
- const r = String(t);
3124
- this.setAttribute("data-orient", r), this.setAttribute("orient", r);
3125
- }
3126
- attributeChangedCallback(t, r, a) {
3127
- t == "data-src" && this.#i(a), (t == "data-orient" || t == "orient") && this.#a(this.#r);
3128
- }
3129
- connectedCallback() {
3130
- const t = this.parentNode;
3131
- this.style.setProperty("max-inline-size", "min(100%, min(100cqi, 100dvi))"), this.style.setProperty("max-block-size", "min(100%, min(100cqb, 100dvb))"), this.#e = [Math.min(Math.min(Math.max(this.clientWidth || t?.clientWidth || 1, 1), t?.clientWidth || 1) * (this.currentCSSZoom || 1), screen?.width || 1) * (devicePixelRatio || 1), Math.min(Math.min(Math.max(this.clientHeight || t?.clientHeight || 1, 1), t?.clientHeight || 1) * (this.currentCSSZoom || 1), screen?.height || 1) * (devicePixelRatio || 1)], this.#i(this.#t = this.dataset.src || this.#t), this.image && this.#a(this.#r);
3132
- }
3133
- constructor() {
3134
- super();
3135
- const t = this, r = this.parentNode, a = () => {
3136
- const n = this.#e;
3137
- this.#e = [Math.min(Math.min(Math.max(this.clientWidth || r?.clientWidth || 1, 1), r?.clientWidth || 1) * (this.currentCSSZoom || 1), screen?.width || 1) * (devicePixelRatio || 1), Math.min(Math.min(Math.max(this.clientHeight || r?.clientHeight || 1, 1), r?.clientHeight || 1) * (this.currentCSSZoom || 1), screen?.height || 1) * (devicePixelRatio || 1)], (n?.[0] != this.#e[0] || n?.[1] != this.#e[1]) && this.#a(this.#r);
3138
- };
3139
- jr?.shedule?.(() => {
3140
- this.ctx = zo(t);
3141
- try {
3142
- this.ctx?.configureHighDynamicRange?.({ mode: "extended" }), t?.configureHighDynamicRange?.({ mode: "extended" });
3143
- } catch {
3144
- }
3145
- this.inert = !0, this.style.objectFit = "cover", this.style.objectPosition = "center", this.classList.add("u-canvas"), this.classList.add("u2-canvas"), this.classList.add("ui-canvas"), this.style.setProperty("max-inline-size", "min(100%, min(100cqi, 100dvi))"), this.style.setProperty("max-block-size", "min(100%, min(100cqb, 100dvb))"), this.style.setProperty("dynamic-range-limit", "no-limit"), this.style.setProperty("color-space", "display-p3"), this.style.setProperty("background-color", "black", "important"), this.style.setProperty("opacity", "1", "important"), a(), new ResizeObserver((n) => {
3146
- for (const i of n) {
3147
- const o = i?.devicePixelContentBoxSize?.[0];
3148
- if (o) {
3149
- const s = this.#e;
3150
- this.#e = [Math.max(o.inlineSize || this.width, 1), Math.max(o.blockSize || this.height, 1)], (s?.[0] != this.#e[0] || s?.[1] != this.#e[1]) && this.#a(this.#r);
3151
- }
3152
- }
3153
- }).observe(this, { box: "device-pixel-content-box" }), this.#i(this.#t = this.dataset.src || this.#t);
3154
- });
3155
- }
3156
- async $useImageAsSource(t, r) {
3157
- r ||= this.#t;
3158
- const a = t instanceof ImageBitmap ? t : await Po(t).catch(console.warn.bind(console));
3159
- return a && r == this.#t && (this.image = a, this.#a(r)), t;
3160
- }
3161
- $renderPass(t) {
3162
- const r = this, a = this.ctx, n = this.image;
3163
- if (n && a && (t == this.#t || !t)) {
3164
- t && (this.#r = t), this.width != this.#e[0] && (this.width = this.#e[0]), this.height != this.#e[1] && (this.height = this.#e[1]), this.style.aspectRatio = `${this.width || 1} / ${this.height || 1}`;
3165
- const i = this.#n % 2 || 0, o = Se(n) <= ke(n) ? 1 : 0, s = Math.max(r[["height", "width"][i]] / (o ? ke(n) : Se(n)), r[["width", "height"][i]] / (o ? Se(n) : ke(n)));
3166
- a.save(), a.clearRect(0, 0, r.width, r.height), _o(a, n, s, o, this.#n), a.drawImage(n, 0, 0, n.width * s, n.height * s), a.restore();
3167
- }
3168
- }
3169
- #i(t) {
3170
- const r = t || this.#t;
3171
- return this.#t = r, fetch(t, {
3172
- cache: "force-cache",
3173
- mode: "same-origin",
3174
- priority: "high"
3175
- })?.then?.(async (a) => this.$useImageAsSource(await a.blob(), r)?.catch(console.warn.bind(console)))?.catch?.(console.warn.bind(console));
3176
- }
3177
- #a(t) {
3178
- const r = this.ctx;
3179
- this.image && r && (t == this.#t || !t) && jr?.shedule?.(Co(this.$renderPass, this));
3180
- }
3181
- } : Ot = class {
3182
- constructor() {
3183
- }
3184
- $renderPass(t) {
3185
- }
3186
- $useImageAsSource(t, r) {
3187
- return t;
3188
- }
3189
- #e(t) {
3190
- return Promise.resolve();
3191
- }
3192
- #t(t) {
3193
- }
3194
- #r = 0;
3195
- #n = "";
3196
- #i = "";
3197
- #a = [1, 1];
3198
- ctx = null;
3199
- image = null;
3200
- };
3201
- try {
3202
- customElements.define("ui-canvas", Ot, { extends: "canvas" });
3203
- } catch {
3204
- }
3205
- var ka = "rs-wallpaper-image", H = "/assets/wallpaper.jpg", Wt = "idb:rs-wallpaper", Ao = "cwsp-wallpaper-v1", O = "blobs", er = "current", Ea = 512e3, $ = null, tr = () => Fi?.[Xi()] ?? 0, Le = () => {
3206
- if ($ && $.startsWith("blob:")) try {
3207
- URL.revokeObjectURL($);
3208
- } catch {
3209
- }
3210
- $ = null;
3211
- }, rr = () => new Promise((e, t) => {
3212
- if (typeof indexedDB > "u") {
3213
- t(/* @__PURE__ */ new Error("indexedDB unavailable"));
3214
- return;
3215
- }
3216
- const r = indexedDB.open(Ao, 1);
3217
- r.onupgradeneeded = () => {
3218
- const a = r.result;
3219
- a.objectStoreNames.contains(O) || a.createObjectStore(O);
3220
- }, r.onsuccess = () => e(r.result), r.onerror = () => t(r.error || /* @__PURE__ */ new Error("IDB open failed"));
3221
- }), Lo = async (e) => {
3222
- const t = await rr();
3223
- try {
3224
- await new Promise((r, a) => {
3225
- const n = t.transaction(O, "readwrite");
3226
- n.objectStore(O).put(e, er), n.oncomplete = () => r(), n.onerror = () => a(n.error || /* @__PURE__ */ new Error("IDB put failed"));
3227
- });
3228
- } finally {
3229
- t.close();
3230
- }
3231
- }, Hr = async () => {
3232
- const e = await rr();
3233
- try {
3234
- return await new Promise((t, r) => {
3235
- const a = e.transaction(O, "readonly").objectStore(O).get(er);
3236
- a.onsuccess = () => {
3237
- const n = a.result;
3238
- t(n instanceof Blob ? n : null);
3239
- }, a.onerror = () => r(a.error || /* @__PURE__ */ new Error("IDB get failed"));
3240
- });
3241
- } finally {
3242
- e.close();
3243
- }
3244
- }, No = async () => {
3245
- try {
3246
- const e = await rr();
3247
- try {
3248
- await new Promise((t, r) => {
3249
- const a = e.transaction(O, "readwrite");
3250
- a.objectStore(O).delete(er), a.oncomplete = () => t(), a.onerror = () => r(a.error || /* @__PURE__ */ new Error("IDB delete failed"));
3251
- });
3252
- } finally {
3253
- e.close();
3254
- }
3255
- } catch {
3256
- }
3257
- }, ar = () => {
3258
- try {
3259
- const e = localStorage.getItem(ka);
3260
- return e && e.trim() ? e.trim() : H;
3261
- } catch {
3262
- return H;
3263
- }
3264
- }, Ne = (e) => {
3265
- try {
3266
- return localStorage.setItem(ka, e), !0;
3267
- } catch {
3268
- return !1;
3269
- }
3270
- }, Ro = (e) => e.startsWith("data:") || e.startsWith("blob:"), Io = async () => {
3271
- const e = ar();
3272
- if (e === "idb:rs-wallpaper" || e.startsWith("idb:")) {
3273
- try {
3274
- const t = await Hr();
3275
- if (t)
3276
- return Le(), $ = URL.createObjectURL(t), $;
3277
- } catch (t) {
3278
- console.warn("[fest/image] wallpaper IDB restore failed", t);
3279
- }
3280
- return H;
3281
- }
3282
- if (e.startsWith("data:") && e.length > Ea) try {
3283
- const t = await Hr();
3284
- if (t)
3285
- return Le(), $ = URL.createObjectURL(t), Ne(Wt), $;
3286
- } catch {
3287
- }
3288
- return e || H;
3289
- }, Vs = () => ar(), Or = (e) => {
3290
- const t = () => {
3291
- const r = tr(), a = String(r);
3292
- e.getAttribute("data-orient") !== a && e.setAttribute("data-orient", a), e.getAttribute("orient") !== a && e.setAttribute("orient", a), e.style.setProperty("--orient", a), e.orient = r;
3293
- };
3294
- return t(), Yi(t);
3295
- }, Ds = () => {
3296
- document.querySelectorAll('[data-app-layer="canvas"] canvas[is="ui-canvas"], [data-app-layer="canvas"] canvas.ui-canvas').forEach((e) => {
3297
- const t = tr(), r = String(t);
3298
- e.setAttribute("data-orient", r), e.setAttribute("orient", r), e.style.setProperty("--orient", r);
3299
- });
3300
- }, ce = (e) => {
3301
- const t = getComputedStyle(document.documentElement).getPropertyValue("--color-primary").trim() || "#5b86eb";
3302
- e.style.background = `radial-gradient(circle at 15% 20%, color-mix(in oklab, ${t} 45%, transparent) 0%, transparent 40%), radial-gradient(circle at 75% 72%, color-mix(in oklab, ${t} 35%, transparent) 0%, transparent 43%)`;
3303
- }, qt = (e) => {
3304
- const t = document.querySelectorAll('[data-app-layer="canvas"] canvas[is="ui-canvas"], [data-app-layer="canvas"] canvas.ui-canvas'), r = String(tr());
3305
- t.forEach((a) => {
3306
- a.setAttribute("data-src", e), a.setAttribute("data-orient", r), a.setAttribute("orient", r), a.style.setProperty("--orient", r);
3307
- });
3308
- }, jo = async (e) => (await fetch(e)).blob(), Ho = async (e) => {
3309
- if (!(e instanceof Blob) || e.size <= 0)
3310
- return Oo(H), H;
3311
- Le(), $ = URL.createObjectURL(e), qt($), $e($, { force: !0 }).then(() => {
3312
- document.querySelectorAll(".app-canvas__glow").forEach(ce);
3313
- });
3314
- try {
3315
- await Lo(e), Ne(Wt);
3316
- } catch (t) {
3317
- console.warn("[fest/image] wallpaper IDB persist failed", t);
3318
- try {
3319
- const r = new FileReader(), a = await new Promise((n, i) => {
3320
- r.onload = () => n(String(r.result || "")), r.onerror = () => i(r.error || /* @__PURE__ */ new Error("read failed")), r.readAsDataURL(e);
3321
- });
3322
- a && !Ne(a) && console.warn("[fest/image] wallpaper localStorage persist also failed (quota?)");
3323
- } catch {
3324
- }
3325
- }
3326
- try {
3327
- globalThis.dispatchEvent?.(new CustomEvent("cwsp-wallpaper-change", { detail: {
3328
- pointer: Wt,
3329
- url: $
3330
- } }));
3331
- } catch {
3332
- }
3333
- return $;
3334
- }, Fs = (e) => {
3335
- const t = e;
3336
- t.replaceChildren(), t.dataset.appLayer = "canvas", t.style.position = "absolute", t.style.inset = "0", t.style.overflow = "hidden", t.style.background = "radial-gradient(circle at 18% 12%, #1b2a45 0%, #0f1728 42%, #060910 100%)";
3337
- const r = document.createElement("div");
3338
- r.className = "app-canvas__glow", r.style.position = "absolute", r.style.inset = "-20%", r.style.pointerEvents = "none", r.style.opacity = "0.7", r.style.background = "radial-gradient(circle at 15% 20%, rgba(145,185,255,0.45) 0%, transparent 40%), radial-gradient(circle at 75% 72%, rgba(91,134,235,0.35) 0%, transparent 43%)";
3339
- const a = document.createElement("canvas", { is: "ui-canvas" });
3340
- a.className = "app-canvas__image ui-canvas", a.style.position = "absolute", a.style.inset = "0", a.style.pointerEvents = "none", a.style.inlineSize = "100%", a.style.blockSize = "100%", a.style.maxInlineSize = "100%", a.style.maxBlockSize = "100%", a.style.opacity = "1", a.style.mixBlendMode = "normal", a.setAttribute("is", "ui-canvas"), a.style.setProperty("dynamic-range-limit", "no-limit"), a.style.setProperty("color-space", "display-p3"), a.style.setProperty("background-color", "black", "important"), a.style.setProperty("opacity", "1", "important"), t.append(r, a);
3341
- const n = ar(), i = n === "idb:rs-wallpaper" || n.startsWith("idb:") || n.startsWith("data:") ? H : n;
3342
- a.setAttribute("data-src", i);
3343
- const o = Or(a);
3344
- return Ri(), ce(r), Io().then((s) => (a.setAttribute("data-src", s), Or(a), $e(s).then(() => ce(r)))), {
3345
- root: t,
3346
- canvas: a,
3347
- glow: r,
3348
- disposeOrient: o
3349
- };
3350
- }, Oo = (e) => {
3351
- const t = String(e || "").trim() || H;
3352
- if (Ro(t) || t.length > Ea) {
3353
- (async () => {
3354
- try {
3355
- const r = t.startsWith("blob:") ? await (await fetch(t)).blob() : await jo(t);
3356
- await Ho(r);
3357
- } catch (r) {
3358
- console.warn("[fest/image] setAppWallpaper inline persist failed", r), qt(t), $e(t, { force: !0 }).then(() => {
3359
- document.querySelectorAll(".app-canvas__glow").forEach(ce);
3360
- });
3361
- }
3362
- })();
3363
- return;
3364
- }
3365
- No(), Le(), Ne(t) || console.warn("[fest/image] wallpaper pointer write failed"), qt(t), $e(t, { force: !0 }).then(() => {
3366
- document.querySelectorAll(".app-canvas__glow").forEach(ce);
3367
- });
3368
- try {
3369
- globalThis.dispatchEvent?.(new CustomEvent("cwsp-wallpaper-change", { detail: {
3370
- pointer: t,
3371
- url: t
3372
- } }));
3373
- } catch {
3374
- }
3375
- };
3376
- export {
3377
- Ot as UICanvas,
3378
- Wt as WALLPAPER_IDB_MARKER,
3379
- _i as WALLPAPER_PRIMARY_STORAGE_KEY,
3380
- Pi as WALLPAPER_THEME_SRC_STORAGE_KEY,
3381
- zi as WALLPAPER_THEME_STORAGE_KEY,
3382
- $e as applyThemeFromWallpaper,
3383
- Me as applyWallpaperThemeSeeds,
3384
- Os as callByFrame,
3385
- _o as cover,
3386
- Po as createImageBitmapCache,
3387
- Wo as electronAPI,
3388
- Ti as getDominantColors,
3389
- Vs as getWallpaperStoragePointer,
3390
- Fs as initializeAppCanvasLayer,
3391
- Rt as loadCachedWallpaperTheme,
3392
- qo as qualityMode,
3393
- Li as rankWallpaperSeeds,
3394
- Io as resolveAppWallpaperUrl,
3395
- Ri as restoreWallpaperThemeCache,
3396
- Oo as setAppWallpaper,
3397
- Ho as setAppWallpaperFromBlob,
3398
- Ds as syncAppWallpaperOrient,
3399
- Or as syncCanvasOrient,
3400
- Ni as themeHosts
3401
- };