dsh-ppt 0.32.1 → 0.33.0

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.
@@ -0,0 +1,1214 @@
1
+ /**
2
+ * deck-infographics.mjs —— dsh-ppt 视觉信息图与智能配图协作引擎(零外部依赖)。
3
+ *
4
+ * 100% 原生可编辑 PowerPoint DrawingML(<p:sp> / <a:custGeom>)+ HTML SVG 双端同构:
5
+ * 1. map(战略热力点阵地图:world 全球点阵版 / china 中国经济带枢纽点阵版 + 右侧区域排行侧栏)
6
+ * 2. isometric(2.5D 等轴测矢量信息图:stack 分层架构堆叠 / pillars 3D 立体柱碑对比)
7
+ * 3. generateVisualBrief / normalizeImageBrief(主题自适应智能配图协作 Brief 与视觉蓝图占位卡)
8
+ */
9
+
10
+ import { relativeLuminance, mixHex } from './deck-themes.mjs'
11
+ import {
12
+ roundRectAdj,
13
+ escapeXml,
14
+ escapeHtml,
15
+ stripInlineMarkdown,
16
+ renderInlineHtml,
17
+ resolveEffectiveItems,
18
+ computeTextFit,
19
+ ooxmlRichParagraph,
20
+ ooxmlShape,
21
+ ooxmlCustGeomShape,
22
+ ooxmlLine,
23
+ computeBadgePillWidth,
24
+ renderSurfaceCardPptx,
25
+ } from './deck-chrome.mjs'
26
+
27
+ export const INFOGRAPHIC_LAYOUTS = new Set(['map', 'isometric'])
28
+
29
+ function parseNum(raw, fallback = NaN) {
30
+ if (typeof raw === 'number' && Number.isFinite(raw)) return raw
31
+ const cleaned = String(raw ?? '').replace(/[,,%%$¥€£\s]/g, '').replace(/[++]/g, '')
32
+ const m = /-?\d+(?:\.\d+)?/.exec(cleaned)
33
+ return m ? Number(m[0]) : fallback
34
+ }
35
+
36
+ function clamp(v, lo, hi) {
37
+ return Math.max(lo, Math.min(hi, v))
38
+ }
39
+
40
+ function contrastInk(bgHex, lightInk = '#FFFFFF', darkInk = '#0F172A') {
41
+ return relativeLuminance(bgHex) < 0.36 ? lightInk : darkInk
42
+ }
43
+
44
+ function buildPolygonPathXml(pts, pathW, pathH) {
45
+ if (!pts || pts.length < 3) return ''
46
+ const toP = ([nx, ny]) => `x="${Math.round(clamp(nx, 0, 1) * pathW)}" y="${Math.round(clamp(ny, 0, 1) * pathH)}"`
47
+ const segs = [`<a:moveTo><a:pt ${toP(pts[0])}/></a:moveTo>`]
48
+ for (let i = 1; i < pts.length; i += 1) {
49
+ segs.push(`<a:lnTo><a:pt ${toP(pts[i])}/></a:lnTo>`)
50
+ }
51
+ segs.push('<a:close/>')
52
+ return segs.join('')
53
+ }
54
+
55
+ function renderCustomPolyPptx(id, name, absPts, options = {}) {
56
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity
57
+ for (const [x, y] of absPts) {
58
+ if (x < minX) minX = x
59
+ if (y < minY) minY = y
60
+ if (x > maxX) maxX = x
61
+ if (y > maxY) maxY = y
62
+ }
63
+ const w = Math.max(0.02, maxX - minX)
64
+ const h = Math.max(0.02, maxY - minY)
65
+ const norm = absPts.map(([x, y]) => [(x - minX) / w, (y - minY) / h])
66
+ const pathW = 10000
67
+ const pathH = 10000
68
+ return ooxmlCustGeomShape(id, name, { x: minX, y: minY, w, h }, buildPolygonPathXml(norm, pathW, pathH), {
69
+ pathW,
70
+ pathH,
71
+ ...options,
72
+ })
73
+ }
74
+
75
+ // ---------------------------------------------------------------------------
76
+ // 1. 战略点阵地图(World & China Economic Hub Dot-Matrix Maps)
77
+ // ---------------------------------------------------------------------------
78
+
79
+ // 36 x 18 Economist-style dotted world silhouette (row -> column indices)
80
+ const WORLD_ROWS = [
81
+ [11, 12, 13], // Greenland top
82
+ [4, 5, 6, 7, 8, 11, 12, 13, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30], // Arctic NA / Scand / Siberia
83
+ [3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
84
+ [4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
85
+ [5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31], // US / EU / China / Japan
86
+ [5, 6, 7, 8, 9, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31],
87
+ [6, 7, 8, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], // Mexico / N Africa / ME / China
88
+ [7, 8, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29], // C America / Sahara / India / SE Asia
89
+ [8, 9, 14, 15, 16, 17, 18, 19, 20, 24, 25, 27, 28, 30], // N SA / W Africa / India / Indochina / PH
90
+ [9, 10, 11, 15, 16, 17, 18, 19, 20, 24, 28, 29], // Brazil / Central Africa
91
+ [9, 10, 11, 12, 16, 17, 18, 19, 20, 28, 29, 30, 31], // Brazil / E Africa / Indonesia
92
+ [10, 11, 12, 17, 18, 19, 20, 29, 30, 31, 32], // S America / S Africa / N Australia
93
+ [10, 11, 12, 17, 18, 19, 21, 28, 29, 30, 31, 32], // S America / S Africa / Madagascar / Australia
94
+ [10, 11, 17, 18, 19, 29, 30, 31, 32], // Argentina / S Africa / Australia
95
+ [10, 11, 18, 30, 31, 33], // Patagonia / NZ
96
+ [10, 33], // Southern tip
97
+ ]
98
+ const WORLD_DOTS = WORLD_ROWS.flatMap((cols, r) => cols.map((c) => [c / 35, (r + 0.6) / 16.5]))
99
+
100
+ // 26 x 20 stylized China economic-zone dotted landmass (incl. NE, NW, SW, Central, East, South, Hainan & Taiwan)
101
+ const CHINA_ROWS = [
102
+ [19, 20, 21], // Heilongjiang N
103
+ [17, 18, 19, 20, 21, 22],
104
+ [16, 17, 18, 19, 20, 21, 22], // NE / Inner Mongolia
105
+ [4, 5, 6, 14, 15, 16, 17, 18, 19, 20, 21], // N Xinjiang / Inner Mongolia / Liaoning
106
+ [2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20], // Xinjiang / Gansu / Beijing-Tianjin
107
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
108
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], // Hebei / Shandong
109
+ [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
110
+ [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], // Qinghai / Shaanxi / Henan / Jiangsu
111
+ [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], // Tibet / Sichuan / Hubei / Shanghai
112
+ [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], // Tibet / Chongqing / Zhejiang
113
+ [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], // Yunnan / Guizhou / Hunan / Jiangxi / Fujian
114
+ [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], // Yunnan / Guangxi / Guangdong / Fujian
115
+ [10, 11, 12, 13, 14, 15, 16, 17, 18, 20], // Guangxi / Guangdong / Taiwan
116
+ [11, 12, 13, 14, 15, 16, 17, 20], // GBA / Taiwan
117
+ [13, 14], // Hainan
118
+ ]
119
+ const CHINA_DOTS = CHINA_ROWS.flatMap((cols, r) => cols.map((c) => [(c + 0.8) / 24.5, (r + 0.8) / 17]))
120
+
121
+ const WORLD_HUBS = [
122
+ { re: /拉美|南美|巴西|墨西哥|latam|latin\s*america|south\s*america|brazil|mexico/i, x: 30, y: 68 },
123
+ { re: /北美|北美洲|美国|加拿大|north\s*america|\busa?\b|\bcanada\b|\bna\b/i, x: 20, y: 31 },
124
+ { re: /欧洲|欧盟|英法德|西欧|europe|\beu\b|\bemea\b|\buk\b|germany|france/i, x: 51, y: 25 },
125
+ { re: /中国|大中华|大陆|华东|china|greater\s*china|\bcn\b/i, x: 78, y: 37 },
126
+ { re: /亚太|亚洲|apac|asia/i, x: 80, y: 46 },
127
+ { re: /日韩|日本|韩国|东亚|japan|korea|\bjp\b|\bkr\b/i, x: 89, y: 34 },
128
+ { re: /东南亚|东盟|新加坡|asean|sea|southeast\s*asia|singapore/i, x: 81, y: 58 },
129
+ { re: /印度|南亚|india|south\s*asia/i, x: 70, y: 47 },
130
+ { re: /中东|非洲|中东非|沙特|阿联酋|middle\s*east|africa|\bmea\b|\bmena\b|dubai|uae/i, x: 56, y: 53 },
131
+ { re: /大洋洲|澳洲|澳大利亚|澳新|australia|oceania|\banz\b|new\s*zealand/i, x: 87, y: 78 },
132
+ ]
133
+
134
+ const CHINA_HUBS = [
135
+ { re: /华北|京津冀|北京|天津|河北|north\s*china|beijing|tianjin/i, x: 70, y: 33 },
136
+ { re: /华东|长三角|上海|杭州|南京|苏州|浙江|江苏|east\s*china|shanghai|hangzhou/i, x: 84, y: 55 },
137
+ { re: /华南|粤港澳|大湾区|深圳|广州|广东|福建|south\s*china|shenzhen|guangzhou|\bgba\b/i, x: 71, y: 81 },
138
+ { re: /西南|成渝|成都|重庆|四川|云南|贵州|southwest|chengdu|chongqing/i, x: 46, y: 63 },
139
+ { re: /华中|武汉|长沙|郑州|湖北|湖南|河南|central\s*china|wuhan|changsha/i, x: 64, y: 58 },
140
+ { re: /东北|沈阳|大连|哈尔滨|长春|辽宁|吉林|黑龙江|northeast|shenyang|dalian/i, x: 82, y: 19 },
141
+ { re: /西北|西安|陕西|新疆|甘肃|青海|northwest|xian|xi'an|xinjiang/i, x: 41, y: 45 },
142
+ { re: /港澳台|香港|澳门|台湾|台北|hong\s*kong|taipei|taiwan/i, x: 83, y: 82 },
143
+ ]
144
+
145
+ function detectMapMode(slide, items) {
146
+ const v = String(slide?.variant || '').trim().toLowerCase()
147
+ if (v === 'china' || v === 'cn') return 'china'
148
+ if (v === 'world' || v === 'global') return 'world'
149
+ const textPool = [slide?.title, slide?.subtitle, ...items.map((it) => `${it.title || ''} ${it.tag || ''}`)].join(' ')
150
+ const chinaHits = CHINA_HUBS.filter((h) => h.re.test(textPool)).length
151
+ const worldHits = WORLD_HUBS.filter((h) => h.re.test(textPool)).length
152
+ if (chinaHits >= 2 && worldHits <= 1) return 'china'
153
+ return 'world'
154
+ }
155
+
156
+ export function computeMapModel(slide, langEn = false) {
157
+ let rawItems = resolveEffectiveItems(slide)
158
+ if (rawItems.length === 0 && Array.isArray(slide?.rows) && slide.rows.length >= 2) {
159
+ rawItems = slide.rows.slice(1).map((r) => ({
160
+ title: stripInlineMarkdown(r[0] || ''),
161
+ value: String(r[1] ?? '').trim(),
162
+ delta: String(r[2] ?? '').trim(),
163
+ text: stripInlineMarkdown(r[3] || ''),
164
+ })).filter((it) => it.title)
165
+ }
166
+
167
+ if (rawItems.length === 0) {
168
+ rawItems = langEn
169
+ ? [
170
+ { title: 'North America', value: '$48M', delta: '+28%', status: 'accent', text: 'Enterprise flagship region' },
171
+ { title: 'APAC', value: '$36M', delta: '+44%', status: 'positive', text: 'Fastest YoY expansion' },
172
+ { title: 'Europe', value: '$29M', delta: '+19%', status: 'neutral', text: 'DACH & UK compliance wins' },
173
+ { title: 'MEA', value: '$14M', delta: '+32%', status: 'neutral', text: 'Sovereign cloud partnerships' },
174
+ { title: 'LATAM', value: '$11M', delta: '+21%', status: 'neutral', text: 'Fintech channel rollout' },
175
+ ]
176
+ : [
177
+ { title: '北美区', value: '$48M', delta: '+28%', status: 'accent', text: '企业级大客户主力市场' },
178
+ { title: '亚太区', value: '$36M', delta: '+44%', status: 'positive', text: '增速最快的高潜增量引擎' },
179
+ { title: '欧洲区', value: '$29M', delta: '+19%', status: 'neutral', text: '合规认证驱动稳健交付' },
180
+ { title: '中东非', value: '$14M', delta: '+32%', status: 'neutral', text: '主权云标杆项目落地' },
181
+ { title: '拉美区', value: '$11M', delta: '+21%', status: 'neutral', text: '金融科技渠道加速渗透' },
182
+ ]
183
+ }
184
+
185
+ const mode = detectMapMode(slide, rawItems)
186
+ const hubs = mode === 'china' ? CHINA_HUBS : WORLD_HUBS
187
+ const fallbackCoords = mode === 'china'
188
+ ? [[81, 58], [71, 80], [70, 35], [51, 63], [67, 60], [82, 20], [43, 46]]
189
+ : [[21, 31], [79, 45], [51, 26], [56, 50], [31, 66], [87, 78]]
190
+
191
+ const parsed = rawItems.slice(0, 7).map((it, idx) => {
192
+ const label = stripInlineMarkdown(it.title || it.tag || `Region ${idx + 1}`)
193
+ const valStr = String(it.value ?? '').trim()
194
+ const numVal = parseNum(valStr || it.text || it.delta, NaN)
195
+ const matchedHub = hubs.find((h) => h.re.test(`${label} ${it.tag || ''}`))
196
+ const explicitX = parseNum(it.x, NaN)
197
+ const explicitY = parseNum(it.y, NaN)
198
+ const fb = fallbackCoords[idx % fallbackCoords.length]
199
+ const x = Number.isFinite(explicitX) ? clamp(explicitX, 6, 94) : (matchedHub ? matchedHub.x : fb[0])
200
+ const y = Number.isFinite(explicitY) ? clamp(explicitY, 8, 90) : (matchedHub ? matchedHub.y : fb[1])
201
+ return {
202
+ title: label,
203
+ tag: stripInlineMarkdown(it.tag || ''),
204
+ value: valStr || (Number.isFinite(numVal) ? String(numVal) : ''),
205
+ numericVal: Number.isFinite(numVal) ? Math.max(0, numVal) : (rawItems.length - idx) * 10,
206
+ delta: stripInlineMarkdown(it.delta || ''),
207
+ text: stripInlineMarkdown(it.text || ''),
208
+ status: it.status || '',
209
+ x,
210
+ y,
211
+ rawIndex: idx,
212
+ }
213
+ })
214
+
215
+ const maxVal = Math.max(1, ...parsed.map((p) => p.numericVal))
216
+ const totalVal = parsed.reduce((s, p) => s + Math.max(0, p.numericVal), 0) || 1
217
+ const ranked = [...parsed].sort((a, b) => b.numericVal - a.numericVal)
218
+ const focalItem = ranked.find((p) => p.status === 'accent') || ranked[0]
219
+
220
+ const regions = ranked.map((p, rankIdx) => ({
221
+ ...p,
222
+ rank: rankIdx + 1,
223
+ ratio: clamp(p.numericVal / maxVal, 0.14, 1),
224
+ sharePct: Math.round((p.numericVal / totalVal) * 100),
225
+ isFocal: p === focalItem,
226
+ radiusNorm: 0.35 + 0.65 * Math.sqrt(clamp(p.numericVal / maxVal, 0.1, 1)),
227
+ }))
228
+
229
+ return {
230
+ mode,
231
+ dots: mode === 'china' ? CHINA_DOTS : WORLD_DOTS,
232
+ regions,
233
+ focal: regions.find((r) => r.isFocal) || regions[0],
234
+ }
235
+ }
236
+
237
+ function resolveRegionColors(regions, tk) {
238
+ return regions.map((r) => {
239
+ if (r.isFocal || r.status === 'accent') return tk.accentPrimary
240
+ if (r.status === 'positive') return tk.positive
241
+ if (r.status === 'warning') return tk.warning
242
+ if (r.status === 'negative') return tk.negative
243
+ return tk.accentSecondary || mixHex(tk.accentPrimary, tk.inkMuted, 0.35)
244
+ })
245
+ }
246
+
247
+ function placeMapBadges(regions, mapBox) {
248
+ const placed = []
249
+ const hubCenters = regions.map((r) => ({
250
+ cx: mapBox.x + (r.x / 100) * mapBox.w,
251
+ cy: mapBox.y + (r.y / 100) * mapBox.h,
252
+ rad: (0.28 + 0.30 * r.radiusNorm) / 2 + 0.04,
253
+ }))
254
+ return regions.map((r, idx) => {
255
+ const { cx, cy } = hubCenters[idx]
256
+ const labelText = r.value ? `${r.title} · ${r.value}` : r.title
257
+ const bw = computeBadgePillWidth(labelText, 9.5, 2.05, 0.95)
258
+ const bh = 0.25
259
+ const candidates = [
260
+ { bx: cx - bw / 2, by: cy - 0.50 },
261
+ { bx: cx - bw / 2, by: cy + 0.28 },
262
+ { bx: cx + 0.30, by: cy - bh / 2 },
263
+ { bx: cx - bw - 0.30, by: cy - bh / 2 },
264
+ { bx: cx + 0.26, by: cy - 0.48 },
265
+ { bx: cx - bw - 0.26, by: cy + 0.28 },
266
+ { bx: cx - bw - 0.26, by: cy - 0.48 },
267
+ { bx: cx + 0.26, by: cy + 0.28 },
268
+ ]
269
+ let chosen = null
270
+ for (const c of candidates) {
271
+ const bx = clamp(c.bx, mapBox.x + 0.08, mapBox.x + mapBox.w - bw - 0.08)
272
+ const by = clamp(c.by, mapBox.y + 0.08, mapBox.y + mapBox.h - bh - 0.08)
273
+ const hitBadge = placed.some((p) => !(bx + bw + 0.06 < p.bx || bx > p.bx + p.bw + 0.06 || by + bh + 0.05 < p.by || by > p.by + p.bh + 0.05))
274
+ const hitHub = hubCenters.some((h) => !(bx + bw + 0.02 < h.cx - h.rad || bx - 0.02 > h.cx + h.rad || by + bh + 0.02 < h.cy - h.rad || by - 0.02 > h.cy + h.rad))
275
+ if (!hitBadge && !hitHub) {
276
+ chosen = { bx, by }
277
+ break
278
+ }
279
+ if (!chosen && !hitBadge) chosen = { bx, by }
280
+ }
281
+ if (!chosen) {
282
+ chosen = {
283
+ bx: clamp(cx - bw / 2, mapBox.x + 0.08, mapBox.x + mapBox.w - bw - 0.08),
284
+ by: clamp(cy - 0.50, mapBox.y + 0.08, mapBox.y + mapBox.h - bh - 0.08),
285
+ }
286
+ }
287
+ placed.push({ bx: chosen.bx, by: chosen.by, bw, bh })
288
+ return { ...r, cx, cy, bx: chosen.bx, by: chosen.by, bw, bh, labelText }
289
+ })
290
+ }
291
+
292
+ function renderMapPptx(slide, ctx) {
293
+ const { theme, langAttr, chromeCfg, nextId, bodyTopY, bodyH } = ctx
294
+ const tk = theme.tokens
295
+ const langEn = langAttr === 'en-US'
296
+ const model = computeMapModel(slide, langEn)
297
+ const colors = resolveRegionColors(model.regions, tk)
298
+ const shapes = []
299
+
300
+ const mapBox = { x: 0.62, y: bodyTopY + 0.06, w: 7.62, h: bodyH - 0.14 }
301
+ const sideBox = { x: 8.48, y: bodyTopY + 0.06, w: 4.23, h: bodyH - 0.14 }
302
+ const cardPreset = chromeCfg.cardRadiusPx > 0 ? 'roundRect' : 'rect'
303
+
304
+ // Left map card container
305
+ shapes.push(renderSurfaceCardPptx('Map Canvas', mapBox, { fill: tk.surface1 }, nextId, chromeCfg, theme))
306
+
307
+ // Top-left subtle map mode tag
308
+ const modeTag = model.mode === 'china'
309
+ ? (langEn ? 'CHINA REGIONAL HUBS' : '中国区域经济枢纽分布')
310
+ : (langEn ? 'GLOBAL STRATEGIC FOOTPRINT' : '全球战略布局热力图')
311
+ shapes.push(ooxmlShape(nextId(), 'Map Mode Badge', { x: mapBox.x + 0.18, y: mapBox.y + 0.12, w: 2.8, h: 0.24 }, {
312
+ txBox: true,
313
+ anchor: 'ctr',
314
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
315
+ paragraphs: [ooxmlRichParagraph(modeTag, { sizePt: 9, color: tk.inkMuted, bold: true, lang: langAttr, font: theme.fonts.body, spc: 120 })],
316
+ }))
317
+
318
+ // Dotted landmass silhouette (inset inside mapBox)
319
+ const padX = 0.34, padTop = 0.44, padBot = 0.28
320
+ const plotW = mapBox.w - padX * 2
321
+ const plotH = mapBox.h - padTop - padBot
322
+ const dotSize = model.mode === 'china' ? 0.11 : 0.095
323
+ const dotColor = theme.dark ? mixHex(tk.inkMuted, tk.surface2, 0.35) : mixHex(tk.hairline, tk.inkMuted, 0.32)
324
+ for (let i = 0; i < model.dots.length; i += 1) {
325
+ const [nx, ny] = model.dots[i]
326
+ const dx = mapBox.x + padX + nx * plotW - dotSize / 2
327
+ const dy = mapBox.y + padTop + ny * plotH - dotSize / 2
328
+ shapes.push(ooxmlShape(nextId(), `Map Dot ${i}`, { x: dx, y: dy, w: dotSize, h: dotSize }, {
329
+ preset: 'ellipse',
330
+ fill: dotColor,
331
+ fillAlpha: theme.dark ? 0.42 : 0.58,
332
+ }))
333
+ }
334
+
335
+ // Place hub hotspots inside plot region
336
+ const plotBox = { x: mapBox.x + padX, y: mapBox.y + padTop, w: plotW, h: plotH }
337
+ const placed = placeMapBadges(model.regions, plotBox)
338
+ const focalPlaced = placed.find((p) => p.isFocal) || placed[0]
339
+
340
+ // Subtle dashed network links from focal hub to secondary hubs
341
+ placed.forEach((p, idx) => {
342
+ if (p === focalPlaced) return
343
+ shapes.push(ooxmlLine(nextId(), `Map Link ${idx}`, { x: focalPlaced.cx, y: focalPlaced.cy }, { x: p.cx, y: p.cy }, {
344
+ color: tk.accentPrimary,
345
+ widthPt: 0.75,
346
+ dash: 'dash',
347
+ }))
348
+ })
349
+
350
+ // Render outer halo + inner dot + callout badge
351
+ placed.forEach((p, idx) => {
352
+ const col = colors[idx]
353
+ const outerD = 0.28 + 0.30 * p.radiusNorm
354
+ const innerD = 0.13 + 0.11 * p.radiusNorm
355
+ shapes.push(ooxmlShape(nextId(), `Map Halo ${idx + 1}`, { x: p.cx - outerD / 2, y: p.cy - outerD / 2, w: outerD, h: outerD }, {
356
+ preset: 'ellipse',
357
+ fill: col,
358
+ fillAlpha: 0.22,
359
+ stroke: col,
360
+ strokeAlpha: 0.45,
361
+ strokePt: 0.75,
362
+ }))
363
+ shapes.push(ooxmlShape(nextId(), `Map Hub ${idx + 1}`, { x: p.cx - innerD / 2, y: p.cy - innerD / 2, w: innerD, h: innerD }, {
364
+ preset: 'ellipse',
365
+ fill: col,
366
+ stroke: theme.dark ? tk.canvas : '#FFFFFF',
367
+ strokePt: 1.25,
368
+ }))
369
+ shapes.push(ooxmlShape(nextId(), `Map Tag ${idx + 1}`, { x: p.bx, y: p.by, w: p.bw, h: p.bh }, {
370
+ preset: 'roundRect',
371
+ adj: 50000,
372
+ fill: p.isFocal ? col : (theme.dark ? tk.surface2 : '#FFFFFF'),
373
+ stroke: col,
374
+ strokePt: p.isFocal ? 0 : 0.9,
375
+ anchor: 'ctr',
376
+ marginsIn: { l: 0.05, r: 0.05, t: 0.01, b: 0.01 },
377
+ paragraphs: [
378
+ ooxmlRichParagraph(p.labelText, {
379
+ sizePt: 9.5,
380
+ color: p.isFocal ? contrastInk(col) : tk.inkPrimary,
381
+ bold: true,
382
+ lang: langAttr,
383
+ align: 'ctr',
384
+ font: theme.fonts.body,
385
+ }),
386
+ ],
387
+ }))
388
+ })
389
+
390
+ // Right sidecar: Ranked Regional Breakdown cards
391
+ const shown = model.regions.slice(0, 6)
392
+ const gap = 0.12
393
+ const rowH = Math.min(0.86, (sideBox.h - gap * Math.max(0, shown.length - 1)) / Math.max(1, shown.length))
394
+ const startY = sideBox.y + Math.max(0, (sideBox.h - (rowH * shown.length + gap * Math.max(0, shown.length - 1))) / 2)
395
+
396
+ shown.forEach((r, idx) => {
397
+ const col = colors[idx]
398
+ const ry = startY + idx * (rowH + gap)
399
+ const rBox = { x: sideBox.x, y: ry, w: sideBox.w, h: rowH }
400
+ shapes.push(renderSurfaceCardPptx(`Map Rank Card ${idx + 1}`, rBox, {
401
+ fill: r.isFocal ? tk.accentSoft : tk.surface1,
402
+ focal: r.isFocal,
403
+ }, nextId, chromeCfg, theme))
404
+
405
+ // Rank pill
406
+ shapes.push(ooxmlShape(nextId(), `Rank Num ${idx + 1}`, { x: rBox.x + 0.14, y: ry + 0.09, w: 0.34, h: 0.22 }, {
407
+ preset: cardPreset,
408
+ adj: roundRectAdj(0.34, 0.22, 4),
409
+ fill: r.isFocal ? col : tk.surface2,
410
+ anchor: 'ctr',
411
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
412
+ paragraphs: [ooxmlRichParagraph(String(r.rank).padStart(2, '0'), { sizePt: 9.5, color: r.isFocal ? contrastInk(col) : tk.inkMuted, bold: true, align: 'ctr', font: theme.fonts.body })],
413
+ }))
414
+
415
+ // Region name
416
+ shapes.push(ooxmlShape(nextId(), `Region Name ${idx + 1}`, { x: rBox.x + 0.54, y: ry + 0.07, w: 1.75, h: 0.26 }, {
417
+ txBox: true,
418
+ anchor: 'ctr',
419
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
420
+ paragraphs: [ooxmlRichParagraph(r.title, { sizePt: 12.5, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading })],
421
+ }))
422
+
423
+ // Value + delta right-aligned
424
+ const valLine = [r.value, r.delta].filter(Boolean).join(' ')
425
+ shapes.push(ooxmlShape(nextId(), `Region Val ${idx + 1}`, { x: rBox.x + 2.28, y: ry + 0.07, w: rBox.w - 2.42, h: 0.26 }, {
426
+ txBox: true,
427
+ anchor: 'ctr',
428
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
429
+ paragraphs: [ooxmlRichParagraph(valLine || `${r.sharePct}%`, { sizePt: 12, color: r.isFocal ? tk.accentText : col, bold: true, align: 'r', lang: langAttr, font: theme.fonts.heading })],
430
+ }))
431
+
432
+ // Proportional bar track + fill
433
+ const barX = rBox.x + 0.14
434
+ const barW = rBox.w - 0.28
435
+ const showNote = rowH >= 0.72 && Boolean(r.text)
436
+ const barY = ry + (showNote ? 0.38 : rowH - 0.18)
437
+ shapes.push(ooxmlShape(nextId(), `Bar Track ${idx + 1}`, { x: barX, y: barY, w: barW, h: 0.075 }, {
438
+ preset: 'roundRect',
439
+ adj: 50000,
440
+ fill: tk.hairline,
441
+ fillAlpha: 0.55,
442
+ }))
443
+ shapes.push(ooxmlShape(nextId(), `Bar Fill ${idx + 1}`, { x: barX, y: barY, w: Math.max(0.18, barW * r.ratio), h: 0.075 }, {
444
+ preset: 'roundRect',
445
+ adj: 50000,
446
+ fill: col,
447
+ }))
448
+
449
+ if (showNote) {
450
+ shapes.push(ooxmlShape(nextId(), `Region Note ${idx + 1}`, { x: barX, y: barY + 0.11, w: barW, h: Math.max(0.20, rowH - (barY - ry) - 0.16) }, {
451
+ txBox: true,
452
+ anchor: 'ctr',
453
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
454
+ paragraphs: [ooxmlRichParagraph(r.text, { sizePt: 9.8, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body })],
455
+ }))
456
+ }
457
+ })
458
+
459
+ return shapes.join('')
460
+ }
461
+
462
+ function renderMapHtml(slide, ctx) {
463
+ const { theme, langId } = ctx
464
+ const tk = theme.tokens
465
+ const langEn = langId === 'en'
466
+ const model = computeMapModel(slide, langEn)
467
+ const colors = resolveRegionColors(model.regions, tk)
468
+
469
+ const vw = 760, vh = 460
470
+ const padX = 36, padTop = 44, padBot = 28
471
+ const pw = vw - padX * 2, ph = vh - padTop - padBot
472
+ const dotR = model.mode === 'china' ? 5.2 : 4.4
473
+ const dotColor = theme.dark ? mixHex(tk.inkMuted, tk.surface2, 0.35) : mixHex(tk.hairline, tk.inkMuted, 0.32)
474
+
475
+ const dotsSvg = model.dots.map(([nx, ny]) =>
476
+ `<circle cx="${(padX + nx * pw).toFixed(1)}" cy="${(padTop + ny * ph).toFixed(1)}" r="${dotR}" fill="${dotColor}" opacity="${theme.dark ? '0.45' : '0.6'}"/>`
477
+ ).join('')
478
+
479
+ const focal = model.focal
480
+ const fx = padX + (focal.x / 100) * pw
481
+ const fy = padTop + (focal.y / 100) * ph
482
+
483
+ const linksSvg = model.regions.filter((r) => r !== focal).map((r) => {
484
+ const rx = padX + (r.x / 100) * pw
485
+ const ry = padTop + (r.y / 100) * ph
486
+ return `<line x1="${fx.toFixed(1)}" y1="${fy.toFixed(1)}" x2="${rx.toFixed(1)}" y2="${ry.toFixed(1)}" stroke="${tk.accentPrimary}" stroke-width="1.3" stroke-dasharray="5 4" opacity="0.55"/>`
487
+ }).join('')
488
+
489
+ const hubsSvg = model.regions.map((r, idx) => {
490
+ const col = colors[idx]
491
+ const rx = padX + (r.x / 100) * pw
492
+ const ry = padTop + (r.y / 100) * ph
493
+ const outerR = 14 + 15 * r.radiusNorm
494
+ const innerR = 6.5 + 5 * r.radiusNorm
495
+ const lbl = r.value ? `${r.title} · ${r.value}` : r.title
496
+ const pillW = Math.min(188, Math.max(76, lbl.length * 10.5 + 22))
497
+ const px = clamp(rx - pillW / 2, 10, vw - pillW - 10)
498
+ const py = clamp(ry - outerR - 26, 26, vh - 30)
499
+ const pillFill = r.isFocal ? col : (theme.dark ? tk.surface2 : '#FFFFFF')
500
+ const pillInk = r.isFocal ? contrastInk(col) : tk.inkPrimary
501
+ return (
502
+ `<circle cx="${rx.toFixed(1)}" cy="${ry.toFixed(1)}" r="${outerR.toFixed(1)}" fill="${col}" fill-opacity="0.22" stroke="${col}" stroke-opacity="0.48" stroke-width="1.4"/>` +
503
+ `<circle cx="${rx.toFixed(1)}" cy="${ry.toFixed(1)}" r="${innerR.toFixed(1)}" fill="${col}" stroke="${theme.dark ? tk.canvas : '#FFFFFF'}" stroke-width="2.2"/>` +
504
+ `<rect x="${px.toFixed(1)}" y="${py.toFixed(1)}" width="${pillW.toFixed(1)}" height="23" rx="11.5" fill="${pillFill}" stroke="${col}" stroke-width="${r.isFocal ? 0 : 1.2}"/>` +
505
+ `<text x="${(px + pillW / 2).toFixed(1)}" y="${(py + 15.5).toFixed(1)}" text-anchor="middle" font-size="11.5" font-weight="700" fill="${pillInk}">${escapeHtml(lbl)}</text>`
506
+ )
507
+ }).join('')
508
+
509
+ const modeTag = model.mode === 'china'
510
+ ? (langEn ? 'CHINA REGIONAL HUBS' : '中国区域经济枢纽分布')
511
+ : (langEn ? 'GLOBAL STRATEGIC FOOTPRINT' : '全球战略布局热力图')
512
+
513
+ const rankCards = model.regions.slice(0, 6).map((r, idx) => {
514
+ const col = colors[idx]
515
+ const valLine = [r.value, r.delta].filter(Boolean).join(' ')
516
+ return (
517
+ `<div class="surface-card map-rank-card${r.isFocal ? ' is-focal' : ''}" data-item-index="${r.rawIndex}">` +
518
+ `<div class="map-rank-head">` +
519
+ `<span class="map-rank-num" style="${r.isFocal ? `background:${col};color:${contrastInk(col)}` : ''}">${String(r.rank).padStart(2, '0')}</span>` +
520
+ `<strong class="map-rank-name" data-item-field="title">${escapeHtml(r.title)}</strong>` +
521
+ `<span class="map-rank-val" style="color:${r.isFocal ? 'var(--accent-text)' : col}">${escapeHtml(valLine || `${r.sharePct}%`)}</span>` +
522
+ `</div>` +
523
+ `<div class="map-bar-track"><div class="map-bar-fill" style="width:${Math.round(r.ratio * 100)}%;background:${col}"></div></div>` +
524
+ (r.text ? `<div class="map-rank-note" data-item-field="text">${renderInlineHtml(r.text)}</div>` : '') +
525
+ `</div>`
526
+ )
527
+ }).join('')
528
+
529
+ return (
530
+ `<div class="info-map-board">` +
531
+ `<div class="surface-card info-map-canvas">` +
532
+ `<div class="info-map-mode">${escapeHtml(modeTag)}</div>` +
533
+ `<svg class="info-map-svg" viewBox="0 0 ${vw} ${vh}" role="img" aria-label="${escapeHtml(slide.title || modeTag)}">${dotsSvg}${linksSvg}${hubsSvg}</svg>` +
534
+ `</div>` +
535
+ `<div class="info-map-side">${rankCards}</div>` +
536
+ `</div>`
537
+ )
538
+ }
539
+
540
+ // ---------------------------------------------------------------------------
541
+ // 2. 2.5D 等轴测矢量信息图(Isometric Stack & Isometric 3D Pillars)
542
+ // ---------------------------------------------------------------------------
543
+
544
+ export function computeIsometricModel(slide, langEn = false) {
545
+ const variant = String(slide?.variant || '').trim().toLowerCase() === 'pillars' ? 'pillars' : 'stack'
546
+ let rawItems = resolveEffectiveItems(slide)
547
+ if (rawItems.length === 0 && Array.isArray(slide?.rows) && slide.rows.length >= 2) {
548
+ rawItems = slide.rows.slice(1).map((r) => ({
549
+ title: stripInlineMarkdown(r[0] || ''),
550
+ value: String(r[1] ?? '').trim(),
551
+ text: stripInlineMarkdown(r[2] || ''),
552
+ delta: String(r[3] ?? '').trim(),
553
+ })).filter((it) => it.title)
554
+ }
555
+ if (rawItems.length === 0) {
556
+ rawItems = variant === 'pillars'
557
+ ? (langEn
558
+ ? [
559
+ { tag: 'Phase 1', title: 'Core Engine', value: '42', unit: 'pts', delta: 'Baseline' },
560
+ { tag: 'Phase 2', title: 'Agent Layer', value: '68', unit: 'pts', delta: '+62%' },
561
+ { tag: 'Phase 3', title: 'Enterprise Scale', value: '94', unit: 'pts', delta: '+124%', status: 'accent' },
562
+ ]
563
+ : [
564
+ { tag: '阶段一', title: '基础底座', value: '42', unit: '分', delta: '基线能力' },
565
+ { tag: '阶段二', title: '智能体协同', value: '68', unit: '分', delta: '+62%' },
566
+ { tag: '阶段三', title: '企业级规模化', value: '94', unit: '分', delta: '+124%', status: 'accent' },
567
+ ])
568
+ : (langEn
569
+ ? [
570
+ { tag: 'L4 · Experience', title: 'Multi-Modal Copilot UI', text: 'Zero-friction workspace & live preview' },
571
+ { tag: 'L3 · Orchestration', title: 'Deterministic Agent Runtime', text: 'Fact-checking, tool guardrails & self-repair' },
572
+ { tag: 'L2 · Knowledge', title: 'Unified Evidence & Vector Graph', text: 'Primary citations, lineage & enterprise memory' },
573
+ { tag: 'L1 · Infrastructure', title: 'High-Throughput Inference Mesh', text: 'Low-latency routing & multi-region resilience' },
574
+ ]
575
+ : [
576
+ { tag: 'L4 · 体验层', title: '多端交互与实时预览工作台', text: '零门槛操控、在线精修与一键多格式交付' },
577
+ { tag: 'L3 · 编排层', title: '确定性 Agent 调度与门禁引擎', text: '任务拆解、SLOP 质量自检修复与事实溯源' },
578
+ { tag: 'L2 · 知识层', title: '企业证据账本与向量语义图谱', text: '一手出处绑定、口径一致性与领域范本沉淀' },
579
+ { tag: 'L1 · 底座层', title: '高吞吐推理与安全隔离算力网', text: '多模型路由、低延迟并发与合规审计隔离' },
580
+ ])
581
+ }
582
+
583
+ const maxCount = variant === 'pillars' ? 4 : 5
584
+ const items = rawItems.slice(0, maxCount).map((it, idx) => {
585
+ const valStr = String(it.value ?? '').trim()
586
+ const numVal = parseNum(valStr, NaN)
587
+ return {
588
+ index: idx,
589
+ tag: stripInlineMarkdown(it.tag || (variant === 'pillars' ? `0${idx + 1}` : `L${Math.min(maxCount, rawItems.length) - idx}`)),
590
+ title: stripInlineMarkdown(it.title || it.text || `Layer ${idx + 1}`),
591
+ text: stripInlineMarkdown(it.text || (Array.isArray(it.bullets) ? it.bullets.join(' · ') : '')),
592
+ value: valStr,
593
+ unit: stripInlineMarkdown(it.unit || ''),
594
+ delta: stripInlineMarkdown(it.delta || ''),
595
+ status: it.status || '',
596
+ numericVal: numVal,
597
+ }
598
+ })
599
+
600
+ const hasExplicitNums = items.some((it) => Number.isFinite(it.numericVal))
601
+ const resolvedVals = items.map((it, idx) =>
602
+ Number.isFinite(it.numericVal) ? Math.max(1, it.numericVal) : (idx + 1) * 28 + 20
603
+ )
604
+ const maxV = Math.max(1, ...resolvedVals)
605
+ return {
606
+ variant,
607
+ hasExplicitNums,
608
+ items: items.map((it, idx) => ({
609
+ ...it,
610
+ ratio: clamp(resolvedVals[idx] / maxV, 0.28, 1),
611
+ })),
612
+ }
613
+ }
614
+
615
+ function isometricLayerColors(count, tk, dark) {
616
+ const palette = [
617
+ tk.accentPrimary,
618
+ tk.accentSecondary || mixHex(tk.accentPrimary, '#0E7490', 0.45),
619
+ mixHex(tk.accentPrimary, tk.surface2 || '#CBD5E1', dark ? 0.35 : 0.45),
620
+ mixHex(tk.accentSecondary || tk.accentPrimary, tk.surface2 || '#CBD5E1', dark ? 0.52 : 0.62),
621
+ dark ? '#334155' : '#94A3B8',
622
+ ]
623
+ return Array.from({ length: count }, (_, idx) => {
624
+ const top = palette[idx % palette.length]
625
+ const left = mixHex(top, '#020617', 0.22)
626
+ const right = mixHex(top, '#020617', 0.40)
627
+ return { top, left, right }
628
+ })
629
+ }
630
+
631
+ function renderIsometricStackPptx(slide, model, ctx) {
632
+ const { theme, langAttr, chromeCfg, nextId, bodyTopY, bodyH } = ctx
633
+ const tk = theme.tokens
634
+ const shapes = []
635
+ const items = model.items
636
+ const n = items.length
637
+ const colors = isometricLayerColors(n, tk, theme.dark)
638
+
639
+ // Left 3D isometric stack stage: x 0.62 .. 6.75 (leave crisp left margin for layer badges!)
640
+ const cx = 4.10
641
+ const rx = 2.28
642
+ const ry = Math.min(0.56, (bodyH * 0.24) / Math.max(1, n * 0.35))
643
+ const thickness = n >= 5 ? 0.22 : 0.27
644
+ const spanY = Math.max(0.65, bodyH - ry * 2 - thickness - 0.34)
645
+ const stepY = n > 1 ? spanY / (n - 1) : 0
646
+ const topCy = bodyTopY + ry + 0.14
647
+
648
+ // Right explanation cards: x 7.12 .. 12.71
649
+ const cardX = 7.12
650
+ const cardW = 5.59
651
+ const cardGap = 0.12
652
+ const cardH = Math.min(1.06, (bodyH - 0.14 - cardGap * Math.max(0, n - 1)) / Math.max(1, n))
653
+ const cardStartY = bodyTopY + Math.max(0.06, (bodyH - (cardH * n + cardGap * Math.max(0, n - 1))) / 2)
654
+
655
+ // Draw slabs bottom-to-top so upper isometric layers overlap lower ones cleanly!
656
+ for (let i = n - 1; i >= 0; i -= 1) {
657
+ const it = items[i]
658
+ const col = colors[i]
659
+ const cy = topCy + i * stepY
660
+ const pTop = [cx, cy - ry]
661
+ const pRight = [cx + rx, cy]
662
+ const pBot = [cx, cy + ry]
663
+ const pLeft = [cx - rx, cy]
664
+ const pLeftD = [cx - rx, cy + thickness]
665
+ const pBotD = [cx, cy + ry + thickness]
666
+ const pRightD = [cx + rx, cy + thickness]
667
+
668
+ // Left shaded face
669
+ shapes.push(renderCustomPolyPptx(nextId(), `Iso Slab Left ${i + 1}`, [pLeft, pBot, pBotD, pLeftD], {
670
+ fill: col.left,
671
+ stroke: theme.dark ? tk.canvas : '#FFFFFF',
672
+ strokeAlpha: 0.35,
673
+ strokePt: 0.5,
674
+ }))
675
+ // Right deeper shaded face
676
+ shapes.push(renderCustomPolyPptx(nextId(), `Iso Slab Right ${i + 1}`, [pBot, pRight, pRightD, pBotD], {
677
+ fill: col.right,
678
+ stroke: theme.dark ? tk.canvas : '#FFFFFF',
679
+ strokeAlpha: 0.35,
680
+ strokePt: 0.5,
681
+ }))
682
+ // Top isometric diamond face
683
+ shapes.push(renderCustomPolyPptx(nextId(), `Iso Slab Top ${i + 1}`, [pTop, pRight, pBot, pLeft], {
684
+ fill: col.top,
685
+ stroke: '#FFFFFF',
686
+ strokeAlpha: 0.55,
687
+ strokePt: 0.75,
688
+ }))
689
+
690
+ // Top slab shows full crisp label centered on its unobstructed face; all slabs get crisp non-occluded left index pills!
691
+ const slabLabel = it.tag || it.title.slice(0, 12)
692
+ if (i === 0) {
693
+ shapes.push(ooxmlShape(nextId(), `Iso Face Label ${i + 1}`, { x: cx - rx * 0.62, y: cy - 0.18, w: rx * 1.24, h: 0.36 }, {
694
+ txBox: true,
695
+ anchor: 'ctr',
696
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
697
+ paragraphs: [
698
+ ooxmlRichParagraph(slabLabel, {
699
+ sizePt: 11.5,
700
+ color: contrastInk(col.top),
701
+ bold: true,
702
+ align: 'ctr',
703
+ lang: langAttr,
704
+ font: theme.fonts.heading,
705
+ }),
706
+ ],
707
+ }))
708
+ }
709
+ const shortTag = /^L\d+/i.test(slabLabel) ? slabLabel.split(/[·\s::-]+/)[0] : `0${i + 1}`
710
+ const pillW = Math.min(1.02, Math.max(0.56, computeBadgePillWidth(shortTag, 9.5, 1.02, 0.56)))
711
+ const pillX = 0.64
712
+ const pillY = cy - 0.13
713
+ shapes.push(ooxmlLine(nextId(), `Iso Left Tick ${i + 1}`, { x: pillX + pillW + 0.04, y: cy }, { x: cx - rx - 0.06, y: cy }, {
714
+ color: col.top,
715
+ widthPt: 0.9,
716
+ dash: i === 0 ? '' : 'dash',
717
+ }))
718
+ shapes.push(ooxmlShape(nextId(), `Iso Left Pill ${i + 1}`, { x: pillX, y: pillY, w: pillW, h: 0.26 }, {
719
+ preset: 'roundRect',
720
+ adj: 50000,
721
+ fill: col.top,
722
+ anchor: 'ctr',
723
+ marginsIn: { l: 0.04, r: 0.04, t: 0, b: 0 },
724
+ paragraphs: [ooxmlRichParagraph(shortTag, { sizePt: 9.5, color: contrastInk(col.top), bold: true, align: 'ctr', lang: langAttr, font: theme.fonts.heading })],
725
+ }))
726
+
727
+ // Precision horizontal connector line from right corner of slab to explanation card
728
+ const cardY = cardStartY + i * (cardH + cardGap)
729
+ const cardMidY = cardY + cardH / 2
730
+ const connStartX = cx + rx + 0.06
731
+ const connEndX = cardX - 0.08
732
+ shapes.push(ooxmlLine(nextId(), `Iso Leader ${i + 1}`, { x: connStartX, y: cy }, { x: connEndX, y: cardMidY }, {
733
+ color: col.top,
734
+ widthPt: 1.1,
735
+ dash: i === 0 ? '' : 'dash',
736
+ }))
737
+ shapes.push(ooxmlShape(nextId(), `Iso Anchor ${i + 1}`, { x: connStartX - 0.05, y: cy - 0.05, w: 0.10, h: 0.10 }, {
738
+ preset: 'ellipse',
739
+ fill: col.top,
740
+ }))
741
+
742
+ // Right explanation card
743
+ const cBox = { x: cardX, y: cardY, w: cardW, h: cardH }
744
+ shapes.push(renderSurfaceCardPptx(`Iso Info Card ${i + 1}`, cBox, {
745
+ fill: i === 0 ? tk.accentSoft : tk.surface1,
746
+ focal: i === 0,
747
+ }, nextId, chromeCfg, theme))
748
+ shapes.push(ooxmlShape(nextId(), `Iso Card Rail ${i + 1}`, { x: cBox.x, y: cBox.y, w: 0.06, h: cBox.h }, {
749
+ preset: 'rect',
750
+ fill: col.top,
751
+ }))
752
+
753
+ const paras = []
754
+ const titleLine = it.value ? `${it.title} · ${it.value}${it.unit ? ' ' + it.unit : ''}` : it.title
755
+ paras.push(ooxmlRichParagraph(titleLine, {
756
+ sizePt: n >= 5 ? 13 : 14,
757
+ color: tk.inkPrimary,
758
+ bold: true,
759
+ lang: langAttr,
760
+ font: theme.fonts.heading,
761
+ spaceAfterPt: it.text ? 2 : 0,
762
+ }))
763
+ if (it.text) {
764
+ paras.push(ooxmlRichParagraph(it.text, {
765
+ sizePt: n >= 5 ? 11.5 : 12.5,
766
+ color: tk.inkSecondary,
767
+ lang: langAttr,
768
+ font: theme.fonts.body,
769
+ lineHeight: 1.28,
770
+ }))
771
+ }
772
+ shapes.push(ooxmlShape(nextId(), `Iso Card Text ${i + 1}`, { x: cBox.x + 0.18, y: cBox.y + 0.06, w: cBox.w - 0.28, h: cBox.h - 0.12 }, {
773
+ txBox: true,
774
+ anchor: 'ctr',
775
+ marginsIn: { l: 0.02, r: 0.02, t: 0.01, b: 0.01 },
776
+ paragraphs: paras,
777
+ }))
778
+ }
779
+
780
+ return shapes.join('')
781
+ }
782
+
783
+ function renderIsometricPillarsPptx(slide, model, ctx) {
784
+ const { theme, langAttr, chromeCfg, nextId, bodyTopY, bodyH } = ctx
785
+ const tk = theme.tokens
786
+ const shapes = []
787
+ const items = model.items
788
+ const n = items.length
789
+
790
+ const stageX = 0.62
791
+ const stageW = 12.09
792
+ const baseLineY = bodyTopY + bodyH * 0.69
793
+ const maxBarH = Math.max(1.1, bodyH * 0.36)
794
+ const colW = stageW / n
795
+ const rx = Math.min(0.92, colW * 0.29)
796
+ const ry = rx * 0.42
797
+
798
+ // Subtle architectural ground baseline
799
+ shapes.push(ooxmlLine(nextId(), 'Iso Pillars Ground', { x: stageX + 0.2, y: baseLineY + ry + 0.06 }, { x: stageX + stageW - 0.2, y: baseLineY + ry + 0.06 }, {
800
+ color: tk.hairline,
801
+ widthPt: 1.0,
802
+ }))
803
+
804
+ items.forEach((it, idx) => {
805
+ const isFocal = it.status === 'accent' || idx === n - 1
806
+ const baseCol = isFocal
807
+ ? tk.accentPrimary
808
+ : (idx === n - 2 ? (tk.accentSecondary || mixHex(tk.accentPrimary, tk.surface2, 0.3)) : mixHex(tk.accentPrimary, tk.surface2 || '#CBD5E1', theme.dark ? 0.45 : 0.55))
809
+ const leftCol = mixHex(baseCol, '#020617', 0.18)
810
+ const rightCol = mixHex(baseCol, '#020617', 0.36)
811
+
812
+ const cx = stageX + (idx + 0.5) * colW
813
+ const barH = Math.max(0.55, maxBarH * it.ratio)
814
+ const topY = baseLineY - barH
815
+
816
+ const pTop = [cx, topY - ry]
817
+ const pRight = [cx + rx, topY]
818
+ const pBot = [cx, topY + ry]
819
+ const pLeft = [cx - rx, topY]
820
+ const bLeft = [cx - rx, baseLineY]
821
+ const bBot = [cx, baseLineY + ry]
822
+ const bRight = [cx + rx, baseLineY]
823
+
824
+ // Ground soft shadow diamond
825
+ shapes.push(renderCustomPolyPptx(nextId(), `Iso Pillar Shadow ${idx + 1}`, [
826
+ [cx, baseLineY - ry * 0.7],
827
+ [cx + rx * 1.15, baseLineY + 0.04],
828
+ [cx, baseLineY + ry * 1.25],
829
+ [cx - rx * 1.15, baseLineY + 0.04],
830
+ ], { fill: tk.inkPrimary, fillAlpha: theme.dark ? 0.24 : 0.08 }))
831
+
832
+ // Left extruded wall
833
+ shapes.push(renderCustomPolyPptx(nextId(), `Iso Pillar Left ${idx + 1}`, [pLeft, pBot, bBot, bLeft], {
834
+ fill: leftCol,
835
+ stroke: '#FFFFFF',
836
+ strokeAlpha: 0.3,
837
+ strokePt: 0.5,
838
+ }))
839
+ // Right shaded wall
840
+ shapes.push(renderCustomPolyPptx(nextId(), `Iso Pillar Right ${idx + 1}`, [pBot, pRight, bRight, bBot], {
841
+ fill: rightCol,
842
+ stroke: '#FFFFFF',
843
+ strokeAlpha: 0.3,
844
+ strokePt: 0.5,
845
+ }))
846
+ // Top cap diamond
847
+ shapes.push(renderCustomPolyPptx(nextId(), `Iso Pillar Top ${idx + 1}`, [pTop, pRight, pBot, pLeft], {
848
+ fill: baseCol,
849
+ stroke: '#FFFFFF',
850
+ strokeAlpha: 0.65,
851
+ strokePt: 0.75,
852
+ }))
853
+
854
+ // Floating value + delta above top cap
855
+ const valStr = it.value ? `${it.value}${it.unit ? ' ' + it.unit : ''}` : it.tag
856
+ shapes.push(ooxmlShape(nextId(), `Iso Pillar Value ${idx + 1}`, { x: cx - colW * 0.44, y: topY - ry - 0.62, w: colW * 0.88, h: 0.38 }, {
857
+ txBox: true,
858
+ anchor: 'b',
859
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
860
+ paragraphs: [ooxmlRichParagraph(valStr, { sizePt: 22, color: isFocal ? tk.accentText : tk.inkPrimary, bold: true, align: 'ctr', lang: langAttr, font: theme.fonts.heading })],
861
+ }))
862
+ if (it.delta) {
863
+ const dw = computeBadgePillWidth(it.delta, 10, colW * 0.78, 0.72)
864
+ shapes.push(ooxmlShape(nextId(), `Iso Pillar Delta ${idx + 1}`, { x: cx - dw / 2, y: topY - ry - 0.90, w: dw, h: 0.24 }, {
865
+ preset: 'roundRect',
866
+ adj: 50000,
867
+ fill: isFocal ? tk.accentSoft : tk.surface2,
868
+ stroke: isFocal ? baseCol : tk.hairline,
869
+ strokePt: 0.75,
870
+ anchor: 'ctr',
871
+ marginsIn: { l: 0.04, r: 0.04, t: 0, b: 0 },
872
+ paragraphs: [ooxmlRichParagraph(it.delta, { sizePt: 9.5, color: isFocal ? tk.accentText : tk.inkSecondary, bold: true, align: 'ctr', lang: langAttr, font: theme.fonts.body })],
873
+ }))
874
+ }
875
+
876
+ // Bottom caption card
877
+ const capY = baseLineY + ry + 0.18
878
+ const capH = Math.max(0.85, bodyTopY + bodyH - capY - 0.06)
879
+ const capBox = { x: stageX + idx * colW + 0.12, y: capY, w: colW - 0.24, h: capH }
880
+ shapes.push(renderSurfaceCardPptx(`Iso Pillar Caption ${idx + 1}`, capBox, {
881
+ fill: isFocal ? tk.accentSoft : tk.surface1,
882
+ focal: isFocal,
883
+ }, nextId, chromeCfg, theme))
884
+ const cParas = [
885
+ ooxmlRichParagraph(it.title, { sizePt: 13.5, color: tk.inkPrimary, bold: true, align: 'ctr', lang: langAttr, font: theme.fonts.heading, spaceAfterPt: it.text ? 3 : 0 }),
886
+ ]
887
+ if (it.text) {
888
+ cParas.push(ooxmlRichParagraph(it.text, { sizePt: 11.5, color: tk.inkSecondary, align: 'ctr', lang: langAttr, font: theme.fonts.body, lineHeight: 1.25 }))
889
+ }
890
+ shapes.push(ooxmlShape(nextId(), `Iso Pillar CapText ${idx + 1}`, { x: capBox.x + 0.10, y: capBox.y + 0.06, w: capBox.w - 0.20, h: capBox.h - 0.12 }, {
891
+ txBox: true,
892
+ anchor: 'ctr',
893
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
894
+ paragraphs: cParas,
895
+ }))
896
+ })
897
+
898
+ return shapes.join('')
899
+ }
900
+
901
+ function renderIsometricHtml(slide, ctx) {
902
+ const { theme, langId } = ctx
903
+ const tk = theme.tokens
904
+ const langEn = langId === 'en'
905
+ const model = computeIsometricModel(slide, langEn)
906
+ const items = model.items
907
+ const n = items.length
908
+
909
+ if (model.variant === 'pillars') {
910
+ const vw = 1040, vh = 320
911
+ const colW = vw / n
912
+ const baseLineY = 266
913
+ const maxBarH = 158
914
+ const rx = Math.min(72, colW * 0.26)
915
+ const ry = rx * 0.42
916
+ let svg = `<line x1="28" y1="${(baseLineY + ry + 6).toFixed(1)}" x2="${vw - 28}" y2="${(baseLineY + ry + 6).toFixed(1)}" stroke="${tk.hairline}" stroke-width="1.5"/>`
917
+ items.forEach((it, idx) => {
918
+ const isFocal = it.status === 'accent' || idx === n - 1
919
+ const baseCol = isFocal
920
+ ? tk.accentPrimary
921
+ : (idx === n - 2 ? (tk.accentSecondary || mixHex(tk.accentPrimary, tk.surface2, 0.3)) : mixHex(tk.accentPrimary, tk.surface2 || '#CBD5E1', theme.dark ? 0.45 : 0.55))
922
+ const leftCol = mixHex(baseCol, '#020617', 0.18)
923
+ const rightCol = mixHex(baseCol, '#020617', 0.36)
924
+ const cx = (idx + 0.5) * colW
925
+ const bh = Math.max(46, maxBarH * it.ratio)
926
+ const topY = baseLineY - bh
927
+ const pts = (arr) => arr.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(' ')
928
+ svg += `<polygon points="${pts([[cx - rx, topY], [cx, topY + ry], [cx, baseLineY + ry], [cx - rx, baseLineY]])}" fill="${leftCol}" stroke="#FFFFFF" stroke-opacity="0.3"/>`
929
+ svg += `<polygon points="${pts([[cx, topY + ry], [cx + rx, topY], [cx + rx, baseLineY], [cx, baseLineY + ry]])}" fill="${rightCol}" stroke="#FFFFFF" stroke-opacity="0.3"/>`
930
+ svg += `<polygon points="${pts([[cx, topY - ry], [cx + rx, topY], [cx, topY + ry], [cx - rx, topY]])}" fill="${baseCol}" stroke="#FFFFFF" stroke-opacity="0.6"/>`
931
+ const valStr = it.value ? `${it.value}${it.unit ? ' ' + it.unit : ''}` : it.tag
932
+ svg += `<text x="${cx.toFixed(1)}" y="${(topY - ry - 14).toFixed(1)}" text-anchor="middle" font-size="24" font-weight="800" fill="${isFocal ? tk.accentText : tk.inkPrimary}">${escapeHtml(valStr)}</text>`
933
+ if (it.delta) {
934
+ svg += `<text x="${cx.toFixed(1)}" y="${(topY - ry - 42).toFixed(1)}" text-anchor="middle" font-size="13" font-weight="700" fill="${isFocal ? tk.accentText : tk.inkMuted}">${escapeHtml(it.delta)}</text>`
935
+ }
936
+ })
937
+ const caps = items.map((it, idx) => {
938
+ const isFocal = it.status === 'accent' || idx === n - 1
939
+ return (
940
+ `<div class="surface-card iso-pillar-cap${isFocal ? ' is-focal' : ''}" data-item-index="${idx}">` +
941
+ `<div class="card-title" data-item-field="title">${escapeHtml(it.title)}</div>` +
942
+ (it.text ? `<div class="card-body" data-item-field="text">${renderInlineHtml(it.text)}</div>` : '') +
943
+ `</div>`
944
+ )
945
+ }).join('')
946
+ return (
947
+ `<div class="iso-pillars-wrap">` +
948
+ `<svg class="iso-pillars-svg" viewBox="0 0 ${vw} ${vh}" role="img" aria-label="${escapeHtml(slide.title || 'Isometric pillars')}">${svg}</svg>` +
949
+ `<div class="layout-grid cols-${n} iso-pillars-caps">${caps}</div>` +
950
+ `</div>`
951
+ )
952
+ }
953
+
954
+ // Default variant: 'stack'
955
+ const colors = isometricLayerColors(n, tk, theme.dark)
956
+ const vw = 580, vh = 460
957
+ const cx = 330, rx = 198, ry = Math.min(54, 118 / Math.max(1, n * 0.45)), thick = n >= 5 ? 20 : 25
958
+ const spanY = Math.max(80, vh - ry * 2 - thick - 46)
959
+ const stepY = n > 1 ? spanY / (n - 1) : 0
960
+ const topCy = ry + 22
961
+ const pts = (arr) => arr.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(' ')
962
+ let svg = ''
963
+ for (let i = n - 1; i >= 0; i -= 1) {
964
+ const it = items[i]
965
+ const col = colors[i]
966
+ const cy = topCy + i * stepY
967
+ svg += `<polygon points="${pts([[cx - rx, cy], [cx, cy + ry], [cx, cy + ry + thick], [cx - rx, cy + thick]])}" fill="${col.left}" stroke="#FFFFFF" stroke-opacity="0.35"/>`
968
+ svg += `<polygon points="${pts([[cx, cy + ry], [cx + rx, cy], [cx + rx, cy + thick], [cx, cy + ry + thick]])}" fill="${col.right}" stroke="#FFFFFF" stroke-opacity="0.35"/>`
969
+ svg += `<polygon points="${pts([[cx, cy - ry], [cx + rx, cy], [cx, cy + ry], [cx - rx, cy]])}" fill="${col.top}" stroke="#FFFFFF" stroke-opacity="0.6"/>`
970
+ const slabLabel = it.tag || it.title.slice(0, 12)
971
+ if (i === 0) {
972
+ svg += `<text x="${cx}" y="${(cy + 5).toFixed(1)}" text-anchor="middle" font-size="14" font-weight="700" fill="${contrastInk(col.top)}">${escapeHtml(slabLabel)}</text>`
973
+ }
974
+ const shortTag = /^L\d+/i.test(slabLabel) ? slabLabel.split(/[·\s::-]+/)[0] : `0${i + 1}`
975
+ svg += `<line x1="78" y1="${cy.toFixed(1)}" x2="${(cx - rx - 8).toFixed(1)}" y2="${cy.toFixed(1)}" stroke="${col.top}" stroke-width="1.4" ${i === 0 ? '' : 'stroke-dasharray="4 3"'}/>`
976
+ svg += `<rect x="14" y="${(cy - 13).toFixed(1)}" width="58" height="26" rx="13" fill="${col.top}"/>`
977
+ svg += `<text x="43" y="${(cy + 4.5).toFixed(1)}" text-anchor="middle" font-size="12" font-weight="800" fill="${contrastInk(col.top)}">${escapeHtml(shortTag)}</text>`
978
+ }
979
+ const cards = items.map((it, idx) => {
980
+ const col = colors[idx]
981
+ const titleLine = it.value ? `${it.title} · ${it.value}${it.unit ? ' ' + it.unit : ''}` : it.title
982
+ return (
983
+ `<div class="surface-card iso-stack-card${idx === 0 ? ' is-focal' : ''}" style="border-left:5px solid ${col.top}" data-item-index="${idx}">` +
984
+ `<div class="card-title" data-item-field="title">${escapeHtml(titleLine)}</div>` +
985
+ (it.text ? `<div class="card-body" data-item-field="text">${renderInlineHtml(it.text)}</div>` : '') +
986
+ `</div>`
987
+ )
988
+ }).join('')
989
+ return (
990
+ `<div class="iso-stack-board">` +
991
+ `<div class="iso-stack-stage"><svg class="iso-stack-svg" viewBox="0 0 ${vw} ${vh}" role="img" aria-label="${escapeHtml(slide.title || 'Isometric stack')}">${svg}</svg></div>` +
992
+ `<div class="iso-stack-cards">${cards}</div>` +
993
+ `</div>`
994
+ )
995
+ }
996
+
997
+ export function renderInfographicSlideBodyPptx(slide, ctx) {
998
+ const layout = slide?.layout
999
+ if (!INFOGRAPHIC_LAYOUTS.has(layout)) return null
1000
+ if (layout === 'map') return renderMapPptx(slide, ctx)
1001
+ const model = computeIsometricModel(slide, ctx.langAttr === 'en-US')
1002
+ return model.variant === 'pillars'
1003
+ ? renderIsometricPillarsPptx(slide, model, ctx)
1004
+ : renderIsometricStackPptx(slide, model, ctx)
1005
+ }
1006
+
1007
+ export function renderInfographicSlideBodyHtml(slide, ctx) {
1008
+ const layout = slide?.layout
1009
+ if (!INFOGRAPHIC_LAYOUTS.has(layout)) return null
1010
+ if (layout === 'map') return renderMapHtml(slide, ctx)
1011
+ return renderIsometricHtml(slide, ctx)
1012
+ }
1013
+
1014
+ // ---------------------------------------------------------------------------
1015
+ // 3. 智能配图协作 Brief(Visual Brief Generator + Editorial Blueprint Slot)
1016
+ // ---------------------------------------------------------------------------
1017
+
1018
+ export function normalizeImageBrief(raw) {
1019
+ if (raw === undefined || raw === null || raw === '') return undefined
1020
+ if (typeof raw === 'string') {
1021
+ const prompt = raw.replace(/\s+/g, ' ').trim().slice(0, 400)
1022
+ return prompt ? { prompt } : undefined
1023
+ }
1024
+ if (typeof raw === 'object' && !Array.isArray(raw)) {
1025
+ const prompt = String(raw.prompt ?? raw.description ?? raw.subject ?? '').replace(/\s+/g, ' ').trim().slice(0, 400)
1026
+ const aspect = String(raw.aspect ?? raw.recommendedAspect ?? '').trim().slice(0, 16)
1027
+ const mood = String(raw.mood ?? '').trim().slice(0, 40)
1028
+ const safeZone = String(raw.safeZone ?? raw.compositionGuide ?? '').replace(/\s+/g, ' ').trim().slice(0, 180)
1029
+ const style = String(raw.style ?? '').trim().slice(0, 60)
1030
+ if (!prompt && !safeZone) return undefined
1031
+ return {
1032
+ ...(prompt ? { prompt } : {}),
1033
+ ...(aspect ? { aspect } : {}),
1034
+ ...(mood ? { mood } : {}),
1035
+ ...(safeZone ? { safeZone } : {}),
1036
+ ...(style ? { style } : {}),
1037
+ }
1038
+ }
1039
+ return undefined
1040
+ }
1041
+
1042
+ /**
1043
+ * 为封面/图文槽位确定性生成与当前主题色板、明暗极性、留白区严格对齐的配图 Brief。
1044
+ */
1045
+ export function generateVisualBrief(slide = {}, theme = null, lang = 'zh') {
1046
+ const langEn = String(lang || 'zh').toLowerCase() === 'en'
1047
+ const layout = String(slide.layout || 'image-right').toLowerCase()
1048
+ const variant = String(slide.variant || '').toLowerCase()
1049
+ const title = stripInlineMarkdown(slide.title || slide.topic || 'Executive presentation visual')
1050
+ const tk = theme?.tokens || {}
1051
+ const dark = Boolean(theme?.dark)
1052
+ const accentPrimary = tk.accentPrimary || theme?.palette?.accent || '#0057B8'
1053
+ const accentSecondary = tk.accentSecondary || theme?.palette?.accent2 || '#0E7490'
1054
+ const canvas = tk.canvas || theme?.palette?.bg || (dark ? '#0B1020' : '#FFFFFF')
1055
+
1056
+ let recommendedAspect = '4:3'
1057
+ let safeZoneEn = 'Center primary subject cleanly with subtle editorial margin; avoid text overlays.'
1058
+ let safeZoneZh = '主体居中并保留四周呼吸留白;画面内严禁生成任何文字或乱码标签。'
1059
+ if (layout === 'cover') {
1060
+ recommendedAspect = '8:9'
1061
+ safeZoneEn = 'Right-half hero photo split (8:9 vertical); anchor focal subject in right 70%, keep left border clean for seamless dark-panel seam; zero text in image.'
1062
+ safeZoneZh = '封面右侧半屏出血(8:9 竖幅):主体锚定右侧 70%,左侧边缘保持简洁以便与深色排版区无缝衔接;严禁图内文字。'
1063
+ } else if (layout === 'image' && variant === 'full-bleed') {
1064
+ recommendedAspect = '16:9'
1065
+ safeZoneEn = '16:9 full-bleed hero; place main subject in upper 60%, keep bottom 32% low-detail/darker for protective title scrim; zero text in image.'
1066
+ safeZoneZh = '16:9 全屏出血主图:视觉主体置于上半 60%,底部 32% 保持简洁暗调以承接标题渐变压暗层;严禁图内文字。'
1067
+ } else if (layout === 'image-left' || layout === 'image-right') {
1068
+ recommendedAspect = variant === 'split-bleed' ? '5:6' : '4:3'
1069
+ safeZoneEn = `${recommendedAspect} split-frame visual; crisp focal subject aligned away from text column; zero embedded text.`
1070
+ safeZoneZh = `${recommendedAspect} 图文分栏配图:主体清晰聚焦、避免与文字栏边界争抢焦点;严禁图内文字。`
1071
+ }
1072
+
1073
+ const moodLabel = dark ? 'sleek moody studio lighting, obsidian-depth shadows' : 'clean architectural daylight studio photography, airy editorial light'
1074
+ const explicitPrompt = typeof slide.imageBrief === 'string'
1075
+ ? slide.imageBrief.trim()
1076
+ : (slide.imageBrief?.prompt ? String(slide.imageBrief.prompt).trim() : '')
1077
+
1078
+ const promptEn = explicitPrompt
1079
+ ? `${explicitPrompt}. Color harmony: ${accentPrimary} and ${accentSecondary} accents on ${dark ? 'dark' : 'light'} backdrop (${canvas}). ${moodLabel}. Ultra-clean composition, NO text, NO letters, NO watermarks.`
1080
+ : `Editorial conceptual photography / minimalist 3D studio render illustrating "${title}". Harmonized with accent palette ${accentPrimary} and ${accentSecondary} on a ${dark ? 'deep dark' : 'bright airy daylight'} background (${canvas}). ${moodLabel}, ultra-crisp geometry, NO text, NO typography, NO watermarks.`
1081
+
1082
+ const promptZh = explicitPrompt
1083
+ ? `${explicitPrompt}。色调严格呼应主题主色 ${accentPrimary} 与辅色 ${accentSecondary}(画布底色 ${canvas}),${dark ? '暗夜高定棚拍光影' : '明亮现代建筑/杂志级自然棚拍'},构图干净克制,图内零文字零水印。`
1084
+ : `围绕「${title}」的高级杂志感实拍或极简 3D 棚拍概念视觉图;主辅色调严格贴合 ${accentPrimary} / ${accentSecondary}(${dark ? '深邃暗底光影' : '明亮通透浅底自然光'},底色 ${canvas}),留白克制,图内绝不出现任何文字或水印。`
1085
+
1086
+ return {
1087
+ recommendedAspect,
1088
+ paletteHex: { accentPrimary, accentSecondary, canvas },
1089
+ mood: dark ? 'dark-studio' : 'daylight-editorial',
1090
+ safeZone: langEn ? safeZoneEn : safeZoneZh,
1091
+ promptEn,
1092
+ promptZh,
1093
+ }
1094
+ }
1095
+
1096
+ export function renderImageBriefPlaceholderPptx(slide, boxIn, theme, langAttr, nextId) {
1097
+ const tk = theme.tokens
1098
+ const langEn = langAttr === 'en-US'
1099
+ const briefObj = normalizeImageBrief(slide.imageBrief) || {}
1100
+ const generated = generateVisualBrief(slide, theme, langEn ? 'en' : 'zh')
1101
+ const aspect = briefObj.aspect || generated.recommendedAspect
1102
+ const promptText = briefObj.prompt || (langEn ? generated.promptEn : generated.promptZh)
1103
+ const safeText = briefObj.safeZone || generated.safeZone
1104
+
1105
+ const shapes = []
1106
+ shapes.push(ooxmlShape(nextId(), 'Visual Brief Frame', boxIn, {
1107
+ preset: 'roundRect',
1108
+ adj: roundRectAdj(boxIn.w, boxIn.h, 12),
1109
+ fill: tk.surface2 || tk.surface1,
1110
+ stroke: tk.accentPrimary,
1111
+ strokePt: 1.25,
1112
+ dash: 'dash',
1113
+ }))
1114
+
1115
+ // Aspect & tag badge
1116
+ const badgeText = langEn ? `VISUAL BRIEF · ${aspect}` : `智能配图槽位 · ${aspect}`
1117
+ const bw = computeBadgePillWidth(badgeText, 10, Math.min(3.4, boxIn.w - 0.5), 1.4)
1118
+ shapes.push(ooxmlShape(nextId(), 'Visual Brief Pill', { x: boxIn.x + 0.28, y: boxIn.y + 0.28, w: bw, h: 0.30 }, {
1119
+ preset: 'roundRect',
1120
+ adj: 50000,
1121
+ fill: tk.accentPrimary,
1122
+ anchor: 'ctr',
1123
+ marginsIn: { l: 0.06, r: 0.06, t: 0.01, b: 0.01 },
1124
+ paragraphs: [ooxmlRichParagraph(badgeText, { sizePt: 10, color: contrastInk(tk.accentPrimary), bold: true, align: 'ctr', lang: langAttr, font: theme.fonts.body })],
1125
+ }))
1126
+
1127
+ // Theme palette harmony swatches (top-right inside frame)
1128
+ const swatches = [tk.accentPrimary, tk.accentSecondary || tk.accentPrimary, tk.canvas || theme.palette.bg]
1129
+ swatches.forEach((hexCol, si) => {
1130
+ shapes.push(ooxmlShape(nextId(), `Brief Swatch ${si + 1}`, { x: boxIn.x + boxIn.w - 0.28 - (3 - si) * 0.28, y: boxIn.y + 0.31, w: 0.22, h: 0.22 }, {
1131
+ preset: 'ellipse',
1132
+ fill: hexCol,
1133
+ stroke: tk.hairline,
1134
+ strokePt: 0.75,
1135
+ }))
1136
+ })
1137
+
1138
+ // Prompt body
1139
+ const textBox = { x: boxIn.x + 0.28, y: boxIn.y + 0.78, w: boxIn.w - 0.56, h: Math.max(0.8, boxIn.h - 1.56) }
1140
+ const fit = computeTextFit(promptText, textBox, 'cardBody', { maxPt: 14.5, minPt: 11.5 })
1141
+ shapes.push(ooxmlShape(nextId(), 'Visual Brief Prompt', textBox, {
1142
+ txBox: true,
1143
+ anchor: 'ctr',
1144
+ marginsIn: { l: 0.04, r: 0.04, t: 0.04, b: 0.04 },
1145
+ paragraphs: [
1146
+ ooxmlRichParagraph(langEn ? 'Suggested Image Prompt' : '建议生图 / 选图描述', { sizePt: 10.5, color: tk.accentText, bold: true, lang: langAttr, font: theme.fonts.body, spaceAfterPt: 4 }),
1147
+ ooxmlRichParagraph(promptText, { sizePt: fit.fontPt, color: tk.inkPrimary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.38 }),
1148
+ ],
1149
+ }))
1150
+
1151
+ // Safe zone footer
1152
+ shapes.push(ooxmlShape(nextId(), 'Visual Brief SafeZone', { x: boxIn.x + 0.28, y: boxIn.y + boxIn.h - 0.62, w: boxIn.w - 0.56, h: 0.44 }, {
1153
+ txBox: true,
1154
+ anchor: 'b',
1155
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1156
+ paragraphs: [ooxmlRichParagraph(safeText, { sizePt: 10, color: tk.inkMuted, lang: langAttr, font: theme.fonts.body, lineHeight: 1.25 })],
1157
+ }))
1158
+
1159
+ return shapes.join('')
1160
+ }
1161
+
1162
+ export function renderImageBriefPlaceholderHtml(slide, theme, langEn = false) {
1163
+ const tk = theme.tokens
1164
+ const briefObj = normalizeImageBrief(slide.imageBrief) || {}
1165
+ const generated = generateVisualBrief(slide, theme, langEn ? 'en' : 'zh')
1166
+ const aspect = briefObj.aspect || generated.recommendedAspect
1167
+ const promptText = briefObj.prompt || (langEn ? generated.promptEn : generated.promptZh)
1168
+ const safeText = briefObj.safeZone || generated.safeZone
1169
+ const swatches = [tk.accentPrimary, tk.accentSecondary || tk.accentPrimary, tk.canvas || theme.palette.bg]
1170
+ .map((c) => `<span class="brief-swatch" style="background:${c}" title="${c}"></span>`).join('')
1171
+ return (
1172
+ `<div class="visual-brief-card">` +
1173
+ `<div class="visual-brief-top"><span class="visual-brief-pill">${escapeHtml(langEn ? `VISUAL BRIEF · ${aspect}` : `智能配图槽位 · ${aspect}`)}</span><span class="visual-brief-swatches">${swatches}</span></div>` +
1174
+ `<div class="visual-brief-label">${escapeHtml(langEn ? 'Suggested Image Prompt' : '建议生图 / 选图描述')}</div>` +
1175
+ `<p class="visual-brief-prompt">${escapeHtml(promptText)}</p>` +
1176
+ `<div class="visual-brief-safe">${escapeHtml(safeText)}</div>` +
1177
+ `</div>`
1178
+ )
1179
+ }
1180
+
1181
+ export const INFOGRAPHICS_CSS = `
1182
+ .info-map-board{display:grid;grid-template-columns:1.78fr 1fr;gap:clamp(14px,1.6vw,22px);align-items:stretch;width:100%}
1183
+ .info-map-canvas{position:relative;padding:12px 14px;display:flex;flex-direction:column;justify-content:center}
1184
+ .info-map-mode{font-size:11px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);margin-bottom:4px}
1185
+ .info-map-svg{width:100%;height:auto;max-height:56vh;display:block}
1186
+ .info-map-side{display:flex;flex-direction:column;justify-content:center;gap:10px;min-width:0}
1187
+ .map-rank-card{padding:11px 14px;gap:6px}
1188
+ .map-rank-head{display:flex;align-items:center;gap:8px}
1189
+ .map-rank-num{display:inline-flex;align-items:center;justify-content:center;width:26px;height:20px;border-radius:4px;font-size:11px;font-weight:800;background:var(--surface2);color:var(--muted);flex-shrink:0}
1190
+ .map-rank-name{font-size:14px;color:var(--fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
1191
+ .map-rank-val{font-size:13.5px;font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap}
1192
+ .map-bar-track{width:100%;height:6px;border-radius:99px;background:var(--hairline);overflow:hidden}
1193
+ .map-bar-fill{height:100%;border-radius:99px}
1194
+ .map-rank-note{font-size:12px;color:var(--ink-secondary);line-height:1.35}
1195
+ .iso-stack-board{display:grid;grid-template-columns:1.08fr 1fr;gap:clamp(16px,2vw,28px);align-items:center;width:100%}
1196
+ .iso-stack-stage{display:flex;align-items:center;justify-content:center}
1197
+ .iso-stack-svg{width:100%;max-height:58vh;height:auto;display:block}
1198
+ .iso-stack-cards{display:flex;flex-direction:column;gap:10px;min-width:0}
1199
+ .iso-stack-card{padding:12px 16px;gap:4px}
1200
+ .iso-pillars-wrap{display:flex;flex-direction:column;gap:14px;width:100%}
1201
+ .iso-pillars-svg{width:100%;max-height:36vh;height:auto;display:block}
1202
+ .iso-pillar-cap{text-align:center;padding:12px 14px;gap:4px}
1203
+ .visual-brief-card{width:100%;height:100%;box-sizing:border-box;border:2px dashed var(--accent);border-radius:var(--radius);background:var(--surface2);padding:20px 22px;display:flex;flex-direction:column;justify-content:space-between;gap:10px}
1204
+ .visual-brief-top{display:flex;align-items:center;justify-content:space-between;gap:10px}
1205
+ .visual-brief-pill{display:inline-flex;padding:4px 12px;border-radius:99px;background:var(--accent);color:var(--ink-on-accent);font-size:11px;font-weight:800;letter-spacing:.08em}
1206
+ .visual-brief-swatches{display:inline-flex;gap:6px}
1207
+ .brief-swatch{width:16px;height:16px;border-radius:50%;border:1px solid var(--hairline);display:inline-block}
1208
+ .visual-brief-label{font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--accent-text)}
1209
+ .visual-brief-prompt{margin:0;font-size:15px;line-height:1.45;color:var(--fg)}
1210
+ .visual-brief-safe{font-size:12px;color:var(--muted);line-height:1.35;border-top:1px solid var(--hairline);padding-top:8px}
1211
+ @media (max-width:900px){
1212
+ .info-map-board,.iso-stack-board{grid-template-columns:1fr}
1213
+ }
1214
+ `