dsh-ppt 0.21.0 → 0.22.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 (49) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.en.md +18 -17
  3. package/README.md +16 -15
  4. package/docs/COACHING.md +14 -13
  5. package/docs/DATA.md +8 -8
  6. package/docs/REFERENCE.en.md +17 -19
  7. package/docs/REFERENCE.zh.md +16 -18
  8. package/docs/USAGE.en.md +107 -60
  9. package/docs/USAGE.md +115 -84
  10. package/docs/VALIDATION.md +2 -0
  11. package/docs/VISUAL.md +27 -20
  12. package/docs/WORKBENCH.md +17 -6
  13. package/docs/assets/intro/screen-en.webp +0 -0
  14. package/docs/assets/intro/screen-zh.webp +0 -0
  15. package/lib/client.js +941 -132
  16. package/lib/coaching.d.ts +1 -1
  17. package/lib/coaching.js +25 -12
  18. package/lib/config.d.ts +2 -0
  19. package/lib/config.js +30 -2
  20. package/lib/execution.d.ts +2 -1
  21. package/lib/execution.js +21 -1
  22. package/lib/tools.d.ts +1 -1
  23. package/lib/tools.js +151 -24
  24. package/lib/types.d.ts +108 -8
  25. package/lib/visual.d.ts +3 -1
  26. package/lib/visual.js +40 -13
  27. package/lib/workbench-language.js +45 -9
  28. package/lib/workbench.d.ts +5 -0
  29. package/lib/workbench.js +485 -9
  30. package/package.json +9 -4
  31. package/skills/dsh-ppt/SKILL.md +56 -54
  32. package/skills/dsh-ppt/package.json +1 -1
  33. package/skills/dsh-ppt/references/advanced.md +122 -41
  34. package/skills/dsh-ppt/references/copywriting.md +63 -41
  35. package/skills/dsh-ppt/references/data.md +83 -36
  36. package/skills/dsh-ppt/references/syntax.md +157 -28
  37. package/skills/dsh-ppt/references/themes.md +90 -41
  38. package/skills/dsh-ppt/references/troubleshooting.md +21 -16
  39. package/skills/dsh-ppt/scripts/build-deck.mjs +67 -28
  40. package/skills/dsh-ppt/scripts/deck-absorb.mjs +1029 -0
  41. package/skills/dsh-ppt/scripts/deck-advanced.mjs +406 -99
  42. package/skills/dsh-ppt/scripts/deck-core.mjs +568 -717
  43. package/skills/dsh-ppt/scripts/deck-data-view.mjs +30 -11
  44. package/skills/dsh-ppt/scripts/deck-data.mjs +35 -5
  45. package/skills/dsh-ppt/scripts/deck-director.mjs +1717 -0
  46. package/skills/dsh-ppt/scripts/deck-layouts.mjs +4557 -0
  47. package/skills/dsh-ppt/scripts/deck-media.mjs +1408 -86
  48. package/skills/dsh-ppt/scripts/deck-themes.mjs +1503 -0
  49. package/skills/dsh-ppt/scripts/deck-visual.mjs +133 -31
