@takazudo/zdtp 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +58 -10
  3. package/dist/apply/build-apply-overrides.d.ts +4 -2
  4. package/dist/apply/build-apply-overrides.d.ts.map +1 -1
  5. package/dist/astro/host-adapter.js +67 -44
  6. package/dist/astro/index.js +1 -1
  7. package/dist/autoload-state-DsvvPDih.js +46 -0
  8. package/dist/components/palette-chart/palette-chart.d.ts +0 -1
  9. package/dist/components/palette-chart/palette-chart.d.ts.map +1 -1
  10. package/dist/config/panel-config.d.ts +8 -0
  11. package/dist/config/panel-config.d.ts.map +1 -1
  12. package/dist/element-path/element-path-state.d.ts +3 -2
  13. package/dist/element-path/element-path-state.d.ts.map +1 -1
  14. package/dist/index.d.ts +39 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2596 -3626
  17. package/dist/{panel-config-066BPYJD.js → panel-config-DyVRQ2n1.js} +37 -33
  18. package/dist/panel.d.ts.map +1 -1
  19. package/dist/state/autoload-state.d.ts +92 -0
  20. package/dist/state/autoload-state.d.ts.map +1 -0
  21. package/dist/state/tweak-state.d.ts +18 -1
  22. package/dist/state/tweak-state.d.ts.map +1 -1
  23. package/dist/tabs/color-tab.d.ts +7 -4
  24. package/dist/tabs/color-tab.d.ts.map +1 -1
  25. package/dist/tabs/generic-tab.d.ts +1 -1
  26. package/dist/tabs/palette/palette-edit-view.d.ts +0 -1
  27. package/dist/tabs/palette/palette-edit-view.d.ts.map +1 -1
  28. package/dist/testing.js +2 -2
  29. package/dist/tweak-state-DzZVbY25.js +1779 -0
  30. package/dist/utils/design-token-serde.d.ts +2 -1
  31. package/dist/utils/design-token-serde.d.ts.map +1 -1
  32. package/dist/zdtp.css +1 -1
  33. package/package.json +1 -1
  34. package/dist/tweak-state-Do5gj6Nw.js +0 -730
