@takazudo/zdtp 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,68 +3,68 @@ class w extends Error {
3
3
  super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, w.prototype);
4
4
  }
5
5
  }
6
- function E(e, t) {
6
+ function A(e, t) {
7
7
  return e.tiers.find((n) => n.id === t);
8
8
  }
9
9
  function $(e, t) {
10
10
  return e.items.find((n) => n.id === t);
11
11
  }
12
- function G(e, t, n, l) {
13
- const g = E(e, t);
12
+ function Y(e, t, n, a) {
13
+ const g = A(e, t);
14
14
  if (!g)
15
15
  throw new w(
16
- `Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((a) => a.id).join(", ")}.`
16
+ `Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((l) => l.id).join(", ")}.`
17
17
  );
18
18
  const c = $(g, n);
19
19
  if (!c)
20
20
  throw new w(
21
21
  `Item "${n}" not found in tier "${t}" of tab "${e.id}".`
22
22
  );
23
- const i = l[t]?.[n];
23
+ const s = a[t]?.[n];
24
24
  if (g.referencesTier !== void 0) {
25
- const a = g.referencesTier, f = E(e, a);
25
+ const l = g.referencesTier, f = A(e, l);
26
26
  if (!f)
27
27
  throw new w(
28
- `Tier "${t}" declares referencesTier "${a}" but that tier does not exist in tab "${e.id}".`
28
+ `Tier "${t}" declares referencesTier "${l}" but that tier does not exist in tab "${e.id}".`
29
29
  );
30
- const o = $(f, i ?? n);
31
- if (!o) {
32
- const d = $(f, c.default) ?? $(f, n) ?? f.items[0];
33
- if (!d)
30
+ const i = $(f, s ?? n);
31
+ if (!i) {
32
+ const u = $(f, c.default) ?? $(f, n) ?? f.items[0];
33
+ if (!u)
34
34
  throw new w(
35
- `Referenced tier "${a}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
35
+ `Referenced tier "${l}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
36
36
  );
37
- return { kind: "ref", targetCssVar: d.cssVar };
37
+ return { kind: "ref", targetCssVar: u.cssVar };
38
38
  }
39
- return { kind: "ref", targetCssVar: o.cssVar };
39
+ return { kind: "ref", targetCssVar: i.cssVar };
40
40
  }
41
- return i !== void 0 ? c.pill && i === c.pill.value ? { kind: "literal", value: c.pill.value } : { kind: "literal", value: i } : c.pill ? { kind: "literal", value: c.pill.customDefault } : { kind: "literal", value: c.default };
41
+ return s !== void 0 ? c.pill && s === c.pill.value ? { kind: "literal", value: c.pill.value } : { kind: "literal", value: s } : c.pill ? { kind: "literal", value: c.pill.customDefault } : { kind: "literal", value: c.default };
42
42
  }
43
- function U(e) {
43
+ function Z(e) {
44
44
  return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
45
45
  }
46
- function _(e, t, n = [t]) {
47
- const l = e.tab === void 0 || e.tab === t.id ? t : n.find((s) => s.id === e.tab);
48
- if (!l)
46
+ function M(e, t, n = [t]) {
47
+ const a = e.tab === void 0 || e.tab === t.id ? t : n.find((o) => o.id === e.tab);
48
+ if (!a)
49
49
  throw new w(
50
- `Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((s) => s.id).join(", ")}.`
50
+ `Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((o) => o.id).join(", ")}.`
51
51
  );
52
- const g = E(l, e.tier);
52
+ const g = A(a, e.tier);
53
53
  if (!g)
54
54
  throw new w(
55
- `Cross-tab ref target tier "${e.tier}" not found in tab "${l.id}". Available tiers: ${l.tiers.map((s) => s.id).join(", ")}.`
55
+ `Cross-tab ref target tier "${e.tier}" not found in tab "${a.id}". Available tiers: ${a.tiers.map((o) => o.id).join(", ")}.`
56
56
  );
57
57
  const c = $(g, e.item);
58
58
  if (!c)
59
59
  throw new w(
60
- `Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${l.id}". Available items: ${g.items.map((s) => s.id).join(", ")}.`
60
+ `Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${a.id}". Available items: ${g.items.map((o) => o.id).join(", ")}.`
61
61
  );
62
62
  return c.cssVar;
63
63
  }
64
- function W(e, t) {
64
+ function X(e, t) {
65
65
  return e.paletteCssVarTemplate.replace("{n}", String(t));
66
66
  }
67
- const M = /* @__PURE__ */ new Set([
67
+ const N = /* @__PURE__ */ new Set([
68
68
  "aliceblue",
69
69
  "antiquewhite",
70
70
  "aqua",
@@ -221,39 +221,39 @@ const M = /* @__PURE__ */ new Set([
221
221
  "revert",
222
222
  "revert-layer"
223
223
  ]);
224
- function H(e) {
225
- return e.startsWith("#") || e.includes("(") || M.has(e.toLowerCase());
224
+ function z(e) {
225
+ return e.startsWith("#") || e.includes("(") || N.has(e.toLowerCase());
226
226
  }
227
- function N(e, t, n, l) {
227
+ function H(e, t, n, a) {
228
228
  const g = [], c = e.indexOf(":");
229
229
  if (c !== -1) {
230
- const i = e.slice(0, c), a = e.slice(c + 1), f = t.find((r) => r.tier === i);
231
- f && g.push({ tab: f.tab, tier: f.tier, item: a });
230
+ const s = e.slice(0, c), l = e.slice(c + 1), f = t.find((r) => r.tier === s);
231
+ f && g.push({ tab: f.tab, tier: f.tier, item: l });
232
232
  }
233
- const [s] = t;
234
- g.push({ tab: s.tab, tier: s.tier, item: e });
235
- for (const i of g)
233
+ const [o] = t;
234
+ g.push({ tab: o.tab, tier: o.tier, item: e });
235
+ for (const s of g)
236
236
  try {
237
- return _(i, n, l), { ref: i };
237
+ return M(s, n, a), { ref: s };
238
238
  } catch {
239
239
  }
240
240
  return { ref: g[0] };
241
241
  }
242
- function K(e, t, n, l, g, c) {
243
- const s = t.get(e.default);
244
- return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !H(e.default) ? N(e.default, n, l, g) : c ? (console.warn(
242
+ function K(e, t, n, a, g, c) {
243
+ const o = t.get(e.default);
244
+ return o !== void 0 ? o : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !z(e.default) ? H(e.default, n, a, g) : c ? (console.warn(
245
245
  `[design-token-panel] semantic item "${e.id}" default "${e.default}" names no palette item; falling back to palette index 0`
246
246
  ), 0) : { literal: e.default };
247
247
  }
248
- function R(e, t = [e]) {
248
+ function V(e, t = [e]) {
249
249
  const n = e.colorExtras;
250
250
  if (!n) return;
251
- const l = e.tiers.find(
252
- (o) => !o.referencesTier && !o.semantic && o.items.length > 0 && o.items[0].type.kind === "color"
251
+ const a = e.tiers.find(
252
+ (i) => !i.referencesTier && !i.semantic && i.items.length > 0 && i.items[0].type.kind === "color"
253
253
  ), g = e.tiers.find(
254
- (o) => l && o.referencesTier === l.id || o.semantic === !0
254
+ (i) => a && i.referencesTier === a.id || i.semantic === !0
255
255
  );
256
- if (!l && !g)
256
+ if (!a && !g)
257
257
  return {
258
258
  id: n.id,
259
259
  label: n.label,
@@ -267,28 +267,28 @@ function R(e, t = [e]) {
267
267
  colorSchemes: n.colorSchemes,
268
268
  panelSettings: n.panelSettings
269
269
  };
270
- const c = l?.items ?? [], s = c.length, i = c[0] ? c[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", a = /* @__PURE__ */ new Map();
271
- for (let o = 0; o < c.length; o++)
272
- a.set(c[o].id, o);
270
+ const c = a?.items ?? [], o = c.length, s = c[0] ? c[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", l = /* @__PURE__ */ new Map();
271
+ for (let i = 0; i < c.length; i++)
272
+ l.set(c[i].id, i);
273
273
  const f = {}, r = {};
274
274
  if (g) {
275
- const o = !g.semantic;
275
+ const i = !g.semantic, u = n.semanticDefaults;
276
276
  for (const d of g.items)
277
- r[d.id] = d.cssVar, f[d.id] = K(
277
+ r[d.id] = d.cssVar, f[d.id] = u && d.id in u ? u[d.id] : K(
278
278
  d,
279
- a,
279
+ l,
280
280
  g.referencesRamps,
281
281
  e,
282
282
  t,
283
- o
283
+ i
284
284
  );
285
285
  }
286
286
  return {
287
287
  id: n.id,
288
288
  label: n.label,
289
- paletteSize: s,
289
+ paletteSize: o,
290
290
  baseRoles: n.baseRoles,
291
- paletteCssVarTemplate: i,
291
+ paletteCssVarTemplate: s,
292
292
  semanticDefaults: f,
293
293
  semanticCssNames: r,
294
294
  baseDefaults: n.baseDefaults,
@@ -297,34 +297,34 @@ function R(e, t = [e]) {
297
297
  panelSettings: n.panelSettings
298
298
  };
299
299
  }
300
- function Y(e) {
300
+ function Q(e) {
301
301
  const t = e.find((n) => n.id === "color");
302
302
  if (t)
303
- return R(t, e);
303
+ return V(t, e);
304
304
  }
305
- function z(e) {
305
+ function L(e) {
306
306
  const t = e.find((n) => n.id === "color-secondary");
307
- return t ? R(t, e) ?? null : null;
307
+ return t ? V(t, e) ?? null : null;
308
308
  }
309
- function A(e, t) {
309
+ function S(e, t) {
310
310
  if (Object.is(e, t)) return !0;
311
311
  if (e === null || t === null || typeof e != typeof t || typeof e != "object") return !1;
312
312
  if (Array.isArray(e)) {
313
313
  if (!Array.isArray(t) || e.length !== t.length) return !1;
314
314
  for (let c = 0; c < e.length; c++)
315
- if (!A(e[c], t[c])) return !1;
315
+ if (!S(e[c], t[c])) return !1;
316
316
  return !0;
317
317
  }
318
318
  if (Array.isArray(t)) return !1;
319
- const n = Object.keys(e), l = Object.keys(t);
320
- if (n.length !== l.length) return !1;
321
- const g = new Set(l);
319
+ const n = Object.keys(e), a = Object.keys(t);
320
+ if (n.length !== a.length) return !1;
321
+ const g = new Set(a);
322
322
  for (const c of n)
323
- if (!g.has(c) || !A(e[c], t[c]))
323
+ if (!g.has(c) || !S(e[c], t[c]))
324
324
  return !1;
325
325
  return !0;
326
326
  }
327
- const V = {
327
+ const _ = {
328
328
  storagePrefix: "zudo-design-token-panel",
329
329
  consoleNamespace: "zudo",
330
330
  modalClassPrefix: "zudo-design-token-panel-modal",
@@ -336,33 +336,34 @@ const V = {
336
336
  // No bundled apply endpoint / routing — hosts wire their own.
337
337
  applyEndpoint: void 0,
338
338
  applyRouting: void 0
339
- }, j = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:singleton");
340
- function y() {
339
+ }, R = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:singleton");
340
+ function m() {
341
341
  const e = globalThis;
342
- let t = e[j];
342
+ let t = e[R];
343
343
  return t || (t = {
344
344
  instances: /* @__PURE__ */ new Map(),
345
345
  defaultPrefix: null,
346
346
  pendingColorPresets: null,
347
347
  pendingPostConfigureHooks: [],
348
- lifecycleHooks: {}
349
- }, e[j] = t), t;
348
+ lifecycleHooks: {},
349
+ colorSchemeOwners: /* @__PURE__ */ new Set()
350
+ }, e[R] = t), t;
350
351
  }
351
- function D(e) {
352
+ function F(e) {
352
353
  return {
353
354
  instanceId: e,
354
355
  open() {
355
- y().lifecycleHooks.open?.(e);
356
+ m().lifecycleHooks.open?.(e);
356
357
  },
357
358
  close() {
358
- y().lifecycleHooks.close?.(e);
359
+ m().lifecycleHooks.close?.(e);
359
360
  },
360
361
  toggle() {
361
- y().lifecycleHooks.toggle?.(e);
362
+ m().lifecycleHooks.toggle?.(e);
362
363
  },
363
364
  destroy() {
364
- y().lifecycleHooks.destroy?.(e);
365
- const t = y();
365
+ m().lifecycleHooks.destroy?.(e);
366
+ const t = m();
366
367
  if (t.instances.delete(e), t.defaultPrefix === e) {
367
368
  const n = [...t.instances.keys()];
368
369
  t.defaultPrefix = n.length > 0 ? n[n.length - 1] : null;
@@ -371,7 +372,7 @@ function D(e) {
371
372
  };
372
373
  }
373
374
  function I(e) {
374
- y().lifecycleHooks = {
375
+ m().lifecycleHooks = {
375
376
  configured: e.configured,
376
377
  open: e.open,
377
378
  close: e.close,
@@ -379,110 +380,140 @@ function I(e) {
379
380
  destroy: e.destroy
380
381
  };
381
382
  }
382
- function X(e) {
383
- const t = y(), n = e.storagePrefix, l = t.instances.get(n);
384
- if (l) {
383
+ function ee(e) {
384
+ const t = m(), n = e.storagePrefix, a = t.instances.get(n);
385
+ if (a) {
385
386
  const f = (r) => ({ ...r, applySink: void 0 });
386
- if (A(f(l.suppliedConfig), f(e)))
387
- return t.defaultPrefix = n, l.handle;
387
+ if (S(f(a.suppliedConfig), f(e)))
388
+ return t.defaultPrefix = n, a.handle;
388
389
  throw new Error(
389
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.)`
390
391
  );
391
392
  }
392
393
  const g = t.pendingColorPresets, c = g ? { ...e, colorPresets: g } : { ...e };
393
394
  t.pendingColorPresets = null;
394
- const s = t.instances.size === 0, i = s ? [...t.pendingPostConfigureHooks] : [];
395
- s && (t.pendingPostConfigureHooks.length = 0);
396
- const a = {
395
+ const o = t.instances.size === 0, s = o ? [...t.pendingPostConfigureHooks] : [];
396
+ o && (t.pendingPostConfigureHooks.length = 0);
397
+ const l = {
397
398
  config: c,
398
399
  // Snapshot the as-supplied config before any runtime merges. Used by the
399
400
  // idempotency guard so view-transition re-calls with the original inline
400
401
  // config keep passing even after setPanelColorPresets mutates `config`.
401
402
  suppliedConfig: { ...e },
402
403
  pendingColorPresets: null,
403
- postConfigureHooks: i,
404
- handle: D(n)
404
+ postConfigureHooks: s,
405
+ handle: F(n)
405
406
  };
406
- t.instances.set(n, a), t.defaultPrefix = n;
407
- for (const f of a.postConfigureHooks)
407
+ t.instances.set(n, l), t.defaultPrefix = n;
408
+ for (const f of l.postConfigureHooks)
408
409
  f();
409
- return t.lifecycleHooks.configured?.(n), a.handle;
410
+ return t.lifecycleHooks.configured?.(n), l.handle;
410
411
  }
411
412
  function x() {
412
- const e = y();
413
+ const e = m();
413
414
  return e.defaultPrefix === null ? null : e.instances.get(e.defaultPrefix) ?? null;
414
415
  }
415
- function Q(e) {
416
+ function te(e) {
416
417
  const t = x();
417
418
  if (t === null) {
418
- const n = y();
419
+ const n = m();
419
420
  if (n.pendingPostConfigureHooks.includes(e)) return;
420
421
  n.pendingPostConfigureHooks.push(e);
421
422
  return;
422
423
  }
423
424
  t.postConfigureHooks.includes(e) || (t.postConfigureHooks.push(e), e());
424
425
  }
425
- function O() {
426
- return x()?.config ?? V;
426
+ function D() {
427
+ return x()?.config ?? _;
427
428
  }
428
- function Z() {
429
- return [...y().instances.values()].map((e) => e.config);
429
+ function ne() {
430
+ return [...m().instances.values()].map((e) => e.config);
430
431
  }
431
- function ee(e) {
432
- return y().instances.get(e)?.config ?? null;
432
+ function re(e) {
433
+ return m().instances.get(e)?.config ?? null;
433
434
  }
434
- function te() {
435
- const e = y();
436
- e.instances.clear(), e.defaultPrefix = null, e.pendingColorPresets = null, e.pendingPostConfigureHooks.length = 0;
435
+ function ie() {
436
+ const e = m();
437
+ e.instances.clear(), e.defaultPrefix = null, e.pendingColorPresets = null, e.pendingPostConfigureHooks.length = 0, v().clear();
437
438
  }
438
- function ne(e = O()) {
439
- return z(e.tabs);
439
+ function v() {
440
+ const e = m();
441
+ return e.colorSchemeOwners || (e.colorSchemeOwners = /* @__PURE__ */ new Set()), e.colorSchemeOwners;
440
442
  }
441
- function re(e) {
443
+ function oe(e) {
444
+ v().add(e);
445
+ }
446
+ function se(e) {
447
+ v().delete(e);
448
+ }
449
+ function ae(e) {
450
+ return v().has(e);
451
+ }
452
+ function le(e = D()) {
453
+ return L(e.tabs);
454
+ }
455
+ function fe(e) {
442
456
  return `${e.storagePrefix}-state-v2`;
443
457
  }
444
- function ie(e) {
458
+ function ce(e) {
445
459
  return `${e.storagePrefix}-state-v3`;
446
460
  }
447
- function oe(e) {
461
+ function ge(e) {
462
+ return `${e.storagePrefix}-state-v4`;
463
+ }
464
+ function ue(e) {
448
465
  return `${e.storagePrefix}-state`;
449
466
  }
450
- function se(e) {
467
+ function de(e) {
451
468
  return `${e.storagePrefix}-open`;
452
469
  }
453
- function ae(e) {
470
+ function pe(e) {
454
471
  return `${e.storagePrefix}-position`;
455
472
  }
456
- function le(e) {
473
+ function ye(e) {
457
474
  return `${e.storagePrefix}-size`;
458
475
  }
459
- function fe(e) {
476
+ function me(e) {
460
477
  return `${e.storagePrefix}-density`;
461
478
  }
462
- function ce(e) {
479
+ function he(e) {
463
480
  return `${e.storagePrefix}:visible`;
464
481
  }
465
- function ge(e) {
482
+ function be(e) {
466
483
  return `${e.storagePrefix}:autoload`;
467
484
  }
468
- function de(e) {
485
+ function we(e) {
469
486
  return `${e.storagePrefix}-root`;
470
487
  }
471
- const F = V.storagePrefix, q = "toggle-design-token-panel";
472
- function ue(e) {
473
- return e.storagePrefix === F ? q : e.toggleEvent ?? `toggle-${e.storagePrefix}`;
488
+ const J = _.storagePrefix, q = "toggle-design-token-panel";
489
+ function ke(e) {
490
+ return e.storagePrefix === J ? q : e.toggleEvent ?? `toggle-${e.storagePrefix}`;
474
491
  }
475
- const L = "__zdtp:open-state-changed";
476
- function pe(e) {
477
- return `${L}:${e.storagePrefix}`;
492
+ const G = "__zdtp:open-state-changed";
493
+ function $e(e) {
494
+ return `${G}:${e.storagePrefix}`;
478
495
  }
479
- function ye(e, t) {
496
+ function Pe(e, t) {
480
497
  return `${e.modalClassPrefix}${t}`;
481
498
  }
482
- function me(e) {
499
+ function Ce(e) {
483
500
  return `${e.exportFilenameBase}.json`;
484
501
  }
485
- function he(e) {
502
+ const O = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:global-alias-marker");
503
+ function Ee(e) {
504
+ if (typeof window > "u") return;
505
+ const t = window, n = t.zdtp;
506
+ if (n !== void 0) {
507
+ if ((typeof n == "object" || typeof n == "function") && n !== null && n[O] === !0) return;
508
+ console.warn(
509
+ "[design-token-panel] window.zdtp already exists and was not installed by this package. Skipping the zdtp.show() / zdtp.hide() / zdtp.toggle() global alias to avoid clobbering it. Use window[consoleNamespace].* or the configurePanel(cfg) handle instead."
510
+ );
511
+ return;
512
+ }
513
+ const a = { ...e };
514
+ a[O] = !0, t.zdtp = a;
515
+ }
516
+ function ve(e) {
486
517
  if (e === null || typeof e != "object" || Array.isArray(e))
487
518
  throw new Error("[design-token-panel] PanelConfig must be a non-null object");
488
519
  const t = e;
@@ -497,7 +528,7 @@ function he(e) {
497
528
  throw new Error(
498
529
  `[design-token-panel] PanelConfig.${n} must be a non-empty string (got ${typeof t[n]})`
499
530
  );
500
- if (J(t.tabs), t.toggleEvent !== void 0 && (typeof t.toggleEvent != "string" || t.toggleEvent.length === 0))
531
+ if (B(t.tabs), t.toggleEvent !== void 0 && (typeof t.toggleEvent != "string" || t.toggleEvent.length === 0))
501
532
  throw new Error(
502
533
  `[design-token-panel] PanelConfig.toggleEvent must be a non-empty string when set (got ${typeof t.toggleEvent})`
503
534
  );
@@ -508,8 +539,8 @@ function he(e) {
508
539
  if (t.applyRouting !== void 0) {
509
540
  if (t.applyRouting === null || typeof t.applyRouting != "object" || Array.isArray(t.applyRouting))
510
541
  throw new Error("[design-token-panel] PanelConfig.applyRouting must be a plain object");
511
- for (const [n, l] of Object.entries(t.applyRouting))
512
- if (typeof l != "string")
542
+ for (const [n, a] of Object.entries(t.applyRouting))
543
+ if (typeof a != "string")
513
544
  throw new Error(
514
545
  `[design-token-panel] PanelConfig.applyRouting[${JSON.stringify(n)}] must be a string`
515
546
  );
@@ -517,87 +548,106 @@ function he(e) {
517
548
  if (t.legacyIdRenameMap !== void 0) {
518
549
  if (t.legacyIdRenameMap === null || typeof t.legacyIdRenameMap != "object" || Array.isArray(t.legacyIdRenameMap))
519
550
  throw new Error("[design-token-panel] PanelConfig.legacyIdRenameMap must be a plain object");
520
- for (const [n, l] of Object.entries(t.legacyIdRenameMap))
521
- if (l !== null && typeof l != "string")
551
+ for (const [n, a] of Object.entries(t.legacyIdRenameMap))
552
+ if (a !== null && typeof a != "string")
522
553
  throw new Error(
523
- `[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof l})`
554
+ `[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof a})`
524
555
  );
525
556
  }
526
557
  }
527
- function J(e) {
558
+ function B(e) {
528
559
  if (!Array.isArray(e))
529
560
  throw new Error("[design-token-panel] PanelConfig.tabs must be an array");
530
561
  const t = /* @__PURE__ */ new Set();
531
562
  for (const n of e) {
532
563
  if (n === null || typeof n != "object" || Array.isArray(n))
533
564
  throw new Error("[design-token-panel] PanelConfig.tabs: each tab must be a non-null object");
534
- const l = n;
535
- if (typeof l.id != "string" || l.id.length === 0)
565
+ const a = n;
566
+ if (typeof a.id != "string" || a.id.length === 0)
536
567
  throw new Error("[design-token-panel] PanelConfig.tabs: each tab must have a non-empty string id");
537
- if (t.has(l.id))
568
+ if (t.has(a.id))
538
569
  throw new Error(
539
- `[design-token-panel] PanelConfig.tabs: duplicate tab id "${l.id}"`
570
+ `[design-token-panel] PanelConfig.tabs: duplicate tab id "${a.id}"`
540
571
  );
541
- t.add(l.id), B(l.id, l, e);
572
+ t.add(a.id), W(a.id, a, e);
542
573
  }
543
574
  }
544
- function B(e, t, n) {
575
+ function U(e) {
576
+ if (typeof e == "number" || e === "bg" || e === "fg") return !0;
577
+ if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
578
+ const t = e;
579
+ if ("literal" in t) {
580
+ const n = t.literal;
581
+ if (typeof n == "string") return !0;
582
+ if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
583
+ const a = n;
584
+ return typeof a.light == "string" && typeof a.dark == "string";
585
+ }
586
+ if ("ref" in t) {
587
+ const n = t.ref;
588
+ if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
589
+ const a = n;
590
+ return !(typeof a.tier != "string" || typeof a.item != "string" || a.tab !== void 0 && typeof a.tab != "string");
591
+ }
592
+ return !1;
593
+ }
594
+ function W(e, t, n) {
545
595
  if (!Array.isArray(t.tiers))
546
596
  throw new Error(
547
597
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers must be an array`
548
598
  );
549
- const l = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
550
- for (const s of t.tiers) {
551
- if (s === null || typeof s != "object" || Array.isArray(s))
599
+ const a = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
600
+ for (const o of t.tiers) {
601
+ if (o === null || typeof o != "object" || Array.isArray(o))
552
602
  throw new Error(
553
603
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must be a non-null object`
554
604
  );
555
- const i = s;
556
- if (typeof i.id != "string" || i.id.length === 0)
605
+ const s = o;
606
+ if (typeof s.id != "string" || s.id.length === 0)
557
607
  throw new Error(
558
608
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must have a non-empty string id`
559
609
  );
560
- if (l.has(i.id))
610
+ if (a.has(s.id))
561
611
  throw new Error(
562
- `[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${i.id}"`
612
+ `[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${s.id}"`
563
613
  );
564
- if (l.add(i.id), i.semantic !== void 0 && i.semantic !== !0)
614
+ if (a.add(s.id), s.semantic !== void 0 && s.semantic !== !0)
565
615
  throw new Error(
566
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${i.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(i.semantic)})`
616
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(s.semantic)})`
567
617
  );
568
- if (!Array.isArray(i.items))
618
+ if (!Array.isArray(s.items))
569
619
  throw new Error(
570
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${i.id}"].items must be an array`
620
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"].items must be an array`
571
621
  );
572
- let a;
573
- for (const f of i.items) {
622
+ let l;
623
+ for (const f of s.items) {
574
624
  if (f === null || typeof f != "object" || Array.isArray(f)) continue;
575
- const o = f.type;
576
- if (o === null || typeof o != "object" || Array.isArray(o)) continue;
577
- const d = o.kind;
578
- if (typeof d == "string") {
579
- if (a === void 0)
580
- a = d;
581
- else if (a !== d)
625
+ const i = f.type;
626
+ if (i === null || typeof i != "object" || Array.isArray(i)) continue;
627
+ const u = i.kind;
628
+ if (typeof u == "string") {
629
+ if (l === void 0)
630
+ l = u;
631
+ else if (l !== u)
582
632
  throw new Error(
583
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${i.id}"]: mixed item kinds — found "${a}" and "${d}" in the same tier (all items must share the same kind)`
633
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"]: mixed item kinds — found "${l}" and "${u}" in the same tier (all items must share the same kind)`
584
634
  );
585
635
  }
586
636
  }
587
- a !== void 0 && g.set(i.id, a);
637
+ l !== void 0 && g.set(s.id, l);
588
638
  }
589
639
  const c = /* @__PURE__ */ new Set();
590
- for (const s of t.tiers) {
591
- const i = s, a = i.id;
592
- for (const f of i.items) {
640
+ for (const o of t.tiers) {
641
+ const s = o, l = s.id;
642
+ for (const f of s.items) {
593
643
  if (f === null || typeof f != "object" || Array.isArray(f))
594
644
  throw new Error(
595
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].items: each item must be a non-null object`
645
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items: each item must be a non-null object`
596
646
  );
597
647
  const r = f;
598
648
  if (typeof r.id != "string" || r.id.length === 0)
599
649
  throw new Error(
600
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].items: each item must have a non-empty string id`
650
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items: each item must have a non-empty string id`
601
651
  );
602
652
  if (c.has(r.id))
603
653
  throw new Error(
@@ -605,220 +655,280 @@ function B(e, t, n) {
605
655
  );
606
656
  if (c.add(r.id), typeof r.cssVar != "string" || !r.cssVar.startsWith("--"))
607
657
  throw new Error(
608
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].items["${r.id}"].cssVar must start with "--" (got ${JSON.stringify(r.cssVar)})`
658
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].cssVar must start with "--" (got ${JSON.stringify(r.cssVar)})`
609
659
  );
610
660
  if (r.cssVar.length <= 2)
611
661
  throw new Error(
612
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].items["${r.id}"].cssVar must be non-empty after "--"`
662
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].cssVar must be non-empty after "--"`
613
663
  );
664
+ const i = r.type;
665
+ if (i !== null && typeof i == "object" && !Array.isArray(i) && i.kind === "length" && i.units !== void 0) {
666
+ const u = i.units;
667
+ if (!Array.isArray(u))
668
+ throw new Error(
669
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units must be an array`
670
+ );
671
+ const d = /* @__PURE__ */ new Set();
672
+ for (const p of u) {
673
+ if (typeof p != "string" || p.length === 0)
674
+ throw new Error(
675
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(p)})`
676
+ );
677
+ if (d.has(p))
678
+ throw new Error(
679
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units: duplicate unit ${JSON.stringify(p)}`
680
+ );
681
+ d.add(p);
682
+ }
683
+ }
614
684
  }
615
685
  }
616
- for (const s of t.tiers) {
617
- const i = s, a = i.id;
618
- if (i.referencesTier !== void 0) {
619
- if (typeof i.referencesTier != "string")
686
+ for (const o of t.tiers) {
687
+ const s = o, l = s.id;
688
+ if (s.referencesTier !== void 0) {
689
+ if (typeof s.referencesTier != "string")
620
690
  throw new Error(
621
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesTier must be a string`
691
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier must be a string`
622
692
  );
623
- const f = i.referencesTier;
624
- if (!l.has(f))
693
+ const f = s.referencesTier;
694
+ if (!a.has(f))
625
695
  throw new Error(
626
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesTier: tier "${f}" does not exist in this tab`
696
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: tier "${f}" does not exist in this tab`
627
697
  );
628
- const r = g.get(a), o = g.get(f);
629
- if (r !== void 0 && o !== void 0 && r !== "text" && r !== o)
698
+ const r = g.get(l), i = g.get(f);
699
+ if (r !== void 0 && i !== void 0 && r !== "text" && r !== i)
630
700
  throw new Error(
631
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesTier: referencing tier has kind "${r}" but referenced tier "${f}" has kind "${o}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
701
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: referencing tier has kind "${r}" but referenced tier "${f}" has kind "${i}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
632
702
  );
633
703
  }
634
704
  }
635
- for (const s of t.tiers) {
636
- const i = s, a = i.id;
637
- if (i.referencesRamps === void 0) continue;
638
- if (i.semantic !== !0)
705
+ for (const o of t.tiers) {
706
+ const s = o, l = s.id;
707
+ if (s.referencesRamps === void 0) continue;
708
+ if (s.semantic !== !0)
639
709
  throw new Error(
640
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps is only valid on a tier with semantic: true`
710
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps is only valid on a tier with semantic: true`
641
711
  );
642
- if (!Array.isArray(i.referencesRamps))
712
+ if (!Array.isArray(s.referencesRamps))
643
713
  throw new Error(
644
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps must be an array`
714
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps must be an array`
645
715
  );
646
- const f = g.get(a), r = i.referencesRamps;
647
- for (let o = 0; o < r.length; o++) {
648
- const d = r[o];
649
- if (d === null || typeof d != "object" || Array.isArray(d))
716
+ const f = g.get(l), r = s.referencesRamps;
717
+ for (let i = 0; i < r.length; i++) {
718
+ const u = r[i];
719
+ if (u === null || typeof u != "object" || Array.isArray(u))
650
720
  throw new Error(
651
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps[${o}] must be a non-null object`
721
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}] must be a non-null object`
652
722
  );
653
- const u = d;
654
- if (typeof u.tier != "string" || u.tier.length === 0)
723
+ const d = u;
724
+ if (typeof d.tier != "string" || d.tier.length === 0)
655
725
  throw new Error(
656
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps[${o}].tier must be a non-empty string`
726
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tier must be a non-empty string`
657
727
  );
658
- if (u.tab !== void 0 && (typeof u.tab != "string" || u.tab.length === 0))
728
+ if (d.tab !== void 0 && (typeof d.tab != "string" || d.tab.length === 0))
659
729
  throw new Error(
660
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps[${o}].tab must be a non-empty string when set`
730
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tab must be a non-empty string when set`
661
731
  );
662
- const m = u.tab === void 0 ? e : u.tab;
732
+ const p = d.tab === void 0 ? e : d.tab;
663
733
  let k;
664
- if (m === e)
734
+ if (p === e)
665
735
  k = t;
666
736
  else {
667
737
  const b = n.find(
668
- (p) => p !== null && typeof p == "object" && !Array.isArray(p) && p.id === m
738
+ (y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === p
669
739
  );
670
740
  if (!b) {
671
- const p = n.filter((h) => h !== null && typeof h == "object" && !Array.isArray(h)).map((h) => h.id).join(", ");
741
+ const y = n.filter((h) => h !== null && typeof h == "object" && !Array.isArray(h)).map((h) => h.id).join(", ");
672
742
  throw new Error(
673
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps[${o}]: tab "${m}" does not exist. Available tabs: ${p}.`
743
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tab "${p}" does not exist. Available tabs: ${y}.`
674
744
  );
675
745
  }
676
746
  k = b;
677
747
  }
678
- const P = Array.isArray(k.tiers) ? k.tiers : [], S = [];
748
+ const P = Array.isArray(k.tiers) ? k.tiers : [], j = [];
679
749
  let C;
680
750
  for (const b of P) {
681
751
  if (b === null || typeof b != "object" || Array.isArray(b)) continue;
682
- const p = b;
683
- typeof p.id == "string" && (S.push(p.id), p.id === u.tier && (C = p));
752
+ const y = b;
753
+ typeof y.id == "string" && (j.push(y.id), y.id === d.tier && (C = y));
684
754
  }
685
755
  if (!C)
686
756
  throw new Error(
687
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps[${o}]: tier "${u.tier}" does not exist in tab "${m}". Available tiers: ${S.join(", ")}.`
757
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tier "${d.tier}" does not exist in tab "${p}". Available tiers: ${j.join(", ")}.`
688
758
  );
689
759
  if (f !== void 0) {
690
760
  const b = Array.isArray(C.items) ? C.items : [];
691
- let p;
761
+ let y;
692
762
  for (const h of b) {
693
763
  if (h === null || typeof h != "object" || Array.isArray(h)) continue;
694
- const v = h.type;
695
- if (v === null || typeof v != "object" || Array.isArray(v)) continue;
696
- const T = v.kind;
764
+ const E = h.type;
765
+ if (E === null || typeof E != "object" || Array.isArray(E)) continue;
766
+ const T = E.kind;
697
767
  if (typeof T == "string") {
698
- p = T;
768
+ y = T;
699
769
  break;
700
770
  }
701
771
  }
702
- if (p !== void 0 && f !== p)
772
+ if (y !== void 0 && f !== y)
703
773
  throw new Error(
704
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a}"].referencesRamps[${o}]: referencing semantic tier has kind "${f}" but target tier "${u.tier}" in tab "${m}" has kind "${p}" (cross-tab ramp sources must share the semantic tier's kind)`
774
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: referencing semantic tier has kind "${f}" but target tier "${d.tier}" in tab "${p}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
705
775
  );
706
776
  }
707
777
  }
708
778
  }
709
779
  if (t.colorExtras !== void 0) {
710
- const s = t.colorExtras;
711
- if (s === null || typeof s != "object" || Array.isArray(s))
780
+ const o = t.colorExtras;
781
+ if (o === null || typeof o != "object" || Array.isArray(o))
712
782
  throw new Error(
713
783
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras must be a plain object`
714
784
  );
715
785
  for (const r of ["id", "defaultShikiTheme"])
716
- if (typeof s[r] != "string" || s[r].length === 0)
786
+ if (typeof o[r] != "string" || o[r].length === 0)
717
787
  throw new Error(
718
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof s[r]})`
788
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof o[r]})`
719
789
  );
720
790
  for (const r of ["colorSchemes", "baseRoles", "baseDefaults"])
721
- if (s[r] === void 0 || s[r] === null || typeof s[r] != "object" || Array.isArray(s[r]))
791
+ if (o[r] === void 0 || o[r] === null || typeof o[r] != "object" || Array.isArray(o[r]))
722
792
  throw new Error(
723
793
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a plain object`
724
794
  );
725
- if (s.panelSettings === void 0 || s.panelSettings === null || typeof s.panelSettings != "object" || Array.isArray(s.panelSettings))
795
+ if (o.panelSettings === void 0 || o.panelSettings === null || typeof o.panelSettings != "object" || Array.isArray(o.panelSettings))
726
796
  throw new Error(
727
797
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings must be a plain object`
728
798
  );
729
- const i = s.panelSettings;
730
- if (typeof i.colorScheme != "string" || i.colorScheme.length === 0)
799
+ const s = o.panelSettings;
800
+ if (typeof s.colorScheme != "string" || s.colorScheme.length === 0)
731
801
  throw new Error(
732
802
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorScheme must be a non-empty string`
733
803
  );
734
- if (i.colorMode !== !1) {
735
- if (i.colorMode === null || typeof i.colorMode != "object" || Array.isArray(i.colorMode))
804
+ if (s.colorMode !== !1) {
805
+ if (s.colorMode === null || typeof s.colorMode != "object" || Array.isArray(s.colorMode))
736
806
  throw new Error(
737
807
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode must be false or a plain object`
738
808
  );
739
- const r = i.colorMode;
740
- for (const o of ["lightScheme", "darkScheme"])
741
- if (typeof r[o] != "string" || r[o].length === 0)
809
+ const r = s.colorMode;
810
+ for (const i of ["lightScheme", "darkScheme"])
811
+ if (typeof r[i] != "string" || r[i].length === 0)
742
812
  throw new Error(
743
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${o} must be a non-empty string`
813
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${i} must be a non-empty string`
744
814
  );
745
815
  if (r.defaultMode !== "light" && r.defaultMode !== "dark")
746
816
  throw new Error(
747
817
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(r.defaultMode)})`
748
818
  );
749
819
  }
820
+ if (o.semanticDefaults !== void 0) {
821
+ if (o.semanticDefaults === null || typeof o.semanticDefaults != "object" || Array.isArray(o.semanticDefaults))
822
+ throw new Error(
823
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults must be a plain object`
824
+ );
825
+ const r = o.semanticDefaults;
826
+ for (const [i, u] of Object.entries(r))
827
+ if (!U(u))
828
+ throw new Error(
829
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${i}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(u)}`
830
+ );
831
+ }
750
832
  const f = t.tiers.find((r) => {
751
833
  if (r.referencesTier !== void 0 || r.semantic === !0) return !1;
752
- const o = r.items;
753
- if (!Array.isArray(o) || o.length === 0) return !1;
754
- const d = o[0];
755
- if (d === null || typeof d != "object" || Array.isArray(d)) return !1;
756
- const u = d.type;
757
- return u === null || typeof u != "object" || Array.isArray(u) ? !1 : u.kind === "color";
834
+ const i = r.items;
835
+ if (!Array.isArray(i) || i.length === 0) return !1;
836
+ const u = i[0];
837
+ if (u === null || typeof u != "object" || Array.isArray(u)) return !1;
838
+ const d = u.type;
839
+ return d === null || typeof d != "object" || Array.isArray(d) ? !1 : d.kind === "color";
758
840
  });
759
841
  if (f) {
760
- const r = f.id, o = f.items, d = o[0]?.cssVar;
761
- if (d !== void 0) {
762
- const u = d.replace(/\d+$/, "{n}");
763
- if (u.includes("{n}"))
764
- for (let m = 0; m < o.length; m++) {
765
- const k = o[m], P = u.replace("{n}", String(m));
842
+ const r = f.id, i = f.items, u = i[0]?.cssVar;
843
+ if (u !== void 0) {
844
+ const d = u.replace(/\d+$/, "{n}");
845
+ if (d.includes("{n}"))
846
+ for (let p = 0; p < i.length; p++) {
847
+ const k = i[p], P = d.replace("{n}", String(p));
766
848
  if (k.cssVar !== P)
767
849
  throw new Error(
768
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[${m}].cssVar is ${JSON.stringify(k.cssVar)} but expected ${JSON.stringify(P)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(u)})`
850
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[${p}].cssVar is ${JSON.stringify(k.cssVar)} but expected ${JSON.stringify(P)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(d)})`
769
851
  );
770
852
  }
771
- else if (o.length > 1)
853
+ else if (i.length > 1)
772
854
  throw new Error(
773
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[0].cssVar ${JSON.stringify(d)} 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")`
855
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[0].cssVar ${JSON.stringify(u)} 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")`
774
856
  );
775
857
  }
776
858
  }
777
859
  }
860
+ if (e === "notes") {
861
+ if (t.tiers.length > 0)
862
+ throw new Error(
863
+ '[design-token-panel] PanelConfig.tabs["notes"].tiers must be empty — the notes tab does not hold token tiers'
864
+ );
865
+ if (t.colorExtras !== void 0)
866
+ throw new Error(
867
+ '[design-token-panel] PanelConfig.tabs["notes"].colorExtras must not be set — the notes tab does not carry token config'
868
+ );
869
+ if (t.notesExtras === void 0 || t.notesExtras === null || typeof t.notesExtras != "object" || Array.isArray(t.notesExtras))
870
+ throw new Error(
871
+ '[design-token-panel] PanelConfig.tabs["notes"].notesExtras must be a plain object with { title, html }'
872
+ );
873
+ const o = t.notesExtras;
874
+ for (const s of ["title", "html"])
875
+ if (typeof o[s] != "string" || o[s].length === 0)
876
+ throw new Error(
877
+ `[design-token-panel] PanelConfig.tabs["notes"].notesExtras.${s} must be a non-empty string (got ${typeof o[s]})`
878
+ );
879
+ } else if (t.notesExtras !== void 0)
880
+ throw new Error(
881
+ `[design-token-panel] PanelConfig.tabs["${e}"].notesExtras must only be set on a tab with id "notes"`
882
+ );
778
883
  }
779
- function be(e = O()) {
884
+ function Ae(e = D()) {
780
885
  return e.applyRouting ?? {};
781
886
  }
782
- function we(e) {
887
+ function Se(e) {
783
888
  const t = x();
784
889
  if (t === null) {
785
- y().pendingColorPresets = e;
890
+ m().pendingColorPresets = e;
786
891
  return;
787
892
  }
788
893
  t.config = { ...t.config, colorPresets: e };
789
894
  }
790
895
  export {
791
- ee as A,
792
- de as B,
793
- Y as C,
794
- q as D,
795
- le as E,
796
- fe as F,
797
- te as _,
798
- ce as a,
799
- re as b,
800
- X as c,
801
- ie as d,
802
- he as e,
803
- se as f,
804
- O as g,
805
- ae as h,
806
- oe as i,
807
- ge as j,
808
- A as k,
809
- _ as l,
810
- me as m,
811
- ye as n,
812
- G as o,
813
- U as p,
814
- ne as q,
815
- W as r,
816
- we as s,
817
- be as t,
818
- R as u,
819
- pe as v,
820
- I as w,
821
- Q as x,
822
- ue as y,
823
- Z as z
896
+ Pe as A,
897
+ Ae as B,
898
+ V as C,
899
+ $e as D,
900
+ I as E,
901
+ te as F,
902
+ ke as G,
903
+ q as H,
904
+ ne as I,
905
+ re as J,
906
+ we as K,
907
+ ie as _,
908
+ he as a,
909
+ fe as b,
910
+ ee as c,
911
+ ce as d,
912
+ ge as e,
913
+ ve as f,
914
+ D as g,
915
+ de as h,
916
+ Ee as i,
917
+ pe as j,
918
+ ue as k,
919
+ be as l,
920
+ se as m,
921
+ le as n,
922
+ Y as o,
923
+ Z as p,
924
+ ye as q,
925
+ Q as r,
926
+ Se as s,
927
+ me as t,
928
+ X as u,
929
+ oe as v,
930
+ ae as w,
931
+ M as x,
932
+ S as y,
933
+ Ce as z
824
934
  };