@@ -0,0 +1,1503 @@
1
+ /**
2
+ * deck-themes.mjs —— dsh-ppt 的 18 套大师视觉主题、18 语义设计 Token、
3
+ * 6 套差异化母版骨架(Chrome Skeleton)、WCAG 对比度求解器、
4
+ * 外源 PPTX 主题净化器与跨平台零缺字字体映射系统。
5
+ *
6
+ * 零外部运行时依赖,仅使用 Node 内置模块。
7
+ */
8
+
9
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
10
+ import { resolve as resolvePath, join as joinPath } from 'node:path'
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // 色彩空间、WCAG 对比度与确定性净化数学工具
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export function normalizeHex(input, fallback = '#000000') {
17
+ const raw = String(input ?? '').trim().replace(/^#/, '')
18
+ if (/^[\da-fA-F]{3}$/.test(raw)) {
19
+ return '#' + raw.split('').map((c) => c + c).join('').toUpperCase()
20
+ }
21
+ if (/^[\da-fA-F]{6}$/.test(raw)) {
22
+ return '#' + raw.toUpperCase()
23
+ }
24
+ if (/^[\da-fA-F]{8}$/.test(raw)) {
25
+ return '#' + raw.slice(0, 6).toUpperCase()
26
+ }
27
+ return fallback.toUpperCase()
28
+ }
29
+
30
+ export function hexToRgb(hex) {
31
+ const clean = normalizeHex(hex).slice(1)
32
+ const num = Number.parseInt(clean, 16)
33
+ return {
34
+ r: (num >> 16) & 255,
35
+ g: (num >> 8) & 255,
36
+ b: num & 255,
37
+ }
38
+ }
39
+
40
+ export function rgbToHex(r, g, b) {
41
+ const clamp = (v) => Math.max(0, Math.min(255, Math.round(v)))
42
+ return '#' + [clamp(r), clamp(g), clamp(b)].map((v) => v.toString(16).padStart(2, '0')).join('').toUpperCase()
43
+ }
44
+
45
+ export function hexToRgba(hex, alpha) {
46
+ const { r, g, b } = hexToRgb(hex)
47
+ return 'rgba(' + r + ',' + g + ',' + b + ',' + alpha + ')'
48
+ }
49
+
50
+ export function rgbToHsl(r, g, b) {
51
+ const rn = r / 255
52
+ const gn = g / 255
53
+ const bn = b / 255
54
+ const max = Math.max(rn, gn, bn)
55
+ const min = Math.min(rn, gn, bn)
56
+ let h = 0
57
+ let s = 0
58
+ const l = (max + min) / 2
59
+ if (max !== min) {
60
+ const d = max - min
61
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
62
+ switch (max) {
63
+ case rn:
64
+ h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6
65
+ break
66
+ case gn:
67
+ h = ((bn - rn) / d + 2) / 6
68
+ break
69
+ default:
70
+ h = ((rn - gn) / d + 4) / 6
71
+ break
72
+ }
73
+ }
74
+ return { h: h * 360, s, l }
75
+ }
76
+
77
+ export function hslToRgb(h, s, l) {
78
+ const hn = (((h % 360) + 360) % 360) / 360
79
+ const sn = Math.max(0, Math.min(1, s))
80
+ const ln = Math.max(0, Math.min(1, l))
81
+ if (sn === 0) {
82
+ const v = Math.round(ln * 255)
83
+ return { r: v, g: v, b: v }
84
+ }
85
+ const hue2rgb = (p, q, t) => {
86
+ let tn = t
87
+ if (tn < 0) tn += 1
88
+ if (tn > 1) tn -= 1
89
+ if (tn < 1 / 6) return p + (q - p) * 6 * tn
90
+ if (tn < 1 / 2) return q
91
+ if (tn < 2 / 3) return p + (q - p) * (2 / 3 - tn) * 6
92
+ return p
93
+ }
94
+ const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn
95
+ const p = 2 * ln - q
96
+ return {
97
+ r: Math.round(hue2rgb(p, q, hn + 1 / 3) * 255),
98
+ g: Math.round(hue2rgb(p, q, hn) * 255),
99
+ b: Math.round(hue2rgb(p, q, hn - 1 / 3) * 255),
100
+ }
101
+ }
102
+
103
+ export function hexToHsl(hex) {
104
+ const { r, g, b } = hexToRgb(hex)
105
+ return rgbToHsl(r, g, b)
106
+ }
107
+
108
+ export function hslToHex(h, s, l) {
109
+ const { r, g, b } = hslToRgb(h, s, l)
110
+ return rgbToHex(r, g, b)
111
+ }
112
+
113
+ export function relativeLuminance(hex) {
114
+ const { r, g, b } = hexToRgb(hex)
115
+ const lin = (c) => {
116
+ const v = c / 255
117
+ return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
118
+ }
119
+ return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b)
120
+ }
121
+
122
+ export function contrastRatio(hexA, hexB) {
123
+ const la = relativeLuminance(hexA)
124
+ const lb = relativeLuminance(hexB)
125
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05)
126
+ }
127
+
128
+ export function mixHex(hexA, hexB, weightB = 0.5) {
129
+ const t = Math.max(0, Math.min(1, weightB))
130
+ const a = hexToRgb(hexA)
131
+ const b = hexToRgb(hexB)
132
+ return rgbToHex(
133
+ a.r * (1 - t) + b.r * t,
134
+ a.g * (1 - t) + b.g * t,
135
+ a.b * (1 - t) + b.b * t,
136
+ )
137
+ }
138
+
139
+ function adjustLightness(hex, deltaL) {
140
+ const { h, s, l } = hexToHsl(hex)
141
+ return hslToHex(h, s, Math.max(0, Math.min(1, l + deltaL)))
142
+ }
143
+
144
+ function clampHslColor(hex, { minL = 0, maxL = 1, maxS = 1 } = {}) {
145
+ const { h, s, l } = hexToHsl(hex)
146
+ return hslToHex(h, Math.min(s, maxS), Math.max(minL, Math.min(maxL, l)))
147
+ }
148
+
149
+ /**
150
+ * 16 步二分法对比度求解器:钳制过饱和荧光色并调整亮度直至满足 WCAG 目标对比度。
151
+ */
152
+ export function ensureContrast(hex, bgHex, minCR = 4.5, maxSaturation = 0.82) {
153
+ const bg = normalizeHex(bgHex, '#FFFFFF')
154
+ const start = normalizeHex(hex, '#0057B8')
155
+ const hsl = hexToHsl(start)
156
+ const cappedS = Math.min(hsl.s, maxSaturation)
157
+ const cappedHex = hslToHex(hsl.h, cappedS, hsl.l)
158
+ if (contrastRatio(cappedHex, bg) >= minCR) return cappedHex
159
+
160
+ const bgLum = relativeLuminance(bg)
161
+ const goDarker = bgLum >= 0.42
162
+ let low = goDarker ? 0 : hsl.l
163
+ let high = goDarker ? hsl.l : 1
164
+ let best = goDarker ? '#000000' : '#FFFFFF'
165
+ // Check whether target direction can reach minCR; if not, flip search direction
166
+ const extreme = hslToHex(hsl.h, cappedS, goDarker ? 0.02 : 0.98)
167
+ if (contrastRatio(extreme, bg) < minCR) {
168
+ return bgLum >= 0.42 ? '#0F172A' : '#F8FAFC'
169
+ }
170
+ best = extreme
171
+ for (let step = 0; step < 16; step += 1) {
172
+ const mid = (low + high) / 2
173
+ const candidate = hslToHex(hsl.h, cappedS, mid)
174
+ if (contrastRatio(candidate, bg) >= minCR) {
175
+ best = candidate
176
+ if (goDarker) low = mid
177
+ else high = mid
178
+ } else {
179
+ if (goDarker) high = mid
180
+ else low = mid
181
+ }
182
+ }
183
+ return best
184
+ }
185
+
186
+ function colorDistance(hexA, hexB) {
187
+ const a = hexToRgb(hexA)
188
+ const b = hexToRgb(hexB)
189
+ return Math.hypot(a.r - b.r, a.g - b.g, a.b - b.b)
190
+ }
191
+
192
+ function hueDelta(hexA, hexB) {
193
+ const ha = hexToHsl(hexA).h
194
+ const hb = hexToHsl(hexB).h
195
+ const diff = Math.abs(ha - hb) % 360
196
+ return diff > 180 ? 360 - diff : diff
197
+ }
198
+
199
+ // ---------------------------------------------------------------------------
200
+ // 跨平台安全字体栈与零缺字 PPTX 字体解析
201
+ // ---------------------------------------------------------------------------
202
+
203
+ const SANS_STACK = '"Inter", "Segoe UI", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif'
204
+ const GEOMETRIC_SANS_STACK = '"Avenir Next", "Segoe UI", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif'
205
+ const DISPLAY_SANS_STACK = '"Segoe UI", "Helvetica Neue", "Arial Black", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif'
206
+ const SERIF_HEADING_STACK = 'Georgia, "Times New Roman", "Songti SC", "Noto Serif CJK SC", "Microsoft YaHei", serif'
207
+
208
+ const BITMAP_SERIF_FONT_RE = /^(?:SimSun|NSimSun|宋体|新宋体|FangSong|仿宋)$/i
209
+ const NOVELTY_FONT_RE = /^(?:Impact|Comic Sans MS|Papyrus)$/i
210
+
211
+ export function pptxFontName(value, platform = process.platform) {
212
+ const names = String(value ?? '')
213
+ .split(',')
214
+ .map((name) => name.trim().replace(/^["']|["']$/g, ''))
215
+ .filter(Boolean)
216
+ if (names.length === 1 && !['serif', 'sans-serif', 'system-ui', 'monospace'].includes(names[0].toLowerCase())) {
217
+ const single = names[0]
218
+ if (BITMAP_SERIF_FONT_RE.test(single)) {
219
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'Songti SC' : 'Noto Serif CJK SC'
220
+ }
221
+ if (NOVELTY_FONT_RE.test(single) || /^(?:微软雅黑|黑体)$/i.test(single)) {
222
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'PingFang SC' : 'Noto Sans CJK SC'
223
+ }
224
+ if (platform === 'win32' && /^Songti SC$/i.test(single)) return 'Microsoft YaHei'
225
+ if (platform === 'linux' && /^(Microsoft YaHei|PingFang SC|Songti SC|Segoe UI|Helvetica Neue|Avenir Next)$/i.test(single)) {
226
+ return /Songti|Serif/i.test(single) ? 'Liberation Serif' : 'Liberation Sans'
227
+ }
228
+ return single
229
+ }
230
+ const available = platform === 'win32'
231
+ ? ['Segoe UI', 'Georgia', 'Arial', 'Arial Black', 'Calibri', 'Times New Roman', 'Microsoft YaHei']
232
+ : platform === 'darwin'
233
+ ? ['Helvetica Neue', 'Avenir Next', 'Georgia', 'Arial', 'Times New Roman', 'PingFang SC', 'Songti SC']
234
+ : ['Liberation Sans', 'Liberation Serif', 'Noto Sans', 'Noto Sans CJK SC', 'Noto Serif CJK SC']
235
+ const hit = names.find((name) => available.includes(name))
236
+ if (hit) return hit
237
+ const isSerif = names.some((n) => /serif|Georgia|Times/i.test(n) && !/sans-serif/i.test(n))
238
+ if (isSerif) return platform === 'linux' ? 'Liberation Serif' : 'Georgia'
239
+ return platform === 'win32' ? 'Segoe UI' : platform === 'darwin' ? 'Helvetica Neue' : 'Liberation Sans'
240
+ }
241
+
242
+ /**
243
+ * PPTX <a:ea> 东亚字体映射:
244
+ * - win32 统一优先使用矢量平滑的 Microsoft YaHei(避免 SimSun 大字号点阵锯齿,且避免 macOS 专属 Songti SC 缺字)
245
+ * - darwin 使用 PingFang SC / Songti SC
246
+ * - linux 使用 Noto Sans CJK SC / Noto Serif CJK SC
247
+ */
248
+ export function pptxEastAsianFont(value, platform = process.platform) {
249
+ const names = String(value ?? '')
250
+ .split(',')
251
+ .map((name) => name.trim().replace(/^["']|["']$/g, ''))
252
+ .filter(Boolean)
253
+ if (names.length === 1) {
254
+ const single = names[0]
255
+ if (BITMAP_SERIF_FONT_RE.test(single)) {
256
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'Songti SC' : 'Noto Serif CJK SC'
257
+ }
258
+ if (NOVELTY_FONT_RE.test(single) || /^(?:微软雅黑|黑体)$/i.test(single)) {
259
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'PingFang SC' : 'Noto Sans CJK SC'
260
+ }
261
+ if (platform === 'win32' && /^(Microsoft YaHei|SimHei|KaiTi)$/i.test(single)) return single
262
+ if (platform === 'darwin' && /^(PingFang SC|Songti SC|Heiti SC|Kaiti SC)$/i.test(single)) return single
263
+ if (platform === 'linux' && /^Noto (Sans|Serif) CJK SC$/i.test(single)) return single
264
+ }
265
+ const font = pptxFontName(value, platform)
266
+ const isSerif = /Georgia|Times New Roman|Cambria|Liberation Serif|Songti|Noto Serif/i.test(font) ||
267
+ names.some((n) => /^serif$/i.test(n))
268
+ if (platform === 'win32') return 'Microsoft YaHei'
269
+ if (platform === 'darwin') return isSerif ? 'Songti SC' : 'PingFang SC'
270
+ return isSerif ? 'Noto Serif CJK SC' : 'Noto Sans CJK SC'
271
+ }
272
+
273
+ // ---------------------------------------------------------------------------
274
+ // 6 套母版骨架(Chrome Skeleton)与 18 套内置大师主题定义(前 5 项兼容原顺序与色值)
275
+ // ---------------------------------------------------------------------------
276
+
277
+ export const CHROME_STYLES = Object.freeze([
278
+ 'consulting-classic',
279
+ 'keynote-spatial',
280
+ 'editorial-folio',
281
+ 'saas-bento',
282
+ 'academic-minimal',
283
+ 'gov-ceremonial',
284
+ ])
285
+
286
+ const CHROME_STYLE_SET = new Set(CHROME_STYLES)
287
+
288
+ export function resolveChromeStyle(theme, slide = null, brand = null) {
289
+ const candidates = [slide?.chrome, brand?.chromeStyle, theme?.chromeStyle]
290
+ for (const cand of candidates) {
291
+ if (typeof cand === 'string') {
292
+ const clean = cand.trim()
293
+ if (CHROME_STYLE_SET.has(clean)) return clean
294
+ }
295
+ }
296
+ return 'consulting-classic'
297
+ }
298
+
299
+ function makeTheme(spec) {
300
+ const {
301
+ id,
302
+ name,
303
+ mood,
304
+ bestFor,
305
+ persona,
306
+ dark,
307
+ palette,
308
+ tokens,
309
+ fonts,
310
+ radiusPx = 10,
311
+ shadow = !dark,
312
+ defaultTableStyle = 'consulting',
313
+ chromeStyle = 'saas-bento',
314
+ } = spec
315
+ const canvas = normalizeHex(tokens.canvas ?? palette.bg)
316
+ const surface1 = normalizeHex(tokens.surface1 ?? palette.panel)
317
+ const surface2 = normalizeHex(tokens.surface2 ?? (dark ? mixHex(surface1, '#FFFFFF', 0.06) : mixHex(surface1, '#0F172A', 0.05)))
318
+ const hairline = normalizeHex(tokens.hairline ?? (dark ? mixHex(canvas, '#FFFFFF', 0.16) : mixHex(canvas, '#0F172A', 0.14)))
319
+ const inkPrimary = normalizeHex(tokens.inkPrimary ?? palette.fg)
320
+ const inkSecondary = ensureContrast(tokens.inkSecondary ?? mixHex(inkPrimary, surface1, 0.24), surface1, 7.0)
321
+ const inkMuted = ensureContrast(tokens.inkMuted ?? palette.muted, surface1, 4.6)
322
+ const accentPrimary = normalizeHex(tokens.accentPrimary ?? palette.accent)
323
+ const accentText = ensureContrast(tokens.accentText ?? accentPrimary, surface1, 4.6)
324
+ const accentSecondary = normalizeHex(tokens.accentSecondary ?? palette.accent2)
325
+ const accent2Text = ensureContrast(tokens.accent2Text ?? accentSecondary, surface1, 4.6)
326
+ const inkOnAccent = normalizeHex(tokens.inkOnAccent ?? (relativeLuminance(accentPrimary) > 0.36 ? '#0F172A' : '#FFFFFF'))
327
+ const accentSoft = normalizeHex(tokens.accentSoft ?? mixHex(canvas, accentPrimary, dark ? 0.18 : 0.10))
328
+ const positive = normalizeHex(tokens.positive ?? ensureContrast(dark ? '#34D399' : '#0D7A4E', surface1, 4.5))
329
+ const negative = normalizeHex(tokens.negative ?? ensureContrast(dark ? '#F87171' : '#C81E1E', surface1, 4.5))
330
+ const warning = normalizeHex(tokens.warning ?? ensureContrast(dark ? '#FBBF24' : '#B45309', surface1, 4.5))
331
+ const chartFocal = normalizeHex(tokens.chartFocal ?? accentPrimary)
332
+ const chartNeutral = normalizeHex(tokens.chartNeutral ?? (dark ? '#2B354D' : '#CBD5E1'))
333
+ const chartSeries = (tokens.chartSeries ?? [accentPrimary, accentSecondary, '#0E7490', '#4F46E5', '#0D7A4E', '#64748B']).map((c) => normalizeHex(c))
334
+ const coverMode = tokens.coverMode ?? 'standard'
335
+ const coverBg = normalizeHex(tokens.coverBg ?? (coverMode === 'inverted-accent' ? accentPrimary : canvas))
336
+
337
+ return Object.freeze({
338
+ id,
339
+ name: Object.freeze(name),
340
+ mood: Object.freeze(mood),
341
+ bestFor: Object.freeze(bestFor),
342
+ persona: persona ?? 'consulting',
343
+ dark: Boolean(dark),
344
+ radiusPx,
345
+ shadow: Boolean(shadow),
346
+ defaultTableStyle,
347
+ chromeStyle,
348
+ palette: Object.freeze({
349
+ bg: normalizeHex(palette.bg),
350
+ panel: normalizeHex(palette.panel),
351
+ fg: normalizeHex(palette.fg),
352
+ muted: normalizeHex(palette.muted),
353
+ accent: normalizeHex(palette.accent),
354
+ accent2: normalizeHex(palette.accent2),
355
+ }),
356
+ tokens: Object.freeze({
357
+ canvas,
358
+ surface1,
359
+ surface2,
360
+ hairline,
361
+ inkPrimary,
362
+ inkSecondary,
363
+ inkMuted,
364
+ inkOnAccent,
365
+ accentPrimary,
366
+ accentText,
367
+ accentSecondary,
368
+ accent2Text,
369
+ accentSoft,
370
+ positive,
371
+ negative,
372
+ warning,
373
+ chartFocal,
374
+ chartNeutral,
375
+ chartSeries: Object.freeze(chartSeries),
376
+ coverMode,
377
+ coverBg,
378
+ }),
379
+ fonts: Object.freeze(fonts),
380
+ })
381
+ }
382
+
383
+ export const THEMES = {
384
+ // 0..4: Legacy 5 themes (exact order & exact palette hexes preserved for zero regression)
385
+ swiss: makeTheme({
386
+ id: 'swiss',
387
+ name: { zh: '瑞士脉冲', en: 'Swiss Pulse' },
388
+ mood: { zh: '精准、理性、数据', en: 'Precise, rational, data-driven' },
389
+ bestFor: { zh: 'SaaS、数据、开发者工具', en: 'SaaS, data, developer tools' },
390
+ persona: 'tech-pitch',
391
+ dark: true,
392
+ radiusPx: 8,
393
+ shadow: false,
394
+ chromeStyle: 'saas-bento',
395
+ palette: {
396
+ bg: '#10151B',
397
+ panel: '#161D26',
398
+ fg: '#F5F7FA',
399
+ muted: '#8E9AAA',
400
+ accent: '#2F6BFF',
401
+ accent2: '#FFB300',
402
+ },
403
+ tokens: {
404
+ canvas: '#10151B',
405
+ surface1: '#161D26',
406
+ surface2: '#1E2835',
407
+ hairline: '#293646',
408
+ inkPrimary: '#F5F7FA',
409
+ inkSecondary: '#C2CCD8',
410
+ inkMuted: '#8E9AAA',
411
+ accentPrimary: '#2F6BFF',
412
+ accentText: '#6B9BFF',
413
+ accentSecondary: '#FFB300',
414
+ accent2Text: '#FFC233',
415
+ chartNeutral: '#2A3748',
416
+ chartSeries: ['#2F6BFF', '#FFB300', '#22D3EE', '#34D399', '#F87171', '#94A3B8'],
417
+ },
418
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
419
+ }),
420
+ velvet: makeTheme({
421
+ id: 'velvet',
422
+ name: { zh: '天鹅绒标准', en: 'Velvet Standard' },
423
+ mood: { zh: '高级、克制、可信', en: 'Premium, restrained, trustworthy' },
424
+ bestFor: { zh: '高管汇报、品牌、融资路演', en: 'Executive decks, brand, investor pitches' },
425
+ persona: 'editorial',
426
+ dark: true,
427
+ radiusPx: 8,
428
+ shadow: false,
429
+ chromeStyle: 'editorial-folio',
430
+ palette: {
431
+ bg: '#111316',
432
+ panel: '#1A1D22',
433
+ fg: '#F4EFE6',
434
+ muted: '#A79F91',
435
+ accent: '#C9A84C',
436
+ accent2: '#3D4A63',
437
+ },
438
+ tokens: {
439
+ canvas: '#111316',
440
+ surface1: '#1A1D22',
441
+ surface2: '#23272F',
442
+ hairline: '#2F3540',
443
+ inkPrimary: '#F4EFE6',
444
+ inkSecondary: '#CEC6B8',
445
+ inkMuted: '#A79F91',
446
+ accentPrimary: '#C9A84C',
447
+ accentText: '#D6B862',
448
+ accentSecondary: '#3D4A63',
449
+ accent2Text: '#8FA5C7',
450
+ chartNeutral: '#323842',
451
+ chartSeries: ['#C9A84C', '#6C82A6', '#C87D65', '#6D9B87', '#9B8EC4', '#8A847C'],
452
+ },
453
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
454
+ }),
455
+ data: makeTheme({
456
+ id: 'data',
457
+ name: { zh: '数据漂移', en: 'Data Drift' },
458
+ mood: { zh: '未来、沉浸、前沿', en: 'Futuristic, immersive, cutting-edge' },
459
+ bestFor: { zh: 'AI、数据、研究、技术发布', en: 'AI, data, research, tech launches' },
460
+ persona: 'tech-pitch',
461
+ dark: true,
462
+ radiusPx: 10,
463
+ shadow: false,
464
+ chromeStyle: 'saas-bento',
465
+ palette: {
466
+ bg: '#070B14',
467
+ panel: '#0D1424',
468
+ fg: '#E8F1FF',
469
+ muted: '#7E8BA8',
470
+ accent: '#7C3AED',
471
+ accent2: '#06B6D4',
472
+ },
473
+ tokens: {
474
+ canvas: '#070B14',
475
+ surface1: '#0D1424',
476
+ surface2: '#152038',
477
+ hairline: '#233252',
478
+ inkPrimary: '#E8F1FF',
479
+ inkSecondary: '#B5C5E0',
480
+ inkMuted: '#8896B5',
481
+ accentPrimary: '#7C3AED',
482
+ accentText: '#A78BFA',
483
+ accentSecondary: '#06B6D4',
484
+ accent2Text: '#22D3EE',
485
+ chartNeutral: '#253453',
486
+ chartSeries: ['#7C3AED', '#06B6D4', '#60A5FA', '#34D399', '#F472B6', '#818CF8'],
487
+ },
488
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
489
+ }),
490
+ soft: makeTheme({
491
+ id: 'soft',
492
+ name: { zh: '柔和信号', en: 'Soft Signal' },
493
+ mood: { zh: '温暖、亲近、人本', en: 'Warm, intimate, human' },
494
+ bestFor: { zh: '品牌故事、培训、个人分享', en: 'Brand stories, training, personal talks' },
495
+ persona: 'education',
496
+ dark: false,
497
+ radiusPx: 12,
498
+ shadow: true,
499
+ chromeStyle: 'saas-bento',
500
+ palette: {
501
+ bg: '#FFF8EC',
502
+ panel: '#FFF2DE',
503
+ fg: '#3B2F2A',
504
+ muted: '#7E6F68',
505
+ accent: '#E58A2F',
506
+ accent2: '#8FAF8C',
507
+ },
508
+ tokens: {
509
+ canvas: '#FFF8EC',
510
+ surface1: '#F7EEDF',
511
+ surface2: '#EFE2CE',
512
+ hairline: '#DED0BC',
513
+ inkPrimary: '#3B2F2A',
514
+ inkSecondary: '#54453E',
515
+ inkMuted: '#6E5E57',
516
+ accentPrimary: '#E58A2F',
517
+ accentText: '#B35309',
518
+ accentSecondary: '#8FAF8C',
519
+ accent2Text: '#3E6644',
520
+ chartNeutral: '#D8CBB8',
521
+ chartSeries: ['#C86419', '#4D7358', '#2B5B84', '#9A3B26', '#7A5C3E', '#7D746D'],
522
+ },
523
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: GEOMETRIC_SANS_STACK },
524
+ }),
525
+ bold: makeTheme({
526
+ id: 'bold',
527
+ name: { zh: '极繁大字', en: 'Maximalist Type' },
528
+ mood: { zh: '大声、动能、发布', en: 'Loud, kinetic, launch' },
529
+ bestFor: { zh: '产品发布、活动、品牌大事件', en: 'Product launches, events, brand moments' },
530
+ persona: 'tech-pitch',
531
+ dark: true,
532
+ radiusPx: 6,
533
+ shadow: false,
534
+ chromeStyle: 'keynote-spatial',
535
+ palette: {
536
+ bg: '#0D0D0D',
537
+ panel: '#181818',
538
+ fg: '#FFFFFF',
539
+ muted: '#B8B8B8',
540
+ accent: '#E63946',
541
+ accent2: '#FFD60A',
542
+ },
543
+ tokens: {
544
+ canvas: '#0D0D0D',
545
+ surface1: '#181818',
546
+ surface2: '#222226',
547
+ hairline: '#303036',
548
+ inkPrimary: '#FFFFFF',
549
+ inkSecondary: '#D4D4D8',
550
+ inkMuted: '#A1A1AA',
551
+ accentPrimary: '#E63946',
552
+ accentText: '#FF6B76',
553
+ accentSecondary: '#FFD60A',
554
+ accent2Text: '#FFD60A',
555
+ chartNeutral: '#32323A',
556
+ chartSeries: ['#E63946', '#FFD60A', '#38BDF8', '#34D399', '#A855F7', '#71717A'],
557
+ },
558
+ fonts: { heading: DISPLAY_SANS_STACK, body: SANS_STACK },
559
+ }),
560
+
561
+ // 5..13: 9 High-Taste Daylight & Persona Signature Themes
562
+ consulting: makeTheme({
563
+ id: 'consulting',
564
+ name: { zh: '蔚蓝战略', en: 'Strategy Navy' },
565
+ mood: { zh: '权威、清晰、高管决策', en: 'Authoritative, crisp, executive strategy' },
566
+ bestFor: { zh: '管理咨询、商业分析、经营汇报、项目复盘', en: 'Consulting, business reviews, strategy decks' },
567
+ persona: 'consulting',
568
+ dark: false,
569
+ radiusPx: 8,
570
+ shadow: false,
571
+ defaultTableStyle: 'consulting',
572
+ chromeStyle: 'consulting-classic',
573
+ palette: {
574
+ bg: '#FFFFFF',
575
+ panel: '#F4F6F9',
576
+ fg: '#0F172A',
577
+ muted: '#5B6B82',
578
+ accent: '#0057B8',
579
+ accent2: '#0E7490',
580
+ },
581
+ tokens: {
582
+ canvas: '#FFFFFF',
583
+ surface1: '#F4F6F9',
584
+ surface2: '#E9EEF5',
585
+ hairline: '#D5DFEC',
586
+ inkPrimary: '#0F172A',
587
+ inkSecondary: '#334155',
588
+ inkMuted: '#5B6B82',
589
+ accentPrimary: '#0057B8',
590
+ accentText: '#004C9E',
591
+ accentSecondary: '#0E7490',
592
+ accent2Text: '#0C637B',
593
+ chartNeutral: '#CBD5E1',
594
+ chartSeries: ['#0057B8', '#0E7490', '#1E293B', '#4F46E5', '#0D7A4E', '#64748B'],
595
+ },
596
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
597
+ }),
598
+ 'cobalt-cream': makeTheme({
599
+ id: 'cobalt-cream',
600
+ name: { zh: '钴蓝简报', en: 'Blue Professional' },
601
+ mood: { zh: '理性纸感、现代简报、零阴影', en: 'Warm paper, crisp cobalt, zero-shadow precision' },
602
+ bestFor: { zh: '产品方案、B2B提案、研究简报、技术方案', en: 'B2B proposals, product briefs, research memos' },
603
+ persona: 'consulting',
604
+ dark: false,
605
+ radiusPx: 8,
606
+ shadow: false,
607
+ chromeStyle: 'consulting-classic',
608
+ palette: {
609
+ bg: '#FDFAE7',
610
+ panel: '#F3F1E8',
611
+ fg: '#111111',
612
+ muted: '#5C5B55',
613
+ accent: '#1E2BFA',
614
+ accent2: '#0F6E56',
615
+ },
616
+ tokens: {
617
+ canvas: '#FDFAE7',
618
+ surface1: '#F3F1E8',
619
+ surface2: '#E8E6DC',
620
+ hairline: '#D0D0EC',
621
+ inkPrimary: '#111111',
622
+ inkSecondary: '#363632',
623
+ inkMuted: '#5C5B55',
624
+ accentPrimary: '#1E2BFA',
625
+ accentText: '#1A25D9',
626
+ accentSecondary: '#0F6E56',
627
+ accent2Text: '#0D5E49',
628
+ chartNeutral: '#CFCBC0',
629
+ chartSeries: ['#1E2BFA', '#0F6E56', '#1E293B', '#B45309', '#9A3B26', '#64748B'],
630
+ },
631
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
632
+ }),
633
+ 'exec-jilan': makeTheme({
634
+ id: 'exec-jilan',
635
+ name: { zh: '霁蓝政务', en: 'Imperial Slate' },
636
+ mood: { zh: '庄重、稳健、现代东方政务', en: 'Dignified, composed, modern institutional' },
637
+ bestFor: { zh: '政企汇报、年度总结、述职报告、专项规划', en: 'Institutional reports, annual reviews, executive briefings' },
638
+ persona: 'gov-exec',
639
+ dark: false,
640
+ radiusPx: 6,
641
+ shadow: false,
642
+ chromeStyle: 'gov-ceremonial',
643
+ palette: {
644
+ bg: '#F7F6F2',
645
+ panel: '#EFECE6',
646
+ fg: '#16243E',
647
+ muted: '#5F6C80',
648
+ accent: '#1A2B4C',
649
+ accent2: '#9E1B1E',
650
+ },
651
+ tokens: {
652
+ canvas: '#F7F6F2',
653
+ surface1: '#EFECE6',
654
+ surface2: '#E5E0D5',
655
+ hairline: '#D4CEC3',
656
+ inkPrimary: '#16243E',
657
+ inkSecondary: '#3A4963',
658
+ inkMuted: '#5F6C80',
659
+ accentPrimary: '#1A2B4C',
660
+ accentText: '#1A2B4C',
661
+ accentSecondary: '#9E1B1E',
662
+ accent2Text: '#9E1B1E',
663
+ chartNeutral: '#C8C3B8',
664
+ chartSeries: ['#1A2B4C', '#9E1B1E', '#2B5B84', '#8C6508', '#3D6B5E', '#7A869A'],
665
+ coverMode: 'inverted-accent',
666
+ coverBg: '#1A2B4C',
667
+ },
668
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
669
+ }),
670
+ 'exec-palace': makeTheme({
671
+ id: 'exec-palace',
672
+ name: { zh: '故宫丹宸', en: 'Palace Vermilion' },
673
+ mood: { zh: '典雅庄严、丹红金线、宣纸浅底', en: 'Ceremonial vermilion cover with warm rice-paper body' },
674
+ bestFor: { zh: '党建述职、重大表彰、文化工程、庆典汇报', en: 'Keynote ceremonies, cultural & institutional milestones' },
675
+ persona: 'gov-exec',
676
+ dark: false,
677
+ radiusPx: 6,
678
+ shadow: false,
679
+ chromeStyle: 'gov-ceremonial',
680
+ palette: {
681
+ bg: '#F9F6F1',
682
+ panel: '#F1ECE3',
683
+ fg: '#231916',
684
+ muted: '#6E5D56',
685
+ accent: '#9E1B1E',
686
+ accent2: '#8A6826',
687
+ },
688
+ tokens: {
689
+ canvas: '#F9F6F1',
690
+ surface1: '#F1ECE3',
691
+ surface2: '#E7DFD3',
692
+ hairline: '#D8CEBE',
693
+ inkPrimary: '#231916',
694
+ inkSecondary: '#4A3B36',
695
+ inkMuted: '#6E5D56',
696
+ accentPrimary: '#9E1B1E',
697
+ accentText: '#8E171A',
698
+ accentSecondary: '#8A6826',
699
+ accent2Text: '#75571E',
700
+ chartNeutral: '#CFC6BA',
701
+ chartSeries: ['#9E1B1E', '#2C4A63', '#8A6826', '#4E6E5D', '#5C4B51', '#8C7B70'],
702
+ coverMode: 'inverted-accent',
703
+ coverBg: '#9E1B1E',
704
+ },
705
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
706
+ }),
707
+ academic: makeTheme({
708
+ id: 'academic',
709
+ name: { zh: '清澄学术', en: 'ETH & Nature' },
710
+ mood: { zh: '严谨、清澈、出版级学术规范', en: 'Rigorous, high-clarity, publication-grade' },
711
+ bestFor: { zh: '论文答辩、开题报告、学术会议、科研组会', en: 'Thesis defense, academic talks, research seminars' },
712
+ persona: 'academic',
713
+ dark: false,
714
+ radiusPx: 6,
715
+ shadow: false,
716
+ defaultTableStyle: 'booktabs',
717
+ chromeStyle: 'academic-minimal',
718
+ palette: {
719
+ bg: '#FFFFFF',
720
+ panel: '#F5F7FA',
721
+ fg: '#111827',
722
+ muted: '#596577',
723
+ accent: '#006980',
724
+ accent2: '#C8430E',
725
+ },
726
+ tokens: {
727
+ canvas: '#FFFFFF',
728
+ surface1: '#F5F7FA',
729
+ surface2: '#EBF0F5',
730
+ hairline: '#CBD5E1',
731
+ inkPrimary: '#111827',
732
+ inkSecondary: '#374151',
733
+ inkMuted: '#596577',
734
+ accentPrimary: '#006980',
735
+ accentText: '#005A6E',
736
+ accentSecondary: '#C8430E',
737
+ accent2Text: '#B23A0B',
738
+ chartNeutral: '#CBD5E1',
739
+ chartSeries: ['#006980', '#C8430E', '#1E3A8A', '#2E7D32', '#6D28D9', '#52525B'],
740
+ },
741
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
742
+ }),
743
+ 'editorial-forest': makeTheme({
744
+ id: 'editorial-forest',
745
+ name: { zh: '森系社论', en: 'Editorial Forest' },
746
+ mood: { zh: '人文杂志、衬线留白、沉静质感', en: 'Editorial serif, organic calm, generous whitespace' },
747
+ bestFor: { zh: '品牌提案、文化策展、ESG报告、深度叙事', en: 'Brand strategy, ESG reports, cultural curation' },
748
+ persona: 'editorial',
749
+ dark: false,
750
+ radiusPx: 8,
751
+ shadow: false,
752
+ chromeStyle: 'editorial-folio',
753
+ palette: {
754
+ bg: '#F4EFE4',
755
+ panel: '#EAE2D3',
756
+ fg: '#1A1A17',
757
+ muted: '#615E55',
758
+ accent: '#2E4A2A',
759
+ accent2: '#A64B67',
760
+ },
761
+ tokens: {
762
+ canvas: '#F4EFE4',
763
+ surface1: '#EAE2D3',
764
+ surface2: '#DFD5C3',
765
+ hairline: '#C5BCAA',
766
+ inkPrimary: '#1A1A17',
767
+ inkSecondary: '#3F3E38',
768
+ inkMuted: '#615E55',
769
+ accentPrimary: '#2E4A2A',
770
+ accentText: '#263E23',
771
+ accentSecondary: '#E89CB1',
772
+ accent2Text: '#9C3F5B',
773
+ chartNeutral: '#C9C0AE',
774
+ chartSeries: ['#2E4A2A', '#9C3F5B', '#2D4A5E', '#8C6239', '#556B52', '#7A756B'],
775
+ },
776
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
777
+ }),
778
+ cartesian: makeTheme({
779
+ id: 'cartesian',
780
+ name: { zh: '暖石极简', en: 'Cartesian Stone' },
781
+ mood: { zh: '建筑网格、0圆角锋利线条、克制优雅', en: 'Architectural hairline grid, zero-radius minimalism' },
782
+ bestFor: { zh: '设计提案、建筑作品集、高端零售、战略宣言', en: 'Design portfolios, architecture, luxury & manifesto decks' },
783
+ persona: 'editorial',
784
+ dark: false,
785
+ radiusPx: 0,
786
+ shadow: false,
787
+ defaultTableStyle: 'minimal',
788
+ chromeStyle: 'editorial-folio',
789
+ palette: {
790
+ bg: '#F5F1EB',
791
+ panel: '#EAE4DB',
792
+ fg: '#1A1A1A',
793
+ muted: '#635E57',
794
+ accent: '#734B2F',
795
+ accent2: '#2F4F4F',
796
+ },
797
+ tokens: {
798
+ canvas: '#F5F1EB',
799
+ surface1: '#EAE4DB',
800
+ surface2: '#DFD7CB',
801
+ hairline: '#B8B0A4',
802
+ inkPrimary: '#1A1A1A',
803
+ inkSecondary: '#403D39',
804
+ inkMuted: '#635E57',
805
+ accentPrimary: '#734B2F',
806
+ accentText: '#664128',
807
+ accentSecondary: '#2F4F4F',
808
+ accent2Text: '#284545',
809
+ chartNeutral: '#C9C1B6',
810
+ chartSeries: ['#734B2F', '#2F4F4F', '#8C6239', '#4A5D73', '#5E5063', '#7D776D'],
811
+ },
812
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
813
+ }),
814
+ 'course-sage': makeTheme({
815
+ id: 'course-sage',
816
+ name: { zh: '知行讲义', en: 'Workshop Sage' },
817
+ mood: { zh: '清晰易读、护眼低眩光、循序渐进', en: 'Low-glare clarity, structured learning progression' },
818
+ bestFor: { zh: '教学课件、企业内训、工作坊、科普分享', en: 'Courseware, corporate training, workshops, tutorials' },
819
+ persona: 'education',
820
+ dark: false,
821
+ radiusPx: 10,
822
+ shadow: false,
823
+ chromeStyle: 'academic-minimal',
824
+ palette: {
825
+ bg: '#FAFBF9',
826
+ panel: '#F0F4F1',
827
+ fg: '#182420',
828
+ muted: '#5A6F67',
829
+ accent: '#0F6E56',
830
+ accent2: '#B45309',
831
+ },
832
+ tokens: {
833
+ canvas: '#FAFBF9',
834
+ surface1: '#F0F4F1',
835
+ surface2: '#E3EBE6',
836
+ hairline: '#C8D6CE',
837
+ inkPrimary: '#182420',
838
+ inkSecondary: '#384B44',
839
+ inkMuted: '#5A6F67',
840
+ accentPrimary: '#0F6E56',
841
+ accentText: '#0C5C47',
842
+ accentSecondary: '#B45309',
843
+ accent2Text: '#9A4607',
844
+ chartNeutral: '#CBD8D1',
845
+ chartSeries: ['#0F6E56', '#B45309', '#1D4ED8', '#7C3AED', '#BE123C', '#576B63'],
846
+ },
847
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: GEOMETRIC_SANS_STACK },
848
+ }),
849
+ 'linear-dark': makeTheme({
850
+ id: 'linear-dark',
851
+ name: { zh: '黑曜石路演', en: 'Obsidian Keynote' },
852
+ mood: { zh: '1px微描边层级、Apple/Linear式科技质感', en: 'Keynote dark elevation, crisp 1px hairlines' },
853
+ bestFor: { zh: '科技发布会、AI产品路演、融资Deck、开发者大会', en: 'Product keynotes, AI launches, VC pitch decks' },
854
+ persona: 'tech-pitch',
855
+ dark: true,
856
+ radiusPx: 12,
857
+ shadow: false,
858
+ chromeStyle: 'saas-bento',
859
+ palette: {
860
+ bg: '#090B10',
861
+ panel: '#11151F',
862
+ fg: '#F3F6FC',
863
+ muted: '#8A96AC',
864
+ accent: '#5E81F4',
865
+ accent2: '#38BDF8',
866
+ },
867
+ tokens: {
868
+ canvas: '#090B10',
869
+ surface1: '#11151F',
870
+ surface2: '#181E2C',
871
+ hairline: '#232B3E',
872
+ inkPrimary: '#F3F6FC',
873
+ inkSecondary: '#B8C2D4',
874
+ inkMuted: '#8A96AC',
875
+ accentPrimary: '#5E81F4',
876
+ accentText: '#7C9BFF',
877
+ accentSecondary: '#38BDF8',
878
+ accent2Text: '#38BDF8',
879
+ chartNeutral: '#2B354D',
880
+ chartSeries: ['#5E81F4', '#38BDF8', '#A78BFA', '#34D399', '#FBBF24', '#64748B'],
881
+ },
882
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
883
+ }),
884
+
885
+ // 14..17: 4 Signature World-Class Themes (Keynote, FT Financial, Clinical Medical, Luxury Noir)
886
+ 'keynote-light': makeTheme({
887
+ id: 'keynote-light',
888
+ name: { zh: '苹果极简白', en: 'Keynote Spatial Light' },
889
+ mood: { zh: 'Apple空间留白、无框空气感、极致纯净', en: 'Apple spatial whitespace, borderless purity, airy clarity' },
890
+ bestFor: { zh: '旗舰产品发布、设计哲学演讲、高管主题演讲', en: 'Flagship launches, design keynotes, executive talks' },
891
+ persona: 'tech-pitch',
892
+ dark: false,
893
+ radiusPx: 16,
894
+ shadow: false,
895
+ chromeStyle: 'keynote-spatial',
896
+ palette: {
897
+ bg: '#FFFFFF',
898
+ panel: '#F5F5F7',
899
+ fg: '#1D1D1F',
900
+ muted: '#6E6E73',
901
+ accent: '#0066CC',
902
+ accent2: '#5E5CE6',
903
+ },
904
+ tokens: {
905
+ canvas: '#FFFFFF',
906
+ surface1: '#F5F5F7',
907
+ surface2: '#EAEAEF',
908
+ hairline: '#D2D2D7',
909
+ inkPrimary: '#1D1D1F',
910
+ inkSecondary: '#424245',
911
+ inkMuted: '#6E6E73',
912
+ accentPrimary: '#0066CC',
913
+ accentText: '#0055B3',
914
+ accentSecondary: '#5E5CE6',
915
+ accent2Text: '#4947C2',
916
+ chartNeutral: '#D2D2D7',
917
+ chartSeries: ['#0066CC', '#5E5CE6', '#0F766E', '#D97706', '#DC2626', '#6E6E73'],
918
+ },
919
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: SANS_STACK },
920
+ }),
921
+ 'financial-ft': makeTheme({
922
+ id: 'financial-ft',
923
+ name: { zh: '金融时报粉', en: 'FT Salmon Financial' },
924
+ mood: { zh: '财经权威纸感、锋利直角、深海蓝与酒红双色', en: 'FT salmon paper authority, sharp corners, deep teal & claret' },
925
+ bestFor: { zh: '季度财报、投行路演、宏观研究、CFO经营复盘', en: 'Earnings decks, investment banking, macro research, CFO reviews' },
926
+ persona: 'consulting',
927
+ dark: false,
928
+ radiusPx: 0,
929
+ shadow: false,
930
+ defaultTableStyle: 'consulting',
931
+ chromeStyle: 'consulting-classic',
932
+ palette: {
933
+ bg: '#FFF1E5',
934
+ panel: '#F6E3D2',
935
+ fg: '#1A1817',
936
+ muted: '#5F544C',
937
+ accent: '#0D3D56',
938
+ accent2: '#990F3D',
939
+ },
940
+ tokens: {
941
+ canvas: '#FFF1E5',
942
+ surface1: '#F6E3D2',
943
+ surface2: '#ECD3BE',
944
+ hairline: '#D8BFA9',
945
+ inkPrimary: '#1A1817',
946
+ inkSecondary: '#3E3834',
947
+ inkMuted: '#5F544C',
948
+ accentPrimary: '#0D3D56',
949
+ accentText: '#0D3D56',
950
+ accentSecondary: '#990F3D',
951
+ accent2Text: '#990F3D',
952
+ chartNeutral: '#D2BAA5',
953
+ chartSeries: ['#0D3D56', '#990F3D', '#0F766E', '#B45309', '#4F46E5', '#6B5E54'],
954
+ },
955
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
956
+ }),
957
+ 'medical-clean': makeTheme({
958
+ id: 'medical-clean',
959
+ name: { zh: '循证医学蓝绿', en: 'Clinical Evidence Teal' },
960
+ mood: { zh: '高洁净临床严谨感、蓝绿理性配色、三线表规范', en: 'Clinical precision, antiseptic clarity, publication-grade rigor' },
961
+ bestFor: { zh: '医学病例汇报、临床试验、生物医药路演、科研进展', en: 'Clinical cases, biomedical trials, healthcare research' },
962
+ persona: 'academic',
963
+ dark: false,
964
+ radiusPx: 8,
965
+ shadow: false,
966
+ defaultTableStyle: 'booktabs',
967
+ chromeStyle: 'academic-minimal',
968
+ palette: {
969
+ bg: '#F8FAFC',
970
+ panel: '#EEF5F7',
971
+ fg: '#0F172A',
972
+ muted: '#526478',
973
+ accent: '#0F766E',
974
+ accent2: '#0284C7',
975
+ },
976
+ tokens: {
977
+ canvas: '#F8FAFC',
978
+ surface1: '#EEF5F7',
979
+ surface2: '#E1ECEF',
980
+ hairline: '#CBD8DE',
981
+ inkPrimary: '#0F172A',
982
+ inkSecondary: '#334155',
983
+ inkMuted: '#526478',
984
+ accentPrimary: '#0F766E',
985
+ accentText: '#0D665F',
986
+ accentSecondary: '#0284C7',
987
+ accent2Text: '#0369A1',
988
+ chartNeutral: '#CBD5E1',
989
+ chartSeries: ['#0F766E', '#0284C7', '#1E3A8A', '#B45309', '#BE123C', '#64748B'],
990
+ },
991
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
992
+ }),
993
+ 'luxury-noir': makeTheme({
994
+ id: 'luxury-noir',
995
+ name: { zh: '黑金典藏', en: 'Luxury Noir Gold' },
996
+ mood: { zh: '黑金杂志书脊、衬线排印、高奢品牌与白皮书', en: 'Noir gold editorial folio, serif authority, luxury lookbook' },
997
+ bestFor: { zh: '高奢品牌画册、创意作品集、年度白皮书、高端峰会', en: 'Luxury lookbooks, creative portfolios, flagship annual books' },
998
+ persona: 'editorial',
999
+ dark: true,
1000
+ radiusPx: 0,
1001
+ shadow: false,
1002
+ defaultTableStyle: 'minimal',
1003
+ chromeStyle: 'editorial-folio',
1004
+ palette: {
1005
+ bg: '#0B0B0D',
1006
+ panel: '#151519',
1007
+ fg: '#F5F2EB',
1008
+ muted: '#A09A8E',
1009
+ accent: '#D4AF37',
1010
+ accent2: '#8FA3BF',
1011
+ },
1012
+ tokens: {
1013
+ canvas: '#0B0B0D',
1014
+ surface1: '#151519',
1015
+ surface2: '#1F1F26',
1016
+ hairline: '#2D2C33',
1017
+ inkPrimary: '#F5F2EB',
1018
+ inkSecondary: '#D2CCC0',
1019
+ inkMuted: '#A09A8E',
1020
+ accentPrimary: '#D4AF37',
1021
+ accentText: '#E0BE4C',
1022
+ accentSecondary: '#8FA3BF',
1023
+ accent2Text: '#9EB3CF',
1024
+ chartNeutral: '#2C2C34',
1025
+ chartSeries: ['#D4AF37', '#8FA3BF', '#C87D65', '#6D9B87', '#B695C0', '#8A847C'],
1026
+ },
1027
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
1028
+ }),
1029
+ }
1030
+
1031
+ export const THEME_IDS = Object.keys(THEMES)
1032
+ export const DEFAULT_THEME = 'data'
1033
+ export const SMART_DEFAULT_THEME = 'consulting'
1034
+
1035
+ export function resolveTheme(input) {
1036
+ if (input && typeof input === 'object' && input.palette && input.tokens) return input
1037
+ const raw = String(input ?? DEFAULT_THEME).trim().toLowerCase()
1038
+ const id = raw === '' || raw === 'auto' ? (raw === 'auto' ? SMART_DEFAULT_THEME : DEFAULT_THEME) : raw
1039
+ const theme = THEMES[id]
1040
+ if (!theme) {
1041
+ throw new Error('dsh-ppt:未知主题 "' + id + '",可选:' + THEME_IDS.join(' / ') + '(默认 ' + DEFAULT_THEME + ')')
1042
+ }
1043
+ return theme
1044
+ }
1045
+
1046
+ export function listThemes(lang = 'zh') {
1047
+ const pick = (pair) => (lang === 'en' ? pair.en : pair.zh)
1048
+ return THEME_IDS.map((id) => {
1049
+ const theme = THEMES[id]
1050
+ return {
1051
+ id,
1052
+ name: pick(theme.name),
1053
+ mood: pick(theme.mood),
1054
+ bestFor: pick(theme.bestFor),
1055
+ persona: theme.persona,
1056
+ dark: theme.dark,
1057
+ radiusPx: theme.radiusPx,
1058
+ defaultTableStyle: theme.defaultTableStyle,
1059
+ chromeStyle: theme.chromeStyle,
1060
+ palette: { ...theme.palette },
1061
+ tokens: { ...theme.tokens, chartSeries: [...theme.tokens.chartSeries] },
1062
+ fonts: { ...theme.fonts },
1063
+ }
1064
+ })
1065
+ }
1066
+
1067
+ // ---------------------------------------------------------------------------
1068
+ // 外源 PPTX 主题净化器 sanitizeAbsorbedTheme() 与品牌色派生器 deriveBrandedTheme()
1069
+ // ---------------------------------------------------------------------------
1070
+
1071
+ const OKABE_ITO_FALLBACKS = ['#0057B8', '#C8430E', '#0F6E56', '#7C3AED', '#B45309', '#475569']
1072
+
1073
+ /**
1074
+ * 将任意提取出的外部 .pptx 色板与字体净化为满足 WCAG 对比度与审美约束的 18-Token 主题配置。
1075
+ * 自动处理高饱和企业红/蓝底母版(降级为深色庄重封面 + 明亮正文画布)。
1076
+ */
1077
+ export function sanitizeAbsorbedTheme(raw = {}) {
1078
+ const warnings = []
1079
+ const srcPalette = raw.palette ?? raw.theme ?? raw
1080
+ const srcFonts = raw.fonts ?? raw
1081
+
1082
+ const rawBgCandidate = raw.contentSlideBg ?? raw.backgroundColor ?? raw.masterBg ?? srcPalette.bg ?? srcPalette.light1 ?? '#FFFFFF'
1083
+ const rawBg = normalizeHex(rawBgCandidate, '#FFFFFF')
1084
+ const bgHsl = hexToHsl(rawBg)
1085
+ const bgLum = relativeLuminance(rawBg)
1086
+
1087
+ let dark = false
1088
+ let canvas = rawBg
1089
+ let coverMode = 'standard'
1090
+ let coverBg = rawBg
1091
+
1092
+ // 高饱和度母版背景自动降级(如 #FF0000 刺眼大红底或高饱和蓝底)
1093
+ if (bgHsl.s > 0.35 && bgLum > 0.06 && bgLum < 0.78) {
1094
+ coverMode = 'inverted-accent'
1095
+ coverBg = hslToHex(bgHsl.h, Math.min(bgHsl.s, 0.76), Math.max(0.14, Math.min(0.22, bgHsl.l * 0.42)))
1096
+ canvas = mixHex('#FFFFFF', rawBg, 0.03)
1097
+ dark = false
1098
+ warnings.push('检测到高饱和背景色 ' + rawBg + ',已自动设为庄重深色封面 + 护眼浅色正文画布。')
1099
+ } else if (bgLum >= 0.42) {
1100
+ dark = false
1101
+ canvas = clampHslColor(rawBg, { minL: 0.88, maxL: 1.0, maxS: 0.18 })
1102
+ } else {
1103
+ dark = true
1104
+ canvas = clampHslColor(rawBg, { minL: 0.008, maxL: 0.055, maxS: 0.35 })
1105
+ if (bgLum > 0.08) warnings.push('检测到中灰低对比背景色 ' + rawBg + ',已提纯为深邃暗色画布 ' + canvas + '。')
1106
+ }
1107
+
1108
+ const accentCandidates = [
1109
+ raw.brandPrimary,
1110
+ raw.primaryColor,
1111
+ coverMode === 'inverted-accent' ? coverBg : null,
1112
+ srcPalette.accent,
1113
+ srcPalette.accent1,
1114
+ srcPalette.accent2,
1115
+ srcPalette.accent3,
1116
+ srcPalette.dark2,
1117
+ ]
1118
+ .filter(Boolean)
1119
+ .map((c) => normalizeHex(c, ''))
1120
+ .filter((c) => c.length === 7)
1121
+
1122
+ const chromaticSeed = accentCandidates.find((c) => hexToHsl(c).s >= 0.12 && colorDistance(c, canvas) > 36)
1123
+ ?? accentCandidates[0]
1124
+ ?? (dark ? '#5E81F4' : '#0057B8')
1125
+ const accentSeed = clampHslColor(chromaticSeed, { maxS: 0.84, minL: 0.12, maxL: 0.82 })
1126
+
1127
+ const surface1 = dark
1128
+ ? mixHex(canvas, '#FFFFFF', 0.055)
1129
+ : adjustLightness(mixHex(canvas, accentSeed, 0.04), -0.03)
1130
+ const surface2 = dark
1131
+ ? mixHex(canvas, '#FFFFFF', 0.105)
1132
+ : adjustLightness(mixHex(canvas, accentSeed, 0.08), -0.065)
1133
+ const hairline = dark
1134
+ ? mixHex(canvas, '#FFFFFF', 0.16)
1135
+ : mixHex(canvas, '#0F172A', 0.14)
1136
+
1137
+ const rawFgCandidate = raw.textColor ?? srcPalette.fg ?? srcPalette.dark1 ?? (dark ? '#F5F7FA' : '#0F172A')
1138
+ const rawFg = normalizeHex(rawFgCandidate, dark ? '#F5F7FA' : '#0F172A')
1139
+ const inkPrimary = ensureContrast(rawFg, surface1, 10.0)
1140
+ if (contrastRatio(rawFg, surface1) < 4.5) {
1141
+ warnings.push('原文字颜色 ' + rawFg + ' 对比度不足,已自动增强至 ' + inkPrimary + '。')
1142
+ }
1143
+ const inkSecondary = ensureContrast(mixHex(inkPrimary, surface1, 0.25), surface1, 7.0)
1144
+ const inkMuted = ensureContrast(mixHex(inkPrimary, surface1, 0.46), surface1, 4.6)
1145
+
1146
+ const accentPrimary = ensureContrast(accentSeed, canvas, 3.2, 0.82)
1147
+ const accentText = ensureContrast(accentPrimary, surface1, 4.6, 0.82)
1148
+ const inkOnAccent = relativeLuminance(accentPrimary) > 0.36 ? '#0F172A' : '#FFFFFF'
1149
+
1150
+ const secondaryPool = [
1151
+ srcPalette.accent2,
1152
+ srcPalette.accent3,
1153
+ srcPalette.accent4,
1154
+ srcPalette.accent5,
1155
+ srcPalette.accent6,
1156
+ ]
1157
+ .filter(Boolean)
1158
+ .map((c) => normalizeHex(c, ''))
1159
+ .filter((c) => c.length === 7 && hueDelta(c, accentPrimary) >= 28)
1160
+
1161
+ const rawSecondary = secondaryPool[0] ?? hslToHex((hexToHsl(accentPrimary).h + 36) % 360, Math.max(0.45, hexToHsl(accentPrimary).s * 0.85), dark ? 0.62 : 0.38)
1162
+ const accentSecondary = ensureContrast(rawSecondary, canvas, 3.2, 0.80)
1163
+ const accent2Text = ensureContrast(accentSecondary, surface1, 4.6, 0.80)
1164
+ const accentSoft = mixHex(canvas, accentPrimary, dark ? 0.18 : 0.10)
1165
+
1166
+ const positive = ensureContrast(dark ? '#34D399' : '#0D7A4E', surface1, 4.5)
1167
+ const negative = ensureContrast(dark ? '#F87171' : '#C81E1E', surface1, 4.5)
1168
+ const warning = ensureContrast(dark ? '#FBBF24' : '#B45309', surface1, 4.5)
1169
+
1170
+ const seriesSeeds = [
1171
+ accentPrimary,
1172
+ accentSecondary,
1173
+ ...[srcPalette.accent3, srcPalette.accent4, srcPalette.accent5, srcPalette.accent6].filter(Boolean).map((c) => normalizeHex(c)),
1174
+ ...OKABE_ITO_FALLBACKS,
1175
+ ]
1176
+ const chartSeries = []
1177
+ for (const candidate of seriesSeeds) {
1178
+ if (chartSeries.length >= 6) break
1179
+ const adjusted = ensureContrast(candidate, canvas, 3.0, 0.80)
1180
+ if (chartSeries.every((existing) => colorDistance(existing, adjusted) >= 34)) {
1181
+ chartSeries.push(adjusted)
1182
+ }
1183
+ }
1184
+ while (chartSeries.length < 6) {
1185
+ chartSeries.push(ensureContrast(OKABE_ITO_FALLBACKS[chartSeries.length % OKABE_ITO_FALLBACKS.length], canvas, 3.0))
1186
+ }
1187
+ const chartNeutral = mixHex(canvas, inkPrimary, dark ? 0.24 : 0.18)
1188
+
1189
+ const warnedFonts = new Set()
1190
+ const sanitizeExtractedFont = (rawFont) => {
1191
+ const trimmed = String(rawFont ?? '').trim()
1192
+ if (!trimmed || /^\+mn-|^\+mj-/i.test(trimmed)) return ''
1193
+ if (BITMAP_SERIF_FONT_RE.test(trimmed) || NOVELTY_FONT_RE.test(trimmed)) {
1194
+ if (!warnedFonts.has(trimmed)) {
1195
+ warnedFonts.add(trimmed)
1196
+ warnings.push('检测到低可读点阵或装饰字体 ' + trimmed + ',已自动升级为矢量抗锯齿字体。')
1197
+ }
1198
+ return pptxEastAsianFont(trimmed)
1199
+ }
1200
+ if (/^微软雅黑$/i.test(trimmed)) return pptxEastAsianFont(trimmed)
1201
+ return trimmed
1202
+ }
1203
+
1204
+ const majorLatin = sanitizeExtractedFont(srcFonts.majorLatin)
1205
+ const majorEA = sanitizeExtractedFont(srcFonts.majorEastAsian)
1206
+ const minorLatin = sanitizeExtractedFont(srcFonts.minorLatin)
1207
+ const minorEA = sanitizeExtractedFont(srcFonts.minorEastAsian)
1208
+ const headingStack = [majorLatin, majorEA, SANS_STACK].filter(Boolean).join(', ')
1209
+ const bodyStack = [minorLatin || majorLatin, minorEA || majorEA, SANS_STACK].filter(Boolean).join(', ')
1210
+ const safeBrandFont = [majorEA, minorEA, majorLatin, minorLatin]
1211
+ .find((f) => f && /^[\p{L}\p{N} _-]+$/u.test(f) && f.length <= 80 && !/^\+mn-|^\+mj-/i.test(f))
1212
+
1213
+ // 匹配最接近的内置大师主题 ID
1214
+ let recommendedTheme = dark ? 'linear-dark' : 'consulting'
1215
+ let bestScore = Infinity
1216
+ for (const id of THEME_IDS) {
1217
+ const candidate = THEMES[id]
1218
+ if (candidate.dark !== dark) continue
1219
+ if (coverMode === 'inverted-accent' && candidate.tokens.coverMode === 'inverted-accent') {
1220
+ const d = hueDelta(coverBg, candidate.tokens.coverBg)
1221
+ if (d < bestScore) {
1222
+ bestScore = d
1223
+ recommendedTheme = id
1224
+ }
1225
+ continue
1226
+ }
1227
+ const score = hueDelta(accentPrimary, candidate.palette.accent) + colorDistance(canvas, candidate.palette.bg) * 0.25
1228
+ if (score < bestScore) {
1229
+ bestScore = score
1230
+ recommendedTheme = id
1231
+ }
1232
+ }
1233
+
1234
+ const tokens = {
1235
+ canvas,
1236
+ surface1,
1237
+ surface2,
1238
+ hairline,
1239
+ inkPrimary,
1240
+ inkSecondary,
1241
+ inkMuted,
1242
+ inkOnAccent,
1243
+ accentPrimary,
1244
+ accentText,
1245
+ accentSecondary,
1246
+ accent2Text,
1247
+ accentSoft,
1248
+ positive,
1249
+ negative,
1250
+ warning,
1251
+ chartFocal: accentPrimary,
1252
+ chartNeutral,
1253
+ chartSeries,
1254
+ coverMode,
1255
+ coverBg: coverMode === 'inverted-accent' ? coverBg : canvas,
1256
+ }
1257
+ const palette = {
1258
+ bg: canvas,
1259
+ panel: surface1,
1260
+ fg: inkPrimary,
1261
+ muted: inkMuted,
1262
+ accent: accentPrimary,
1263
+ accent2: accentSecondary,
1264
+ }
1265
+ const sanitizedBrand = {
1266
+ primaryColor: accentPrimary,
1267
+ backgroundColor: canvas,
1268
+ textColor: inkPrimary,
1269
+ ...(safeBrandFont ? { fontFamily: safeBrandFont } : {}),
1270
+ }
1271
+
1272
+ return {
1273
+ dark,
1274
+ tokens,
1275
+ palette,
1276
+ fonts: { heading: headingStack, body: bodyStack },
1277
+ sanitizedBrand,
1278
+ sanitizedTokens: tokens,
1279
+ recommendedTheme,
1280
+ warnings,
1281
+ }
1282
+ }
1283
+
1284
+ /**
1285
+ * 基于用户 brand 覆盖安全重算整套主题表面色、网格线与次级色(彻底修复浅色覆盖深色主题时的黑网格线 Bug),
1286
+ * 同时保留用户显式指定的 backgroundColor / textColor 原值以供 checkManifest 进行对比度告警。
1287
+ */
1288
+ export function deriveBrandedTheme(themeOrId, brand) {
1289
+ const base = resolveTheme(themeOrId)
1290
+ const cloned = {
1291
+ ...base,
1292
+ palette: { ...base.palette },
1293
+ tokens: { ...base.tokens, chartSeries: [...base.tokens.chartSeries] },
1294
+ fonts: { ...base.fonts },
1295
+ }
1296
+ if (!brand || typeof brand !== 'object') return cloned
1297
+
1298
+ const hasColorOverride = Boolean(brand.backgroundColor || brand.textColor || brand.primaryColor)
1299
+ if (hasColorOverride) {
1300
+ const nextBg = brand.backgroundColor ? normalizeHex(brand.backgroundColor, base.palette.bg) : base.palette.bg
1301
+ const nextDark = relativeLuminance(nextBg) < 0.42
1302
+ const nextAccent = brand.primaryColor ? normalizeHex(brand.primaryColor, base.palette.accent) : base.palette.accent
1303
+ const defaultFgForPolarity = nextDark ? '#F5F7FA' : '#0F172A'
1304
+ const nextFg = brand.textColor
1305
+ ? normalizeHex(brand.textColor, defaultFgForPolarity)
1306
+ : (nextDark === base.dark ? base.palette.fg : defaultFgForPolarity)
1307
+
1308
+ const nextSurface1 = nextDark
1309
+ ? mixHex(nextBg, '#FFFFFF', 0.06)
1310
+ : adjustLightness(mixHex(nextBg, nextAccent, 0.035), -0.028)
1311
+ const nextSurface2 = nextDark
1312
+ ? mixHex(nextBg, '#FFFFFF', 0.11)
1313
+ : adjustLightness(mixHex(nextBg, nextAccent, 0.07), -0.06)
1314
+ const nextHairline = nextDark
1315
+ ? mixHex(nextBg, '#FFFFFF', 0.16)
1316
+ : mixHex(nextBg, '#0F172A', 0.13)
1317
+ const safeInkForDerived = contrastRatio(nextFg, nextSurface1) >= 4.5 ? nextFg : defaultFgForPolarity
1318
+ const nextInkSecondary = ensureContrast(mixHex(safeInkForDerived, nextSurface1, 0.25), nextSurface1, 7.0)
1319
+ const nextMuted = ensureContrast(mixHex(safeInkForDerived, nextSurface1, 0.46), nextSurface1, 4.6)
1320
+ const nextAccentText = ensureContrast(nextAccent, nextSurface1, 4.6)
1321
+ const nextAccent2 = ensureContrast(base.palette.accent2, nextBg, 3.0)
1322
+ const nextAccent2Text = ensureContrast(nextAccent2, nextSurface1, 4.6)
1323
+ const nextChartNeutral = mixHex(nextBg, safeInkForDerived, nextDark ? 0.24 : 0.18)
1324
+ const nextSeries = [nextAccent, ...base.tokens.chartSeries.slice(1).map((c) => ensureContrast(c, nextBg, 2.8))]
1325
+
1326
+ cloned.dark = nextDark
1327
+ cloned.shadow = !nextDark && base.shadow
1328
+ cloned.palette = {
1329
+ bg: nextBg,
1330
+ panel: nextSurface1,
1331
+ fg: nextFg,
1332
+ muted: nextMuted,
1333
+ accent: nextAccent,
1334
+ accent2: nextAccent2,
1335
+ }
1336
+ cloned.tokens = {
1337
+ ...cloned.tokens,
1338
+ canvas: nextBg,
1339
+ surface1: nextSurface1,
1340
+ surface2: nextSurface2,
1341
+ hairline: nextHairline,
1342
+ inkPrimary: nextFg,
1343
+ inkSecondary: nextInkSecondary,
1344
+ inkMuted: nextMuted,
1345
+ inkOnAccent: relativeLuminance(nextAccent) > 0.36 ? '#0F172A' : '#FFFFFF',
1346
+ accentPrimary: nextAccent,
1347
+ accentText: nextAccentText,
1348
+ accentSecondary: nextAccent2,
1349
+ accent2Text: nextAccent2Text,
1350
+ accentSoft: mixHex(nextBg, nextAccent, nextDark ? 0.18 : 0.10),
1351
+ positive: ensureContrast(nextDark ? '#34D399' : '#0D7A4E', nextSurface1, 4.5),
1352
+ negative: ensureContrast(nextDark ? '#F87171' : '#C81E1E', nextSurface1, 4.5),
1353
+ warning: ensureContrast(nextDark ? '#FBBF24' : '#B45309', nextSurface1, 4.5),
1354
+ chartFocal: nextAccent,
1355
+ chartNeutral: nextChartNeutral,
1356
+ chartSeries: nextSeries,
1357
+ coverMode: brand.backgroundColor ? 'standard' : cloned.tokens.coverMode,
1358
+ coverBg: brand.backgroundColor ? nextBg : cloned.tokens.coverBg,
1359
+ }
1360
+ }
1361
+
1362
+ if (brand.chromeStyle && CHROME_STYLE_SET.has(String(brand.chromeStyle).trim())) {
1363
+ cloned.chromeStyle = String(brand.chromeStyle).trim()
1364
+ }
1365
+
1366
+ if (brand.fontFamily) {
1367
+ const trimmed = String(brand.fontFamily).trim()
1368
+ const cleanFamily = BITMAP_SERIF_FONT_RE.test(trimmed) || NOVELTY_FONT_RE.test(trimmed) || /^微软雅黑$/i.test(trimmed)
1369
+ ? [pptxEastAsianFont(trimmed), SANS_STACK].join(', ')
1370
+ : trimmed
1371
+ cloned.fonts = { heading: cleanFamily, body: cleanFamily }
1372
+ }
1373
+ return cloned
1374
+ }
1375
+
1376
+ // ---------------------------------------------------------------------------
1377
+ // 主题预览 SVG 色板卡与对比页生成
1378
+ // ---------------------------------------------------------------------------
1379
+
1380
+ function xmlEsc(value) {
1381
+ return String(value ?? '')
1382
+ .replace(/&/g, '&amp;')
1383
+ .replace(/</g, '&lt;')
1384
+ .replace(/>/g, '&gt;')
1385
+ .replace(/"/g, '&quot;')
1386
+ .replace(/'/g, '&apos;')
1387
+ }
1388
+
1389
+ function htmlEsc(value) {
1390
+ return String(value ?? '')
1391
+ .replace(/&/g, '&amp;')
1392
+ .replace(/</g, '&lt;')
1393
+ .replace(/>/g, '&gt;')
1394
+ .replace(/"/g, '&quot;')
1395
+ }
1396
+
1397
+ function themePreviewLabels(lang) {
1398
+ return lang === 'en'
1399
+ ? { title: 'dsh-ppt theme gallery', hint: 'Pick a theme id for ppt_create (or pass auto)', usage: 'theme', dark: 'dark', light: 'light', palette: 'Palette' }
1400
+ : { title: 'dsh-ppt 主题预览', hint: '把 id 填给 ppt_create 的 theme 参数(默认推荐 auto 智能匹配)', usage: 'theme', dark: '深色', light: '浅色', palette: '色板' }
1401
+ }
1402
+
1403
+ export function renderThemeSvg(input, lang = 'zh', version = '0.0.0') {
1404
+ const theme = typeof input === 'string' ? resolveTheme(input) : input
1405
+ const pick = (pair) => (lang === 'en' ? pair.en : pair.zh)
1406
+ const p = theme.palette
1407
+ const tk = theme.tokens
1408
+ const L = themePreviewLabels(lang === 'en' ? 'en' : 'zh')
1409
+ const font = theme.fonts.heading.replace(/"/g, "'")
1410
+ const bodyFont = theme.fonts.body.replace(/"/g, "'")
1411
+ const rx = Math.max(0, Math.min(16, theme.radiusPx ?? 10))
1412
+ const out = []
1413
+ out.push('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 540" width="960" height="540" role="img" aria-label="' + xmlEsc(theme.id + ' ' + pick(theme.name)) + '">')
1414
+ out.push('<rect width="960" height="540" fill="' + p.bg + '"/>')
1415
+ out.push('<rect x="0" y="0" width="960" height="6" fill="' + p.accent + '"/><rect x="0" y="534" width="960" height="4" fill="' + p.accent2 + '"/>')
1416
+ out.push('<rect x="36" y="40" width="560" height="360" rx="' + rx + '" fill="' + p.panel + '" stroke="' + tk.hairline + '"/>')
1417
+ out.push('<text x="64" y="92" fill="' + tk.accentText + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13" font-weight="700" letter-spacing="2.5">' + xmlEsc(pick(theme.mood).toUpperCase()) + '</text>')
1418
+ out.push('<text x="64" y="156" fill="' + p.fg + '" font-family="' + xmlEsc(font) + '" font-size="40" font-weight="800">' + xmlEsc('Aa ' + pick(theme.name)) + '</text>')
1419
+ out.push('<rect x="64" y="196" width="164" height="74" rx="' + Math.max(0, rx - 2) + '" fill="' + tk.surface2 + '" stroke="' + tk.hairline + '"/>')
1420
+ out.push('<text x="80" y="232" fill="' + tk.accentText + '" font-family="' + xmlEsc(font) + '" font-size="24" font-weight="800">+38.4%</text>')
1421
+ out.push('<text x="80" y="254" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="12">Core KPI · YoY</text>')
1422
+ out.push('<rect x="244" y="196" width="320" height="74" rx="' + Math.max(0, rx - 2) + '" fill="' + tk.surface2 + '" stroke="' + tk.hairline + '"/>')
1423
+ out.push('<rect x="262" y="214" width="210" height="10" rx="4" fill="' + hexToRgba(p.fg, 0.78) + '"/>')
1424
+ out.push('<rect x="262" y="238" width="165" height="10" rx="4" fill="' + hexToRgba(p.fg, 0.45) + '"/>')
1425
+ out.push('<rect x="64" y="298" width="500" height="36" rx="' + Math.max(0, rx - 2) + '" fill="' + p.accent + '"/>')
1426
+ out.push('<text x="80" y="321" fill="' + tk.inkOnAccent + '" font-family="' + xmlEsc(bodyFont) + '" font-size="14" font-weight="700">dsh-ppt · ' + xmlEsc(theme.persona) + '</text>')
1427
+ out.push('<text x="548" y="321" fill="' + tk.inkOnAccent + '" font-family="' + xmlEsc(bodyFont) + '" font-size="14" font-weight="700" text-anchor="end">100%</text>')
1428
+ out.push('<rect x="64" y="352" width="500" height="1" fill="' + tk.hairline + '"/>')
1429
+ out.push('<text x="64" y="380" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13">' + xmlEsc(theme.id + ' · ' + (theme.dark ? L.dark : L.light) + ' · v' + version) + '</text>')
1430
+ const swatches = ['bg', 'panel', 'fg', 'muted', 'accent', 'accent2']
1431
+ out.push('<text x="632" y="76" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13" font-weight="700" letter-spacing="2">' + xmlEsc(L.palette.toUpperCase()) + '</text>')
1432
+ swatches.forEach((key, i) => {
1433
+ const y = 96 + i * 62
1434
+ out.push('<rect x="632" y="' + y + '" width="44" height="44" rx="10" fill="' + p[key] + '" stroke="' + tk.hairline + '"/>')
1435
+ out.push('<text x="692" y="' + (y + 20) + '" fill="' + p.fg + '" font-family="' + xmlEsc(bodyFont) + '" font-size="14" font-weight="600">' + xmlEsc(key) + '</text>')
1436
+ out.push('<text x="692" y="' + (y + 38) + '" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13">' + xmlEsc(String(p[key]).toUpperCase()) + '</text>')
1437
+ })
1438
+ out.push('<text x="632" y="508" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="12">' + xmlEsc(pick(theme.bestFor)).slice(0, 44) + '</text>')
1439
+ out.push('</svg>')
1440
+ return out.join('')
1441
+ }
1442
+
1443
+ export function renderThemePreviewHtml(lang = 'zh', version = '0.0.0') {
1444
+ const L = themePreviewLabels(lang === 'en' ? 'en' : 'zh')
1445
+ const cards = THEME_IDS.map((id) => {
1446
+ const theme = THEMES[id]
1447
+ const pick = (pair) => (lang === 'en' ? pair.en : pair.zh)
1448
+ const chips = Object.keys(theme.palette).map((key) =>
1449
+ '<span class="chip"><i style="background:' + theme.palette[key] + '"></i>' + htmlEsc(String(theme.palette[key]).toUpperCase()) + '</span>').join('')
1450
+ return '<figure class="card" id="theme-' + htmlEsc(id) + '">' +
1451
+ renderThemeSvg(theme, lang === 'en' ? 'en' : 'zh', version) +
1452
+ '<figcaption><div class="row"><strong>' + htmlEsc(id) + '</strong><span class="badge">' + htmlEsc(pick(theme.name)) + ' · ' + (theme.dark ? L.dark : L.light) + '</span></div>' +
1453
+ '<p class="muted">' + htmlEsc(pick(theme.mood)) + ' · ' + htmlEsc(pick(theme.bestFor)) + '</p>' +
1454
+ '<p class="chips">' + chips + '</p>' +
1455
+ '<p class="usage">' + htmlEsc(L.usage) + ': <code>' + htmlEsc(id) + '</code></p></figcaption></figure>'
1456
+ }).join('')
1457
+ return '<!DOCTYPE html><html lang="' + (lang === 'en' ? 'en-US' : 'zh-CN') + '">' +
1458
+ '<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">' +
1459
+ '<title>' + htmlEsc(L.title) + '</title><style>' +
1460
+ 'body{margin:0;background:#F8FAFC;color:#0F172A;font-family:"Inter","Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;padding:32px}' +
1461
+ 'h1{font-size:28px;margin:0 0 6px;letter-spacing:-.02em}p.sub{color:#475569;margin:0 0 26px;font-size:14px}' +
1462
+ '.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(420px,1fr));gap:22px}' +
1463
+ '.card{margin:0;background:#FFFFFF;border:1px solid #E2E8F0;border-radius:14px;overflow:hidden;box-shadow:0 4px 16px rgba(15,23,42,.04)}' +
1464
+ '.card svg{display:block;width:100%;height:auto;border-bottom:1px solid #E2E8F0}' +
1465
+ 'figcaption{padding:14px 16px 16px}.row{display:flex;align-items:center;gap:10px;font-size:16px}' +
1466
+ '.badge{color:#475569;font-size:13px}.muted{color:#475569;font-size:13px;margin:6px 0 10px;line-height:1.5}' +
1467
+ '.chips{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px}.chip{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:#334155;background:#F8FAFC;border:1px solid #CBD5E1;border-radius:99px;padding:3px 9px}' +
1468
+ '.chip i{width:10px;height:10px;border-radius:3px;display:inline-block;border:1px solid rgba(0,0,0,.12)}' +
1469
+ '.usage{margin:0;font-size:13px;color:#334155}code{background:#F1F5F9;border:1px solid #CBD5E1;border-radius:6px;padding:1px 6px}' +
1470
+ '@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}' +
1471
+ '</style></head><body><h1>' + htmlEsc(L.title) + '</h1><p class="sub">' + htmlEsc(L.hint) + ' · dsh-ppt v' + htmlEsc(version) + '</p>' +
1472
+ '<div class="grid">' + cards + '</div></body></html>'
1473
+ }
1474
+
1475
+ export function buildThemePreviewFileSet(options = {}, resolveLanguageFn, version = '0.0.0') {
1476
+ const langInput = typeof options.lang === 'string' && options.lang.trim() !== '' ? options.lang.trim() : 'zh'
1477
+ const language = resolveLanguageFn ? resolveLanguageFn(langInput) : { id: langInput === 'en' ? 'en' : 'zh' }
1478
+ const outputDir = resolvePath(String(options.outputDir ?? '.'))
1479
+ mkdirSync(outputDir, { recursive: true })
1480
+ const overwrite = options.overwrite === true
1481
+ const pickPath = (base, ext) => {
1482
+ const first = resolvePath(joinPath(outputDir, base + ext))
1483
+ if (overwrite || !existsSync(first)) return first
1484
+ for (let i = 1; i < 1000; i += 1) {
1485
+ const candidate = resolvePath(joinPath(outputDir, base + '-' + i + ext))
1486
+ if (!existsSync(candidate)) return candidate
1487
+ }
1488
+ throw new Error('dsh-ppt:找不到可用的预览文件名(同名前缀超过 999 个),请允许 overwrite。')
1489
+ }
1490
+ const htmlPath = pickPath('themes-preview', '.html')
1491
+ writeFileSync(htmlPath, renderThemePreviewHtml(language.id, version), 'utf8')
1492
+ const svgs = THEME_IDS.map((id) => {
1493
+ const svgPath = pickPath('theme-' + id, '.svg')
1494
+ writeFileSync(svgPath, renderThemeSvg(id, language.id, version), 'utf8')
1495
+ return { id, path: svgPath }
1496
+ })
1497
+ return { ok: true, outputDir, htmlPath, svgs, themeCount: THEME_IDS.length, language: language.id }
1498
+ }
1499
+
1500
+ export function buildThemePreview(options = {}, resolveLanguageFn, version = '0.0.0') {
1501
+ return buildThemePreviewFileSet(options, resolveLanguageFn, version)
1502
+ }
1503
+