@takazudo/zdtp 0.7.0 → 0.8.1

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.
@@ -1,66 +1,71 @@
1
- import { DEFAULT_STORAGE_PREFIX as z, resolveToggleEventName as M, READABLE_STATE_KEY_SUFFIXES as v } from "./constants.js";
1
+ import { DEFAULT_STORAGE_PREFIX as M, resolveToggleEventName as z, READABLE_STATE_KEY_SUFFIXES as E } from "./constants.js";
2
2
  class k extends Error {
3
3
  constructor(t) {
4
4
  super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, k.prototype);
5
5
  }
6
6
  }
7
- function S(e, t) {
7
+ function x(e, t) {
8
8
  return e.tiers.find((n) => n.id === t);
9
9
  }
10
10
  function $(e, t) {
11
11
  return e.items.find((n) => n.id === t);
12
12
  }
13
- function te(e, t, n, a) {
14
- const u = S(e, t);
15
- if (!u)
13
+ function te(e, t, n, c) {
14
+ const p = x(e, t);
15
+ if (!p)
16
16
  throw new k(
17
- `Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((f) => f.id).join(", ")}.`
17
+ `Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((d) => d.id).join(", ")}.`
18
18
  );
19
- const d = $(u, n);
20
- if (!d)
19
+ const g = $(p, n);
20
+ if (!g)
21
21
  throw new k(
22
22
  `Item "${n}" not found in tier "${t}" of tab "${e.id}".`
23
23
  );
24
- const r = a[t]?.[n];
25
- if (u.referencesTier !== void 0) {
26
- const f = u.referencesTier, l = S(e, f);
27
- if (!l)
24
+ const r = c[t]?.[n];
25
+ if (r === void 0 && g.modes !== void 0)
26
+ return {
27
+ kind: "literal",
28
+ value: `light-dark(${g.modes.light}, ${g.modes.dark})`
29
+ };
30
+ if (p.referencesTier !== void 0) {
31
+ const d = p.referencesTier, a = x(e, d);
32
+ if (!a)
28
33
  throw new k(
29
- `Tier "${t}" declares referencesTier "${f}" but that tier does not exist in tab "${e.id}".`
34
+ `Tier "${t}" declares referencesTier "${d}" but that tier does not exist in tab "${e.id}".`
30
35
  );
31
- const o = $(l, r ?? n);
32
- if (!o) {
33
- const c = $(l, d.default) ?? $(l, n) ?? l.items[0];
34
- if (!c)
36
+ const l = $(a, r ?? n);
37
+ if (!l) {
38
+ const i = $(a, g.default) ?? $(a, n) ?? a.items[0];
39
+ if (!i)
35
40
  throw new k(
36
- `Referenced tier "${f}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
41
+ `Referenced tier "${d}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
37
42
  );
38
- return { kind: "ref", targetCssVar: c.cssVar };
43
+ return { kind: "ref", targetCssVar: i.cssVar };
39
44
  }
40
- return { kind: "ref", targetCssVar: o.cssVar };
45
+ return { kind: "ref", targetCssVar: l.cssVar };
41
46
  }
42
- return r !== void 0 ? d.pill && r === d.pill.value ? { kind: "literal", value: d.pill.value } : { kind: "literal", value: r } : d.pill ? { kind: "literal", value: d.pill.customDefault } : { kind: "literal", value: d.default };
47
+ return r !== void 0 ? g.pill && r === g.pill.value ? { kind: "literal", value: g.pill.value } : { kind: "literal", value: r } : g.pill ? { kind: "literal", value: g.pill.customDefault } : { kind: "literal", value: g.default };
43
48
  }
44
49
  function ne(e) {
45
50
  return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
46
51
  }
47
52
  function D(e, t, n = [t]) {
48
- const a = e.tab === void 0 || e.tab === t.id ? t : n.find((s) => s.id === e.tab);
49
- if (!a)
53
+ const c = e.tab === void 0 || e.tab === t.id ? t : n.find((s) => s.id === e.tab);
54
+ if (!c)
50
55
  throw new k(
51
56
  `Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((s) => s.id).join(", ")}.`
52
57
  );
53
- const u = S(a, e.tier);
54
- if (!u)
58
+ const p = x(c, e.tier);
59
+ if (!p)
55
60
  throw new k(
56
- `Cross-tab ref target tier "${e.tier}" not found in tab "${a.id}". Available tiers: ${a.tiers.map((s) => s.id).join(", ")}.`
61
+ `Cross-tab ref target tier "${e.tier}" not found in tab "${c.id}". Available tiers: ${c.tiers.map((s) => s.id).join(", ")}.`
57
62
  );
58
- const d = $(u, e.item);
59
- if (!d)
63
+ const g = $(p, e.item);
64
+ if (!g)
60
65
  throw new k(
61
- `Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${a.id}". Available items: ${u.items.map((s) => s.id).join(", ")}.`
66
+ `Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${c.id}". Available items: ${p.items.map((s) => s.id).join(", ")}.`
62
67
  );
63
- return d.cssVar;
68
+ return g.cssVar;
64
69
  }
65
70
  function re(e, t) {
66
71
  return e.paletteCssVarTemplate.replace("{n}", String(t));
@@ -222,83 +227,77 @@ const H = /* @__PURE__ */ new Set([
222
227
  "revert",
223
228
  "revert-layer"
224
229
  ]);
225
- function B(e) {
230
+ function J(e) {
226
231
  return e.startsWith("#") || e.includes("(") || H.has(e.toLowerCase());
227
232
  }
228
- function J(e, t, n, a) {
229
- const u = [], d = e.indexOf(":");
230
- if (d !== -1) {
231
- const r = e.slice(0, d), f = e.slice(d + 1), l = t.find((i) => i.tier === r);
232
- l && u.push({ tab: l.tab, tier: l.tier, item: f });
233
+ function B(e, t, n, c) {
234
+ const p = [], g = e.indexOf(":");
235
+ if (g !== -1) {
236
+ const r = e.slice(0, g), d = e.slice(g + 1), a = t.find((o) => o.tier === r);
237
+ a && p.push({ tab: a.tab, tier: a.tier, item: d });
233
238
  }
234
239
  const [s] = t;
235
- u.push({ tab: s.tab, tier: s.tier, item: e });
236
- for (const r of u)
240
+ p.push({ tab: s.tab, tier: s.tier, item: e });
241
+ for (const r of p)
237
242
  try {
238
- return D(r, n, a), { ref: r };
243
+ return D(r, n, c), { ref: r };
239
244
  } catch {
240
245
  }
241
- return { ref: u[0] };
246
+ return { ref: p[0] };
242
247
  }
243
- function F(e, t, n, a, u, d) {
248
+ function F(e, t, n, c, p, g) {
244
249
  const s = t.get(e.default);
245
- return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !B(e.default) ? J(e.default, n, a, u) : d ? (console.warn(
250
+ return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !J(e.default) ? B(e.default, n, c, p) : g ? (console.warn(
246
251
  `[design-token-panel] semantic item "${e.id}" default "${e.default}" names no palette item; falling back to palette index 0`
247
252
  ), 0) : { literal: e.default };
248
253
  }
249
254
  function _(e, t = [e]) {
250
255
  const n = e.colorExtras;
251
256
  if (!n) return;
252
- const a = e.tiers.find(
253
- (o) => !o.referencesTier && !o.semantic && o.items.length > 0 && o.items[0].type.kind === "color"
254
- ), u = e.tiers.find(
255
- (o) => a && o.referencesTier === a.id || o.semantic === !0
256
- );
257
- if (!a && !u)
258
- return {
259
- id: n.id,
260
- label: n.label,
261
- paletteSize: 0,
262
- baseRoles: n.baseRoles,
263
- paletteCssVarTemplate: "--zudo-stub-p{n}",
264
- semanticDefaults: {},
265
- semanticCssNames: {},
266
- baseDefaults: n.baseDefaults,
267
- defaultShikiTheme: n.defaultShikiTheme,
268
- colorSchemes: n.colorSchemes,
269
- panelSettings: n.panelSettings
270
- };
271
- const d = a?.items ?? [], s = d.length, r = d[0] ? d[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", f = /* @__PURE__ */ new Map();
272
- for (let o = 0; o < d.length; o++)
273
- f.set(d[o].id, o);
274
- const l = {}, i = {};
275
- if (u) {
276
- const o = !u.semantic, c = n.semanticDefaults;
277
- for (const g of u.items)
278
- i[g.id] = g.cssVar, l[g.id] = c && g.id in c ? c[g.id] : F(
279
- g,
280
- f,
281
- u.referencesRamps,
257
+ const c = e.tiers.find(
258
+ (i) => !i.referencesTier && !i.semantic && i.items.length > 0 && (i.items[0].type.kind === "color" || i.items[0].modes !== void 0)
259
+ ), p = e.tiers.find(
260
+ (i) => c && i.referencesTier === c.id || i.semantic === !0
261
+ ), g = c?.items ?? [], s = g.length, r = {};
262
+ for (let i = 0; i < g.length; i++) {
263
+ const f = g[i].modes;
264
+ f && (r[i] = { ...f });
265
+ }
266
+ const d = g[0] ? g[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", a = /* @__PURE__ */ new Map();
267
+ for (let i = 0; i < g.length; i++)
268
+ a.set(g[i].id, i);
269
+ const o = {}, l = {};
270
+ if (p) {
271
+ const i = !p.semantic, f = n.semanticDefaults;
272
+ for (const u of p.items)
273
+ l[u.id] = u.cssVar, u.modes ? o[u.id] = { literal: { ...u.modes } } : o[u.id] = f && u.id in f ? f[u.id] : F(
274
+ u,
275
+ a,
276
+ p.referencesRamps,
282
277
  e,
283
278
  t,
284
- o
279
+ i
285
280
  );
286
281
  }
282
+ for (const i of e.tiers)
283
+ for (const f of i.items)
284
+ !f.modes || a.has(f.id) || f.id in o || (o[f.id] = { literal: { ...f.modes } }, l[f.id] = f.cssVar);
287
285
  return {
288
286
  id: n.id,
289
287
  label: n.label,
290
288
  paletteSize: s,
289
+ ...Object.keys(r).length > 0 ? { paletteModes: r } : {},
291
290
  baseRoles: n.baseRoles,
292
- paletteCssVarTemplate: r,
293
- semanticDefaults: l,
294
- semanticCssNames: i,
291
+ paletteCssVarTemplate: d,
292
+ semanticDefaults: o,
293
+ semanticCssNames: l,
295
294
  baseDefaults: n.baseDefaults,
296
295
  defaultShikiTheme: n.defaultShikiTheme,
297
296
  colorSchemes: n.colorSchemes,
298
297
  panelSettings: n.panelSettings
299
298
  };
300
299
  }
301
- function ie(e) {
300
+ function oe(e) {
302
301
  const t = e.find((n) => n.id === "color");
303
302
  if (t)
304
303
  return _(t, e);
@@ -307,26 +306,26 @@ function L(e) {
307
306
  const t = e.find((n) => n.id === "color-secondary");
308
307
  return t ? _(t, e) ?? null : null;
309
308
  }
310
- function x(e, t) {
309
+ function S(e, t) {
311
310
  if (Object.is(e, t)) return !0;
312
311
  if (e === null || t === null || typeof e != typeof t || typeof e != "object") return !1;
313
312
  if (Array.isArray(e)) {
314
313
  if (!Array.isArray(t) || e.length !== t.length) return !1;
315
- for (let d = 0; d < e.length; d++)
316
- if (!x(e[d], t[d])) return !1;
314
+ for (let g = 0; g < e.length; g++)
315
+ if (!S(e[g], t[g])) return !1;
317
316
  return !0;
318
317
  }
319
318
  if (Array.isArray(t)) return !1;
320
- const n = Object.keys(e), a = Object.keys(t);
321
- if (n.length !== a.length) return !1;
322
- const u = new Set(a);
323
- for (const d of n)
324
- if (!u.has(d) || !x(e[d], t[d]))
319
+ const n = Object.keys(e), c = Object.keys(t);
320
+ if (n.length !== c.length) return !1;
321
+ const p = new Set(c);
322
+ for (const g of n)
323
+ if (!p.has(g) || !S(e[g], t[g]))
325
324
  return !1;
326
325
  return !0;
327
326
  }
328
327
  const q = {
329
- storagePrefix: z,
328
+ storagePrefix: M,
330
329
  consoleNamespace: "zudo",
331
330
  modalClassPrefix: "zudo-design-token-panel-modal",
332
331
  schemaId: "zudo-design-tokens/v1",
@@ -372,7 +371,7 @@ function G(e) {
372
371
  }
373
372
  };
374
373
  }
375
- function oe(e) {
374
+ function ie(e) {
376
375
  h().lifecycleHooks = {
377
376
  configured: e.configured,
378
377
  open: e.open,
@@ -382,21 +381,21 @@ function oe(e) {
382
381
  };
383
382
  }
384
383
  function se(e) {
385
- const t = h(), n = e.storagePrefix, a = t.instances.get(n);
386
- if (a) {
387
- const l = (i) => ({ ...i, applySink: void 0 });
388
- if (x(l(a.suppliedConfig), l(e)))
389
- return t.defaultPrefix = n, a.handle;
384
+ const t = h(), n = e.storagePrefix, c = t.instances.get(n);
385
+ if (c) {
386
+ const a = (o) => ({ ...o, applySink: void 0 });
387
+ if (S(a(c.suppliedConfig), a(e)))
388
+ return t.defaultPrefix = n, c.handle;
390
389
  throw new Error(
391
390
  `[design-token-panel] configurePanel() was already called with different values for storagePrefix "${n}". Configuration is one-shot per prefix per page lifecycle. To re-configure this prefix, call handle.destroy() first, then configurePanel() again. (Use a distinct storagePrefix for a second panel instance.)`
392
391
  );
393
392
  }
394
- const u = t.pendingColorPresets, d = u ? { ...e, colorPresets: u } : { ...e };
393
+ const p = t.pendingColorPresets, g = p ? { ...e, colorPresets: p } : { ...e };
395
394
  t.pendingColorPresets = null;
396
395
  const s = t.instances.size === 0, r = s ? [...t.pendingPostConfigureHooks] : [];
397
396
  s && (t.pendingPostConfigureHooks.length = 0);
398
- const f = {
399
- config: d,
397
+ const d = {
398
+ config: g,
400
399
  // Snapshot the as-supplied config before any runtime merges. Used by the
401
400
  // idempotency guard so view-transition re-calls with the original inline
402
401
  // config keep passing even after setPanelColorPresets mutates `config`.
@@ -405,17 +404,17 @@ function se(e) {
405
404
  postConfigureHooks: r,
406
405
  handle: G(n)
407
406
  };
408
- t.instances.set(n, f), t.defaultPrefix = n;
409
- for (const l of f.postConfigureHooks)
410
- l();
411
- return t.lifecycleHooks.configured?.(n), f.handle;
407
+ t.instances.set(n, d), t.defaultPrefix = n;
408
+ for (const a of d.postConfigureHooks)
409
+ a();
410
+ return t.lifecycleHooks.configured?.(n), d.handle;
412
411
  }
413
- function T() {
412
+ function j() {
414
413
  const e = h();
415
414
  return e.defaultPrefix === null ? null : e.instances.get(e.defaultPrefix) ?? null;
416
415
  }
417
416
  function ae(e) {
418
- const t = T();
417
+ const t = j();
419
418
  if (t === null) {
420
419
  const n = h();
421
420
  if (n.pendingPostConfigureHooks.includes(e)) return;
@@ -424,8 +423,8 @@ function ae(e) {
424
423
  }
425
424
  t.postConfigureHooks.includes(e) || (t.postConfigureHooks.push(e), e());
426
425
  }
427
- function j() {
428
- return T()?.config ?? q;
426
+ function T() {
427
+ return j()?.config ?? q;
429
428
  }
430
429
  function le() {
431
430
  return [...h().instances.values()].map((e) => e.config);
@@ -441,29 +440,29 @@ function A() {
441
440
  const e = h();
442
441
  return e.colorSchemeOwners || (e.colorSchemeOwners = /* @__PURE__ */ new Set()), e.colorSchemeOwners;
443
442
  }
444
- function ge(e) {
443
+ function de(e) {
445
444
  A().add(e);
446
445
  }
447
- function de(e) {
446
+ function ge(e) {
448
447
  A().delete(e);
449
448
  }
450
449
  function ue(e) {
451
450
  return A().has(e);
452
451
  }
453
- function pe(e = j()) {
452
+ function pe(e = T()) {
454
453
  return L(e.tabs);
455
454
  }
456
455
  function me(e) {
457
- return e.storagePrefix + v.v2;
456
+ return e.storagePrefix + E.v2;
458
457
  }
459
458
  function ye(e) {
460
- return e.storagePrefix + v.v3;
459
+ return e.storagePrefix + E.v3;
461
460
  }
462
461
  function he(e) {
463
- return e.storagePrefix + v.v4;
462
+ return e.storagePrefix + E.v4;
464
463
  }
465
464
  function we(e) {
466
- return e.storagePrefix + v.v1;
465
+ return e.storagePrefix + E.v1;
467
466
  }
468
467
  function be(e) {
469
468
  return `${e.storagePrefix}-spawn-ordinal`;
@@ -480,32 +479,32 @@ function Ce(e) {
480
479
  function Pe(e) {
481
480
  return `${e.storagePrefix}-dock`;
482
481
  }
483
- function Ee(e) {
482
+ function ve(e) {
484
483
  return `${e.storagePrefix}-dock-size`;
485
484
  }
486
- function ve(e) {
485
+ function Ee(e) {
487
486
  return `${e.storagePrefix}-density`;
488
487
  }
489
488
  function Ae(e) {
490
489
  return `${e.storagePrefix}-specimen`;
491
490
  }
492
- function Se(e, t) {
491
+ function xe(e, t) {
493
492
  return `${e.storagePrefix}-snapshot-${t}`;
494
493
  }
495
- function xe(e) {
494
+ function Se(e) {
496
495
  return `${e.storagePrefix}-last-applied`;
497
496
  }
498
- function Te(e) {
497
+ function je(e) {
499
498
  return `${e.storagePrefix}:visible`;
500
499
  }
501
- function je(e) {
500
+ function Te(e) {
502
501
  return `${e.storagePrefix}:autoload`;
503
502
  }
504
503
  function Oe(e) {
505
504
  return `${e.storagePrefix}-root`;
506
505
  }
507
506
  function Re(e) {
508
- return M(e);
507
+ return z(e);
509
508
  }
510
509
  const U = "__zdtp:open-state-changed";
511
510
  function Ve(e) {
@@ -549,10 +548,10 @@ function Ke(e) {
549
548
  );
550
549
  return;
551
550
  }
552
- const a = { ...e };
553
- a[N] = !0, t.zdtp = a;
551
+ const c = { ...e };
552
+ c[N] = !0, t.zdtp = c;
554
553
  }
555
- function ze(e) {
554
+ function Me(e) {
556
555
  if (e === null || typeof e != "object" || Array.isArray(e))
557
556
  throw new Error("[design-token-panel] PanelConfig must be a non-null object");
558
557
  const t = e;
@@ -578,8 +577,8 @@ function ze(e) {
578
577
  if (t.applyRouting !== void 0) {
579
578
  if (t.applyRouting === null || typeof t.applyRouting != "object" || Array.isArray(t.applyRouting))
580
579
  throw new Error("[design-token-panel] PanelConfig.applyRouting must be a plain object");
581
- for (const [n, a] of Object.entries(t.applyRouting))
582
- if (typeof a != "string")
580
+ for (const [n, c] of Object.entries(t.applyRouting))
581
+ if (typeof c != "string")
583
582
  throw new Error(
584
583
  `[design-token-panel] PanelConfig.applyRouting[${JSON.stringify(n)}] must be a string`
585
584
  );
@@ -588,10 +587,10 @@ function ze(e) {
588
587
  if (t.domTweaker === null || typeof t.domTweaker != "object" || Array.isArray(t.domTweaker))
589
588
  throw new Error("[design-token-panel] PanelConfig.domTweaker must be a plain object");
590
589
  const n = t.domTweaker;
591
- for (const a of Object.keys(n))
592
- if (a !== "themeCss")
590
+ for (const c of Object.keys(n))
591
+ if (c !== "themeCss")
593
592
  throw new Error(
594
- `[design-token-panel] PanelConfig.domTweaker.${a} is not a supported field`
593
+ `[design-token-panel] PanelConfig.domTweaker.${c} is not a supported field`
595
594
  );
596
595
  if (n.themeCss !== void 0) {
597
596
  if (typeof n.themeCss != "string")
@@ -608,9 +607,9 @@ function ze(e) {
608
607
  if (t.dock === null || typeof t.dock != "object" || Array.isArray(t.dock))
609
608
  throw new Error("[design-token-panel] PanelConfig.dock must be a plain object");
610
609
  const n = t.dock;
611
- for (const a of Object.keys(n))
612
- if (a !== "reflow")
613
- throw new Error(`[design-token-panel] PanelConfig.dock.${a} is not a supported field`);
610
+ for (const c of Object.keys(n))
611
+ if (c !== "reflow")
612
+ throw new Error(`[design-token-panel] PanelConfig.dock.${c} is not a supported field`);
614
613
  if (n.reflow !== void 0 && n.reflow !== "body-margin" && n.reflow !== "none")
615
614
  throw new Error(
616
615
  '[design-token-panel] PanelConfig.dock.reflow must be "body-margin" or "none" when set'
@@ -623,10 +622,10 @@ function ze(e) {
623
622
  if (t.legacyIdRenameMap !== void 0) {
624
623
  if (t.legacyIdRenameMap === null || typeof t.legacyIdRenameMap != "object" || Array.isArray(t.legacyIdRenameMap))
625
624
  throw new Error("[design-token-panel] PanelConfig.legacyIdRenameMap must be a plain object");
626
- for (const [n, a] of Object.entries(t.legacyIdRenameMap))
627
- if (a !== null && typeof a != "string")
625
+ for (const [n, c] of Object.entries(t.legacyIdRenameMap))
626
+ if (c !== null && typeof c != "string")
628
627
  throw new Error(
629
- `[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof a})`
628
+ `[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof c})`
630
629
  );
631
630
  }
632
631
  }
@@ -637,14 +636,14 @@ function Z(e) {
637
636
  for (const n of e) {
638
637
  if (n === null || typeof n != "object" || Array.isArray(n))
639
638
  throw new Error("[design-token-panel] PanelConfig.tabs: each tab must be a non-null object");
640
- const a = n;
641
- if (typeof a.id != "string" || a.id.length === 0)
639
+ const c = n;
640
+ if (typeof c.id != "string" || c.id.length === 0)
642
641
  throw new Error("[design-token-panel] PanelConfig.tabs: each tab must have a non-empty string id");
643
- if (t.has(a.id))
642
+ if (t.has(c.id))
644
643
  throw new Error(
645
- `[design-token-panel] PanelConfig.tabs: duplicate tab id "${a.id}"`
644
+ `[design-token-panel] PanelConfig.tabs: duplicate tab id "${c.id}"`
646
645
  );
647
- t.add(a.id), Q(a.id, a, e);
646
+ t.add(c.id), Q(c.id, c, e);
648
647
  }
649
648
  }
650
649
  function X(e) {
@@ -655,14 +654,14 @@ function X(e) {
655
654
  const n = t.literal;
656
655
  if (typeof n == "string") return !0;
657
656
  if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
658
- const a = n;
659
- return typeof a.light == "string" && typeof a.dark == "string";
657
+ const c = n;
658
+ return typeof c.light == "string" && typeof c.dark == "string";
660
659
  }
661
660
  if ("ref" in t) {
662
661
  const n = t.ref;
663
662
  if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
664
- const a = n;
665
- return !(typeof a.tier != "string" || typeof a.item != "string" || a.tab !== void 0 && typeof a.tab != "string");
663
+ const c = n;
664
+ return !(typeof c.tier != "string" || typeof c.item != "string" || c.tab !== void 0 && typeof c.tab != "string");
666
665
  }
667
666
  return !1;
668
667
  }
@@ -671,7 +670,7 @@ function Q(e, t, n) {
671
670
  throw new Error(
672
671
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers must be an array`
673
672
  );
674
- const a = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map();
673
+ const c = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map();
675
674
  for (const s of t.tiers) {
676
675
  if (s === null || typeof s != "object" || Array.isArray(s))
677
676
  throw new Error(
@@ -682,15 +681,15 @@ function Q(e, t, n) {
682
681
  throw new Error(
683
682
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must have a non-empty string id`
684
683
  );
685
- if (a.has(r.id))
684
+ if (c.has(r.id))
686
685
  throw new Error(
687
686
  `[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${r.id}"`
688
687
  );
689
- if (a.add(r.id), r.semantic !== void 0 && r.semantic !== !0)
688
+ if (c.add(r.id), r.semantic !== void 0 && r.semantic !== !0)
690
689
  throw new Error(
691
690
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(r.semantic)})`
692
691
  );
693
- const f = /* @__PURE__ */ new Set([
692
+ const d = /* @__PURE__ */ new Set([
694
693
  "size",
695
694
  "line-height",
696
695
  "family",
@@ -699,7 +698,7 @@ function Q(e, t, n) {
699
698
  "radius",
700
699
  "duration"
701
700
  ]);
702
- if (r.preview !== void 0 && !f.has(r.preview))
701
+ if (r.preview !== void 0 && !d.has(r.preview))
703
702
  throw new Error(
704
703
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].preview has unsupported value ${JSON.stringify(r.preview)}`
705
704
  );
@@ -715,150 +714,164 @@ function Q(e, t, n) {
715
714
  throw new Error(
716
715
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].items must be an array`
717
716
  );
718
- let l;
719
- for (const i of r.items) {
717
+ let a;
718
+ for (const o of r.items) {
719
+ if (o === null || typeof o != "object" || Array.isArray(o)) continue;
720
+ const i = o.type;
720
721
  if (i === null || typeof i != "object" || Array.isArray(i)) continue;
721
- const c = i.type;
722
- if (c === null || typeof c != "object" || Array.isArray(c)) continue;
723
- const g = c.kind;
724
- if (typeof g == "string") {
725
- if (l === void 0)
726
- l = g;
727
- else if (l !== g)
722
+ const f = i.kind;
723
+ if (typeof f == "string") {
724
+ if (a === void 0)
725
+ a = f;
726
+ else if (a !== f)
728
727
  throw new Error(
729
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"]: mixed item kinds — found "${l}" and "${g}" in the same tier (all items must share the same kind)`
728
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"]: mixed item kinds — found "${a}" and "${f}" in the same tier (all items must share the same kind)`
730
729
  );
731
730
  }
732
731
  }
733
- l !== void 0 && u.set(r.id, l);
732
+ a !== void 0 && p.set(r.id, a);
734
733
  }
735
- const d = /* @__PURE__ */ new Set();
734
+ const g = /* @__PURE__ */ new Set();
736
735
  for (const s of t.tiers) {
737
- const r = s, f = r.id;
738
- for (const l of r.items) {
739
- if (l === null || typeof l != "object" || Array.isArray(l))
736
+ const r = s, d = r.id;
737
+ for (const a of r.items) {
738
+ if (a === null || typeof a != "object" || Array.isArray(a))
740
739
  throw new Error(
741
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items: each item must be a non-null object`
740
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items: each item must be a non-null object`
742
741
  );
743
- const i = l;
744
- if (typeof i.id != "string" || i.id.length === 0)
742
+ const o = a;
743
+ if (typeof o.id != "string" || o.id.length === 0)
745
744
  throw new Error(
746
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items: each item must have a non-empty string id`
745
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items: each item must have a non-empty string id`
747
746
  );
748
- if (d.has(i.id))
747
+ if (g.has(o.id))
749
748
  throw new Error(
750
- `[design-token-panel] PanelConfig.tabs["${e}"]: duplicate item id "${i.id}" (item ids must be unique across all tiers within a tab)`
749
+ `[design-token-panel] PanelConfig.tabs["${e}"]: duplicate item id "${o.id}" (item ids must be unique across all tiers within a tab)`
751
750
  );
752
- if (d.add(i.id), typeof i.cssVar != "string" || !i.cssVar.startsWith("--"))
751
+ if (g.add(o.id), typeof o.cssVar != "string" || !o.cssVar.startsWith("--"))
753
752
  throw new Error(
754
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${i.id}"].cssVar must start with "--" (got ${JSON.stringify(i.cssVar)})`
753
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].cssVar must start with "--" (got ${JSON.stringify(o.cssVar)})`
755
754
  );
756
- if (i.cssVar.length <= 2)
755
+ if (o.cssVar.length <= 2)
757
756
  throw new Error(
758
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${i.id}"].cssVar must be non-empty after "--"`
757
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].cssVar must be non-empty after "--"`
759
758
  );
760
- const o = i.type;
761
- if (o !== null && typeof o == "object" && !Array.isArray(o) && o.kind === "length" && o.units !== void 0) {
762
- const c = o.units;
763
- if (!Array.isArray(c))
759
+ const l = o.type;
760
+ if (o.modes !== void 0) {
761
+ const i = `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].modes`;
762
+ if (o.modes === null || typeof o.modes != "object" || Array.isArray(o.modes))
763
+ throw new Error(`${i} must be a plain object`);
764
+ const f = l !== null && typeof l == "object" && !Array.isArray(l) ? l.kind : void 0;
765
+ if (f !== "color" && f !== "text")
766
+ throw new Error(
767
+ `${i} is only valid when type.kind is "color" or "text" (got ${JSON.stringify(f)})`
768
+ );
769
+ const u = o.modes;
770
+ for (const m of ["light", "dark"])
771
+ if (typeof u[m] != "string" || u[m].trim().length === 0)
772
+ throw new Error(`${i}.${m} must be a non-empty string`);
773
+ }
774
+ if (l !== null && typeof l == "object" && !Array.isArray(l) && l.kind === "length" && l.units !== void 0) {
775
+ const i = l.units;
776
+ if (!Array.isArray(i))
764
777
  throw new Error(
765
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${i.id}"].type.units must be an array`
778
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].type.units must be an array`
766
779
  );
767
- const g = /* @__PURE__ */ new Set();
768
- for (const p of c) {
769
- if (typeof p != "string" || p.length === 0)
780
+ const f = /* @__PURE__ */ new Set();
781
+ for (const u of i) {
782
+ if (typeof u != "string" || u.length === 0)
770
783
  throw new Error(
771
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${i.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(p)})`
784
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(u)})`
772
785
  );
773
- if (g.has(p))
786
+ if (f.has(u))
774
787
  throw new Error(
775
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${i.id}"].type.units: duplicate unit ${JSON.stringify(p)}`
788
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].type.units: duplicate unit ${JSON.stringify(u)}`
776
789
  );
777
- g.add(p);
790
+ f.add(u);
778
791
  }
779
792
  }
780
793
  }
781
794
  }
782
795
  for (const s of t.tiers) {
783
- const r = s, f = r.id;
796
+ const r = s, d = r.id;
784
797
  if (r.referencesTier !== void 0) {
785
798
  if (typeof r.referencesTier != "string")
786
799
  throw new Error(
787
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesTier must be a string`
800
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesTier must be a string`
788
801
  );
789
- const l = r.referencesTier;
790
- if (!a.has(l))
802
+ const a = r.referencesTier;
803
+ if (!c.has(a))
791
804
  throw new Error(
792
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesTier: tier "${l}" does not exist in this tab`
805
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesTier: tier "${a}" does not exist in this tab`
793
806
  );
794
- const i = u.get(f), o = u.get(l);
795
- if (i !== void 0 && o !== void 0 && i !== "text" && i !== o)
807
+ const o = p.get(d), l = p.get(a);
808
+ if (o !== void 0 && l !== void 0 && o !== "text" && o !== l)
796
809
  throw new Error(
797
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesTier: referencing tier has kind "${i}" but referenced tier "${l}" has kind "${o}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
810
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesTier: referencing tier has kind "${o}" but referenced tier "${a}" has kind "${l}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
798
811
  );
799
812
  }
800
813
  }
801
814
  for (const s of t.tiers) {
802
- const r = s, f = r.id, l = r.preview;
803
- if (l === void 0) continue;
804
- const i = u.get(f), o = typeof r.referencesTier == "string" ? u.get(r.referencesTier) : void 0, c = (g) => {
815
+ const r = s, d = r.id, a = r.preview;
816
+ if (a === void 0) continue;
817
+ const o = p.get(d), l = typeof r.referencesTier == "string" ? p.get(r.referencesTier) : void 0, i = (f) => {
805
818
  throw new Error(
806
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].preview "${l}" requires ${g}`
819
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].preview "${a}" requires ${f}`
807
820
  );
808
821
  };
809
- if (l === "size" && (r.referencesTier === void 0 ? i !== "length" : o !== "length") && c("a length tier or a reference tier resolving to length"), l === "line-height" && i !== "number" && c("a number tier"), l === "family" && i !== "text" && c("a text tier"), l === "weight" && i !== "select" && i !== "number" && c("a select or number tier"), (l === "bar" || l === "radius") && i !== "length" && c("a length tier"), l === "duration") {
810
- i !== "length" && i !== "number" && c('a length or number tier with unit "ms" or "s"');
811
- for (const g of r.items) {
812
- if (g === null || typeof g != "object" || Array.isArray(g))
822
+ if (a === "size" && (r.referencesTier === void 0 ? o !== "length" : l !== "length") && i("a length tier or a reference tier resolving to length"), a === "line-height" && o !== "number" && i("a number tier"), a === "family" && o !== "text" && i("a text tier"), a === "weight" && o !== "select" && o !== "number" && i("a select or number tier"), (a === "bar" || a === "radius") && o !== "length" && i("a length tier"), a === "duration") {
823
+ o !== "length" && o !== "number" && i('a length or number tier with unit "ms" or "s"');
824
+ for (const f of r.items) {
825
+ if (f === null || typeof f != "object" || Array.isArray(f))
813
826
  continue;
814
- const p = g.type, m = p !== null && typeof p == "object" && !Array.isArray(p) ? p.unit : void 0;
815
- m !== "ms" && m !== "s" && c('a length or number tier with unit "ms" or "s"');
827
+ const u = f.type, m = u !== null && typeof u == "object" && !Array.isArray(u) ? u.unit : void 0;
828
+ m !== "ms" && m !== "s" && i('a length or number tier with unit "ms" or "s"');
816
829
  }
817
830
  }
818
831
  }
819
832
  for (const s of t.tiers) {
820
- const r = s, f = r.id;
833
+ const r = s, d = r.id;
821
834
  if (r.referencesRamps === void 0) continue;
822
835
  if (r.semantic !== !0)
823
836
  throw new Error(
824
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps is only valid on a tier with semantic: true`
837
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps is only valid on a tier with semantic: true`
825
838
  );
826
839
  if (!Array.isArray(r.referencesRamps))
827
840
  throw new Error(
828
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps must be an array`
841
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps must be an array`
829
842
  );
830
843
  if (e !== "color" && e !== "color-secondary")
831
844
  throw new Error(
832
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps is only supported on tabs with id "color" or "color-secondary" (got "${e}")`
845
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps is only supported on tabs with id "color" or "color-secondary" (got "${e}")`
833
846
  );
834
- const l = u.get(f), i = r.referencesRamps;
835
- for (let o = 0; o < i.length; o++) {
836
- const c = i[o];
837
- if (c === null || typeof c != "object" || Array.isArray(c))
847
+ const a = p.get(d), o = r.referencesRamps;
848
+ for (let l = 0; l < o.length; l++) {
849
+ const i = o[l];
850
+ if (i === null || typeof i != "object" || Array.isArray(i))
838
851
  throw new Error(
839
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${o}] must be a non-null object`
852
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}] must be a non-null object`
840
853
  );
841
- const g = c;
842
- if (typeof g.tier != "string" || g.tier.length === 0)
854
+ const f = i;
855
+ if (typeof f.tier != "string" || f.tier.length === 0)
843
856
  throw new Error(
844
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${o}].tier must be a non-empty string`
857
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}].tier must be a non-empty string`
845
858
  );
846
- if (g.tab !== void 0 && (typeof g.tab != "string" || g.tab.length === 0))
859
+ if (f.tab !== void 0 && (typeof f.tab != "string" || f.tab.length === 0))
847
860
  throw new Error(
848
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${o}].tab must be a non-empty string when set`
861
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}].tab must be a non-empty string when set`
849
862
  );
850
- const p = g.tab === void 0 ? e : g.tab;
863
+ const u = f.tab === void 0 ? e : f.tab;
851
864
  let m;
852
- if (p === e)
865
+ if (u === e)
853
866
  m = t;
854
867
  else {
855
868
  const b = n.find(
856
- (y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === p
869
+ (y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === u
857
870
  );
858
871
  if (!b) {
859
872
  const y = n.filter((w) => w !== null && typeof w == "object" && !Array.isArray(w)).map((w) => w.id).join(", ");
860
873
  throw new Error(
861
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${o}]: tab "${p}" does not exist. Available tabs: ${y}.`
874
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}]: tab "${u}" does not exist. Available tabs: ${y}.`
862
875
  );
863
876
  }
864
877
  m = b;
@@ -868,28 +881,28 @@ function Q(e, t, n) {
868
881
  for (const b of C) {
869
882
  if (b === null || typeof b != "object" || Array.isArray(b)) continue;
870
883
  const y = b;
871
- typeof y.id == "string" && (O.push(y.id), y.id === g.tier && (P = y));
884
+ typeof y.id == "string" && (O.push(y.id), y.id === f.tier && (P = y));
872
885
  }
873
886
  if (!P)
874
887
  throw new Error(
875
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${o}]: tier "${g.tier}" does not exist in tab "${p}". Available tiers: ${O.join(", ")}.`
888
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}]: tier "${f.tier}" does not exist in tab "${u}". Available tiers: ${O.join(", ")}.`
876
889
  );
877
- if (l !== void 0) {
890
+ if (a !== void 0) {
878
891
  const b = Array.isArray(P.items) ? P.items : [];
879
892
  let y;
880
893
  for (const w of b) {
881
894
  if (w === null || typeof w != "object" || Array.isArray(w)) continue;
882
- const E = w.type;
883
- if (E === null || typeof E != "object" || Array.isArray(E)) continue;
884
- const R = E.kind;
895
+ const v = w.type;
896
+ if (v === null || typeof v != "object" || Array.isArray(v)) continue;
897
+ const R = v.kind;
885
898
  if (typeof R == "string") {
886
899
  y = R;
887
900
  break;
888
901
  }
889
902
  }
890
- if (y !== void 0 && l !== y)
903
+ if (y !== void 0 && a !== y)
891
904
  throw new Error(
892
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${o}]: referencing semantic tier has kind "${l}" but target tier "${g.tier}" in tab "${p}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
905
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}]: referencing semantic tier has kind "${a}" but target tier "${f.tier}" in tab "${u}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
893
906
  );
894
907
  }
895
908
  }
@@ -900,31 +913,31 @@ function Q(e, t, n) {
900
913
  '[design-token-panel] PanelConfig.tabs["palette"].colorExtras must be absent — multiple kind:"color" tiers are only safe when resolveColorClusterFromTab is not invoked'
901
914
  );
902
915
  for (const s of t.tiers) {
903
- const r = s.items, f = `[design-token-panel] PanelConfig.tabs["palette"].tiers["${s.id}"]`;
916
+ const r = s.items, d = `[design-token-panel] PanelConfig.tabs["palette"].tiers["${s.id}"]`;
904
917
  if (r.length === 0)
905
- throw new Error(`${f}.items must be non-empty`);
906
- for (const [o, c] of r.entries())
907
- if (c.type.kind !== "color")
908
- throw new Error(`${f}.items[${o}].type.kind must be "color"`);
909
- const l = r[0].cssVar, i = l.replace(/\d+$/, "{n}");
910
- if (i.includes("{n}")) {
911
- const o = Number(l.match(/\d+$/)[0]);
912
- for (const [c, g] of r.entries()) {
913
- const p = i.replace("{n}", String(o + c));
914
- if (!Number.isSafeInteger(o + c) || g.cssVar !== p)
918
+ throw new Error(`${d}.items must be non-empty`);
919
+ for (const [l, i] of r.entries())
920
+ if (i.type.kind !== "color")
921
+ throw new Error(`${d}.items[${l}].type.kind must be "color"`);
922
+ const a = r[0].cssVar, o = a.replace(/\d+$/, "{n}");
923
+ if (o.includes("{n}")) {
924
+ const l = Number(a.match(/\d+$/)[0]);
925
+ for (const [i, f] of r.entries()) {
926
+ const u = o.replace("{n}", String(l + i));
927
+ if (!Number.isSafeInteger(l + i) || f.cssVar !== u)
915
928
  throw new Error(
916
- `${f}.items[${c}].cssVar is ${JSON.stringify(g.cssVar)} but expected ${JSON.stringify(p)} — palette item cssVars must share one prefix and be numbered consecutively in tier order`
929
+ `${d}.items[${i}].cssVar is ${JSON.stringify(f.cssVar)} but expected ${JSON.stringify(u)} — palette item cssVars must share one prefix and be numbered consecutively in tier order`
917
930
  );
918
931
  }
919
932
  } else {
920
- const o = l.slice(0, l.lastIndexOf("-") + 1), c = /* @__PURE__ */ new Set();
921
- for (const [g, p] of r.entries()) {
922
- const m = p.cssVar;
923
- if (r.length > 1 && o === "--" || !m.startsWith(o) || m.length === o.length || /\d+$/.test(m) || c.has(m))
933
+ const l = a.slice(0, a.lastIndexOf("-") + 1), i = /* @__PURE__ */ new Set();
934
+ for (const [f, u] of r.entries()) {
935
+ const m = u.cssVar;
936
+ if (r.length > 1 && l === "--" || !m.startsWith(l) || m.length === l.length || /\d+$/.test(m) || i.has(m))
924
937
  throw new Error(
925
- `${f}.items[${g}].cssVar ${JSON.stringify(m)} — named palette item cssVars must share one prefix and have unique non-numbered suffixes`
938
+ `${d}.items[${f}].cssVar ${JSON.stringify(m)} — named palette item cssVars must share one prefix and have unique non-numbered suffixes`
926
939
  );
927
- c.add(m);
940
+ i.add(m);
928
941
  }
929
942
  }
930
943
  }
@@ -935,15 +948,15 @@ function Q(e, t, n) {
935
948
  throw new Error(
936
949
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras must be a plain object`
937
950
  );
938
- for (const i of ["id", "defaultShikiTheme"])
939
- if (typeof s[i] != "string" || s[i].length === 0)
951
+ for (const o of ["id", "defaultShikiTheme"])
952
+ if (typeof s[o] != "string" || s[o].length === 0)
940
953
  throw new Error(
941
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${i} must be a non-empty string (got ${typeof s[i]})`
954
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${o} must be a non-empty string (got ${typeof s[o]})`
942
955
  );
943
- for (const i of ["colorSchemes", "baseRoles", "baseDefaults"])
944
- if (s[i] === void 0 || s[i] === null || typeof s[i] != "object" || Array.isArray(s[i]))
956
+ for (const o of ["colorSchemes", "baseRoles", "baseDefaults"])
957
+ if (s[o] === void 0 || s[o] === null || typeof s[o] != "object" || Array.isArray(s[o]))
945
958
  throw new Error(
946
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${i} must be a plain object`
959
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${o} must be a plain object`
947
960
  );
948
961
  if (s.panelSettings === void 0 || s.panelSettings === null || typeof s.panelSettings != "object" || Array.isArray(s.panelSettings))
949
962
  throw new Error(
@@ -959,15 +972,15 @@ function Q(e, t, n) {
959
972
  throw new Error(
960
973
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode must be false or a plain object`
961
974
  );
962
- const i = r.colorMode;
963
- for (const o of ["lightScheme", "darkScheme"])
964
- if (typeof i[o] != "string" || i[o].length === 0)
975
+ const o = r.colorMode;
976
+ for (const l of ["lightScheme", "darkScheme"])
977
+ if (typeof o[l] != "string" || o[l].length === 0)
965
978
  throw new Error(
966
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${o} must be a non-empty string`
979
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${l} must be a non-empty string`
967
980
  );
968
- if (i.defaultMode !== "light" && i.defaultMode !== "dark")
981
+ if (o.defaultMode !== "light" && o.defaultMode !== "dark")
969
982
  throw new Error(
970
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(i.defaultMode)})`
983
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(o.defaultMode)})`
971
984
  );
972
985
  }
973
986
  if (s.semanticDefaults !== void 0) {
@@ -975,37 +988,37 @@ function Q(e, t, n) {
975
988
  throw new Error(
976
989
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults must be a plain object`
977
990
  );
978
- const i = s.semanticDefaults;
979
- for (const [o, c] of Object.entries(i))
980
- if (!X(c))
991
+ const o = s.semanticDefaults;
992
+ for (const [l, i] of Object.entries(o))
993
+ if (!X(i))
981
994
  throw new Error(
982
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${o}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(c)}`
995
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${l}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(i)}`
983
996
  );
984
997
  }
985
- const l = t.tiers.find((i) => {
986
- if (i.referencesTier !== void 0 || i.semantic === !0) return !1;
987
- const o = i.items;
988
- if (!Array.isArray(o) || o.length === 0) return !1;
989
- const c = o[0];
990
- if (c === null || typeof c != "object" || Array.isArray(c)) return !1;
991
- const g = c.type;
992
- return g === null || typeof g != "object" || Array.isArray(g) ? !1 : g.kind === "color";
998
+ const a = t.tiers.find((o) => {
999
+ if (o.referencesTier !== void 0 || o.semantic === !0) return !1;
1000
+ const l = o.items;
1001
+ if (!Array.isArray(l) || l.length === 0) return !1;
1002
+ const i = l[0];
1003
+ if (i === null || typeof i != "object" || Array.isArray(i)) return !1;
1004
+ const f = i.type;
1005
+ return f === null || typeof f != "object" || Array.isArray(f) ? !1 : f.kind === "color";
993
1006
  });
994
- if (l) {
995
- const i = l.id, o = l.items, c = o[0]?.cssVar;
996
- if (c !== void 0) {
997
- const g = c.replace(/\d+$/, "{n}");
998
- if (g.includes("{n}"))
999
- for (let p = 0; p < o.length; p++) {
1000
- const m = o[p], C = g.replace("{n}", String(p));
1007
+ if (a) {
1008
+ const o = a.id, l = a.items, i = l[0]?.cssVar;
1009
+ if (i !== void 0) {
1010
+ const f = i.replace(/\d+$/, "{n}");
1011
+ if (f.includes("{n}"))
1012
+ for (let u = 0; u < l.length; u++) {
1013
+ const m = l[u], C = f.replace("{n}", String(u));
1001
1014
  if (m.cssVar !== C)
1002
1015
  throw new Error(
1003
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${i}"].items[${p}].cssVar is ${JSON.stringify(m.cssVar)} but expected ${JSON.stringify(C)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(g)})`
1016
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${o}"].items[${u}].cssVar is ${JSON.stringify(m.cssVar)} but expected ${JSON.stringify(C)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(f)})`
1004
1017
  );
1005
1018
  }
1006
- else if (o.length > 1)
1019
+ else if (l.length > 1)
1007
1020
  throw new Error(
1008
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${i}"].items[0].cssVar ${JSON.stringify(c)} has no trailing digit — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (e.g. "--pal-0" … "--pal-15")`
1021
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${o}"].items[0].cssVar ${JSON.stringify(i)} has no trailing digit — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (e.g. "--pal-0" … "--pal-15")`
1009
1022
  );
1010
1023
  }
1011
1024
  }
@@ -1034,14 +1047,14 @@ function Q(e, t, n) {
1034
1047
  `[design-token-panel] PanelConfig.tabs["${e}"].notesExtras must only be set on a tab with id "notes"`
1035
1048
  );
1036
1049
  }
1037
- function I(e = j()) {
1050
+ function I(e = T()) {
1038
1051
  return e.applyRouting ?? {};
1039
1052
  }
1040
- function Me(e = j()) {
1053
+ function ze(e = T()) {
1041
1054
  return !!e.applyEndpoint && Object.keys(I(e)).length > 0;
1042
1055
  }
1043
1056
  function De(e) {
1044
- const t = T();
1057
+ const t = j();
1045
1058
  if (t === null) {
1046
1059
  h().pendingColorPresets = e;
1047
1060
  return;
@@ -1051,15 +1064,15 @@ function De(e) {
1051
1064
  export {
1052
1065
  D as A,
1053
1066
  _ as B,
1054
- x as C,
1067
+ S as C,
1055
1068
  Ne as D,
1056
1069
  I as E,
1057
- Me as F,
1058
- xe as G,
1059
- Se as H,
1070
+ ze as F,
1071
+ Se as G,
1072
+ xe as H,
1060
1073
  Ae as I,
1061
1074
  Ve as J,
1062
- oe as K,
1075
+ ie as K,
1063
1076
  ae as L,
1064
1077
  Re as M,
1065
1078
  le as N,
@@ -1067,30 +1080,30 @@ export {
1067
1080
  Oe as P,
1068
1081
  be as Q,
1069
1082
  ce as _,
1070
- Te as a,
1071
- ze as b,
1083
+ je as a,
1084
+ Me as b,
1072
1085
  se as c,
1073
1086
  ke as d,
1074
1087
  $e as e,
1075
1088
  we as f,
1076
- j as g,
1089
+ T as g,
1077
1090
  me as h,
1078
1091
  Ke as i,
1079
- je as j,
1080
- he as k,
1081
- ye as l,
1092
+ Te as j,
1093
+ te as k,
1094
+ ne as l,
1082
1095
  _e as m,
1083
1096
  de as n,
1084
- pe as o,
1085
- te as p,
1086
- ne as q,
1087
- ie as r,
1097
+ he as o,
1098
+ ye as p,
1099
+ ge as q,
1100
+ oe as r,
1088
1101
  De as s,
1089
- Ce as t,
1090
- ve as u,
1102
+ pe as t,
1103
+ Ce as u,
1091
1104
  Ee as v,
1092
- Pe as w,
1093
- re as x,
1094
- ge as y,
1105
+ ve as w,
1106
+ Pe as x,
1107
+ re as y,
1095
1108
  ue as z
1096
1109
  };