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