@takazudo/zdtp 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +113 -12
- package/dist/apply/apply-token-overrides.d.ts +139 -32
- package/dist/astro/host-adapter.js +39 -39
- package/dist/astro/index.js +1 -1
- package/dist/{autoload-state-CmhI7q9j.js → autoload-state-DF7TsTgY.js} +1 -1
- package/dist/bin/server.js +116 -112
- package/dist/config/panel-config.d.ts +36 -1
- package/dist/export-modal.d.ts +5 -3
- package/dist/import-modal.d.ts +9 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2239 -2219
- package/dist/load-routing-LJ72261l.js +421 -0
- package/dist/{panel-config-CXTCcYQs.js → panel-config-CipeKMTz.js} +286 -234
- package/dist/server/create-apply-handler.d.ts +6 -0
- package/dist/server/index.js +1 -1
- package/dist/state/tweak-state.d.ts +137 -14
- package/dist/testing.js +5 -5
- package/dist/tokens/tier-model.d.ts +12 -0
- package/dist/tweak-state-xt-tSQ_t.js +1958 -0
- package/dist/utils/design-token-serde.d.ts +20 -12
- package/package.json +1 -1
- package/dist/load-routing-DtNTKoLW.js +0 -353
- package/dist/tweak-state-BeXkzoj8.js +0 -1858
|
@@ -1,1858 +0,0 @@
|
|
|
1
|
-
import { g, C as ot, q as W, d as at, b as st, f as ft, i as lt, r as z, o as xe, p as Me, E as ut, h as ct, F as dt, l as ht } from "./panel-config-CXTCcYQs.js";
|
|
2
|
-
const Ce = (e, t) => {
|
|
3
|
-
if (typeof e == "number") {
|
|
4
|
-
if (t === 3)
|
|
5
|
-
return {
|
|
6
|
-
mode: "rgb",
|
|
7
|
-
r: (e >> 8 & 15 | e >> 4 & 240) / 255,
|
|
8
|
-
g: (e >> 4 & 15 | e & 240) / 255,
|
|
9
|
-
b: (e & 15 | e << 4 & 240) / 255
|
|
10
|
-
};
|
|
11
|
-
if (t === 4)
|
|
12
|
-
return {
|
|
13
|
-
mode: "rgb",
|
|
14
|
-
r: (e >> 12 & 15 | e >> 8 & 240) / 255,
|
|
15
|
-
g: (e >> 8 & 15 | e >> 4 & 240) / 255,
|
|
16
|
-
b: (e >> 4 & 15 | e & 240) / 255,
|
|
17
|
-
alpha: (e & 15 | e << 4 & 240) / 255
|
|
18
|
-
};
|
|
19
|
-
if (t === 6)
|
|
20
|
-
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)
|
|
27
|
-
return {
|
|
28
|
-
mode: "rgb",
|
|
29
|
-
r: (e >> 24 & 255) / 255,
|
|
30
|
-
g: (e >> 16 & 255) / 255,
|
|
31
|
-
b: (e >> 8 & 255) / 255,
|
|
32
|
-
alpha: (e & 255) / 255
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}, pt = {
|
|
36
|
-
aliceblue: 15792383,
|
|
37
|
-
antiquewhite: 16444375,
|
|
38
|
-
aqua: 65535,
|
|
39
|
-
aquamarine: 8388564,
|
|
40
|
-
azure: 15794175,
|
|
41
|
-
beige: 16119260,
|
|
42
|
-
bisque: 16770244,
|
|
43
|
-
black: 0,
|
|
44
|
-
blanchedalmond: 16772045,
|
|
45
|
-
blue: 255,
|
|
46
|
-
blueviolet: 9055202,
|
|
47
|
-
brown: 10824234,
|
|
48
|
-
burlywood: 14596231,
|
|
49
|
-
cadetblue: 6266528,
|
|
50
|
-
chartreuse: 8388352,
|
|
51
|
-
chocolate: 13789470,
|
|
52
|
-
coral: 16744272,
|
|
53
|
-
cornflowerblue: 6591981,
|
|
54
|
-
cornsilk: 16775388,
|
|
55
|
-
crimson: 14423100,
|
|
56
|
-
cyan: 65535,
|
|
57
|
-
darkblue: 139,
|
|
58
|
-
darkcyan: 35723,
|
|
59
|
-
darkgoldenrod: 12092939,
|
|
60
|
-
darkgray: 11119017,
|
|
61
|
-
darkgreen: 25600,
|
|
62
|
-
darkgrey: 11119017,
|
|
63
|
-
darkkhaki: 12433259,
|
|
64
|
-
darkmagenta: 9109643,
|
|
65
|
-
darkolivegreen: 5597999,
|
|
66
|
-
darkorange: 16747520,
|
|
67
|
-
darkorchid: 10040012,
|
|
68
|
-
darkred: 9109504,
|
|
69
|
-
darksalmon: 15308410,
|
|
70
|
-
darkseagreen: 9419919,
|
|
71
|
-
darkslateblue: 4734347,
|
|
72
|
-
darkslategray: 3100495,
|
|
73
|
-
darkslategrey: 3100495,
|
|
74
|
-
darkturquoise: 52945,
|
|
75
|
-
darkviolet: 9699539,
|
|
76
|
-
deeppink: 16716947,
|
|
77
|
-
deepskyblue: 49151,
|
|
78
|
-
dimgray: 6908265,
|
|
79
|
-
dimgrey: 6908265,
|
|
80
|
-
dodgerblue: 2003199,
|
|
81
|
-
firebrick: 11674146,
|
|
82
|
-
floralwhite: 16775920,
|
|
83
|
-
forestgreen: 2263842,
|
|
84
|
-
fuchsia: 16711935,
|
|
85
|
-
gainsboro: 14474460,
|
|
86
|
-
ghostwhite: 16316671,
|
|
87
|
-
gold: 16766720,
|
|
88
|
-
goldenrod: 14329120,
|
|
89
|
-
gray: 8421504,
|
|
90
|
-
green: 32768,
|
|
91
|
-
greenyellow: 11403055,
|
|
92
|
-
grey: 8421504,
|
|
93
|
-
honeydew: 15794160,
|
|
94
|
-
hotpink: 16738740,
|
|
95
|
-
indianred: 13458524,
|
|
96
|
-
indigo: 4915330,
|
|
97
|
-
ivory: 16777200,
|
|
98
|
-
khaki: 15787660,
|
|
99
|
-
lavender: 15132410,
|
|
100
|
-
lavenderblush: 16773365,
|
|
101
|
-
lawngreen: 8190976,
|
|
102
|
-
lemonchiffon: 16775885,
|
|
103
|
-
lightblue: 11393254,
|
|
104
|
-
lightcoral: 15761536,
|
|
105
|
-
lightcyan: 14745599,
|
|
106
|
-
lightgoldenrodyellow: 16448210,
|
|
107
|
-
lightgray: 13882323,
|
|
108
|
-
lightgreen: 9498256,
|
|
109
|
-
lightgrey: 13882323,
|
|
110
|
-
lightpink: 16758465,
|
|
111
|
-
lightsalmon: 16752762,
|
|
112
|
-
lightseagreen: 2142890,
|
|
113
|
-
lightskyblue: 8900346,
|
|
114
|
-
lightslategray: 7833753,
|
|
115
|
-
lightslategrey: 7833753,
|
|
116
|
-
lightsteelblue: 11584734,
|
|
117
|
-
lightyellow: 16777184,
|
|
118
|
-
lime: 65280,
|
|
119
|
-
limegreen: 3329330,
|
|
120
|
-
linen: 16445670,
|
|
121
|
-
magenta: 16711935,
|
|
122
|
-
maroon: 8388608,
|
|
123
|
-
mediumaquamarine: 6737322,
|
|
124
|
-
mediumblue: 205,
|
|
125
|
-
mediumorchid: 12211667,
|
|
126
|
-
mediumpurple: 9662683,
|
|
127
|
-
mediumseagreen: 3978097,
|
|
128
|
-
mediumslateblue: 8087790,
|
|
129
|
-
mediumspringgreen: 64154,
|
|
130
|
-
mediumturquoise: 4772300,
|
|
131
|
-
mediumvioletred: 13047173,
|
|
132
|
-
midnightblue: 1644912,
|
|
133
|
-
mintcream: 16121850,
|
|
134
|
-
mistyrose: 16770273,
|
|
135
|
-
moccasin: 16770229,
|
|
136
|
-
navajowhite: 16768685,
|
|
137
|
-
navy: 128,
|
|
138
|
-
oldlace: 16643558,
|
|
139
|
-
olive: 8421376,
|
|
140
|
-
olivedrab: 7048739,
|
|
141
|
-
orange: 16753920,
|
|
142
|
-
orangered: 16729344,
|
|
143
|
-
orchid: 14315734,
|
|
144
|
-
palegoldenrod: 15657130,
|
|
145
|
-
palegreen: 10025880,
|
|
146
|
-
paleturquoise: 11529966,
|
|
147
|
-
palevioletred: 14381203,
|
|
148
|
-
papayawhip: 16773077,
|
|
149
|
-
peachpuff: 16767673,
|
|
150
|
-
peru: 13468991,
|
|
151
|
-
pink: 16761035,
|
|
152
|
-
plum: 14524637,
|
|
153
|
-
powderblue: 11591910,
|
|
154
|
-
purple: 8388736,
|
|
155
|
-
// Added in CSS Colors Level 4:
|
|
156
|
-
// https://drafts.csswg.org/css-color/#changes-from-3
|
|
157
|
-
rebeccapurple: 6697881,
|
|
158
|
-
red: 16711680,
|
|
159
|
-
rosybrown: 12357519,
|
|
160
|
-
royalblue: 4286945,
|
|
161
|
-
saddlebrown: 9127187,
|
|
162
|
-
salmon: 16416882,
|
|
163
|
-
sandybrown: 16032864,
|
|
164
|
-
seagreen: 3050327,
|
|
165
|
-
seashell: 16774638,
|
|
166
|
-
sienna: 10506797,
|
|
167
|
-
silver: 12632256,
|
|
168
|
-
skyblue: 8900331,
|
|
169
|
-
slateblue: 6970061,
|
|
170
|
-
slategray: 7372944,
|
|
171
|
-
slategrey: 7372944,
|
|
172
|
-
snow: 16775930,
|
|
173
|
-
springgreen: 65407,
|
|
174
|
-
steelblue: 4620980,
|
|
175
|
-
tan: 13808780,
|
|
176
|
-
teal: 32896,
|
|
177
|
-
thistle: 14204888,
|
|
178
|
-
tomato: 16737095,
|
|
179
|
-
turquoise: 4251856,
|
|
180
|
-
violet: 15631086,
|
|
181
|
-
wheat: 16113331,
|
|
182
|
-
white: 16777215,
|
|
183
|
-
whitesmoke: 16119285,
|
|
184
|
-
yellow: 16776960,
|
|
185
|
-
yellowgreen: 10145074
|
|
186
|
-
}, gt = (e) => Ce(pt[e.toLowerCase()], 6), mt = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i, bt = (e) => {
|
|
187
|
-
let t;
|
|
188
|
-
return (t = e.match(mt)) ? Ce(parseInt(t[1], 16), t[1].length) : void 0;
|
|
189
|
-
}, S = "([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)", H = `${S}%`, pe = `(?:${S}%|${S})`, yt = `(?:${S}(deg|grad|rad|turn)|${S})`, O = "\\s*,\\s*", xt = new RegExp(
|
|
190
|
-
`^rgba?\\(\\s*${S}${O}${S}${O}${S}\\s*(?:,\\s*${pe}\\s*)?\\)$`
|
|
191
|
-
), Mt = new RegExp(
|
|
192
|
-
`^rgba?\\(\\s*${H}${O}${H}${O}${H}\\s*(?:,\\s*${pe}\\s*)?\\)$`
|
|
193
|
-
), vt = (e) => {
|
|
194
|
-
let t = { mode: "rgb" }, n;
|
|
195
|
-
if (n = e.match(xt))
|
|
196
|
-
n[1] !== void 0 && (t.r = n[1] / 255), n[2] !== void 0 && (t.g = n[2] / 255), n[3] !== void 0 && (t.b = n[3] / 255);
|
|
197
|
-
else if (n = e.match(Mt))
|
|
198
|
-
n[1] !== void 0 && (t.r = n[1] / 100), n[2] !== void 0 && (t.g = n[2] / 100), n[3] !== void 0 && (t.b = n[3] / 100);
|
|
199
|
-
else
|
|
200
|
-
return;
|
|
201
|
-
return n[4] !== void 0 ? t.alpha = Math.max(0, Math.min(1, n[4] / 100)) : n[5] !== void 0 && (t.alpha = Math.max(0, Math.min(1, +n[5]))), t;
|
|
202
|
-
}, j = (e, t) => e === void 0 ? void 0 : typeof e != "object" ? Ee(e) : e.mode !== void 0 ? e : t ? { ...e, mode: t } : void 0, x = (e = "rgb") => (t) => (t = j(t, e)) !== void 0 ? (
|
|
203
|
-
// if the color's mode corresponds to our target mode
|
|
204
|
-
t.mode === e ? (
|
|
205
|
-
// then just return the color
|
|
206
|
-
t
|
|
207
|
-
) : (
|
|
208
|
-
// otherwise check to see if we have a dedicated
|
|
209
|
-
// converter for the target mode
|
|
210
|
-
M[t.mode][e] ? (
|
|
211
|
-
// and return its result...
|
|
212
|
-
M[t.mode][e](t)
|
|
213
|
-
) : (
|
|
214
|
-
// ...otherwise pass through RGB as an intermediary step.
|
|
215
|
-
// if the target mode is RGB...
|
|
216
|
-
e === "rgb" ? (
|
|
217
|
-
// just return the RGB
|
|
218
|
-
M[t.mode].rgb(t)
|
|
219
|
-
) : (
|
|
220
|
-
// otherwise convert color.mode -> RGB -> target_mode
|
|
221
|
-
M.rgb[e](M[t.mode].rgb(t))
|
|
222
|
-
)
|
|
223
|
-
)
|
|
224
|
-
)
|
|
225
|
-
) : void 0, M = {}, _e = {}, K = [], Ae = {}, kt = (e) => e, ge = (e) => (M[e.mode] = {
|
|
226
|
-
...M[e.mode],
|
|
227
|
-
...e.toMode
|
|
228
|
-
}, Object.keys(e.fromMode || {}).forEach((t) => {
|
|
229
|
-
M[t] || (M[t] = {}), M[t][e.mode] = e.fromMode[t];
|
|
230
|
-
}), e.ranges || (e.ranges = {}), e.difference || (e.difference = {}), e.channels.forEach((t) => {
|
|
231
|
-
if (e.ranges[t] === void 0 && (e.ranges[t] = [0, 1]), !e.interpolate[t])
|
|
232
|
-
throw new Error(`Missing interpolator for: ${t}`);
|
|
233
|
-
typeof e.interpolate[t] == "function" && (e.interpolate[t] = {
|
|
234
|
-
use: e.interpolate[t]
|
|
235
|
-
}), e.interpolate[t].fixup || (e.interpolate[t].fixup = kt);
|
|
236
|
-
}), _e[e.mode] = e, (e.parse || []).forEach((t) => {
|
|
237
|
-
St(t, e.mode);
|
|
238
|
-
}), x(e.mode)), X = (e) => _e[e], St = (e, t) => {
|
|
239
|
-
if (typeof e == "string") {
|
|
240
|
-
if (!t)
|
|
241
|
-
throw new Error("'mode' required when 'parser' is a string");
|
|
242
|
-
Ae[e] = t;
|
|
243
|
-
} else typeof e == "function" && K.indexOf(e) < 0 && K.push(e);
|
|
244
|
-
}, ae = /[^\x00-\x7F]|[a-zA-Z_]/, wt = /[^\x00-\x7F]|[-\w]/, l = {
|
|
245
|
-
Function: "function",
|
|
246
|
-
Ident: "ident",
|
|
247
|
-
Number: "number",
|
|
248
|
-
Percentage: "percentage",
|
|
249
|
-
ParenClose: ")",
|
|
250
|
-
None: "none",
|
|
251
|
-
Hue: "hue",
|
|
252
|
-
Alpha: "alpha"
|
|
253
|
-
};
|
|
254
|
-
let u = 0;
|
|
255
|
-
function F(e) {
|
|
256
|
-
let t = e[u], n = e[u + 1];
|
|
257
|
-
return t === "-" || t === "+" ? /\d/.test(n) || n === "." && /\d/.test(e[u + 2]) : t === "." ? /\d/.test(n) : /\d/.test(t);
|
|
258
|
-
}
|
|
259
|
-
function se(e) {
|
|
260
|
-
if (u >= e.length)
|
|
261
|
-
return !1;
|
|
262
|
-
let t = e[u];
|
|
263
|
-
if (ae.test(t))
|
|
264
|
-
return !0;
|
|
265
|
-
if (t === "-") {
|
|
266
|
-
if (e.length - u < 2)
|
|
267
|
-
return !1;
|
|
268
|
-
let n = e[u + 1];
|
|
269
|
-
return !!(n === "-" || ae.test(n));
|
|
270
|
-
}
|
|
271
|
-
return !1;
|
|
272
|
-
}
|
|
273
|
-
const $t = {
|
|
274
|
-
deg: 1,
|
|
275
|
-
rad: 180 / Math.PI,
|
|
276
|
-
grad: 9 / 10,
|
|
277
|
-
turn: 360
|
|
278
|
-
};
|
|
279
|
-
function _(e) {
|
|
280
|
-
let t = "";
|
|
281
|
-
if ((e[u] === "-" || e[u] === "+") && (t += e[u++]), t += V(e), e[u] === "." && /\d/.test(e[u + 1]) && (t += e[u++] + V(e)), (e[u] === "e" || e[u] === "E") && ((e[u + 1] === "-" || e[u + 1] === "+") && /\d/.test(e[u + 2]) ? t += e[u++] + e[u++] + V(e) : /\d/.test(e[u + 1]) && (t += e[u++] + V(e))), se(e)) {
|
|
282
|
-
let n = B(e);
|
|
283
|
-
return n === "deg" || n === "rad" || n === "turn" || n === "grad" ? { type: l.Hue, value: t * $t[n] } : void 0;
|
|
284
|
-
}
|
|
285
|
-
return e[u] === "%" ? (u++, { type: l.Percentage, value: +t }) : { type: l.Number, value: +t };
|
|
286
|
-
}
|
|
287
|
-
function V(e) {
|
|
288
|
-
let t = "";
|
|
289
|
-
for (; /\d/.test(e[u]); )
|
|
290
|
-
t += e[u++];
|
|
291
|
-
return t;
|
|
292
|
-
}
|
|
293
|
-
function B(e) {
|
|
294
|
-
let t = "";
|
|
295
|
-
for (; u < e.length && wt.test(e[u]); )
|
|
296
|
-
t += e[u++];
|
|
297
|
-
return t;
|
|
298
|
-
}
|
|
299
|
-
function Nt(e) {
|
|
300
|
-
let t = B(e);
|
|
301
|
-
return e[u] === "(" ? (u++, { type: l.Function, value: t }) : t === "none" ? { type: l.None, value: void 0 } : { type: l.Ident, value: t };
|
|
302
|
-
}
|
|
303
|
-
function Tt(e = "") {
|
|
304
|
-
let t = e.trim(), n = [], r;
|
|
305
|
-
for (u = 0; u < t.length; ) {
|
|
306
|
-
if (r = t[u++], r === `
|
|
307
|
-
` || r === " " || r === " ") {
|
|
308
|
-
for (; u < t.length && (t[u] === `
|
|
309
|
-
` || t[u] === " " || t[u] === " "); )
|
|
310
|
-
u++;
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
if (r === ",")
|
|
314
|
-
return;
|
|
315
|
-
if (r === ")") {
|
|
316
|
-
n.push({ type: l.ParenClose });
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
if (r === "+") {
|
|
320
|
-
if (u--, F(t)) {
|
|
321
|
-
n.push(_(t));
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (r === "-") {
|
|
327
|
-
if (u--, F(t)) {
|
|
328
|
-
n.push(_(t));
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
if (se(t)) {
|
|
332
|
-
n.push({ type: l.Ident, value: B(t) });
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
if (r === ".") {
|
|
338
|
-
if (u--, F(t)) {
|
|
339
|
-
n.push(_(t));
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
if (r === "/") {
|
|
345
|
-
for (; u < t.length && (t[u] === `
|
|
346
|
-
` || t[u] === " " || t[u] === " "); )
|
|
347
|
-
u++;
|
|
348
|
-
let i;
|
|
349
|
-
if (F(t) && (i = _(t), i.type !== l.Hue)) {
|
|
350
|
-
n.push({ type: l.Alpha, value: i });
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
if (se(t) && B(t) === "none") {
|
|
354
|
-
n.push({
|
|
355
|
-
type: l.Alpha,
|
|
356
|
-
value: { type: l.None, value: void 0 }
|
|
357
|
-
});
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
if (/\d/.test(r)) {
|
|
363
|
-
u--, n.push(_(t));
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
if (ae.test(r)) {
|
|
367
|
-
u--, n.push(Nt(t));
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
return n;
|
|
373
|
-
}
|
|
374
|
-
function It(e) {
|
|
375
|
-
e._i = 0;
|
|
376
|
-
let t = e[e._i++];
|
|
377
|
-
if (!t || t.type !== l.Function || t.value !== "color" || (t = e[e._i++], t.type !== l.Ident))
|
|
378
|
-
return;
|
|
379
|
-
const n = Ae[t.value];
|
|
380
|
-
if (!n)
|
|
381
|
-
return;
|
|
382
|
-
const r = { mode: n }, i = He(e, !1);
|
|
383
|
-
if (!i)
|
|
384
|
-
return;
|
|
385
|
-
const a = X(n).channels;
|
|
386
|
-
for (let o = 0, s, f; o < a.length; o++)
|
|
387
|
-
s = i[o], f = a[o], s.type !== l.None && (r[f] = s.type === l.Number ? s.value : s.value / 100, f === "alpha" && (r[f] = Math.max(0, Math.min(1, r[f]))));
|
|
388
|
-
return r;
|
|
389
|
-
}
|
|
390
|
-
function He(e, t) {
|
|
391
|
-
const n = [];
|
|
392
|
-
let r;
|
|
393
|
-
for (; e._i < e.length; ) {
|
|
394
|
-
if (r = e[e._i++], r.type === l.None || r.type === l.Number || r.type === l.Alpha || r.type === l.Percentage || t && r.type === l.Hue) {
|
|
395
|
-
n.push(r);
|
|
396
|
-
continue;
|
|
397
|
-
}
|
|
398
|
-
if (r.type === l.ParenClose) {
|
|
399
|
-
if (e._i < e.length)
|
|
400
|
-
return;
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
if (!(n.length < 3 || n.length > 4)) {
|
|
406
|
-
if (n.length === 4) {
|
|
407
|
-
if (n[3].type !== l.Alpha)
|
|
408
|
-
return;
|
|
409
|
-
n[3] = n[3].value;
|
|
410
|
-
}
|
|
411
|
-
return n.length === 3 && n.push({ type: l.None, value: void 0 }), n.every((i) => i.type !== l.Alpha) ? n : void 0;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
function Ot(e, t) {
|
|
415
|
-
e._i = 0;
|
|
416
|
-
let n = e[e._i++];
|
|
417
|
-
if (!n || n.type !== l.Function)
|
|
418
|
-
return;
|
|
419
|
-
let r = He(e, t);
|
|
420
|
-
if (r)
|
|
421
|
-
return r.unshift(n.value), r;
|
|
422
|
-
}
|
|
423
|
-
const Ee = (e) => {
|
|
424
|
-
if (typeof e != "string")
|
|
425
|
-
return;
|
|
426
|
-
const t = Tt(e), n = t ? Ot(t, !0) : void 0;
|
|
427
|
-
let r, i = 0, a = K.length;
|
|
428
|
-
for (; i < a; )
|
|
429
|
-
if ((r = K[i++](e, n)) !== void 0)
|
|
430
|
-
return r;
|
|
431
|
-
return t ? It(t) : void 0;
|
|
432
|
-
};
|
|
433
|
-
function Pt(e, t) {
|
|
434
|
-
if (!t || t[0] !== "rgb" && t[0] !== "rgba")
|
|
435
|
-
return;
|
|
436
|
-
const n = { mode: "rgb" }, [, r, i, a, o] = t;
|
|
437
|
-
if (!(r.type === l.Hue || i.type === l.Hue || a.type === l.Hue))
|
|
438
|
-
return r.type !== l.None && (n.r = r.type === l.Number ? r.value / 255 : r.value / 100), i.type !== l.None && (n.g = i.type === l.Number ? i.value / 255 : i.value / 100), a.type !== l.None && (n.b = a.type === l.Number ? a.value / 255 : a.value / 100), o.type !== l.None && (n.alpha = Math.min(
|
|
439
|
-
1,
|
|
440
|
-
Math.max(
|
|
441
|
-
0,
|
|
442
|
-
o.type === l.Number ? o.value : o.value / 100
|
|
443
|
-
)
|
|
444
|
-
)), n;
|
|
445
|
-
}
|
|
446
|
-
const Ct = (e) => e === "transparent" ? { mode: "rgb", r: 0, g: 0, b: 0, alpha: 0 } : void 0, _t = (e, t, n) => e + n * (t - e), At = (e) => {
|
|
447
|
-
let t = [];
|
|
448
|
-
for (let n = 0; n < e.length - 1; n++) {
|
|
449
|
-
let r = e[n], i = e[n + 1];
|
|
450
|
-
r === void 0 && i === void 0 ? t.push(void 0) : r !== void 0 && i !== void 0 ? t.push([r, i]) : t.push(r !== void 0 ? [r, r] : [i, i]);
|
|
451
|
-
}
|
|
452
|
-
return t;
|
|
453
|
-
}, Ht = (e) => (t) => {
|
|
454
|
-
let n = At(t);
|
|
455
|
-
return (r) => {
|
|
456
|
-
let i = r * n.length, a = r >= 1 ? n.length - 1 : Math.max(Math.floor(i), 0), o = n[a];
|
|
457
|
-
return o === void 0 ? void 0 : e(o[0], o[1], i - a);
|
|
458
|
-
};
|
|
459
|
-
}, b = Ht(_t), me = (e) => {
|
|
460
|
-
let t = !1, n = e.map((r) => r !== void 0 ? (t = !0, r) : 1);
|
|
461
|
-
return t ? n : e;
|
|
462
|
-
}, Et = {
|
|
463
|
-
mode: "rgb",
|
|
464
|
-
channels: ["r", "g", "b", "alpha"],
|
|
465
|
-
parse: [
|
|
466
|
-
Pt,
|
|
467
|
-
bt,
|
|
468
|
-
vt,
|
|
469
|
-
gt,
|
|
470
|
-
Ct,
|
|
471
|
-
"srgb"
|
|
472
|
-
],
|
|
473
|
-
serialize: "srgb",
|
|
474
|
-
interpolate: {
|
|
475
|
-
r: b,
|
|
476
|
-
g: b,
|
|
477
|
-
b,
|
|
478
|
-
alpha: { use: b, fixup: me }
|
|
479
|
-
},
|
|
480
|
-
gamut: !0,
|
|
481
|
-
white: { r: 1, g: 1, b: 1 },
|
|
482
|
-
black: { r: 0, g: 0, b: 0 }
|
|
483
|
-
}, U = (e = 0) => {
|
|
484
|
-
const t = Math.abs(e);
|
|
485
|
-
return t <= 0.04045 ? e / 12.92 : (Math.sign(e) || 1) * Math.pow((t + 0.055) / 1.055, 2.4);
|
|
486
|
-
}, Re = ({ r: e, g: t, b: n, alpha: r }) => {
|
|
487
|
-
let i = {
|
|
488
|
-
mode: "lrgb",
|
|
489
|
-
r: U(e),
|
|
490
|
-
g: U(t),
|
|
491
|
-
b: U(n)
|
|
492
|
-
};
|
|
493
|
-
return r !== void 0 && (i.alpha = r), i;
|
|
494
|
-
}, Q = (e = 0) => {
|
|
495
|
-
const t = Math.abs(e);
|
|
496
|
-
return t > 31308e-7 ? (Math.sign(e) || 1) * (1.055 * Math.pow(t, 1 / 2.4) - 0.055) : e * 12.92;
|
|
497
|
-
}, Fe = ({ r: e, g: t, b: n, alpha: r }, i = "rgb") => {
|
|
498
|
-
let a = {
|
|
499
|
-
mode: i,
|
|
500
|
-
r: Q(e),
|
|
501
|
-
g: Q(t),
|
|
502
|
-
b: Q(n)
|
|
503
|
-
};
|
|
504
|
-
return r !== void 0 && (a.alpha = r), a;
|
|
505
|
-
}, w = (e) => (e = e % 360) < 0 ? e + 360 : e, Rt = (e, t) => e.map((n, r, i) => {
|
|
506
|
-
if (n === void 0)
|
|
507
|
-
return n;
|
|
508
|
-
let a = w(n);
|
|
509
|
-
return r === 0 || e[r - 1] === void 0 ? a : t(a - w(i[r - 1]));
|
|
510
|
-
}).reduce((n, r) => !n.length || r === void 0 || n[n.length - 1] === void 0 ? (n.push(r), n) : (n.push(r + n[n.length - 1]), n), []), Ve = (e) => Rt(e, (t) => Math.abs(t) <= 180 ? t : t - 360 * Math.sign(t)), Ft = (e, t) => {
|
|
511
|
-
if (e.h === void 0 || t.h === void 0 || !e.s || !t.s)
|
|
512
|
-
return 0;
|
|
513
|
-
let n = w(e.h), r = w(t.h), i = Math.sin((r - n + 360) / 2 * Math.PI / 180);
|
|
514
|
-
return 2 * Math.sqrt(e.s * t.s) * i;
|
|
515
|
-
}, Vt = (e, t) => {
|
|
516
|
-
if (e.h === void 0 || t.h === void 0 || !e.c || !t.c)
|
|
517
|
-
return 0;
|
|
518
|
-
let n = w(e.h), r = w(t.h), i = Math.sin((r - n + 360) / 2 * Math.PI / 180);
|
|
519
|
-
return 2 * Math.sqrt(e.c * t.c) * i;
|
|
520
|
-
}, De = (e) => {
|
|
521
|
-
let t = e.reduce(
|
|
522
|
-
(r, i) => {
|
|
523
|
-
if (i !== void 0) {
|
|
524
|
-
let a = i * Math.PI / 180;
|
|
525
|
-
r.sin += Math.sin(a), r.cos += Math.cos(a);
|
|
526
|
-
}
|
|
527
|
-
return r;
|
|
528
|
-
},
|
|
529
|
-
{ sin: 0, cos: 0 }
|
|
530
|
-
), n = Math.atan2(t.sin, t.cos) * 180 / Math.PI;
|
|
531
|
-
return n < 0 ? 360 + n : n;
|
|
532
|
-
}, G = ({ l: e, a: t, b: n, alpha: r }, i = "lch") => {
|
|
533
|
-
t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
534
|
-
let a = Math.sqrt(t * t + n * n), o = { mode: i, l: e, c: a };
|
|
535
|
-
return a && (o.h = w(Math.atan2(n, t) * 180 / Math.PI)), r !== void 0 && (o.alpha = r), o;
|
|
536
|
-
}, q = ({ l: e, c: t, h: n, alpha: r }, i = "lab") => {
|
|
537
|
-
n === void 0 && (n = 0);
|
|
538
|
-
let a = {
|
|
539
|
-
mode: i,
|
|
540
|
-
l: e,
|
|
541
|
-
a: t ? t * Math.cos(n / 180 * Math.PI) : 0,
|
|
542
|
-
b: t ? t * Math.sin(n / 180 * Math.PI) : 0
|
|
543
|
-
};
|
|
544
|
-
return r !== void 0 && (a.alpha = r), a;
|
|
545
|
-
}, I = {
|
|
546
|
-
X: 0.3457 / 0.3585,
|
|
547
|
-
Y: 1,
|
|
548
|
-
Z: (1 - 0.3457 - 0.3585) / 0.3585
|
|
549
|
-
};
|
|
550
|
-
function Dt({ h: e, s: t, l: n, alpha: r }) {
|
|
551
|
-
e = w(e !== void 0 ? e : 0), t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
552
|
-
let i = n + t * (n < 0.5 ? n : 1 - n), a = i - (i - n) * 2 * Math.abs(e / 60 % 2 - 1), o;
|
|
553
|
-
switch (Math.floor(e / 60)) {
|
|
554
|
-
case 0:
|
|
555
|
-
o = { r: i, g: a, b: 2 * n - i };
|
|
556
|
-
break;
|
|
557
|
-
case 1:
|
|
558
|
-
o = { r: a, g: i, b: 2 * n - i };
|
|
559
|
-
break;
|
|
560
|
-
case 2:
|
|
561
|
-
o = { r: 2 * n - i, g: i, b: a };
|
|
562
|
-
break;
|
|
563
|
-
case 3:
|
|
564
|
-
o = { r: 2 * n - i, g: a, b: i };
|
|
565
|
-
break;
|
|
566
|
-
case 4:
|
|
567
|
-
o = { r: a, g: 2 * n - i, b: i };
|
|
568
|
-
break;
|
|
569
|
-
case 5:
|
|
570
|
-
o = { r: i, g: 2 * n - i, b: a };
|
|
571
|
-
break;
|
|
572
|
-
default:
|
|
573
|
-
o = { r: 2 * n - i, g: 2 * n - i, b: 2 * n - i };
|
|
574
|
-
}
|
|
575
|
-
return o.mode = "rgb", r !== void 0 && (o.alpha = r), o;
|
|
576
|
-
}
|
|
577
|
-
function Lt({ r: e, g: t, b: n, alpha: r }) {
|
|
578
|
-
e === void 0 && (e = 0), t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
579
|
-
let i = Math.max(e, t, n), a = Math.min(e, t, n), o = {
|
|
580
|
-
mode: "hsl",
|
|
581
|
-
s: i === a ? 0 : (i - a) / (1 - Math.abs(i + a - 1)),
|
|
582
|
-
l: 0.5 * (i + a)
|
|
583
|
-
};
|
|
584
|
-
return i - a !== 0 && (o.h = (i === e ? (t - n) / (i - a) + (t < n) * 6 : i === t ? (n - e) / (i - a) + 2 : (e - t) / (i - a) + 4) * 60), r !== void 0 && (o.alpha = r), o;
|
|
585
|
-
}
|
|
586
|
-
const zt = (e, t) => {
|
|
587
|
-
switch (t) {
|
|
588
|
-
case "deg":
|
|
589
|
-
return +e;
|
|
590
|
-
case "rad":
|
|
591
|
-
return e / Math.PI * 180;
|
|
592
|
-
case "grad":
|
|
593
|
-
return e / 10 * 9;
|
|
594
|
-
case "turn":
|
|
595
|
-
return e * 360;
|
|
596
|
-
}
|
|
597
|
-
}, jt = new RegExp(
|
|
598
|
-
`^hsla?\\(\\s*${yt}${O}${H}${O}${H}\\s*(?:,\\s*${pe}\\s*)?\\)$`
|
|
599
|
-
), Kt = (e) => {
|
|
600
|
-
let t = e.match(jt);
|
|
601
|
-
if (!t) return;
|
|
602
|
-
let n = { mode: "hsl" };
|
|
603
|
-
return t[3] !== void 0 ? n.h = +t[3] : t[1] !== void 0 && t[2] !== void 0 && (n.h = zt(t[1], t[2])), t[4] !== void 0 && (n.s = Math.min(Math.max(0, t[4] / 100), 1)), t[5] !== void 0 && (n.l = Math.min(Math.max(0, t[5] / 100), 1)), t[6] !== void 0 ? n.alpha = Math.max(0, Math.min(1, t[6] / 100)) : t[7] !== void 0 && (n.alpha = Math.max(0, Math.min(1, +t[7]))), n;
|
|
604
|
-
};
|
|
605
|
-
function Bt(e, t) {
|
|
606
|
-
if (!t || t[0] !== "hsl" && t[0] !== "hsla")
|
|
607
|
-
return;
|
|
608
|
-
const n = { mode: "hsl" }, [, r, i, a, o] = t;
|
|
609
|
-
if (r.type !== l.None) {
|
|
610
|
-
if (r.type === l.Percentage)
|
|
611
|
-
return;
|
|
612
|
-
n.h = r.value;
|
|
613
|
-
}
|
|
614
|
-
if (i.type !== l.None) {
|
|
615
|
-
if (i.type === l.Hue)
|
|
616
|
-
return;
|
|
617
|
-
n.s = i.value / 100;
|
|
618
|
-
}
|
|
619
|
-
if (a.type !== l.None) {
|
|
620
|
-
if (a.type === l.Hue)
|
|
621
|
-
return;
|
|
622
|
-
n.l = a.value / 100;
|
|
623
|
-
}
|
|
624
|
-
return o.type !== l.None && (n.alpha = Math.min(
|
|
625
|
-
1,
|
|
626
|
-
Math.max(
|
|
627
|
-
0,
|
|
628
|
-
o.type === l.Number ? o.value : o.value / 100
|
|
629
|
-
)
|
|
630
|
-
)), n;
|
|
631
|
-
}
|
|
632
|
-
const Gt = {
|
|
633
|
-
mode: "hsl",
|
|
634
|
-
toMode: {
|
|
635
|
-
rgb: Dt
|
|
636
|
-
},
|
|
637
|
-
fromMode: {
|
|
638
|
-
rgb: Lt
|
|
639
|
-
},
|
|
640
|
-
channels: ["h", "s", "l", "alpha"],
|
|
641
|
-
ranges: {
|
|
642
|
-
h: [0, 360]
|
|
643
|
-
},
|
|
644
|
-
gamut: "rgb",
|
|
645
|
-
parse: [Bt, Kt],
|
|
646
|
-
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}` : ""})`,
|
|
647
|
-
interpolate: {
|
|
648
|
-
h: { use: b, fixup: Ve },
|
|
649
|
-
s: b,
|
|
650
|
-
l: b,
|
|
651
|
-
alpha: { use: b, fixup: me }
|
|
652
|
-
},
|
|
653
|
-
difference: {
|
|
654
|
-
h: Ft
|
|
655
|
-
},
|
|
656
|
-
average: {
|
|
657
|
-
h: De
|
|
658
|
-
}
|
|
659
|
-
}, Le = Math.pow(29, 3) / Math.pow(3, 3), ze = Math.pow(6, 3) / Math.pow(29, 3);
|
|
660
|
-
let ee = (e) => Math.pow(e, 3) > ze ? Math.pow(e, 3) : (116 * e - 16) / Le;
|
|
661
|
-
const qt = ({ l: e, a: t, b: n, alpha: r }) => {
|
|
662
|
-
e === void 0 && (e = 0), t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
663
|
-
let i = (e + 16) / 116, a = t / 500 + i, o = i - n / 200, s = {
|
|
664
|
-
mode: "xyz50",
|
|
665
|
-
x: ee(a) * I.X,
|
|
666
|
-
y: ee(i) * I.Y,
|
|
667
|
-
z: ee(o) * I.Z
|
|
668
|
-
};
|
|
669
|
-
return r !== void 0 && (s.alpha = r), s;
|
|
670
|
-
}, Jt = ({ x: e, y: t, z: n, alpha: r }) => {
|
|
671
|
-
e === void 0 && (e = 0), t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
672
|
-
let i = Fe({
|
|
673
|
-
r: e * 3.1341359569958707 - t * 1.6173863321612538 - 0.4906619460083532 * n,
|
|
674
|
-
g: e * -0.978795502912089 + t * 1.916254567259524 + 0.03344273116131949 * n,
|
|
675
|
-
b: e * 0.07195537988411677 - t * 0.2289768264158322 + 1.405386058324125 * n
|
|
676
|
-
});
|
|
677
|
-
return r !== void 0 && (i.alpha = r), i;
|
|
678
|
-
}, Wt = (e) => Jt(qt(e)), Xt = (e) => {
|
|
679
|
-
let { r: t, g: n, b: r, alpha: i } = Re(e), a = {
|
|
680
|
-
mode: "xyz50",
|
|
681
|
-
x: 0.436065742824811 * t + 0.3851514688337912 * n + 0.14307845442264197 * r,
|
|
682
|
-
y: 0.22249319175623702 * t + 0.7168870538238823 * n + 0.06061979053616537 * r,
|
|
683
|
-
z: 0.013923904500943465 * t + 0.09708128566574634 * n + 0.7140993584005155 * r
|
|
684
|
-
};
|
|
685
|
-
return i !== void 0 && (a.alpha = i), a;
|
|
686
|
-
}, te = (e) => e > ze ? Math.cbrt(e) : (Le * e + 16) / 116, Yt = ({ x: e, y: t, z: n, alpha: r }) => {
|
|
687
|
-
e === void 0 && (e = 0), t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
688
|
-
let i = te(e / I.X), a = te(t / I.Y), o = te(n / I.Z), s = {
|
|
689
|
-
mode: "lab",
|
|
690
|
-
l: 116 * a - 16,
|
|
691
|
-
a: 500 * (i - a),
|
|
692
|
-
b: 200 * (a - o)
|
|
693
|
-
};
|
|
694
|
-
return r !== void 0 && (s.alpha = r), s;
|
|
695
|
-
}, Zt = (e) => {
|
|
696
|
-
let t = Yt(Xt(e));
|
|
697
|
-
return e.r === e.b && e.b === e.g && (t.a = t.b = 0), t;
|
|
698
|
-
};
|
|
699
|
-
function Ut(e, t) {
|
|
700
|
-
if (!t || t[0] !== "lch")
|
|
701
|
-
return;
|
|
702
|
-
const n = { mode: "lch" }, [, r, i, a, o] = t;
|
|
703
|
-
if (r.type !== l.None) {
|
|
704
|
-
if (r.type === l.Hue)
|
|
705
|
-
return;
|
|
706
|
-
n.l = Math.min(Math.max(0, r.value), 100);
|
|
707
|
-
}
|
|
708
|
-
if (i.type !== l.None && (n.c = Math.max(
|
|
709
|
-
0,
|
|
710
|
-
i.type === l.Number ? i.value : i.value * 150 / 100
|
|
711
|
-
)), a.type !== l.None) {
|
|
712
|
-
if (a.type === l.Percentage)
|
|
713
|
-
return;
|
|
714
|
-
n.h = a.value;
|
|
715
|
-
}
|
|
716
|
-
return o.type !== l.None && (n.alpha = Math.min(
|
|
717
|
-
1,
|
|
718
|
-
Math.max(
|
|
719
|
-
0,
|
|
720
|
-
o.type === l.Number ? o.value : o.value / 100
|
|
721
|
-
)
|
|
722
|
-
)), n;
|
|
723
|
-
}
|
|
724
|
-
const Qt = {
|
|
725
|
-
mode: "lch",
|
|
726
|
-
toMode: {
|
|
727
|
-
lab: q,
|
|
728
|
-
rgb: (e) => Wt(q(e))
|
|
729
|
-
},
|
|
730
|
-
fromMode: {
|
|
731
|
-
rgb: (e) => G(Zt(e)),
|
|
732
|
-
lab: G
|
|
733
|
-
},
|
|
734
|
-
channels: ["l", "c", "h", "alpha"],
|
|
735
|
-
ranges: {
|
|
736
|
-
l: [0, 100],
|
|
737
|
-
c: [0, 150],
|
|
738
|
-
h: [0, 360]
|
|
739
|
-
},
|
|
740
|
-
parse: [Ut],
|
|
741
|
-
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}` : ""})`,
|
|
742
|
-
interpolate: {
|
|
743
|
-
h: { use: b, fixup: Ve },
|
|
744
|
-
c: b,
|
|
745
|
-
l: b,
|
|
746
|
-
alpha: { use: b, fixup: me }
|
|
747
|
-
},
|
|
748
|
-
difference: {
|
|
749
|
-
h: Vt
|
|
750
|
-
},
|
|
751
|
-
average: {
|
|
752
|
-
h: De
|
|
753
|
-
}
|
|
754
|
-
}, en = ({ r: e, g: t, b: n, alpha: r }) => {
|
|
755
|
-
e === void 0 && (e = 0), t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
756
|
-
let i = Math.cbrt(
|
|
757
|
-
0.412221469470763 * e + 0.5363325372617348 * t + 0.0514459932675022 * n
|
|
758
|
-
), a = Math.cbrt(
|
|
759
|
-
0.2119034958178252 * e + 0.6806995506452344 * t + 0.1073969535369406 * n
|
|
760
|
-
), o = Math.cbrt(
|
|
761
|
-
0.0883024591900564 * e + 0.2817188391361215 * t + 0.6299787016738222 * n
|
|
762
|
-
), s = {
|
|
763
|
-
mode: "oklab",
|
|
764
|
-
l: 0.210454268309314 * i + 0.7936177747023054 * a - 0.0040720430116193 * o,
|
|
765
|
-
a: 1.9779985324311684 * i - 2.42859224204858 * a + 0.450593709617411 * o,
|
|
766
|
-
b: 0.0259040424655478 * i + 0.7827717124575296 * a - 0.8086757549230774 * o
|
|
767
|
-
};
|
|
768
|
-
return r !== void 0 && (s.alpha = r), s;
|
|
769
|
-
}, tn = (e) => {
|
|
770
|
-
let t = en(Re(e));
|
|
771
|
-
return e.r === e.b && e.b === e.g && (t.a = t.b = 0), t;
|
|
772
|
-
}, nn = ({ l: e, a: t, b: n, alpha: r }) => {
|
|
773
|
-
e === void 0 && (e = 0), t === void 0 && (t = 0), n === void 0 && (n = 0);
|
|
774
|
-
let i = Math.pow(e + 0.3963377773761749 * t + 0.2158037573099136 * n, 3), a = Math.pow(e - 0.1055613458156586 * t - 0.0638541728258133 * n, 3), o = Math.pow(e - 0.0894841775298119 * t - 1.2914855480194092 * n, 3), s = {
|
|
775
|
-
mode: "lrgb",
|
|
776
|
-
r: 4.076741636075957 * i - 3.3077115392580616 * a + 0.2309699031821044 * o,
|
|
777
|
-
g: -1.2684379732850317 * i + 2.6097573492876887 * a - 0.3413193760026573 * o,
|
|
778
|
-
b: -0.0041960761386756 * i - 0.7034186179359362 * a + 1.7076146940746117 * o
|
|
779
|
-
};
|
|
780
|
-
return r !== void 0 && (s.alpha = r), s;
|
|
781
|
-
}, rn = (e) => Fe(nn(e));
|
|
782
|
-
function on(e, t) {
|
|
783
|
-
if (!t || t[0] !== "oklch")
|
|
784
|
-
return;
|
|
785
|
-
const n = { mode: "oklch" }, [, r, i, a, o] = t;
|
|
786
|
-
if (r.type !== l.None) {
|
|
787
|
-
if (r.type === l.Hue)
|
|
788
|
-
return;
|
|
789
|
-
n.l = Math.min(
|
|
790
|
-
Math.max(0, r.type === l.Number ? r.value : r.value / 100),
|
|
791
|
-
1
|
|
792
|
-
);
|
|
793
|
-
}
|
|
794
|
-
if (i.type !== l.None && (n.c = Math.max(
|
|
795
|
-
0,
|
|
796
|
-
i.type === l.Number ? i.value : i.value * 0.4 / 100
|
|
797
|
-
)), a.type !== l.None) {
|
|
798
|
-
if (a.type === l.Percentage)
|
|
799
|
-
return;
|
|
800
|
-
n.h = a.value;
|
|
801
|
-
}
|
|
802
|
-
return o.type !== l.None && (n.alpha = Math.min(
|
|
803
|
-
1,
|
|
804
|
-
Math.max(
|
|
805
|
-
0,
|
|
806
|
-
o.type === l.Number ? o.value : o.value / 100
|
|
807
|
-
)
|
|
808
|
-
)), n;
|
|
809
|
-
}
|
|
810
|
-
const an = {
|
|
811
|
-
...Qt,
|
|
812
|
-
mode: "oklch",
|
|
813
|
-
toMode: {
|
|
814
|
-
oklab: (e) => q(e, "oklab"),
|
|
815
|
-
rgb: (e) => rn(q(e, "oklab"))
|
|
816
|
-
},
|
|
817
|
-
fromMode: {
|
|
818
|
-
rgb: (e) => G(tn(e), "oklch"),
|
|
819
|
-
oklab: (e) => G(e, "oklch")
|
|
820
|
-
},
|
|
821
|
-
parse: [on],
|
|
822
|
-
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}` : ""})`,
|
|
823
|
-
ranges: {
|
|
824
|
-
l: [0, 1],
|
|
825
|
-
c: [0, 0.4],
|
|
826
|
-
h: [0, 360]
|
|
827
|
-
}
|
|
828
|
-
}, sn = (e) => Math.max(0, Math.min(1, e || 0)), L = (e) => Math.round(sn(e) * 255), je = x("rgb"), Ke = (e) => {
|
|
829
|
-
if (e === void 0)
|
|
830
|
-
return;
|
|
831
|
-
let t = L(e.r), n = L(e.g), r = L(e.b);
|
|
832
|
-
return "#" + (1 << 24 | t << 16 | n << 8 | r).toString(16).slice(1);
|
|
833
|
-
}, fn = (e) => {
|
|
834
|
-
if (e === void 0)
|
|
835
|
-
return;
|
|
836
|
-
let t = L(e.alpha !== void 0 ? e.alpha : 1);
|
|
837
|
-
return Ke(e) + (256 | t).toString(16).slice(1);
|
|
838
|
-
}, ln = (e) => Ke(je(e)), un = (e) => fn(je(e)), Be = x("rgb"), Ge = (e) => {
|
|
839
|
-
const t = {
|
|
840
|
-
mode: e.mode,
|
|
841
|
-
r: Math.max(0, Math.min(e.r !== void 0 ? e.r : 0, 1)),
|
|
842
|
-
g: Math.max(0, Math.min(e.g !== void 0 ? e.g : 0, 1)),
|
|
843
|
-
b: Math.max(0, Math.min(e.b !== void 0 ? e.b : 0, 1))
|
|
844
|
-
};
|
|
845
|
-
return e.alpha !== void 0 && (t.alpha = e.alpha), t;
|
|
846
|
-
}, cn = (e) => Ge(Be(e)), qe = (e) => e !== void 0 && (e.r === void 0 || e.r >= 0 && e.r <= 1) && (e.g === void 0 || e.g >= 0 && e.g <= 1) && (e.b === void 0 || e.b >= 0 && e.b <= 1);
|
|
847
|
-
function dn(e) {
|
|
848
|
-
return qe(Be(e));
|
|
849
|
-
}
|
|
850
|
-
function be(e = "rgb") {
|
|
851
|
-
const { gamut: t } = X(e);
|
|
852
|
-
if (!t)
|
|
853
|
-
return (r) => !0;
|
|
854
|
-
const n = x(typeof t == "string" ? t : e);
|
|
855
|
-
return (r) => qe(n(r));
|
|
856
|
-
}
|
|
857
|
-
function hn(e = "rgb") {
|
|
858
|
-
const { gamut: t } = X(e);
|
|
859
|
-
if (!t)
|
|
860
|
-
return (a) => j(a);
|
|
861
|
-
const n = typeof t == "string" ? t : e, r = x(n), i = be(n);
|
|
862
|
-
return (a) => {
|
|
863
|
-
const o = j(a);
|
|
864
|
-
if (!o)
|
|
865
|
-
return;
|
|
866
|
-
const s = r(o);
|
|
867
|
-
if (i(s))
|
|
868
|
-
return o;
|
|
869
|
-
const f = Ge(s);
|
|
870
|
-
return o.mode === f.mode ? f : x(o.mode)(f);
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
function pn(e, t = "lch", n = "rgb") {
|
|
874
|
-
e = j(e);
|
|
875
|
-
let r = n === "rgb" ? dn : be(n), i = n === "rgb" ? cn : hn(n);
|
|
876
|
-
if (e === void 0 || r(e)) return e;
|
|
877
|
-
let a = x(e.mode);
|
|
878
|
-
e = x(t)(e);
|
|
879
|
-
let o = { ...e, c: 0 };
|
|
880
|
-
if (!r(o))
|
|
881
|
-
return a(i(o));
|
|
882
|
-
let s = 0, f = e.c !== void 0 ? e.c : 0, c = X(t).ranges.c, d = (c[1] - c[0]) / Math.pow(2, 13), h = o.c;
|
|
883
|
-
for (; f - s > d; )
|
|
884
|
-
o.c = s + (f - s) * 0.5, r(o) ? (h = o.c, s = o.c) : f = o.c;
|
|
885
|
-
return a(
|
|
886
|
-
r(o) ? o : { ...o, c: h }
|
|
887
|
-
);
|
|
888
|
-
}
|
|
889
|
-
ge(an);
|
|
890
|
-
ge(Et);
|
|
891
|
-
ge(Gt);
|
|
892
|
-
const qn = 0.37, Je = x("oklch"), We = x("rgb"), gn = x("hsl"), mn = be("rgb");
|
|
893
|
-
function Y(e) {
|
|
894
|
-
return {
|
|
895
|
-
mode: "oklch",
|
|
896
|
-
l: e.l / 100,
|
|
897
|
-
c: e.c,
|
|
898
|
-
h: e.h,
|
|
899
|
-
alpha: e.a / 100
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
function bn(e) {
|
|
903
|
-
return {
|
|
904
|
-
l: (e.l ?? 0) * 100,
|
|
905
|
-
c: e.c ?? 0,
|
|
906
|
-
h: e.h ?? 0,
|
|
907
|
-
a: (e.alpha ?? 1) * 100
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
function Jn(e) {
|
|
911
|
-
const t = (e.l / 100).toFixed(4), n = e.c.toFixed(4), r = e.h.toFixed(2);
|
|
912
|
-
if (e.a >= 100)
|
|
913
|
-
return `oklch(${t} ${n} ${r})`;
|
|
914
|
-
const i = (e.a / 100).toFixed(4);
|
|
915
|
-
return `oklch(${t} ${n} ${r} / ${i})`;
|
|
916
|
-
}
|
|
917
|
-
function Wn(e) {
|
|
918
|
-
const t = { l: 0, c: 0, h: 0, a: 100 };
|
|
919
|
-
try {
|
|
920
|
-
const n = Ee(e);
|
|
921
|
-
if (!n) return t;
|
|
922
|
-
const r = Je(n);
|
|
923
|
-
if (!r) return t;
|
|
924
|
-
const i = r.alpha === void 0 ? 1 : r.alpha;
|
|
925
|
-
return {
|
|
926
|
-
l: (r.l ?? 0) * 100,
|
|
927
|
-
c: r.c ?? 0,
|
|
928
|
-
h: r.h ?? 0,
|
|
929
|
-
a: i * 100
|
|
930
|
-
};
|
|
931
|
-
} catch {
|
|
932
|
-
return t;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
function Xn(e, t) {
|
|
936
|
-
const n = Y(e), r = We(n);
|
|
937
|
-
return r ? e.a < 100 ? un({ ...r, alpha: e.a / 100 }) ?? "#000000ff" : ln(r) ?? "#000000" : "#000000";
|
|
938
|
-
}
|
|
939
|
-
function Yn(e) {
|
|
940
|
-
const t = Y(e), n = gn(t);
|
|
941
|
-
return n ? {
|
|
942
|
-
h: n.h ?? 0,
|
|
943
|
-
s: (n.s ?? 0) * 100,
|
|
944
|
-
l: (n.l ?? 0) * 100,
|
|
945
|
-
a: e.a
|
|
946
|
-
} : { h: 0, s: 0, l: 0, a: e.a };
|
|
947
|
-
}
|
|
948
|
-
function Zn(e) {
|
|
949
|
-
const t = {
|
|
950
|
-
mode: "hsl",
|
|
951
|
-
h: e.h,
|
|
952
|
-
s: e.s / 100,
|
|
953
|
-
l: e.l / 100,
|
|
954
|
-
alpha: e.a / 100
|
|
955
|
-
}, n = Je(t);
|
|
956
|
-
return n ? bn(n) : { l: 0, c: 0, h: 0, a: e.a };
|
|
957
|
-
}
|
|
958
|
-
function Un(e) {
|
|
959
|
-
const t = Y(e), n = pn(t, "oklch", "rgb");
|
|
960
|
-
return n ? {
|
|
961
|
-
l: (n.l ?? e.l / 100) * 100,
|
|
962
|
-
c: n.c ?? 0,
|
|
963
|
-
h: n.h ?? e.h,
|
|
964
|
-
a: e.a
|
|
965
|
-
} : { l: e.l, c: 0, h: e.h, a: e.a };
|
|
966
|
-
}
|
|
967
|
-
function Qn(e) {
|
|
968
|
-
const t = We(Y(e));
|
|
969
|
-
return t ? mn(t) : !1;
|
|
970
|
-
}
|
|
971
|
-
function yn(e, t) {
|
|
972
|
-
const n = parseFloat(e);
|
|
973
|
-
let r;
|
|
974
|
-
switch (t.toLowerCase()) {
|
|
975
|
-
case "rad":
|
|
976
|
-
r = n * (180 / Math.PI);
|
|
977
|
-
break;
|
|
978
|
-
case "grad":
|
|
979
|
-
r = n * (360 / 400);
|
|
980
|
-
break;
|
|
981
|
-
case "turn":
|
|
982
|
-
r = n * 360;
|
|
983
|
-
break;
|
|
984
|
-
default:
|
|
985
|
-
r = n;
|
|
986
|
-
}
|
|
987
|
-
return (r % 360 + 360) % 360;
|
|
988
|
-
}
|
|
989
|
-
function fe(e) {
|
|
990
|
-
const n = e.trim().match(/^oklch\(\s*(.*?)\s*\)$/i);
|
|
991
|
-
if (!n) return null;
|
|
992
|
-
const i = n[1].split("/");
|
|
993
|
-
if (i.length > 2) return null;
|
|
994
|
-
const a = i[0].trim(), o = i.length === 2 ? i[1].trim() : null, s = a.split(/\s+/).filter(Boolean);
|
|
995
|
-
if (s.length !== 3) return null;
|
|
996
|
-
const f = (m) => {
|
|
997
|
-
if (m.toLowerCase() === "none") return { value: 0, isPercent: !1 };
|
|
998
|
-
const C = m.match(/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(%?)$/i);
|
|
999
|
-
if (!C) return null;
|
|
1000
|
-
const R = parseFloat(C[1]);
|
|
1001
|
-
return isNaN(R) ? null : { value: R, isPercent: C[2] === "%" };
|
|
1002
|
-
}, c = f(s[0]);
|
|
1003
|
-
if (!c) return null;
|
|
1004
|
-
const d = c.isPercent ? c.value : c.value * 100, h = f(s[1]);
|
|
1005
|
-
if (!h) return null;
|
|
1006
|
-
const p = h.isPercent ? h.value / 100 * 0.4 : h.value, y = s[2];
|
|
1007
|
-
let v;
|
|
1008
|
-
if (y.toLowerCase() === "none")
|
|
1009
|
-
v = 0;
|
|
1010
|
-
else {
|
|
1011
|
-
const m = y.match(/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(deg|rad|grad|turn)?$/i);
|
|
1012
|
-
if (!m) return null;
|
|
1013
|
-
const C = m[1], R = m[2] ?? "deg";
|
|
1014
|
-
v = yn(C, R);
|
|
1015
|
-
}
|
|
1016
|
-
let P = 100;
|
|
1017
|
-
if (o !== null) {
|
|
1018
|
-
const m = f(o.trim());
|
|
1019
|
-
if (!m) return null;
|
|
1020
|
-
P = m.isPercent ? m.value : m.value * 100;
|
|
1021
|
-
}
|
|
1022
|
-
return {
|
|
1023
|
-
l: d,
|
|
1024
|
-
c: p,
|
|
1025
|
-
h: v,
|
|
1026
|
-
a: P
|
|
1027
|
-
};
|
|
1028
|
-
}
|
|
1029
|
-
function Xe(e = g()) {
|
|
1030
|
-
return lt(e);
|
|
1031
|
-
}
|
|
1032
|
-
function Ye(e = g()) {
|
|
1033
|
-
return st(e);
|
|
1034
|
-
}
|
|
1035
|
-
function ye(e = g()) {
|
|
1036
|
-
return at(e);
|
|
1037
|
-
}
|
|
1038
|
-
function er(e = g()) {
|
|
1039
|
-
return ft(e);
|
|
1040
|
-
}
|
|
1041
|
-
function Ze(e = g()) {
|
|
1042
|
-
return ct(e);
|
|
1043
|
-
}
|
|
1044
|
-
function Ue(e = g()) {
|
|
1045
|
-
return ut(e);
|
|
1046
|
-
}
|
|
1047
|
-
function Qe(e = g()) {
|
|
1048
|
-
return dt(e);
|
|
1049
|
-
}
|
|
1050
|
-
const xn = { top: 60, left: 20 };
|
|
1051
|
-
function Mn() {
|
|
1052
|
-
if (typeof window > "u") return xn;
|
|
1053
|
-
const e = Math.min(1200, 0.8 * window.innerWidth), t = Math.min(800, 0.8 * window.innerHeight), n = Math.max(0, Math.round((window.innerHeight - t) / 2)), r = Math.max(0, Math.round((window.innerWidth - e) / 2));
|
|
1054
|
-
return { top: n, left: r };
|
|
1055
|
-
}
|
|
1056
|
-
function tr(e) {
|
|
1057
|
-
try {
|
|
1058
|
-
const t = localStorage.getItem(Ze(e));
|
|
1059
|
-
if (t) {
|
|
1060
|
-
const n = JSON.parse(t);
|
|
1061
|
-
if (typeof n.top == "number" && typeof n.left == "number" && Number.isFinite(n.top) && Number.isFinite(n.left))
|
|
1062
|
-
return n;
|
|
1063
|
-
}
|
|
1064
|
-
} catch {
|
|
1065
|
-
}
|
|
1066
|
-
return Mn();
|
|
1067
|
-
}
|
|
1068
|
-
function nr(e, t) {
|
|
1069
|
-
try {
|
|
1070
|
-
localStorage.setItem(Ze(t), JSON.stringify(e));
|
|
1071
|
-
} catch {
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
const ne = 60, ve = 320, ke = 240, Se = 1600, we = 1200, vn = { width: 1024 * 0.8, height: 768 * 0.8 };
|
|
1075
|
-
function kn() {
|
|
1076
|
-
return typeof window > "u" ? vn : et(
|
|
1077
|
-
Math.min(1200, 0.8 * window.innerWidth),
|
|
1078
|
-
Math.min(800, 0.8 * window.innerHeight)
|
|
1079
|
-
);
|
|
1080
|
-
}
|
|
1081
|
-
const $e = 32;
|
|
1082
|
-
function et(e, t) {
|
|
1083
|
-
const n = typeof window < "u" ? window.innerWidth : Se, r = typeof window < "u" ? window.innerHeight : we, i = Math.max(ve, Math.min(Se, n - $e)), a = Math.max(ke, Math.min(we, r - $e));
|
|
1084
|
-
return {
|
|
1085
|
-
width: Math.max(ve, Math.min(e, i)),
|
|
1086
|
-
height: Math.max(ke, Math.min(t, a))
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
function rr(e) {
|
|
1090
|
-
try {
|
|
1091
|
-
const t = localStorage.getItem(Ue(e));
|
|
1092
|
-
if (t) {
|
|
1093
|
-
const n = JSON.parse(t);
|
|
1094
|
-
if (typeof n.width == "number" && typeof n.height == "number" && Number.isFinite(n.width) && Number.isFinite(n.height))
|
|
1095
|
-
return et(n.width, n.height);
|
|
1096
|
-
}
|
|
1097
|
-
} catch {
|
|
1098
|
-
}
|
|
1099
|
-
return kn();
|
|
1100
|
-
}
|
|
1101
|
-
function ir(e, t) {
|
|
1102
|
-
try {
|
|
1103
|
-
localStorage.setItem(Ue(t), JSON.stringify(e));
|
|
1104
|
-
} catch {
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
const Sn = 1;
|
|
1108
|
-
function or(e) {
|
|
1109
|
-
return e === 0 ? "192px" : e === 2 ? "100%" : "288px";
|
|
1110
|
-
}
|
|
1111
|
-
function ar(e) {
|
|
1112
|
-
try {
|
|
1113
|
-
const t = localStorage.getItem(Qe(e));
|
|
1114
|
-
if (t === "0" || t === "1" || t === "2")
|
|
1115
|
-
return Number(t);
|
|
1116
|
-
} catch {
|
|
1117
|
-
}
|
|
1118
|
-
return Sn;
|
|
1119
|
-
}
|
|
1120
|
-
function sr(e, t) {
|
|
1121
|
-
try {
|
|
1122
|
-
localStorage.setItem(Qe(t), String(e));
|
|
1123
|
-
} catch {
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
function fr(e, t, n, r) {
|
|
1127
|
-
const i = -(n - ne), a = window.innerWidth - ne, o = -30, s = window.innerHeight - ne, f = Math.max(s, o), c = Math.max(a, i);
|
|
1128
|
-
return {
|
|
1129
|
-
top: Math.max(o, Math.min(e, f)),
|
|
1130
|
-
left: Math.max(i, Math.min(t, c))
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
async function lr(e) {
|
|
1134
|
-
}
|
|
1135
|
-
function wn(e) {
|
|
1136
|
-
return typeof e == "number" || e === "bg" || e === "fg";
|
|
1137
|
-
}
|
|
1138
|
-
function le(e) {
|
|
1139
|
-
return typeof e == "object" && e !== null && "literal" in e;
|
|
1140
|
-
}
|
|
1141
|
-
function ue(e) {
|
|
1142
|
-
return le(e) && typeof e.literal == "object" && e.literal !== null;
|
|
1143
|
-
}
|
|
1144
|
-
function $n(e) {
|
|
1145
|
-
return typeof e == "object" && e !== null && "ref" in e;
|
|
1146
|
-
}
|
|
1147
|
-
function re() {
|
|
1148
|
-
return {};
|
|
1149
|
-
}
|
|
1150
|
-
const Nn = {
|
|
1151
|
-
id: "stub",
|
|
1152
|
-
label: "STUB",
|
|
1153
|
-
paletteSize: 0,
|
|
1154
|
-
baseRoles: {},
|
|
1155
|
-
paletteCssVarTemplate: "--zudo-stub-p{n}",
|
|
1156
|
-
semanticDefaults: {},
|
|
1157
|
-
semanticCssNames: {},
|
|
1158
|
-
baseDefaults: {},
|
|
1159
|
-
defaultShikiTheme: "dracula",
|
|
1160
|
-
colorSchemes: {},
|
|
1161
|
-
panelSettings: { colorScheme: "", colorMode: !1 }
|
|
1162
|
-
};
|
|
1163
|
-
function $(e = g()) {
|
|
1164
|
-
return ot(e.tabs) ?? Nn;
|
|
1165
|
-
}
|
|
1166
|
-
function Z(e) {
|
|
1167
|
-
const t = e.paletteSize;
|
|
1168
|
-
return {
|
|
1169
|
-
palette: Array.from({ length: t }, (r, i) => {
|
|
1170
|
-
if (t === 1) return "#808080";
|
|
1171
|
-
const o = Math.round(i / (t - 1) * 255).toString(16).padStart(2, "0");
|
|
1172
|
-
return `#${o}${o}${o}`;
|
|
1173
|
-
}),
|
|
1174
|
-
background: e.baseDefaults.background ?? 0,
|
|
1175
|
-
foreground: e.baseDefaults.foreground ?? 0,
|
|
1176
|
-
cursor: e.baseDefaults.cursor ?? 0,
|
|
1177
|
-
selectionBg: e.baseDefaults.selectionBg ?? 0,
|
|
1178
|
-
selectionFg: e.baseDefaults.selectionFg ?? 0,
|
|
1179
|
-
semanticMappings: { ...e.semanticDefaults },
|
|
1180
|
-
shikiTheme: e.defaultShikiTheme
|
|
1181
|
-
};
|
|
1182
|
-
}
|
|
1183
|
-
function ur(e) {
|
|
1184
|
-
const t = W(e);
|
|
1185
|
-
return t ? Z(t) : void 0;
|
|
1186
|
-
}
|
|
1187
|
-
function Tn() {
|
|
1188
|
-
try {
|
|
1189
|
-
const e = document.createElement("canvas").getContext("2d");
|
|
1190
|
-
return e ? (e.fillStyle = "#ffffff", e.fillStyle === "#ffffff") : !1;
|
|
1191
|
-
} catch {
|
|
1192
|
-
return !1;
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
const In = Tn();
|
|
1196
|
-
function On(e) {
|
|
1197
|
-
const t = e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?/);
|
|
1198
|
-
if (!t) return null;
|
|
1199
|
-
const n = parseInt(t[1], 10), r = parseInt(t[2], 10), i = parseInt(t[3], 10), a = `#${(1 << 24 | n << 16 | r << 8 | i).toString(16).slice(1)}`;
|
|
1200
|
-
if (t[4] !== void 0) {
|
|
1201
|
-
const o = parseFloat(t[4]);
|
|
1202
|
-
if (o < 1) {
|
|
1203
|
-
const s = Math.round(o * 255).toString(16).padStart(2, "0");
|
|
1204
|
-
return `${a}${s}`;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
return a;
|
|
1208
|
-
}
|
|
1209
|
-
function Pn(e, t, n, r) {
|
|
1210
|
-
const i = (o) => o.toString(16).padStart(2, "0"), a = `#${i(e)}${i(t)}${i(n)}`;
|
|
1211
|
-
return r < 255 ? `${a}${i(r)}` : a;
|
|
1212
|
-
}
|
|
1213
|
-
let k = null;
|
|
1214
|
-
function ce(e) {
|
|
1215
|
-
if (!e || e === "initial" || e === "inherit") return "#000000";
|
|
1216
|
-
const t = e.trim();
|
|
1217
|
-
if (/^#[0-9a-fA-F]{6}$/.test(t) || /^#[0-9a-fA-F]{8}$/.test(t)) return t;
|
|
1218
|
-
if (/^#[0-9a-fA-F]{3}$/.test(t))
|
|
1219
|
-
return `#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`;
|
|
1220
|
-
if (/^#[0-9a-fA-F]{4}$/.test(t))
|
|
1221
|
-
return `#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}${t[4]}${t[4]}`;
|
|
1222
|
-
const n = On(t);
|
|
1223
|
-
if (n) return n;
|
|
1224
|
-
if (!In) return "#000000";
|
|
1225
|
-
try {
|
|
1226
|
-
if (k || (k = document.createElement("canvas").getContext("2d")), !k) return "#000000";
|
|
1227
|
-
k.fillStyle = "#000000", k.fillStyle = t, k.clearRect(0, 0, 1, 1), k.fillRect(0, 0, 1, 1);
|
|
1228
|
-
const [r, i, a, o] = k.getImageData(0, 0, 1, 1).data;
|
|
1229
|
-
return Pn(r, i, a, o);
|
|
1230
|
-
} catch {
|
|
1231
|
-
return "#000000";
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
function A(e, t) {
|
|
1235
|
-
document.documentElement.style.setProperty(e, t);
|
|
1236
|
-
}
|
|
1237
|
-
function Cn(e, t) {
|
|
1238
|
-
let n = Math.abs(e.h - t.h) % 360;
|
|
1239
|
-
return n > 180 && (n = 360 - n), Math.abs(e.l - t.l) <= 1e-3 && Math.abs(e.c - t.c) <= 1e-5 && n <= 1e-3 && Math.abs(e.a - t.a) <= 1e-3;
|
|
1240
|
-
}
|
|
1241
|
-
function T(e, t, n) {
|
|
1242
|
-
if (e === void 0) return n;
|
|
1243
|
-
if (typeof e == "number") return e;
|
|
1244
|
-
const r = t.indexOf(e);
|
|
1245
|
-
if (r >= 0) return r;
|
|
1246
|
-
const i = fe(e);
|
|
1247
|
-
if (i)
|
|
1248
|
-
for (let h = 0; h < t.length; h++) {
|
|
1249
|
-
const p = fe(t[h]);
|
|
1250
|
-
if (p && Cn(i, p)) return h;
|
|
1251
|
-
}
|
|
1252
|
-
const a = ce(e), o = t.map((h) => ce(h)), s = o.indexOf(a);
|
|
1253
|
-
if (s >= 0) return s;
|
|
1254
|
-
const f = Ne(a);
|
|
1255
|
-
let c = n, d = 1 / 0;
|
|
1256
|
-
for (let h = 0; h < o.length; h++) {
|
|
1257
|
-
const p = Ne(o[h]), y = (f.r - p.r) ** 2 + (f.g - p.g) ** 2 + (f.b - p.b) ** 2;
|
|
1258
|
-
y < d && (d = y, c = h);
|
|
1259
|
-
}
|
|
1260
|
-
return c;
|
|
1261
|
-
}
|
|
1262
|
-
function Ne(e) {
|
|
1263
|
-
const t = e.replace("#", "");
|
|
1264
|
-
return {
|
|
1265
|
-
r: parseInt(t.substring(0, 2), 16) || 0,
|
|
1266
|
-
g: parseInt(t.substring(2, 4), 16) || 0,
|
|
1267
|
-
b: parseInt(t.substring(4, 6), 16) || 0,
|
|
1268
|
-
aa: t.length >= 8 ? parseInt(t.substring(6, 8), 16) || 0 : 255
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
function _n(e = $(), t) {
|
|
1272
|
-
const n = e.panelSettings, r = t !== void 0 && t.applySink !== void 0;
|
|
1273
|
-
if (n.colorMode && !r) {
|
|
1274
|
-
const i = document.documentElement.getAttribute("data-theme");
|
|
1275
|
-
if (i === "light") return n.colorMode.lightScheme;
|
|
1276
|
-
if (i === "dark") return n.colorMode.darkScheme;
|
|
1277
|
-
}
|
|
1278
|
-
return n.colorScheme;
|
|
1279
|
-
}
|
|
1280
|
-
function An(e = $(), t) {
|
|
1281
|
-
const n = e.colorSchemes;
|
|
1282
|
-
if (Object.keys(n).length === 0)
|
|
1283
|
-
return Z(e);
|
|
1284
|
-
const r = _n(e, t), i = n[r] ?? Object.values(n)[0];
|
|
1285
|
-
return En(i, e);
|
|
1286
|
-
}
|
|
1287
|
-
function Hn(e) {
|
|
1288
|
-
return fe(e) ? e : ce(e);
|
|
1289
|
-
}
|
|
1290
|
-
function En(e, t = $()) {
|
|
1291
|
-
if (t.paletteSize === 0)
|
|
1292
|
-
return console.warn(
|
|
1293
|
-
`[tweak] Scheme/preset load ignored for palette-less cluster "${t.id}" (paletteSize: 0) — schemes cannot seed a tier with no palette.`
|
|
1294
|
-
), Z(t);
|
|
1295
|
-
const n = e.palette.map(Hn), r = {};
|
|
1296
|
-
for (const [i, a] of Object.entries(t.semanticDefaults)) {
|
|
1297
|
-
const o = typeof a == "number" ? a : 0, s = e.semantic?.[i];
|
|
1298
|
-
s === void 0 ? r[i] = o : typeof s == "number" ? r[i] = s : r[i] = T(s, e.palette, o);
|
|
1299
|
-
}
|
|
1300
|
-
return {
|
|
1301
|
-
palette: n,
|
|
1302
|
-
background: T(
|
|
1303
|
-
e.background,
|
|
1304
|
-
e.palette,
|
|
1305
|
-
t.baseDefaults.background ?? 0
|
|
1306
|
-
),
|
|
1307
|
-
foreground: T(
|
|
1308
|
-
e.foreground,
|
|
1309
|
-
e.palette,
|
|
1310
|
-
t.baseDefaults.foreground ?? 0
|
|
1311
|
-
),
|
|
1312
|
-
cursor: T(e.cursor, e.palette, t.baseDefaults.cursor ?? 0),
|
|
1313
|
-
selectionBg: T(
|
|
1314
|
-
e.selectionBg,
|
|
1315
|
-
e.palette,
|
|
1316
|
-
t.baseDefaults.selectionBg ?? 0
|
|
1317
|
-
),
|
|
1318
|
-
selectionFg: T(
|
|
1319
|
-
e.selectionFg,
|
|
1320
|
-
e.palette,
|
|
1321
|
-
t.baseDefaults.selectionFg ?? 0
|
|
1322
|
-
),
|
|
1323
|
-
semanticMappings: r,
|
|
1324
|
-
shikiTheme: String(e.shikiTheme ?? t.defaultShikiTheme)
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
function Rn(e, t, n, r) {
|
|
1328
|
-
const i = t.length;
|
|
1329
|
-
return e === "bg" ? t[E(n, i)] ?? "#000000" : e === "fg" ? t[E(r, i)] ?? "#ffffff" : t[E(e, i)] ?? "#000000";
|
|
1330
|
-
}
|
|
1331
|
-
function E(e, t) {
|
|
1332
|
-
return e >= 0 && e < t ? e : 0;
|
|
1333
|
-
}
|
|
1334
|
-
function de(e, t, n, r, i, a, o) {
|
|
1335
|
-
if (wn(e)) return Rn(e, t, n, r);
|
|
1336
|
-
if (le(e) && ue(e))
|
|
1337
|
-
return o ? e.literal[o] : `light-dark(${e.literal.light}, ${e.literal.dark})`;
|
|
1338
|
-
if (le(e) && !ue(e)) return e.literal;
|
|
1339
|
-
if ($n(e) && i)
|
|
1340
|
-
try {
|
|
1341
|
-
return `var(${ht(e.ref, i, a ?? [i])})`;
|
|
1342
|
-
} catch {
|
|
1343
|
-
return null;
|
|
1344
|
-
}
|
|
1345
|
-
return null;
|
|
1346
|
-
}
|
|
1347
|
-
function Fn(e) {
|
|
1348
|
-
const t = e.panelSettings.colorMode;
|
|
1349
|
-
return t ? t.defaultMode : "light";
|
|
1350
|
-
}
|
|
1351
|
-
function cr(e, t) {
|
|
1352
|
-
return e.literal[t];
|
|
1353
|
-
}
|
|
1354
|
-
function dr(e, t, n = $(), r, i) {
|
|
1355
|
-
return de(
|
|
1356
|
-
e,
|
|
1357
|
-
t.palette,
|
|
1358
|
-
t.background,
|
|
1359
|
-
t.foreground,
|
|
1360
|
-
r,
|
|
1361
|
-
i,
|
|
1362
|
-
Fn(n)
|
|
1363
|
-
) ?? "#000000";
|
|
1364
|
-
}
|
|
1365
|
-
const N = "color-scheme", Te = "light dark";
|
|
1366
|
-
function J(e, t) {
|
|
1367
|
-
for (const n of Object.keys(t.semanticCssNames)) {
|
|
1368
|
-
const r = e.semanticMappings[n] ?? t.semanticDefaults[n];
|
|
1369
|
-
if (r !== void 0 && ue(r)) return !0;
|
|
1370
|
-
}
|
|
1371
|
-
return !1;
|
|
1372
|
-
}
|
|
1373
|
-
function Ie(e, t = $(), n, r, i) {
|
|
1374
|
-
const a = e.palette.length;
|
|
1375
|
-
if (n) {
|
|
1376
|
-
const o = [];
|
|
1377
|
-
for (let s = 0; s < a; s++)
|
|
1378
|
-
o.push([z(t, s), e.palette[s]]);
|
|
1379
|
-
for (const [s, f] of Object.entries(t.baseRoles)) {
|
|
1380
|
-
if (typeof f != "string" || f.length === 0) continue;
|
|
1381
|
-
const c = e[s];
|
|
1382
|
-
typeof c == "number" && o.push([f, e.palette[E(c, a)]]);
|
|
1383
|
-
}
|
|
1384
|
-
for (const [s, f] of Object.entries(t.semanticCssNames)) {
|
|
1385
|
-
const c = e.semanticMappings[s] ?? t.semanticDefaults[s], d = de(
|
|
1386
|
-
c,
|
|
1387
|
-
e.palette,
|
|
1388
|
-
e.background,
|
|
1389
|
-
e.foreground,
|
|
1390
|
-
r,
|
|
1391
|
-
i
|
|
1392
|
-
);
|
|
1393
|
-
d !== null && o.push([f, d]);
|
|
1394
|
-
}
|
|
1395
|
-
J(e, t) && o.push([N, Te]);
|
|
1396
|
-
try {
|
|
1397
|
-
n.apply(o);
|
|
1398
|
-
} catch (s) {
|
|
1399
|
-
console.warn("[design-token-panel] applySink.apply threw; falling back silently.", s);
|
|
1400
|
-
}
|
|
1401
|
-
return;
|
|
1402
|
-
}
|
|
1403
|
-
for (let o = 0; o < a; o++)
|
|
1404
|
-
A(z(t, o), e.palette[o]);
|
|
1405
|
-
for (const [o, s] of Object.entries(t.baseRoles)) {
|
|
1406
|
-
if (typeof s != "string" || s.length === 0) continue;
|
|
1407
|
-
const f = e[o];
|
|
1408
|
-
typeof f == "number" && A(s, e.palette[E(f, a)]);
|
|
1409
|
-
}
|
|
1410
|
-
for (const [o, s] of Object.entries(t.semanticCssNames)) {
|
|
1411
|
-
const f = e.semanticMappings[o] ?? t.semanticDefaults[o], c = de(
|
|
1412
|
-
f,
|
|
1413
|
-
e.palette,
|
|
1414
|
-
e.background,
|
|
1415
|
-
e.foreground,
|
|
1416
|
-
r,
|
|
1417
|
-
i
|
|
1418
|
-
);
|
|
1419
|
-
c !== null && A(s, c);
|
|
1420
|
-
}
|
|
1421
|
-
J(e, t) && A(N, Te);
|
|
1422
|
-
}
|
|
1423
|
-
function hr(e, t) {
|
|
1424
|
-
const n = t ?? g(), r = n.applySink, i = n.tabs.find((f) => f.id === "color"), a = $(n);
|
|
1425
|
-
Ie(e.color, a, r, i, n.tabs), D(n.tabs, "spacing", e.spacing, r), D(n.tabs, "font", e.typography, r), D(n.tabs, "size", e.size, r);
|
|
1426
|
-
const o = W(n);
|
|
1427
|
-
let s = !1;
|
|
1428
|
-
if (o && e.secondary) {
|
|
1429
|
-
const f = n.tabs.find((c) => c.id === "color-secondary");
|
|
1430
|
-
Ie(e.secondary, o, r, f, n.tabs), s = J(e.secondary, o);
|
|
1431
|
-
}
|
|
1432
|
-
if (!J(e.color, a) && !s)
|
|
1433
|
-
if (r)
|
|
1434
|
-
try {
|
|
1435
|
-
r.clear([N]);
|
|
1436
|
-
} catch (f) {
|
|
1437
|
-
console.warn("[design-token-panel] applySink.clear threw; falling back silently.", f);
|
|
1438
|
-
}
|
|
1439
|
-
else
|
|
1440
|
-
document.documentElement.style.removeProperty(N);
|
|
1441
|
-
if (e.tabs)
|
|
1442
|
-
for (const [f, c] of Object.entries(e.tabs)) {
|
|
1443
|
-
const d = {};
|
|
1444
|
-
for (const h of Object.values(c))
|
|
1445
|
-
for (const [p, y] of Object.entries(h))
|
|
1446
|
-
d[p] = y;
|
|
1447
|
-
D(n.tabs, f, d, r);
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
function D(e, t, n, r) {
|
|
1451
|
-
const i = e.find((s) => s.id === t);
|
|
1452
|
-
if (!i) return;
|
|
1453
|
-
const a = {};
|
|
1454
|
-
for (const s of i.tiers) {
|
|
1455
|
-
const f = {};
|
|
1456
|
-
for (const c of s.items) {
|
|
1457
|
-
const d = n[c.id];
|
|
1458
|
-
typeof d == "string" && d.length > 0 && (f[c.id] = d);
|
|
1459
|
-
}
|
|
1460
|
-
a[s.id] = f;
|
|
1461
|
-
}
|
|
1462
|
-
if (r) {
|
|
1463
|
-
const s = [], f = [];
|
|
1464
|
-
for (const c of i.tiers)
|
|
1465
|
-
for (const d of c.items)
|
|
1466
|
-
if (!d.readonly)
|
|
1467
|
-
try {
|
|
1468
|
-
const h = xe(i, c.id, d.id, a), p = Me(h);
|
|
1469
|
-
typeof n[d.id] == "string" && n[d.id].length > 0 || c.referencesTier !== void 0 ? s.push([d.cssVar, p]) : f.push(d.cssVar);
|
|
1470
|
-
} catch {
|
|
1471
|
-
f.push(d.cssVar);
|
|
1472
|
-
}
|
|
1473
|
-
if (s.length > 0)
|
|
1474
|
-
try {
|
|
1475
|
-
r.apply(s);
|
|
1476
|
-
} catch (c) {
|
|
1477
|
-
console.warn("[design-token-panel] applySink.apply threw; falling back silently.", c);
|
|
1478
|
-
}
|
|
1479
|
-
if (f.length > 0)
|
|
1480
|
-
try {
|
|
1481
|
-
r.clear(f);
|
|
1482
|
-
} catch (c) {
|
|
1483
|
-
console.warn("[design-token-panel] applySink.clear threw; falling back silently.", c);
|
|
1484
|
-
}
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
const o = document.documentElement;
|
|
1488
|
-
for (const s of i.tiers)
|
|
1489
|
-
for (const f of s.items)
|
|
1490
|
-
if (!f.readonly)
|
|
1491
|
-
try {
|
|
1492
|
-
const c = xe(i, s.id, f.id, a), d = Me(c);
|
|
1493
|
-
typeof n[f.id] == "string" && n[f.id].length > 0 || s.referencesTier !== void 0 ? A(f.cssVar, d) : o.style.removeProperty(f.cssVar);
|
|
1494
|
-
} catch {
|
|
1495
|
-
o.style.removeProperty(f.cssVar);
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
function tt(e) {
|
|
1499
|
-
const t = e ?? g(), n = $(t), r = W(t);
|
|
1500
|
-
return r ? [n, r] : [n];
|
|
1501
|
-
}
|
|
1502
|
-
function nt(e) {
|
|
1503
|
-
const t = [];
|
|
1504
|
-
for (let n = 0; n < e.paletteSize; n++)
|
|
1505
|
-
t.push(z(e, n));
|
|
1506
|
-
for (const n of Object.values(e.baseRoles))
|
|
1507
|
-
typeof n == "string" && n.length > 0 && t.push(n);
|
|
1508
|
-
for (const n of Object.values(e.semanticCssNames))
|
|
1509
|
-
t.push(n);
|
|
1510
|
-
return t;
|
|
1511
|
-
}
|
|
1512
|
-
function Vn(e) {
|
|
1513
|
-
const t = [];
|
|
1514
|
-
for (const n of e.tabs)
|
|
1515
|
-
if (!(n.id === "color" || n.id === "color-secondary"))
|
|
1516
|
-
for (const r of n.tiers)
|
|
1517
|
-
for (const i of r.items)
|
|
1518
|
-
i.readonly || t.push(i.cssVar);
|
|
1519
|
-
return t;
|
|
1520
|
-
}
|
|
1521
|
-
function Dn(e, t, n) {
|
|
1522
|
-
const r = e ?? tt(n), i = n?.applySink;
|
|
1523
|
-
return Ln(r, i);
|
|
1524
|
-
}
|
|
1525
|
-
function Ln(e, t) {
|
|
1526
|
-
if (t) {
|
|
1527
|
-
const r = [];
|
|
1528
|
-
for (const i of e)
|
|
1529
|
-
r.push(...nt(i));
|
|
1530
|
-
if (e.length > 0 && r.push(N), r.length > 0)
|
|
1531
|
-
try {
|
|
1532
|
-
t.clear(r);
|
|
1533
|
-
} catch (i) {
|
|
1534
|
-
console.warn("[design-token-panel] applySink.clear threw; falling back silently.", i);
|
|
1535
|
-
}
|
|
1536
|
-
return;
|
|
1537
|
-
}
|
|
1538
|
-
const n = document.documentElement;
|
|
1539
|
-
for (const r of e) {
|
|
1540
|
-
for (let i = 0; i < r.paletteSize; i++)
|
|
1541
|
-
n.style.removeProperty(z(r, i));
|
|
1542
|
-
for (const i of Object.values(r.baseRoles))
|
|
1543
|
-
n.style.removeProperty(i);
|
|
1544
|
-
for (const i of Object.values(r.semanticCssNames))
|
|
1545
|
-
n.style.removeProperty(i);
|
|
1546
|
-
}
|
|
1547
|
-
e.length > 0 && n.style.removeProperty(N);
|
|
1548
|
-
}
|
|
1549
|
-
function pr(e, t) {
|
|
1550
|
-
const n = t ?? g(), r = n.applySink, i = tt(n);
|
|
1551
|
-
if (r) {
|
|
1552
|
-
const o = [];
|
|
1553
|
-
for (const s of i)
|
|
1554
|
-
o.push(...nt(s));
|
|
1555
|
-
if (i.length > 0 && o.push(N), o.push(...Vn(n)), o.length > 0)
|
|
1556
|
-
try {
|
|
1557
|
-
r.clear(o);
|
|
1558
|
-
} catch (s) {
|
|
1559
|
-
console.warn("[design-token-panel] applySink.clear threw; falling back silently.", s);
|
|
1560
|
-
}
|
|
1561
|
-
return;
|
|
1562
|
-
}
|
|
1563
|
-
Dn(i);
|
|
1564
|
-
const a = document.documentElement;
|
|
1565
|
-
for (const o of n.tabs)
|
|
1566
|
-
if (!(o.id === "color" || o.id === "color-secondary"))
|
|
1567
|
-
for (const s of o.tiers)
|
|
1568
|
-
for (const f of s.items)
|
|
1569
|
-
f.readonly || a.style.removeProperty(f.cssVar);
|
|
1570
|
-
}
|
|
1571
|
-
function rt(e, t) {
|
|
1572
|
-
if (!e || typeof e != "object") return !1;
|
|
1573
|
-
const n = e;
|
|
1574
|
-
return Array.isArray(n.palette) && n.palette.length === t && typeof n.background == "number" && typeof n.foreground == "number" && typeof n.cursor == "number" && typeof n.selectionBg == "number" && typeof n.selectionFg == "number" && typeof n.semanticMappings == "object" && n.semanticMappings !== null;
|
|
1575
|
-
}
|
|
1576
|
-
function zn(e) {
|
|
1577
|
-
if (typeof e == "number" || e === "bg" || e === "fg") return e;
|
|
1578
|
-
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
1579
|
-
const t = e;
|
|
1580
|
-
if ("literal" in t) {
|
|
1581
|
-
const n = t.literal;
|
|
1582
|
-
if (typeof n == "string") return { literal: n };
|
|
1583
|
-
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
1584
|
-
const r = n;
|
|
1585
|
-
if (typeof r.light == "string" && typeof r.dark == "string")
|
|
1586
|
-
return { literal: { light: r.light, dark: r.dark } };
|
|
1587
|
-
}
|
|
1588
|
-
return;
|
|
1589
|
-
}
|
|
1590
|
-
if ("ref" in t) {
|
|
1591
|
-
const n = t.ref;
|
|
1592
|
-
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
1593
|
-
const r = n;
|
|
1594
|
-
if (typeof r.tier == "string" && typeof r.item == "string")
|
|
1595
|
-
return {
|
|
1596
|
-
ref: {
|
|
1597
|
-
tier: r.tier,
|
|
1598
|
-
item: r.item,
|
|
1599
|
-
...typeof r.tab == "string" ? { tab: r.tab } : {}
|
|
1600
|
-
}
|
|
1601
|
-
};
|
|
1602
|
-
}
|
|
1603
|
-
return;
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
function jn(e, t) {
|
|
1607
|
-
if (!e || typeof e != "object" || Array.isArray(e)) return { ...t };
|
|
1608
|
-
const n = { ...t };
|
|
1609
|
-
for (const [r, i] of Object.entries(e)) {
|
|
1610
|
-
const a = zn(i);
|
|
1611
|
-
a !== void 0 && (n[r] = a);
|
|
1612
|
-
}
|
|
1613
|
-
return n;
|
|
1614
|
-
}
|
|
1615
|
-
function he(e, t) {
|
|
1616
|
-
const n = Array.isArray(e.palette) ? e.palette : null;
|
|
1617
|
-
let r;
|
|
1618
|
-
return n && n.length === t.palette.length && n.every((i) => typeof i == "string") ? r = n : (n && n.some((i) => typeof i != "string") && console.error(
|
|
1619
|
-
"[design-token-panel] Persisted palette contained non-string elements; falling back to defaults."
|
|
1620
|
-
), r = t.palette), {
|
|
1621
|
-
palette: r,
|
|
1622
|
-
background: typeof e.background == "number" ? e.background : t.background,
|
|
1623
|
-
foreground: typeof e.foreground == "number" ? e.foreground : t.foreground,
|
|
1624
|
-
cursor: typeof e.cursor == "number" ? e.cursor : t.cursor,
|
|
1625
|
-
selectionBg: typeof e.selectionBg == "number" ? e.selectionBg : t.selectionBg,
|
|
1626
|
-
selectionFg: typeof e.selectionFg == "number" ? e.selectionFg : t.selectionFg,
|
|
1627
|
-
semanticMappings: jn(e.semanticMappings, t.semanticMappings),
|
|
1628
|
-
shikiTheme: typeof e.shikiTheme == "string" && e.shikiTheme.length > 0 ? e.shikiTheme : t.shikiTheme
|
|
1629
|
-
};
|
|
1630
|
-
}
|
|
1631
|
-
const gr = {
|
|
1632
|
-
"text-caption": "text-xs",
|
|
1633
|
-
"text-small": "text-sm",
|
|
1634
|
-
"text-body": "text-base",
|
|
1635
|
-
"text-subheading": "text-lg",
|
|
1636
|
-
"text-heading": "text-3xl",
|
|
1637
|
-
"text-display": "text-5xl",
|
|
1638
|
-
// Dropped — no main-site equivalent. `null` signals "discard".
|
|
1639
|
-
"text-micro": null
|
|
1640
|
-
};
|
|
1641
|
-
function Oe(e) {
|
|
1642
|
-
if (!e || typeof e != "object") return {};
|
|
1643
|
-
const t = {};
|
|
1644
|
-
for (const [n, r] of Object.entries(e))
|
|
1645
|
-
typeof r == "string" && (t[n] = r);
|
|
1646
|
-
return t;
|
|
1647
|
-
}
|
|
1648
|
-
function Kn(e, t = {}) {
|
|
1649
|
-
if (!e || typeof e != "object") return {};
|
|
1650
|
-
const n = {};
|
|
1651
|
-
for (const [r, i] of Object.entries(e))
|
|
1652
|
-
if (typeof i == "string")
|
|
1653
|
-
if (Object.hasOwn(t, r)) {
|
|
1654
|
-
const a = t[r];
|
|
1655
|
-
if (a === null) continue;
|
|
1656
|
-
Object.hasOwn(n, a) || (n[a] = i);
|
|
1657
|
-
} else
|
|
1658
|
-
n[r] = i;
|
|
1659
|
-
return n;
|
|
1660
|
-
}
|
|
1661
|
-
function Bn(e) {
|
|
1662
|
-
if (!e || typeof e != "object" || Array.isArray(e)) return {};
|
|
1663
|
-
const t = {};
|
|
1664
|
-
for (const [n, r] of Object.entries(e)) {
|
|
1665
|
-
if (!r || typeof r != "object" || Array.isArray(r)) continue;
|
|
1666
|
-
const i = {};
|
|
1667
|
-
for (const [a, o] of Object.entries(r)) {
|
|
1668
|
-
if (!o || typeof o != "object" || Array.isArray(o)) continue;
|
|
1669
|
-
const s = {};
|
|
1670
|
-
for (const [f, c] of Object.entries(o))
|
|
1671
|
-
typeof c == "string" && (s[f] = c);
|
|
1672
|
-
i[a] = s;
|
|
1673
|
-
}
|
|
1674
|
-
t[n] = i;
|
|
1675
|
-
}
|
|
1676
|
-
return t;
|
|
1677
|
-
}
|
|
1678
|
-
function Pe(e, t, n, r = g()) {
|
|
1679
|
-
if (!e.color || typeof e.color != "object") return null;
|
|
1680
|
-
const i = n ?? it(t, r), a = e.typography !== void 0 ? e.typography : e.font, o = r.legacyIdRenameMap ?? {}, s = {
|
|
1681
|
-
color: he(e.color, i),
|
|
1682
|
-
// New sections added after v1 migration — tolerate their absence so
|
|
1683
|
-
// older v2 payloads (Color-only) still load cleanly.
|
|
1684
|
-
spacing: Oe(e.spacing),
|
|
1685
|
-
// Typography slice: apply the host-configured rename map (if any)
|
|
1686
|
-
// so payloads persisted under the host's "old" ids survive a
|
|
1687
|
-
// host-driven id rename without losing the user's tweaks.
|
|
1688
|
-
typography: Kn(a, o),
|
|
1689
|
-
size: Oe(e.size)
|
|
1690
|
-
}, f = W(r);
|
|
1691
|
-
f && e.secondary && rt(e.secondary, f.paletteSize) && (s.secondary = he(
|
|
1692
|
-
e.secondary,
|
|
1693
|
-
Z(f)
|
|
1694
|
-
));
|
|
1695
|
-
const c = Bn(e.tabs);
|
|
1696
|
-
return Object.keys(c).length > 0 && (s.tabs = c), s;
|
|
1697
|
-
}
|
|
1698
|
-
function mr(e = localStorage, t, n = $(), r = g()) {
|
|
1699
|
-
const i = Xe(r), a = Ye(r), o = ye(r), s = ie(e, o);
|
|
1700
|
-
if (s !== null) {
|
|
1701
|
-
const d = oe(s);
|
|
1702
|
-
if (d && typeof d == "object") {
|
|
1703
|
-
const h = d, p = Pe(h, n, t, r);
|
|
1704
|
-
if (p !== null) {
|
|
1705
|
-
const y = h.typography !== void 0 ? h.typography : h.font, v = JSON.stringify(y ?? {}) !== JSON.stringify(p.typography), P = h.color, m = Array.isArray(P?.palette) && P.palette.length !== n.paletteSize;
|
|
1706
|
-
if (v || h.typography === void 0 || m)
|
|
1707
|
-
try {
|
|
1708
|
-
e.setItem(o, JSON.stringify(p));
|
|
1709
|
-
} catch {
|
|
1710
|
-
}
|
|
1711
|
-
return p;
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
console.warn(`[tweak] Malformed ${o}, attempting v2 migration`);
|
|
1715
|
-
}
|
|
1716
|
-
const f = ie(e, a);
|
|
1717
|
-
if (f !== null) {
|
|
1718
|
-
const d = oe(f);
|
|
1719
|
-
if (d && typeof d == "object") {
|
|
1720
|
-
const p = Pe(d, n, t, r);
|
|
1721
|
-
if (p !== null) {
|
|
1722
|
-
try {
|
|
1723
|
-
e.setItem(o, JSON.stringify(p)), e.removeItem(a);
|
|
1724
|
-
} catch {
|
|
1725
|
-
}
|
|
1726
|
-
return p;
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
console.warn(`[tweak] Malformed ${a}, attempting v1 migration`);
|
|
1730
|
-
}
|
|
1731
|
-
const c = ie(e, i);
|
|
1732
|
-
if (c !== null) {
|
|
1733
|
-
const d = oe(c);
|
|
1734
|
-
if (d && typeof d == "object" && rt(d, n.paletteSize)) {
|
|
1735
|
-
const h = t ?? it(n, r), p = d;
|
|
1736
|
-
p.shikiTheme || (p.shikiTheme = h.shikiTheme);
|
|
1737
|
-
const v = {
|
|
1738
|
-
color: he(p, h),
|
|
1739
|
-
spacing: re(),
|
|
1740
|
-
typography: re(),
|
|
1741
|
-
size: re()
|
|
1742
|
-
};
|
|
1743
|
-
try {
|
|
1744
|
-
e.setItem(o, JSON.stringify(v)), e.removeItem(i);
|
|
1745
|
-
} catch {
|
|
1746
|
-
}
|
|
1747
|
-
return v;
|
|
1748
|
-
}
|
|
1749
|
-
console.warn(`[tweak] Malformed ${i}; discarding and using fresh defaults`);
|
|
1750
|
-
try {
|
|
1751
|
-
e.removeItem(i);
|
|
1752
|
-
} catch {
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
return null;
|
|
1756
|
-
}
|
|
1757
|
-
function br(e, t = localStorage, n = g()) {
|
|
1758
|
-
try {
|
|
1759
|
-
t.setItem(ye(n), JSON.stringify(e));
|
|
1760
|
-
} catch {
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
function yr(e = localStorage, t = g()) {
|
|
1764
|
-
try {
|
|
1765
|
-
e.removeItem(ye(t));
|
|
1766
|
-
} catch {
|
|
1767
|
-
}
|
|
1768
|
-
try {
|
|
1769
|
-
e.removeItem(Ye(t));
|
|
1770
|
-
} catch {
|
|
1771
|
-
}
|
|
1772
|
-
try {
|
|
1773
|
-
e.removeItem(Xe(t));
|
|
1774
|
-
} catch {
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
function ie(e, t) {
|
|
1778
|
-
try {
|
|
1779
|
-
return e.getItem(t);
|
|
1780
|
-
} catch {
|
|
1781
|
-
return null;
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
function oe(e) {
|
|
1785
|
-
try {
|
|
1786
|
-
return JSON.parse(e);
|
|
1787
|
-
} catch {
|
|
1788
|
-
return null;
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
function it(e, t) {
|
|
1792
|
-
try {
|
|
1793
|
-
return An(e, t);
|
|
1794
|
-
} catch {
|
|
1795
|
-
return {
|
|
1796
|
-
palette: Array.from(
|
|
1797
|
-
{ length: e.paletteSize },
|
|
1798
|
-
(r, i) => i === 0 ? "#000000" : i === e.paletteSize - 1 ? "#ffffff" : "#808080"
|
|
1799
|
-
),
|
|
1800
|
-
background: e.baseDefaults.background ?? 0,
|
|
1801
|
-
foreground: e.baseDefaults.foreground ?? 0,
|
|
1802
|
-
cursor: e.baseDefaults.cursor ?? 0,
|
|
1803
|
-
selectionBg: e.baseDefaults.selectionBg ?? 0,
|
|
1804
|
-
selectionFg: e.baseDefaults.selectionFg ?? 0,
|
|
1805
|
-
semanticMappings: { ...e.semanticDefaults },
|
|
1806
|
-
shikiTheme: e.defaultShikiTheme
|
|
1807
|
-
};
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
export {
|
|
1811
|
-
Sn as A,
|
|
1812
|
-
rr as B,
|
|
1813
|
-
tr as C,
|
|
1814
|
-
xn as D,
|
|
1815
|
-
fr as E,
|
|
1816
|
-
ar as F,
|
|
1817
|
-
sr as G,
|
|
1818
|
-
Dn as H,
|
|
1819
|
-
yr as I,
|
|
1820
|
-
pr as J,
|
|
1821
|
-
ur as K,
|
|
1822
|
-
or as L,
|
|
1823
|
-
qn as M,
|
|
1824
|
-
An as N,
|
|
1825
|
-
nr as O,
|
|
1826
|
-
ir as P,
|
|
1827
|
-
et as Q,
|
|
1828
|
-
re as R,
|
|
1829
|
-
ye as S,
|
|
1830
|
-
dr as T,
|
|
1831
|
-
gr as Z,
|
|
1832
|
-
Xe as a,
|
|
1833
|
-
Ye as b,
|
|
1834
|
-
$ as c,
|
|
1835
|
-
ue as d,
|
|
1836
|
-
le as e,
|
|
1837
|
-
$n as f,
|
|
1838
|
-
er as g,
|
|
1839
|
-
En as h,
|
|
1840
|
-
wn as i,
|
|
1841
|
-
Wn as j,
|
|
1842
|
-
Yn as k,
|
|
1843
|
-
mr as l,
|
|
1844
|
-
Un as m,
|
|
1845
|
-
Hn as n,
|
|
1846
|
-
Xn as o,
|
|
1847
|
-
Jn as p,
|
|
1848
|
-
Zn as q,
|
|
1849
|
-
Qn as r,
|
|
1850
|
-
E as s,
|
|
1851
|
-
fe as t,
|
|
1852
|
-
cr as u,
|
|
1853
|
-
Fn as v,
|
|
1854
|
-
lr as w,
|
|
1855
|
-
hr as x,
|
|
1856
|
-
br as y,
|
|
1857
|
-
kn as z
|
|
1858
|
-
};
|