@@ -0,0 +1,1779 @@
1
+ import { g, n as J, d as rt, b as it, f as at, y as ot, i as st, r as L, h as ft, z as ut, A as lt } from "./panel-config-DyVRQ2n1.js";
2
+ class N extends Error {
3
+ constructor(t) {
4
+ super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, N.prototype);
5
+ }
6
+ }
7
+ function be(e, t) {
8
+ return e.tiers.find((n) => n.id === t);
9
+ }
10
+ function E(e, t) {
11
+ return e.items.find((n) => n.id === t);
12
+ }
13
+ function ye(e, t, n, r) {
14
+ const i = be(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 = E(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 = be(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 = E(c, s ?? n);
32
+ if (!h) {
33
+ const p = E(c, a.default) ?? E(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 xe(e) {
45
+ return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
46
+ }
47
+ const Pe = (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) => Pe(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)) ? Pe(parseInt(t[1], 16), t[1].length) : void 0;
234
+ }, k = "([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)", C = `${k}%`, le = `(?:${k}%|${k})`, gt = `(?:${k}(deg|grad|rad|turn)|${k})`, O = "\\s*,\\s*", mt = new RegExp(
235
+ `^rgba?\\(\\s*${k}${O}${k}${O}${k}\\s*(?:,\\s*${le}\\s*)?\\)$`
236
+ ), bt = new RegExp(
237
+ `^rgba?\\(\\s*${C}${O}${C}${O}${C}\\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
+ }, j = (e, t) => e === void 0 ? void 0 : typeof e != "object" ? He(e) : e.mode !== void 0 ? e : t ? { ...e, mode: t } : void 0, y = (e = "rgb") => (t) => (t = j(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 = [], Ce = {}, 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)), W = (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
+ Ce[e] = t;
288
+ } else typeof e == "function" && K.indexOf(e) < 0 && K.push(e);
289
+ }, ie = /[^\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 V(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 ae(e) {
305
+ if (l >= e.length)
306
+ return !1;
307
+ let t = e[l];
308
+ if (ie.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 === "-" || ie.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 _(e) {
325
+ let t = "";
326
+ if ((e[l] === "-" || e[l] === "+") && (t += e[l++]), t += R(e), e[l] === "." && /\d/.test(e[l + 1]) && (t += e[l++] + R(e)), (e[l] === "e" || e[l] === "E") && ((e[l + 1] === "-" || e[l + 1] === "+") && /\d/.test(e[l + 2]) ? t += e[l++] + e[l++] + R(e) : /\d/.test(e[l + 1]) && (t += e[l++] + R(e))), ae(e)) {
327
+ let n = B(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 R(e) {
333
+ let t = "";
334
+ for (; /\d/.test(e[l]); )
335
+ t += e[l++];
336
+ return t;
337
+ }
338
+ function B(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 = B(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--, V(t)) {
366
+ n.push(_(t));
367
+ continue;
368
+ }
369
+ return;
370
+ }
371
+ if (r === "-") {
372
+ if (l--, V(t)) {
373
+ n.push(_(t));
374
+ continue;
375
+ }
376
+ if (ae(t)) {
377
+ n.push({ type: f.Ident, value: B(t) });
378
+ continue;
379
+ }
380
+ return;
381
+ }
382
+ if (r === ".") {
383
+ if (l--, V(t)) {
384
+ n.push(_(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 (V(t) && (i = _(t), i.type !== f.Hue)) {
395
+ n.push({ type: f.Alpha, value: i });
396
+ continue;
397
+ }
398
+ if (ae(t) && B(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(_(t));
409
+ continue;
410
+ }
411
+ if (ie.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 = Ce[t.value];
425
+ if (!n)
426
+ return;
427
+ const r = { mode: n }, i = Ae(e, !1);
428
+ if (!i)
429
+ return;
430
+ const a = W(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 Ae(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 = Ae(e, t);
465
+ if (r)
466
+ return r.unshift(n.value), r;
467
+ }
468
+ const He = (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), Pt = (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
+ }, _t = (e) => (t) => {
499
+ let n = Pt(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
+ }, m = _t(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: m,
521
+ g: m,
522
+ b: m,
523
+ alpha: { use: m, fixup: de }
524
+ },
525
+ gamut: !0,
526
+ white: { r: 1, g: 1, b: 1 },
527
+ black: { r: 0, g: 0, b: 0 }
528
+ }, Y = (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
+ }, Ee = ({ r: e, g: t, b: n, alpha: r }) => {
532
+ let i = {
533
+ mode: "lrgb",
534
+ r: Y(e),
535
+ g: Y(t),
536
+ b: Y(n)
537
+ };
538
+ return r !== void 0 && (i.alpha = r), i;
539
+ }, Z = (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
+ }, Ve = ({ r: e, g: t, b: n, alpha: r }, i = "rgb") => {
543
+ let a = {
544
+ mode: i,
545
+ r: Z(e),
546
+ g: Z(t),
547
+ b: Z(n)
548
+ };
549
+ return r !== void 0 && (a.alpha = r), a;
550
+ }, w = (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 = w(n);
554
+ return r === 0 || e[r - 1] === void 0 ? a : t(a - w(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), []), Re = (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 = w(e.h), r = w(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 = w(e.h), r = w(t.h), i = Math.sin((r - n + 360) / 2 * Math.PI / 180);
564
+ return 2 * Math.sqrt(e.c * t.c) * i;
565
+ }, Fe = (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
+ }, G = ({ 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 = w(Math.atan2(n, t) * 180 / Math.PI)), r !== void 0 && (o.alpha = r), o;
581
+ }, q = ({ 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 = w(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
+ }, Dt = new RegExp(
643
+ `^hsla?\\(\\s*${gt}${O}${C}${O}${C}\\s*(?:,\\s*${le}\\s*)?\\)$`
644
+ ), zt = (e) => {
645
+ let t = e.match(Dt);
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, zt],
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: m, fixup: Re },
694
+ s: m,
695
+ l: m,
696
+ alpha: { use: m, fixup: de }
697
+ },
698
+ difference: {
699
+ h: Ht
700
+ },
701
+ average: {
702
+ h: Fe
703
+ }
704
+ }, De = Math.pow(29, 3) / Math.pow(3, 3), ze = Math.pow(6, 3) / Math.pow(29, 3);
705
+ let U = (e) => Math.pow(e, 3) > ze ? Math.pow(e, 3) : (116 * e - 16) / De;
706
+ const Kt = ({ 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: U(a) * I.X,
711
+ y: U(i) * I.Y,
712
+ z: U(o) * I.Z
713
+ };
714
+ return r !== void 0 && (s.alpha = r), s;
715
+ }, Bt = ({ 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 = Ve({
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) => Bt(Kt(e)), qt = (e) => {
724
+ let { r: t, g: n, b: r, alpha: i } = Ee(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
+ }, Q = (e) => e > ze ? Math.cbrt(e) : (De * 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 = Q(e / I.X), a = Q(t / I.Y), o = Q(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: q,
773
+ rgb: (e) => Gt(q(e))
774
+ },
775
+ fromMode: {
776
+ rgb: (e) => G(Wt(e)),
777
+ lab: G
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: m, fixup: Re },
789
+ c: m,
790
+ l: m,
791
+ alpha: { use: m, fixup: de }
792
+ },
793
+ difference: {
794
+ h: Et
795
+ },
796
+ average: {
797
+ h: Fe
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(Ee(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) => Ve(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) => q(e, "oklab"),
860
+ rgb: (e) => en(q(e, "oklab"))
861
+ },
862
+ fromMode: {
863
+ rgb: (e) => G(Ut(e), "oklch"),
864
+ oklab: (e) => G(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), Le = y("rgb"), je = (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 je(e) + (256 | t).toString(16).slice(1);
883
+ }, on = (e) => je(Le(e)), sn = (e) => an(Le(e)), Ke = 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(Ke(e)), Ge = (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 Ge(Ke(e));
894
+ }
895
+ function he(e = "rgb") {
896
+ const { gamut: t } = W(e);
897
+ if (!t)
898
+ return (r) => !0;
899
+ const n = y(typeof t == "string" ? t : e);
900
+ return (r) => Ge(n(r));
901
+ }
902
+ function ln(e = "rgb") {
903
+ const { gamut: t } = W(e);
904
+ if (!t)
905
+ return (a) => j(a);
906
+ const n = typeof t == "string" ? t : e, r = y(n), i = he(n);
907
+ return (a) => {
908
+ const o = j(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 = j(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 = W(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 Fn = 0.37, qe = y("oklch"), Je = y("rgb"), dn = y("hsl"), hn = he("rgb");
938
+ function X(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 Dn(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 = He(e);
966
+ if (!n) return t;
967
+ const r = qe(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 Ln(e, t) {
981
+ const n = X(e), r = Je(n);
982
+ return r ? e.a < 100 ? sn({ ...r, alpha: e.a / 100 }) ?? "#000000ff" : on(r) ?? "#000000" : "#000000";
983
+ }
984
+ function jn(e) {
985
+ const t = X(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 Kn(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 = qe(t);
1001
+ return n ? pn(n) : { l: 0, c: 0, h: 0, a: e.a };
1002
+ }
1003
+ function Bn(e) {
1004
+ const t = X(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 Gn(e) {
1013
+ const t = Je(X(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 oe(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 = (b) => {
1042
+ if (b.toLowerCase() === "none") return { value: 0, isPercent: !1 };
1043
+ const P = b.match(/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(%?)$/i);
1044
+ if (!P) return null;
1045
+ const H = parseFloat(P[1]);
1046
+ return isNaN(H) ? null : { value: H, 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 S;
1053
+ if (v.toLowerCase() === "none")
1054
+ S = 0;
1055
+ else {
1056
+ const b = v.match(/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(deg|rad|grad|turn)?$/i);
1057
+ if (!b) return null;
1058
+ const P = b[1], H = b[2] ?? "deg";
1059
+ S = gn(P, H);
1060
+ }
1061
+ let me = 100;
1062
+ if (o !== null) {
1063
+ const b = u(o.trim());
1064
+ if (!b) return null;
1065
+ me = b.isPercent ? b.value : b.value * 100;
1066
+ }
1067
+ return {
1068
+ l: d,
1069
+ c: p,
1070
+ h: S,
1071
+ a: me
1072
+ };
1073
+ }
1074
+ function We(e = g()) {
1075
+ return st(e);
1076
+ }
1077
+ function Xe(e = g()) {
1078
+ return it(e);
1079
+ }
1080
+ function pe(e = g()) {
1081
+ return rt(e);
1082
+ }
1083
+ function qn(e = g()) {
1084
+ return at(e);
1085
+ }
1086
+ function Ye(e = g()) {
1087
+ return ft(e);
1088
+ }
1089
+ function Ze(e = g()) {
1090
+ return ut(e);
1091
+ }
1092
+ function Ue(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 Jn(e) {
1102
+ try {
1103
+ const t = localStorage.getItem(Ye(e));
1104
+ if (t) {
1105
+ const n = JSON.parse(t);
1106
+ if (typeof n.top == "number" && typeof n.left == "number")
1107
+ return n;
1108
+ }
1109
+ } catch {
1110
+ }
1111
+ return bn();
1112
+ }
1113
+ function Wn(e, t) {
1114
+ try {
1115
+ localStorage.setItem(Ye(t), JSON.stringify(e));
1116
+ } catch {
1117
+ }
1118
+ }
1119
+ const ee = 60, ve = 320, Me = 240, ke = 1600, we = 1200, yn = { width: 1024 * 0.8, height: 768 * 0.8 };
1120
+ function xn() {
1121
+ return typeof window > "u" ? yn : Qe(
1122
+ Math.min(1200, 0.8 * window.innerWidth),
1123
+ Math.min(800, 0.8 * window.innerHeight)
1124
+ );
1125
+ }
1126
+ const Se = 32;
1127
+ function Qe(e, t) {
1128
+ const n = typeof window < "u" ? window.innerWidth : ke, r = typeof window < "u" ? window.innerHeight : we, i = Math.max(ve, Math.min(ke, n - Se)), a = Math.max(Me, Math.min(we, r - Se));
1129
+ return {
1130
+ width: Math.max(ve, Math.min(e, i)),
1131
+ height: Math.max(Me, Math.min(t, a))
1132
+ };
1133
+ }
1134
+ function Xn(e) {
1135
+ try {
1136
+ const t = localStorage.getItem(Ze(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 Qe(n.width, n.height);
1141
+ }
1142
+ } catch {
1143
+ }
1144
+ return xn();
1145
+ }
1146
+ function Yn(e, t) {
1147
+ try {
1148
+ localStorage.setItem(Ze(t), JSON.stringify(e));
1149
+ } catch {
1150
+ }
1151
+ }
1152
+ const vn = 1;
1153
+ function Zn(e) {
1154
+ return e === 0 ? "12rem" : e === 2 ? "100%" : "18rem";
1155
+ }
1156
+ function Un(e) {
1157
+ try {
1158
+ const t = localStorage.getItem(Ue(e));
1159
+ if (t === "0" || t === "1" || t === "2")
1160
+ return Number(t);
1161
+ } catch {
1162
+ }
1163
+ return vn;
1164
+ }
1165
+ function Qn(e, t) {
1166
+ try {
1167
+ localStorage.setItem(Ue(t), String(e));
1168
+ } catch {
1169
+ }
1170
+ }
1171
+ function er(e, t, n, r) {
1172
+ const i = -(n - ee), a = window.innerWidth - ee, o = -30, s = window.innerHeight - ee, 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 tr(e) {
1179
+ }
1180
+ function te() {
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 ot(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 nr(e) {
1217
+ const t = J(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 M = null;
1247
+ function se(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 (M || (M = document.createElement("canvas").getContext("2d")), !M) return "#000000";
1260
+ M.fillStyle = "#000000", M.fillStyle = t, M.clearRect(0, 0, 1, 1), M.fillRect(0, 0, 1, 1);
1261
+ const [r, i, a, o] = M.getImageData(0, 0, 1, 1).data;
1262
+ return $n(r, i, a, o);
1263
+ } catch {
1264
+ return "#000000";
1265
+ }
1266
+ }
1267
+ function z(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 = oe(e);
1280
+ if (i)
1281
+ for (let h = 0; h < t.length; h++) {
1282
+ const p = oe(t[h]);
1283
+ if (p && Tn(i, p)) return h;
1284
+ }
1285
+ const a = se(e), o = t.map((h) => se(h)), s = o.indexOf(a);
1286
+ if (s >= 0) return s;
1287
+ const u = $e(a);
1288
+ let c = n, d = 1 / 0;
1289
+ for (let h = 0; h < o.length; h++) {
1290
+ const p = $e(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 $e(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;
1306
+ if (n.colorMode) {
1307
+ const r = document.documentElement.getAttribute("data-theme");
1308
+ if (r === "light") return n.colorMode.lightScheme;
1309
+ if (r === "dark") return n.colorMode.darkScheme;
1310
+ }
1311
+ return n.colorScheme;
1312
+ }
1313
+ function In(e = $()) {
1314
+ const t = e.colorSchemes;
1315
+ if (Object.keys(t).length === 0)
1316
+ return ge(e);
1317
+ const n = Nn(e), r = t[n] ?? Object.values(t)[0];
1318
+ return Pn(r, e);
1319
+ }
1320
+ function On(e) {
1321
+ return oe(e) ? e : se(e);
1322
+ }
1323
+ function Pn(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 Te(e, t, n, r) {
1357
+ const i = t.length;
1358
+ return e === "bg" ? t[A(n, i)] ?? "#000000" : e === "fg" ? t[A(r, i)] ?? "#ffffff" : t[A(e, i)] ?? "#000000";
1359
+ }
1360
+ function A(e, t) {
1361
+ return e >= 0 && e < t ? e : 0;
1362
+ }
1363
+ function Ne(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([L(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[A(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, Te(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
+ z(L(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" && z(a, e.palette[A(o, r)]);
1391
+ }
1392
+ for (const [i, a] of Object.entries(t.semanticCssNames)) {
1393
+ const o = e.semanticMappings[i] ?? t.semanticDefaults[i];
1394
+ z(a, Te(o, e.palette, e.background, e.foreground));
1395
+ }
1396
+ }
1397
+ function rr(e, t) {
1398
+ const n = t ?? g(), r = n.applySink;
1399
+ Ne(e.color, $(n), r), F(n.tabs, "spacing", e.spacing, r), F(n.tabs, "font", e.typography, r), F(n.tabs, "size", e.size, r);
1400
+ const i = J(n);
1401
+ if (i && e.secondary && Ne(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
+ F(n.tabs, a, s, r);
1408
+ }
1409
+ }
1410
+ function F(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 = ye(i, c.id, d.id, a), p = xe(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 = ye(i, s.id, u.id, a), d = xe(c);
1453
+ typeof n[u.id] == "string" && n[u.id].length > 0 || s.referencesTier !== void 0 ? z(u.cssVar, d) : o.style.removeProperty(u.cssVar);
1454
+ } catch {
1455
+ o.style.removeProperty(u.cssVar);
1456
+ }
1457
+ }
1458
+ function et(e) {
1459
+ const t = e ?? g(), n = $(t), r = J(t);
1460
+ return r ? [n, r] : [n];
1461
+ }
1462
+ function tt(e) {
1463
+ const t = [];
1464
+ for (let n = 0; n < e.paletteSize; n++)
1465
+ t.push(L(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 _n(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 ?? et(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(...tt(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(L(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 ir(e, t) {
1509
+ const n = t ?? g(), r = n.applySink, i = et(n);
1510
+ if (r) {
1511
+ const o = [];
1512
+ for (const s of i)
1513
+ o.push(...tt(s));
1514
+ if (o.push(..._n(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 fe(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 ar = {
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 Ie(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") return;
1583
+ const t = e;
1584
+ if (typeof t.top == "number" && typeof t.left == "number" && Number.isFinite(t.top) && Number.isFinite(t.left))
1585
+ return { top: t.top, left: t.left };
1586
+ }
1587
+ function Vn(e) {
1588
+ if (!e || typeof e != "object" || Array.isArray(e)) return {};
1589
+ const t = {};
1590
+ for (const [n, r] of Object.entries(e)) {
1591
+ if (!r || typeof r != "object" || Array.isArray(r)) continue;
1592
+ const i = {};
1593
+ for (const [a, o] of Object.entries(r)) {
1594
+ if (!o || typeof o != "object" || Array.isArray(o)) continue;
1595
+ const s = {};
1596
+ for (const [u, c] of Object.entries(o))
1597
+ typeof c == "string" && (s[u] = c);
1598
+ i[a] = s;
1599
+ }
1600
+ t[n] = i;
1601
+ }
1602
+ return t;
1603
+ }
1604
+ function Oe(e, t, n, r = g()) {
1605
+ if (!e.color || !fe(e.color, t.paletteSize)) return null;
1606
+ const i = n ?? nt(t), a = e.typography !== void 0 ? e.typography : e.font, o = r.legacyIdRenameMap ?? {}, s = {
1607
+ color: ue(e.color, i),
1608
+ // New sections added after v1 migration — tolerate their absence so
1609
+ // older v2 payloads (Color-only) still load cleanly.
1610
+ spacing: Ie(e.spacing),
1611
+ // Typography slice: apply the host-configured rename map (if any)
1612
+ // so payloads persisted under the host's "old" ids survive a
1613
+ // host-driven id rename without losing the user's tweaks.
1614
+ typography: Hn(a, o),
1615
+ size: Ie(e.size),
1616
+ panelPosition: En(e.panelPosition)
1617
+ }, u = J(r);
1618
+ u && e.secondary && fe(e.secondary, u.paletteSize) && (s.secondary = ue(
1619
+ e.secondary,
1620
+ ge(u)
1621
+ ));
1622
+ const c = Vn(e.tabs);
1623
+ return Object.keys(c).length > 0 && (s.tabs = c), s;
1624
+ }
1625
+ function or(e = localStorage, t, n = $(), r = g()) {
1626
+ const i = We(r), a = Xe(r), o = pe(r), s = ne(e, o);
1627
+ if (s !== null) {
1628
+ const d = re(s);
1629
+ if (d && typeof d == "object") {
1630
+ const h = d, p = Oe(h, n, t, r);
1631
+ if (p !== null) {
1632
+ const v = h.typography !== void 0 ? h.typography : h.font;
1633
+ if (JSON.stringify(v ?? {}) !== JSON.stringify(p.typography) || h.typography === void 0)
1634
+ try {
1635
+ e.setItem(o, JSON.stringify(p));
1636
+ } catch {
1637
+ }
1638
+ return p;
1639
+ }
1640
+ }
1641
+ console.warn(`[tweak] Malformed ${o}, attempting v2 migration`);
1642
+ }
1643
+ const u = ne(e, a);
1644
+ if (u !== null) {
1645
+ const d = re(u);
1646
+ if (d && typeof d == "object") {
1647
+ const p = Oe(d, n, t, r);
1648
+ if (p !== null) {
1649
+ try {
1650
+ e.setItem(o, JSON.stringify(p)), e.removeItem(a);
1651
+ } catch {
1652
+ }
1653
+ return p;
1654
+ }
1655
+ }
1656
+ console.warn(`[tweak] Malformed ${a}, attempting v1 migration`);
1657
+ }
1658
+ const c = ne(e, i);
1659
+ if (c !== null) {
1660
+ const d = re(c);
1661
+ if (d && typeof d == "object" && fe(d, n.paletteSize)) {
1662
+ const h = t ?? nt(n), p = d;
1663
+ p.shikiTheme || (p.shikiTheme = h.shikiTheme);
1664
+ const S = {
1665
+ color: ue(p, h),
1666
+ spacing: te(),
1667
+ typography: te(),
1668
+ size: te()
1669
+ };
1670
+ try {
1671
+ e.setItem(o, JSON.stringify(S)), e.removeItem(i);
1672
+ } catch {
1673
+ }
1674
+ return S;
1675
+ }
1676
+ console.warn(`[tweak] Malformed ${i}; discarding and using fresh defaults`);
1677
+ try {
1678
+ e.removeItem(i);
1679
+ } catch {
1680
+ }
1681
+ }
1682
+ return null;
1683
+ }
1684
+ function sr(e, t = localStorage, n = g()) {
1685
+ try {
1686
+ t.setItem(pe(n), JSON.stringify(e));
1687
+ } catch {
1688
+ }
1689
+ }
1690
+ function fr(e = localStorage, t = g()) {
1691
+ try {
1692
+ e.removeItem(pe(t));
1693
+ } catch {
1694
+ }
1695
+ try {
1696
+ e.removeItem(Xe(t));
1697
+ } catch {
1698
+ }
1699
+ try {
1700
+ e.removeItem(We(t));
1701
+ } catch {
1702
+ }
1703
+ }
1704
+ function ne(e, t) {
1705
+ try {
1706
+ return e.getItem(t);
1707
+ } catch {
1708
+ return null;
1709
+ }
1710
+ }
1711
+ function re(e) {
1712
+ try {
1713
+ return JSON.parse(e);
1714
+ } catch {
1715
+ return null;
1716
+ }
1717
+ }
1718
+ function nt(e) {
1719
+ try {
1720
+ return In(e);
1721
+ } catch {
1722
+ return {
1723
+ palette: Array.from(
1724
+ { length: e.paletteSize },
1725
+ (n, r) => r === 0 ? "#000000" : r === e.paletteSize - 1 ? "#ffffff" : "#808080"
1726
+ ),
1727
+ background: e.baseDefaults.background ?? 0,
1728
+ foreground: e.baseDefaults.foreground ?? 0,
1729
+ cursor: e.baseDefaults.cursor ?? 0,
1730
+ selectionBg: e.baseDefaults.selectionBg ?? 0,
1731
+ selectionFg: e.baseDefaults.selectionFg ?? 0,
1732
+ semanticMappings: { ...e.semanticDefaults },
1733
+ shikiTheme: e.defaultShikiTheme
1734
+ };
1735
+ }
1736
+ }
1737
+ export {
1738
+ fr as A,
1739
+ ir as B,
1740
+ nr as C,
1741
+ mn as D,
1742
+ Zn as E,
1743
+ In as F,
1744
+ Cn as G,
1745
+ Wn as H,
1746
+ Yn as I,
1747
+ er as J,
1748
+ Qe as K,
1749
+ te as L,
1750
+ Fn as M,
1751
+ pe as N,
1752
+ ar as Z,
1753
+ We as a,
1754
+ Xe as b,
1755
+ $ as c,
1756
+ jn as d,
1757
+ xe as e,
1758
+ Bn as f,
1759
+ qn as g,
1760
+ zn as h,
1761
+ Pn as i,
1762
+ Dn as j,
1763
+ Kn as k,
1764
+ or as l,
1765
+ Gn as m,
1766
+ oe as n,
1767
+ Ln as o,
1768
+ tr as p,
1769
+ rr as q,
1770
+ ye as r,
1771
+ A as s,
1772
+ sr as t,
1773
+ xn as u,
1774
+ vn as v,
1775
+ Jn as w,
1776
+ Xn as x,
1777
+ Un as y,
1778
+ Qn as z
1779
+ };