@iksnerd/blazon 0.3.3 → 0.5.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/dist/chunks/{site-builder-DlaZeZHi.js → site-builder-C8g2sfUv.js} +3471 -3650
  3. package/dist/cli/commands/approvals.d.ts +1 -1
  4. package/dist/cli/commands/approvals.d.ts.map +1 -1
  5. package/dist/cli/commands/mcp-check.d.ts +7 -4
  6. package/dist/cli/commands/mcp-check.d.ts.map +1 -1
  7. package/dist/cli/errors.d.ts +3 -1
  8. package/dist/cli/errors.d.ts.map +1 -1
  9. package/dist/cli/folder-first.d.ts +7 -0
  10. package/dist/cli/folder-first.d.ts.map +1 -0
  11. package/dist/cli/handlers/can.d.ts +1 -1
  12. package/dist/cli/handlers/can.d.ts.map +1 -1
  13. package/dist/cli/handlers/list.d.ts.map +1 -1
  14. package/dist/cli/index.js +1384 -1033
  15. package/dist/cli/json.d.ts +3 -2
  16. package/dist/cli/json.d.ts.map +1 -1
  17. package/dist/cli/operations.d.ts +1 -1
  18. package/dist/cli/operations.d.ts.map +1 -1
  19. package/dist/cli/read.d.ts +4 -1
  20. package/dist/cli/read.d.ts.map +1 -1
  21. package/dist/cli/where.d.ts +2 -0
  22. package/dist/cli/where.d.ts.map +1 -1
  23. package/dist/core/assets/representations.d.ts +44 -0
  24. package/dist/core/assets/representations.d.ts.map +1 -0
  25. package/dist/core/assets/scanner.d.ts.map +1 -1
  26. package/dist/core/assets/sidecar.d.ts.map +1 -1
  27. package/dist/core/blazon-pin.d.ts +19 -1
  28. package/dist/core/blazon-pin.d.ts.map +1 -1
  29. package/dist/core/brand/export.d.ts +13 -5
  30. package/dist/core/brand/export.d.ts.map +1 -1
  31. package/dist/core/brand/schema.d.ts +68 -0
  32. package/dist/core/brand/schema.d.ts.map +1 -1
  33. package/dist/core/checker/approvals.d.ts +5 -0
  34. package/dist/core/checker/approvals.d.ts.map +1 -1
  35. package/dist/core/checker/catalogue.d.ts +37 -7
  36. package/dist/core/checker/catalogue.d.ts.map +1 -1
  37. package/dist/core/checker/font-meta.d.ts.map +1 -1
  38. package/dist/core/checker/index.d.ts +5 -0
  39. package/dist/core/checker/index.d.ts.map +1 -1
  40. package/dist/core/checker/review.d.ts +19 -1
  41. package/dist/core/checker/review.d.ts.map +1 -1
  42. package/dist/core/docs/directives.d.ts +10 -0
  43. package/dist/core/docs/directives.d.ts.map +1 -1
  44. package/dist/core/docs/parser.d.ts.map +1 -1
  45. package/dist/core/font-roles.d.ts +11 -0
  46. package/dist/core/font-roles.d.ts.map +1 -0
  47. package/dist/core/index.d.ts.map +1 -1
  48. package/dist/core/init/from-site/fonts.d.ts.map +1 -1
  49. package/dist/core/logo/colorways.d.ts +29 -0
  50. package/dist/core/logo/colorways.d.ts.map +1 -0
  51. package/dist/core/logo/misuse.d.ts +18 -0
  52. package/dist/core/logo/misuse.d.ts.map +1 -0
  53. package/dist/core/mcp-config.d.ts +7 -0
  54. package/dist/core/mcp-config.d.ts.map +1 -1
  55. package/dist/core/operations/check.d.ts +1 -1
  56. package/dist/core/operations/check.d.ts.map +1 -1
  57. package/dist/core/operations/index.d.ts +1 -1
  58. package/dist/core/operations/index.d.ts.map +1 -1
  59. package/dist/core/operations/limits.d.ts +2 -0
  60. package/dist/core/operations/limits.d.ts.map +1 -1
  61. package/dist/core/operations/list.d.ts.map +1 -1
  62. package/dist/core/operations/types.d.ts +13 -0
  63. package/dist/core/operations/types.d.ts.map +1 -1
  64. package/dist/core/preflight.d.ts.map +1 -1
  65. package/dist/core/read/can.d.ts +14 -3
  66. package/dist/core/read/can.d.ts.map +1 -1
  67. package/dist/core/read/fonts.d.ts +2 -6
  68. package/dist/core/read/fonts.d.ts.map +1 -1
  69. package/dist/core/read/index.d.ts +3 -2
  70. package/dist/core/read/index.d.ts.map +1 -1
  71. package/dist/core/read/list.d.ts +15 -1
  72. package/dist/core/read/list.d.ts.map +1 -1
  73. package/dist/core/read/logo.d.ts +3 -3
  74. package/dist/core/read/logo.d.ts.map +1 -1
  75. package/dist/core/read/lookup.d.ts +2 -2
  76. package/dist/core/read/lookup.d.ts.map +1 -1
  77. package/dist/core/read/theme.d.ts +8 -0
  78. package/dist/core/read/theme.d.ts.map +1 -0
  79. package/dist/core/read/token.d.ts +6 -2
  80. package/dist/core/read/token.d.ts.map +1 -1
  81. package/dist/core/tokens/alias.d.ts +5 -3
  82. package/dist/core/tokens/alias.d.ts.map +1 -1
  83. package/dist/core/tokens/contexts.d.ts +11 -3
  84. package/dist/core/tokens/contexts.d.ts.map +1 -1
  85. package/dist/core/tokens/formatters/json.d.ts +4 -1
  86. package/dist/core/tokens/formatters/json.d.ts.map +1 -1
  87. package/dist/core/tokens/key-lines.d.ts.map +1 -1
  88. package/dist/core/tokens/merge.d.ts.map +1 -1
  89. package/dist/core/tokens/resolver/compile.d.ts.map +1 -1
  90. package/dist/core/tokens/resolver/parse.d.ts.map +1 -1
  91. package/dist/core/tokens/resolver/sources.d.ts.map +1 -1
  92. package/dist/core/tokens/walk.d.ts.map +1 -1
  93. package/dist/index.js +34 -34
  94. package/dist/plugins/host/call.d.ts.map +1 -1
  95. package/dist/plugins/roles/roles.d.ts.map +1 -1
  96. package/dist/server/plugin.d.ts.map +1 -1
  97. package/dist/types/assets.d.ts +19 -1
  98. package/dist/types/assets.d.ts.map +1 -1
  99. package/dist/types/parsed.d.ts +8 -0
  100. package/dist/types/parsed.d.ts.map +1 -1
  101. package/dist/types/tokens.d.ts +12 -0
  102. package/dist/types/tokens.d.ts.map +1 -1
  103. package/dist/ui/assets/index-b4HhGGrn.js +82 -0
  104. package/dist/ui/assets/index-pE1ku5gt.css +2 -0
  105. package/dist/ui/index.html +2 -2
  106. package/mcp/dist/index.js +358 -45
  107. package/package.json +3 -2
  108. package/plugins/blazon.brand-deck/README.md +1 -1
  109. package/plugins/blazon.brand-deck/bin/blazon-blazon.brand-deck./360/237/224/214 +106 -13
  110. package/plugins/blazon.favicons/bin/blazon-blazon.favicons./360/237/224/214 +120 -12
  111. package/plugins/blazon.logo-geometry/bin/blazon-blazon.logo-geometry./360/237/224/214 +45 -1
  112. package/plugins/blazon.logo-kit/bin/blazon-blazon.logo-kit./360/237/224/214 +45 -1
  113. package/plugins/blazon.office-template/bin/blazon-blazon.office-template./360/237/224/214 +66 -3
  114. package/plugins/blazon.platform-tokens/README.md +1 -1
  115. package/plugins/blazon.press-kit/README.md +17 -9
  116. package/plugins/blazon.press-kit/bin/blazon-blazon.press-kit./360/237/224/214 +621 -101
  117. package/plugins/blazon.print-book/README.md +16 -1
  118. package/plugins/blazon.social-cards/bin/blazon-blazon.social-cards./360/237/224/214 +59 -3
  119. package/plugins/shipped.lock +9 -9
  120. package/dist/ui/assets/index-Biy1hkeq.css +0 -2
  121. package/dist/ui/assets/index-dkJG6W9p.js +0 -82
package/dist/cli/index.js CHANGED
@@ -1,241 +1,242 @@
1
- import { $t as e, A as t, At as n, Bt as r, C as i, Ct as a, D as o, Dn as s, Dt as c, E as l, Ft as u, G as d, It as f, Jt as p, K as m, M as h, Mt as g, Nt as _, O as v, On as y, Pt as b, Qt as x, R as S, Rt as ee, S as C, T as w, Tt as T, Ut as te, Vt as ne, W as re, Xt as ie, Zt as ae, _ as oe, _n as se, _t as ce, a as le, an as ue, b as de, bt as fe, c as pe, cn as me, d as he, dn as E, en as ge, f as _e, fn as ve, g as ye, gt as be, h as xe, hn as Se, ht as Ce, i as we, j as Te, jt as Ee, k as De, l as Oe, ln as ke, m as Ae, mn as je, mt as D, on as Me, p as Ne, pn as Pe, q as Fe, s as Ie, sn as Le, t as Re, tn as ze, u as Be, un as Ve, ut as He, v as Ue, vt as We, w as Ge, wt as Ke, x as qe, y as Je, yt as Ye, z as Xe, zt as Ze } from "../chunks/site-builder-DlaZeZHi.js";
1
+ import { A as e, At as t, B as n, Bt as r, C as i, D as a, Dt as o, E as s, Et as c, G as l, Gt as u, Ht as d, It as f, J as p, Jt as m, K as h, Lt as g, M as _, N as v, Nt as y, O as ee, Ot as b, Pt as x, Rn as te, Rt as S, S as C, Sn as w, St as ne, T as re, Tt as ie, Ut as ae, Vt as oe, Wt as se, Xt as ce, Yt as le, _ as ue, _n as de, _t as fe, a as pe, an as me, b as he, bn as ge, bt as _e, c as ve, cn as ye, d as be, dt as xe, f as Se, fn as Ce, g as we, gn as Te, gt as Ee, h as De, hn as Oe, ht as T, i as ke, in as Ae, j as je, k as E, l as Me, m as Ne, mn as Pe, on as Fe, p as Ie, pn as Le, q as Re, qt as ze, rn as Be, s as Ve, sn as He, t as Ue, tn as We, u as Ge, v as Ke, vn as D, vt as qe, w as Je, wn as Ye, x as Xe, xn as Ze, xt as Qe, y as $e, yn as et, yt as tt, z as nt, zn as rt, zt as it } from "../chunks/site-builder-C8g2sfUv.js";
2
2
  import O from "node:path";
3
3
  import k from "node:fs";
4
- import { spawn as Qe } from "node:child_process";
5
- import $e from "node:os";
6
- import { preview as et } from "vite";
7
- import { cac as tt } from "cac";
4
+ import { spawn as at } from "node:child_process";
5
+ import ot from "node:os";
6
+ import { preview as st } from "vite";
7
+ import { cac as ct } from "cac";
8
8
  import * as A from "@clack/prompts";
9
9
  // src/cli/errors.ts
10
10
  var j = class extends Error {
11
11
  fix;
12
12
  code;
13
+ hint;
13
14
  constructor(e, t, n = "error") {
14
15
  super(e), this.fix = t, this.code = n;
15
16
  }
16
- }, M = class extends j {}, nt = (e) => new M(`port ${e} is in use`, "Pick another with --port, or leave out --strict-port to take the next free one.", "port-in-use"), rt = (e) => e.replace(/^./, (e) => e.toLowerCase()).replace(/\.$/, "");
17
- function it(e, t, n) {
18
- return `blazon${e ? ` ${e}` : ""}: ${t}${n ? `\n ${n}` : ""}`;
17
+ }, M = class extends j {}, lt = (e) => new M(`port ${e} is in use`, "Pick another with --port, or leave out --strict-port to take the next free one.", "port-in-use"), ut = (e) => e.replace(/^./, (e) => e.toLowerCase()).replace(/\.$/, "");
18
+ function dt(e, t, n, r) {
19
+ return `blazon${e ? ` ${e}` : ""}: ${t}${n ? `\n ${n}` : ""}${r ? `\n ${r}` : ""}`;
19
20
  }
20
- var at = (e, t) => t ? `${e}; ${rt(t)}` : e, ot;
21
- function st(e) {
22
- ot = e;
21
+ var ft = (e, t) => t ? `${e}; ${ut(t)}` : e, pt;
22
+ function mt(e) {
23
+ pt = e;
23
24
  }
24
- function ct(e) {
25
- console.error(e.replace(/^blazon(?: [a-z]+)*:/, (e) => l.red(e)));
25
+ function ht(e) {
26
+ console.error(e.replace(/^blazon(?: [a-z]+)*:/, (e) => a.red(e)));
26
27
  }
27
- var lt = (e, t, n) => ({
28
+ var gt = (e, t, n) => ({
28
29
  code: e,
29
30
  message: t,
30
31
  ...n !== void 0 && { fix: n }
31
32
  });
32
- function ut(e, t, n) {
33
- ot !== void 0 && process.stdout.write(`${JSON.stringify({
34
- command: ot,
33
+ function _t(e, t, n) {
34
+ pt !== void 0 && process.stdout.write(`${JSON.stringify({
35
+ command: pt,
35
36
  passed: !1,
36
- error: lt(e, t, n)
37
+ error: gt(e, t, n)
37
38
  })}\n`);
38
39
  }
39
40
  function N(e, t, n = {}) {
40
- return ct(e), n.stack && console.error(n.stack), ut(t, n.json ?? e.replace(/^blazon(?: [a-z]+)?: /, ""), n.fix), process.exit(2);
41
+ return ht(e), n.stack && console.error(n.stack), _t(t, n.json ?? e.replace(/^blazon(?: [a-z]+)?: /, ""), n.fix), process.exit(2);
41
42
  }
42
- var dt = (e) => e.replace(/`([^`]*)`/g, "\"$1\"").replace(/^./, (e) => e.toLowerCase()), ft = (e) => e instanceof Error && e.name === "CACError";
43
+ var vt = (e) => e.replace(/`([^`]*)`/g, "\"$1\"").replace(/^./, (e) => e.toLowerCase()), yt = (e) => e instanceof Error && e.name === "CACError";
43
44
  function P(e, t, n) {
44
45
  let r = t instanceof j ? t.fix : void 0;
45
- if (t instanceof M) return N(it(e, t.message, r), t.code, {
46
+ if (t instanceof M) return N(dt(e, t.message, r, t.hint), t.code, {
46
47
  stack: n ? t.stack : void 0,
47
- json: at(t.message, r),
48
+ json: ft(t.message, r),
48
49
  fix: r
49
50
  });
50
51
  let i = t instanceof Error ? t.message : String(t);
51
- return console.error(), ct(it(e, i, r ?? (n || t instanceof j ? void 0 : l.dim("Run again with --debug for the stack.")))), n && t instanceof Error && t.stack && console.error(t.stack), ut(t instanceof j ? t.code : "error", at(i, r), r), process.exit(1);
52
+ return console.error(), ht(dt(e, i, r ?? (n || t instanceof j ? void 0 : a.dim("Run again with --debug for the stack.")))), n && t instanceof Error && t.stack && console.error(t.stack), _t(t instanceof j ? t.code : "error", ft(i, r), r), process.exit(1);
52
53
  }
53
54
  // src/cli/where.ts
54
55
  function F(e, t = process.cwd()) {
55
56
  let n = O.relative(t, O.resolve(t, e));
56
57
  return n === "" ? "" : n.startsWith("..") || O.isAbsolute(n) ? O.resolve(t, e) : n.split(O.sep).join("/");
57
58
  }
58
- var I = (e, t) => e ? `${e}/${t}` : t, pt = (e) => /^[\w./@%+=:,-]+$/.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, L = (e, t) => `blazon ${e}${t ? ` ${pt(t)}` : ""}`, mt = (e) => k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1, ht = (e) => `Run ${L("init", F(e))} to start a brand book there`;
59
- function gt(e) {
60
- if (!mt(e)) throw new M(`no folder "${e}"`, `${ht(e)}.`, "no-folder");
59
+ var I = (e, t) => e ? `${e}/${t}` : t, bt = (e) => /^[\w./@%+=:,-]+$/.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, L = (e, t) => `blazon ${e}${t ? ` ${bt(t)}` : ""}`, xt = (e) => k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1, St = (e) => `Run ${L("init", F(e))} to start a brand book there`;
60
+ function Ct(e) {
61
+ if (!xt(e)) throw new M(`no folder "${e}"`, `${St(e)}.`, "no-folder");
61
62
  }
62
- function _t(e, t) {
63
- if (!mt(O.resolve(e, t))) throw new M(`no tokens folder (${t.replace(/^\.\//, "").replace(/\/$/, "")}) in "${e}"`, `${ht(e)}, or set tokensDir in blazon.json.`, "no-tokens-folder");
63
+ function wt(e, t) {
64
+ if (!xt(O.resolve(e, t))) throw new M(`no tokens folder (${t.replace(/^\.\//, "").replace(/\/$/, "")}) in "${e}"`, `${St(e)}, or set tokensDir in blazon.json.`, "no-tokens-folder");
64
65
  }
65
66
  async function R(e, t) {
66
- gt(e);
67
- let n = await ae(e, t);
68
- return _t(e, n.tokensDir), n;
67
+ Ct(e);
68
+ let n = await Ae(e, t);
69
+ return wt(e, n.tokensDir), n;
69
70
  }
70
71
  // src/cli/commands/dev.ts
71
- var vt = /* @__PURE__ */ y({ runDev: () => yt });
72
- async function yt(e = process.cwd(), t, n = {}) {
72
+ var Tt = /* @__PURE__ */ rt({ runDev: () => Et });
73
+ async function Et(e = process.cwd(), t, n = {}) {
73
74
  let r = await R(e, t ? { port: t } : void 0);
74
75
  try {
75
- await we(r, e, n);
76
+ await ke(r, e, n);
76
77
  } catch (e) {
77
- throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? nt(r.port) : e;
78
+ throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? lt(r.port) : e;
78
79
  }
79
80
  }
80
81
  // src/cli/commands/check.ts
81
- var bt = class extends j {
82
+ var Dt = class extends j {
82
83
  findings;
83
84
  constructor(e, t, n, r = "check-failed") {
84
85
  super(e, n, r), this.findings = t;
85
86
  }
86
- }, xt = (e) => e?.plugins === !1, St = (e) => e?.plugin === void 0 ? [] : [e.plugin].flat();
87
- function Ct(e) {
87
+ }, Ot = (e) => e?.plugins === !1, kt = (e) => e?.plugin === void 0 ? [] : [e.plugin].flat();
88
+ function At(e) {
88
89
  return e.context ? `${e.path} (${e.context})` : e.path;
89
90
  }
90
- var wt = 5;
91
- function Tt(e) {
92
- let t = e.slice(0, wt).join(", ");
93
- return e.length > wt ? `${t} and ${e.length - wt} more` : t;
94
- }
95
- var Et = (e) => e.path.split("/")[0];
96
- function Dt(e, t) {
97
- let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = e.filter((e) => e.code === "page-review-pending");
98
- for (let t of e) t.code === "starter-file-unchanged" && i.set(Et(t), [...i.get(Et(t)) ?? [], t]), t.code === "review-pending" && a.set(t.message, [...a.get(t.message) ?? [], t]);
99
- for (let s of e) {
100
- if (r.has(s)) continue;
101
- let e = s.code === "starter-file-unchanged" ? i.get(Et(s)) : void 0, c = s.code === "review-pending" ? a.get(s.message) : void 0;
102
- if (s.code === "page-review-pending" && o.length > 1) o.forEach((e) => r.add(e)), n.push(`${l.bold(`page-review-pending (${o.length} pages)`)}: ${Tt(o.map(Ct))}: show assets still marked needs-review ${l.dim("[page-review-pending]")}`);
91
+ var jt = 5;
92
+ function Mt(e) {
93
+ let t = e.slice(0, jt).join(", ");
94
+ return e.length > jt ? `${t} and ${e.length - jt} more` : t;
95
+ }
96
+ var Nt = (e) => e.path.split("/")[0];
97
+ function Pt(e, t) {
98
+ let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = e.filter((e) => e.code === "page-review-pending");
99
+ for (let t of e) t.code === "starter-file-unchanged" && i.set(Nt(t), [...i.get(Nt(t)) ?? [], t]), t.code === "review-pending" && o.set(t.message, [...o.get(t.message) ?? [], t]);
100
+ for (let c of e) {
101
+ if (r.has(c)) continue;
102
+ let e = c.code === "starter-file-unchanged" ? i.get(Nt(c)) : void 0, l = c.code === "review-pending" ? o.get(c.message) : void 0;
103
+ if (c.code === "page-review-pending" && s.length > 1) s.forEach((e) => r.add(e)), n.push(`${a.bold(`page-review-pending (${s.length} pages)`)}: ${Mt(s.map(At))}: show assets still marked needs-review ${a.dim("[page-review-pending]")}`);
103
104
  else if (e && e.length > 1) {
104
105
  e.forEach((e) => r.add(e));
105
- let t = Et(s), i = e.map((e) => e.path.slice(t.length + 1));
106
- n.push(`${l.bold(`${t}/`)}: ${e.length} files are still the starter's text (${Tt(i)}) ${l.dim("[starter-file-unchanged]")}`);
107
- } else if (c && c.length > 1) c.forEach((e) => r.add(e)), n.push(`${l.bold(`review-pending (${c.length})`)}: ${Tt(c.map(Ct))}: ${s.message} ${l.dim("[review-pending]")}`);
106
+ let t = Nt(c), i = e.map((e) => e.path.slice(t.length + 1));
107
+ n.push(`${a.bold(`${t}/`)}: ${e.length} files are still the starter's text (${Mt(i)}) ${a.dim("[starter-file-unchanged]")}`);
108
+ } else if (l && l.length > 1) l.forEach((e) => r.add(e)), n.push(`${a.bold(`review-pending (${l.length})`)}: ${Mt(l.map(At))}: ${c.message} ${a.dim("[review-pending]")}`);
108
109
  else {
109
- let e = ye(s, t), r = e === void 0 ? l.bold(Ct(s)) : s.path === s.file ? l.bold(e) : `${l.bold(e)} ${Ct(s)}`;
110
- n.push(`${r}: ${s.message} ${l.dim(`[${s.code}]`)}`);
110
+ let e = ue(c, t), r = e === void 0 ? a.bold(At(c)) : c.path === c.file ? a.bold(e) : `${a.bold(e)} ${At(c)}`;
111
+ n.push(`${r}: ${c.message} ${a.dim(`[${c.code}]`)}`);
111
112
  }
112
113
  }
113
114
  return n;
114
115
  }
115
- function Ot(e, t = "") {
116
- for (let n of Dt(e.errors, t)) console.log(` ${l.bgRed(l.white(" ERROR "))} ${n}`);
117
- for (let n of Dt(e.warnings, t)) console.log(` ${l.bgYellow(l.black(" WARN "))} ${n}`);
118
- for (let n of Dt(e.infos, t)) console.log(` ${l.bgCyan(l.black(" NOTE "))} ${n}`);
116
+ function Ft(e, t = "") {
117
+ for (let n of Pt(e.errors, t)) console.log(` ${a.bgRed(a.white(" ERROR "))} ${n}`);
118
+ for (let n of Pt(e.warnings, t)) console.log(` ${a.bgYellow(a.black(" WARN "))} ${n}`);
119
+ for (let n of Pt(e.infos, t)) console.log(` ${a.bgCyan(a.black(" NOTE "))} ${n}`);
119
120
  }
120
- var kt = 5;
121
- function At(e, t = "") {
122
- e.infos.filter((e) => e.code === "starter-file-unchanged").length < kt || (console.log(l.bold("Next:")), console.log(` 1. Edit ${l.cyan(I(t, "tokens/colors.json"))} with your colors`), console.log(` 2. Run ${l.cyan(L("dev", t))} to see the book`), console.log(` 3. Replace blazon's artwork in ${l.cyan(I(t, "assets/"))} and the text in ${l.cyan(I(t, "docs/"))}`), console.log());
121
+ var It = 5;
122
+ function Lt(e, t = "") {
123
+ e.infos.filter((e) => e.code === "starter-file-unchanged").length < It || (console.log(a.bold("Next:")), console.log(` 1. Edit ${a.cyan(I(t, "tokens/colors.json"))} with your colors`), console.log(` 2. Run ${a.cyan(L("dev", t))} to see the book`), console.log(` 3. Replace blazon's artwork in ${a.cyan(I(t, "assets/"))} and the text in ${a.cyan(I(t, "docs/"))}`), console.log());
123
124
  }
124
- var jt = 3;
125
- function Mt(e, t = "") {
125
+ var Rt = 3;
126
+ function zt(e, t = "") {
126
127
  let n = /* @__PURE__ */ new Map();
127
128
  for (let t of e.errors) {
128
- let e = Ue(t);
129
+ let e = $e(t);
129
130
  e && !n.has(`${t.code}\n${e}`) && n.set(`${t.code}\n${e}`, {
130
131
  code: t.code,
131
132
  fix: e
132
133
  });
133
134
  }
134
- let r = [...n.values()].slice(0, jt);
135
- console.log(l.bold("Next:")), r.forEach(({ code: e, fix: t }, n) => console.log(` ${n + 1}. ${l.cyan(e)}: ${t}`)), console.log(` ${r.length + 1}. Run ${l.cyan(L("check", t))} again`), console.log();
136
- }
137
- function Nt(e, t = process.cwd()) {
138
- let n = c(e.findings);
139
- if (n.all.length === 0) return;
140
- let r = F(t);
141
- if (console.log(), Ot(n, r), console.log(), n.errors.length > 0) throw new bt(`blazon check found ${n.errors.length} error(s)`, e.findings, `Fix them, or run ${L("check", r)} for details.`);
142
- }
143
- async function Pt(e = process.cwd(), t = !1, n) {
144
- let r = await R(e);
145
- console.log(l.cyan("\n[blazon] Checking design tokens..."));
146
- let a = await D(r, e);
147
- a.findings.push(...We(e)), xt(n) || await i(a, r, e, new Je(r, e, { named: St(n) }));
148
- let o = c(a.findings, { strict: t });
149
- if (o.all.length === 0) return console.log(l.green(`\n ✔ ${a.tokens.items.length} tokens, no findings.\n`)), {
150
- findings: o.all,
135
+ let r = [...n.values()].slice(0, Rt);
136
+ console.log(a.bold("Next:")), r.forEach(({ code: e, fix: t }, n) => console.log(` ${n + 1}. ${a.cyan(e)}: ${t}`)), console.log(` ${r.length + 1}. Run ${a.cyan(L("check", t))} again`), console.log();
137
+ }
138
+ function Bt(e, n = process.cwd()) {
139
+ let r = t(e.findings);
140
+ if (r.all.length === 0) return;
141
+ let i = F(n);
142
+ if (console.log(), Ft(r, i), console.log(), r.errors.length > 0) throw new Dt(`blazon check found ${r.errors.length} error(s)`, e.findings, `Fix them, or run ${L("check", i)} for details.`);
143
+ }
144
+ async function Vt(e = process.cwd(), n = !1, r) {
145
+ let i = await R(e);
146
+ console.log(a.cyan("\n[blazon] Checking design tokens..."));
147
+ let o = await T(i, e);
148
+ o.findings.push(...tt(e)), Ot(r) || await Je(o, i, e, new he(i, e, { named: kt(r) }));
149
+ let s = t(o.findings, { strict: n });
150
+ if (s.all.length === 0) return console.log(a.green(`\n ✔ ${o.tokens.items.length} tokens, no findings.\n`)), {
151
+ findings: s.all,
151
152
  passed: !0
152
153
  };
153
- let s = [
154
- o.errors.length > 0 && `${o.errors.length} error(s)`,
155
- o.warnings.length > 0 && `${o.warnings.length} warning(s)`,
156
- o.infos.length > 0 && `${o.infos.length} note(s)`
157
- ].filter(Boolean), u = o.errors.length + o.warnings.length > 0 ? `${o.errors.length} error(s) and ${o.warnings.length} warning(s)${o.infos.length > 0 ? ` and ${o.infos.length} note(s)` : ""}` : s.join(" and "), d = F(e);
158
- return console.log(`\nFound ${u}:\n`), Ot(o, d), console.log(), o.errors.length > 0 ? Mt(o, d) : At(o, d), o.passed ? (console.log(o.warnings.length > 0 ? l.yellow("✔ Check passed with warnings.\n") : l.green("✔ Check passed.\n")), {
159
- findings: o.all,
154
+ let c = [
155
+ s.errors.length > 0 && `${s.errors.length} error(s)`,
156
+ s.warnings.length > 0 && `${s.warnings.length} warning(s)`,
157
+ s.infos.length > 0 && `${s.infos.length} note(s)`
158
+ ].filter(Boolean), l = s.errors.length + s.warnings.length > 0 ? `${s.errors.length} error(s) and ${s.warnings.length} warning(s)${s.infos.length > 0 ? ` and ${s.infos.length} note(s)` : ""}` : c.join(" and "), u = F(e);
159
+ return console.log(`\nFound ${l}:\n`), Ft(s, u), console.log(), s.errors.length > 0 ? zt(s, u) : Lt(s, u), s.passed ? (console.log(s.warnings.length > 0 ? a.yellow("✔ Check passed with warnings.\n") : a.green("✔ Check passed.\n")), {
160
+ findings: s.all,
160
161
  passed: !0
161
- }) : (console.error(l.red(`✖ Check failed${t ? " (--strict treats warnings as errors)" : ""}.\n`)), {
162
- findings: o.all,
162
+ }) : (console.error(a.red(`✖ Check failed${n ? " (--strict treats warnings as errors)" : ""}.\n`)), {
163
+ findings: s.all,
163
164
  passed: !1
164
165
  });
165
166
  }
166
167
  // src/cli/commands/build.ts
167
- async function Ft(e = process.cwd(), t, n) {
168
- let r = await R(e, t ? { outDir: t } : void 0), a = await D(r, e);
169
- a.findings.push(...We(e));
170
- let o = new Je(r, e, { named: St(n) });
171
- xt(n) || await i(a, r, e, o), Nt(a, e);
172
- let { siteOutDir: s } = await Re(r, e, { data: a }), u = xt(n) ? [] : await C(a, r, e, o, s);
173
- if (u.length === 0) return { findings: a.findings };
174
- let d = c(u);
175
- if (console.log(), Ot(d, F(e)), console.log(), d.errors.length > 0) throw new bt(`a build plugin reported ${d.errors.length} error(s)`, [...a.findings, ...u], "The site is built; the plugin's findings above say what to fix.", "plugin-failed");
176
- return console.log(l.dim(" Build plugins finished.")), { findings: [...a.findings, ...u] };
168
+ async function Ht(e = process.cwd(), n, r) {
169
+ let o = await R(e, n ? { outDir: n } : void 0), s = await T(o, e);
170
+ s.findings.push(...tt(e));
171
+ let c = new he(o, e, { named: kt(r) });
172
+ Ot(r) || await Je(s, o, e, c), Bt(s, e);
173
+ let { siteOutDir: l } = await Ue(o, e, { data: s }), u = Ot(r) ? [] : await i(s, o, e, c, l);
174
+ if (u.length === 0) return { findings: s.findings };
175
+ let d = t(u);
176
+ if (console.log(), Ft(d, F(e)), console.log(), d.errors.length > 0) throw new Dt(`a build plugin reported ${d.errors.length} error(s)`, [...s.findings, ...u], "The site is built; the plugin's findings above say what to fix.", "plugin-failed");
177
+ return console.log(a.dim(" Build plugins finished.")), { findings: [...s.findings, ...u] };
177
178
  }
178
179
  // src/cli/commands/tokens.ts
179
- async function It(e = process.cwd(), t) {
180
- let n = await R(e);
181
- console.log(l.cyan("\n[blazon] Compiling design tokens..."));
182
- let r = await D(n, e);
183
- r.findings.push(...We(e));
184
- let a = new Je(n, e, { named: St(t) });
185
- xt(t) || await i(r, n, e, a), Nt(r, e);
186
- let o = await Ce(r, n, e);
180
+ async function Ut(e = process.cwd(), n) {
181
+ let r = await R(e);
182
+ console.log(a.cyan("\n[blazon] Compiling design tokens..."));
183
+ let o = await T(r, e);
184
+ o.findings.push(...tt(e));
185
+ let s = new he(r, e, { named: kt(n) });
186
+ Ot(n) || await Je(o, r, e, s), Bt(o, e);
187
+ let c = await Ee(o, r, e);
187
188
  for (let e of [
188
- o.cssPath,
189
- o.typographyPath,
190
- o.tsPath,
191
- o.jsonPath
192
- ]) e && console.log(` ${l.green("✔")} Emitted ${l.bold(e)}`);
189
+ c.cssPath,
190
+ c.typographyPath,
191
+ c.tsPath,
192
+ c.jsonPath
193
+ ]) e && console.log(` ${a.green("✔")} Emitted ${a.bold(e)}`);
193
194
  console.log();
194
- let s = xt(t) ? [] : await C(r, n, e, a);
195
- if (s.length === 0) return { findings: r.findings };
196
- let u = c(s);
197
- if (Ot(u, F(e)), console.log(), u.errors.length > 0) throw new bt(`a build plugin reported ${u.errors.length} error(s)`, [...r.findings, ...s], "The token files are written; the plugin's findings above say what to fix.", "plugin-failed");
198
- return { findings: [...r.findings, ...s] };
195
+ let l = Ot(n) ? [] : await i(o, r, e, s);
196
+ if (l.length === 0) return { findings: o.findings };
197
+ let u = t(l);
198
+ if (Ft(u, F(e)), console.log(), u.errors.length > 0) throw new Dt(`a build plugin reported ${u.errors.length} error(s)`, [...o.findings, ...l], "The token files are written; the plugin's findings above say what to fix.", "plugin-failed");
199
+ return { findings: [...o.findings, ...l] };
199
200
  }
200
201
  // src/core/drift/compare.ts
201
- var Lt = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Rt = /^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/i, zt = (e) => e.trim().toLowerCase().replace(/\s+/g, " ");
202
- function Bt(e) {
202
+ var Wt = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Gt = /^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/i, Kt = (e) => e.trim().toLowerCase().replace(/\s+/g, " ");
203
+ function qt(e) {
203
204
  let t = e.trim();
204
- if (!Lt.test(t)) return zt(t);
205
+ if (!Wt.test(t)) return Kt(t);
205
206
  let n = t.slice(1).toLowerCase();
206
207
  return `#${n.length <= 4 ? [...n].map((e) => e + e).join("") : n}`;
207
208
  }
208
- function Vt(e) {
209
- let t = e.trim().match(Rt);
210
- return t ? `${Number(t[1])}${t[2].toLowerCase()}` : zt(e);
209
+ function Jt(e) {
210
+ let t = e.trim().match(Gt);
211
+ return t ? `${Number(t[1])}${t[2].toLowerCase()}` : Kt(e);
211
212
  }
212
- function Ht(e, t) {
213
- return e === "color" ? Bt(t) : e === "dimension" ? Vt(t) : zt(t);
213
+ function Yt(e, t) {
214
+ return e === "color" ? qt(t) : e === "dimension" ? Jt(t) : Kt(t);
214
215
  }
215
- var Ut = /\/\*[\s\S]*?\*\//g, Wt = /([^{}]*)\{([^{}]*)\}/g, Gt = /(--[A-Za-z0-9_-]+)\s*:\s*([^;]*?)\s*(?:;|$)/g, Kt = /(^|,)\s*(:root|html)\s*(,|$)/, qt = /^var\(\s*(--[A-Za-z0-9_-]+)\s*\)$/;
216
- function Jt(e) {
216
+ var Xt = /\/\*[\s\S]*?\*\//g, Zt = /([^{}]*)\{([^{}]*)\}/g, Qt = /(--[A-Za-z0-9_-]+)\s*:\s*([^;]*?)\s*(?:;|$)/g, $t = /(^|,)\s*(:root|html)\s*(,|$)/, en = /^var\(\s*(--[A-Za-z0-9_-]+)\s*\)$/;
217
+ function tn(e) {
217
218
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
218
- for (let r of e.replace(Ut, "").matchAll(Wt)) {
219
- let e = Kt.test(r[1].trim()) ? t : n;
220
- for (let t of r[2].matchAll(Gt)) e.set(t[1], t[2]);
219
+ for (let r of e.replace(Xt, "").matchAll(Zt)) {
220
+ let e = $t.test(r[1].trim()) ? t : n;
221
+ for (let t of r[2].matchAll(Qt)) e.set(t[1], t[2]);
221
222
  }
222
223
  let r = new Map([...n, ...t]);
223
224
  for (let [e, t] of r) {
224
225
  let n = t, i = /* @__PURE__ */ new Set([e]);
225
- for (let e = n.match(qt); e && r.has(e[1]) && !i.has(e[1]); e = n.match(qt)) i.add(e[1]), n = r.get(e[1]);
226
+ for (let e = n.match(en); e && r.has(e[1]) && !i.has(e[1]); e = n.match(en)) i.add(e[1]), n = r.get(e[1]);
226
227
  r.set(e, n);
227
228
  }
228
229
  return r;
229
230
  }
230
- function Yt(e, t, n) {
231
- let r = Ht(e.type, String(e.value)), i = n.get(t);
231
+ function nn(e, t, n) {
232
+ let r = Yt(e.type, String(e.value)), i = n.get(t);
232
233
  if (i === void 0) return {
233
234
  path: e.path,
234
235
  cssVar: t,
235
236
  status: "missing",
236
237
  expected: r
237
238
  };
238
- let a = Ht(e.type, i);
239
+ let a = Yt(e.type, i);
239
240
  return {
240
241
  path: e.path,
241
242
  cssVar: t,
@@ -244,21 +245,21 @@ function Yt(e, t, n) {
244
245
  actual: a
245
246
  };
246
247
  }
247
- var Xt = 1e4;
248
- function Zt(e) {
248
+ var rn = 1e4;
249
+ function an(e) {
249
250
  let t = e instanceof Error ? e.message : String(e), n = e instanceof Error ? e.cause : void 0;
250
251
  return n instanceof Error && n.message && n.message !== t ? `${t}: ${n.message}` : t;
251
252
  }
252
- async function Qt(e) {
253
+ async function on(e) {
253
254
  let t;
254
255
  try {
255
256
  t = await fetch(e, {
256
- signal: AbortSignal.timeout(Xt),
257
+ signal: AbortSignal.timeout(rn),
257
258
  redirect: "follow"
258
259
  });
259
260
  } catch (t) {
260
261
  let n = t instanceof Error && (t.name === "TimeoutError" || t.name === "AbortError");
261
- throw Error(`could not fetch ${e}: ${n ? `no answer in ${Xt / 1e3} s` : Zt(t)}`, { cause: t });
262
+ throw Error(`could not fetch ${e}: ${n ? `no answer in ${rn / 1e3} s` : an(t)}`, { cause: t });
262
263
  }
263
264
  if (!t.ok) throw Error(`could not fetch ${e}: ${t.status} ${t.statusText}`.trim());
264
265
  let n = [], r = 0;
@@ -272,10 +273,10 @@ async function Qt(e) {
272
273
  }
273
274
  return Buffer.concat(n);
274
275
  }
275
- async function $t(e) {
276
- return (await Qt(e)).toString("utf8");
276
+ async function sn(e) {
277
+ return (await on(e)).toString("utf8");
277
278
  }
278
- function en(e, t) {
279
+ function cn(e, t) {
279
280
  let n = [];
280
281
  for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
281
282
  let e = (e) => r.match(RegExp(`\\s${e}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i")), i = e("rel"), a = e("href");
@@ -286,12 +287,12 @@ function en(e, t) {
286
287
  }
287
288
  return n;
288
289
  }
289
- async function tn(e) {
290
+ async function ln(e) {
290
291
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(e)) {
291
292
  if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address or a file`);
292
- let t = en(await $t(e), e).slice(0, 20);
293
+ let t = cn(await sn(e), e).slice(0, 20);
293
294
  return {
294
- css: (await Promise.all(t.map($t))).join("\n"),
295
+ css: (await Promise.all(t.map(sn))).join("\n"),
295
296
  sources: t
296
297
  };
297
298
  }
@@ -307,60 +308,60 @@ async function tn(e) {
307
308
  sources: [t]
308
309
  };
309
310
  }
310
- async function nn(e) {
311
+ async function un(e) {
311
312
  if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address`);
312
- let t = await $t(e), n = en(t, e).slice(0, 20);
313
+ let t = await sn(e), n = cn(t, e).slice(0, 20);
313
314
  return {
314
315
  html: t,
315
- css: (await Promise.all(n.map($t))).join("\n"),
316
+ css: (await Promise.all(n.map(sn))).join("\n"),
316
317
  sources: n
317
318
  };
318
319
  }
319
320
  // src/core/init/from-site/tree.ts
320
- var rn = (e) => typeof e == "object" && !!e && "$value" in e;
321
- function an(e) {
321
+ var dn = (e) => typeof e == "object" && !!e && "$value" in e;
322
+ function fn(e) {
322
323
  return JSON.parse(k.readFileSync(e, "utf-8"));
323
324
  }
324
- function on(e, t) {
325
+ function pn(e, t) {
325
326
  k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
326
327
  }
327
- var sn = (e) => ({ "dev.blazon": e });
328
- function cn(e, t = []) {
328
+ var mn = (e) => ({ "dev.blazon": e });
329
+ function hn(e, t = []) {
329
330
  let n = [];
330
- for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (rn(i) ? n.push([...t, r].join(".")) : n.push(...cn(i, [...t, r])));
331
+ for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (dn(i) ? n.push([...t, r].join(".")) : n.push(...hn(i, [...t, r])));
331
332
  return n;
332
333
  }
333
- var ln = (e, t) => {
334
+ var gn = (e, t) => {
334
335
  let n = e;
335
336
  for (let e of t.split(".")) {
336
337
  if (typeof n != "object" || !n) return;
337
338
  n = n[e];
338
339
  }
339
- return rn(n) ? n : void 0;
340
- }, un = (e) => [...JSON.stringify(e).matchAll(/\{([A-Za-z0-9_.-]+)\}/g)].map((e) => e[1]);
341
- function dn(e, t) {
340
+ return dn(n) ? n : void 0;
341
+ }, _n = (e) => [...JSON.stringify(e).matchAll(/\{([A-Za-z0-9_.-]+)\}/g)].map((e) => e[1]);
342
+ function vn(e, t) {
342
343
  return k.existsSync(e) ? k.readdirSync(e, { withFileTypes: !0 }).flatMap((n) => {
343
344
  let r = O.join(e, n.name);
344
- return n.isDirectory() ? dn(r, t) : t.some((e) => n.name.endsWith(e)) ? [r] : [];
345
+ return n.isDirectory() ? vn(r, t) : t.some((e) => n.name.endsWith(e)) ? [r] : [];
345
346
  }) : [];
346
347
  }
347
- function fn(e, t) {
348
+ function yn(e, t) {
348
349
  let n = t.split("."), r = [e];
349
350
  for (let e of n.slice(0, -1)) r.push(r.at(-1)[e]);
350
351
  delete r.at(-1)[n.at(-1)];
351
352
  for (let e = r.length - 1; e >= 2 && !Object.keys(r[e]).some((e) => !e.startsWith("$")); e--) delete r[e - 1][n[e - 1]];
352
353
  }
353
354
  // src/core/init/from-site/clean-colors.ts
354
- function pn(e) {
355
+ function bn(e) {
355
356
  let { tree: t, destDir: n, picks: r, starterColors: i, siteColors: a, note: o, review: s, source: c, result: l } = e, u = (e, n) => {
356
- let r = ln(t, `${e}.${n}`)?.$value, o = typeof r == "string" ? r.match(/^\{(.+)\}$/)?.[1] : void 0;
357
+ let r = gn(t, `${e}.${n}`)?.$value, o = typeof r == "string" ? r.match(/^\{(.+)\}$/)?.[1] : void 0;
357
358
  return o && i.has(o) && !a.has(o) ? o : void 0;
358
359
  }, d = (e, n, r, i = {}) => {
359
- let [a, c] = e.split("."), u = ln(t, e), d = String(u.$value);
360
+ let [a, c] = e.split("."), u = gn(t, e), d = String(u.$value);
360
361
  t[a][c] = {
361
362
  $value: `{${n}}`,
362
363
  ...typeof u.$description == "string" && { $description: u.$description },
363
- $extensions: sn({
364
+ $extensions: mn({
364
365
  ...i,
365
366
  review: r ? {
366
367
  ...s,
@@ -391,20 +392,20 @@ function pn(e) {
391
392
  let [n, r] = e.split("."), i = p(t);
392
393
  i && u(n, r) && d(e, f(i), "", { source: c(`:root { ${i.cssVar} }`, i.exact ? i.cssVar : void 0) });
393
394
  }
394
- let m = t.color, { color: h, ...g } = t, _ = new Set(un(g));
395
- for (let e of dn(O.join(n, "tokens"), [".json"])) if (O.basename(e) !== "colors.json") for (let t of un(an(e))) _.add(t);
396
- let v = [O.join(n, "blazon.json"), ...dn(O.join(n, "docs"), [".md", ".mdx"])].filter((e) => k.existsSync(e)).map((e) => k.readFileSync(e, "utf-8")).join("\n");
395
+ let m = t.color, { color: h, ...g } = t, _ = new Set(_n(g));
396
+ for (let e of vn(O.join(n, "tokens"), [".json"])) if (O.basename(e) !== "colors.json") for (let t of _n(fn(e))) _.add(t);
397
+ let v = [O.join(n, "blazon.json"), ...vn(O.join(n, "docs"), [".md", ".mdx"])].filter((e) => k.existsSync(e)).map((e) => k.readFileSync(e, "utf-8")).join("\n");
397
398
  for (let e of v.matchAll(/(?<![\w.-])color(?:\.[A-Za-z0-9_-]+)+/g)) _.add(e[0]);
398
399
  let y = [..._];
399
400
  for (; y.length > 0;) {
400
- let e = ln(t, y.pop());
401
- for (let t of e ? un(e.$value) : []) _.has(t) || (_.add(t), y.push(t));
401
+ let e = gn(t, y.pop());
402
+ for (let t of e ? _n(e.$value) : []) _.has(t) || (_.add(t), y.push(t));
402
403
  }
403
- for (let e of [...i].filter((e) => !a.has(e) && !_.has(e))) ln({ color: m }, e) && (fn({ color: m }, e), l.removed.push(`${e} (a starter color nothing uses)`));
404
+ for (let e of [...i].filter((e) => !a.has(e) && !_.has(e))) gn({ color: m }, e) && (yn({ color: m }, e), l.removed.push(`${e} (a starter color nothing uses)`));
404
405
  }
405
406
  // src/core/init/palette.ts
406
- var mn = "#ffffff", hn = "#0b1120";
407
- function gn(e) {
407
+ var xn = "#ffffff", Sn = "#0b1120";
408
+ function Cn(e) {
408
409
  let t = e.trim().match(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i);
409
410
  if (!t) return;
410
411
  let n = t[1].length === 3 ? [...t[1]].map((e) => e + e).join("") : t[1];
@@ -414,38 +415,38 @@ function gn(e) {
414
415
  4
415
416
  ].map((e) => parseInt(n.slice(e, e + 2), 16) / 255);
416
417
  }
417
- var _n = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
418
- function vn(e) {
419
- let t = gn(e);
418
+ var wn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
419
+ function Tn(e) {
420
+ let t = Cn(e);
420
421
  if (!t) throw Error(`not a hex color: ${e}`);
421
422
  return t;
422
423
  }
423
- function yn(e) {
424
- let [t, n, r] = vn(e).map(_n);
424
+ function En(e) {
425
+ let [t, n, r] = Tn(e).map(wn);
425
426
  return .2126 * t + .7152 * n + .0722 * r;
426
427
  }
427
428
  function z(e, t) {
428
- let [n, r] = [yn(e), yn(t)];
429
+ let [n, r] = [En(e), En(t)];
429
430
  return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
430
431
  }
431
- var bn = (e) => e >= 7 ? "AAA" : e >= 4.5 ? "AA" : e >= 3 ? "AA-large" : "fail";
432
- function xn(e) {
433
- let t = z(e, mn), n = z(e, hn);
432
+ var Dn = (e) => e >= 7 ? "AAA" : e >= 4.5 ? "AA" : e >= 3 ? "AA-large" : "fail";
433
+ function On(e) {
434
+ let t = z(e, xn), n = z(e, Sn);
434
435
  return {
435
436
  onWhite: {
436
437
  ratio: t,
437
- level: bn(t)
438
+ level: Dn(t)
438
439
  },
439
440
  onNearBlack: {
440
441
  ratio: n,
441
- level: bn(n)
442
+ level: Dn(n)
442
443
  },
443
444
  carriesWhiteText: t >= 4.5
444
445
  };
445
446
  }
446
- var Sn = "#1E1F21", Cn = "#F2F0EB";
447
- function wn(e) {
448
- let t = z(e, Sn), n = z(e, Cn);
447
+ var kn = "#1E1F21", An = "#F2F0EB";
448
+ function jn(e) {
449
+ let t = z(e, kn), n = z(e, An);
449
450
  return t >= n ? {
450
451
  ink: "graphite",
451
452
  ratio: t,
@@ -457,42 +458,42 @@ function wn(e) {
457
458
  };
458
459
  }
459
460
  // src/core/init/vocabulary.ts
460
- var Tn = "color.signal.orange", En = "color.signal.primary", Dn = "color.signal.hazard", On = (e) => typeof e == "object" && !!e && "$value" in e;
461
+ var Mn = "color.signal.orange", Nn = "color.signal.primary", Pn = "color.signal.hazard", Fn = (e) => typeof e == "object" && !!e && "$value" in e;
461
462
  function B(e, t) {
462
463
  let n = e;
463
464
  for (let e of t.split(".")) {
464
465
  if (typeof n != "object" || !n) return;
465
466
  n = n[e];
466
467
  }
467
- return On(n) ? n : void 0;
468
+ return Fn(n) ? n : void 0;
468
469
  }
469
- function kn(e, t) {
470
+ function In(e, t) {
470
471
  let n = e.$extensions ??= {}, r = n["dev.blazon"] ??= {};
471
472
  r.review === void 0 && (r.review = {
472
473
  status: "needs-review",
473
474
  note: t
474
475
  });
475
476
  }
476
- function An(e, t) {
477
+ function Ln(e, t) {
477
478
  let n = [], r = e.color, i = r?.signal, a = i?.orange;
478
- if (!i || !On(a)) throw Error(`${Tn} is not in the tokens`);
479
+ if (!i || !Fn(a)) throw Error(`${Mn} is not in the tokens`);
479
480
  let o = {};
480
481
  for (let [e, t] of Object.entries(i)) o[e === "orange" ? "primary" : e] = t;
481
482
  r.signal = o;
482
- let s = JSON.parse(JSON.stringify(e).split(`{${Tn}}`).join(`{${En}}`));
483
+ let s = JSON.parse(JSON.stringify(e).split(`{${Mn}}`).join(`{${Nn}}`));
483
484
  for (let t of Object.keys(e)) e[t] = s[t];
484
- let c = B(e, En);
485
+ let c = B(e, Nn);
485
486
  c.$value = t, c.$description = "Primary signal color";
486
- let l = jn(e, t, `{${En}}`);
487
+ let l = Rn(e, t, `{${Nn}}`);
487
488
  n.push(...l.hints);
488
- let u = B(e, Dn);
489
- return u && (kn(u, "Still blazon's hazard yellow: it was not chosen to go with your primary. Set the brand's own, or remove it."), n.push(`${Dn} is still blazon's hazard yellow and is marked needs-review: set the brand's own or remove it`)), {
489
+ let u = B(e, Pn);
490
+ return u && (In(u, "Still blazon's hazard yellow: it was not chosen to go with your primary. Set the brand's own, or remove it."), n.push(`${Pn} is still blazon's hazard yellow and is marked needs-review: set the brand's own or remove it`)), {
490
491
  hints: n,
491
492
  label: l.label
492
493
  };
493
494
  }
494
- function jn(e, t, n, r = !1) {
495
- let i = [], a = z(t, Sn), o = z(t, Cn), s = B(e, "text.onSignal"), c = a < 4.5 && o >= 4.5 && s !== void 0;
495
+ function Rn(e, t, n, r = !1) {
496
+ let i = [], a = z(t, kn), o = z(t, An), s = B(e, "text.onSignal"), c = a < 4.5 && o >= 4.5 && s !== void 0;
496
497
  if (c ? (s.$value = "{color.base.bone}", s.$description = "Labels on the brand color are bone", i.push(`Labels on ${t} are bone, because graphite is ${a.toFixed(1)}:1 there; blazon's hazard yellow has no label pair now`)) : a < 4.5 && i.push(`Neither graphite (${a.toFixed(1)}:1) nor bone (${o.toFixed(1)}:1) reaches AA (4.5:1) as a label on ${t}: blazon check will report text.onSignal, so choose a lighter or darker color`), c || r) {
497
498
  let t = e.text?.$extensions?.["dev.blazon"];
498
499
  for (let e of t?.pairs ?? []) e.bg === "{color.signal.*}" && (e.bg = n);
@@ -502,16 +503,16 @@ function jn(e, t, n, r = !1) {
502
503
  label: c ? "bone" : "graphite"
503
504
  };
504
505
  }
505
- var Mn = (e) => JSON.parse(k.readFileSync(e, "utf-8")), Nn = (e, t) => k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
506
- function Pn(e, t) {
506
+ var zn = (e) => JSON.parse(k.readFileSync(e, "utf-8")), Bn = (e, t) => k.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
507
+ function Vn(e, t) {
507
508
  return [...t, ...Array.isArray(e) ? e.filter((e) => typeof e == "object" && !!e) : []];
508
509
  }
509
- var Fn = ["blazon-graphite", "blazon-bone"], In = [...Fn, "blazon-mark"];
510
+ var Hn = ["blazon-graphite", "blazon-bone"], Un = [...Hn, "blazon-mark"];
510
511
  // src/core/init/shared/hex.ts
511
- function Ln(e) {
512
+ function Wn(e) {
512
513
  let t = e.trim();
513
514
  if (/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)) return {
514
- hex: Bt(t),
515
+ hex: qt(t),
515
516
  exact: !0
516
517
  };
517
518
  let n = t.match(/^rgba?\(\s*([\d.]+)(%?)[\s,]+([\d.]+)%?[\s,]+([\d.]+)%?(?:\s*[,/]\s*([\d.]+)(%?))?\s*\)$/i);
@@ -527,12 +528,12 @@ function Ln(e) {
527
528
  };
528
529
  }
529
530
  // src/core/init/from-site/colors.ts
530
- var Rn = 40, zn = /brand|primary|secondary|accent|background|foreground|surface/i;
531
- function Bn(e) {
531
+ var Gn = 40, Kn = /brand|primary|secondary|accent|background|foreground|surface/i;
532
+ function qn(e) {
532
533
  let t = [], n = /* @__PURE__ */ new Set();
533
534
  for (let [r, i] of e) {
534
- if (!zn.test(r)) continue;
535
- let e = Ln(i);
535
+ if (!Kn.test(r)) continue;
536
+ let e = Wn(i);
536
537
  if (!e || e.hex.length !== 7) continue;
537
538
  let a = r.slice(2).toLowerCase().split(/[-_]+/).filter(Boolean);
538
539
  a.length > 1 && (a[0] === "color" || a[0] === "colors") && (a = a.slice(1)), a.length > 1 && a.at(-1) === "foreground" || a.length > 1 && a.at(-2) === "on" && /^(dark|light)$/.test(a.at(-1)) || a.length === 0 || n.has(a.join(".")) || (n.add(a.join(".")), t.push({
@@ -541,20 +542,20 @@ function Bn(e) {
541
542
  segments: a
542
543
  }));
543
544
  }
544
- return t.slice(0, Rn);
545
+ return t.slice(0, Gn);
545
546
  }
546
- function Vn(e, t, n = []) {
547
+ function Jn(e, t, n = []) {
547
548
  let r = e.filter((e) => e.segments.includes(t)).sort((e, n) => Number(e.segments.at(-1) !== t) - Number(n.segments.at(-1) !== t) || e.segments.length - n.segments.length)[0];
548
549
  return r || t !== "secondary" ? r : e.find((e) => !n.includes(e) && e.segments.includes("brand") && !e.segments.some((e) => /light|dark|strong|hero|raised|navy|background|foreground|surface/.test(e)));
549
550
  }
550
551
  // src/core/init/from-site/context.ts
551
- var Hn = (...e) => e.join("/");
552
+ var Yn = (...e) => e.join("/");
552
553
  // src/core/init/from-site/sections/colors.ts
553
- function Un(e, t) {
554
- let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = Bn(r).filter((e) => !t?.has(e.cssVar));
554
+ function Xn(e, t) {
555
+ let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = qn(r).filter((e) => !t?.has(e.cssVar));
555
556
  if (l.length === 0) i.missing.push("no brand color: no custom property named brand, primary, secondary, accent, background, foreground or surface holds a hex or rgb() color");
556
- else if (c(Hn("tokens", "colors.json"))) {
557
- let e = O.join(n, "tokens", "colors.json"), t = an(e), r = t.color ??= {}, c = new Set(cn(r, ["color"])), u = /* @__PURE__ */ new Set(), d = new Set(l.map((e) => e.segments.join(".")));
557
+ else if (c(Yn("tokens", "colors.json"))) {
558
+ let e = O.join(n, "tokens", "colors.json"), t = fn(e), r = t.color ??= {}, c = new Set(hn(r, ["color"])), u = /* @__PURE__ */ new Set(), d = new Set(l.map((e) => e.segments.join(".")));
558
559
  for (let e of l) {
559
560
  let t = e.segments;
560
561
  [...d].some((e) => e.startsWith(`${t.join(".")}.`)) && (t = [...t, "base"]);
@@ -563,37 +564,37 @@ function Un(e, t) {
563
564
  let t = n[r];
564
565
  if (t === void 0) {
565
566
  let t = {};
566
- e === 0 && (t.$extensions = sn({ review: o }), a = !0), n[r] = t, n = t;
567
- } else if (rn(t) || typeof t != "object" || !t) {
567
+ e === 0 && (t.$extensions = mn({ review: o }), a = !0), n[r] = t, n = t;
568
+ } else if (dn(t) || typeof t != "object" || !t) {
568
569
  c = !1;
569
570
  break;
570
571
  } else n = t;
571
572
  }
572
573
  let l = t.at(-1);
573
- !c || typeof n[l] == "object" && n[l] !== null && !rn(n[l]) ? i.missing.push(`${e.cssVar} was not written: color.${t.join(".")} clashes with a starter token`) : (n[l] = {
574
+ !c || typeof n[l] == "object" && n[l] !== null && !dn(n[l]) ? i.missing.push(`${e.cssVar} was not written: color.${t.join(".")} clashes with a starter token`) : (n[l] = {
574
575
  $value: e.hex,
575
- $extensions: sn({
576
+ $extensions: mn({
576
577
  source: s(`:root { ${e.cssVar} }`, e.exact ? e.cssVar : void 0),
577
578
  ...a ? {} : { review: o }
578
579
  })
579
580
  }, e.segments = t, u.add(e));
580
581
  }
581
- let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p = Vn(l, "primary"), m = t.interactive, h = ln(t, "interactive.primary");
582
+ let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p = Jn(l, "primary"), m = t.interactive, h = gn(t, "interactive.primary");
582
583
  if (!p) i.missing.push("no primary color: interactive.primary keeps the starter's value");
583
584
  else if (m && h) {
584
585
  let e = `color.${p.segments.join(".")}`;
585
586
  m.primary = {
586
587
  $value: `{${e}}`,
587
588
  ...typeof h.$description == "string" && { $description: h.$description },
588
- $extensions: sn({
589
+ $extensions: mn({
589
590
  source: s(`:root { ${p.cssVar} }`, p.exact ? p.cssVar : void 0),
590
591
  review: o
591
592
  })
592
593
  }, i.repointed.push(`interactive.primary to {${e}}`);
593
- let n = jn(t, p.hex, `{${e}}`, !0);
594
+ let n = Rn(t, p.hex, `{${e}}`, !0);
594
595
  for (let e of n.hints) i.missing.push(e);
595
596
  } else i.missing.push("interactive.primary was not found in tokens/colors.json, so the primary color was not set");
596
- pn({
597
+ bn({
597
598
  tree: t,
598
599
  destDir: n,
599
600
  picks: [...u],
@@ -603,11 +604,11 @@ function Un(e, t) {
603
604
  review: o,
604
605
  source: s,
605
606
  result: i
606
- }), on(e, t), i.written.push(Hn("tokens", "colors.json"));
607
+ }), pn(e, t), i.written.push(Yn("tokens", "colors.json"));
607
608
  }
608
609
  }
609
610
  // src/core/init/from-site/html.ts
610
- function Wn(e) {
611
+ function Zn(e) {
611
612
  return e.replace(/&amp;/g, "&").replace(/&quot;/g, "\"").replace(/&#0?39;|&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim().split(/ [|:–—-] /)[0].trim();
612
613
  }
613
614
  var V = (e, t) => {
@@ -620,36 +621,36 @@ function H(e, t) {
620
621
  if (e) return e;
621
622
  }
622
623
  }
623
- function Gn(e) {
624
+ function Qn(e) {
624
625
  let t = H(e, "og:site_name") ?? H(e, "application-name");
625
626
  if (t) return t;
626
627
  let n = e.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i);
627
- return (n ? Wn(n[1]) : "") || void 0;
628
+ return (n ? Zn(n[1]) : "") || void 0;
628
629
  }
629
- async function Kn(e, t) {
630
+ async function $n(e, t) {
630
631
  let n = (e.match(/<link\b[^>]*>/gi) ?? []).find((e) => V(e, "rel")?.toLowerCase() === "manifest"), r = n && V(n, "href");
631
632
  if (r) try {
632
633
  let e = new URL(r, t);
633
634
  if (e.protocol !== "http:" && e.protocol !== "https:") return;
634
- let n = JSON.parse(await $t(e.href)), i = typeof n.short_name == "string" ? n.short_name.trim() : "", a = typeof n.name == "string" ? Wn(n.name) : "";
635
+ let n = JSON.parse(await sn(e.href)), i = typeof n.short_name == "string" ? n.short_name.trim() : "", a = typeof n.name == "string" ? Zn(n.name) : "";
635
636
  return i || a || void 0;
636
637
  } catch {
637
638
  return;
638
639
  }
639
640
  }
640
641
  // src/core/init/from-site/sections/config.ts
641
- async function qn(e, t, n) {
642
- let { destDir: r, url: i, page: a, result: o, mayChange: s } = e, { fontUrls: c } = n, l = "blazon.json", u = H(a.html, "og:site_name") ?? H(a.html, "application-name") ?? await Kn(a.html, i) ?? Gn(a.html), d = H(a.html, "description");
642
+ async function er(e, t, n) {
643
+ let { destDir: r, url: i, page: a, result: o, mayChange: s } = e, { fontUrls: c } = n, l = "blazon.json", u = H(a.html, "og:site_name") ?? H(a.html, "application-name") ?? await $n(a.html, i) ?? Qn(a.html), d = H(a.html, "description");
643
644
  u || o.missing.push("no <title> on the page: the config title keeps the folder name");
644
645
  let f = !1;
645
646
  if ((u || d || t.single || t.onLight || c.length > 0) && s(l)) {
646
- let e = O.join(r, l), n = Mn(e);
647
+ let e = O.join(r, l), n = zn(e);
647
648
  u && (n.title = u), d && (n.description = d);
648
649
  let i = t.single ?? (t.onLight ? {
649
650
  onLight: t.onLight,
650
651
  ...t.onDark ? { onDark: t.onDark } : {}
651
652
  } : void 0);
652
- i && (n.logo = i), c.length > 0 && (n.fonts = Pn(n.fonts, c)), Nn(e, n), o.written.push(l), f = !!i;
653
+ i && (n.logo = i), c.length > 0 && (n.fonts = Vn(n.fonts, c)), Bn(e, n), o.written.push(l), f = !!i;
653
654
  }
654
655
  return {
655
656
  title: u,
@@ -658,15 +659,15 @@ async function qn(e, t, n) {
658
659
  };
659
660
  }
660
661
  // src/core/init/from-site/sections/directives.ts
661
- var Jn = /^[ \t]*<!--\s*blazon:tokens\b([^>]*?)-->[ \t]*\r?\n?/gm;
662
- function Yn(e) {
662
+ var tr = /^[ \t]*<!--\s*blazon:tokens\b([^>]*?)-->[ \t]*\r?\n?/gm;
663
+ function nr(e) {
663
664
  let { destDir: t, created: n, result: r } = e, i = O.join(t, "docs");
664
665
  if (!k.existsSync(i)) return;
665
- let a = te(ie(O.join(t, "tokens"), t), "--").items, o = (e) => a.some((t) => t.path === e || t.path.startsWith(`${e}.`));
666
+ let a = ce(Be(O.join(t, "tokens"), t), "--").items, o = (e) => a.some((t) => t.path === e || t.path.startsWith(`${e}.`));
666
667
  for (let e of k.readdirSync(i).filter((e) => e.endsWith(".md"))) {
667
668
  let t = `docs/${e}`;
668
669
  if (!n.has(t)) continue;
669
- let a = O.join(i, e), s = k.readFileSync(a, "utf-8"), c = [], l = s.replace(Jn, (e, t) => {
670
+ let a = O.join(i, e), s = k.readFileSync(a, "utf-8"), c = [], l = s.replace(tr, (e, t) => {
670
671
  let n = t.split(/\s+/).filter(Boolean), r = n.filter(o);
671
672
  return c.push(...n.filter((e) => !o(e))), r.length === n.length ? e : r.length === 0 ? "" : `<!-- blazon:tokens ${r.join(" ")} -->\n`;
672
673
  }).replace(/\n{3,}/g, "\n\n");
@@ -674,7 +675,7 @@ function Yn(e) {
674
675
  }
675
676
  }
676
677
  // src/core/init/shared/google-fonts.ts
677
- var Xn = [
678
+ var rr = [
678
679
  "Inter",
679
680
  "Roboto",
680
681
  "Open Sans",
@@ -692,12 +693,12 @@ var Xn = [
692
693
  "Playfair Display",
693
694
  "JetBrains Mono"
694
695
  ];
695
- function Zn(e) {
696
- let t = Xn.find((t) => t.toLowerCase() === e.toLowerCase());
696
+ function ir(e) {
697
+ let t = rr.find((t) => t.toLowerCase() === e.toLowerCase());
697
698
  return t ? `https://fonts.googleapis.com/css2?family=${t.replace(/ /g, "+")}:wght@400;500;600;700&display=swap` : void 0;
698
699
  }
699
700
  // src/core/init/from-site/fonts.ts
700
- var Qn = /* @__PURE__ */ new Set([
701
+ var ar = /* @__PURE__ */ new Set([
701
702
  "serif",
702
703
  "sans-serif",
703
704
  "monospace",
@@ -717,19 +718,55 @@ var Qn = /* @__PURE__ */ new Set([
717
718
  "-apple-system",
718
719
  "blinkmacsystemfont",
719
720
  "segoe ui"
720
- ]), $n = /* @__PURE__ */ new Set([
721
+ ]), or = /* @__PURE__ */ new Set([
721
722
  "serif",
722
723
  "sans-serif",
723
724
  "monospace",
724
725
  "cursive",
725
726
  "fantasy"
726
- ]);
727
- function er(e) {
728
- let t = [], n = "", r = "";
729
- for (let i of e) r ? i === r ? r = "" : n += i : i === "\"" || i === "'" ? r = i : i === "," ? (t.push(n.trim()), n = "") : n += i;
727
+ ]), sr = /[0-9a-fA-F]/, cr = /[\n\r\f]/;
728
+ function lr(e, t) {
729
+ if (!sr.test(e[t])) return {
730
+ text: e[t],
731
+ next: t + 1
732
+ };
733
+ let n = "", r = t;
734
+ for (; n.length < 6 && r < e.length && sr.test(e[r]);) n += e[r++];
735
+ e.startsWith("\r\n", r) ? r += 2 : r < e.length && /\s/.test(e[r]) && (r += 1);
736
+ let i = parseInt(n, 16);
737
+ return {
738
+ text: i !== 0 && i <= 1114111 && (i < 55296 || i > 57343) ? String.fromCodePoint(i) : "�",
739
+ next: r
740
+ };
741
+ }
742
+ function ur(e) {
743
+ let t = [], n = "", r = "bare", i = "", a = 0, o = 0;
744
+ for (; o < e.length;) {
745
+ let s = e[o];
746
+ if (r === "string") {
747
+ if (s === i) r = "bare", o++;
748
+ else if (cr.test(s)) r = "bare";
749
+ else if (s === "\\") {
750
+ if (o + 1 >= e.length) o++;
751
+ else if (e.startsWith("\r\n", o + 1)) o += 3;
752
+ else if (cr.test(e[o + 1])) o += 2;
753
+ else {
754
+ let t = lr(e, o + 1);
755
+ n += t.text, o = t.next;
756
+ }
757
+ } else n += s, o++;
758
+ } else if (r === "call") n += s, o++, i ? s === "\\" && o < e.length ? n += e[o++] : s === i && (i = "") : s === "\"" || s === "'" ? i = s : s === "(" ? a++ : s === ")" && --a === 0 && (r = "bare");
759
+ else if (s === "\"" || s === "'") r = "string", i = s, o++;
760
+ else if (s === "(") r = "call", i = "", a = 1, n += s, o++;
761
+ else if (s === ",") t.push(n.trim()), n = "", o++;
762
+ else if (s === "\\" && o + 1 < e.length && !cr.test(e[o + 1])) {
763
+ let t = lr(e, o + 1);
764
+ n += t.text, o = t.next;
765
+ } else n += s, o++;
766
+ }
730
767
  return t.push(n.trim()), t.filter(Boolean);
731
768
  }
732
- function tr(e, t, n) {
769
+ function dr(e, t, n) {
733
770
  let r;
734
771
  for (let i of e.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/([^{}]*)\{([^{}]*)\}/g)) {
735
772
  let e = i[1].split(",").map((e) => e.trim().toLowerCase()).find((e) => n.test(e));
@@ -741,7 +778,7 @@ function tr(e, t, n) {
741
778
  let e = t.get(c[1]);
742
779
  o = e ?? c[2] ?? "", e !== void 0 && (s = c[1]);
743
780
  }
744
- let l = er(o), u = l.find((e) => !Qn.has(e.toLowerCase()) && !e.startsWith("var("));
781
+ let l = ur(o), u = l.find((e) => !ar.has(e.toLowerCase()) && !e.startsWith("var("));
745
782
  u && (r = {
746
783
  family: u,
747
784
  stack: l,
@@ -751,21 +788,21 @@ function tr(e, t, n) {
751
788
  }
752
789
  return r;
753
790
  }
754
- function nr(e) {
755
- let t = e.stack.find((e) => $n.has(e.toLowerCase()));
791
+ function fr(e) {
792
+ let t = e.stack.find((e) => or.has(e.toLowerCase()));
756
793
  return [e.family, (t ?? "sans-serif").toLowerCase()];
757
794
  }
758
795
  // src/core/init/from-site/sections/fonts.ts
759
- function rr(e) {
760
- let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = tr(n.css, r, /^(body|html)$/), u = tr(n.css, r, /^h[1-6]$/), d = [];
796
+ function pr(e) {
797
+ let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = dr(n.css, r, /^(body|html)$/), u = dr(n.css, r, /^h[1-6]$/), d = [];
761
798
  if (!l && !u) i.missing.push("no font: no body or heading rule in the stylesheets names a font-family");
762
- else if (c(Hn("tokens", "typography.json"))) {
763
- let e = O.join(t, "tokens", "typography.json"), n = an(e), r = (n.font ??= {}).family ??= {}, c = l ?? u, f = [["body", c], ["display", u ?? c]];
799
+ else if (c(Yn("tokens", "typography.json"))) {
800
+ let e = O.join(t, "tokens", "typography.json"), n = fn(e), r = (n.font ??= {}).family ??= {}, c = l ?? u, f = [["body", c], ["display", u ?? c]];
764
801
  for (let [e, t] of f) {
765
- let n = Zn(t.family);
802
+ let n = ir(t.family);
766
803
  n ? d.includes(n) || d.push(n) : i.missing.push(`the font ${t.family} is not one blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`), r[e] = {
767
- $value: nr(t),
768
- $extensions: sn({
804
+ $value: fr(t),
805
+ $extensions: mn({
769
806
  source: s(t.cssVar ? `${t.locator}, from ${t.cssVar}` : t.locator),
770
807
  review: n ? o : {
771
808
  status: "needs-review",
@@ -775,23 +812,23 @@ function rr(e) {
775
812
  };
776
813
  }
777
814
  let p = r.mono;
778
- p && kn(p, `${a} Still blazon's mono font: the site's stylesheets named no monospace font. Set the brand's own.`), on(e, n), i.written.push(Hn("tokens", "typography.json"));
815
+ p && In(p, `${a} Still blazon's mono font: the site's stylesheets named no monospace font. Set the brand's own.`), pn(e, n), i.written.push(Yn("tokens", "typography.json"));
779
816
  }
780
817
  return { fontUrls: d };
781
818
  }
782
819
  // src/core/init/from-site/sections/intro.ts
783
- var ir = (e) => e.length === 1 && e[0] === "logo", ar = (e) => e.length < 2 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
784
- function or(e) {
820
+ var mr = (e) => e.length === 1 && e[0] === "logo", hr = (e) => e.length < 2 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
821
+ function gr(e) {
785
822
  let { url: t, date: n, result: r } = e, i = {
786
823
  colors: r.written.includes("tokens/colors.json"),
787
824
  fonts: r.written.includes("tokens/typography.json"),
788
825
  logo: r.written.some((e) => e.startsWith("assets/logos/"))
789
826
  }, a = Object.entries(i).filter(([, e]) => e).map(([e]) => e), o = Object.entries(i).filter(([, e]) => !e).map(([e]) => e);
790
827
  if (a.length === 0) return `Nothing could be read from ${t} on ${n}: it gave no brand colors, no fonts and no logo. This brand book is still blazon's own starter, so replace its colors, fonts and logo with the brand's.`;
791
- let s = `The ${ar(a)} in this brand book ${ir(a) ? "was" : "were"} read from ${t} on ${n}. They are what the site shows today, so the brand owner needs to confirm them before anyone relies on them.`;
792
- return o.length === 0 ? s : `${s} The ${ar(o)} ${ir(o) ? "was" : "were"} not found, so ${ir(o) ? "it is" : "they are"} still blazon's own starter: replace ${ir(o) ? "it" : "them"}.`;
828
+ let s = `The ${hr(a)} in this brand book ${mr(a) ? "was" : "were"} read from ${t} on ${n}. They are what the site shows today, so the brand owner needs to confirm them before anyone relies on them.`;
829
+ return o.length === 0 ? s : `${s} The ${hr(o)} ${mr(o) ? "was" : "were"} not found, so ${mr(o) ? "it is" : "they are"} still blazon's own starter: replace ${mr(o) ? "it" : "them"}.`;
793
830
  }
794
- function sr(e, t, n) {
831
+ function _r(e, t, n) {
795
832
  let { destDir: r, url: i, created: a, result: o } = e, s = "docs/01-principles.md";
796
833
  if (a.has(s) && k.existsSync(O.join(r, s))) {
797
834
  let a = t ?? new URL(i).hostname.replace(/^www\./, ""), c = [
@@ -806,19 +843,19 @@ function sr(e, t, n) {
806
843
  `# ${a}`,
807
844
  "",
808
845
  ...n ? [n, ""] : [],
809
- or(e),
846
+ gr(e),
810
847
  ""
811
848
  ];
812
849
  k.writeFileSync(O.join(r, s), c.join("\n")), o.written.push(s);
813
850
  }
814
851
  }
815
852
  // src/core/init/shared/svg.ts
816
- function cr(e) {
853
+ function vr(e) {
817
854
  let t = e.replace(/<script\b[\s\S]*?<\/script>/gi, "").replace(/\son\w+\s*=\s*(?:"[^"]*"|'[^']*')/gi, "").replace(/(href\s*=\s*["'])\s*javascript:[^"']*/gi, "$1#");
818
855
  return /<svg\b[^>]*\sxmlns\s*=/i.test(t) || (t = t.replace(/<svg\b/i, "<svg xmlns=\"http://www.w3.org/2000/svg\"")), `${t.trim()}\n`;
819
856
  }
820
857
  // src/core/init/from-site/logo.ts
821
- function lr(e, t) {
858
+ function yr(e, t) {
822
859
  let n = e.replace(/<!--[\s\S]*?-->/g, "").match(/<header\b[^>]*>([\s\S]*?)<\/header>/i)?.[1];
823
860
  if (!n) return;
824
861
  let r = [];
@@ -867,7 +904,7 @@ function lr(e, t) {
867
904
  locator: "header img"
868
905
  } : void 0;
869
906
  }
870
- function ur(e, t) {
907
+ function br(e, t) {
871
908
  let n = [];
872
909
  for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
873
910
  let e = (V(r, "rel") ?? "").toLowerCase().split(/\s+/), i = e.includes("apple-touch-icon") || e.includes("apple-touch-icon-precomposed");
@@ -888,14 +925,14 @@ function ur(e, t) {
888
925
  }
889
926
  return n.find((e) => e.svg) ?? n.find((e) => e.apple) ?? n[0];
890
927
  }
891
- function dr(e) {
928
+ function xr(e) {
892
929
  let t = new URL(e).hostname.replace(/^www\./, "");
893
930
  return /^[\d.]+$/.test(t) || t.includes(":") || t.startsWith("[") ? "site" : t.split(".")[0].replace(/[^a-z0-9-]/gi, "-").toLowerCase() || "site";
894
931
  }
895
932
  // src/core/init/from-site/sections/logo.ts
896
- async function fr(e) {
897
- let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l = dr(n), u = (e, i, c) => {
898
- on(O.join(t, e.replace(/\.[a-z]+$/, ".json")), {
933
+ async function Sr(e) {
934
+ let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l = xr(n), u = (e, i, c) => {
935
+ pn(O.join(t, e.replace(/\.[a-z]+$/, ".json")), {
899
936
  description: o,
900
937
  ...c,
901
938
  source: {
@@ -907,24 +944,24 @@ async function fr(e) {
907
944
  }, d = (e, n) => {
908
945
  let r = O.join(t, e), i = [e, e.replace(/\.[a-z]+$/, ".json")].filter((e) => k.existsSync(O.join(t, e)));
909
946
  return i.length > 0 ? (a.missing.push(`${i.join(" and ")} already existed, so ${i.length > 1 ? "they were" : "it was"} kept as ${i.length > 1 ? "they were" : "it was"}, and no logo was written to ${e}`), !1) : (k.mkdirSync(O.dirname(r), { recursive: !0 }), k.writeFileSync(r, n), a.written.push(e), !0);
910
- }, f = lr(i.html, n), p, m = "";
947
+ }, f = yr(i.html, n), p, m = "";
911
948
  if (f?.kind === "inline") p = f.svg, m = f.locator;
912
949
  else if (f?.kind === "url") {
913
950
  try {
914
- p = (await Qt(f.url)).toString("utf8"), m = `${f.locator} (${f.url})`;
951
+ p = (await on(f.url)).toString("utf8"), m = `${f.locator} (${f.url})`;
915
952
  } catch (e) {
916
953
  a.missing.push(`the header logo could not be read: ${e instanceof Error ? e.message : String(e)}`);
917
954
  }
918
955
  p !== void 0 && !/<svg\b/i.test(p) && (p = void 0, a.missing.push(`${f.url} is not an SVG`));
919
956
  }
920
957
  let h;
921
- if (p === void 0 && (h = ur(i.html, n), h?.svg)) try {
922
- p = (await Qt(h.url)).toString("utf8"), m = `${h.locator} (${h.url})`, /<svg\b/i.test(p) || (p = void 0);
958
+ if (p === void 0 && (h = br(i.html, n), h?.svg)) try {
959
+ p = (await on(h.url)).toString("utf8"), m = `${h.locator} (${h.url})`, /<svg\b/i.test(p) || (p = void 0);
923
960
  } catch (e) {
924
961
  a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
925
962
  }
926
963
  if (p !== void 0) {
927
- let e = cr(p);
964
+ let e = vr(p);
928
965
  if (/<use\b/i.test(e) && !/<symbol\b/i.test(e) && a.missing.push("the logo uses <use> to point at a sprite elsewhere on the page, so it may draw nothing: check it"), /currentColor/i.test(e)) {
929
966
  let t = `assets/logos/${l}.svg`, n = `assets/logos/${l}-white.svg`;
930
967
  d(t, e.replace(/currentColor/gi, "#111111")) && (u(t, m, {
@@ -951,7 +988,7 @@ async function fr(e) {
951
988
  ].includes(h.ext)) a.missing.push(`only a ${h.ext} icon was found (${h.url}), which blazon cannot show: no logo was written`);
952
989
  else try {
953
990
  let e = `assets/logos/${l}${h.ext === ".jpeg" ? ".jpg" : h.ext}`;
954
- d(e, await Qt(h.url)) && (u(e, h.locator, { title: "Site icon" }), c.single = `./${e}`, a.missing.push(`no SVG logo was found: ${e} is the site's raster icon (${h.url}), not a logo, so replace it with the real one`));
991
+ d(e, await on(h.url)) && (u(e, h.locator, { title: "Site icon" }), c.single = `./${e}`, a.missing.push(`no SVG logo was found: ${e} is the site's raster icon (${h.url}), not a logo, so replace it with the real one`));
955
992
  } catch (e) {
956
993
  a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
957
994
  }
@@ -959,28 +996,28 @@ async function fr(e) {
959
996
  return c;
960
997
  }
961
998
  // src/core/init/from-site/sections/placeholder.ts
962
- function pr(e, t, n) {
999
+ function Cr(e, t, n) {
963
1000
  let { destDir: r, created: i, result: a } = e, o = t.single ?? t.onLight;
964
1001
  if (n && o) {
965
- let e = O.join(r, `assets/logos/${Fn[0]}.json`), t = O.join(r, o.replace(/^\.\//, "").replace(/\.[a-z]+$/, ".json"));
966
- if (i.has(`assets/logos/${Fn[0]}.json`) && k.existsSync(e) && k.existsSync(t)) {
967
- let { description: n, background: i, ...a } = an(e), s = an(t), c = k.readFileSync(O.join(r, o.replace(/^\.\//, "")), "utf-8").match(/<svg\b[^>]*>/i)?.[0] ?? "", l = c.match(/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+[\d.]+[\s,]+([\d.]+)/i)?.[1] ?? c.match(/\sheight\s*=\s*["']?([\d.]+)/i)?.[1];
1002
+ let e = O.join(r, `assets/logos/${Hn[0]}.json`), t = O.join(r, o.replace(/^\.\//, "").replace(/\.[a-z]+$/, ".json"));
1003
+ if (i.has(`assets/logos/${Hn[0]}.json`) && k.existsSync(e) && k.existsSync(t)) {
1004
+ let { description: n, background: i, ...a } = fn(e), s = fn(t), c = k.readFileSync(O.join(r, o.replace(/^\.\//, "")), "utf-8").match(/<svg\b[^>]*>/i)?.[0] ?? "", l = c.match(/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+[\d.]+[\s,]+([\d.]+)/i)?.[1] ?? c.match(/\sheight\s*=\s*["']?([\d.]+)/i)?.[1];
968
1005
  l && Number(l) > 0 && (a.clearSpace = {
969
1006
  value: Math.max(1, Math.round(Number(l) * .3 * 100) / 100),
970
1007
  unit: "px"
971
1008
  });
972
1009
  for (let [e, t] of Object.entries(a)) s[e] ??= t;
973
- s.description = `${String(s.description)} Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.`, on(t, s);
1010
+ s.description = `${String(s.description)} Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.`, pn(t, s);
974
1011
  }
975
- for (let e of In) for (let t of ["svg", "json"]) {
1012
+ for (let e of Un) for (let t of ["svg", "json"]) {
976
1013
  let n = `assets/logos/${e}.${t}`;
977
1014
  i.has(n) && (k.rmSync(O.join(r, n), { force: !0 }), a.removed.push(`${n} (blazon's own logo)`));
978
1015
  }
979
1016
  }
980
1017
  }
981
1018
  // src/core/init/from-site/apply.ts
982
- async function mr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
983
- let a = r.toISOString().slice(0, 10), o = i.page ?? await nn(t), s = {
1019
+ async function wr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
1020
+ let a = r.toISOString().slice(0, 10), o = i.page ?? await un(t), s = {
984
1021
  written: [],
985
1022
  missing: [],
986
1023
  removed: [],
@@ -991,7 +1028,7 @@ async function mr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
991
1028
  date: a,
992
1029
  created: n,
993
1030
  page: o,
994
- vars: Jt(o.css),
1031
+ vars: tn(o.css),
995
1032
  result: s,
996
1033
  note: c,
997
1034
  review: {
@@ -1005,23 +1042,23 @@ async function mr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
1005
1042
  }),
1006
1043
  mayChange: (e) => n.has(e) ? !0 : (s.missing.push(`${e} already existed, so it was kept as it was`), !1)
1007
1044
  };
1008
- Un(l, i.skipVars);
1009
- let u = rr(l), d = await fr(l), { title: f, description: p, configLogo: m } = await qn(l, d, u);
1010
- return pr(l, d, m), sr(l, f, p), Yn(l), s;
1045
+ Xn(l, i.skipVars);
1046
+ let u = pr(l), d = await Sr(l), { title: f, description: p, configLogo: m } = await er(l, d, u);
1047
+ return Cr(l, d, m), _r(l, f, p), nr(l), s;
1011
1048
  }
1012
1049
  // src/core/init/from-site/inspect.ts
1013
- async function hr(e) {
1014
- let t = await nn(e), n = Jt(t.css), r = Bn(n), i = tr(t.css, n, /^(body|html)$/), a = tr(t.css, n, /^h[1-6]$/), o = [];
1050
+ async function Tr(e) {
1051
+ let t = await un(e), n = tn(t.css), r = qn(n), i = dr(t.css, n, /^(body|html)$/), a = dr(t.css, n, /^h[1-6]$/), o = [];
1015
1052
  i && o.push({
1016
1053
  family: i.family,
1017
1054
  role: "body",
1018
- stylesheet: !!Zn(i.family)
1055
+ stylesheet: !!ir(i.family)
1019
1056
  }), a && a.family.toLowerCase() !== i?.family.toLowerCase() && o.push({
1020
1057
  family: a.family,
1021
1058
  role: "headings",
1022
- stylesheet: !!Zn(a.family)
1059
+ stylesheet: !!ir(a.family)
1023
1060
  });
1024
- let s = lr(t.html, e), c = ur(t.html, e), l = s ? `${s.kind === "inline" ? "an inline SVG" : `an SVG image (${s.url})`} in the page header` : c ? `the site icon (${c.url})${c.svg ? "" : `, a ${c.ext} image, not an SVG logo`}` : void 0, u = H(t.html, "og:site_name") ?? H(t.html, "application-name") ?? await Kn(t.html, e) ?? Gn(t.html), d = [];
1061
+ let s = yr(t.html, e), c = br(t.html, e), l = s ? `${s.kind === "inline" ? "an inline SVG" : `an SVG image (${s.url})`} in the page header` : c ? `the site icon (${c.url})${c.svg ? "" : `, a ${c.ext} image, not an SVG logo`}` : void 0, u = H(t.html, "og:site_name") ?? H(t.html, "application-name") ?? await $n(t.html, e) ?? Qn(t.html), d = [];
1025
1062
  return r.length === 0 && d.push("no brand colors: no custom property named brand, primary, secondary, accent, background, foreground or surface holds a hex or rgb() color"), o.length === 0 && d.push("no font: no body or heading rule names a font-family"), l || d.push("no logo: no SVG in the header and no icon link on the page"), u || d.push("no site name: the brand name stays as you typed it"), {
1026
1063
  page: t,
1027
1064
  name: u,
@@ -1036,23 +1073,23 @@ async function hr(e) {
1036
1073
  };
1037
1074
  }
1038
1075
  // src/core/init/answers.ts
1039
- var gr = [
1076
+ var Er = [
1040
1077
  ".svg",
1041
1078
  ".png",
1042
1079
  ".jpg",
1043
1080
  ".jpeg",
1044
1081
  ".webp"
1045
- ], _r = (e) => e.trim() ? { value: e.trim() } : { hint: "A name cannot be empty." }, vr = (e) => e.trim().length <= 240 ? { value: e.trim() } : { hint: "Keep the description to one sentence, 240 characters at most." };
1046
- function yr(e) {
1047
- let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ? Ln(t.startsWith("#") ? t : `#${t}`) : void 0;
1082
+ ], Dr = (e) => e.trim() ? { value: e.trim() } : { hint: "A name cannot be empty." }, Or = (e) => e.trim().length <= 240 ? { value: e.trim() } : { hint: "Keep the description to one sentence, 240 characters at most." };
1083
+ function kr(e) {
1084
+ let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ? Wn(t.startsWith("#") ? t : `#${t}`) : void 0;
1048
1085
  return n ? { value: n.hex } : { hint: "Give the color as hex, for example #2563eb or #26e." };
1049
1086
  }
1050
- var br = (e) => /^[A-Za-z0-9][A-Za-z0-9 -]{0,60}$/.test(e.trim()) ? { value: e.trim() } : { hint: "Give a font family name, for example Inter or DM Sans." };
1051
- function xr(e, t = process.cwd()) {
1087
+ var Ar = (e) => /^[A-Za-z0-9][A-Za-z0-9 -]{0,60}$/.test(e.trim()) ? { value: e.trim() } : { hint: "Give a font family name, for example Inter or DM Sans." };
1088
+ function jr(e, t = process.cwd()) {
1052
1089
  let n = O.resolve(t, e.trim());
1053
- return gr.includes(O.extname(n).toLowerCase()) ? !k.existsSync(n) || !k.statSync(n).isFile() ? { hint: `There is no file at ${n}. Check the path, or press Enter to skip the logo.` } : { value: n } : { hint: "The logo must be an SVG or PNG file (JPG and WebP also work)." };
1090
+ return Er.includes(O.extname(n).toLowerCase()) ? !k.existsSync(n) || !k.statSync(n).isFile() ? { hint: `There is no file at ${n}. Check the path, or press Enter to skip the logo.` } : { value: n } : { hint: "The logo must be an SVG or PNG file (JPG and WebP also work)." };
1054
1091
  }
1055
- function Sr(e) {
1092
+ function Mr(e) {
1056
1093
  let t = k.readFileSync(e), n = O.extname(e).toLowerCase() === ".svg";
1057
1094
  return {
1058
1095
  bytes: t.length,
@@ -1060,20 +1097,20 @@ function Sr(e) {
1060
1097
  usesCurrentColor: n && /currentColor/i.test(t.toString("utf8"))
1061
1098
  };
1062
1099
  }
1063
- var Cr = (e) => /^https?:\/\/[^\s/]/i.test(e);
1064
- function wr(e, t, n) {
1100
+ var Nr = (e) => /^https?:\/\/[^\s/]/i.test(e);
1101
+ function Pr(e, t, n) {
1065
1102
  let r = {
1066
1103
  set: [],
1067
1104
  hints: [],
1068
1105
  files: []
1069
- }, i = (e) => r.hints.push(`${e} already existed, so it was kept as it was`), a = O.join(e, "blazon.json"), o = n.has("blazon.json") ? Mn(a) : void 0, s = o === void 0 ? void 0 : JSON.stringify(o), c = (e) => (o === void 0 && i(`blazon.json (${e} not set)`), o !== void 0);
1106
+ }, i = (e) => r.hints.push(`${e} already existed, so it was kept as it was`), a = O.join(e, "blazon.json"), o = n.has("blazon.json") ? zn(a) : void 0, s = o === void 0 ? void 0 : JSON.stringify(o), c = (e) => (o === void 0 && i(`blazon.json (${e} not set)`), o !== void 0);
1070
1107
  if (t.name !== void 0 && c("name") && (o.title = t.name, r.set.push(`name "${t.name}"`)), t.description && c("description") && (o.description = t.description, r.set.push("description")), t.color !== void 0) {
1071
1108
  let a = O.join(e, "tokens", "colors.json");
1072
1109
  if (!n.has("tokens/colors.json")) i("tokens/colors.json");
1073
1110
  else {
1074
1111
  let e = JSON.parse(k.readFileSync(a, "utf-8"));
1075
1112
  if (B(e, "color.signal.orange")) {
1076
- let n = An(e, t.color);
1113
+ let n = Ln(e, t.color);
1077
1114
  k.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/colors.json"), r.set.push(`primary color ${t.color} (color.signal.primary, which interactive.primary uses)`), r.hints.push(...n.hints);
1078
1115
  } else r.hints.push("color.signal.orange was not found in tokens/colors.json, so the color was not set");
1079
1116
  }
@@ -1086,9 +1123,9 @@ function wr(e, t, n) {
1086
1123
  if (n && i) {
1087
1124
  n.$value = [t.font, "sans-serif"], i.$value = [t.font, "sans-serif"];
1088
1125
  let s = B(e, "font.family.mono");
1089
- s && kn(s, "Still blazon's mono font: it was not chosen to go with your font. Set the brand's own."), k.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/typography.json");
1090
- let l = Zn(t.font);
1091
- l && c("font stylesheet") ? (o.fonts = Pn(o.fonts, [l]), r.set.push(`font ${t.font} (font.family.display and font.family.body)`)) : l || (r.set.push(`font ${t.font} (font.family.display and font.family.body)`), r.hints.push(`${t.font} is not a font blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`)), r.hints.push("font.family.mono and the type scale are still blazon's: set the brand's own");
1126
+ s && In(s, "Still blazon's mono font: it was not chosen to go with your font. Set the brand's own."), k.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/typography.json");
1127
+ let l = ir(t.font);
1128
+ l && c("font stylesheet") ? (o.fonts = Vn(o.fonts, [l]), r.set.push(`font ${t.font} (font.family.display and font.family.body)`)) : l || (r.set.push(`font ${t.font} (font.family.display and font.family.body)`), r.hints.push(`${t.font} is not a font blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`)), r.hints.push("font.family.mono and the type scale are still blazon's: set the brand's own");
1092
1129
  } else r.hints.push("font.family.display and font.family.body were not found in tokens/typography.json, so the font was not set");
1093
1130
  }
1094
1131
  }
@@ -1098,25 +1135,25 @@ function wr(e, t, n) {
1098
1135
  for (let e of l) i(`assets/logos/${e}`);
1099
1136
  r.hints.push(`the logo ${t.logo} was not copied: pick another file name, or remove the existing file`);
1100
1137
  } else {
1101
- let e = O.join(c, `${Fn[0]}.json`), i = {};
1102
- if (n.has(`assets/logos/${Fn[0]}.json`) && k.existsSync(e)) {
1138
+ let e = O.join(c, `${Hn[0]}.json`), i = {};
1139
+ if (n.has(`assets/logos/${Hn[0]}.json`) && k.existsSync(e)) {
1103
1140
  let { description: t, background: n, ...r } = JSON.parse(k.readFileSync(e, "utf-8"));
1104
1141
  i = r;
1105
1142
  }
1106
- for (let e of In) for (let t of ["svg", "json"]) n.has(`assets/logos/${e}.${t}`) && k.rmSync(O.join(c, `${e}.${t}`), { force: !0 });
1143
+ for (let e of Un) for (let t of ["svg", "json"]) n.has(`assets/logos/${e}.${t}`) && k.rmSync(O.join(c, `${e}.${t}`), { force: !0 });
1107
1144
  k.mkdirSync(c, { recursive: !0 });
1108
1145
  let l = k.readFileSync(t.logo);
1109
- k.writeFileSync(O.join(c, a), a.toLowerCase().endsWith(".svg") ? cr(l.toString("utf8")) : l), k.writeFileSync(O.join(c, `${s}.json`), `${JSON.stringify({
1146
+ k.writeFileSync(O.join(c, a), a.toLowerCase().endsWith(".svg") ? vr(l.toString("utf8")) : l), k.writeFileSync(O.join(c, `${s}.json`), `${JSON.stringify({
1110
1147
  title: "Logo",
1111
1148
  description: "The brand's logo. Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.",
1112
1149
  ...i
1113
1150
  }, null, 2)}\n`), o.logo = `./assets/logos/${a}`, r.files.push(`assets/logos/${a}`, `assets/logos/${s}.json`), r.set.push(`logo ${a}`);
1114
1151
  }
1115
1152
  }
1116
- return o !== void 0 && JSON.stringify(o) !== s && (Nn(a, o), r.files.push("blazon.json")), r;
1153
+ return o !== void 0 && JSON.stringify(o) !== s && (Bn(a, o), r.files.push("blazon.json")), r;
1117
1154
  }
1118
1155
  // src/core/init/prompts.ts
1119
- var Tr = class extends Error {
1156
+ var Fr = class extends Error {
1120
1157
  constructor() {
1121
1158
  super("cancelled"), this.name = "PromptCancelled";
1122
1159
  }
@@ -1130,33 +1167,33 @@ function U(e, t) {
1130
1167
  }).join("\n");
1131
1168
  }
1132
1169
  var W = () => Math.max(30, (process.stdout.columns ?? 80) - 6);
1133
- function Er(e) {
1134
- if (A.isCancel(e)) throw new Tr();
1170
+ function Ir(e) {
1171
+ if (A.isCancel(e)) throw new Fr();
1135
1172
  return e;
1136
1173
  }
1137
- function Dr() {
1174
+ function Lr() {
1138
1175
  return {
1139
1176
  intro: (e) => A.intro(e),
1140
1177
  outro: (e) => A.outro(e),
1141
1178
  cancel: (e) => A.cancel(e),
1142
- text: async (e) => Er(await A.text({
1179
+ text: async (e) => Ir(await A.text({
1143
1180
  message: e.message,
1144
1181
  placeholder: e.placeholder,
1145
1182
  defaultValue: e.defaultValue,
1146
1183
  validate: e.validate && ((t) => e.validate(t ?? ""))
1147
1184
  })) ?? "",
1148
- select: async (e) => Er(await A.select({
1185
+ select: async (e) => Ir(await A.select({
1149
1186
  message: e.message,
1150
1187
  options: e.options,
1151
1188
  initialValue: e.initialValue
1152
1189
  })),
1153
- multiselect: async (e) => Er(await A.multiselect({
1190
+ multiselect: async (e) => Ir(await A.multiselect({
1154
1191
  message: e.message,
1155
1192
  options: e.options,
1156
1193
  initialValues: e.initialValues,
1157
1194
  required: !1
1158
1195
  })),
1159
- confirm: async (e) => Er(await A.confirm({
1196
+ confirm: async (e) => Ir(await A.confirm({
1160
1197
  message: e.message,
1161
1198
  initialValue: e.initialValue
1162
1199
  })),
@@ -1180,15 +1217,15 @@ function Dr() {
1180
1217
  };
1181
1218
  }
1182
1219
  // src/cli/init-ui.ts
1183
- function Or(e = process.env, t = !!process.stdout.isTTY) {
1184
- let n = w(e, t, []);
1220
+ function Rr(e = process.env, t = !!process.stdout.isTTY) {
1221
+ let n = s(e, t, []);
1185
1222
  return {
1186
1223
  color: n,
1187
1224
  truecolor: n && /^(truecolor|24bit)$/i.test(e.COLORTERM ?? "")
1188
1225
  };
1189
1226
  }
1190
- function kr(e, t) {
1191
- let [n, r, i] = (gn(e) ?? [
1227
+ function zr(e, t) {
1228
+ let [n, r, i] = (Cn(e) ?? [
1192
1229
  0,
1193
1230
  0,
1194
1231
  0
@@ -1197,62 +1234,62 @@ function kr(e, t) {
1197
1234
  let a = (e) => Math.round(e / 255 * 5);
1198
1235
  return `\x1b[48;5;${16 + 36 * a(n) + 6 * a(r) + a(i)}m`;
1199
1236
  }
1200
- function Ar(e, t, n = 2) {
1201
- return t.color ? `${kr(e, t)}${" ".repeat(n)}\x1b[0m` : `[${e}]`;
1237
+ function Br(e, t, n = 2) {
1238
+ return t.color ? `${zr(e, t)}${" ".repeat(n)}\x1b[0m` : `[${e}]`;
1202
1239
  }
1203
- var jr = {
1240
+ var Vr = {
1204
1241
  AAA: "AAA",
1205
1242
  AA: "AA",
1206
1243
  "AA-large": "AA for large text only",
1207
1244
  fail: "below AA"
1208
- }, Mr = (e) => `${e.toFixed(1)}:1`;
1209
- function Nr(e, t, n = xn(e)) {
1245
+ }, Hr = (e) => `${e.toFixed(1)}:1`;
1246
+ function Ur(e, t, n = On(e)) {
1210
1247
  let r = (e) => e === "AAA" || e === "AA" ? "yes" : "no";
1211
1248
  return [
1212
- `${Ar(e, t, 4)} ${e}`,
1213
- `AA for text on white: ${r(n.onWhite.level)} (${Mr(n.onWhite.ratio)}, ${jr[n.onWhite.level]})`,
1214
- `AA for text on near-black: ${r(n.onNearBlack.level)} (${Mr(n.onNearBlack.ratio)}, ${jr[n.onNearBlack.level]})`
1249
+ `${Br(e, t, 4)} ${e}`,
1250
+ `AA for text on white: ${r(n.onWhite.level)} (${Hr(n.onWhite.ratio)}, ${Vr[n.onWhite.level]})`,
1251
+ `AA for text on near-black: ${r(n.onNearBlack.level)} (${Hr(n.onNearBlack.ratio)}, ${Vr[n.onNearBlack.level]})`
1215
1252
  ];
1216
1253
  }
1217
- function Pr(e) {
1218
- let { ink: t, ratio: n, aa: r } = wn(e);
1254
+ function Wr(e) {
1255
+ let { ink: t, ratio: n, aa: r } = jn(e);
1219
1256
  return r ? `Labels on ${e} will be ${t} (${n.toFixed(1)}:1).` : `Neither graphite nor bone reaches AA (4.5:1) as a label on ${e} (best is ${t} at ${n.toFixed(1)}:1). blazon check will report it; a lighter or darker color fixes that.`;
1220
1257
  }
1221
- var Fr = (e, t, n) => `${e} of ${t} ${n}`;
1222
- function Ir(e) {
1258
+ var Gr = (e, t, n) => `${e} of ${t} ${n}`;
1259
+ function Kr(e) {
1223
1260
  return e < 1024 ? `${e} bytes` : `${(e / 1024).toFixed(1)} KB`;
1224
1261
  }
1225
1262
  // src/cli/init-flow.ts
1226
- var Lr = 4;
1263
+ var qr = 4;
1227
1264
  function G(e, t, n, r) {
1228
- return e.log.message(r.color ? l.dim(n) : n), t;
1265
+ return e.log.message(r.color ? a.dim(n) : n), t;
1229
1266
  }
1230
- function Rr(e) {
1267
+ function Jr(e) {
1231
1268
  return (t) => {
1232
1269
  if (t.trim() === "") return;
1233
1270
  let n = e(t);
1234
1271
  return "hint" in n ? n.hint : void 0;
1235
1272
  };
1236
1273
  }
1237
- var zr = (e, t) => {
1274
+ var Yr = (e, t) => {
1238
1275
  let n = t.trim() === "" ? void 0 : e(t);
1239
1276
  return n && "value" in n ? n.value : void 0;
1240
1277
  };
1241
- async function Br(e) {
1278
+ async function Xr(e) {
1242
1279
  let { prompter: t, look: n } = e, r = {};
1243
- t.intro(n.color ? l.bold(`blazon init ${l.dim(e.dir)}`) : `blazon init ${e.dir}`), e.kept && t.log.warn(`${e.kept} starter ${e.kept === 1 ? "file is" : "files are"} already in this folder and ${e.kept === 1 ? "is" : "are"} kept as ${e.kept === 1 ? "it is" : "they are"}. Only missing files are added.`), t.log.step(Fr(1, Lr, "Brand"));
1280
+ t.intro(n.color ? a.bold(`blazon init ${a.dim(e.dir)}`) : `blazon init ${e.dir}`), e.kept && t.log.warn(`${e.kept} starter ${e.kept === 1 ? "file is" : "files are"} already in this folder and ${e.kept === 1 ? "is" : "are"} kept as ${e.kept === 1 ? "it is" : "they are"}. Only missing files are added.`), t.log.step(Gr(1, qr, "Brand"));
1244
1281
  let i = (await t.text({
1245
1282
  message: G(t, "Brand name", "The title of the brand book. Enter keeps the name taken from the folder.", n),
1246
1283
  placeholder: "from the folder name",
1247
1284
  validate: () => void 0
1248
1285
  })).trim();
1249
1286
  i && (r.name = i);
1250
- let a = (await t.text({
1287
+ let o = (await t.text({
1251
1288
  message: G(t, "One-line description", "What the brand is, in a sentence. It goes in the config and opens the intro page. Enter skips it.", n),
1252
1289
  placeholder: "what the brand is, in one sentence",
1253
- validate: (e) => "hint" in vr(e) ? "Keep it to one sentence, 240 characters at most." : void 0
1290
+ validate: (e) => "hint" in Or(e) ? "Keep it to one sentence, 240 characters at most." : void 0
1254
1291
  })).trim();
1255
- if (a && (r.description = a), await t.select({
1292
+ if (o && (r.description = o), await t.select({
1256
1293
  message: G(t, "Where should the colors, fonts and logo come from?", "Reading a live site fills them in for you to review before anything is written.", n),
1257
1294
  options: [{
1258
1295
  value: "manual",
@@ -1264,36 +1301,36 @@ async function Br(e) {
1264
1301
  hint: "you review what was found first"
1265
1302
  }]
1266
1303
  }) === "site") {
1267
- let n = await Vr(e);
1304
+ let n = await Zr(e);
1268
1305
  if (n) return {
1269
1306
  answers: r,
1270
1307
  site: n
1271
1308
  };
1272
1309
  t.log.info("Nothing from a site will be written. Giving the values here instead.");
1273
1310
  }
1274
- t.log.step(Fr(2, Lr, "Colors"));
1275
- let o = zr(yr, (await t.text({
1311
+ t.log.step(Gr(2, qr, "Colors"));
1312
+ let s = Yr(kr, (await t.text({
1276
1313
  message: G(t, "Primary color", "Hex, for example #2563eb. Buttons and links use it. Enter keeps the orange it starts with.", n),
1277
1314
  placeholder: "#2563eb",
1278
- validate: Rr(yr)
1315
+ validate: Jr(kr)
1279
1316
  })).trim());
1280
- o && (r.color = o, t.log.info(Nr(o, n).join("\n")), t.log.info(Pr(o))), t.log.step(Fr(3, Lr, "Type"));
1281
- let s = zr(br, (await t.text({
1317
+ s && (r.color = s, t.log.info(Ur(s, n).join("\n")), t.log.info(Wr(s))), t.log.step(Gr(3, qr, "Type"));
1318
+ let c = Yr(Ar, (await t.text({
1282
1319
  message: G(t, "Font family", "A Google Fonts name, for example Inter. Enter keeps the fonts it starts with.", n),
1283
1320
  placeholder: "Inter",
1284
- validate: Rr(br)
1321
+ validate: Jr(Ar)
1285
1322
  })).trim());
1286
- s && (r.font = s, Zn(s) ? t.log.success(`${s} is on Google Fonts. Its stylesheet will be added to fonts in blazon.json.`) : t.log.warn(`${s} is not in blazon's short list of Google Fonts, so only the font name is written. Add its stylesheet to fonts in blazon.json.`)), t.log.step(Fr(4, Lr, "Logo"));
1287
- let c = zr((e) => xr(e), (await t.text({
1323
+ c && (r.font = c, ir(c) ? t.log.success(`${c} is on Google Fonts. Its stylesheet will be added to fonts in blazon.json.`) : t.log.warn(`${c} is not in blazon's short list of Google Fonts, so only the font name is written. Add its stylesheet to fonts in blazon.json.`)), t.log.step(Gr(4, qr, "Logo"));
1324
+ let l = Yr((e) => jr(e), (await t.text({
1288
1325
  message: G(t, "Logo file", "The path to an SVG or PNG. Enter skips it and keeps the logo it starts with.", n),
1289
1326
  placeholder: "./logo.svg",
1290
- validate: Rr((e) => xr(e))
1327
+ validate: Jr((e) => jr(e))
1291
1328
  })).trim());
1292
- if (c) {
1293
- r.logo = c;
1294
- let e = Sr(c), n = O.basename(c);
1329
+ if (l) {
1330
+ r.logo = l;
1331
+ let e = Mr(l), n = O.basename(l);
1295
1332
  t.log.info([
1296
- `${n}: ${e.svg ? "SVG" : "raster image"}, ${Ir(e.bytes)}.`,
1333
+ `${n}: ${e.svg ? "SVG" : "raster image"}, ${Kr(e.bytes)}.`,
1297
1334
  "It will be copied to assets/logos/ and replace the starter's placeholder.",
1298
1335
  ...e.usesCurrentColor ? ["It draws in currentColor, so it takes the text color of the page it is on."] : [],
1299
1336
  ...e.svg ? [] : ["A raster logo cannot be recolored; an SVG is better if you have one."]
@@ -1301,13 +1338,13 @@ async function Br(e) {
1301
1338
  }
1302
1339
  return { answers: r };
1303
1340
  }
1304
- async function Vr(e) {
1305
- let { prompter: t, look: n } = e, r = e.inspect ?? hr;
1341
+ async function Zr(e) {
1342
+ let { prompter: t, look: n } = e, r = e.inspect ?? Tr;
1306
1343
  for (;;) {
1307
1344
  let i = (await t.text({
1308
1345
  message: G(t, "Website address", "Blazon reads its stylesheets and page. It sends no cookies and runs none of the site's scripts.", n),
1309
1346
  placeholder: "https://example.com (leave empty to enter the values by hand)",
1310
- validate: (e) => e.trim() === "" || Cr(e.trim()) ? void 0 : "Give the full address, starting with http:// or https://, or leave it empty to enter the values by hand."
1347
+ validate: (e) => e.trim() === "" || Nr(e.trim()) ? void 0 : "Give the full address, starting with http:// or https://, or leave it empty to enter the values by hand."
1311
1348
  })).trim();
1312
1349
  if (i === "") {
1313
1350
  t.log.info("No address given: you can enter the values by hand.");
@@ -1322,7 +1359,7 @@ async function Vr(e) {
1322
1359
  a.error(`Could not read ${i}`), t.log.error(`${e instanceof Error ? e.message : String(e)}\nCheck the address and your connection. The starter is in place, so nothing is lost.`);
1323
1360
  }
1324
1361
  if (o) {
1325
- let t = await Hr(e, i, o);
1362
+ let t = await Qr(e, i, o);
1326
1363
  return t ? {
1327
1364
  url: i,
1328
1365
  findings: o,
@@ -1335,7 +1372,7 @@ async function Vr(e) {
1335
1372
  })) return;
1336
1373
  }
1337
1374
  }
1338
- async function Hr(e, t, n) {
1375
+ async function Qr(e, t, n) {
1339
1376
  let { prompter: r, look: i } = e, a = [];
1340
1377
  n.name && a.push(`Name: ${n.name}`), n.description && a.push(`Description: ${n.description}`);
1341
1378
  for (let e of n.fonts) a.push(`Font (${e.role}): ${e.family}${e.stylesheet ? ", its Google Fonts stylesheet will be added" : ", not in blazon's short list, so add its stylesheet yourself"}`);
@@ -1347,7 +1384,7 @@ async function Hr(e, t, n) {
1347
1384
  message: G(r, "Brand colors found", "Untick any you do not want. Everything written is marked needs-review.", i),
1348
1385
  options: n.colors.map((e) => ({
1349
1386
  value: e.cssVar,
1350
- label: `${Ar(e.hex, i)} ${e.hex} ${e.cssVar}`
1387
+ label: `${Br(e.hex, i)} ${e.hex} ${e.cssVar}`
1351
1388
  })),
1352
1389
  initialValues: n.colors.map((e) => e.cssVar)
1353
1390
  });
@@ -1359,69 +1396,69 @@ async function Hr(e, t, n) {
1359
1396
  }) ? o : void 0;
1360
1397
  }
1361
1398
  // src/cli/commands/init.ts
1362
- var Ur = (e, t, n) => `${e} ${e === 1 ? t : n}`;
1363
- function Wr(e, t) {
1399
+ var $r = (e, t, n) => `${e} ${e === 1 ? t : n}`;
1400
+ function ei(e, t) {
1364
1401
  let n = t.map((e) => e.split("/").slice(1));
1365
1402
  if (n.length === 0) return;
1366
- if (e === "docs") return `${Ur(n.length, "page", "pages")}, ${n[0][0]} to ${n[n.length - 1][0]}`;
1367
- if (e === "tokens") return `${Ur(n.length, "file", "files")}: ${n.map((e) => e.join("/")).join(", ")}`;
1403
+ if (e === "docs") return `${$r(n.length, "page", "pages")}, ${n[0][0]} to ${n[n.length - 1][0]}`;
1404
+ if (e === "tokens") return `${$r(n.length, "file", "files")}: ${n.map((e) => e.join("/")).join(", ")}`;
1368
1405
  let r = [...new Set(n.filter((e) => e.length > 1).map((e) => e[0]))];
1369
- return r.length > 0 ? `${Ur(n.length, "file", "files")} in ${Ur(r.length, "folder", "folders")}: ${r.join(", ")}` : `${Ur(n.length, "file", "files")}: ${n.map((e) => e[0]).join(", ")}`;
1406
+ return r.length > 0 ? `${$r(n.length, "file", "files")} in ${$r(r.length, "folder", "folders")}: ${r.join(", ")}` : `${$r(n.length, "file", "files")}: ${n.map((e) => e[0]).join(", ")}`;
1370
1407
  }
1371
- var Gr = /^(brand|book|guidelines|guide)$/i;
1372
- function Kr(e) {
1408
+ var ti = /^(brand|book|guidelines|guide)$/i;
1409
+ function ni(e) {
1373
1410
  let t = O.basename(e).split(/[-_\s]+/).filter(Boolean), n = t.length > 0;
1374
- for (; t.length > 0 && Gr.test(t[t.length - 1]);) t = t.slice(0, -1);
1411
+ for (; t.length > 0 && ti.test(t[t.length - 1]);) t = t.slice(0, -1);
1375
1412
  let r = t.map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
1376
1413
  return r ? `${r} Brand Book` : n ? "Brand Book" : "Blazon Brand Book";
1377
1414
  }
1378
- var qr = [
1415
+ var ri = [
1379
1416
  [
1380
1417
  "--name",
1381
1418
  "name",
1382
- _r
1419
+ Dr
1383
1420
  ],
1384
1421
  [
1385
1422
  "--description",
1386
1423
  "description",
1387
- vr
1424
+ Or
1388
1425
  ],
1389
1426
  [
1390
1427
  "--color",
1391
1428
  "color",
1392
- yr
1429
+ kr
1393
1430
  ],
1394
1431
  [
1395
1432
  "--font",
1396
1433
  "font",
1397
- br
1434
+ Ar
1398
1435
  ],
1399
1436
  [
1400
1437
  "--logo",
1401
1438
  "logo",
1402
- (e) => xr(e)
1439
+ (e) => jr(e)
1403
1440
  ]
1404
1441
  ];
1405
- async function Jr(e = ".", t = {}) {
1442
+ async function ii(e = ".", t = {}) {
1406
1443
  if (t.from !== void 0 && !/^https?:\/\/[^\s/]/i.test(t.from)) {
1407
1444
  let e = `--from needs an http(s) address, got ${JSON.stringify(t.from)}`;
1408
- return console.error(l.red(`blazon init: ${e}`)), t.failure?.({
1445
+ return console.error(a.red(`blazon init: ${e}`)), t.failure?.({
1409
1446
  code: "invalid-option-value",
1410
1447
  message: e
1411
1448
  }), 2;
1412
1449
  }
1413
1450
  let n = {};
1414
- for (let [e, r, i] of qr) {
1415
- let a = t[r];
1416
- if (a === void 0) continue;
1417
- let o = i(String(a));
1418
- if ("hint" in o) return console.error(l.red(`blazon init: ${e}: ${o.hint}`)), t.failure?.({
1451
+ for (let [e, r, i] of ri) {
1452
+ let o = t[r];
1453
+ if (o === void 0) continue;
1454
+ let s = i(String(o));
1455
+ if ("hint" in s) return console.error(a.red(`blazon init: ${e}: ${s.hint}`)), t.failure?.({
1419
1456
  code: "invalid-option-value",
1420
- message: `${e}: ${o.hint}`
1457
+ message: `${e}: ${s.hint}`
1421
1458
  }), 2;
1422
- n[r] = o.value;
1459
+ n[r] = s.value;
1423
1460
  }
1424
- let r = O.resolve(process.cwd(), e), i = Ke();
1461
+ let r = O.resolve(process.cwd(), e), i = c();
1425
1462
  if (!k.existsSync(i)) throw Error(`Template directory not found at ${i}`);
1426
1463
  let o = t.tty ?? !!(process.stdin.isTTY && process.stdout.isTTY), s = [
1427
1464
  t.from,
@@ -1430,16 +1467,16 @@ async function Jr(e = ".", t = {}) {
1430
1467
  t.color,
1431
1468
  t.font,
1432
1469
  t.logo
1433
- ].some((e) => e !== void 0), c = o && !s && !t.yes && t.input !== !1, u = c ? t.prompter ?? Dr() : void 0, d = t.look ?? Or(process.env, o);
1434
- c || console.log(l.cyan(`\n✨ Initializing Blazon Brand Book in ${l.bold(r)}...\n`));
1435
- let f = O.join(r, "blazon.json"), p = k.existsSync(f), m = a(r, i), h = m.kept, g = m.written.map((e) => O.relative(r, e).split(O.sep).join("/")).sort(), _ = new Set(g);
1470
+ ].some((e) => e !== void 0), l = o && !s && !t.yes && t.input !== !1, u = l ? t.prompter ?? Lr() : void 0, d = t.look ?? Rr(process.env, o);
1471
+ l || console.log(a.cyan(`\n✨ Initializing Blazon Brand Book in ${a.bold(r)}...\n`));
1472
+ let f = O.join(r, "blazon.json"), p = k.existsSync(f), m = ie(r, i), h = m.kept, g = m.written.map((e) => O.relative(r, e).split(O.sep).join("/")).sort(), _ = new Set(g);
1436
1473
  t.report?.({
1437
1474
  dir: r,
1438
1475
  created: g,
1439
1476
  kept: h.map((e) => O.relative(r, e).split(O.sep).join("/")).sort()
1440
- }), !p && k.existsSync(f) && Nn(f, {
1441
- ...Mn(f),
1442
- title: Kr(r),
1477
+ }), !p && k.existsSync(f) && Bn(f, {
1478
+ ...zn(f),
1479
+ title: ni(r),
1443
1480
  description: "Brand guidelines, built from design tokens"
1444
1481
  });
1445
1482
  let v = [];
@@ -1448,66 +1485,66 @@ async function Jr(e = ".", t = {}) {
1448
1485
  "assets",
1449
1486
  "docs"
1450
1487
  ]) {
1451
- let t = Wr(e, g.filter((t) => t.startsWith(`${e}/`)));
1488
+ let t = ei(e, g.filter((t) => t.startsWith(`${e}/`)));
1452
1489
  t && v.push(`${e}/ (${t})`);
1453
1490
  }
1454
1491
  g.includes("blazon.json") && v.push("blazon.json"), g.includes("blazon.resolver.json") && v.push("blazon.resolver.json");
1455
1492
  let y = { answers: n };
1456
1493
  if (u) try {
1457
- y = await Br({
1494
+ y = await Xr({
1458
1495
  prompter: u,
1459
1496
  look: d,
1460
1497
  dir: r,
1461
1498
  kept: h.length
1462
1499
  });
1463
1500
  } catch (e) {
1464
- if (e instanceof Tr) return u.cancel("Stopped. The starter was copied as it is, and nothing else was changed."), 130;
1501
+ if (e instanceof Fr) return u.cancel("Stopped. The starter was copied as it is, and nothing else was changed."), 130;
1465
1502
  throw e;
1466
1503
  }
1467
1504
  else {
1468
- for (let e of v) console.log(` ${l.green("✔")} Created ${e}`);
1469
- h.length > 0 && console.log(` ${l.yellow("!")} ${h.length} starter files were already here and are kept as they are`), console.log();
1505
+ for (let e of v) console.log(` ${a.green("✔")} Created ${e}`);
1506
+ h.length > 0 && console.log(` ${a.yellow("!")} ${h.length} starter files were already here and are kept as they are`), console.log();
1470
1507
  }
1471
- let b = y.site?.url ?? t.from, x = 0, S, ee = u?.spinner();
1472
- if (ee?.start("Writing the brand book"), b !== void 0) try {
1473
- if (S = await mr(r, b, _, /* @__PURE__ */ new Date(), {
1508
+ let ee = y.site?.url ?? t.from, b = 0, x, te = u?.spinner();
1509
+ if (te?.start("Writing the brand book"), ee !== void 0) try {
1510
+ if (x = await wr(r, ee, _, /* @__PURE__ */ new Date(), {
1474
1511
  page: y.site?.findings.page,
1475
1512
  skipVars: y.site?.skipVars
1476
1513
  }), !u) {
1477
- console.log(l.bold(`Read from ${b}:`));
1478
- for (let e of S.written) console.log(` ${l.green("✔")} Wrote ${e}`);
1479
- for (let e of S.removed) console.log(` ${l.green("✔")} Removed ${e}`);
1480
- for (let e of S.repointed) console.log(` ${l.green("✔")} Re-pointed ${e}`);
1481
- for (let e of S.missing) console.log(` ${l.yellow("!")} ${e}`);
1482
- console.log(l.dim("\n All of it is marked needs-review: it is a starting point, so confirm it with the brand owner.\n"));
1514
+ console.log(a.bold(`Read from ${ee}:`));
1515
+ for (let e of x.written) console.log(` ${a.green("✔")} Wrote ${e}`);
1516
+ for (let e of x.removed) console.log(` ${a.green("✔")} Removed ${e}`);
1517
+ for (let e of x.repointed) console.log(` ${a.green("✔")} Re-pointed ${e}`);
1518
+ for (let e of x.missing) console.log(` ${a.yellow("!")} ${e}`);
1519
+ console.log(a.dim("\n All of it is marked needs-review: it is a starting point, so confirm it with the brand owner.\n"));
1483
1520
  }
1484
1521
  } catch (e) {
1485
1522
  let n = e instanceof Error ? e.message : String(e);
1486
1523
  t.failure?.({
1487
1524
  code: "site-unreadable",
1488
1525
  message: n
1489
- }), u ? u.log.error(`Could not read ${b}: ${n}\nThe starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.`) : (console.error(l.red(`blazon init: ${n}`)), console.error(l.dim(" The starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.\n"))), x = 2;
1526
+ }), u ? u.log.error(`Could not read ${ee}: ${n}\nThe starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.`) : (console.error(a.red(`blazon init: ${n}`)), console.error(a.dim(" The starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.\n"))), b = 2;
1490
1527
  }
1491
- let C;
1528
+ let S;
1492
1529
  try {
1493
- C = wr(r, y.answers, _);
1530
+ S = Pr(r, y.answers, _);
1494
1531
  } catch (e) {
1495
- throw ee?.error("Could not write the brand book"), e;
1496
- }
1497
- ee?.stop("Wrote the brand book");
1498
- let w = (e) => d.color ? l.cyan(e) : e, T = F(r), te = [
1499
- `Run ${w(L("dev", T))} to see the book`,
1500
- `Replace blazon's artwork in ${w(I(T, "assets/"))} and the text in ${w(I(T, "docs/"))}`,
1501
- `Run ${w(L("check", T))} to see what is left`,
1502
- `Point a coding agent at ${w(I(T, "AGENTS.md"))}: it is the guide for editing this brand`
1532
+ throw te?.error("Could not write the brand book"), e;
1533
+ }
1534
+ te?.stop("Wrote the brand book");
1535
+ let C = (e) => d.color ? a.cyan(e) : e, w = F(r), ne = [
1536
+ `Run ${C(L("dev", w))} to see the book`,
1537
+ `Replace blazon's artwork in ${C(I(w, "assets/"))} and the text in ${C(I(w, "docs/"))}`,
1538
+ `Run ${C(L("check", w))} to see what is left`,
1539
+ `Point a coding agent at ${C(I(w, "AGENTS.md"))}: it is the guide for editing this brand`
1503
1540
  ];
1504
- S && !S.written.some((e) => e.startsWith("assets/logos/")) && te.splice(1, 0, `Add your logo: the book still shows blazon's own. Put it in ${w(I(T, "assets/logos/"))} and point ${w("logo")} in ${w(I(T, "blazon.json"))} at it`);
1505
- let ne = w(I(T, "tokens/colors.json")), re = C.set.some((e) => e.startsWith("primary color")) ? `Finish the palette in ${ne}: the primary color is set, the rest is still blazon's` : S?.written.includes("tokens/colors.json") ? `Confirm the colors read from the site in ${ne} with the brand owner` : `Edit ${ne} with your colors`;
1541
+ x && !x.written.some((e) => e.startsWith("assets/logos/")) && ne.splice(1, 0, `Add your logo: the book still shows blazon's own. Put it in ${C(I(w, "assets/logos/"))} and point ${C("logo")} in ${C(I(w, "blazon.json"))} at it`);
1542
+ let re = C(I(w, "tokens/colors.json")), ae = S.set.some((e) => e.startsWith("primary color")) ? `Finish the palette in ${re}: the primary color is set, the rest is still blazon's` : x?.written.includes("tokens/colors.json") ? `Confirm the colors read from the site in ${re} with the brand owner` : `Edit ${re} with your colors`;
1506
1543
  if (u) {
1507
1544
  let e = [...v.map((e) => `Created ${e}`)];
1508
- S && e.push(`Read from ${b}: ${S.written.length} files written, ${S.removed.length} starter files removed`, ...S.missing.map((e) => `Not found: ${e}`));
1509
- for (let t of C.set) e.push(`Set ${t}`);
1510
- e.push(...C.hints.map((e) => `Note: ${e}`)), u.note(e.join("\n"), "What was written"), x === 0 && u.note(te.map((e, t) => `${t + 1}. ${e}`).join("\n"), "Next steps");
1545
+ x && e.push(`Read from ${ee}: ${x.written.length} files written, ${x.removed.length} starter files removed`, ...x.missing.map((e) => `Not found: ${e}`));
1546
+ for (let t of S.set) e.push(`Set ${t}`);
1547
+ e.push(...S.hints.map((e) => `Note: ${e}`)), u.note(e.join("\n"), "What was written"), b === 0 && u.note(ne.map((e, t) => `${t + 1}. ${e}`).join("\n"), "Next steps");
1511
1548
  let n;
1512
1549
  try {
1513
1550
  n = t.dev ?? await u.confirm({
@@ -1515,48 +1552,48 @@ async function Jr(e = ".", t = {}) {
1515
1552
  initialValue: !1
1516
1553
  });
1517
1554
  } catch (e) {
1518
- if (!(e instanceof Tr)) throw e;
1519
- return u.cancel("Stopped. Everything above was written."), x === 0 ? 130 : x;
1555
+ if (!(e instanceof Fr)) throw e;
1556
+ return u.cancel("Stopped. Everything above was written."), b === 0 ? 130 : b;
1520
1557
  }
1521
- return u.outro(n ? "Starting blazon dev. Press Ctrl-C to stop it." : `Done. Run ${w(L("dev", T))} when you are ready.`), n && await (t.startDev ?? Yr)(r), x;
1558
+ return u.outro(n ? "Starting blazon dev. Press Ctrl-C to stop it." : `Done. Run ${C(L("dev", w))} when you are ready.`), n && await (t.startDev ?? ai)(r), b;
1522
1559
  }
1523
- for (let e of C.hints) console.log(` ${l.yellow("!")} ${e}`);
1524
- return C.set.length > 0 && console.log(` ${l.green("✔")} Set ${C.set.join(", ")}\n`), x === 0 && (console.log(l.bold("Next steps:")), console.log(` 1. ${re}`), te.forEach((e, t) => console.log(` ${t + 2}. ${e}`))), console.log(), t.dev && await (t.startDev ?? Yr)(r), x;
1560
+ for (let e of S.hints) console.log(` ${a.yellow("!")} ${e}`);
1561
+ return S.set.length > 0 && console.log(` ${a.green("✔")} Set ${S.set.join(", ")}\n`), b === 0 && (console.log(a.bold("Next steps:")), console.log(` 1. ${ae}`), ne.forEach((e, t) => console.log(` ${t + 2}. ${e}`))), console.log(), t.dev && await (t.startDev ?? ai)(r), b;
1525
1562
  }
1526
- async function Yr(e) {
1527
- let { runDev: t } = await Promise.resolve().then(() => vt);
1563
+ async function ai(e) {
1564
+ let { runDev: t } = await Promise.resolve().then(() => Tt);
1528
1565
  await t(e);
1529
1566
  }
1530
1567
  // src/server/preview-guard.ts
1531
- function Xr(t) {
1532
- return (n, r, i) => {
1533
- let a;
1568
+ function oi(e) {
1569
+ return (t, n, r) => {
1570
+ let i;
1534
1571
  try {
1535
- a = decodeURIComponent((n.url ?? "").split("?")[0]);
1572
+ i = decodeURIComponent((t.url ?? "").split("?")[0]);
1536
1573
  } catch {
1537
- return i();
1574
+ return r();
1538
1575
  }
1539
- if (a.includes("\0")) return i();
1540
- let o = O.join(t, O.normalize(`/${a}`));
1541
- if (e(x(t), x(o))) return i();
1542
- r.statusCode = 403, r.setHeader("Content-Type", "text/plain"), r.end("blazon preview serves only files inside the built site: this path is a link that leaves it");
1576
+ if (i.includes("\0")) return r();
1577
+ let a = O.join(e, O.normalize(`/${i}`));
1578
+ if (Fe(me(e), me(a))) return r();
1579
+ n.statusCode = 403, n.setHeader("Content-Type", "text/plain"), n.end("blazon preview serves only files inside the built site: this path is a link that leaves it");
1543
1580
  };
1544
1581
  }
1545
- var Zr = (e) => ({
1582
+ var si = (e) => ({
1546
1583
  name: "blazon-site-link-guard",
1547
1584
  configurePreviewServer(t) {
1548
- t.middlewares.use(Xr(e));
1585
+ t.middlewares.use(oi(e));
1549
1586
  }
1550
1587
  });
1551
1588
  // src/cli/commands/preview.ts
1552
- async function Qr(e = process.cwd(), t, n = {}) {
1553
- gt(e);
1554
- let r = await ae(e, t ? { port: t } : void 0), i = O.resolve(e, r.outDir);
1589
+ async function ci(e = process.cwd(), t, n = {}) {
1590
+ Ct(e);
1591
+ let r = await Ae(e, t ? { port: t } : void 0), i = O.resolve(e, r.outDir);
1555
1592
  if (!k.existsSync(O.join(i, "index.html"))) throw new M(`no built site at "${i}"`, `Run ${L("build", F(e))} first.`, "no-built-site");
1556
- let a;
1593
+ let o;
1557
1594
  try {
1558
- a = await et({
1559
- plugins: [le(), Zr(i)],
1595
+ o = await st({
1596
+ plugins: [pe(), si(i)],
1560
1597
  build: { outDir: i },
1561
1598
  preview: {
1562
1599
  port: r.port,
@@ -1566,61 +1603,61 @@ async function Qr(e = process.cwd(), t, n = {}) {
1566
1603
  }
1567
1604
  });
1568
1605
  } catch (e) {
1569
- throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? nt(r.port) : e;
1606
+ throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? lt(r.port) : e;
1570
1607
  }
1571
- let o = a.resolvedUrls, s = o?.local[0] || `http://localhost:${r.port}/`;
1572
- console.log(`\n ${l.bold(l.blue("blazon preview"))}`), console.log(` ${l.dim("➜")} ${l.bold("Local:")} ${l.cyan(s)}`);
1573
- for (let e of o?.network ?? []) console.log(` ${l.dim("➜")} ${l.bold("Network:")} ${l.cyan(e)}`);
1574
- return console.log(` ${l.dim("➜")} ${l.bold("Dist:")} ${l.dim(i)}\n`), a;
1608
+ let s = o.resolvedUrls, c = s?.local[0] || `http://localhost:${r.port}/`;
1609
+ console.log(`\n ${a.bold(a.blue("blazon preview"))}`), console.log(` ${a.dim("➜")} ${a.bold("Local:")} ${a.cyan(c)}`);
1610
+ for (let e of s?.network ?? []) console.log(` ${a.dim("➜")} ${a.bold("Network:")} ${a.cyan(e)}`);
1611
+ return console.log(` ${a.dim("➜")} ${a.bold("Dist:")} ${a.dim(i)}\n`), o;
1575
1612
  }
1576
1613
  // src/plugins/roles/check-cases.ts
1577
- var $r = "docs/manual/12-plugins.md (\"What a plugin can look at, and where it writes\")";
1578
- function ei(e) {
1579
- let t = O.basename(e), n = je(t) ?? t.replace(/^blazon-/, "");
1580
- return Pe(n) ? n : void 0;
1614
+ var li = "docs/manual/12-plugins.md (\"What a plugin can look at, and where it writes\")";
1615
+ function ui(e) {
1616
+ let t = O.basename(e), n = Ze(t) ?? t.replace(/^blazon-/, "");
1617
+ return ge(n) ? n : void 0;
1581
1618
  }
1582
- function ti(e, t) {
1619
+ function di(e, t) {
1583
1620
  return k.readdirSync(e, { recursive: !0 }).filter((n) => O.join(e, n) !== t && !O.join(e, n).startsWith(t + O.sep)).sort();
1584
1621
  }
1585
- function ni(e) {
1586
- let n = ei(e);
1587
- return async (e, r) => {
1588
- let i = t(e), a = i.answers.join(" or "), o = i.stdoutLimit ?? 65536, s = [], c = {
1622
+ function fi(t) {
1623
+ let n = ui(t);
1624
+ return async (t, r) => {
1625
+ let i = je(t), a = i.answers.join(" or "), o = i.stdoutLimit ?? 65536, s = [], c = {
1589
1626
  exit: `a valid request is answered with exit ${a}`,
1590
1627
  limit: `the answer is at most ${o} bytes`,
1591
- shape: `the answer is one the ${e} role accepts: a findings list of at most 500, each with the plugin's code, a severity, a path and a message`,
1628
+ shape: `the answer is one the ${t} role accepts: a findings list of at most 500, each with the plugin's code, a severity, a path and a message`,
1592
1629
  folder: "the plugin writes into out_dir and nothing beside it"
1593
- }, l = JSON.parse(De()[e]), u = k.mkdtempSync(O.join($e.tmpdir(), "blazon-plugin-check-")), d = O.join(u, "tokens"), f = O.join(d, n ?? "plugin");
1630
+ }, l = JSON.parse(e()[t]), u = k.mkdtempSync(O.join(ot.tmpdir(), "blazon-plugin-check-")), d = O.join(u, "tokens"), f = O.join(d, n ?? "plugin");
1594
1631
  try {
1595
- e === "build" && (k.mkdirSync(O.join(u, "site")), k.mkdirSync(f, { recursive: !0 }), Object.assign(l, {
1632
+ t === "build" && (k.mkdirSync(O.join(u, "site")), k.mkdirSync(f, { recursive: !0 }), Object.assign(l, {
1596
1633
  site_dir: O.join(u, "site"),
1597
1634
  tokens_dir: d,
1598
1635
  out_dir: f
1599
1636
  }));
1600
- let t = await r(Buffer.from(JSON.stringify(l)), o), p = !t.answered && t.breakReason.startsWith("output over the limit");
1601
- p ? s.push(h(6, c.exit, e, {
1637
+ let e = await r(Buffer.from(JSON.stringify(l)), o), p = !e.answered && e.breakReason.startsWith("output over the limit");
1638
+ p ? s.push(v(6, c.exit, t, {
1602
1639
  skipped: !0,
1603
1640
  detail: "the output went over the limit before the plugin exited (case 7)"
1604
- })) : t.answered && i.answers.includes(t.code) ? s.push(h(6, c.exit, e, { passed: !0 })) : t.answered && t.code === 1 ? s.push(h(6, c.exit, e, { detail: `got exit 1, and exit 1 is a break in blazon: the ${e} role defines only ${a}, so blazon reports the plugin as failed and counts it toward its breaker. Exit 2 with the reason on the first line when the plugin cannot answer` })) : s.push(h(6, c.exit, e, { detail: t.answered ? `got exit ${t.code}` : `a break: ${t.breakReason}` }));
1605
- let m = i.stdoutLimit === void 0 ? "the core's limit, which the role does not raise" : `the ${e} role's limit (stdout_limit_bytes)`;
1606
- if (s.push(p ? h(7, c.limit, e, { detail: `the plugin printed more than ${o} bytes, ${m}` }) : h(7, c.limit, e, { passed: !0 })), !t.answered || t.code !== 0) s.push(h(8, c.shape, e, {
1641
+ })) : e.answered && i.answers.includes(e.code) ? s.push(v(6, c.exit, t, { passed: !0 })) : e.answered && e.code === 1 ? s.push(v(6, c.exit, t, { detail: `got exit 1, and exit 1 is a break in blazon: the ${t} role defines only ${a}, so blazon reports the plugin as failed and counts it toward its breaker. Exit 2 with the reason on the first line when the plugin cannot answer` })) : s.push(v(6, c.exit, t, { detail: e.answered ? `got exit ${e.code}` : `a break: ${e.breakReason}` }));
1642
+ let m = i.stdoutLimit === void 0 ? "the core's limit, which the role does not raise" : `the ${t} role's limit (stdout_limit_bytes)`;
1643
+ if (s.push(p ? v(7, c.limit, t, { detail: `the plugin printed more than ${o} bytes, ${m}` }) : v(7, c.limit, t, { passed: !0 })), !e.answered || e.code !== 0) s.push(v(8, c.shape, t, {
1607
1644
  skipped: !0,
1608
1645
  detail: "the plugin did not answer with exit 0"
1609
1646
  }));
1610
- else if (n === void 0) s.push(h(8, c.shape, e, {
1647
+ else if (n === void 0) s.push(v(8, c.shape, t, {
1611
1648
  skipped: !0,
1612
1649
  detail: "the program's file name is not blazon-<plugin name>, so the check does not know the plugin's code prefix"
1613
1650
  }));
1614
1651
  else {
1615
- let r = de(e, n, t.stdout, []);
1616
- s.push("problem" in r ? h(8, c.shape, e, { detail: r.problem }) : h(8, c.shape, e, { passed: !0 }));
1652
+ let r = Xe(t, n, e.stdout, []);
1653
+ s.push("problem" in r ? v(8, c.shape, t, { detail: r.problem }) : v(8, c.shape, t, { passed: !0 }));
1617
1654
  }
1618
- if (e === "build") {
1619
- let t = ti(d, f);
1620
- s.push(t.length === 0 ? h(9, c.folder, e, { passed: !0 }) : h(9, c.folder, e, {
1655
+ if (t === "build") {
1656
+ let e = di(d, f);
1657
+ s.push(e.length === 0 ? v(9, c.folder, t, { passed: !0 }) : v(9, c.folder, t, {
1621
1658
  passed: !0,
1622
1659
  warning: !0,
1623
- detail: `it wrote ${t.map((e) => `tokens_dir/${e}`).join(", ")}. Blazon empties only out_dir before a build, so a file beside it is never cleaned and can collide with another plugin's. Blazon has no folder for a plugin's own state yet, so this is a warning; see ${$r}`
1660
+ detail: `it wrote ${e.map((e) => `tokens_dir/${e}`).join(", ")}. Blazon empties only out_dir before a build, so a file beside it is never cleaned and can collide with another plugin's. Blazon has no folder for a plugin's own state yet, so this is a warning; see ${li}`
1624
1661
  }));
1625
1662
  }
1626
1663
  } finally {
@@ -1633,30 +1670,30 @@ function ni(e) {
1633
1670
  };
1634
1671
  }
1635
1672
  // src/cli/commands/plugin.ts
1636
- var ri = {
1673
+ var pi = {
1637
1674
  plugin: "usage: blazon plugin check <program> [--core] | blazon plugin pin <path> [--name <plugin name>] | blazon plugin profile",
1638
1675
  check: "usage: blazon plugin check <program> [--core]",
1639
1676
  pin: "usage: blazon plugin pin <path> [--name <plugin name> [--digest <digest>] [--entry <path>]]"
1640
1677
  };
1641
- function ii(e) {
1642
- let t = e.warning ? l.yellow("warn") : e.passed ? l.green("ok ") : e.skipped ? l.dim("skip") : l.red("FAIL"), n = e.role ? `${e.role}: ` : "", r = e.detail ? ` (${e.detail})` : "";
1678
+ function mi(e) {
1679
+ let t = e.warning ? a.yellow("warn") : e.passed ? a.green("ok ") : e.skipped ? a.dim("skip") : a.red("FAIL"), n = e.role ? `${e.role}: ` : "", r = e.detail ? ` (${e.detail})` : "";
1643
1680
  return ` ${t} ${e.case} ${n}${e.name}${r}`;
1644
1681
  }
1645
- async function ai(e, t = {}) {
1646
- if (!e) throw new M(ri.check, void 0, "missing-argument");
1647
- let n = t.core === !0;
1648
- t.json || (console.log(`${v.host} plugin check: host ${v.host}, adopts: ${v.adopts.length > 0 ? v.adopts.join(", ") : "none"}`), n && console.log("core cases only (1 to 5): no role cases, no layout line"));
1649
- let r = await Te({
1650
- ...n ? {} : { approvals: await oi(e) },
1651
- host: v.host,
1652
- profile: o,
1653
- program: e,
1682
+ async function hi(t, n = {}) {
1683
+ if (!t) throw new M(pi.check, void 0, "missing-argument");
1684
+ let r = n.core === !0;
1685
+ n.json || (console.log(`${E.host} plugin check: host ${E.host}, adopts: ${E.adopts.length > 0 ? E.adopts.join(", ") : "none"}`), r && console.log("core cases only (1 to 5): no role cases, no layout line"));
1686
+ let i = await _({
1687
+ ...r ? {} : { approvals: await gi(t) },
1688
+ host: E.host,
1689
+ profile: ee,
1690
+ program: t,
1654
1691
  validate: !1,
1655
- requests: De(),
1656
- ...n ? {} : { roleCases: ni(e) }
1657
- }), i = r.filter((e) => e.warning).length, a = r.filter((e) => !e.passed && !e.skipped), s = n ? void 0 : Se(O.resolve(e));
1658
- if (t.json) {
1659
- let e = (e) => e.warning ? "warn" : e.passed ? "ok" : e.skipped ? "skip" : "fail", t = r.map((t) => ({
1692
+ requests: e(),
1693
+ ...r ? {} : { roleCases: fi(t) }
1694
+ }), o = i.filter((e) => e.warning).length, s = i.filter((e) => !e.passed && !e.skipped), c = r ? void 0 : w(O.resolve(t));
1695
+ if (n.json) {
1696
+ let e = (e) => e.warning ? "warn" : e.passed ? "ok" : e.skipped ? "skip" : "fail", t = i.map((t) => ({
1660
1697
  case: t.case,
1661
1698
  name: t.name,
1662
1699
  role: t.role,
@@ -1665,128 +1702,129 @@ async function ai(e, t = {}) {
1665
1702
  }));
1666
1703
  return process.stdout.write(`${JSON.stringify({
1667
1704
  command: "plugin check",
1668
- passed: a.length === 0 && !s,
1669
- host: v.host,
1670
- adopts: v.adopts,
1671
- ...n ? { core: !0 } : {},
1705
+ passed: s.length === 0 && !c,
1706
+ host: E.host,
1707
+ adopts: E.adopts,
1708
+ ...r ? { core: !0 } : {},
1672
1709
  cases: t,
1673
- ...s ? { layout: s } : {}
1674
- })}\n`), a.length === 0 && !s ? 0 : 1;
1710
+ ...c ? { layout: c } : {}
1711
+ })}\n`), s.length === 0 && !c ? 0 : 1;
1675
1712
  }
1676
- for (let e of r) console.log(ii(e));
1677
- return s && console.log(` ${l.red("FAIL")} layout: ${s}`), a.length > 0 ? console.log(l.red(`\n${a.length} case${a.length === 1 ? "" : "s"} failed`)) : console.log(s ? l.red("\nFailed: the file name does not follow the layout of a shipped plugin") : l.green(`\nPassed${i > 0 ? `, with ${i} warning${i === 1 ? "" : "s"}` : ""}`)), a.length === 0 && !s ? 0 : 1;
1713
+ for (let e of i) console.log(mi(e));
1714
+ return c && console.log(` ${a.red("FAIL")} layout: ${c}`), s.length > 0 ? console.log(a.red(`\n${s.length} case${s.length === 1 ? "" : "s"} failed`)) : console.log(c ? a.red("\nFailed: the file name does not follow the layout of a shipped plugin") : a.green(`\nPassed${o > 0 ? `, with ${o} warning${o === 1 ? "" : "s"}` : ""}`)), s.length === 0 && !c ? 0 : 1;
1678
1715
  }
1679
- async function oi(e) {
1716
+ async function gi(e) {
1680
1717
  let t;
1681
1718
  try {
1682
1719
  t = (await R(process.cwd())).plugins ?? [];
1683
1720
  } catch {
1684
1721
  return;
1685
1722
  }
1686
- let n = O.basename(e), r = je(n) ?? n.replace(/^blazon-/, "");
1723
+ let n = O.basename(e), r = Ze(n) ?? n.replace(/^blazon-/, "");
1687
1724
  return t.flatMap((e, t) => e.name === r ? [{
1688
1725
  key: `plugins[${t}].env`,
1689
1726
  approved: e.env ?? []
1690
1727
  }] : []);
1691
1728
  }
1692
- function si(e, t = {}, n = process.cwd()) {
1693
- if (!e) throw new M(ri.pin, void 0, "missing-argument");
1694
- if (!t.name && (t.digest || t.entry)) throw new M(`--digest and --entry say what to record, so they need --name; ${ri.pin}`, void 0, "conflicting-options");
1729
+ function _i(e, t = {}, r = process.cwd()) {
1730
+ if (!e) throw new M(pi.pin, void 0, "missing-argument");
1731
+ if (!t.name && (t.digest || t.entry)) throw new M(`--digest and --entry say what to record, so they need --name; ${pi.pin}`, void 0, "conflicting-options");
1695
1732
  if (!k.existsSync(e)) return console.error(`blazon plugin pin: there is nothing at ${e}.`), 2;
1696
1733
  try {
1697
1734
  if (t.name) {
1698
- let r = Xe(n, t.name, e, {
1735
+ let i = n(r, t.name, e, {
1699
1736
  digest: t.digest,
1700
1737
  entry: t.entry
1701
1738
  });
1702
- return console.log(`pinned ${t.name}: ${r.digest} (${r.source}) in ${S}`), 0;
1739
+ return console.log(`pinned ${t.name}: ${i.digest} (${i.source}) in ${nt}`), 0;
1703
1740
  }
1704
- let r = k.lstatSync(e);
1705
- return console.log(r.isDirectory() && !r.isSymbolicLink() ? m(e) : d(e)), 0;
1741
+ let i = k.lstatSync(e);
1742
+ return console.log(i.isDirectory() && !i.isSymbolicLink() ? Re(e) : h(e)), 0;
1706
1743
  } catch (t) {
1707
- return console.error(t instanceof re ? t.message : `cannot read ${e}: ${t instanceof Error ? t.message : String(t)}`), 1;
1744
+ return console.error(t instanceof l ? t.message : `cannot read ${e}: ${t instanceof Error ? t.message : String(t)}`), 1;
1708
1745
  }
1709
1746
  }
1710
- function ci() {
1711
- return console.log(JSON.stringify(v, null, 2)), 0;
1747
+ function vi() {
1748
+ return console.log(JSON.stringify(E, null, 2)), 0;
1712
1749
  }
1713
- async function li(e, t, n = {}) {
1714
- if (e === "check") return ai(t, {
1750
+ async function yi(e, t, n = {}) {
1751
+ if (e === "check") return hi(t, {
1715
1752
  json: n.json,
1716
1753
  core: n.core
1717
1754
  });
1718
- if (e === "pin") return si(t, n);
1719
- if (e === "profile") return ci();
1720
- throw new M(ri.plugin, void 0, "missing-argument");
1755
+ if (e === "pin") return _i(t, n);
1756
+ if (e === "profile") return vi();
1757
+ throw new M(pi.plugin, void 0, "missing-argument");
1721
1758
  }
1722
1759
  // src/cli/commands/pin.ts
1723
- function ui(e = process.cwd(), t = {}) {
1724
- gt(e);
1760
+ function bi(e = process.cwd(), t = {}) {
1761
+ Ct(e);
1725
1762
  try {
1726
- let n = t.identity === void 0 ? Ye(e) : Ye(e, t.identity);
1763
+ let n = t.identity === void 0 ? ne(e) : ne(e, t.identity);
1727
1764
  return t.json ? process.stdout.write(`${JSON.stringify({
1728
1765
  command: "pin",
1729
1766
  passed: !0,
1730
1767
  commit: n,
1731
- file: be
1732
- })}\n`) : console.log(`pinned blazon ${l.bold(n)} in ${be}; commit the file with the book`), 0;
1768
+ file: fe
1769
+ })}\n`) : console.log(`pinned blazon ${a.bold(n)} in ${fe}; commit the file with the book`), 0;
1733
1770
  } catch (e) {
1734
1771
  if (t.json) throw e;
1735
1772
  return console.error(e instanceof Error ? e.message : String(e)), 1;
1736
1773
  }
1737
1774
  }
1738
1775
  // src/cli/commands/drift.ts
1739
- async function di(e, t = {}) {
1740
- let n = (e, n, r) => (console.error(it("drift", n, r).replace(/^blazon drift:/, (e) => l.red(e))), t.json && console.log(JSON.stringify({
1776
+ async function xi(e, t = {}) {
1777
+ let n = (e, n, r) => (console.error(dt("drift", n, r).replace(/^blazon drift:/, (e) => a.red(e))), t.json && console.log(JSON.stringify({
1741
1778
  command: "drift",
1742
1779
  passed: !1,
1743
- error: { ...lt(e, at(n, r), r) }
1780
+ error: { ...gt(e, ft(n, r), r) }
1744
1781
  })), 2);
1745
1782
  if (!e) return n("missing-argument", "needs the address of a page or the path of a CSS file", "Run blazon drift <url-or-css-file>.");
1746
1783
  let r = t.cwd ?? process.cwd();
1747
1784
  if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(e) && !k.existsSync(O.resolve(e))) return n("no-file", `there is no file "${e}"`, "Give the path of a CSS file, or the http(s) address of a page.");
1748
- let i, a;
1785
+ let i, o;
1749
1786
  try {
1750
- let n = await R(r, t.tokens ? { tokensDir: t.tokens } : void 0), o = await D(n, r), s = await tn(e);
1787
+ let n = await R(r, t.tokens ? { tokensDir: t.tokens } : void 0), a = await T(n, r), s = await ln(e);
1751
1788
  i = s.sources;
1752
- let c = Jt(s.css);
1753
- a = o.tokens.items.flatMap((e) => {
1789
+ let c = tn(s.css);
1790
+ o = a.tokens.items.flatMap((e) => {
1754
1791
  let t = e.blazon.source?.cssVar;
1755
- return typeof t == "string" ? [Yt(e, t, c)] : [];
1792
+ return typeof t == "string" ? [nn(e, t, c)] : [];
1756
1793
  });
1757
1794
  } catch (e) {
1758
1795
  return n(e instanceof j ? e.code : "error", e instanceof Error ? e.message : String(e), e instanceof j ? e.fix : void 0);
1759
1796
  }
1760
- if (a.length === 0) return n("error", "no token declares a source.cssVar, so there is nothing to compare", "Name the site's custom property in a token's dev.blazon source.cssVar (manual chapter 2).");
1761
- let o = (e) => a.filter((t) => t.status === e).length, s = {
1762
- ok: o("ok"),
1763
- drift: o("drift"),
1764
- missing: o("missing")
1765
- }, c = +(s.drift + s.missing > 0);
1797
+ if (o.length === 0) return n("error", "no token declares a source.cssVar, so there is nothing to compare", "Name the site's custom property in a token's dev.blazon source.cssVar (manual chapter 2).");
1798
+ let s = (e) => o.filter((t) => t.status === e).length, c = {
1799
+ ok: s("ok"),
1800
+ drift: s("drift"),
1801
+ missing: s("missing")
1802
+ }, l = +(c.drift + c.missing > 0);
1766
1803
  if (t.json) return console.log(JSON.stringify({
1767
1804
  target: e,
1768
1805
  sources: i,
1769
- summary: s,
1770
- tokens: a
1771
- }, null, 2)), c;
1772
- let u = Math.max(...a.map((e) => e.path.length));
1773
- for (let e of a) {
1806
+ summary: c,
1807
+ tokens: o
1808
+ }, null, 2)), l;
1809
+ let u = Math.max(...o.map((e) => e.path.length));
1810
+ for (let e of o) {
1774
1811
  let t = e.path.padEnd(u);
1775
- e.status === "ok" ? console.log(`${l.green("ok ")} ${t} ${l.dim(e.cssVar)}`) : e.status === "drift" ? console.log(`${l.red("drift ")} ${t} ${e.cssVar}: token ${e.expected}, site ${e.actual}`) : console.log(`${l.yellow("missing")} ${t} ${e.cssVar} is not declared (token ${e.expected})`);
1812
+ e.status === "ok" ? console.log(`${a.green("ok ")} ${t} ${a.dim(e.cssVar)}`) : e.status === "drift" ? console.log(`${a.red("drift ")} ${t} ${e.cssVar}: token ${e.expected}, site ${e.actual}`) : console.log(`${a.yellow("missing")} ${t} ${e.cssVar} is not declared (token ${e.expected})`);
1776
1813
  }
1777
- return console.log(`\n${s.ok} ok, ${s.drift} drifted, ${s.missing} missing`), c;
1814
+ return console.log(`\n${c.ok} ok, ${c.drift} drifted, ${c.missing} missing`), l;
1778
1815
  }
1779
1816
  // src/cli/commands/approvals.ts
1780
- async function fi(e = process.cwd(), t = {}) {
1781
- let n = await R(e), r = await D(n, e), i = T(r.tokens, r.assets.all, {
1817
+ async function Si(e = process.cwd(), t = {}) {
1818
+ let n = await R(e), r = await T(n, e), i = o(r.tokens, r.assets.all, {
1782
1819
  assetsDir: O.resolve(e, n.assetsDir),
1783
- dirs: ne(n.assets, e)
1784
- }), a = (e) => e.review.value === void 0 ? "not recorded" : e.review.value === e.current ? "recorded" : "stale";
1820
+ dirs: se(n.assets, e)
1821
+ }), s = (e) => e.review.value === void 0 ? "not recorded" : e.review.value === e.current ? "recorded" : "stale";
1785
1822
  if (t.json) {
1786
1823
  let e = i.map((e) => ({
1787
1824
  path: e.path,
1788
1825
  fingerprint: e.current ?? null,
1789
- state: a(e)
1826
+ state: s(e),
1827
+ ...e.files && { files: e.files }
1790
1828
  }));
1791
1829
  return process.stdout.write(`${JSON.stringify({
1792
1830
  command: "approvals",
@@ -1794,43 +1832,63 @@ async function fi(e = process.cwd(), t = {}) {
1794
1832
  approvals: e
1795
1833
  })}\n`), 0;
1796
1834
  }
1797
- if (i.length === 0) return console.log(l.dim("\n No token or asset is marked review.status: ok.\n")), 0;
1798
- let o = Math.max(...i.map((e) => e.path.length));
1835
+ if (i.length === 0) return console.log(a.dim("\n No token or asset is marked review.status: ok.\n")), 0;
1836
+ let c = Math.max(...i.map((e) => e.path.length));
1799
1837
  console.log();
1800
1838
  for (let e of i) {
1801
- let t = a(e), n = t === "recorded" ? l.green : t === "stale" ? l.yellow : l.dim;
1802
- console.log(` ${e.path.padEnd(o)} ${(e.current ?? "(no value)").padEnd(12)} ${n(t)}`);
1839
+ let t = s(e), n = t === "recorded" ? a.green : t === "stale" ? a.yellow : a.dim, r = e.files ? ` ${a.dim(e.files.join(", "))}` : "";
1840
+ console.log(` ${e.path.padEnd(c)} ${(e.current ?? "(no value)").padEnd(12)} ${n(t)}${" ".repeat(12 - t.length)}${r}`.trimEnd());
1803
1841
  }
1804
- return console.log(), console.log(l.dim(" Set review.value to the fingerprint once a person has confirmed the value.\n")), 0;
1842
+ return console.log(), console.log(a.dim(" Set review.value to the fingerprint once a person has confirmed the value.\n")), 0;
1805
1843
  }
1806
1844
  // src/cli/commands/cwd.ts
1807
- function pi(e) {
1845
+ function Ci(e) {
1808
1846
  if (e === void 0) return;
1809
1847
  if (typeof e != "string" || e === "") throw new M("--cwd needs a folder", "Give one, such as blazon --cwd ./my-brand check.");
1810
1848
  let t = O.resolve(process.cwd(), e);
1811
- gt(t), process.chdir(t);
1849
+ Ct(t), process.chdir(t);
1812
1850
  }
1813
- function mi(e, t = process.env) {
1851
+ function wi(e, t = process.env) {
1814
1852
  let n = (Array.isArray(e) ? e : e === void 0 ? [] : [e]).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : "");
1815
1853
  if (n.some((e) => e.trim() === "")) throw new M("--allow-dir needs a folder", "Give one, such as blazon dev --allow-dir ../shared.");
1816
- ze(ge(n, t, process.cwd()));
1854
+ ye(He(n, t, process.cwd()));
1817
1855
  }
1818
1856
  // src/core/read/lookup.ts
1819
- var K = class extends Error {}, hi = (e) => e.trim().replace(/^\{(.*)\}$/, "$1").trim();
1820
- function gi(e, t) {
1821
- let n = hi(t), r = e.tokens.byPath.get(n);
1822
- if (r) return r;
1823
- let i = E(n, e.tokens.items.map((e) => e.path));
1824
- throw new K(e.tokens.items.some((e) => e.path.startsWith(`${n}.`)) ? `"${n}" is a group, not a token; \`blazon rules ${n}\` shows its rules.` : `no token "${n}"${i ? `; did you mean "${i}"?` : "."}`);
1857
+ var K = class extends Error {}, Ti = (e) => e.trim().replace(/^\{(.*)\}$/, "$1").trim();
1858
+ function Ei(e, t, n) {
1859
+ let r = Ti(t), i = e.tokens.byPath.get(r);
1860
+ if (i) return i;
1861
+ let a = D(r, e.tokens.items.map((e) => e.path));
1862
+ throw new K(e.tokens.items.some((e) => e.path.startsWith(`${r}.`)) ? `"${r}" is a group, not a token; \`blazon rules ${r}\` shows its rules.` : `no token "${r}"${n === void 0 ? "" : ` in theme "${n}"`}${a ? `; did you mean "${a}"?` : "."}`);
1863
+ }
1864
+ // src/core/read/theme.ts
1865
+ var Di = "theme";
1866
+ function Oi(e) {
1867
+ return e.tokens.modifiers?.find((e) => e.name === "theme")?.contexts ?? [];
1868
+ }
1869
+ function ki(e, t) {
1870
+ let n = e.tokens.modifiers?.find((e) => e.name === Di);
1871
+ if (!n) throw new K(`no theme "${t}": this brand has no resolver "${Di}" modifier, so it has no themes.`);
1872
+ if (!n.contexts.includes(t)) throw new K(`no theme "${t}". The themes are ${n.contexts.map((e) => `"${e}"`).join(", ")}.`);
1873
+ let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i = le(e.tokens.items, r), a = m(e.tokens.groupMeta, r);
1874
+ return {
1875
+ ...e,
1876
+ tokens: {
1877
+ ...e.tokens,
1878
+ items: i,
1879
+ groupMeta: a,
1880
+ byPath: new Map(i.map((e) => [e.path, e]))
1881
+ }
1882
+ };
1825
1883
  }
1826
1884
  // src/core/read/rules.ts
1827
- var _i = (e) => e.extensions?.["dev.blazon"] ?? {};
1828
- function vi(e, t, n) {
1829
- return _i(t)[n] === void 0 ? e.tokens.groupMeta.filter((e) => t.path.startsWith(`${e.path}.`) && e.blazon[n] !== void 0).sort((e, t) => t.path.length - e.path.length)[0]?.path : t.path;
1885
+ var Ai = (e) => e.extensions?.["dev.blazon"] ?? {};
1886
+ function ji(e, t, n) {
1887
+ return Ai(t)[n] === void 0 ? e.tokens.groupMeta.filter((e) => t.path.startsWith(`${e.path}.`) && e.blazon[n] !== void 0).sort((e, t) => t.path.length - e.path.length)[0]?.path : t.path;
1830
1888
  }
1831
1889
  var q = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : void 0;
1832
- function yi(e, t) {
1833
- let n = t.blazon.usage, r = vi(e, t, "usage");
1890
+ function Mi(e, t) {
1891
+ let n = t.blazon.usage, r = ji(e, t, "usage");
1834
1892
  if (!n || typeof n != "object" || r === void 0) return;
1835
1893
  let i = q(n.allow), a = q(n.deny);
1836
1894
  return {
@@ -1839,15 +1897,15 @@ function yi(e, t) {
1839
1897
  from: r
1840
1898
  };
1841
1899
  }
1842
- function bi(e, t) {
1843
- let n = t.blazon.logo, r = vi(e, t, "logo"), i = q(n?.deny);
1900
+ function Ni(e, t) {
1901
+ let n = t.blazon.logo, r = ji(e, t, "logo"), i = q(n?.deny);
1844
1902
  if (n && i && r !== void 0) return {
1845
1903
  deny: i,
1846
1904
  ...typeof n.reason == "string" && { reason: n.reason },
1847
1905
  from: r
1848
1906
  };
1849
1907
  }
1850
- function xi(e) {
1908
+ function Pi(e) {
1851
1909
  return e.tokens.groupMeta.flatMap((e) => (e.blazon.pairs ?? []).map((t) => ({
1852
1910
  fg: t.fg,
1853
1911
  bg: t.bg,
@@ -1855,19 +1913,19 @@ function xi(e) {
1855
1913
  from: e.path
1856
1914
  })));
1857
1915
  }
1858
- function Si(e, t) {
1916
+ function Fi(e, t) {
1859
1917
  let n = [];
1860
- for (let r of xi(e)) b(r.fg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1918
+ for (let r of Pi(e)) S(r.fg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1861
1919
  ...r,
1862
1920
  as: "fg"
1863
- }), b(r.bg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1921
+ }), S(r.bg, e.tokens.items).some((e) => e.path === t.path) && n.push({
1864
1922
  ...r,
1865
1923
  as: "bg"
1866
1924
  });
1867
1925
  return n;
1868
1926
  }
1869
- function Ci(e, t) {
1870
- let n = _i(t).review, r = n ? t.path : vi(e, t, "review"), i = n ?? e.tokens.groupMeta.find((e) => e.path === r)?.blazon.review;
1927
+ function Ii(e, t) {
1928
+ let n = Ai(t).review, r = n ? t.path : ji(e, t, "review"), i = n ?? e.tokens.groupMeta.find((e) => e.path === r)?.blazon.review;
1871
1929
  if (i && r !== void 0) return {
1872
1930
  status: i.status,
1873
1931
  ...i.note && { note: i.note },
@@ -1876,8 +1934,8 @@ function Ci(e, t) {
1876
1934
  from: r
1877
1935
  };
1878
1936
  }
1879
- function wi(e, t) {
1880
- let n = yi(e, t), r = bi(e, t), i = Ci(e, t), a = t.blazon.role === void 0 ? void 0 : vi(e, t, "role");
1937
+ function Li(e, t) {
1938
+ let n = Mi(e, t), r = Ni(e, t), i = Ii(e, t), a = t.blazon.role === void 0 ? void 0 : ji(e, t, "role");
1881
1939
  return {
1882
1940
  ...t.blazon.role !== void 0 && a !== void 0 && { role: {
1883
1941
  value: t.blazon.role,
@@ -1885,11 +1943,11 @@ function wi(e, t) {
1885
1943
  } },
1886
1944
  ...n && { usage: n },
1887
1945
  ...r && { logo: r },
1888
- pairs: Si(e, t),
1946
+ pairs: Fi(e, t),
1889
1947
  ...i && { review: i }
1890
1948
  };
1891
1949
  }
1892
- function Ti(e, t, n) {
1950
+ function Ri(e, t, n) {
1893
1951
  let r = n.usage && typeof n.usage == "object" ? {
1894
1952
  ...q(n.usage.allow) && { allow: q(n.usage.allow) },
1895
1953
  ...q(n.usage.deny) && { deny: q(n.usage.deny) }
@@ -1910,59 +1968,66 @@ function Ti(e, t, n) {
1910
1968
  };
1911
1969
  return Object.keys(a).length > 2 ? a : void 0;
1912
1970
  }
1913
- function Ei(e, t) {
1914
- let n = hi(t), r = (e) => n === "" || e === n || e.startsWith(`${n}.`);
1971
+ function zi(e, t) {
1972
+ let n = Ti(t), r = (e) => n === "" || e === n || e.startsWith(`${n}.`);
1915
1973
  if (!(n === "" || e.tokens.items.some((e) => r(e.path)))) {
1916
- let t = [...new Set(e.tokens.items.flatMap((e) => e.path.split(".").slice(0, -1).map((e, t, n) => n.slice(0, t + 1).join("."))))], r = E(n, [...t, ...e.tokens.items.map((e) => e.path)]);
1974
+ let t = [...new Set(e.tokens.items.flatMap((e) => e.path.split(".").slice(0, -1).map((e, t, n) => n.slice(0, t + 1).join("."))))], r = D(n, [...t, ...e.tokens.items.map((e) => e.path)]);
1917
1975
  throw new K(`no token or group "${n}"${r ? `; did you mean "${r}"?` : "."}`);
1918
1976
  }
1919
1977
  return [
1920
- ...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) => Ti(e.path, "group", {
1978
+ ...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) => Ri(e.path, "group", {
1921
1979
  ...e.blazon,
1922
1980
  pairs: void 0
1923
1981
  })).map((e) => e && {
1924
1982
  ...e,
1925
1983
  inherited: !0
1926
1984
  }),
1927
- ...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) => Ti(e.path, "group", e.blazon)),
1928
- ...e.tokens.items.filter((e) => r(e.path)).map((e) => Ti(e.path, "token", _i(e)))
1985
+ ...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) => Ri(e.path, "group", e.blazon)),
1986
+ ...e.tokens.items.filter((e) => r(e.path)).map((e) => Ri(e.path, "token", Ai(e)))
1929
1987
  ].filter((e) => e !== void 0);
1930
1988
  }
1931
1989
  // src/core/read/token.ts
1932
- function Di(e, t) {
1933
- let [r, ...i] = n(t);
1990
+ function Bi(e, t) {
1991
+ let [n, ...r] = y(t);
1934
1992
  return {
1935
1993
  theme: {
1936
- variable: r,
1937
- ...t.parts && { parts: Object.fromEntries(Object.keys(t.parts).map((e, t) => [e, i[t]])) }
1994
+ variable: n,
1995
+ ...t.parts && { parts: Object.fromEntries(Object.keys(t.parts).map((e, t) => [e, r[t]])) }
1938
1996
  },
1939
- ...t.type === "typography" && { typographyClass: p(t.path) }
1997
+ ...t.type === "typography" && { typographyClass: We(t.path) }
1940
1998
  };
1941
1999
  }
1942
- function Oi(e, t) {
1943
- let n = gi(e, t), r = (e.tokens.contexts ?? []).flatMap((e) => e.tokens.filter((e) => e.path === n.path).map((t) => ({
2000
+ function Vi(e, t, n) {
2001
+ let r = Ei(n === void 0 ? e : ki(e, n), t, n), i = n === void 0 ? void 0 : Ei(e, t), a = (e.tokens.contexts ?? []).flatMap((e) => e.tokens.filter((e) => e.path === r.path).map((t) => ({
1944
2002
  modifier: e.modifier,
1945
2003
  context: e.context,
1946
2004
  selector: e.selector,
1947
2005
  value: t.value
1948
2006
  })));
1949
2007
  return {
1950
- path: n.path,
1951
- ...n.type && { type: n.type },
1952
- value: n.value,
1953
- ...n.parts && { parts: n.parts },
1954
- ...n.description && { description: n.description },
1955
- ...n.deprecated && { deprecated: n.deprecated },
1956
- ...n.aliasOf && { aliasOf: n.aliasOf },
1957
- ...n.blazon.tier && { tier: n.blazon.tier },
1958
- names: Di(e, n),
1959
- rules: wi(e, n),
1960
- ...r.length > 0 && { contexts: r },
1961
- sourceFile: n.file.replace(/ \(inline\)$/, "")
2008
+ path: r.path,
2009
+ ...r.type && { type: r.type },
2010
+ value: r.value,
2011
+ ...i && i.value !== r.value && { defaultValue: i.value },
2012
+ ...n !== void 0 && { theme: n },
2013
+ ...r.parts && { parts: r.parts },
2014
+ ...r.description && { description: r.description },
2015
+ ...r.deprecated && { deprecated: r.deprecated },
2016
+ ...r.aliasOf && { aliasOf: r.aliasOf },
2017
+ ...r.blazon.tier && { tier: r.blazon.tier },
2018
+ names: Bi(e, r),
2019
+ rules: Li(e, r),
2020
+ ...a.length > 0 && { contexts: a },
2021
+ sourceFile: r.file.replace(/ \(inline\)$/, "")
1962
2022
  };
1963
2023
  }
1964
2024
  // src/core/read/list.ts
1965
- function ki(e) {
2025
+ var Hi = [
2026
+ "primitive",
2027
+ "semantic",
2028
+ "component"
2029
+ ];
2030
+ function Ui(e) {
1966
2031
  let t = /* @__PURE__ */ new Set();
1967
2032
  for (let { path: n } of e.tokens.items) {
1968
2033
  let e = n.split(".");
@@ -1970,53 +2035,63 @@ function ki(e) {
1970
2035
  }
1971
2036
  return t;
1972
2037
  }
1973
- function Ai(e, t) {
1974
- let n = hi(t);
1975
- return !e.tokens.byPath.has(n) && ki(e).has(n);
2038
+ function Wi(e, t) {
2039
+ let n = Ti(t);
2040
+ return !e.tokens.byPath.has(n) && Ui(e).has(n);
1976
2041
  }
1977
- function ji(e, t = {}) {
2042
+ function Gi(e, t = {}) {
1978
2043
  let n;
1979
- if (t.type !== void 0 && (n = s.find((e) => e === t.type), !n)) throw new K(`no token type "${t.type}"; the types are ${s.join(", ")}.`);
2044
+ if (t.type !== void 0 && (n = te.find((e) => e === t.type), !n)) throw new K(`no token type "${t.type}"; the types are ${te.join(", ")}.`);
1980
2045
  let r;
2046
+ if (t.tier !== void 0 && (r = Hi.find((e) => e === t.tier), !r)) throw new K(`no tier "${t.tier}"; the tiers are ${Hi.join(", ")}.`);
2047
+ let i = Oi(e), a = t.theme === void 0 ? e : ki(e, t.theme), o;
1981
2048
  if (t.group !== void 0) {
1982
- r = hi(t.group);
1983
- let n = ki(e);
1984
- if (!n.has(r)) {
1985
- let e = E(r, [...n]);
1986
- throw new K(`no group "${r}"${e ? `; did you mean "${e}"?` : "."}`);
2049
+ o = Ti(t.group);
2050
+ let n = Ui(e);
2051
+ if (!n.has(o)) {
2052
+ let e = D(o, [...n]);
2053
+ throw new K(`no group "${o}"${e ? `; did you mean "${e}"?` : "."}`);
1987
2054
  }
1988
2055
  }
1989
- let i = e.tokens.items.filter((e) => (r === void 0 || e.path.startsWith(`${r}.`)) && (n === void 0 || e.type === n)).map((e) => ({
1990
- path: e.path,
1991
- ...e.type && { type: e.type },
1992
- value: e.value,
1993
- ...e.aliasOf && { aliasOf: e.aliasOf }
1994
- }));
2056
+ let s = a.tokens.items.filter((e) => (o === void 0 || e.path.startsWith(`${o}.`)) && (n === void 0 || e.type === n) && (r === void 0 || e.blazon.tier === r)).map((n) => {
2057
+ let r = t.theme === void 0 ? void 0 : e.tokens.byPath.get(n.path);
2058
+ return {
2059
+ path: n.path,
2060
+ ...n.type && { type: n.type },
2061
+ value: n.value,
2062
+ ...n.aliasOf && { aliasOf: n.aliasOf },
2063
+ ...n.blazon.tier && { tier: n.blazon.tier },
2064
+ ...r && r.value !== n.value && { defaultValue: r.value }
2065
+ };
2066
+ });
1995
2067
  return {
1996
- ...r !== void 0 && { group: r },
2068
+ ...o !== void 0 && { group: o },
1997
2069
  ...n && { type: n },
1998
- tokens: i
2070
+ ...r && { tier: r },
2071
+ ...t.theme !== void 0 && { theme: t.theme },
2072
+ ...i.length > 0 && { themes: i },
2073
+ tokens: s
1999
2074
  };
2000
2075
  }
2001
- // src/core/read/can.ts
2002
- var Mi = ["text", "ui"], Ni = g["AA-large"], Pi = [
2076
+ // src/core/operations/limits.ts
2077
+ var Ki = 4e4, qi = ["text", "ui"], Ji = f["AA-large"], Yi = [
2003
2078
  "border",
2004
2079
  "icon",
2005
2080
  "interactive"
2006
- ], Fi = [
2081
+ ], Xi = [
2007
2082
  "AAA",
2008
2083
  "AA",
2009
2084
  "AA-large"
2010
2085
  ];
2011
- function Ii(e, t) {
2086
+ function Zi(e, t) {
2012
2087
  let n = [];
2013
2088
  for (let r = t; r && !n.includes(r); r = r.aliasOf ? e.tokens.byPath.get(r.aliasOf) : void 0) n.push(r);
2014
2089
  return n;
2015
2090
  }
2016
- function Li(e, t, n) {
2017
- for (let r of Ii(e, t)) {
2018
- if (Ee(r, n)) continue;
2019
- let t = yi(e, r), i = t.deny?.includes(n) ? `denies "${n}"` : `allows only ${(t.allow ?? []).map((e) => `"${e}"`).join(", ")}, not "${n}"`;
2091
+ function Qi(e, t, n) {
2092
+ for (let r of Zi(e, t)) {
2093
+ if (x(r, n)) continue;
2094
+ let t = Mi(e, r), i = t.deny?.includes(n) ? `denies "${n}"` : `allows only ${(t.allow ?? []).map((e) => `"${e}"`).join(", ")}, not "${n}"`;
2020
2095
  return {
2021
2096
  rule: "usage",
2022
2097
  ok: !1,
@@ -2024,15 +2099,15 @@ function Li(e, t, n) {
2024
2099
  from: t.from
2025
2100
  };
2026
2101
  }
2027
- let r = Ii(e, t).find((t) => yi(e, t));
2102
+ let r = Zi(e, t).find((t) => Mi(e, t));
2028
2103
  return {
2029
2104
  rule: "usage",
2030
2105
  ok: !0,
2031
2106
  message: r ? `usage rules on {${r.path}} leave "${n}" open` : `{${t.path}} has no usage rule against "${n}"`
2032
2107
  };
2033
2108
  }
2034
- function Ri(e, t) {
2035
- let n = Pi.map((n) => Li(e, t, n)), r = Pi.filter((e, t) => n[t].ok);
2109
+ function $i(e, t) {
2110
+ let n = Yi.map((n) => Qi(e, t, n)), r = Yi.filter((e, t) => n[t].ok);
2036
2111
  return r.length > 0 ? {
2037
2112
  rule: "usage",
2038
2113
  ok: !0,
@@ -2044,37 +2119,22 @@ function Ri(e, t) {
2044
2119
  from: n[0].from
2045
2120
  };
2046
2121
  }
2047
- var zi = "theme";
2048
- function Bi(e, t) {
2049
- let n = e.tokens.modifiers?.find((e) => e.name === zi);
2050
- if (!n) throw new K(`no theme "${t}": this brand has no resolver "${zi}" modifier, so it has no themes.`);
2051
- if (!n.contexts.includes(t)) throw new K(`no theme "${t}". The themes are ${n.contexts.map((e) => `"${e}"`).join(", ")}.`);
2052
- let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i = fe(e.tokens.items, r);
2053
- return {
2054
- ...e,
2055
- tokens: {
2056
- ...e.tokens,
2057
- items: i,
2058
- byPath: new Map(i.map((e) => [e.path, e]))
2059
- }
2060
- };
2061
- }
2062
- var Vi = (e, t) => {
2063
- let n = e.type === "color" ? f(String(e.value)) : void 0;
2122
+ var ea = (e, t) => {
2123
+ let n = e.type === "color" ? r(String(e.value)) : void 0;
2064
2124
  if (!n) throw new K(`{${e.path}} (${t}) is not a color blazon can read: it is ${e.type ?? "untyped"} with the value ${String(e.value)}.`);
2065
2125
  return n;
2066
2126
  };
2067
- function Hi(e, t, n, r = "text", i) {
2127
+ function ta(e, t, n, r = "text", i, a) {
2068
2128
  if (i !== void 0) return {
2069
- ...Hi(Bi(e, i), t, n, r),
2129
+ ...ta(ki(e, i), t, n, r, void 0, i),
2070
2130
  theme: i
2071
2131
  };
2072
- if (!Mi.includes(r)) throw new K(`"${String(r)}" is not a role blazon can judge. Use ${Mi.map((e) => `"${e}"`).join(" or ")}.`);
2073
- let a = gi(e, t), o = gi(e, n), s = _(Vi(a, "foreground"), Vi(o, "background")), c = Fi.find((e) => s >= g[e]) ?? "fail", l = `${s.toFixed(2)}:1`, d = Math.round(s * 100) / 100;
2132
+ if (!qi.includes(r)) throw new K(`"${String(r)}" is not a role blazon can judge. Use ${qi.map((e) => `"${e}"`).join(" or ")}.`);
2133
+ let o = Ei(e, t, a), s = Ei(e, n, a), c = g(ea(o, "foreground"), ea(s, "background")), l = Xi.find((e) => c >= f[e]) ?? "fail", u = `${c.toFixed(2)}:1`, d = Math.round(c * 100) / 100;
2074
2134
  if (r === "ui") {
2075
2135
  let t = [
2076
- Ri(e, a),
2077
- Li(e, o, "background"),
2136
+ $i(e, o),
2137
+ Qi(e, s, "background"),
2078
2138
  {
2079
2139
  rule: "pairs",
2080
2140
  ok: !0,
@@ -2082,77 +2142,98 @@ function Hi(e, t, n, r = "text", i) {
2082
2142
  },
2083
2143
  {
2084
2144
  rule: "contrast",
2085
- ok: s >= Ni,
2086
- message: `non-text contrast needs ${Ni}:1, this is ${l}`
2145
+ ok: c >= Ji,
2146
+ message: `non-text contrast needs ${Ji}:1, this is ${u}`
2087
2147
  }
2088
2148
  ], n = t.find((e) => !e.ok), i = n ? n.message : t[t.length - 1].message;
2089
2149
  return {
2090
- fg: a.path,
2091
- bg: o.path,
2150
+ fg: o.path,
2151
+ bg: s.path,
2092
2152
  role: r,
2093
2153
  allowed: n === void 0,
2094
2154
  reason: i,
2095
2155
  checks: t,
2096
2156
  contrast: {
2097
2157
  ratio: d,
2098
- level: c,
2099
- threshold: Ni
2158
+ level: l,
2159
+ threshold: Ji
2100
2160
  }
2101
2161
  };
2102
2162
  }
2103
- let f = [Li(e, a, "text"), Li(e, o, "background")], p = xi(e), m = u(e.tokens.items, p, a.path, o.path);
2104
- if (m.length > 0) for (let e of m) {
2105
- let t = g[e.min];
2106
- f.push({
2163
+ let p = [Qi(e, o, "text"), Qi(e, s, "background")], m = Pi(e), h = it(e.tokens.items, m, o.path, s.path);
2164
+ if (h.length > 0) for (let e of h) {
2165
+ let t = f[e.min];
2166
+ p.push({
2107
2167
  rule: "pairs",
2108
- ok: s >= t,
2109
- message: `pairs on ${e.from} list ${e.fg} on ${e.bg}: ${e.min} needs ${t}:1, this is ${l}`,
2168
+ ok: c >= t,
2169
+ message: `pairs on ${e.from} list ${e.fg} on ${e.bg}: ${e.min} needs ${t}:1, this is ${u}`,
2110
2170
  from: e.from
2111
2171
  });
2112
2172
  }
2113
- else p.length > 0 ? f.push({
2173
+ else m.length > 0 ? p.push({
2114
2174
  rule: "pairs",
2115
2175
  ok: !1,
2116
- message: `no pair lists {${a.path}} on {${o.path}}; the brand lists ${p.length} pair${p.length === 1 ? "" : "s"} and only those may sit together`
2117
- }) : f.push({
2176
+ message: `no pair lists {${o.path}} on {${s.path}}; the brand lists ${m.length} pair${m.length === 1 ? "" : "s"} and only those may sit together. Component tokens are not read for pairs: to allow this pair, declare it in \`pairs\` on a token group (docs/manual/02-tokens.md, "Contrast pairs")`
2177
+ }) : p.push({
2118
2178
  rule: "pairs",
2119
2179
  ok: !0,
2120
2180
  message: "the brand lists no pairs, so contrast is the only measure left"
2121
2181
  });
2122
- f.push({
2182
+ p.push({
2123
2183
  rule: "contrast",
2124
2184
  ok: !0,
2125
- message: `contrast is ${l}${c === "fail" ? ", below every WCAG level" : `, which meets ${c}`} (reported, never a rule of its own)`
2185
+ message: `contrast is ${u}${l === "fail" ? ", below every WCAG level" : `, which meets ${l}`} (reported, never a rule of its own)`
2126
2186
  });
2127
- let h = f.find((e) => !e.ok && e.rule !== "contrast") ?? void 0, v = h === void 0, y = h ? h.message : (f.find((e) => e.rule === "pairs" && e.from) ?? f[f.length - 1]).message;
2187
+ let _ = p.find((e) => !e.ok && e.rule !== "contrast") ?? void 0, v = _ === void 0, y = _ ? _.message : (p.find((e) => e.rule === "pairs" && e.from) ?? p[p.length - 1]).message;
2128
2188
  return {
2129
- fg: a.path,
2130
- bg: o.path,
2189
+ fg: o.path,
2190
+ bg: s.path,
2131
2191
  role: r,
2132
2192
  allowed: v,
2133
2193
  reason: y,
2134
- checks: f,
2194
+ checks: p,
2135
2195
  contrast: {
2136
2196
  ratio: d,
2137
- level: c
2197
+ level: l
2138
2198
  }
2139
2199
  };
2140
2200
  }
2201
+ function na(e) {
2202
+ if (!e.allowed) return e;
2203
+ let { checks: t, ...n } = e;
2204
+ return n;
2205
+ }
2206
+ function ra(e, t, n = "text", r) {
2207
+ if (t.length === 0) throw new K("give at least one pair.");
2208
+ if (t.length > 50) throw new K(`give at most 50 pairs in one call; this call has ${t.length}.`);
2209
+ let i = r === void 0 ? e : ki(e, r);
2210
+ return t.map((e, t) => {
2211
+ try {
2212
+ let t = ta(i, e.fg, e.bg, n, void 0, r);
2213
+ return r === void 0 ? t : {
2214
+ ...t,
2215
+ theme: r
2216
+ };
2217
+ } catch (e) {
2218
+ throw e instanceof K ? new K(`pairs[${t}]: ${e.message}`) : e;
2219
+ }
2220
+ });
2221
+ }
2141
2222
  // src/core/read/fonts.ts
2142
- function Ui(e, t, n) {
2143
- let r = t.fonts ?? [], i = Ve(t.fonts, n), a = /* @__PURE__ */ new Map();
2223
+ function ia(e, t, n) {
2224
+ let r = t.fonts ?? [], i = de(t.fonts, n), a = /* @__PURE__ */ new Map();
2144
2225
  for (let t of e.tokens.items) {
2145
- let e = t.resolvedValue, n = t.type === "fontFamily" ? (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "string") : void 0, r = t.type === "fontFamily" ? Me(e) : t.type === "typography" && typeof e == "object" && e ? Me(e.fontFamily) : void 0;
2226
+ let e = t.resolvedValue, n = t.type === "fontFamily" ? (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "string") : void 0, r = t.type === "fontFamily" ? Le(e) : t.type === "typography" && typeof e == "object" && e ? Le(e.fontFamily) : void 0;
2146
2227
  if (!r) continue;
2147
2228
  let o = r.toLowerCase(), s = a.get(o);
2148
2229
  s ? (s.tokens.push(t.path), !s.stack && n && (s.stack = n)) : a.set(o, {
2149
2230
  family: r,
2150
2231
  tokens: [t.path],
2151
2232
  ...n && { stack: n },
2152
- system: ue.has(o),
2233
+ system: Ce.has(o),
2153
2234
  loaded: i.families.has(o) ? !0 : i.opaque ? null : !1,
2154
2235
  ...t.blazon.webFont !== void 0 && { webFont: t.blazon.webFont },
2155
- ...t.blazon.font && { font: t.blazon.font }
2236
+ ...t.blazon.font && { font: u(t.blazon.font) }
2156
2237
  });
2157
2238
  }
2158
2239
  let o = (t) => e.theme[t] || e.themeTokens?.[t] ? {
@@ -2160,8 +2241,8 @@ function Ui(e, t, n) {
2160
2241
  value: e.theme[t]
2161
2242
  } : void 0;
2162
2243
  return {
2163
- stylesheets: r.filter((e) => !ke(e)),
2164
- files: r.filter(ke).map((e) => ({
2244
+ stylesheets: r.filter((e) => !Te(e)),
2245
+ files: r.filter(Te).map((e) => ({
2165
2246
  family: e.family,
2166
2247
  file: e.file,
2167
2248
  ...e.weight !== void 0 && { weight: e.weight },
@@ -2174,45 +2255,45 @@ function Ui(e, t, n) {
2174
2255
  families: [...a.values()]
2175
2256
  };
2176
2257
  }
2177
- function Wi(e, t) {
2258
+ function aa(e, t) {
2178
2259
  let n = e.stylesheets.map((e) => `/* Stylesheet, not fetched by blazon: ${e.replace(/\*\//g, "*%2F")} */`);
2179
2260
  for (let r of e.files) {
2180
- let e = me(r.file);
2261
+ let e = Oe(r.file);
2181
2262
  if (!e) {
2182
2263
  n.push(`/* ${r.file.replace(/\*\//g, "*%2F")}: not a font file blazon embeds, so no rule */`);
2183
2264
  continue;
2184
2265
  }
2185
2266
  let i = t === void 0 ? r.file : `${t.endsWith("/") ? t : `${t}/`}${r.file.split("/").pop()}`;
2186
- n.push(Le(r, `url("${encodeURI(i).replace(/"/g, "%22")}") format("${e}")`, !0));
2267
+ n.push(Pe(r, `url("${encodeURI(i).replace(/"/g, "%22")}") format("${e}")`, !0));
2187
2268
  }
2188
2269
  return n.length === 0 ? "/* The config lists no fonts. */\n" : `${n.join("\n\n")}\n`;
2189
2270
  }
2190
2271
  // src/core/read/logo.ts
2191
- function Gi(e, t, n) {
2192
- let i = ee(t), a = O.resolve(n, t.assetsDir), o = ne(t.assets, n), s = (e) => O.relative(n, r(e, a, o)).split(O.sep).join("/"), c = ["onLight", "onDark"].flatMap((t) => {
2193
- let n = i[t];
2272
+ function oa(e, t, n) {
2273
+ let r = oe(t), i = O.resolve(n, t.assetsDir), a = se(t.assets, n), o = (e) => O.relative(n, ae(e, i, a)).split(O.sep).join("/"), s = ["onLight", "onDark"].flatMap((t) => {
2274
+ let n = r[t];
2194
2275
  if (!n) return [];
2195
- let r = t === "onLight" ? e.logo?.onLightAsset : e.logo?.onDarkAsset, a = t === "onLight" ? e.logo?.onLightInk : e.logo?.onDarkInk;
2276
+ let i = t === "onLight" ? e.logo?.onLightAsset : e.logo?.onDarkAsset, a = t === "onLight" ? e.logo?.onLightInk : e.logo?.onDarkInk;
2196
2277
  return [{
2197
2278
  variant: t,
2198
2279
  file: n,
2199
2280
  found: !!(t === "onLight" ? e.logo?.onLight : e.logo?.onDark),
2200
- ...r && { asset: r },
2281
+ ...i && { asset: i },
2201
2282
  ...a && { ink: a }
2202
2283
  }];
2203
2284
  });
2204
2285
  return {
2205
- variants: c,
2206
- assets: e.assets.logos.map((e) => {
2207
- let t = r(e, a, o);
2286
+ variants: s,
2287
+ assets: [...new Set(e.assets.logos.map((e) => e.id))].map((t) => {
2288
+ let c = ze(e.assets.logos, t), l = c.map((e) => ae(e, i, a));
2208
2289
  return {
2209
- id: e.id,
2210
- file: s(e),
2211
- variants: c.filter((e) => i[e.variant] ? Ze(O.resolve(n, i[e.variant]), t) : !1).map((e) => e.variant),
2212
- rules: e.meta ?? {}
2290
+ id: t,
2291
+ files: c.map(o),
2292
+ variants: s.filter((e) => r[e.variant] ? l.some((t) => d(O.resolve(n, r[e.variant]), t)) : !1).map((e) => e.variant),
2293
+ rules: c[0].meta ?? {}
2213
2294
  };
2214
2295
  }),
2215
- forbidden: Ei(e, "").flatMap((e) => e.logo ? [{
2296
+ forbidden: zi(e, "").flatMap((e) => e.logo ? [{
2216
2297
  at: e.at,
2217
2298
  deny: e.logo.deny,
2218
2299
  ...e.logo.reason && { reason: e.logo.reason }
@@ -2221,13 +2302,16 @@ function Gi(e, t, n) {
2221
2302
  }
2222
2303
  // src/cli/read.ts
2223
2304
  async function J(e) {
2224
- let t = await R(e), n = await D(t, e), { errors: r } = c(n.findings);
2225
- return r.length > 0 && console.error(l.yellow(`blazon: this brand has ${r.length} error(s), so a value below may be wrong; run blazon check.`)), {
2305
+ let t = await R(e), n = await T(t, e), r = b(n.findings);
2306
+ r.length > 0 && console.error(a.yellow(`blazon: this brand has ${r.length} error(s), so a value below may be wrong; run blazon check.`));
2307
+ let { problems: i, mismatch: o } = _e(e);
2308
+ for (let e of i) console.error(a.yellow(`blazon: ${e.message}`));
2309
+ return o && console.error(a.yellow(Qe(o))), {
2226
2310
  config: t,
2227
2311
  data: n
2228
2312
  };
2229
2313
  }
2230
- function Ki(e) {
2314
+ function sa(e) {
2231
2315
  try {
2232
2316
  return e();
2233
2317
  } catch (e) {
@@ -2241,12 +2325,12 @@ function Y(e, t, n) {
2241
2325
  ...n
2242
2326
  }, null, 2)}\n`);
2243
2327
  }
2244
- function qi(e, t = " ") {
2328
+ function ca(e, t = " ") {
2245
2329
  let n = e.filter((e) => e[1] !== void 0), r = Math.max(0, ...n.map(([e]) => e.length));
2246
- for (let [e, i] of n) console.log(`${t}${l.dim(e.padEnd(r))} ${i}`);
2330
+ for (let [e, i] of n) console.log(`${t}${a.dim(e.padEnd(r))} ${i}`);
2247
2331
  }
2248
2332
  // src/cli/commands/doctor.ts
2249
- var Ji = [
2333
+ var la = [
2250
2334
  "blazon.brand-deck",
2251
2335
  "blazon.favicons",
2252
2336
  "blazon.logo-geometry",
@@ -2254,15 +2338,15 @@ var Ji = [
2254
2338
  "blazon.press-kit",
2255
2339
  "blazon.print-book",
2256
2340
  "blazon.social-cards"
2257
- ], Yi = (e) => {
2341
+ ], ua = (e) => {
2258
2342
  try {
2259
2343
  return k.accessSync(e, k.constants.X_OK), k.statSync(e).isFile();
2260
2344
  } catch {
2261
2345
  return !1;
2262
2346
  }
2263
2347
  };
2264
- function Xi(e = process.env) {
2265
- if (e.BLAZON_CHROME) return Yi(e.BLAZON_CHROME);
2348
+ function da(e = process.env) {
2349
+ if (e.BLAZON_CHROME) return ua(e.BLAZON_CHROME);
2266
2350
  let t = [];
2267
2351
  if (process.platform === "darwin") t.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
2268
2352
  else if (process.platform === "win32") for (let n of [
@@ -2271,19 +2355,19 @@ function Xi(e = process.env) {
2271
2355
  e.LOCALAPPDATA
2272
2356
  ]) n && t.push(O.join(n, "Google", "Chrome", "Application", "chrome.exe"));
2273
2357
  else t.push("/opt/google/chrome/chrome", ...(e.PATH ?? "").split(O.delimiter).filter(Boolean).flatMap((e) => ["google-chrome", "google-chrome-stable"].map((t) => O.join(e, t))));
2274
- return t.some(Yi);
2358
+ return t.some(ua);
2275
2359
  }
2276
- var Zi = () => {
2277
- let e = JSON.parse(k.readFileSync(O.join(ve(), "package.json"), "utf-8"));
2360
+ var fa = () => {
2361
+ let e = JSON.parse(k.readFileSync(O.join(et(), "package.json"), "utf-8"));
2278
2362
  return {
2279
2363
  nodeVersion: process.version,
2280
2364
  engine: e.engines?.node,
2281
- hostProblem: (e) => Fe(e, { final: "dir" }),
2282
- chrome: () => Xi(),
2283
- identity: ce()
2365
+ hostProblem: (e) => p(e, { final: "dir" }),
2366
+ chrome: () => da(),
2367
+ identity: qe()
2284
2368
  };
2285
2369
  };
2286
- function Qi(e, t) {
2370
+ function pa(e, t) {
2287
2371
  let n = /^>=\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?$/.exec(t.trim()), r = /^v?(\d+)\.(\d+)\.(\d+)/.exec(e);
2288
2372
  if (!n || !r) return;
2289
2373
  let i = [
@@ -2298,14 +2382,14 @@ function Qi(e, t) {
2298
2382
  for (let e = 0; e < 3; e++) if (a[e] !== i[e]) return a[e] > i[e];
2299
2383
  return !0;
2300
2384
  }
2301
- function $i(e) {
2385
+ function ma(e) {
2302
2386
  if (!e.engine) return {
2303
2387
  id: "node",
2304
2388
  status: "warn",
2305
2389
  message: `Node ${e.nodeVersion}; blazon's package.json names no engines range to compare`,
2306
2390
  fix: "Reinstall blazon."
2307
2391
  };
2308
- let t = Qi(e.nodeVersion, e.engine);
2392
+ let t = pa(e.nodeVersion, e.engine);
2309
2393
  return t === void 0 ? {
2310
2394
  id: "node",
2311
2395
  status: "warn",
@@ -2322,7 +2406,7 @@ function $i(e) {
2322
2406
  fix: `Install Node ${e.engine.replace(/^>=\s*/, "")} or newer, such as with nvm install ${e.engine.replace(/^>=\s*v?(\d+).*$/, "$1")}.`
2323
2407
  };
2324
2408
  }
2325
- async function ea(e) {
2409
+ async function ha(e) {
2326
2410
  try {
2327
2411
  let t = await R(e);
2328
2412
  return {
@@ -2342,14 +2426,14 @@ async function ea(e) {
2342
2426
  } };
2343
2427
  }
2344
2428
  }
2345
- function ta(e, t, n) {
2429
+ function ga(e, t, n) {
2346
2430
  let r = t.hostProblem(e);
2347
2431
  if (!r) return {
2348
2432
  id: "plugin-host",
2349
2433
  status: "ok",
2350
2434
  message: `${e} is a folder blazon will run plugins from`
2351
2435
  };
2352
- let i = /written by group or others/.test(r) ? qe(e) : "Run blazon from a folder under your own home folder that only you can write.";
2436
+ let i = /written by group or others/.test(r) ? C(e) : "Run blazon from a folder under your own home folder that only you can write.";
2353
2437
  return {
2354
2438
  id: "plugin-host",
2355
2439
  status: n > 0 ? "fail" : "warn",
@@ -2357,8 +2441,8 @@ function ta(e, t, n) {
2357
2441
  fix: i
2358
2442
  };
2359
2443
  }
2360
- function na(e, t) {
2361
- let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) => Ji.includes(e)))];
2444
+ function _a(e, t) {
2445
+ let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) => la.includes(e)))];
2362
2446
  return n.length === 0 ? {
2363
2447
  id: "chrome",
2364
2448
  status: "ok",
@@ -2374,61 +2458,66 @@ function na(e, t) {
2374
2458
  fix: "Install Google Chrome, or set BLAZON_CHROME to a Chrome or Chromium program; or take the plugin out of blazon.json."
2375
2459
  };
2376
2460
  }
2377
- function ra(e, t) {
2461
+ function va(e, t) {
2378
2462
  if (!k.existsSync(O.join(e, "blazon.lock"))) return {
2379
2463
  id: "lock",
2380
2464
  status: "ok",
2381
2465
  message: "no blazon.lock: this book is not pinned to a blazon build"
2382
2466
  };
2383
- let n = We(e, t.identity)[0];
2467
+ let n = tt(e, t.identity)[0];
2384
2468
  return n ? {
2385
2469
  id: "lock",
2386
2470
  status: "fail",
2387
2471
  message: n.message,
2388
- fix: n.fix ?? se[n.code].fix
2472
+ fix: n.fix ?? Ye[n.code].fix
2389
2473
  } : {
2390
2474
  id: "lock",
2391
2475
  status: "ok",
2392
2476
  message: "blazon.lock matches the blazon that is running"
2393
2477
  };
2394
2478
  }
2395
- async function ia(e, t = Zi()) {
2396
- let n = await ea(e);
2479
+ async function ya(e, t = fa()) {
2480
+ let n = await ha(e);
2397
2481
  return [
2398
- $i(t),
2482
+ ma(t),
2399
2483
  n.check,
2400
- ta(e, t, n.config?.plugins?.length ?? 0),
2401
- na(t, n.config),
2402
- ra(e, t)
2484
+ ga(e, t, n.config?.plugins?.length ?? 0),
2485
+ _a(t, n.config),
2486
+ va(e, t)
2403
2487
  ];
2404
2488
  }
2405
- var aa = {
2406
- ok: l.green,
2407
- warn: l.yellow,
2408
- fail: l.red
2489
+ var ba = {
2490
+ ok: a.green,
2491
+ warn: a.yellow,
2492
+ fail: a.red
2409
2493
  };
2410
- async function oa(e = process.cwd(), t = {}) {
2411
- let n = await ia(e), r = !n.some((e) => e.status === "fail");
2494
+ async function xa(e = process.cwd(), t = {}) {
2495
+ let n = await ya(e), r = !n.some((e) => e.status === "fail");
2412
2496
  if (t.json) return Y("doctor", r, { checks: n }), +!r;
2413
2497
  console.log();
2414
- for (let e of n) console.log(` ${aa[e.status](e.status.padEnd(4))} ${e.id.padEnd(11)} ${e.message}`), e.status !== "ok" && e.fix && console.log(l.dim(` fix: ${e.fix}`));
2498
+ for (let e of n) console.log(` ${ba[e.status](e.status.padEnd(4))} ${e.id.padEnd(11)} ${e.message}`), e.status !== "ok" && e.fix && console.log(a.dim(` fix: ${e.fix}`));
2415
2499
  return console.log(), +!r;
2416
2500
  }
2417
- // src/core/operations/limits.ts
2418
- var sa = 4e4, X = {
2501
+ // src/core/operations/list.ts
2502
+ var X = {
2419
2503
  readOnlyHint: !0,
2420
2504
  destructiveHint: !1,
2421
2505
  idempotentHint: !0,
2422
2506
  openWorldHint: !1
2423
- }, ca = {
2507
+ }, Sa = {
2424
2508
  type: "string",
2425
2509
  description: "The brand folder. Default: the current folder"
2426
- }, Z = (e, t) => ({
2510
+ }, Ca = (e) => ({
2511
+ type: "string",
2512
+ maxLength: 200,
2513
+ pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*$",
2514
+ description: `${e} in this context of the resolver's theme modifier, such as dark. An unknown theme is refused with the list of themes. Default: the default tokens`
2515
+ }), wa = "^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$", Z = (e, t) => ({
2427
2516
  type: "object",
2428
2517
  properties: e,
2429
2518
  ...t.length > 0 && { required: t },
2430
2519
  additionalProperties: !1
2431
- }), la = {
2520
+ }), Ta = {
2432
2521
  warnings: {
2433
2522
  type: "array",
2434
2523
  items: { type: "string" },
@@ -2436,7 +2525,31 @@ var sa = 4e4, X = {
2436
2525
  },
2437
2526
  brandHasErrors: {
2438
2527
  type: "boolean",
2439
- description: "True when the brand has errors, so values read from it may be wrong. Run check_brand to see them"
2528
+ description: "True when the brand's own data has error findings, so a value read from it may be wrong. Run check_brand to see them. A blazon.lock that names another blazon build does not set it: that is `pinMismatch`"
2529
+ },
2530
+ pinMismatch: {
2531
+ type: "object",
2532
+ properties: {
2533
+ pinned: {
2534
+ type: "string",
2535
+ description: "The blazon build blazon.lock names, as blazon prints it (12 hex digits)"
2536
+ },
2537
+ running: {
2538
+ type: "string",
2539
+ description: "The blazon build running, as blazon prints it, or \"unknown\" when it cannot say"
2540
+ },
2541
+ message: {
2542
+ type: "string",
2543
+ description: "One line: which build the book is pinned to, which is running, and what to do"
2544
+ }
2545
+ },
2546
+ required: [
2547
+ "pinned",
2548
+ "running",
2549
+ "message"
2550
+ ],
2551
+ additionalProperties: {},
2552
+ description: "Present only when blazon.lock names a different blazon build than the one running. The build and the book disagree; no token or value is wrong because of it, so there is no need to re-check values. Tell the user. `blazon check`, `build` and `tokens` refuse until it is fixed"
2440
2553
  },
2441
2554
  truncated: {
2442
2555
  description: "True when the answer was cut to fit the size limit. `notice` says how to narrow the question",
@@ -2449,7 +2562,7 @@ var sa = 4e4, X = {
2449
2562
  }, Q = (e, t) => ({
2450
2563
  type: "object",
2451
2564
  properties: {
2452
- ...la,
2565
+ ...Ta,
2453
2566
  ...e
2454
2567
  },
2455
2568
  required: [
@@ -2458,11 +2571,11 @@ var sa = 4e4, X = {
2458
2571
  ...t
2459
2572
  ],
2460
2573
  additionalProperties: {}
2461
- }), ua = [
2574
+ }), Ea = [
2462
2575
  {
2463
2576
  name: "check_brand",
2464
2577
  title: "Check the brand",
2465
- description: "Runs blazon check on the brand, without plugins, and returns its findings and counts. Plugins in blazon.json do not run, so the counts can be lower than `blazon check` prints, but only for a plugin with a check role; a build-only plugin adds no finding. `pluginsSkipped` and `warnings` list every configured plugin, since a role is known only by starting the plugin. `passed` is false when the brand has errors, and values read from such a brand can be wrong. Returns at most `limit` findings (default 50, at most 500); `counts` stay whole. Not for reading a value: use get_token.",
2578
+ description: "Runs blazon check on the brand, without plugins, and returns its findings and counts. Plugins in blazon.json do not run, so the counts can be lower than `blazon check` prints, but only for a plugin with a check role; a build-only plugin adds no finding. `pluginsSkipped` and `warnings` list every configured plugin, since a role is known only by starting the plugin. `passed` is false when the brand's own data has errors (`brandHasErrors`), and values read from such a brand can be wrong; a `pin-mismatch` finding is listed and counted but does not make `passed` false, and is also in `pinMismatch`. Returns at most `limit` findings (default 50, at most 500); `counts` stay whole. Not for reading a value: use get_token.",
2466
2579
  annotations: X,
2467
2580
  inputSchema: Z({
2468
2581
  severity: {
@@ -2485,7 +2598,7 @@ var sa = 4e4, X = {
2485
2598
  outputSchema: Q({
2486
2599
  passed: {
2487
2600
  type: "boolean",
2488
- description: "True when the brand has no errors"
2601
+ description: "True when no finding other than the pin family is an error. A pin-mismatch alone leaves it true"
2489
2602
  },
2490
2603
  counts: {
2491
2604
  type: "object",
@@ -2564,7 +2677,7 @@ var sa = 4e4, X = {
2564
2677
  {
2565
2678
  name: "list_tokens",
2566
2679
  title: "List the tokens",
2567
- description: `Lists the design tokens of the brand, or of one group, or of one type, each with its path, type and value, in the order the token files write them. Use it to find a path or to read many values at once. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${sa} characters is cut to whole tokens, and \`tokensTotal\` says how many matched: narrow with \`group\` or \`type\`.`,
2680
+ description: `Lists the design tokens of the brand, or of one group, type or tier, each with its path, type, tier and value, in the order the token files write them. Use it to find a path or to read many values at once. \`tier\` (primitive, semantic or component) keeps to one layer of the brand. \`theme\` gives the values as that theme resolves them, and \`defaultValue\` on a token the theme changes; \`themes\` names the themes the brand has. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${Ki} characters is cut to whole tokens, and \`tokensTotal\` says how many matched: narrow with \`group\`, \`type\` or \`tier\`.`,
2568
2681
  annotations: X,
2569
2682
  inputSchema: Z({
2570
2683
  group: {
@@ -2579,6 +2692,13 @@ var sa = 4e4, X = {
2579
2692
  maxLength: 40,
2580
2693
  pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*$"
2581
2694
  },
2695
+ tier: {
2696
+ description: "A tier: primitive, semantic or component. Leave out for every tier. An unknown tier is refused with the list of tiers",
2697
+ type: "string",
2698
+ maxLength: 40,
2699
+ pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*$"
2700
+ },
2701
+ theme: Ca("List the values"),
2582
2702
  dir: {
2583
2703
  type: "string",
2584
2704
  description: "The brand folder. Default: the current folder"
@@ -2593,6 +2713,19 @@ var sa = 4e4, X = {
2593
2713
  description: "The type asked for. Absent when every type was listed",
2594
2714
  type: "string"
2595
2715
  },
2716
+ tier: {
2717
+ description: "The tier asked for. Absent when every tier was listed",
2718
+ type: "string"
2719
+ },
2720
+ theme: {
2721
+ description: "The theme the values are resolved in. Absent when the default tokens were listed",
2722
+ type: "string"
2723
+ },
2724
+ themes: {
2725
+ description: "The names of the themes the brand has, to pass as `theme`. Absent when the brand has no resolver theme modifier",
2726
+ type: "array",
2727
+ items: { type: "string" }
2728
+ },
2596
2729
  tokens: {
2597
2730
  type: "array",
2598
2731
  items: {
@@ -2610,7 +2743,12 @@ var sa = 4e4, X = {
2610
2743
  aliasOf: {
2611
2744
  description: "The token this one is an alias of, when it is one",
2612
2745
  type: "string"
2613
- }
2746
+ },
2747
+ tier: {
2748
+ description: "primitive, semantic or component, when the brand writes one",
2749
+ type: "string"
2750
+ },
2751
+ defaultValue: { description: "With `theme`: the value in the default tokens, present only when the theme changes it" }
2614
2752
  },
2615
2753
  required: ["path", "value"],
2616
2754
  additionalProperties: {}
@@ -2629,20 +2767,33 @@ var sa = 4e4, X = {
2629
2767
  cliOnly: ["dir"],
2630
2768
  folder: "group",
2631
2769
  summary: "List the tokens: path, type and value, and the token each aliases. With a group path, only the tokens in that group",
2632
- options: [{
2633
- property: "json",
2634
- description: "Print the list as JSON on standard output"
2635
- }, {
2636
- property: "type",
2637
- value: "type",
2638
- description: "List only the tokens of one $type (color, dimension, fontFamily, ...)"
2639
- }]
2770
+ options: [
2771
+ {
2772
+ property: "json",
2773
+ description: "Print the list as JSON on standard output"
2774
+ },
2775
+ {
2776
+ property: "type",
2777
+ value: "type",
2778
+ description: "List only the tokens of one $type (color, dimension, fontFamily, ...)"
2779
+ },
2780
+ {
2781
+ property: "tier",
2782
+ value: "tier",
2783
+ description: "List only the tokens of one tier: primitive, semantic or component"
2784
+ },
2785
+ {
2786
+ property: "theme",
2787
+ value: "name",
2788
+ description: "list the values as this context of the resolver's theme modifier resolves them (such as dark), and the default value of each token it changes; exits 2 for an unknown theme"
2789
+ }
2790
+ ]
2640
2791
  }
2641
2792
  },
2642
2793
  {
2643
2794
  name: "get_token",
2644
2795
  title: "Read a token",
2645
- description: "Looks up one design token of the brand: its value, type, the CSS variable names it gets, and the rules that apply to it. Use it for the value of a path you know; a group path is refused. For a path you do not know use list_tokens.",
2796
+ description: "Looks up one design token of the brand: its value, type, the CSS variable names it gets, and the rules that apply to it. Use it for the value of a path you know; a group path is refused. With `theme` the value is the one that theme resolves, and `defaultValue` is the default one when it differs. For a path you do not know use list_tokens.",
2646
2797
  annotations: X,
2647
2798
  inputSchema: Z({
2648
2799
  path: {
@@ -2651,6 +2802,7 @@ var sa = 4e4, X = {
2651
2802
  pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$",
2652
2803
  description: "The token path, for example color.brand.primary. A path from list_tokens works"
2653
2804
  },
2805
+ theme: Ca("Read the value"),
2654
2806
  dir: {
2655
2807
  type: "string",
2656
2808
  description: "The brand folder. Default: the current folder"
@@ -2668,7 +2820,16 @@ var sa = 4e4, X = {
2668
2820
  description: "The token type, such as color",
2669
2821
  type: "string"
2670
2822
  },
2671
- value: { description: "The value as CSS needs it, with aliases resolved" }
2823
+ value: { description: "The value as CSS needs it, with aliases resolved; with `theme`, as that theme resolves it" },
2824
+ defaultValue: { description: "With `theme`: the value in the default tokens, present only when the theme changes it" },
2825
+ theme: {
2826
+ description: "The theme the value is resolved in. Absent for the default tokens",
2827
+ type: "string"
2828
+ },
2829
+ tier: {
2830
+ description: "primitive, semantic or component, when the brand writes one",
2831
+ type: "string"
2832
+ }
2672
2833
  },
2673
2834
  required: ["path", "value"],
2674
2835
  additionalProperties: {}
@@ -2680,6 +2841,10 @@ var sa = 4e4, X = {
2680
2841
  cliOnly: ["dir"],
2681
2842
  summary: "Read one token: its value, type, CSS variable name in theme.css, its usage, pairs and logo rules, and the file it is in. To find a path, use blazon list",
2682
2843
  options: [{
2844
+ property: "theme",
2845
+ value: "name",
2846
+ description: "read the value as this context of the resolver's theme modifier resolves it (such as dark), and the default value when it differs; exits 2 for an unknown theme"
2847
+ }, {
2683
2848
  property: "json",
2684
2849
  description: "Print the token as JSON on standard output"
2685
2850
  }]
@@ -2688,7 +2853,7 @@ var sa = 4e4, X = {
2688
2853
  {
2689
2854
  name: "get_rules",
2690
2855
  title: "Read the brand rules",
2691
- description: `Lists the brand rules (allowed uses, approved color pairs, logo restrictions) of a token or a group of tokens, or of the whole brand when no path is given. The whole brand can be larger than the size limit (${sa} characters): give a path, or read the resource blazon://rules, which is not cut.`,
2856
+ description: `Lists the brand rules (allowed uses, approved color pairs, logo restrictions) of a token or a group of tokens, or of the whole brand when no path is given. The whole brand can be larger than the size limit (${Ki} characters): give a path, or read the resource blazon://rules, which is not cut.`,
2692
2857
  annotations: X,
2693
2858
  inputSchema: Z({
2694
2859
  path: {
@@ -2738,20 +2903,50 @@ var sa = 4e4, X = {
2738
2903
  {
2739
2904
  name: "can_use",
2740
2905
  title: "Can this color be used here",
2741
- description: "Answers whether one color token may be text on another color token, by the brand rules. Set `role` to ui for a focus ring, border or icon stroke: it is judged against the 3:1 non-text contrast and the pairs rules do not apply. A denied answer is a normal result (`allowed` is false, `reason` names the rule), not an error. For a color you have not picked, find one with list_tokens and type color.",
2906
+ description: "Answers whether one color token may be text on another color token, by the brand rules. Give `fg` and `bg` for one pair, or `pairs` (at most 50) for several in one call: the answer then has one result per pair, in order, and `allowed` is true only when every pair is. Exactly one of the two forms. Set `role` to ui for a focus ring, border or icon stroke: it is judged against the 3:1 non-text contrast and the pairs rules do not apply. `verbose` false leaves out the `checks` of an allowed answer; a denial keeps them. A denied answer is a normal result (`allowed` is false, `reason` names the rule), not an error. Pairs come only from the `pairs` rules of token groups; component tokens are not read for them. For a color you have not picked, find one with list_tokens and type color.",
2742
2907
  annotations: X,
2743
2908
  inputSchema: Z({
2744
2909
  fg: {
2745
2910
  type: "string",
2746
2911
  maxLength: 200,
2747
2912
  pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$",
2748
- description: "The text color token path, for example text.primary"
2913
+ description: "The text color token path, for example text.primary. Give it with bg, or give pairs instead"
2749
2914
  },
2750
2915
  bg: {
2751
2916
  type: "string",
2752
2917
  maxLength: 200,
2753
2918
  pattern: "^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$",
2754
- description: "The background color token path, for example surface.background"
2919
+ description: "The background color token path, for example surface.background. Give it with fg, or give pairs instead"
2920
+ },
2921
+ pairs: {
2922
+ type: "array",
2923
+ minItems: 1,
2924
+ maxItems: 50,
2925
+ description: "Several pairs to judge in one call, each a text color token fg and a background color token bg, in place of fg and bg. At most 50",
2926
+ items: {
2927
+ type: "object",
2928
+ properties: {
2929
+ fg: {
2930
+ type: "string",
2931
+ maxLength: 200,
2932
+ pattern: wa,
2933
+ description: "The text color token path"
2934
+ },
2935
+ bg: {
2936
+ type: "string",
2937
+ maxLength: 200,
2938
+ pattern: wa,
2939
+ description: "The background color token path"
2940
+ }
2941
+ },
2942
+ required: ["fg", "bg"],
2943
+ additionalProperties: !1
2944
+ }
2945
+ },
2946
+ verbose: {
2947
+ type: "boolean",
2948
+ default: !0,
2949
+ description: "False leaves out the `checks` of an answer that is allowed, which shortens the answer; a denial keeps its checks, since they are the reason. Default: true"
2755
2950
  },
2756
2951
  role: {
2757
2952
  type: "string",
@@ -2769,11 +2964,16 @@ var sa = 4e4, X = {
2769
2964
  type: "string",
2770
2965
  description: "The brand folder. Default: the current folder"
2771
2966
  }
2772
- }, ["fg", "bg"]),
2967
+ }, []),
2773
2968
  outputSchema: Q({
2774
2969
  allowed: {
2775
2970
  type: "boolean",
2776
- description: "True when the brand allows this text color on this background"
2971
+ description: "True when the brand allows this text color on this background; with `pairs`, true when it allows every pair"
2972
+ },
2973
+ results: {
2974
+ description: "With `pairs`: one answer for each pair, in order, each with the fields of a single answer: fg, bg, allowed, reason, role, contrast and, unless `verbose` is false and the pair is allowed, checks",
2975
+ type: "array",
2976
+ items: { type: "object" }
2777
2977
  },
2778
2978
  reason: {
2779
2979
  type: "string",
@@ -2800,7 +3000,7 @@ var sa = 4e4, X = {
2800
3000
  description: "The contrast ratio of the pair, the strictest WCAG level it meets, and for role ui the threshold it had to reach",
2801
3001
  type: "object"
2802
3002
  }
2803
- }, ["allowed", "reason"]),
3003
+ }, ["allowed"]),
2804
3004
  cli: {
2805
3005
  rank: 4,
2806
3006
  command: ["can"],
@@ -2810,8 +3010,21 @@ var sa = 4e4, X = {
2810
3010
  "dir"
2811
3011
  ],
2812
3012
  cliOnly: ["dir"],
2813
- summary: "Ask whether the foreground token may be text (or, with --role ui, a border or focus ring) on the background token, by the brand rules; exits 0 allowed, 1 denied, 2 unknown token",
3013
+ folder: "fg",
3014
+ summary: "Ask whether the foreground token may be text (or, with --role ui, a border or focus ring) on the background token, by the brand rules; exits 0 allowed, 1 denied, 2 unknown token. Several pairs: --pair fg:bg, repeated",
2814
3015
  options: [
3016
+ {
3017
+ property: "pairs",
3018
+ flag: "pair",
3019
+ value: "fg:bg",
3020
+ items: ["fg", "bg"],
3021
+ description: "judge this pair, in place of the fg and bg arguments; repeat the flag for up to 50 pairs, one result each, in order; exits 0 when every pair is allowed, else 1"
3022
+ },
3023
+ {
3024
+ property: "verbose",
3025
+ flag: "no-verbose",
3026
+ description: "leave out the checks of an allowed answer, which are all it adds to the reason; a denial keeps them"
3027
+ },
2815
3028
  {
2816
3029
  property: "role",
2817
3030
  value: "text|ui",
@@ -2819,7 +3032,7 @@ var sa = 4e4, X = {
2819
3032
  },
2820
3033
  {
2821
3034
  property: "theme",
2822
- value: "<name>",
3035
+ value: "name",
2823
3036
  description: "judge the pair in this context of the resolver's theme modifier (such as dark); exits 2 for an unknown theme"
2824
3037
  },
2825
3038
  {
@@ -2936,7 +3149,7 @@ var sa = 4e4, X = {
2936
3149
  type: "string",
2937
3150
  description: "Only this part of the document, by its dotted path, such as theme.roles"
2938
3151
  },
2939
- dir: ca
3152
+ dir: Sa
2940
3153
  }, []),
2941
3154
  cli: {
2942
3155
  rank: 7,
@@ -2952,10 +3165,47 @@ var sa = 4e4, X = {
2952
3165
  },
2953
3166
  mcp: !1
2954
3167
  }
2955
- ], da = (e) => e.filter((e) => e.mcp !== !1), fa = (e) => e.filter((e) => e.cli !== !1).sort((e, t) => e.cli.rank - t.cli.rank);
3168
+ ], Da = (e) => e.filter((e) => e.mcp !== !1), Oa = (e) => e.filter((e) => e.cli !== !1).sort((e, t) => e.cli.rank - t.cli.rank), ka = (e) => {
3169
+ try {
3170
+ return k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1;
3171
+ } catch {
3172
+ return !1;
3173
+ }
3174
+ };
3175
+ function Aa(e) {
3176
+ if (!ka(e)) return !1;
3177
+ let t = O.join(e, "blazon.json");
3178
+ return k.statSync(t, { throwIfNoEntry: !1 })?.isFile() ? !0 : ka(O.join(e, "tokens"));
3179
+ }
3180
+ var ja = /* @__PURE__ */ new Set([
3181
+ "no-folder",
3182
+ "no-tokens-folder",
3183
+ "unknown-token"
3184
+ ]), Ma = (e) => e.map((e) => /^<.*>$/.test(e) ? e : bt(e)).join(" ");
3185
+ function Na(e, t, n, r, i) {
3186
+ if (!(i instanceof j) || !ja.has(i.code)) return;
3187
+ let a = n.map((e) => typeof e == "string" ? e : void 0), o = t.findIndex((e, t) => {
3188
+ let n = a[t];
3189
+ return e === "dir" || n === void 0 || !Aa(n) ? !1 : i.code !== "unknown-token" || i.message.includes(`"${n}"`);
3190
+ });
3191
+ if (o === -1) return;
3192
+ let s = a[o], c = t[o], l = a.filter((e, t) => e !== void 0 && t !== o), u = l.length === 0 ? [`<${c}>`] : [], d = Ma([
3193
+ "blazon",
3194
+ ...e,
3195
+ ...l.length > 0 ? l : u,
3196
+ s
3197
+ ]), f = Ma([
3198
+ "blazon",
3199
+ ...e,
3200
+ ...l.length > 0 || r.has(c) ? [...l, ...u] : [],
3201
+ "--cwd",
3202
+ s
3203
+ ]);
3204
+ return `"${s}" was read as ${c === "path" ? "the path" : `the ${c} (a token path)`}, not a folder; the folder goes last: ${d}, or ${f}`;
3205
+ }
2956
3206
  // src/cli/handlers/rules.ts
2957
- function pa(e) {
2958
- let t = (e) => l.dim(`(on ${e})`);
3207
+ function Pa(e) {
3208
+ let t = (e) => a.dim(`(on ${e})`);
2959
3209
  return [
2960
3210
  ...e.role ? [`role ${e.role.value} ${t(e.role.from)}`] : [],
2961
3211
  ...e.usage ? [`usage ${[e.usage.deny && `deny ${e.usage.deny.join(", ")}`, e.usage.allow && `allow ${e.usage.allow.join(", ")}`].filter(Boolean).join("; ")} ${t(e.usage.from)}`] : [],
@@ -2964,7 +3214,7 @@ function pa(e) {
2964
3214
  ...e.review ? [`review ${e.review.status}${e.review.by ? ` by ${e.review.by}` : ""}${e.review.at ? ` on ${e.review.at}` : ""} ${t(e.review.from)}`] : []
2965
3215
  ];
2966
3216
  }
2967
- function ma(e) {
3217
+ function Fa(e) {
2968
3218
  return [
2969
3219
  ...e.role ? [`role ${e.role}`] : [],
2970
3220
  ...e.usage ? [`usage ${[e.usage.deny && `deny ${e.usage.deny.join(", ")}`, e.usage.allow && `allow ${e.usage.allow.join(", ")}`].filter(Boolean).join("; ")}`] : [],
@@ -2972,52 +3222,54 @@ function ma(e) {
2972
3222
  ...e.logo ? [`logo deny ${e.logo.deny.join(", ")}${e.logo.reason ? `: ${e.logo.reason}` : ""}`] : []
2973
3223
  ];
2974
3224
  }
2975
- var ha = async ({ path: e }, { dir: t }) => {
2976
- let { data: n } = await J(t), r = hi(e ?? ""), i = r !== "" && n.tokens.byPath.has(r), a = Ki(() => i ? {
3225
+ var Ia = async ({ path: e }, { dir: t }) => {
3226
+ let { data: n } = await J(t), r = Ti(e ?? ""), i = r !== "" && n.tokens.byPath.has(r), o = sa(() => i ? {
2977
3227
  path: r,
2978
3228
  kind: "token",
2979
- rules: wi(n, gi(n, r))
3229
+ rules: Li(n, Ei(n, r))
2980
3230
  } : {
2981
3231
  path: r,
2982
3232
  kind: r === "" ? "brand" : "group",
2983
- entries: Ei(n, r)
3233
+ entries: zi(n, r)
2984
3234
  });
2985
3235
  return {
2986
3236
  command: "rules",
2987
3237
  passed: !0,
2988
3238
  status: 0,
2989
- body: a,
3239
+ body: o,
2990
3240
  text: () => {
2991
- if (console.log(), a.kind === "token") {
2992
- let e = pa(a.rules);
2993
- console.log(` ${l.bold(a.path)}`), e.length === 0 && console.log(l.dim(" no rules apply to this token"));
3241
+ if (console.log(), o.kind === "token") {
3242
+ let e = Pa(o.rules);
3243
+ console.log(` ${a.bold(o.path)}`), e.length === 0 && console.log(a.dim(" no rules apply to this token"));
2994
3244
  for (let t of e) console.log(` ${t}`);
2995
3245
  } else {
2996
- a.entries.length === 0 && console.log(l.dim(` No rules are written ${r === "" ? "in this brand" : `at or under ${r}`}.`));
2997
- for (let e of a.entries) {
2998
- console.log(` ${l.bold(e.at)} ${l.dim(e.kind === "group" ? "group" : "token")}${e.inherited ? l.dim(", passes its rules down") : ""}`);
2999
- for (let t of ma(e)) console.log(` ${t}`);
3246
+ o.entries.length === 0 && console.log(a.dim(` No rules are written ${r === "" ? "in this brand" : `at or under ${r}`}.`));
3247
+ for (let e of o.entries) {
3248
+ console.log(` ${a.bold(e.at)} ${a.dim(e.kind === "group" ? "group" : "token")}${e.inherited ? a.dim(", passes its rules down") : ""}`);
3249
+ for (let t of Fa(e)) console.log(` ${t}`);
3000
3250
  }
3001
3251
  }
3002
3252
  console.log();
3003
3253
  }
3004
3254
  };
3005
- }, ga = async ({ path: e }, { dir: t }) => {
3006
- let { data: n } = await J(t);
3007
- if (Ai(n, String(e))) throw new M(`"${String(e)}" is a group of tokens, not one token; \`blazon list ${String(e)}\` lists its tokens.`, void 0, "not-a-token");
3008
- let r = Ki(() => Oi(n, String(e)));
3255
+ }, La = async ({ path: e, theme: t }, { dir: n }) => {
3256
+ let { data: r } = await J(n);
3257
+ if (Wi(r, String(e))) throw new M(`"${String(e)}" is a group of tokens, not one token; \`blazon list ${String(e)}\` lists its tokens.`, void 0, "not-a-token");
3258
+ let i = sa(() => Vi(r, String(e), t));
3009
3259
  return {
3010
3260
  command: "get",
3011
3261
  passed: !0,
3012
3262
  status: 0,
3013
- body: { token: r },
3014
- text: () => _a(r)
3263
+ body: { token: i },
3264
+ text: () => Ra(i)
3015
3265
  };
3016
3266
  };
3017
- function _a(e) {
3267
+ function Ra(e) {
3018
3268
  let { names: t } = e;
3019
- console.log(`\n ${l.bold(e.path)}${e.deprecated ? l.yellow(" deprecated") : ""}`), qi([
3269
+ console.log(`\n ${a.bold(e.path)}${e.deprecated ? a.yellow(" deprecated") : ""}`), ca([
3020
3270
  ["value", String(e.value)],
3271
+ ["default", e.defaultValue === void 0 ? void 0 : String(e.defaultValue)],
3272
+ ["theme", e.theme],
3021
3273
  ["type", e.type],
3022
3274
  ["alias of", e.aliasOf && `{${e.aliasOf}}`],
3023
3275
  ["tier", e.tier],
@@ -3026,65 +3278,99 @@ function _a(e) {
3026
3278
  ["typography.css", t.typographyClass && `.${t.typographyClass}`],
3027
3279
  ["written in", e.sourceFile]
3028
3280
  ]);
3029
- for (let t of e.contexts ?? []) console.log(` ${l.dim(`${t.modifier}=${t.context}`.padEnd(12))} ${String(t.value)} ${l.dim(t.selector)}`);
3030
- let n = pa(e.rules);
3031
- console.log(`\n ${l.bold("Rules")}`), n.length === 0 && console.log(l.dim(" none written for this token"));
3281
+ for (let t of e.contexts ?? []) console.log(` ${a.dim(`${t.modifier}=${t.context}`.padEnd(12))} ${String(t.value)} ${a.dim(t.selector)}`);
3282
+ let n = Pa(e.rules);
3283
+ console.log(`\n ${a.bold("Rules")}`), n.length === 0 && console.log(a.dim(" none written for this token"));
3032
3284
  for (let e of n) console.log(` ${e}`);
3033
3285
  console.log();
3034
3286
  }
3035
3287
  // src/cli/handlers/list.ts
3036
- var va = async ({ group: e, type: t }, { dir: n }) => {
3037
- let { data: r } = await J(n), i = Ki(() => ji(r, {
3288
+ var za = async ({ group: e, type: t, tier: n, theme: r }, { dir: i }) => {
3289
+ let { data: a } = await J(i), o = sa(() => Gi(a, {
3038
3290
  group: e,
3039
- type: t
3291
+ type: t,
3292
+ tier: n,
3293
+ theme: r
3040
3294
  }));
3041
3295
  return {
3042
3296
  command: "list",
3043
3297
  passed: !0,
3044
3298
  status: 0,
3045
3299
  body: {
3046
- ...i.group !== void 0 && { group: i.group },
3047
- ...i.type && { type: i.type },
3048
- tokens: i.tokens
3300
+ ...o.group !== void 0 && { group: o.group },
3301
+ ...o.type && { type: o.type },
3302
+ ...o.tier && { tier: o.tier },
3303
+ ...o.theme !== void 0 && { theme: o.theme },
3304
+ ...o.themes && { themes: o.themes },
3305
+ tokens: o.tokens
3049
3306
  },
3050
- text: () => ya(i)
3307
+ text: () => Ba(o)
3051
3308
  };
3052
3309
  };
3053
- function ya(e) {
3054
- if (e.tokens.length === 0) return console.log(l.dim(`\n no tokens${e.type ? ` of type ${e.type}` : ""}${e.group ? ` in ${e.group}` : ""}\n`));
3310
+ function Ba(e) {
3311
+ if (e.tokens.length === 0) return console.log(a.dim(`\n no tokens${e.type ? ` of type ${e.type}` : ""}${e.tier ? ` of tier ${e.tier}` : ""}${e.group ? ` in ${e.group}` : ""}\n`));
3055
3312
  let t = Math.max(...e.tokens.map((e) => e.path.length)), n = Math.max(...e.tokens.map((e) => (e.type ?? "").length)), r;
3056
3313
  for (let i of e.tokens) {
3057
3314
  let e = i.path.split(".")[0];
3058
- e !== r && console.log(`\n ${l.dim(e)}`), r = e;
3059
- let a = i.aliasOf ? ` ${l.dim(`-> ${i.aliasOf}`)}` : "";
3060
- console.log(` ${i.path.padEnd(t)} ${l.dim((i.type ?? "").padEnd(n))} ${String(i.value)}${a}`);
3315
+ e !== r && console.log(`\n ${a.dim(e)}`), r = e;
3316
+ let o = i.aliasOf ? ` ${a.dim(`-> ${i.aliasOf}`)}` : "", s = i.defaultValue === void 0 ? "" : ` ${a.dim(`(default ${String(i.defaultValue)})`)}`;
3317
+ console.log(` ${i.path.padEnd(t)} ${a.dim((i.type ?? "").padEnd(n))} ${String(i.value)}${s}${o}`);
3061
3318
  }
3062
- console.log(`\n ${l.dim(`${e.tokens.length} token${e.tokens.length === 1 ? "" : "s"}; blazon get <path> shows one in full`)}\n`);
3319
+ let i = e.themes ? `; themes: ${e.themes.join(", ")}${e.theme ? ` (showing ${e.theme})` : ""}` : "";
3320
+ console.log(`\n ${a.dim(`${e.tokens.length} token${e.tokens.length === 1 ? "" : "s"}; blazon get <path> shows one in full${i}`)}\n`);
3063
3321
  }
3064
3322
  // src/cli/handlers/can.ts
3065
- var ba = async ({ fg: e, bg: t, role: n, theme: r }, { dir: i }) => {
3066
- let { data: a } = await J(i), o = Ki(() => Hi(a, e, t, n ?? "text", r));
3323
+ function Va(e) {
3324
+ return (e === void 0 ? [] : Array.isArray(e) ? e : [e]).map((e) => {
3325
+ let t = String(e).split(":");
3326
+ if (t.length !== 2 || !t[0] || !t[1]) throw new M(`--pair takes fg:bg, such as text.primary:surface.canvas; got "${String(e)}".`, void 0, "invalid-option-value");
3327
+ return {
3328
+ fg: t[0],
3329
+ bg: t[1]
3330
+ };
3331
+ });
3332
+ }
3333
+ var Ha = async ({ fg: e, bg: t, role: n, theme: r, pairs: i, verbose: a }, { dir: o }) => {
3334
+ let s = Va(i), c = e !== void 0 || t !== void 0;
3335
+ if (s.length > 0 && c) throw new M("give fg and bg, or --pair, not both.", void 0, "conflicting-options");
3336
+ if (s.length === 0 && (e === void 0 || t === void 0)) throw new M("give fg and bg, or one or more --pair fg:bg.", void 0, "missing-argument");
3337
+ if (s.length > 50) throw new M(`give at most 50 pairs in one call; this call has ${s.length}.`, void 0, "invalid-option-value");
3338
+ let l = a === !1, u = (e) => l ? na(e) : e, { data: d } = await J(o), f = n ?? "text";
3339
+ if (s.length > 0) {
3340
+ let e = sa(() => ra(d, s, f, r)).map(u), t = e.every((e) => e.allowed);
3341
+ return {
3342
+ command: "can",
3343
+ passed: t,
3344
+ status: +!t,
3345
+ body: {
3346
+ allowed: t,
3347
+ results: e
3348
+ },
3349
+ text: () => e.forEach((e) => Ua(e))
3350
+ };
3351
+ }
3352
+ let p = u(sa(() => ta(d, e, t, f, r)));
3067
3353
  return {
3068
3354
  command: "can",
3069
- passed: o.allowed,
3070
- status: +!o.allowed,
3071
- body: o,
3072
- text: () => xa(o)
3355
+ passed: p.allowed,
3356
+ status: +!p.allowed,
3357
+ body: p,
3358
+ text: () => Ua(p)
3073
3359
  };
3074
3360
  };
3075
- function xa(e) {
3076
- if (console.log(`\n ${e.allowed ? l.green("allowed") : l.red("denied")} ${e.fg} as ${e.role === "ui" ? "a non-text element (--role ui)" : "text"} on ${e.bg}${e.theme ? ` (theme ${e.theme})` : ""}`), console.log(` ${e.reason}`), e.checks.length > 1) {
3361
+ function Ua(e) {
3362
+ if (console.log(`\n ${e.allowed ? a.green("allowed") : a.red("denied")} ${e.fg} as ${e.role === "ui" ? "a non-text element (--role ui)" : "text"} on ${e.bg}${e.theme ? ` (theme ${e.theme})` : ""}`), console.log(` ${e.reason}`), e.checks && e.checks.length > 1) {
3077
3363
  console.log();
3078
- for (let t of e.checks) console.log(` ${t.rule === "contrast" && e.role === "text" ? l.dim("info") : t.ok ? l.green("ok ") : l.red("no ")} ${t.message}`);
3364
+ for (let t of e.checks) console.log(` ${t.rule === "contrast" && e.role === "text" ? a.dim("info") : t.ok ? a.green("ok ") : a.red("no ")} ${t.message}`);
3079
3365
  }
3080
3366
  console.log();
3081
3367
  }
3082
3368
  // src/cli/handlers/fonts.ts
3083
- var Sa = async (e, { dir: t }) => {
3084
- let { config: n, data: r } = await J(t), i = Ui(r, n, t);
3369
+ var Wa = async (e, { dir: t }) => {
3370
+ let { config: n, data: r } = await J(t), i = ia(r, n, t);
3085
3371
  if (e.css === !0 || typeof e.base == "string") {
3086
3372
  if (e.css !== !0) throw new M("blazon fonts: --base goes with --css.", "Add --css, or leave --base out.", "conflicting-options");
3087
- let t = Wi(i, typeof e.base == "string" ? e.base : void 0);
3373
+ let t = aa(i, typeof e.base == "string" ? e.base : void 0);
3088
3374
  return {
3089
3375
  command: "fonts",
3090
3376
  passed: !0,
@@ -3101,18 +3387,18 @@ var Sa = async (e, { dir: t }) => {
3101
3387
  passed: !0,
3102
3388
  status: 0,
3103
3389
  body: i,
3104
- text: () => Ca(i)
3390
+ text: () => Ga(i)
3105
3391
  };
3106
3392
  };
3107
- function Ca(e) {
3108
- console.log(`\n ${l.bold("Loaded")}`), e.stylesheets.length + e.files.length === 0 && console.log(l.dim(" The config lists no fonts."));
3393
+ function Ga(e) {
3394
+ console.log(`\n ${a.bold("Loaded")}`), e.stylesheets.length + e.files.length === 0 && console.log(a.dim(" The config lists no fonts."));
3109
3395
  for (let t of e.stylesheets) console.log(` stylesheet ${t}`);
3110
3396
  for (let t of e.files) console.log(` file ${t.file} ${t.family}${t.weight === void 0 ? "" : `, weight ${t.weight}`}${t.style ? `, ${t.style}` : ""}`);
3111
- console.log(`\n ${l.bold("Named by the tokens")}`);
3112
- for (let [t, n] of Object.entries(e.roles)) console.log(` ${l.dim(t.padEnd(11))} ${n.token ?? ""} ${n.value ?? ""}`);
3397
+ console.log(`\n ${a.bold("Named by the tokens")}`);
3398
+ for (let [t, n] of Object.entries(e.roles)) console.log(` ${a.dim(t.padEnd(11))} ${n.token ?? ""} ${n.value ?? ""}`);
3113
3399
  for (let t of e.families) {
3114
3400
  let e = t.system ? "system font" : t.loaded === !0 ? "loaded" : t.loaded === null ? "maybe loaded by a stylesheet blazon cannot read" : t.webFont === void 0 ? "not loaded" : "not loaded, as the token says";
3115
- console.log(` ${t.family} ${l.dim(`${e}; ${t.tokens.join(", ")}`)}`), t.stack && t.stack.length > 1 && console.log(l.dim(` stack: ${t.stack.join(", ")}`));
3401
+ console.log(` ${t.family} ${a.dim(`${e}; ${t.tokens.join(", ")}`)}`), t.stack && t.stack.length > 1 && console.log(a.dim(` stack: ${t.stack.join(", ")}`)), t.font?.role && console.log(a.dim(` role: ${t.font.role}${t.font.fallbackFor ? `, stands in for ${t.font.fallbackFor}` : ""}`)), t.font?.reason && console.log(a.dim(` why: ${t.font.reason}`));
3116
3402
  }
3117
3403
  console.log();
3118
3404
  }
@@ -3121,22 +3407,22 @@ var $ = (e) => {
3121
3407
  if (typeof e != "object" || !e) return String(e);
3122
3408
  let t = e;
3123
3409
  return t.units === void 0 ? t.value === void 0 ? [t.width !== void 0 && `width ${$(t.width)}`, t.height !== void 0 && `height ${$(t.height)}`].filter(Boolean).join(", ") : `${t.value}${t.unit}` : `${t.units} unit${t.units === 1 ? "" : "s"}`;
3124
- }, wa = async (e, { dir: t }) => {
3125
- let { config: n, data: r } = await J(t), i = Gi(r, n, t);
3410
+ }, Ka = async (e, { dir: t }) => {
3411
+ let { config: n, data: r } = await J(t), i = oa(r, n, t);
3126
3412
  return {
3127
3413
  command: "logo",
3128
3414
  passed: !0,
3129
3415
  status: 0,
3130
3416
  body: i,
3131
- text: () => Ta(i)
3417
+ text: () => qa(i)
3132
3418
  };
3133
3419
  };
3134
- function Ta(e) {
3135
- console.log(`\n ${l.bold("Variants")}`), e.variants.length === 0 && console.log(l.dim(" No logo is configured."));
3136
- for (let t of e.variants) console.log(` ${t.variant.padEnd(8)} ${t.file}${t.found ? "" : l.red(" (not found)")}${t.ink ? ` ink ${t.ink}` : ""}${t.asset ? l.dim(` ${t.asset}`) : ""}`);
3420
+ function qa(e) {
3421
+ console.log(`\n ${a.bold("Variants")}`), e.variants.length === 0 && console.log(a.dim(" No logo is configured."));
3422
+ for (let t of e.variants) console.log(` ${t.variant.padEnd(8)} ${t.file}${t.found ? "" : a.red(" (not found)")}${t.ink ? ` ink ${t.ink}` : ""}${t.asset ? a.dim(` ${t.asset}`) : ""}`);
3137
3423
  for (let t of e.assets) {
3138
3424
  let e = t.rules;
3139
- console.log(`\n ${l.bold(t.id)} ${t.file}${t.variants.length ? l.dim(` used as ${t.variants.join(", ")}`) : ""}`);
3425
+ console.log(`\n ${a.bold(t.id)} ${t.files.join(", ")}${t.variants.length ? a.dim(` used as ${t.variants.join(", ")}`) : ""}`);
3140
3426
  let n = [
3141
3427
  ["lockup", e.lockup],
3142
3428
  ["ink", e.ink],
@@ -3150,18 +3436,18 @@ function Ta(e) {
3150
3436
  ["partnership", e.partnership && `gap ${$(e.partnership.gap)}${e.partnership.dividerHeight ? `, divider ${$(e.partnership.dividerHeight)}` : ""}`],
3151
3437
  ["initiative", e.initiative && `${e.initiative.name}, mark ${e.initiative.mark}, gap ${$(e.initiative.gap)}, ${e.initiative.position ?? "beside"}`]
3152
3438
  ];
3153
- for (let [e, t] of n) t !== void 0 && console.log(` ${l.dim(e.padEnd(12))} ${t}`);
3154
- for (let t of e.do ?? []) console.log(` ${l.dim("do")} ${t}`);
3155
- for (let t of e.dont ?? []) console.log(` ${l.dim("do not")} ${t}`);
3439
+ for (let [e, t] of n) t !== void 0 && console.log(` ${a.dim(e.padEnd(12))} ${t}`);
3440
+ for (let t of e.do ?? []) console.log(` ${a.dim("do")} ${t}`);
3441
+ for (let t of e.dont ?? []) console.log(` ${a.dim("do not")} ${t}`);
3156
3442
  }
3157
3443
  if (e.forbidden.length > 0) {
3158
- console.log(`\n ${l.bold("Forbidden on")}`);
3159
- for (let t of e.forbidden) console.log(` ${t.at} ${t.deny.join(", ")}${t.reason ? ` ${l.dim(t.reason)}` : ""}`);
3444
+ console.log(`\n ${a.bold("Forbidden on")}`);
3445
+ for (let t of e.forbidden) console.log(` ${t.at} ${t.deny.join(", ")}${t.reason ? ` ${a.dim(t.reason)}` : ""}`);
3160
3446
  }
3161
3447
  console.log();
3162
3448
  }
3163
3449
  // src/cli/handlers/brand.ts
3164
- function Ea(e, t) {
3450
+ function Ja(e, t) {
3165
3451
  let n = e;
3166
3452
  for (let e of t.split(".")) {
3167
3453
  if (typeof n != "object" || !n || !Object.prototype.hasOwnProperty.call(n, e)) return;
@@ -3170,15 +3456,15 @@ function Ea(e, t) {
3170
3456
  return n;
3171
3457
  }
3172
3458
  // src/cli/handlers/index.ts
3173
- var Da = {
3174
- get_token: ga,
3175
- list_tokens: va,
3176
- get_rules: ha,
3177
- can_use: ba,
3178
- get_fonts: Sa,
3179
- get_logo: wa,
3459
+ var Ya = {
3460
+ get_token: La,
3461
+ list_tokens: za,
3462
+ get_rules: Ia,
3463
+ can_use: Ha,
3464
+ get_fonts: Wa,
3465
+ get_logo: Ka,
3180
3466
  get_brand: async ({ key: e }, { dir: t }) => {
3181
- let { config: n, data: r } = await J(t), i = He(r, n, t), a = e === void 0 ? i : Ea(i, e);
3467
+ let { config: n, data: r } = await J(t), i = xe(r, n, t), a = e === void 0 ? i : Ja(i, e);
3182
3468
  if (a === void 0) throw new M(`brand.json has no "${String(e)}". Run blazon brand without --key to see the keys.`, void 0, "unknown-key");
3183
3469
  return {
3184
3470
  command: "brand",
@@ -3188,46 +3474,49 @@ var Da = {
3188
3474
  text: () => void process.stdout.write(`${JSON.stringify(a, null, 2)}\n`)
3189
3475
  };
3190
3476
  }
3191
- }, Oa = (e) => e.cli, ka = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), Aa = fa(ua).filter((e) => Oa(e).options.some((e) => e.property === "json")).map((e) => Oa(e).command[0]);
3192
- function ja(e) {
3193
- let t = Oa(e), n = new Set(e.inputSchema.required ?? []);
3477
+ }, Xa = (e) => e.cli, Za = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), Qa = Oa(Ea).filter((e) => Xa(e).options.some((e) => e.property === "json")).map((e) => Xa(e).command[0]);
3478
+ function $a(e) {
3479
+ let t = Xa(e), n = new Set(e.inputSchema.required ?? []);
3194
3480
  return [...t.command, ...t.positional.map((e) => n.has(e) ? `<${e}>` : `[${e}]`)].join(" ");
3195
3481
  }
3196
- function Ma(e, t) {
3197
- return t.property === "json" ? "--json" : e.inputSchema.properties[t.property]?.type === "boolean" ? `--${ka(t.property)}` : `--${ka(t.property)} <${t.value ?? ka(t.property)}>`;
3482
+ function eo(e, t) {
3483
+ if (t.property === "json") return "--json";
3484
+ let n = e.inputSchema.properties[t.property], r = t.flag ?? Za(t.property);
3485
+ return n?.type === "boolean" ? `--${r}` : `--${r} <${t.value ?? r}>`;
3198
3486
  }
3199
- var Na = (e) => typeof e == "string" && /^\.|[\\/]/.test(e) && !!k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory();
3200
- function Pa(e, t) {
3201
- for (let n of fa(ua)) {
3202
- let r = Oa(n), i = Da[n.name];
3487
+ var to = (e) => (e.flag ?? Za(e.property)).replace(/^no-/, "").replace(/-(.)/g, (e, t) => t.toUpperCase()), no = (e) => typeof e == "string" && /^\.|[\\/]/.test(e) && !!k.statSync(e, { throwIfNoEntry: !1 })?.isDirectory();
3488
+ function ro(e, t) {
3489
+ for (let n of Oa(Ea)) {
3490
+ let r = Xa(n), i = Ya[n.name];
3203
3491
  if (!i) throw Error(`operation ${n.name} has a command and no handler`);
3204
- let a = e.command(ja(n), r.summary);
3205
- for (let e of r.options) a.option(Ma(n, e), e.description);
3492
+ let a = e.command($a(n), r.summary);
3493
+ for (let e of r.options) a.option(eo(n, e), e.description);
3206
3494
  a.action(async (...e) => {
3207
- let n = e.pop() ?? {};
3495
+ let a = e.pop() ?? {};
3208
3496
  try {
3209
3497
  let t = {};
3210
3498
  r.positional.forEach((n, r) => t[n] = e[r]);
3211
- for (let e of r.options) e.property !== "json" && (t[e.property] = n[e.property]);
3212
- let a = t.dir;
3213
- r.folder !== void 0 && a === void 0 && Na(t[r.folder]) && (a = t[r.folder], t[r.folder] = void 0), delete t.dir;
3214
- let o = await i(t, { dir: a ? String(a) : process.cwd() });
3215
- n.json ? Y(o.command, o.passed, o.body) : o.text(), process.exitCode = o.status;
3216
- } catch (e) {
3217
- P(r.command.join(" "), e, t);
3499
+ for (let e of r.options) e.property !== "json" && (t[e.property] = a[to(e)]);
3500
+ let n = t.dir;
3501
+ r.folder !== void 0 && n === void 0 && no(t[r.folder]) && (n = t[r.folder], t[r.folder] = void 0), delete t.dir;
3502
+ let o = await i(t, { dir: n ? String(n) : process.cwd() });
3503
+ a.json ? Y(o.command, o.passed, o.body) : o.text(), process.exitCode = o.status;
3504
+ } catch (i) {
3505
+ let a = Na(r.command, r.positional, e, new Set(n.inputSchema.required ?? []), i);
3506
+ a && i instanceof j && (i.hint = a), P(r.command.join(" "), i, t);
3218
3507
  }
3219
3508
  });
3220
3509
  }
3221
3510
  }
3222
3511
  // src/cli/commands/mcp-check.ts
3223
- var Fa = 3e4, Ia = "This check starts blazon-mcp on the brand folder. The server runs blazon with no plugin and a limited environment, and reads the brand files as data. What the brand says reaches your agent as tool results, so check only a brand folder you trust.", La = "npm ci && npm run build -w mcp", Ra = (e) => _e(e) ? `cd ${e} && ${La}` : Oe, za = () => da(ua).map((e) => e.name);
3224
- function Ba(e) {
3512
+ var io = 3e4, ao = "This check starts blazon-mcp on the brand folder. The server runs blazon with no plugin and a limited environment, and reads the brand files as data. What the brand says reaches your agent as tool results, so check only a brand folder you trust.", oo = "npm ci && npm run build -w mcp", so = (e) => Se(e) ? `cd ${e} && ${oo}` : Me, co = () => Da(Ea).map((e) => e.name);
3513
+ function lo(e) {
3225
3514
  let t = O.join(e, "mcp/dist/index.js"), n = k.existsSync(t);
3226
- return !n && !_e(e) ? {
3515
+ return !n && !Se(e) ? {
3227
3516
  name: "built",
3228
3517
  passed: !1,
3229
- detail: Ie,
3230
- fix: Oe,
3518
+ detail: Ve,
3519
+ fix: Me,
3231
3520
  entry: t
3232
3521
  } : n ? {
3233
3522
  name: "built",
@@ -3238,26 +3527,26 @@ function Ba(e) {
3238
3527
  name: "built",
3239
3528
  passed: !1,
3240
3529
  detail: `${t} does not exist: blazon-mcp is not built`,
3241
- fix: Ra(e),
3530
+ fix: so(e),
3242
3531
  entry: t
3243
3532
  };
3244
3533
  }
3245
- var Va = (e) => {
3534
+ var uo = (e) => {
3246
3535
  try {
3247
3536
  return k.statSync(e).isFile() ? (k.accessSync(e, k.constants.X_OK), !0) : !1;
3248
3537
  } catch {
3249
3538
  return !1;
3250
3539
  }
3251
3540
  };
3252
- function Ha(e, t) {
3541
+ function fo(e, t) {
3253
3542
  let n = (t.PATH ?? "").split(O.delimiter).filter(Boolean), r = process.platform === "win32" ? ["", ...(t.PATHEXT ?? ".EXE;.CMD").split(";")].map((t) => e + t) : [e];
3254
- for (let e of n) for (let t of r) if (Va(O.join(e, t))) return O.join(e, t);
3543
+ for (let e of n) for (let t of r) if (uo(O.join(e, t))) return O.join(e, t);
3255
3544
  }
3256
- function Ua(e, t, n) {
3545
+ function po(e, t, n) {
3257
3546
  let r = O.join(n, "bin/blazon.js"), i = k.existsSync(r) ? k.existsSync(O.join(n, "dist/cli/index.js")) ? `export BLAZON_BIN=${r}` : `cd ${n} && npm run build && export BLAZON_BIN=${r}` : "put the blazon program on PATH, or export BLAZON_BIN=<path to the blazon executable>", a = e.BLAZON_BIN;
3258
3547
  if (a) {
3259
- let n = a.includes("/") || a.includes(O.sep) ? O.resolve(t, a) : Ha(a, e);
3260
- return n && Va(n) ? {
3548
+ let n = a.includes("/") || a.includes(O.sep) ? O.resolve(t, a) : fo(a, e);
3549
+ return n && uo(n) ? {
3261
3550
  name: "blazon",
3262
3551
  passed: !0,
3263
3552
  detail: `BLAZON_BIN names ${n}`,
@@ -3271,14 +3560,14 @@ function Ua(e, t, n) {
3271
3560
  source: "BLAZON_BIN"
3272
3561
  };
3273
3562
  }
3274
- if (Va(r)) return {
3563
+ if (uo(r)) return {
3275
3564
  name: "blazon",
3276
3565
  passed: !0,
3277
3566
  detail: `the server runs this package's own ${r}`,
3278
3567
  source: "package",
3279
3568
  path: r
3280
3569
  };
3281
- let o = Ha("blazon", e);
3570
+ let o = fo("blazon", e);
3282
3571
  return o ? {
3283
3572
  name: "blazon",
3284
3573
  passed: !0,
@@ -3293,12 +3582,12 @@ function Ua(e, t, n) {
3293
3582
  source: "none"
3294
3583
  };
3295
3584
  }
3296
- var Wa = (e, t = 200) => {
3585
+ var mo = (e, t = 200) => {
3297
3586
  let n = e.trim().split("\n").find((e) => e.trim() !== "") ?? "";
3298
3587
  return n.length > t ? `${n.slice(0, t)}...` : n;
3299
3588
  };
3300
- async function Ga(e) {
3301
- let { entry: t, brand: n, env: r = process.env, timeoutMs: i = Fa, expect: a = za() } = e, o = process.platform !== "win32", s = Qe(process.execPath, [
3589
+ async function ho(e) {
3590
+ let { entry: t, brand: n, env: r = process.env, timeoutMs: i = io, expect: a = co() } = e, o = process.platform !== "win32", s = at(process.execPath, [
3302
3591
  t,
3303
3592
  "--brand",
3304
3593
  n
@@ -3330,7 +3619,7 @@ async function Ga(e) {
3330
3619
  m = setTimeout(() => {
3331
3620
  p = !0, t(/* @__PURE__ */ Error(`no answer within ${i / 1e3} s`));
3332
3621
  }, i);
3333
- }), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${Wa(c)}` : ""}`))));
3622
+ }), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${mo(c)}` : ""}`))));
3334
3623
  g.catch(() => void 0), h.catch(() => void 0), u.catch(() => void 0);
3335
3624
  let _ = 0, v = (e, t) => {
3336
3625
  let n = ++_, r = new Promise((e) => d.set(n, e));
@@ -3355,7 +3644,7 @@ async function Ga(e) {
3355
3644
  version: "0"
3356
3645
  }
3357
3646
  });
3358
- if (e.error) throw Error(`initialize was refused: ${Wa(e.error.message ?? "")}`);
3647
+ if (e.error) throw Error(`initialize was refused: ${mo(e.error.message ?? "")}`);
3359
3648
  s.stdin.write(`${JSON.stringify({
3360
3649
  jsonrpc: "2.0",
3361
3650
  method: "notifications/initialized"
@@ -3364,8 +3653,8 @@ async function Ga(e) {
3364
3653
  if (t.error || r.length > 0) return {
3365
3654
  name: "handshake",
3366
3655
  passed: !1,
3367
- detail: t.error ? `tools/list failed: ${Wa(t.error.message ?? "")}` : `tools/list answered ${n.length} tool(s); missing ${r.join(", ")}`,
3368
- fix: `${Ra(ve())} (the server is older than this blazon), then run this check again`,
3656
+ detail: t.error ? `tools/list failed: ${mo(t.error.message ?? "")}` : `tools/list answered ${n.length} tool(s); missing ${r.join(", ")}`,
3657
+ fix: `${so(et())} (the server is older than this blazon), then run this check again`,
3369
3658
  tools: n
3370
3659
  };
3371
3660
  let i = Date.now(), o = await v("tools/call", {
@@ -3375,7 +3664,7 @@ async function Ga(e) {
3375
3664
  if (o.error || o.result?.isError) return {
3376
3665
  name: "handshake",
3377
3666
  passed: !1,
3378
- detail: `check_brand failed: ${Wa(o.error?.message ?? l)}`,
3667
+ detail: `check_brand failed: ${mo(o.error?.message ?? l)}`,
3379
3668
  fix: "run blazon check in the brand folder, and make sure the blazon program and the brand folder are the ones the server uses",
3380
3669
  tools: n,
3381
3670
  ms: c
@@ -3394,14 +3683,14 @@ async function Ga(e) {
3394
3683
  name: "handshake",
3395
3684
  passed: !1,
3396
3685
  detail: `the handshake did not finish: ${e instanceof Error ? e.message : String(e)}${p ? "; the server was killed" : ""}`,
3397
- fix: `${Ra(ve())}, then run this check again; on a hang, run the server by hand: node ${t} --brand ${n}`,
3686
+ fix: `${so(et())}, then run this check again; on a hang, run the server by hand: node ${t} --brand ${n}`,
3398
3687
  ms: Date.now() - y
3399
3688
  };
3400
3689
  } finally {
3401
- clearTimeout(m), await Ka(s, l, o);
3690
+ clearTimeout(m), await go(s, l, o);
3402
3691
  }
3403
3692
  }
3404
- async function Ka(e, t, n) {
3693
+ async function go(e, t, n) {
3405
3694
  let r = (t) => {
3406
3695
  try {
3407
3696
  n && e.pid !== void 0 ? process.kill(-e.pid, t) : e.kill(t);
@@ -3415,50 +3704,106 @@ async function Ka(e, t, n) {
3415
3704
  let i;
3416
3705
  await Promise.race([t, new Promise((e) => i = setTimeout(e, 2e3))]), clearTimeout(i), e.exitCode === null && e.signalCode === null ? (r("SIGKILL"), await t) : r("SIGKILL");
3417
3706
  }
3418
- function qa(e, t, n, r = $e.homedir()) {
3419
- let i = Ne(e, t, r, process.platform, process.env.APPDATA), a = [], o = [], s = [];
3420
- for (let e of i) {
3421
- let t;
3707
+ var _o = (e) => {
3708
+ try {
3709
+ return k.realpathSync(e);
3710
+ } catch {
3711
+ return O.resolve(e);
3712
+ }
3713
+ };
3714
+ function vo(e, t, n, r) {
3715
+ for (let i of e.args) {
3716
+ if (i.startsWith("-")) continue;
3717
+ let e = i.startsWith("~/") || i.startsWith(`~${O.sep}`) ? O.join(t, i.slice(1)) : i;
3718
+ if (!O.isAbsolute(e) && n === void 0) continue;
3719
+ let a = _o(O.resolve(n ?? "/", e));
3720
+ if (/\.m?js$/.test(a) && (a === r || k.existsSync(a))) return a;
3721
+ }
3722
+ }
3723
+ function yo(e, t, n, r = ot.homedir(), i = et()) {
3724
+ let a = Ie(e, t, r, process.platform, process.env.APPDATA), o = _o(we(i).args[0]), s = [], c = [], l = [], u = [];
3725
+ for (let e of a) {
3726
+ let n;
3422
3727
  try {
3423
- t = k.readFileSync(e.path, "utf8");
3728
+ n = k.readFileSync(e.path, "utf8");
3424
3729
  } catch {
3425
3730
  continue;
3426
3731
  }
3427
- let n = Ae(t, e);
3428
- n === void 0 ? s.push(e.path) : (o.push(e.path), n.includes("blazon") && a.push(e.path));
3732
+ let i = De(n, e);
3733
+ if (i === void 0) {
3734
+ l.push(e.path);
3735
+ continue;
3736
+ }
3737
+ if (c.push(e.path), !i.includes("blazon")) continue;
3738
+ s.push(e.path);
3739
+ let a = e.scope === "project" ? t.find((t) => e.path.startsWith(t + O.sep)) : void 0, d = Ne(n, e, "blazon") ?? [];
3740
+ d.length === 0 && u.push({
3741
+ file: e.path,
3742
+ script: void 0
3743
+ });
3744
+ for (let t of d) u.push({
3745
+ file: e.path,
3746
+ script: vo(t, r, a, o)
3747
+ });
3429
3748
  }
3430
- let c = s.length > 0 ? ` (not valid JSON, skipped: ${s.join(", ")})` : "", l = `blazon mcp --print-config --client ${e} --brand ${n}`;
3431
- return a.length > 0 ? {
3749
+ let d = l.length > 0 ? ` (not valid JSON, skipped: ${l.join(", ")})` : "", f = `blazon mcp --print-config --client ${e} --brand ${n}`;
3750
+ if (s.length === 0) return {
3432
3751
  name: "registered",
3433
- passed: !0,
3752
+ passed: !1,
3434
3753
  advisory: !0,
3435
3754
  client: e,
3436
- detail: `${e} has a server named blazon in ${a.join(", ")}${c}`,
3437
- files: a
3438
- } : {
3755
+ state: "none",
3756
+ found: !1,
3757
+ sameServer: null,
3758
+ detail: `no server named blazon in ${e}'s config; looked in ${c.length > 0 ? c.join(", ") : "no file that exists"}${d}`,
3759
+ fix: f,
3760
+ files: []
3761
+ };
3762
+ let p = {
3439
3763
  name: "registered",
3440
- passed: !1,
3441
3764
  advisory: !0,
3442
3765
  client: e,
3443
- detail: `no server named blazon in ${e}'s config; looked in ${o.length > 0 ? o.join(", ") : "no file that exists"}${c}`,
3444
- fix: l,
3445
- files: []
3766
+ found: !0,
3767
+ files: s,
3768
+ installPath: o
3769
+ }, m = u.find((e) => e.script !== void 0 && e.script !== o);
3770
+ return m?.script === void 0 ? u.some((e) => e.script === void 0) ? {
3771
+ ...p,
3772
+ passed: !1,
3773
+ state: "unknown",
3774
+ sameServer: null,
3775
+ detail: `${e} has a server named blazon in ${s.join(", ")}, but this check could not tell which file it runs; this install's is ${o}, and blazon mcp --print-config prints the command that registers it${d}`,
3776
+ fix: f
3777
+ } : {
3778
+ ...p,
3779
+ passed: !0,
3780
+ state: "same",
3781
+ sameServer: !0,
3782
+ detail: `${e} has a server named blazon in ${s.join(", ")}, and it runs this install's ${o}${d}`
3783
+ } : {
3784
+ ...p,
3785
+ passed: !1,
3786
+ state: "different",
3787
+ sameServer: !1,
3788
+ registeredPath: m.script,
3789
+ detail: `${e} has a server named blazon in ${m.file}, but it runs ${m.script}, not this install's ${o}; blazon mcp --print-config prints the command that registers this install${d}`,
3790
+ fix: f
3446
3791
  };
3447
3792
  }
3448
- async function Ja(e) {
3449
- let { client: t, brand: n, env: r = process.env, cwd: i = process.cwd(), home: a = $e.homedir() } = e, o = e.root ?? ve(), s = Ba(o), c = Ua(r, n, o), u = s.passed ? await Ga({
3450
- entry: s.entry,
3793
+ async function bo(e) {
3794
+ let { client: t, brand: n, env: r = process.env, cwd: i = process.cwd(), home: o = ot.homedir() } = e, s = e.root ?? et(), c = lo(s), l = po(r, n, s), u = c.passed ? await ho({
3795
+ entry: c.entry,
3451
3796
  brand: n,
3452
3797
  env: r,
3453
3798
  ...e.timeoutMs !== void 0 && { timeoutMs: e.timeoutMs }
3454
3799
  }) : {
3455
3800
  name: "handshake",
3456
3801
  passed: !1,
3457
- detail: `not run: ${_e(o) ? "the server is not built" : "the install is incomplete"}`,
3458
- fix: s.fix
3459
- }, d = qa(t, [.../* @__PURE__ */ new Set([i, n])], n, a), { entry: f, ...p } = s, m = [
3802
+ detail: `not run: ${Se(s) ? "the server is not built" : "the install is incomplete"}`,
3803
+ fix: c.fix
3804
+ }, d = yo(t, [.../* @__PURE__ */ new Set([i, n])], n, o, s), { entry: f, ...p } = c, m = [
3460
3805
  p,
3461
- c,
3806
+ l,
3462
3807
  u,
3463
3808
  d
3464
3809
  ], h = m.filter((e) => !e.advisory).every((e) => e.passed);
@@ -3467,43 +3812,43 @@ async function Ja(e) {
3467
3812
  client: t,
3468
3813
  brand: n,
3469
3814
  runsPlugins: !1,
3470
- trust: Ia,
3471
- registered: d.passed,
3815
+ trust: ao,
3816
+ registered: d.found,
3472
3817
  checks: m
3473
3818
  }), +!h;
3474
- console.log(`\n ${l.bold(`blazon-mcp for ${t}, brand ${n}`)}\n ${l.yellow(Ia)}\n`);
3819
+ console.log(`\n ${a.bold(`blazon-mcp for ${t}, brand ${n}`)}\n ${a.yellow(ao)}\n`);
3475
3820
  for (let e of m) {
3476
- let t = e.passed ? l.green("ok ") : e.advisory ? l.yellow("finding") : l.red("fail ");
3477
- console.log(` ${t} ${e.name.padEnd(10)} ${e.detail}`), !e.passed && e.fix && console.log(` ${" ".repeat(7)} ${" ".repeat(10)} ${l.dim("fix:")} ${e.fix}`);
3821
+ let t = e.passed ? a.green("ok ") : e.advisory ? a.yellow("finding") : a.red("fail ");
3822
+ console.log(` ${t} ${e.name.padEnd(10)} ${e.detail}`), !e.passed && e.fix && console.log(` ${" ".repeat(7)} ${" ".repeat(10)} ${a.dim("fix:")} ${e.fix}`);
3478
3823
  }
3479
- return console.log(`\n ${h ? l.green("The server is ready.") : l.red("The server is not ready.")}${d.passed ? "" : " It is not registered in this client yet (a finding, not a failure)."}\n`), +!h;
3824
+ return console.log(`\n ${h ? a.green("The server is ready.") : a.red("The server is not ready.")}${d.found ? "" : " It is not registered in this client yet (a finding, not a failure)."}\n`), +!h;
3480
3825
  }
3481
3826
  // src/cli/commands/mcp.ts
3482
- async function Ya(e = {}) {
3827
+ async function xo(e = {}) {
3483
3828
  if (e.printConfig && e.check) throw new M("give --print-config or --check, not both. See blazon mcp --help.", void 0, "conflicting-options");
3484
3829
  if (!e.printConfig && !e.check) throw new M("give --print-config to print the config that registers blazon-mcp in a client, or --check to test that it works; neither writes a file. See blazon mcp --help.", void 0, "missing-argument");
3485
3830
  let t = e.client === void 0 ? "claude-code" : e.client;
3486
- if (e.client !== void 0 && !he(e.client)) throw new M(`unknown client "${e.client}"; the clients are ${pe.join(", ")}.`, void 0, "invalid-option-value");
3831
+ if (e.client !== void 0 && !be(e.client)) throw new M(`unknown client "${e.client}"; the clients are ${ve.join(", ")}.`, void 0, "invalid-option-value");
3487
3832
  let n = e.brand === void 0 ? void 0 : O.resolve(process.cwd(), e.brand);
3488
3833
  if (e.check) {
3489
3834
  let r = n ?? process.cwd();
3490
3835
  if (!k.statSync(r, { throwIfNoEntry: !1 })?.isDirectory()) throw new M(`the brand folder ${r} does not exist.`, void 0, "no-folder");
3491
- return Ja({
3836
+ return bo({
3492
3837
  client: t,
3493
3838
  brand: r,
3494
3839
  ...e.root && { root: e.root },
3495
3840
  ...e.json && { json: !0 }
3496
3841
  });
3497
3842
  }
3498
- let r = xe(e.root);
3499
- if (!r.built && !_e(e.root)) return e.json ? Y("mcp", !1, {
3843
+ let r = we(e.root);
3844
+ if (!r.built && !Se(e.root)) return e.json ? Y("mcp", !1, {
3500
3845
  client: t,
3501
3846
  built: !1,
3502
3847
  ...n && { brand: n },
3503
- note: Ie,
3848
+ note: Ve,
3504
3849
  snippets: []
3505
- }) : console.error(`\n ${l.yellow(Ie)}\n`), 1;
3506
- let i = Be(t, r, n);
3850
+ }) : console.error(`\n ${a.yellow(Ve)}\n`), 1;
3851
+ let i = Ge(t, r, n);
3507
3852
  if (e.json) return Y("mcp", !0, {
3508
3853
  client: t,
3509
3854
  built: i.built,
@@ -3511,13 +3856,13 @@ async function Ya(e = {}) {
3511
3856
  ...i.note && { note: i.note },
3512
3857
  snippets: i.snippets
3513
3858
  }), 0;
3514
- console.log(`\n ${l.bold(i.title)}`);
3515
- for (let e of i.snippets) console.log(`\n ${l.dim(e.label)}\n\n${e.text.replace(/^/gm, " ")}`);
3516
- return i.note && console.log(`\n ${l.yellow(i.note)}`), console.log(""), 0;
3859
+ console.log(`\n ${a.bold(i.title)}`);
3860
+ for (let e of i.snippets) console.log(`\n ${a.dim(e.label)}\n\n${e.text.replace(/^/gm, " ")}`);
3861
+ return i.note && console.log(`\n ${a.yellow(i.note)}`), console.log(""), 0;
3517
3862
  }
3518
3863
  // src/cli/commands/explain.ts
3519
- function Xa(e) {
3520
- let t = se[e], n = oe(e);
3864
+ function So(e) {
3865
+ let t = Ye[e], n = Ke(e);
3521
3866
  return {
3522
3867
  code: e,
3523
3868
  severity: t.severity,
@@ -3528,26 +3873,26 @@ function Xa(e) {
3528
3873
  manual: t.manual
3529
3874
  };
3530
3875
  }
3531
- function Za(e) {
3876
+ function Co(e) {
3532
3877
  let [t = "", n] = e.split("#");
3533
3878
  return `RFC ${t.padStart(4, "0")}${n ? `, section ${n}` : ""}`;
3534
3879
  }
3535
- function Qa(e) {
3536
- let t = Object.keys(se), n = [];
3880
+ function wo(e) {
3881
+ let t = Object.keys(Ye), n = [];
3537
3882
  for (let r = 0; r < 3; r++) {
3538
- let r = E(e, t);
3883
+ let r = D(e, t);
3539
3884
  if (r === void 0) break;
3540
3885
  n.push(r), t.splice(t.indexOf(r), 1);
3541
3886
  }
3542
3887
  return n;
3543
3888
  }
3544
- function $a(e) {
3545
- let t = e.severity === "error" ? l.red : e.severity === "warning" ? l.yellow : l.dim;
3546
- console.log(`\n ${l.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${l.bold("Fix")} ${e.fix}`), console.log(`\n ${l.bold("Read")} docs/manual/${e.manual}.md, ${Za(e.rfc)}\n`);
3889
+ function To(e) {
3890
+ let t = e.severity === "error" ? a.red : e.severity === "warning" ? a.yellow : a.dim;
3891
+ console.log(`\n ${a.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${a.bold("Fix")} ${e.fix}`), console.log(`\n ${a.bold("Read")} docs/manual/${e.manual}.md, ${Co(e.rfc)}\n`);
3547
3892
  }
3548
- function eo(e, t = {}) {
3893
+ function Eo(e, t = {}) {
3549
3894
  if (e === void 0) {
3550
- let e = Object.keys(se).sort().map((e) => Xa(e));
3895
+ let e = Object.keys(Ye).sort().map((e) => So(e));
3551
3896
  if (t.json) Y("explain", !0, { codes: e });
3552
3897
  else {
3553
3898
  let t = Math.max(...e.map((e) => e.code.length));
@@ -3557,26 +3902,26 @@ function eo(e, t = {}) {
3557
3902
  }
3558
3903
  return 0;
3559
3904
  }
3560
- if (!Object.hasOwn(se, e)) {
3561
- let t = Qa(e);
3905
+ if (!Object.hasOwn(Ye, e)) {
3906
+ let t = wo(e);
3562
3907
  throw new M(`unknown code "${e}"`, t.length > 0 ? `Did you mean ${t.map((e) => `"${e}"`).join(", ")}? Run blazon explain to list every code.` : "Run blazon explain to list every code.", "unknown-finding-code");
3563
3908
  }
3564
- let n = Xa(e);
3565
- return t.json ? Y("explain", !0, n) : $a(n), 0;
3909
+ let n = So(e);
3910
+ return t.json ? Y("explain", !0, n) : To(n), 0;
3566
3911
  }
3567
3912
  // src/cli/options.ts
3568
- var to = (e) => {
3913
+ var Do = (e) => {
3569
3914
  if (e.length === 1) return [`-${e}`];
3570
3915
  let t = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
3571
3916
  return t === e ? [`--${e}`] : [`--${e}`, `--${t}`];
3572
3917
  };
3573
- function no(e, t) {
3918
+ function Oo(e, t) {
3574
3919
  let n = e.matchedCommand;
3575
3920
  if (!n) return;
3576
3921
  let r = [...n.options, ...e.globalCommand.options].filter((e) => e.required);
3577
3922
  for (let i of r) {
3578
3923
  if (typeof e.options[i.name] == "object") continue;
3579
- let r = i.names.flatMap(to);
3924
+ let r = i.names.flatMap(Do);
3580
3925
  for (let a = 2; a < t.length; a++) {
3581
3926
  let o = t[a], s = r.find((e) => o === e || o.startsWith(`${e}=`));
3582
3927
  if (s === void 0) continue;
@@ -3588,11 +3933,11 @@ function no(e, t) {
3588
3933
  i.some((e, t) => e === "" && !(i[t - 1] ?? "").startsWith("-")) && N(`blazon ${n.name}: ${n.rawName.includes("[dir]") ? "the folder is an empty name; leave it out to use the current folder" : "an argument is empty"}.`, "empty-value", { fix: "Leave the empty argument out, or give it a value." });
3589
3934
  }
3590
3935
  // src/cli/json.ts
3591
- var ro = [
3936
+ var ko = [
3592
3937
  "error",
3593
3938
  "warning",
3594
3939
  "info"
3595
- ], io = {
3940
+ ], Ao = {
3596
3941
  error: ["error"],
3597
3942
  warning: ["error", "warning"],
3598
3943
  info: [
@@ -3601,40 +3946,46 @@ var ro = [
3601
3946
  "info"
3602
3947
  ]
3603
3948
  };
3604
- async function ao(e, t, n, r = "info") {
3605
- let i = console.log;
3949
+ async function jo(e, n, r, i = "info", a = process.cwd()) {
3950
+ let o = console.log;
3606
3951
  console.log = (...e) => console.error(...e);
3607
- let a;
3952
+ let s;
3608
3953
  try {
3609
- a = (await n()).findings;
3954
+ s = (await r()).findings;
3610
3955
  } catch (e) {
3611
- if (!(e instanceof bt)) throw e;
3612
- a = e.findings;
3956
+ if (!(e instanceof Dt)) throw e;
3957
+ s = e.findings;
3613
3958
  } finally {
3614
- console.log = i;
3959
+ console.log = o;
3615
3960
  }
3616
- let o = c(a, { strict: t }), s = {
3617
- errors: o.errors.length,
3618
- warnings: o.warnings.length,
3619
- info: o.infos.length
3961
+ let c = t(s, { strict: n }), l = {
3962
+ errors: c.errors.length,
3963
+ warnings: c.warnings.length,
3964
+ info: c.infos.length
3965
+ }, { mismatch: u } = _e(a), d = u && {
3966
+ pinned: u.pinned,
3967
+ running: u.running,
3968
+ message: u.message
3620
3969
  };
3621
3970
  process.stdout.write(`${JSON.stringify({
3622
3971
  command: e,
3623
- passed: o.passed,
3624
- strict: t,
3625
- counts: s,
3626
- findings: o.all.filter((e) => io[r].includes(e.severity)).map((e) => ({
3972
+ passed: c.passed,
3973
+ strict: n,
3974
+ counts: l,
3975
+ brandHasErrors: b(s).length > 0,
3976
+ ...d && { pinMismatch: d },
3977
+ findings: c.all.filter((e) => Ao[i].includes(e.severity)).map((e) => ({
3627
3978
  ...e,
3628
- ...Ue(e) && { fix: Ue(e) }
3979
+ ...$e(e) && { fix: $e(e) }
3629
3980
  }))
3630
- }, null, 2)}\n`), process.exitCode = +!o.passed;
3981
+ }, null, 2)}\n`), process.exitCode = +!c.passed;
3631
3982
  }
3632
- async function oo(e, t) {
3983
+ async function Mo(e, t) {
3633
3984
  let n = console.log;
3634
3985
  console.log = (...e) => console.error(...e);
3635
3986
  let r, i, a;
3636
3987
  try {
3637
- i = await Jr(e, {
3988
+ i = await ii(e, {
3638
3989
  ...t,
3639
3990
  input: !1,
3640
3991
  report: (e) => r = e,
@@ -3647,18 +3998,18 @@ async function oo(e, t) {
3647
3998
  command: "init",
3648
3999
  passed: i === 0,
3649
4000
  ...r ?? {},
3650
- ...i !== 0 && { error: a ? lt(a.code, a.message) : lt("error", `init did not finish (exit status ${i}); the reason is on standard error`) }
4001
+ ...i !== 0 && { error: a ? gt(a.code, a.message) : gt("error", `init did not finish (exit status ${i}); the reason is on standard error`) }
3651
4002
  };
3652
4003
  return process.stdout.write(`${JSON.stringify(o)}\n`), i;
3653
4004
  }
3654
4005
  // src/cli/help.ts
3655
- var so = " 0 it did what it was asked (for check, no errors)\n 1 the check found errors (or warnings, with --strict), `blazon can` denied the combination, `blazon doctor` found a failing check, or the command failed\n 2 it was used wrongly: an unknown command or option, an unknown token, a bad port, no brand book in the folder. It did nothing, except `blazon init --from`, which copies the starter and then exits 2 when the site cannot be read", co = " blazon explain <code> what a finding code means, the fix, and where to read more\n blazon explain list every code", lo = " --cwd <dir> sets the folder every command works from, the same as running blazon there. A folder argument is then relative to it:\n `blazon --cwd ./brands check acme` checks ./brands/acme. A --cwd that is not a folder exits 2.\n `blazon doctor` checks the environment (Node, brand folder, plugin folder safety, Chrome, blazon.lock): one line each, ok, warn or fail, with a fix.", uo = {
4006
+ var No = " 0 it did what it was asked (for check, no errors)\n 1 the check found errors (or warnings, with --strict), `blazon can` denied the combination, `blazon doctor` found a failing check, or the command failed\n 2 it was used wrongly: an unknown command or option, an unknown token, a bad port, no brand book in the folder. It did nothing, except `blazon init --from`, which copies the starter and then exits 2 when the site cannot be read", Po = " blazon explain <code> what a finding code means, the fix, and where to read more\n blazon explain list every code", Fo = " --cwd <dir> sets the folder every command works from, the same as running blazon there. A folder argument is then relative to it:\n `blazon --cwd ./brands check acme` checks ./brands/acme. A --cwd that is not a folder exits 2.\n `blazon doctor` checks the environment (Node, brand folder, plugin folder safety, Chrome, blazon.lock): one line each, ok, warn or fail, with a fix.", Io = {
3656
4007
  check: "blazon plugin check <program> [--core] [--json]\n\nStarts the program the way blazon does and runs the protocol's core cases against it, then blazon's own cases for each role it declares and, for a shipped plugin's layout, the file name rule. Prints one line for each case: ok, skip or FAIL.\nIn a project whose config lists the plugin, case 10 also fails when the entry's env does not approve a variable the manifest lists.\nWith --core, only the core cases (1 to 5) run: no role cases, no case 10 and no layout line. Use it to check a plugin against the protocol alone.\n\nExit status:\n 0 every case passed\n 1 a case failed\n 2 no program was given\n\nExample:\n $ blazon plugin check ./blazon-acme.house-style",
3657
4008
  pin: "blazon plugin pin <path> [--name <plugin>] [--digest <digest>] [--entry <path>]\n\nPrints the digest that pins a plugin: sha256: for a file, t1: for a directory.\nWith --name, records the pin in blazon.plugins.lock instead. --digest says what the bytes must be, and the pin is refused when they are not. --entry names the program inside a directory when it is not blazon-<plugin>.\n\nExit status:\n 0 printed, or recorded\n 1 the path is one a host must refuse, or the digest does not match\n 2 no path was given, or --digest or --entry without --name\n\nExample:\n $ blazon plugin pin ./blazon-acme.house-style --name acme.house-style",
3658
4009
  profile: "blazon plugin profile\n\nPrints blazon's profile of the plugin protocol as JSON: the roles it defines and its limits. It is the same for every install.\n\nExit status:\n 0 printed"
3659
4010
  };
3660
- function fo(e, t, n) {
3661
- if (t === "plugin" && n !== void 0 && Object.hasOwn(uo, n)) return [{ body: uo[n] }];
4011
+ function Lo(e, t, n) {
4012
+ if (t === "plugin" && n !== void 0 && Object.hasOwn(Io, n)) return [{ body: Io[n] }];
3662
4013
  let r = e.map((e) => ({
3663
4014
  ...e,
3664
4015
  body: e.body.replace(/(--no-[a-z-]+[^\n]*?) *\(default: true\)/g, "$1")
@@ -3667,32 +4018,32 @@ function fo(e, t, n) {
3667
4018
  ...r,
3668
4019
  {
3669
4020
  title: "Finding codes",
3670
- body: co
4021
+ body: Po
3671
4022
  },
3672
4023
  {
3673
4024
  title: "Working folder and environment",
3674
- body: lo
4025
+ body: Fo
3675
4026
  },
3676
4027
  {
3677
4028
  title: "Exit status",
3678
- body: so
4029
+ body: No
3679
4030
  }
3680
4031
  ] : r;
3681
4032
  }
3682
4033
  // src/cli/index.ts
3683
- function po(e, t) {
4034
+ function Ro(e, t) {
3684
4035
  if (t === void 0) return;
3685
4036
  let n = String(t), r = /^\d+$/.test(n) ? Number(n) : NaN;
3686
4037
  return r >= 1 && r <= 65535 || N(`blazon ${e}: the port must be a whole number from 1 to 65535, not "${n}".`, "invalid-port", { fix: "Give a whole number from 1 to 65535." }), r;
3687
4038
  }
3688
- var mo = (e) => typeof e == "number" ? String(e) : e;
3689
- function ho(e, t) {
4039
+ var zo = (e) => typeof e == "number" ? String(e) : e;
4040
+ function Bo(e, t) {
3690
4041
  t?.plugins === !1 && t.plugin !== void 0 && N(`blazon ${e}: --no-plugins runs no plugin, so it cannot be used with --plugin.`, "conflicting-options", { fix: "Leave out --no-plugins, or leave out --plugin." });
3691
4042
  }
3692
- function go(e, t, n) {
3693
- if (t !== void 0) return n || N(`blazon ${e}: --severity cuts the list that --json prints; add --json, or leave --severity out.`, "conflicting-options", { fix: "Add --json, or leave --severity out." }), ro.includes(t) || N(`blazon ${e}: --severity must be error, warning or info, not "${String(t)}".`, "invalid-option-value", { fix: "Use --severity error, warning or info." }), t;
4043
+ function Vo(e, t, n) {
4044
+ if (t !== void 0) return n || N(`blazon ${e}: --severity cuts the list that --json prints; add --json, or leave --severity out.`, "conflicting-options", { fix: "Add --json, or leave --severity out." }), ko.includes(t) || N(`blazon ${e}: --severity must be error, warning or info, not "${String(t)}".`, "invalid-option-value", { fix: "Use --severity error, warning or info." }), t;
3694
4045
  }
3695
- var _o = (e) => {
4046
+ var Ho = (e) => {
3696
4047
  let [t, n] = e.slice(2).filter((e, t, n) => !e.startsWith("-") && n[t - 1] !== "--cwd" && n[t - 1] !== "--allow-dir");
3697
4048
  if (e.includes("--json") && t !== void 0) return t === "plugin" ? n === "check" ? "plugin check" : void 0 : [
3698
4049
  "check",
@@ -3704,11 +4055,11 @@ var _o = (e) => {
3704
4055
  "pin",
3705
4056
  "explain",
3706
4057
  "doctor",
3707
- ...Aa,
4058
+ ...Qa,
3708
4059
  "mcp"
3709
4060
  ].includes(t) ? t : void 0;
3710
4061
  };
3711
- function vo(e) {
4062
+ function Uo(e) {
3712
4063
  if (e[2] !== "help") return e;
3713
4064
  let t = e[3];
3714
4065
  return t !== void 0 && !t.startsWith("-") ? [
@@ -3718,58 +4069,58 @@ function vo(e) {
3718
4069
  ...e.slice(4)
3719
4070
  ] : [...e.slice(0, 2), "--help"];
3720
4071
  }
3721
- async function yo(e = process.argv) {
3722
- let t = vo(e), n = t.includes("--debug");
3723
- st(_o(t));
3724
- let r = tt("blazon");
4072
+ async function Wo(e = process.argv) {
4073
+ let t = Uo(e), n = t.includes("--debug");
4074
+ mt(Ho(t));
4075
+ let r = ct("blazon");
3725
4076
  if (r.option("--debug", "Show the stack of an error"), r.option("--allow-dir <folder>", "Approve a folder outside the project for an asset category dir (repeat for more; or BLAZON_ALLOW_DIRS)"), r.option("--cwd <dir>", "Work from this folder, as if blazon were run there; a folder argument is then relative to it"), r.command("dev [dir]", "Start interactive Brand Book dev server with HMR").option("-p, --port <port>", "Port number to listen on (default: the port in blazon.json, else 3000)").option("--strict-port", "Exit 2 when the port is in use, instead of taking the next free one").option("--host [address]", "Listen on this address, or on every network interface with no address (default: localhost only)").action(async (e, t) => {
3726
4077
  try {
3727
- await yt(e || process.cwd(), po("dev", t?.port), {
4078
+ await Et(e || process.cwd(), Ro("dev", t?.port), {
3728
4079
  strictPort: t?.strictPort,
3729
- host: mo(t?.host)
4080
+ host: zo(t?.host)
3730
4081
  });
3731
4082
  } catch (e) {
3732
4083
  P("dev", e, n);
3733
4084
  }
3734
4085
  }), r.command("build [dir]", "Build static brand book site and compiled design tokens").option("-o, --outDir <dir>", "Output directory for static site").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
3735
4086
  try {
3736
- ho("build", t);
3737
- let n = go("build", t?.severity, t?.json), r = () => Ft(e || process.cwd(), t?.outDir === void 0 ? void 0 : O.resolve(process.cwd(), t.outDir), t);
3738
- t?.json ? await ao("build", !1, r, n) : await r();
4087
+ Bo("build", t);
4088
+ let n = Vo("build", t?.severity, t?.json), r = () => Ht(e || process.cwd(), t?.outDir === void 0 ? void 0 : O.resolve(process.cwd(), t.outDir), t);
4089
+ t?.json ? await jo("build", !1, r, n, e || process.cwd()) : await r();
3739
4090
  } catch (e) {
3740
4091
  P("build", e, n);
3741
4092
  }
3742
4093
  }), r.command("tokens [dir]", "Compile design tokens only (theme.css, tokens.ts, tokens.json)").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
3743
4094
  try {
3744
- ho("tokens", t);
3745
- let n = go("tokens", t?.severity, t?.json), r = () => It(e || process.cwd(), t);
3746
- t?.json ? await ao("tokens", !1, r, n) : await r();
4095
+ Bo("tokens", t);
4096
+ let n = Vo("tokens", t?.severity, t?.json), r = () => Ut(e || process.cwd(), t);
4097
+ t?.json ? await jo("tokens", !1, r, n, e || process.cwd()) : await r();
3747
4098
  } catch (e) {
3748
4099
  P("tokens", e, n);
3749
4100
  }
3750
4101
  }), r.command("check [dir]", "Check tokens: aliases, types, usage rules, contrast pairs, duplicates and review flags").option("--strict", "Treat warnings as errors (useful for CI/CD pipelines)").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
3751
4102
  try {
3752
- ho("check", t);
3753
- let n = go("check", t?.severity, t?.json), r = () => Pt(e || process.cwd(), t?.strict, t);
3754
- t?.json ? await ao("check", !!t.strict, r, n) : (await r()).passed || (process.exitCode = 1);
4103
+ Bo("check", t);
4104
+ let n = Vo("check", t?.severity, t?.json), r = () => Vt(e || process.cwd(), t?.strict, t);
4105
+ t?.json ? await jo("check", !!t.strict, r, n, e || process.cwd()) : (await r()).passed || (process.exitCode = 1);
3755
4106
  } catch (e) {
3756
4107
  P("check", e, n);
3757
4108
  }
3758
- }), Pa(r, n), r.command("mcp", "Set up blazon-mcp, the MCP server for coding agents: --print-config prints what registers it in a client, --check tests that it works; neither writes a file").option("--print-config", "Print the config that registers blazon-mcp (stdio) in a client").option("--check", "Test that the server is built, finds blazon, answers a real MCP handshake and is registered in the client; runs no plugin").option("--client <client>", "With --print-config or --check: claude-code (default), claude-desktop, cursor or vscode").option("--brand <dir>", "The brand folder: with --print-config, written into the config as an absolute path; with --check, the folder the server starts on").option("--json", "Print the config or the check as JSON on standard output").action(async (e) => {
4109
+ }), ro(r, n), r.command("mcp", "Set up blazon-mcp, the MCP server for coding agents: --print-config prints what registers it in a client, --check tests that it works; neither writes a file").option("--print-config", "Print the config that registers blazon-mcp (stdio) in a client").option("--check", "Test that the server is built, finds blazon, answers a real MCP handshake and is registered in the client; runs no plugin").option("--client <client>", "With --print-config or --check: claude-code (default), claude-desktop, cursor or vscode").option("--brand <dir>", "The brand folder: with --print-config, written into the config as an absolute path; with --check, the folder the server starts on").option("--json", "Print the config or the check as JSON on standard output").action(async (e) => {
3759
4110
  try {
3760
- process.exitCode = await Ya(e);
4111
+ process.exitCode = await xo(e);
3761
4112
  } catch (e) {
3762
4113
  P("mcp", e, n);
3763
4114
  }
3764
4115
  }), r.command("drift [target]", "Find tokens that have drifted from the live site: compare each token that names a source.cssVar with a page (http or https address) or a CSS file").option("--json", "Print the findings as JSON").option("--tokens <dir>", "Read the tokens from this folder instead of the one the config names").action(async (e, t) => {
3765
4116
  try {
3766
- process.exitCode = await di(e, t);
4117
+ process.exitCode = await xi(e, t);
3767
4118
  } catch (e) {
3768
4119
  P("drift", e, n);
3769
4120
  }
3770
4121
  }), r.command("approvals [dir]", "List the tokens and assets marked review ok with the fingerprint of their value today, to record in review.value so `blazon check` sees a later change").option("--json", "Print the list as JSON on standard output").action(async (e, t) => {
3771
4122
  try {
3772
- process.exitCode = await fi(e || process.cwd(), { json: t?.json });
4123
+ process.exitCode = await Si(e || process.cwd(), { json: t?.json });
3773
4124
  } catch (e) {
3774
4125
  P("approvals", e, n);
3775
4126
  }
@@ -3780,72 +4131,72 @@ async function yo(e = process.argv) {
3780
4131
  "digest",
3781
4132
  "entry"
3782
4133
  ]) r?.[t] !== void 0 && N(`blazon plugin: --${t} is for \`blazon plugin pin\`; \`${e ?? "check"}\` does not take it.`, "conflicting-options", { fix: `Leave out --${t}, or use it with \`blazon plugin pin\`.` });
3783
- e === "profile" && t !== void 0 && N("blazon plugin: `profile` takes no target.", "conflicting-options", { fix: "Run `blazon plugin profile` on its own." }), process.exitCode = await li(e, t, r);
4134
+ e === "profile" && t !== void 0 && N("blazon plugin: `profile` takes no target.", "conflicting-options", { fix: "Run `blazon plugin profile` on its own." }), process.exitCode = await yi(e, t, r);
3784
4135
  } catch (e) {
3785
4136
  P("plugin", e, n);
3786
4137
  }
3787
4138
  }), r.command("explain [code]", "Explain a finding code: its severity, what it means, the fix and where to read more; with no code, list every code").option("--json", "Print the explanation as JSON on standard output").action((e, t) => {
3788
4139
  try {
3789
- process.exitCode = eo(e, { json: t?.json });
4140
+ process.exitCode = Eo(e, { json: t?.json });
3790
4141
  } catch (e) {
3791
4142
  P("explain", e, n);
3792
4143
  }
3793
4144
  }), r.command("pin [dir]", "Pin the blazon you build with: write blazon.lock with the commit of the blazon that runs this, so check, tokens and build refuse any other").option("--json", "Print the pinned commit as JSON on standard output").action((e, t) => {
3794
4145
  try {
3795
- process.exitCode = ui(e || process.cwd(), { json: t?.json });
4146
+ process.exitCode = bi(e || process.cwd(), { json: t?.json });
3796
4147
  } catch (e) {
3797
4148
  P("pin", e, n);
3798
4149
  }
3799
4150
  }), r.command("init [dir]", "Scaffold a new Blazon brand book and design token structure").option("--from <url>", "Start from a live site: read its stylesheets and page for the brand colors, fonts, logo and title (all marked needs-review)").option("--name <text>", "With `init`: the brand book title, as given").option("--description <text>", "With `init`: one sentence on the brand: the config description").option("--color <hex>", "With `init`: the primary color as hex, with or without the #: #2563eb, 2563eb or #26e").option("--font <family>", "With `init`: the font family, a Google Fonts name").option("--logo <file>", "With `init`: an SVG or PNG file to use as the logo").option("--dev", "With `init`: start `blazon dev` when it is done").option("--json", "Print what init made as JSON on standard output; everything else goes to standard error (never asks)").option("--yes", "With `init`: accept every default and never ask").option("--no-input", "With `init`: same as --yes; implied when stdin or stdout is not a terminal").action(async (e, t) => {
3800
4151
  try {
3801
- t?.json ? (t.dev && N("blazon init: --dev starts a server that never ends, so it cannot be used with --json.", "conflicting-options", { fix: "Leave out --dev, or leave out --json." }), process.exitCode = await oo(e || ".", t)) : process.exitCode = await Jr(e || ".", { ...t });
4152
+ t?.json ? (t.dev && N("blazon init: --dev starts a server that never ends, so it cannot be used with --json.", "conflicting-options", { fix: "Leave out --dev, or leave out --json." }), process.exitCode = await Mo(e || ".", t)) : process.exitCode = await ii(e || ".", { ...t });
3802
4153
  } catch (e) {
3803
4154
  P("init", e, n);
3804
4155
  }
3805
4156
  }), r.command("preview [dir]", "Preview the static production brand book build").option("-p, --port <port>", "Port number to listen on (default: the port in blazon.json, else 3000)").option("--strict-port", "Exit 2 when the port is in use, instead of taking the next free one").option("--host [address]", "Listen on this address, or on every network interface with no address (default: localhost only)").action(async (e, t) => {
3806
4157
  try {
3807
- await Qr(e || process.cwd(), po("preview", t?.port), {
4158
+ await ci(e || process.cwd(), Ro("preview", t?.port), {
3808
4159
  strictPort: t?.strictPort,
3809
- host: mo(t?.host)
4160
+ host: zo(t?.host)
3810
4161
  });
3811
4162
  } catch (e) {
3812
4163
  P("preview", e, n);
3813
4164
  }
3814
4165
  }), r.command("doctor", "Check this machine and folder: Node version, brand folder, plugin folder safety, Chrome (if a plugin needs it) and blazon.lock; writes nothing").option("--json", "Print the checks as JSON on standard output").action(async (e) => {
3815
4166
  try {
3816
- process.exitCode = await oa(process.cwd(), { json: e?.json });
4167
+ process.exitCode = await xa(process.cwd(), { json: e?.json });
3817
4168
  } catch (e) {
3818
4169
  P("doctor", e, n);
3819
4170
  }
3820
- }), r.example(" $ blazon init my-brand"), r.example(" $ blazon check my-brand --json"), r.example(" $ blazon build my-brand"), r.example(" $ blazon list ./my-brand --type color"), r.example(" $ blazon get color.brand.primary my-brand --json"), r.example(" $ blazon can text.primary surface.canvas my-brand"), r.help((e) => fo(e, r.matchedCommand?.name, r.args[0])), r.version(Ge), t.slice(2).length === 0) return r.outputHelp();
4171
+ }), r.example(" $ blazon init my-brand"), r.example(" $ blazon check my-brand --json"), r.example(" $ blazon build my-brand"), r.example(" $ blazon list ./my-brand --type color"), r.example(" $ blazon get color.brand.primary my-brand --json"), r.example(" $ blazon can text.primary surface.canvas my-brand"), r.help((e) => Lo(e, r.matchedCommand?.name, r.args[0])), r.version(re), t.slice(2).length === 0) return r.outputHelp();
3821
4172
  r.addEventListener("command:*", (e) => {
3822
4173
  if (r.options.help || r.options.version) return;
3823
- let t = String(e.detail), n = E(t, r.commands.map((e) => e.name).filter(Boolean));
4174
+ let t = String(e.detail), n = D(t, r.commands.map((e) => e.name).filter(Boolean));
3824
4175
  N(`blazon: unknown command "${t}"${n ? `; did you mean "${n}"?` : "."} Run blazon --help for the commands.`, "unknown-command", { fix: n ? `Run blazon ${n}, or blazon --help for the commands.` : "Run blazon --help for the commands." });
3825
4176
  });
3826
4177
  try {
3827
- r.parse(t, { run: !1 }), no(r, t);
4178
+ r.parse(t, { run: !1 }), Oo(r, t);
3828
4179
  try {
3829
- mi(r.options.allowDir), pi(r.options.cwd);
4180
+ wi(r.options.allowDir), Ci(r.options.cwd);
3830
4181
  } catch (e) {
3831
4182
  P(r.matchedCommand?.name ?? "", e, n);
3832
4183
  }
3833
4184
  await r.runMatchedCommand();
3834
4185
  } catch (e) {
3835
- if (!ft(e)) return P("", e, n);
4186
+ if (!yt(e)) return P("", e, n);
3836
4187
  let t = r.matchedCommand?.name, i = t ? `blazon ${t}` : "blazon", [, a = "", o] = /^Unknown option `(-{1,2})([^`]+)`$/.exec(e.message) ?? [], s = n ? e.stack : void 0;
3837
4188
  o !== void 0 && /^\d+$/.test(o) && (t === "dev" || t === "preview") && N(`blazon ${t}: the port must be a whole number from 1 to 65535, not "-${o}".`, "invalid-port", { fix: "Give a whole number from 1 to 65535." }), t === "get" && /^missing required args/i.test(e.message) && N("blazon get: give a token path, such as blazon get color.brand.primary; blazon list shows the token paths.", "missing-argument", {
3838
4189
  stack: s,
3839
4190
  fix: "Run blazon list to see the token paths."
3840
- }), o === void 0 && N(`${i}: ${dt(e.message)}. Run ${i} --help for the options.`, "missing-argument", {
4191
+ }), o === void 0 && N(`${i}: ${vt(e.message)}. Run ${i} --help for the options.`, "missing-argument", {
3841
4192
  stack: s,
3842
4193
  fix: `Run ${i} --help for the options.`
3843
4194
  });
3844
- let c = [...r.matchedCommand?.options ?? [], ...r.globalCommand.options].map((e) => e.name), l = E(o, c);
4195
+ let c = [...r.matchedCommand?.options ?? [], ...r.globalCommand.options].map((e) => e.name), l = D(o, c);
3845
4196
  N(`${i}: unknown option "${a}${o}"${l ? `; did you mean "--${l}"?` : "."} Run ${i} --help for the options.`, "unknown-option", {
3846
4197
  stack: s,
3847
4198
  fix: l ? `Use --${l}, or run ${i} --help for the options.` : `Run ${i} --help for the options.`
3848
4199
  });
3849
4200
  }
3850
4201
  }
3851
- export { yo as runCli };
4202
+ export { Wo as runCli };