dsh-ppt 0.33.0 → 0.35.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.en.md +8 -10
  3. package/README.md +8 -10
  4. package/docs/USAGE.en.md +44 -35
  5. package/docs/USAGE.md +45 -36
  6. package/docs/VALIDATION.md +8 -0
  7. package/lib/client.js +116 -17
  8. package/lib/ecosystem.js +10 -0
  9. package/lib/execution.js +36 -5
  10. package/lib/tools.js +74 -4
  11. package/lib/types.d.ts +79 -1
  12. package/lib/workbench.js +255 -14
  13. package/package.json +2 -2
  14. package/skills/dsh-ppt/SKILL.md +34 -31
  15. package/skills/dsh-ppt/package.json +1 -1
  16. package/skills/dsh-ppt/references/office-pack.md +124 -0
  17. package/skills/dsh-ppt/references/research-plan.md +93 -62
  18. package/skills/dsh-ppt/scripts/build-deck.mjs +109 -3
  19. package/skills/dsh-ppt/scripts/deck-absorb.mjs +21 -0
  20. package/skills/dsh-ppt/scripts/deck-advanced.mjs +330 -37
  21. package/skills/dsh-ppt/scripts/deck-brand-kit.mjs +257 -0
  22. package/skills/dsh-ppt/scripts/deck-charts-exec.mjs +805 -0
  23. package/skills/dsh-ppt/scripts/deck-chrome.mjs +47 -1
  24. package/skills/dsh-ppt/scripts/deck-compose.mjs +386 -0
  25. package/skills/dsh-ppt/scripts/deck-core.mjs +136 -16
  26. package/skills/dsh-ppt/scripts/deck-delivery.mjs +750 -17
  27. package/skills/dsh-ppt/scripts/deck-evidence.mjs +811 -118
  28. package/skills/dsh-ppt/scripts/deck-export.mjs +652 -0
  29. package/skills/dsh-ppt/scripts/deck-i18n.mjs +170 -0
  30. package/skills/dsh-ppt/scripts/deck-layouts.mjs +72 -8
  31. package/skills/dsh-ppt/scripts/deck-media.mjs +22 -0
  32. package/skills/dsh-ppt/scripts/deck-office.mjs +1455 -14
  33. package/skills/dsh-ppt/scripts/deck-remix.mjs +471 -0
@@ -11,7 +11,8 @@ const VISUAL_DIAGRAM_LAYOUTS = new Set([
11
11
  'chart', 'chart-split', 'table', 'gantt', 'architecture', 'harvey',
12
12
  'tam', 'org', 'marimekko', 'sankey', 'value-chain', 'swot',
13
13
  'process', 'matrix', 'mermaid', 'flowchart', 'sequence',
14
- 'quadrant', 'radar', 'dumbbell', 'heatmap', 'map', 'isometric', 'mockup', 'code',
14
+ 'quadrant', 'radar', 'dumbbell', 'heatmap', 'map', 'isometric',
15
+ 'issue-tree', 'treemap', 'gauge', 'pricing', 'mockup', 'code',
15
16
  'image', 'image-left', 'image-right', 'gallery',
16
17
  ])
17
18
 
@@ -729,6 +730,103 @@ ${MERMAID_CSS}
729
730
  </html>`
730
731
  }
731
732
 
733
+ // ---------------------------------------------------------------------------
734
+ // Subtitles (.srt / .vtt) Generator (powered by computePaceBudget)
735
+ // ---------------------------------------------------------------------------
736
+
737
+ function formatSubtitleTime(totalSeconds, separator = ',') {
738
+ const safe = Math.max(0, Number(totalSeconds) || 0)
739
+ const hrs = Math.floor(safe / 3600)
740
+ const mins = Math.floor((safe % 3600) / 60)
741
+ const secs = Math.floor(safe % 60)
742
+ const ms = Math.round((safe - Math.floor(safe)) * 1000) % 1000
743
+ return (
744
+ String(hrs).padStart(2, '0') + ':' +
745
+ String(mins).padStart(2, '0') + ':' +
746
+ String(secs).padStart(2, '0') + separator +
747
+ String(ms).padStart(3, '0')
748
+ )
749
+ }
750
+
751
+ function splitCaptionPhrases(text, maxChars = 48) {
752
+ const raw = String(text ?? '').replace(/\r/g, '').trim()
753
+ if (!raw) return []
754
+ const chunks = []
755
+ for (const para of raw.split(/\n+/)) {
756
+ const clean = stripMd(para).replace(/^[-•▸*]\s*/, '').trim()
757
+ if (!clean || /^\[(?:证据溯源|压缩归档|Condensed Backup|Evidence)/i.test(clean)) continue
758
+ const sentences = clean.split(/(?<=[。!?.!?;;])\s*/).map(s => s.trim()).filter(Boolean)
759
+ for (const sent of sentences) {
760
+ if (sent.length <= maxChars) {
761
+ chunks.push(sent)
762
+ } else {
763
+ for (let i = 0; i < sent.length; i += maxChars) {
764
+ chunks.push(sent.slice(i, i + maxChars).trim())
765
+ }
766
+ }
767
+ }
768
+ }
769
+ return chunks.filter(Boolean).slice(0, 6)
770
+ }
771
+
772
+ function buildSubtitleCues(manifest, language = 'zh') {
773
+ const pace = computePaceBudget(manifest)
774
+ const slides = Array.isArray(manifest?.slides) ? manifest.slides : []
775
+ const isEn = (language || manifest?.language) === 'en'
776
+ const cues = []
777
+ let cursorSec = 0
778
+
779
+ slides.forEach((slide, idx) => {
780
+ const duration = Math.max(6, Number(pace.slides?.[idx]?.seconds) || 20)
781
+ const rawNotes = typeof slide?.notes === 'string' && slide.notes.trim()
782
+ ? slide.notes.split(/\n\[(?:证据溯源|压缩归档|Condensed Backup|Evidence)/i)[0].trim()
783
+ : ''
784
+ const fallbackText = [
785
+ stripMd(slide?.title || (isEn ? `Slide ${idx + 1}` : `第 ${idx + 1} 页`)),
786
+ slide?.takeaway ? stripMd(slide.takeaway) : '',
787
+ !slide?.takeaway ? slideCueLines(slide) : '',
788
+ ].filter(Boolean).join('\n')
789
+
790
+ const lines = splitCaptionPhrases(rawNotes || fallbackText, isEn ? 68 : 42)
791
+ const safeLines = lines.length > 0 ? lines : [stripMd(slide?.title || (isEn ? `Slide ${idx + 1}` : `第 ${idx + 1} 页`))]
792
+ const totalWeight = safeLines.reduce((sum, l) => sum + Math.max(4, l.length), 0)
793
+ let localStart = cursorSec
794
+ safeLines.forEach((line, lIdx) => {
795
+ const share = lIdx === safeLines.length - 1
796
+ ? (cursorSec + duration) - localStart
797
+ : Math.max(2, Number(((Math.max(4, line.length) / totalWeight) * duration).toFixed(2)))
798
+ const localEnd = Math.min(cursorSec + duration, localStart + share)
799
+ cues.push({
800
+ index: cues.length + 1,
801
+ slide: idx + 1,
802
+ start: localStart,
803
+ end: Math.max(localStart + 1.5, localEnd),
804
+ text: line,
805
+ })
806
+ localStart = localEnd
807
+ })
808
+ cursorSec += duration
809
+ })
810
+
811
+ return cues
812
+ }
813
+
814
+ /** Generate standard SubRip (.srt) timed narration captions synced with computePaceBudget. */
815
+ export function renderSubtitlesSrt(manifest, language) {
816
+ const cues = buildSubtitleCues(manifest, language)
817
+ return cues.map(c =>
818
+ `${c.index}\n${formatSubtitleTime(c.start, ',')} --> ${formatSubtitleTime(c.end, ',')}\n${c.text}\n`
819
+ ).join('\n')
820
+ }
821
+
822
+ /** Generate standard WebVTT (.vtt) timed narration captions synced with computePaceBudget. */
823
+ export function renderSubtitlesVtt(manifest, language) {
824
+ const cues = buildSubtitleCues(manifest, language)
825
+ return 'WEBVTT\n\n' + cues.map(c =>
826
+ `${formatSubtitleTime(c.start, '.')} --> ${formatSubtitleTime(c.end, '.')}\n${c.text}\n`
827
+ ).join('\n')
828
+ }
829
+
732
830
  /** Offline, sibling-file links only. No credentials or application server needed. */
733
831
  export function renderDelivery(manifest, files = {}, language) {
734
832
  const label = (zh, en) => language === 'en' ? en : language === 'bilingual' ? zh + ' · ' + en : zh
@@ -739,6 +837,8 @@ export function renderDelivery(manifest, files = {}, language) {
739
837
  const pptxLabel = label('下载 PPTX', 'Download PPTX')
740
838
  const handoutLabel = label('下载讲义 (.md)', 'Download handout (.md)')
741
839
  const onePagerLabel = label('下载一页纸战报 (.html)', 'Download One-Pager (.html)')
840
+ const carouselLabel = label('下载社媒长图卡片 (.html)', 'Download Social Carousel (.html)')
841
+ const subtitlesLabel = label('下载配音字幕 (.srt)', 'Download Subtitles (.srt)')
742
842
  const reviewLabel = label('检查与导出', 'Review and export')
743
843
  const outline = manifest.slides.map((slide, i) => `<li><button type="button" data-review-slide="${i + 1}"><span>${i + 1}</span>${escape(slide.title || label('无标题', 'Untitled'))}</button></li>`).join('')
744
844
  const rows = issues.map(issue => `<li><button type="button" data-review-slide="${issue.slide}"><strong>${escape(label('第 ' + issue.slide + ' 页', 'Slide ' + issue.slide))} · ${escape(issue.message)}</strong><span>${escape(issue.suggestion)}</span></button></li>`).join('')
@@ -762,6 +862,17 @@ export function renderDelivery(manifest, files = {}, language) {
762
862
  ? `<a id="download-onepager" href="${escape(href(files.onepager))}" download>${escape(onePagerLabel)}</a>`
763
863
  : `<a id="download-onepager" href="#onepager" download="${escape(onePagerFileName)}">${escape(onePagerLabel)}</a>`
764
864
 
865
+ const carouselFileName = files.carousel ? basename(files.carousel) : slugBase + '.carousel.html'
866
+ const carouselLink = files.carousel
867
+ ? `<a id="download-carousel" href="${escape(href(files.carousel))}" download>${escape(carouselLabel)}</a>`
868
+ : `<a id="download-carousel" href="#carousel" download="${escape(carouselFileName)}">${escape(carouselLabel)}</a>`
869
+
870
+ const subtitlesSrt = renderSubtitlesSrt(manifest, language)
871
+ const subtitlesFileName = files.subtitles ? basename(files.subtitles) : slugBase + '.srt'
872
+ const subtitlesLink = files.subtitles
873
+ ? `<a id="download-subtitles" href="${escape(href(files.subtitles))}" download>${escape(subtitlesLabel)}</a>`
874
+ : `<a id="download-subtitles" href="#subtitles" download="${escape(subtitlesFileName)}">${escape(subtitlesLabel)}</a>`
875
+
765
876
  const paceBudget = computePaceBudget(manifest)
766
877
  const paceSummaryText = label(
767
878
  `预计演讲时长 ${paceBudget.estimatedMinutes} 分钟(目标 ${paceBudget.targetMinutes} 分钟)${paceBudget.overBudgetSlides.length ? ` · 超预算页:${paceBudget.overBudgetSlides.join(', ')}` : ''}`,
@@ -769,12 +880,45 @@ export function renderDelivery(manifest, files = {}, language) {
769
880
  )
770
881
 
771
882
  const slideCues = (manifest.slides || []).map((s) => slideCueLines(s))
883
+ const searchIndex = (manifest.slides || []).map((s, idx) => ({
884
+ slide: idx + 1,
885
+ title: stripMd(s.title || label('无标题', 'Untitled')),
886
+ kicker: stripMd(s.kicker || ''),
887
+ layout: s.layout || 'bullets',
888
+ evidenceIds: Array.isArray(s.evidenceIds) ? s.evidenceIds : [],
889
+ }))
890
+ const evidenceIndex = Array.isArray(manifest.evidence)
891
+ ? manifest.evidence.map((ev) => {
892
+ const citingSlides = []
893
+ ;(manifest.slides || []).forEach((s, idx) => {
894
+ if (Array.isArray(s.evidenceIds) && s.evidenceIds.includes(ev.id)) citingSlides.push(idx + 1)
895
+ })
896
+ return {
897
+ id: ev.id,
898
+ claim: stripMd(ev.claim || ''),
899
+ source: stripMd(ev.source || ''),
900
+ confidence: ev.confidence || 'verified',
901
+ slides: citingSlides,
902
+ }
903
+ })
904
+ : []
905
+ const slideSubtitles = (manifest.slides || []).map((s, idx) => {
906
+ const rawNotes = typeof s.notes === 'string' && s.notes.trim()
907
+ ? s.notes.split(/\n\[(?:证据溯源|压缩归档|Condensed Backup|Evidence)/i)[0].trim()
908
+ : ''
909
+ const first = splitCaptionPhrases(rawNotes || [stripMd(s.title || ''), stripMd(s.takeaway || ''), slideCues[idx] || ''].filter(Boolean).join('\n'), language === 'en' ? 96 : 64)[0]
910
+ return first || stripMd(s.title || '')
911
+ })
912
+
772
913
  const targetMinutes = paceBudget.targetMinutes
773
914
  const deliveryConfig = {
774
915
  lang: language || 'zh',
775
916
  title: String(manifest.title || 'Presentation'),
776
917
  channelId: String(manifest.deckId || manifest.title || 'dsh-ppt').slice(0, 64),
777
918
  slideCues,
919
+ slideSubtitles,
920
+ searchIndex,
921
+ evidenceIndex,
778
922
  targetMinutes,
779
923
  slideBudgets: paceBudget.slides.map(s => ({ seconds: s.seconds, status: s.status })),
780
924
  handoutMarkdown,
@@ -783,6 +927,11 @@ export function renderDelivery(manifest, files = {}, language) {
783
927
  onePagerHtml,
784
928
  onePagerFileName,
785
929
  hasSiblingOnePager: Boolean(files.onepager),
930
+ carouselFileName,
931
+ hasSiblingCarousel: Boolean(files.carousel),
932
+ subtitlesSrt,
933
+ subtitlesFileName,
934
+ hasSiblingSubtitles: Boolean(files.subtitles),
786
935
  labels: {
787
936
  presenterTitle: label('演讲者提词台', 'Presenter Console'),
788
937
  currentSlide: label('当前画面', 'CURRENT SLIDE'),
@@ -807,23 +956,85 @@ export function renderDelivery(manifest, files = {}, language) {
807
956
  popupBlocked: label('浏览器拦截了演讲者窗口,请允许弹窗后按 P 重试。', 'Presenter popup was blocked. Allow popups and press P to retry.'),
808
957
  laserOn: label('虚拟激光笔已开启(移动鼠标指示,按 L 关闭)', 'Laser pointer ON (move pointer, press L to off)'),
809
958
  laserOff: label('虚拟激光笔已关闭', 'Laser pointer OFF'),
959
+ drawOn: label('实时白板画笔已开启(按 Z 撤销,C 清屏,D/Esc 退出)', 'Whiteboard pen ON (Z undo, C clear, D/Esc exit)'),
960
+ drawOff: label('实时白板画笔已关闭', 'Whiteboard pen OFF'),
961
+ jumpEmpty: label('未找到匹配的页面或证据编号', 'No matching slides or evidence entries'),
962
+ autoTourStart: label('自动导览', 'Auto-Tour'),
963
+ autoTourStop: label('停止导览', 'Stop Tour'),
964
+ qaFinished: label('Q&A 倒计时结束', 'Q&A time is up'),
965
+ reviewCommentSaved: label('已保存当前页审阅批注', 'Review comment pinned to slide'),
966
+ reviewCommentEmpty: label('暂无批注;按 R 添加当前页修改意见并导出给 AI 修订', 'No comments yet; add feedback for this slide and export JSON for AI revision'),
967
+ reviewExported: label('已导出 review-feedback.json,可直接发给 AI 自动修订', 'Exported review-feedback.json for AI revision'),
810
968
  hint: label('← → 翻页 · P/空格 暂停 · T 重置 · A+/A- 字号 · L 激光笔 · B/W 黑白屏 · Esc 结束', '← → Navigate · T Reset · A+/A- Zoom · L Laser · B/W Blank · Esc End'),
811
969
  },
812
970
  }
813
971
 
814
972
  return {
815
973
  body: `<div id="delivery-bar">
816
- <span id="delivery-status">${escape(draft ? label('待补全草稿', 'Draft: content needed') : label('演示文稿 · 请检查后交付', 'Presentation · review before delivery'))}</span>
974
+ <span id="delivery-status">${escape(draft ? label('待补全草稿', 'Draft: content needed') : label('演示文稿 · Ctrl+K 速搜 · R 批注 · D 标注 · T 计时 · A 导览', 'Presentation · Ctrl+K Jump · R Comment · D Draw · T Timer · A Tour'))}</span>
975
+ <button id="dsh-jump-open" type="button" title="Ctrl/Cmd+K">${escape(label('速搜 (⌘K)', 'Search (⌘K)'))}</button>
976
+ <button id="dsh-comments-btn" type="button" title="R">${escape(label('批注 (R)', 'Comments (R)'))}</button>
977
+ <button id="dsh-autotour-btn" type="button" aria-pressed="false" title="A">${escape(label('自动导览', 'Auto-Tour'))}</button>
817
978
  ${download('pptx', pptxLabel, 'download-pptx')}
818
979
  <button id="review-toggle" type="button" aria-haspopup="dialog">${escape(reviewLabel)}</button>
819
980
  </div>
981
+ <aside id="dsh-review-comments" hidden role="region" aria-label="${escape(label('离线审阅批注面板', 'Offline Review Comments'))}">
982
+ <div class="dsh-rc-head">
983
+ <strong>${escape(label('审阅批注 · 离线回流 AI', 'Review Comments · Export for AI'))}</strong>
984
+ <button type="button" id="dsh-rc-close" aria-label="${escape(label('关闭', 'Close'))}">✕</button>
985
+ </div>
986
+ <div id="dsh-rc-slide-ctx" class="dsh-rc-ctx"></div>
987
+ <input id="dsh-rc-author" type="text" placeholder="${escape(label('审阅人(可选,如 老板 / CFO)', 'Reviewer (optional, e.g. CFO)'))}"/>
988
+ <textarea id="dsh-rc-input" rows="3" placeholder="${escape(label('输入本页修改意见(如:把第3项数字放大并补充对比口径)…', 'Write slide-pinned revision note…'))}"></textarea>
989
+ <div class="dsh-rc-actions">
990
+ <button type="button" id="dsh-rc-add">${escape(label('添加批注', 'Pin Comment'))}</button>
991
+ <button type="button" id="dsh-rc-export">${escape(label('导出 Feedback JSON', 'Export Feedback JSON'))}</button>
992
+ </div>
993
+ <ul id="dsh-rc-list"></ul>
994
+ </aside>
820
995
  <div id="dsh-laser-dot" aria-hidden="true"></div>
996
+ <canvas id="dsh-draw-canvas" aria-label="${escape(label('实时白板标注画布', 'Live annotation canvas'))}"></canvas>
997
+ <div id="dsh-draw-bar" hidden role="toolbar" aria-label="${escape(label('白板标注工具条', 'Whiteboard pen toolbar'))}">
998
+ <button type="button" class="dsh-pen-color is-active" data-pen="#EF4444" data-width="4" title="${escape(label('红笔', 'Red pen'))}" style="--swatch:#EF4444"></button>
999
+ <button type="button" class="dsh-pen-color" data-pen="rgba(245,158,11,0.45)" data-width="14" title="${escape(label('荧光笔', 'Highlighter'))}" style="--swatch:#F59E0B"></button>
1000
+ <button type="button" class="dsh-pen-color" data-pen="#06B6D4" data-width="4" title="${escape(label('青笔', 'Cyan pen'))}" style="--swatch:#06B6D4"></button>
1001
+ <button type="button" id="dsh-draw-undo">${escape(label('撤销 (Z)', 'Undo (Z)'))}</button>
1002
+ <button type="button" id="dsh-draw-clear">${escape(label('清屏 (C)', 'Clear (C)'))}</button>
1003
+ <button type="button" id="dsh-draw-exit">${escape(label('退出 (D)', 'Exit (D)'))}</button>
1004
+ </div>
1005
+ <div id="dsh-qa-timer" hidden role="region" aria-label="${escape(label('Q&A 倒计时器', 'Q&A countdown timer'))}">
1006
+ <span class="dsh-qa-lbl">Q&amp;A</span>
1007
+ <strong id="dsh-qa-readout">03:00</strong>
1008
+ <button type="button" class="dsh-qa-preset" data-mins="1">1m</button>
1009
+ <button type="button" class="dsh-qa-preset is-active" data-mins="3">3m</button>
1010
+ <button type="button" class="dsh-qa-preset" data-mins="5">5m</button>
1011
+ <button type="button" class="dsh-qa-preset" data-mins="10">10m</button>
1012
+ <button type="button" id="dsh-qa-toggle">${escape(label('开始', 'Start'))}</button>
1013
+ <button type="button" id="dsh-qa-reset">${escape(label('重置', 'Reset'))}</button>
1014
+ <button type="button" id="dsh-qa-close" aria-label="${escape(label('关闭', 'Close'))}">✕</button>
1015
+ </div>
1016
+ <div id="dsh-sub-bar" hidden role="status" aria-live="polite">
1017
+ <span id="dsh-sub-text"></span>
1018
+ <div class="dsh-sub-ctrl">
1019
+ <button type="button" id="dsh-sub-speed">1×</button>
1020
+ <button type="button" id="dsh-sub-pause">${escape(label('暂停', 'Pause'))}</button>
1021
+ <button type="button" id="dsh-sub-stop">✕</button>
1022
+ </div>
1023
+ </div>
1024
+ <dialog id="dsh-jump-dialog" aria-labelledby="dsh-jump-title">
1025
+ <div class="dsh-jump-head">
1026
+ <span id="dsh-jump-title">${escape(label('快速跳转页面 / 搜索 [E#] 证据', 'Jump to slide or search [E#] evidence'))}</span>
1027
+ <button type="button" id="dsh-jump-close">Esc</button>
1028
+ </div>
1029
+ <input id="dsh-jump-input" type="search" autocomplete="off" placeholder="${escape(label('输入标题关键词、正文、或 E1 / E2 证据编号…', 'Type slide title, keyword, or E1 / E2 evidence ID…'))}"/>
1030
+ <ul id="dsh-jump-results" role="listbox"></ul>
1031
+ </dialog>
821
1032
  <dialog id="review-panel" aria-labelledby="review-title">
822
1033
  <div class="review-head"><h2 id="review-title">${escape(reviewLabel)}</h2><button id="review-close" type="button">${escape(label('关闭', 'Close'))}</button></div>
823
1034
  <p id="review-summary">${escape(summary)}</p>
824
1035
  <p id="review-pace" class="review-pace">${escape(paceSummaryText)}</p>
825
- <div class="review-exports">${download('pptx', pptxLabel, 'review-download-pptx')}${download('json', label('保存可编辑项目', 'Save project'), 'download-project')}${handoutLink}${onePagerLink}</div>
826
- <p>${escape(label('用 PowerPoint / WPS 打开 PPTX 可直接修改文字、图片和图表。让 Agent 继续修改时,使用保存的项目文件;按 P 打开双屏演讲者提词台,按 L 开启虚拟激光笔。', 'Open the PPTX in PowerPoint / WPS to edit text, images and charts. Use the saved project when asking your Agent to revise it; press P for Dual-Screen Presenter Console and L for Virtual Laser Pointer.'))}</p>
1036
+ <div class="review-exports">${download('pptx', pptxLabel, 'review-download-pptx')}${download('json', label('保存可编辑项目', 'Save project'), 'download-project')}${handoutLink}${onePagerLink}${carouselLink}${subtitlesLink}</div>
1037
+ <p>${escape(label('用 PowerPoint / WPS 打开 PPTX 可直接修改文字、图片和图表。快捷键:P 双屏提词台 · L 激光笔 · Ctrl/Cmd+K 速搜跳页 · D 实时白板标注 · T 现场 Q&A 倒计时 · A 自动字幕导览。', 'Open the PPTX in PowerPoint / WPS to edit text, images and charts. Shortcuts: P Presenter Console · L Laser · Ctrl/Cmd+K Search · D Draw Pen · T Q&A Timer · A Auto-Tour.'))}</p>
827
1038
  <h3>${escape(label('检查提示 · 点击定位页面', 'Review items · click to open slide'))}</h3>
828
1039
  ${issues.length ? `<ul id="review-issues">${rows}</ul>` : `<p>${escape(manifest.quality ? label('静态检查未发现问题;仍需核对实际排版和事实。', 'No static issues found; check the actual layout and facts.') : label('暂无报告。', 'No report available.'))}</p>`}
829
1040
  <p>${escape(label('文字尺寸是静态估算;这里不能证明 PowerPoint / WPS 排版已通过验收。', 'Text fit is estimated; this does not verify the rendered PowerPoint / WPS layout.'))}</p>
@@ -837,6 +1048,7 @@ export function renderDelivery(manifest, files = {}, language) {
837
1048
 
838
1049
  /** This function is embedded in the standalone HTML, with no module dependencies. */
839
1050
  function initDelivery(go, setOverview, current, total, cfg) {
1051
+ const escape = value => String(value ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c])
840
1052
  const previous = document.getElementById('previous-slide')
841
1053
  const next = document.getElementById('next-slide')
842
1054
  const number = document.getElementById('page-number')
@@ -844,7 +1056,127 @@ function initDelivery(go, setOverview, current, total, cfg) {
844
1056
  const toggle = document.getElementById('review-toggle')
845
1057
  const handoutBtn = document.getElementById('download-handout')
846
1058
  const onePagerBtn = document.getElementById('download-onepager')
1059
+ const carouselBtn = document.getElementById('download-carousel')
1060
+ const subtitlesBtn = document.getElementById('download-subtitles')
847
1061
  const laserDot = document.getElementById('dsh-laser-dot')
1062
+ const jumpOpenBtn = document.getElementById('dsh-jump-open')
1063
+ const jumpDialog = document.getElementById('dsh-jump-dialog')
1064
+ const jumpInput = document.getElementById('dsh-jump-input')
1065
+ const jumpResults = document.getElementById('dsh-jump-results')
1066
+ const jumpCloseBtn = document.getElementById('dsh-jump-close')
1067
+ const drawCanvas = document.getElementById('dsh-draw-canvas')
1068
+ const drawBar = document.getElementById('dsh-draw-bar')
1069
+ const qaTimer = document.getElementById('dsh-qa-timer')
1070
+ const qaReadout = document.getElementById('dsh-qa-readout')
1071
+ const qaToggleBtn = document.getElementById('dsh-qa-toggle')
1072
+ const qaResetBtn = document.getElementById('dsh-qa-reset')
1073
+ const qaCloseBtn = document.getElementById('dsh-qa-close')
1074
+ const tourBtn = document.getElementById('dsh-autotour-btn')
1075
+ const subBar = document.getElementById('dsh-sub-bar')
1076
+ const subText = document.getElementById('dsh-sub-text')
1077
+ const subSpeedBtn = document.getElementById('dsh-sub-speed')
1078
+ const subPauseBtn = document.getElementById('dsh-sub-pause')
1079
+ const subStopBtn = document.getElementById('dsh-sub-stop')
1080
+ const commentsBtn = document.getElementById('dsh-comments-btn')
1081
+ const commentsDrawer = document.getElementById('dsh-review-comments')
1082
+ const rcCloseBtn = document.getElementById('dsh-rc-close')
1083
+ const rcSlideCtx = document.getElementById('dsh-rc-slide-ctx')
1084
+ const rcAuthor = document.getElementById('dsh-rc-author')
1085
+ const rcInput = document.getElementById('dsh-rc-input')
1086
+ const rcAddBtn = document.getElementById('dsh-rc-add')
1087
+ const rcExportBtn = document.getElementById('dsh-rc-export')
1088
+ const rcList = document.getElementById('dsh-rc-list')
1089
+
1090
+ // --- Wave 3E: 'R' Offline Stakeholder Review Comment Drawer ---
1091
+ const rcStorageKey = 'dsh-ppt-feedback-' + (cfg?.channelId || 'deck')
1092
+ let reviewComments = []
1093
+ try {
1094
+ const rawSaved = localStorage.getItem(rcStorageKey)
1095
+ if (rawSaved) {
1096
+ const parsed = JSON.parse(rawSaved)
1097
+ if (Array.isArray(parsed)) reviewComments = parsed
1098
+ }
1099
+ } catch (_) {}
1100
+ function persistComments() {
1101
+ try { localStorage.setItem(rcStorageKey, JSON.stringify(reviewComments)) } catch (_) {}
1102
+ }
1103
+ function updateCommentsContext(idx) {
1104
+ if (!rcSlideCtx) return
1105
+ const i = typeof idx === 'number' ? idx : current()
1106
+ const sl = document.querySelectorAll('.slide')[i]
1107
+ const heading = sl ? (sl.querySelector('h1,h2,.statement-title,.quote-text')?.textContent || '').trim() : ''
1108
+ rcSlideCtx.textContent = `P${String(i + 1).padStart(2, '0')} · ${heading || ('Slide ' + (i + 1))}`
1109
+ }
1110
+ function renderCommentsList() {
1111
+ if (!rcList) return
1112
+ if (commentsBtn) {
1113
+ const baseLbl = (commentsBtn.dataset.baseLbl ||= commentsBtn.textContent)
1114
+ commentsBtn.textContent = reviewComments.length > 0 ? `${baseLbl} (${reviewComments.length})` : baseLbl
1115
+ }
1116
+ if (reviewComments.length === 0) {
1117
+ rcList.innerHTML = `<li class="dsh-rc-empty">${escape(cfg?.labels?.reviewCommentEmpty || 'No comments')}</li>`
1118
+ return
1119
+ }
1120
+ rcList.innerHTML = reviewComments.map((c, idx) =>
1121
+ `<li><button type="button" class="dsh-rc-jump" data-rc-slide="${c.slide}"><strong>P${String(c.slide).padStart(2, '0')}</strong>${c.author ? ` <em>${escape(c.author)}</em>` : ''}:${escape(c.text)}</button><button type="button" class="dsh-rc-del" data-rc-del="${idx}" aria-label="Delete">✕</button></li>`
1122
+ ).join('')
1123
+ rcList.querySelectorAll('[data-rc-slide]').forEach((btn) => {
1124
+ btn.addEventListener('click', () => {
1125
+ const s = Number(btn.dataset.rcSlide)
1126
+ if (Number.isInteger(s) && s >= 1 && s <= total) go(s - 1)
1127
+ })
1128
+ })
1129
+ rcList.querySelectorAll('[data-rc-del]').forEach((btn) => {
1130
+ btn.addEventListener('click', () => {
1131
+ const idx = Number(btn.dataset.rcDel)
1132
+ if (Number.isInteger(idx) && idx >= 0 && idx < reviewComments.length) {
1133
+ reviewComments.splice(idx, 1)
1134
+ persistComments()
1135
+ renderCommentsList()
1136
+ }
1137
+ })
1138
+ })
1139
+ }
1140
+ function toggleCommentsDrawer(forceOpen) {
1141
+ if (!commentsDrawer) return
1142
+ const willOpen = typeof forceOpen === 'boolean' ? forceOpen : commentsDrawer.hidden
1143
+ commentsDrawer.hidden = !willOpen
1144
+ if (willOpen) {
1145
+ updateCommentsContext(current())
1146
+ renderCommentsList()
1147
+ setTimeout(() => rcInput?.focus(), 20)
1148
+ }
1149
+ }
1150
+ commentsBtn?.addEventListener('click', () => toggleCommentsDrawer())
1151
+ rcCloseBtn?.addEventListener('click', () => toggleCommentsDrawer(false))
1152
+ rcAddBtn?.addEventListener('click', () => {
1153
+ const txt = String(rcInput?.value || '').trim()
1154
+ if (!txt) return
1155
+ const slideNum = current() + 1
1156
+ reviewComments.push({
1157
+ id: 'rc-' + Date.now() + '-' + Math.random().toString(36).slice(2, 6),
1158
+ slide: slideNum,
1159
+ author: String(rcAuthor?.value || '').trim() || 'Reviewer',
1160
+ text: txt,
1161
+ createdAt: new Date().toISOString(),
1162
+ })
1163
+ if (rcInput) rcInput.value = ''
1164
+ persistComments()
1165
+ renderCommentsList()
1166
+ showToast(cfg?.labels?.reviewCommentSaved || 'Comment pinned')
1167
+ })
1168
+ rcExportBtn?.addEventListener('click', () => {
1169
+ const payload = {
1170
+ schemaVersion: 1,
1171
+ deckId: cfg?.channelId || '',
1172
+ title: cfg?.title || document.title,
1173
+ exportedAt: new Date().toISOString(),
1174
+ comments: reviewComments,
1175
+ }
1176
+ triggerBlobDownload(JSON.stringify(payload, null, 2), 'application/json;charset=utf-8', 'review-feedback.json')
1177
+ showToast(cfg?.labels?.reviewExported || 'Exported review-feedback.json')
1178
+ })
1179
+ renderCommentsList()
848
1180
 
849
1181
  previous.addEventListener('click', () => go(Math.max(0, current() - 1)))
850
1182
  next.addEventListener('click', () => go(Math.min(total - 1, current() + 1)))
@@ -888,6 +1220,328 @@ function initDelivery(go, setOverview, current, total, cfg) {
888
1220
  triggerBlobDownload(cfg.onePagerHtml || '', 'text/html;charset=utf-8', cfg.onePagerFileName || 'onepager.html')
889
1221
  })
890
1222
  }
1223
+ if (carouselBtn && cfg && !cfg.hasSiblingCarousel) {
1224
+ carouselBtn.addEventListener('click', (event) => {
1225
+ event.preventDefault()
1226
+ const cs = getComputedStyle(document.documentElement)
1227
+ const tv = (k, fb) => cs.getPropertyValue(k).trim() || fb
1228
+ const domSlides = Array.from(document.querySelectorAll('.slide'))
1229
+ const cards = domSlides.map((el, idx) => {
1230
+ const heading = (el.querySelector('h1,h2,.statement-title,.quote-text')?.textContent || '').trim()
1231
+ const kicker = (el.querySelector('.kicker')?.textContent || `PART ${String(idx + 1).padStart(2, '0')}`).trim()
1232
+ const takeaway = (el.querySelector('.slide-takeaway,.media-takeaway')?.textContent || '').trim()
1233
+ const points = Array.from(el.querySelectorAll('li,.card-text,.kpi-label,.kpi-val')).map(n => n.textContent.trim()).filter(Boolean).slice(0, 6)
1234
+ const img = el.querySelector('img:not(.brand-logo)')
1235
+ const imgTag = img ? `<img class="sc-img" src="${escape(img.getAttribute('src') || '')}" alt=""/>` : ''
1236
+ const isHero = el.classList.contains('slide--cover') || el.classList.contains('slide--closing') || el.classList.contains('slide--section')
1237
+ return `<article class="sc-card${isHero ? ' is-hero' : ''}"><header><span>${escape(kicker)}</span><span>${String(idx + 1).padStart(2, '0')} / ${String(domSlides.length).padStart(2, '0')}</span></header><h2>${escape(heading)}</h2>${imgTag}${points.length ? `<ul>${points.map(p => `<li>${escape(p)}</li>`).join('')}</ul>` : ''}${takeaway ? `<div class="sc-tk">${escape(takeaway)}</div>` : ''}</article>`
1238
+ }).join('\n')
1239
+ const doc = `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escape(cfg.title || 'Social Carousel')}</title><style>:root{--bg:${tv('--bg', '#FFF')};--fg:${tv('--fg', '#0F172A')};--accent:${tv('--accent', '#2563EB')};--surface:${tv('--panel', '#F8FAFC')};--muted:${tv('--muted', '#64748B')}}*{box-sizing:border-box}body{margin:0;background:#0F172A;color:#FFF;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center}nav{position:sticky;top:0;padding:12px;display:flex;gap:8px;z-index:9}nav button{border:1px solid rgba(255,255,255,.3);background:rgba(255,255,255,.1);color:#FFF;border-radius:8px;padding:6px 12px;cursor:pointer}main{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,420px));gap:20px;padding:16px;width:100%;max-width:960px;justify-content:center}.sc-card{aspect-ratio:4/5;background:var(--bg);color:var(--fg);border-radius:18px;padding:24px;display:flex;flex-direction:column;gap:12px;overflow:hidden}body[data-ratio="1:1"] .sc-card{aspect-ratio:1/1}.sc-card.is-hero{background:var(--accent);color:#FFF;justify-content:center}.sc-card header{display:flex;justify-content:space-between;font-size:11px;font-weight:700;opacity:.75}.sc-card h2{margin:0;font-size:22px;line-height:1.25}.sc-card ul{margin:0;padding-left:18px;font-size:13.5px;line-height:1.5;display:flex;flex-direction:column;gap:6px}.sc-img{width:100%;max-height:46%;object-fit:cover;border-radius:10px}.sc-tk{margin-top:auto;padding:8px 10px;border-left:3px solid var(--accent);background:var(--surface);font-size:12px;font-weight:700}@media print{nav{display:none}.sc-card{page-break-after:always;margin:0 auto}}</style></head><body data-ratio="4:5"><nav><button onclick="document.body.dataset.ratio='4:5'">4:5</button><button onclick="document.body.dataset.ratio='1:1'">1:1</button><button onclick="window.print()">Print / PDF</button></nav><main>${cards}</main></body></html>`
1240
+ triggerBlobDownload(doc, 'text/html;charset=utf-8', cfg.carouselFileName || 'carousel.html')
1241
+ })
1242
+ }
1243
+ if (subtitlesBtn && cfg && !cfg.hasSiblingSubtitles) {
1244
+ subtitlesBtn.addEventListener('click', (event) => {
1245
+ event.preventDefault()
1246
+ triggerBlobDownload(cfg.subtitlesSrt || '', 'application/x-subrip;charset=utf-8', cfg.subtitlesFileName || 'subtitles.srt')
1247
+ })
1248
+ }
1249
+
1250
+ function showToast(msg, ms = 2200) {
1251
+ const toastEl = document.getElementById('toast')
1252
+ if (!toastEl || !msg) return
1253
+ toastEl.textContent = msg
1254
+ toastEl.hidden = false
1255
+ setTimeout(() => { toastEl.hidden = true }, ms)
1256
+ }
1257
+
1258
+ // --- Wave 3A: Ctrl/Cmd+K Instant Jump Search (Slides + [E#] Evidence) ---
1259
+ let jumpMatches = []
1260
+ let jumpSelected = 0
1261
+ function renderJumpResults(queryRaw) {
1262
+ if (!jumpResults) return
1263
+ const q = String(queryRaw || '').trim().toLowerCase()
1264
+ const items = []
1265
+ for (const ev of (cfg?.evidenceIndex || [])) {
1266
+ const hay = `${ev.id} ${ev.claim} ${ev.source}`.toLowerCase()
1267
+ if (q && !hay.includes(q)) continue
1268
+ if (q || (cfg?.evidenceIndex?.length && q.startsWith('e'))) {
1269
+ items.push({
1270
+ kind: 'evidence',
1271
+ slide: ev.slides?.[0] || 1,
1272
+ badge: `[${ev.id}]`,
1273
+ title: ev.claim || ev.source,
1274
+ meta: `${ev.source}${ev.slides?.length ? ` · P${ev.slides.join(', P')}` : ''}`,
1275
+ })
1276
+ }
1277
+ }
1278
+ const liveSlides = Array.from(document.querySelectorAll('.slide'))
1279
+ for (const s of (cfg?.searchIndex || [])) {
1280
+ const domEl = liveSlides[s.slide - 1]
1281
+ const domText = domEl ? `${domEl.textContent || ''} ${domEl.dataset?.notes || ''}` : ''
1282
+ const hay = `${s.slide} ${s.title} ${s.kicker} ${s.layout} ${(s.evidenceIds || []).join(' ')} ${domText}`.toLowerCase()
1283
+ if (q && !hay.includes(q)) continue
1284
+ items.push({
1285
+ kind: 'slide',
1286
+ slide: s.slide,
1287
+ badge: `P${String(s.slide).padStart(2, '0')}`,
1288
+ title: s.title,
1289
+ meta: [s.kicker, s.layout, (s.evidenceIds || []).map(id => `[${id}]`).join(' ')].filter(Boolean).join(' · '),
1290
+ })
1291
+ }
1292
+ jumpMatches = items.slice(0, 14)
1293
+ jumpSelected = 0
1294
+ if (jumpMatches.length === 0) {
1295
+ jumpResults.innerHTML = `<li class="dsh-jump-empty">${escape(cfg?.labels?.jumpEmpty || 'No matches')}</li>`
1296
+ return
1297
+ }
1298
+ jumpResults.innerHTML = jumpMatches.map((m, idx) =>
1299
+ `<li role="option" class="${idx === 0 ? 'is-selected' : ''}" data-jump-idx="${idx}"><span class="dsh-jump-badge${m.kind === 'evidence' ? ' is-ev' : ''}">${escape(m.badge)}</span><span class="dsh-jump-main"><strong>${escape(m.title)}</strong>${m.meta ? `<small>${escape(m.meta)}</small>` : ''}</span></li>`
1300
+ ).join('')
1301
+ jumpResults.querySelectorAll('[data-jump-idx]').forEach((li) => {
1302
+ li.addEventListener('click', () => {
1303
+ const hit = jumpMatches[Number(li.dataset.jumpIdx)]
1304
+ if (hit) { go(Math.max(0, Math.min(total - 1, hit.slide - 1))); setOverview(false); jumpDialog.close() }
1305
+ })
1306
+ })
1307
+ }
1308
+ function openJumpModal() {
1309
+ if (!jumpDialog) return
1310
+ if (jumpDialog.open) { jumpDialog.close(); return }
1311
+ if (jumpInput) jumpInput.value = ''
1312
+ renderJumpResults('')
1313
+ jumpDialog.showModal()
1314
+ if (jumpInput) setTimeout(() => jumpInput.focus(), 20)
1315
+ }
1316
+ if (jumpOpenBtn) jumpOpenBtn.addEventListener('click', openJumpModal)
1317
+ if (jumpCloseBtn && jumpDialog) jumpCloseBtn.addEventListener('click', () => jumpDialog.close())
1318
+ if (jumpInput) {
1319
+ jumpInput.addEventListener('input', () => renderJumpResults(jumpInput.value))
1320
+ jumpInput.addEventListener('keydown', (e) => {
1321
+ if (e.key === 'ArrowDown' && jumpMatches.length > 0) {
1322
+ e.preventDefault()
1323
+ jumpSelected = (jumpSelected + 1) % jumpMatches.length
1324
+ jumpResults.querySelectorAll('[data-jump-idx]').forEach((el, idx) => el.classList.toggle('is-selected', idx === jumpSelected))
1325
+ } else if (e.key === 'ArrowUp' && jumpMatches.length > 0) {
1326
+ e.preventDefault()
1327
+ jumpSelected = (jumpSelected - 1 + jumpMatches.length) % jumpMatches.length
1328
+ jumpResults.querySelectorAll('[data-jump-idx]').forEach((el, idx) => el.classList.toggle('is-selected', idx === jumpSelected))
1329
+ } else if (e.key === 'Enter' && jumpMatches[jumpSelected]) {
1330
+ e.preventDefault()
1331
+ const hit = jumpMatches[jumpSelected]
1332
+ go(Math.max(0, Math.min(total - 1, hit.slide - 1)))
1333
+ setOverview(false)
1334
+ jumpDialog.close()
1335
+ }
1336
+ })
1337
+ }
1338
+
1339
+ // --- Wave 3B: 'D' Live Whiteboard Annotation Pen ---
1340
+ let drawActive = false
1341
+ let drawingStroke = null
1342
+ let penColor = '#EF4444'
1343
+ let penWidth = 4
1344
+ const strokesBySlide = new Map()
1345
+ const drawCtx = drawCanvas ? drawCanvas.getContext('2d') : null
1346
+
1347
+ function resizeDrawCanvas() {
1348
+ if (!drawCanvas || !drawCtx) return
1349
+ const dpr = Math.max(1, Math.min(2, window.devicePixelRatio || 1))
1350
+ drawCanvas.width = Math.round(window.innerWidth * dpr)
1351
+ drawCanvas.height = Math.round(window.innerHeight * dpr)
1352
+ drawCanvas.style.width = window.innerWidth + 'px'
1353
+ drawCanvas.style.height = window.innerHeight + 'px'
1354
+ drawCtx.setTransform(dpr, 0, 0, dpr, 0, 0)
1355
+ redrawCanvas(current())
1356
+ }
1357
+ function redrawCanvas(slideIdx) {
1358
+ if (!drawCanvas || !drawCtx) return
1359
+ drawCtx.clearRect(0, 0, window.innerWidth, window.innerHeight)
1360
+ const strokes = strokesBySlide.get(slideIdx) || []
1361
+ for (const st of strokes) {
1362
+ if (!st.pts || st.pts.length < 2) continue
1363
+ drawCtx.save()
1364
+ drawCtx.strokeStyle = st.color
1365
+ drawCtx.lineWidth = st.width
1366
+ drawCtx.lineCap = 'round'
1367
+ drawCtx.lineJoin = 'round'
1368
+ drawCtx.beginPath()
1369
+ drawCtx.moveTo(st.pts[0][0] * window.innerWidth, st.pts[0][1] * window.innerHeight)
1370
+ for (let i = 1; i < st.pts.length; i += 1) {
1371
+ drawCtx.lineTo(st.pts[i][0] * window.innerWidth, st.pts[i][1] * window.innerHeight)
1372
+ }
1373
+ drawCtx.stroke()
1374
+ drawCtx.restore()
1375
+ }
1376
+ }
1377
+ function setDrawActive(flag) {
1378
+ drawActive = Boolean(flag)
1379
+ if (drawCanvas) drawCanvas.classList.toggle('is-active', drawActive)
1380
+ if (drawBar) drawBar.hidden = !drawActive
1381
+ document.body.classList.toggle('draw-active', drawActive)
1382
+ if (drawActive) resizeDrawCanvas()
1383
+ showToast(drawActive ? cfg?.labels?.drawOn : cfg?.labels?.drawOff)
1384
+ }
1385
+ if (drawCanvas && drawCtx) {
1386
+ window.addEventListener('resize', resizeDrawCanvas)
1387
+ drawCanvas.addEventListener('pointerdown', (e) => {
1388
+ if (!drawActive) return
1389
+ drawCanvas.setPointerCapture?.(e.pointerId)
1390
+ const slideIdx = current()
1391
+ const list = strokesBySlide.get(slideIdx) || []
1392
+ drawingStroke = {
1393
+ color: penColor,
1394
+ width: penWidth,
1395
+ pts: [[e.clientX / Math.max(1, window.innerWidth), e.clientY / Math.max(1, window.innerHeight)]],
1396
+ }
1397
+ list.push(drawingStroke)
1398
+ strokesBySlide.set(slideIdx, list)
1399
+ })
1400
+ drawCanvas.addEventListener('pointermove', (e) => {
1401
+ if (!drawActive || !drawingStroke) return
1402
+ drawingStroke.pts.push([e.clientX / Math.max(1, window.innerWidth), e.clientY / Math.max(1, window.innerHeight)])
1403
+ redrawCanvas(current())
1404
+ })
1405
+ const finishStroke = () => { drawingStroke = null }
1406
+ drawCanvas.addEventListener('pointerup', finishStroke)
1407
+ drawCanvas.addEventListener('pointercancel', finishStroke)
1408
+ }
1409
+ if (drawBar) {
1410
+ drawBar.querySelectorAll('.dsh-pen-color').forEach((btn) => {
1411
+ btn.addEventListener('click', () => {
1412
+ penColor = btn.dataset.pen || '#EF4444'
1413
+ penWidth = Number(btn.dataset.width) || 4
1414
+ drawBar.querySelectorAll('.dsh-pen-color').forEach(b => b.classList.toggle('is-active', b === btn))
1415
+ })
1416
+ })
1417
+ document.getElementById('dsh-draw-undo')?.addEventListener('click', () => {
1418
+ const list = strokesBySlide.get(current())
1419
+ if (list && list.length > 0) { list.pop(); redrawCanvas(current()) }
1420
+ })
1421
+ document.getElementById('dsh-draw-clear')?.addEventListener('click', () => {
1422
+ strokesBySlide.set(current(), [])
1423
+ redrawCanvas(current())
1424
+ })
1425
+ document.getElementById('dsh-draw-exit')?.addEventListener('click', () => setDrawActive(false))
1426
+ }
1427
+
1428
+ // --- Wave 3C: 'T' Q&A Countdown Timer Pill ---
1429
+ let qaPresetMins = 3
1430
+ let qaRemainSec = 180
1431
+ let qaRunning = false
1432
+ let qaInterval = null
1433
+ function renderQaTimer() {
1434
+ if (!qaReadout || !qaTimer) return
1435
+ const m = Math.floor(Math.max(0, qaRemainSec) / 60)
1436
+ const s = Math.max(0, qaRemainSec) % 60
1437
+ qaReadout.textContent = String(m).padStart(2, '0') + ':' + String(s).padStart(2, '0')
1438
+ qaTimer.classList.toggle('is-warn', qaRemainSec > 0 && qaRemainSec <= 30)
1439
+ qaTimer.classList.toggle('is-over', qaRemainSec === 0)
1440
+ if (qaToggleBtn) qaToggleBtn.textContent = qaRunning ? (cfg?.labels?.pause || 'Pause') : (cfg?.labels?.resume || 'Start')
1441
+ }
1442
+ function stopQaInterval() {
1443
+ if (qaInterval) { clearInterval(qaInterval); qaInterval = null }
1444
+ qaRunning = false
1445
+ renderQaTimer()
1446
+ }
1447
+ function startQaTimer() {
1448
+ if (qaRemainSec <= 0) qaRemainSec = qaPresetMins * 60
1449
+ if (qaInterval) clearInterval(qaInterval)
1450
+ qaRunning = true
1451
+ renderQaTimer()
1452
+ qaInterval = setInterval(() => {
1453
+ qaRemainSec = Math.max(0, qaRemainSec - 1)
1454
+ renderQaTimer()
1455
+ if (qaRemainSec === 0) {
1456
+ stopQaInterval()
1457
+ showToast(cfg?.labels?.qaFinished || 'Q&A finished', 3200)
1458
+ }
1459
+ }, 1000)
1460
+ }
1461
+ function toggleQaPill() {
1462
+ if (!qaTimer) return
1463
+ const willOpen = qaTimer.hidden
1464
+ qaTimer.hidden = !willOpen
1465
+ if (!willOpen) stopQaInterval()
1466
+ else renderQaTimer()
1467
+ }
1468
+ if (qaTimer) {
1469
+ qaTimer.querySelectorAll('.dsh-qa-preset').forEach((btn) => {
1470
+ btn.addEventListener('click', () => {
1471
+ qaPresetMins = Number(btn.dataset.mins) || 3
1472
+ qaRemainSec = qaPresetMins * 60
1473
+ stopQaInterval()
1474
+ qaTimer.querySelectorAll('.dsh-qa-preset').forEach(b => b.classList.toggle('is-active', b === btn))
1475
+ })
1476
+ })
1477
+ qaToggleBtn?.addEventListener('click', () => (qaRunning ? stopQaInterval() : startQaTimer()))
1478
+ qaResetBtn?.addEventListener('click', () => { qaRemainSec = qaPresetMins * 60; stopQaInterval() })
1479
+ qaCloseBtn?.addEventListener('click', () => { qaTimer.hidden = true; stopQaInterval() })
1480
+ }
1481
+
1482
+ // --- Wave 3D: 'A' Narrated Auto-Tour + Live Subtitle Bar ---
1483
+ let tourActive = false
1484
+ let tourPaused = false
1485
+ let tourSpeed = 1
1486
+ let tourTimer = null
1487
+ function updateSubtitleBar(idx) {
1488
+ if (!subText) return
1489
+ const caption = cfg?.slideSubtitles?.[idx] || cfg?.slideCues?.[idx] || ''
1490
+ subText.textContent = caption || `Slide ${idx + 1} / ${total}`
1491
+ }
1492
+ function scheduleTourStep() {
1493
+ if (tourTimer) { clearTimeout(tourTimer); tourTimer = null }
1494
+ if (!tourActive || tourPaused) return
1495
+ const idx = current()
1496
+ updateSubtitleBar(idx)
1497
+ const rawSec = Number(cfg?.slideBudgets?.[idx]?.seconds) || 12
1498
+ const delayMs = Math.max(3000, Math.round((Math.min(24, Math.max(6, rawSec)) * 1000) / tourSpeed))
1499
+ tourTimer = setTimeout(() => {
1500
+ if (!tourActive || tourPaused) return
1501
+ const nextIdx = current() + 1
1502
+ if (nextIdx >= total) {
1503
+ stopAutoTour()
1504
+ } else {
1505
+ go(nextIdx)
1506
+ scheduleTourStep()
1507
+ }
1508
+ }, delayMs)
1509
+ }
1510
+ function stopAutoTour() {
1511
+ tourActive = false
1512
+ tourPaused = false
1513
+ if (tourTimer) { clearTimeout(tourTimer); tourTimer = null }
1514
+ if (subBar) subBar.hidden = true
1515
+ if (tourBtn) {
1516
+ tourBtn.setAttribute('aria-pressed', 'false')
1517
+ tourBtn.textContent = cfg?.labels?.autoTourStart || 'Auto-Tour'
1518
+ }
1519
+ }
1520
+ function startAutoTour() {
1521
+ tourActive = true
1522
+ tourPaused = false
1523
+ if (subBar) subBar.hidden = false
1524
+ if (tourBtn) {
1525
+ tourBtn.setAttribute('aria-pressed', 'true')
1526
+ tourBtn.textContent = cfg?.labels?.autoTourStop || 'Stop Tour'
1527
+ }
1528
+ if (subPauseBtn) subPauseBtn.textContent = cfg?.labels?.pause || 'Pause'
1529
+ scheduleTourStep()
1530
+ }
1531
+ tourBtn?.addEventListener('click', () => (tourActive ? stopAutoTour() : startAutoTour()))
1532
+ subStopBtn?.addEventListener('click', stopAutoTour)
1533
+ subPauseBtn?.addEventListener('click', () => {
1534
+ if (!tourActive) return
1535
+ tourPaused = !tourPaused
1536
+ subPauseBtn.textContent = tourPaused ? (cfg?.labels?.resume || 'Resume') : (cfg?.labels?.pause || 'Pause')
1537
+ if (tourPaused && tourTimer) { clearTimeout(tourTimer); tourTimer = null }
1538
+ else scheduleTourStep()
1539
+ })
1540
+ subSpeedBtn?.addEventListener('click', () => {
1541
+ tourSpeed = tourSpeed === 1 ? 2 : 1
1542
+ subSpeedBtn.textContent = tourSpeed + '×'
1543
+ if (tourActive && !tourPaused) scheduleTourStep()
1544
+ })
891
1545
 
892
1546
  // Phase 4 Dual-Screen Presenter Console (BroadcastChannel + window.opener.postMessage + Laser Pointer)
893
1547
  let consoleWin = null
@@ -1147,29 +1801,55 @@ function initDelivery(go, setOverview, current, total, cfg) {
1147
1801
  else openConsole()
1148
1802
  }
1149
1803
 
1150
- // Laser pointer toggle ('L') + local stage tracking + fallback 'P' capture handler
1804
+ // Live Presenter Hotkeys: Ctrl/Cmd+K (Jump Search), L (Laser), D (Whiteboard Draw), T (Q&A Timer), A (Auto-Tour)
1151
1805
  document.addEventListener('keydown', event => {
1152
1806
  const targetEl = event.target
1807
+ const lower = String(event.key || '').toLowerCase()
1808
+ if ((event.ctrlKey || event.metaKey) && lower === 'k') {
1809
+ event.preventDefault()
1810
+ openJumpModal()
1811
+ return
1812
+ }
1153
1813
  if (event.ctrlKey || event.metaKey || event.altKey) return
1154
1814
  if (targetEl && (['INPUT', 'SELECT', 'TEXTAREA'].includes(targetEl.tagName) || targetEl.isContentEditable === true)) return
1155
- if (panel.open) return
1156
- const lower = String(event.key || '').toLowerCase()
1815
+ if (panel.open || (jumpDialog && jumpDialog.open)) return
1157
1816
  if (lower === 'l') {
1158
1817
  event.preventDefault()
1159
1818
  laserActive = !laserActive
1160
1819
  applyLaser(laserActive, 0.5, 0.5)
1161
1820
  document.body.classList.toggle('laser-active', laserActive)
1162
1821
  sendConsoleState()
1163
- const toastEl = document.getElementById('toast')
1164
- if (toastEl && cfg?.labels) {
1165
- toastEl.textContent = laserActive ? cfg.labels.laserOn : cfg.labels.laserOff
1166
- toastEl.hidden = false
1167
- setTimeout(() => { toastEl.hidden = true }, 2000)
1822
+ showToast(laserActive ? cfg?.labels?.laserOn : cfg?.labels?.laserOff)
1823
+ } else if (lower === 'd') {
1824
+ event.preventDefault()
1825
+ setDrawActive(!drawActive)
1826
+ } else if (lower === 'z' && drawActive) {
1827
+ event.preventDefault()
1828
+ const list = strokesBySlide.get(current())
1829
+ if (list && list.length > 0) { list.pop(); redrawCanvas(current()) }
1830
+ } else if (lower === 'c' && drawActive) {
1831
+ event.preventDefault()
1832
+ strokesBySlide.set(current(), [])
1833
+ redrawCanvas(current())
1834
+ } else if (lower === 't') {
1835
+ event.preventDefault()
1836
+ toggleQaPill()
1837
+ } else if (lower === 'a') {
1838
+ event.preventDefault()
1839
+ if (tourActive) stopAutoTour()
1840
+ else startAutoTour()
1841
+ } else if (lower === 'r') {
1842
+ event.preventDefault()
1843
+ toggleCommentsDrawer()
1844
+ } else if (lower === 'escape') {
1845
+ if (commentsDrawer && !commentsDrawer.hidden) { event.preventDefault(); toggleCommentsDrawer(false); return }
1846
+ if (drawActive) { event.preventDefault(); setDrawActive(false); return }
1847
+ if (laserActive) {
1848
+ applyLaser(false)
1849
+ document.body.classList.remove('laser-active')
1850
+ sendConsoleState()
1168
1851
  }
1169
- } else if (lower === 'escape' && laserActive) {
1170
- applyLaser(false)
1171
- document.body.classList.remove('laser-active')
1172
- sendConsoleState()
1852
+ if (tourActive) stopAutoTour()
1173
1853
  }
1174
1854
  })
1175
1855
 
@@ -1185,6 +1865,9 @@ function initDelivery(go, setOverview, current, total, cfg) {
1185
1865
  previous.disabled = index === 0
1186
1866
  next.disabled = index === total - 1
1187
1867
  if (consoleOpen()) sendConsoleState(index)
1868
+ if (drawActive || strokesBySlide.has(index)) redrawCanvas(index)
1869
+ if (tourActive) updateSubtitleBar(index)
1870
+ if (commentsDrawer && !commentsDrawer.hidden) updateCommentsContext(index)
1188
1871
  }
1189
1872
  }
1190
1873
 
@@ -1198,6 +1881,42 @@ const DELIVERY_CSS = `
1198
1881
  #delivery-bar #download-pptx{background:var(--accent);color:var(--bg);border-color:var(--accent)}
1199
1882
  #dsh-laser-dot{position:fixed;z-index:95;width:16px;height:16px;border-radius:99px;background:#EF4444;box-shadow:0 0 14px 6px rgba(239,68,68,.75);pointer-events:none;transform:translate(-50%,-50%);display:none}
1200
1883
  body.laser-active{cursor:crosshair}
1884
+ #dsh-draw-canvas{position:fixed;inset:0;z-index:88;pointer-events:none;touch-action:none}
1885
+ #dsh-draw-canvas.is-active{pointer-events:auto;cursor:crosshair}
1886
+ #dsh-draw-bar{position:fixed;top:16px;left:50%;transform:translateX(-50%);z-index:94;display:flex;align-items:center;gap:8px;padding:7px 12px;border-radius:99px;background:color-mix(in srgb,var(--panel) 94%,transparent);border:1px solid var(--accent);box-shadow:0 10px 30px rgba(0,0,0,.35);backdrop-filter:blur(8px)}
1887
+ #dsh-draw-bar[hidden]{display:none}
1888
+ .dsh-pen-color{width:20px;height:20px;border-radius:99px;background:var(--swatch);border:2px solid transparent;cursor:pointer;padding:0}
1889
+ .dsh-pen-color.is-active{border-color:#FFF;box-shadow:0 0 0 2px var(--accent)}
1890
+ #dsh-draw-bar button:not(.dsh-pen-color){border:1px solid var(--muted);border-radius:99px;background:var(--bg);color:var(--fg);padding:4px 10px;font-size:12px;cursor:pointer}
1891
+ #dsh-qa-timer{position:fixed;top:64px;right:22px;z-index:92;display:flex;align-items:center;gap:7px;padding:8px 13px;border-radius:99px;background:color-mix(in srgb,var(--panel) 95%,transparent);border:1px solid var(--accent);box-shadow:0 10px 28px rgba(0,0,0,.32);font-size:12.5px;font-variant-numeric:tabular-nums}
1892
+ #dsh-qa-timer[hidden]{display:none}
1893
+ #dsh-qa-timer.is-warn{border-color:#F59E0B}
1894
+ #dsh-qa-timer.is-warn #dsh-qa-readout{color:#F59E0B}
1895
+ #dsh-qa-timer.is-over{border-color:#EF4444}
1896
+ #dsh-qa-timer.is-over #dsh-qa-readout{color:#EF4444}
1897
+ .dsh-qa-lbl{font-weight:700;color:var(--accent);font-size:11px;letter-spacing:.08em}
1898
+ #dsh-qa-readout{font-size:16px;font-weight:800;min-width:52px;text-align:center}
1899
+ #dsh-qa-timer button{border:1px solid color-mix(in srgb,var(--muted) 45%,transparent);border-radius:99px;background:var(--bg);color:var(--fg);padding:3px 8px;font-size:11.5px;cursor:pointer}
1900
+ #dsh-qa-timer button.is-active{background:var(--accent);color:var(--bg);border-color:var(--accent)}
1901
+ #dsh-sub-bar{position:fixed;bottom:76px;left:50%;transform:translateX(-50%);z-index:90;max-width:min(820px,calc(100vw - 36px));display:flex;align-items:center;gap:12px;padding:10px 16px;border-radius:14px;background:rgba(15,23,42,.9);color:#F8FAFC;border:1px solid rgba(255,255,255,.16);box-shadow:0 12px 32px rgba(0,0,0,.38);backdrop-filter:blur(8px)}
1902
+ #dsh-sub-bar[hidden]{display:none}
1903
+ #dsh-sub-text{font-size:15px;line-height:1.45;font-weight:500}
1904
+ .dsh-sub-ctrl{display:flex;gap:6px;flex-shrink:0}
1905
+ .dsh-sub-ctrl button{border:1px solid rgba(255,255,255,.28);border-radius:99px;background:rgba(255,255,255,.1);color:#F8FAFC;padding:4px 9px;font-size:11.5px;cursor:pointer}
1906
+ #dsh-jump-dialog{background:var(--panel);color:var(--fg);border:1px solid var(--accent);border-radius:16px;width:min(620px,calc(100vw - 24px));max-height:76vh;padding:16px;box-shadow:0 20px 54px rgba(0,0,0,.45)}
1907
+ #dsh-jump-dialog::backdrop{background:rgba(0,0,0,.55);backdrop-filter:blur(3px)}
1908
+ .dsh-jump-head{display:flex;justify-content:space-between;align-items:center;font-size:13px;font-weight:700;color:var(--muted);margin-bottom:10px}
1909
+ .dsh-jump-head button{border:1px solid var(--muted);border-radius:8px;background:transparent;color:var(--fg);padding:3px 8px;font-size:11px;cursor:pointer}
1910
+ #dsh-jump-input{width:100%;padding:11px 14px;border-radius:10px;border:1px solid var(--muted);background:var(--bg);color:var(--fg);font:inherit;font-size:15px;margin-bottom:10px}
1911
+ #dsh-jump-results{list-style:none;margin:0;padding:0;max-height:48vh;overflow:auto;display:flex;flex-direction:column;gap:6px}
1912
+ #dsh-jump-results li{display:flex;align-items:center;gap:10px;padding:9px 11px;border-radius:10px;background:var(--bg);border:1px solid transparent;cursor:pointer}
1913
+ #dsh-jump-results li:hover,#dsh-jump-results li.is-selected{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--bg))}
1914
+ .dsh-jump-badge{font-size:11px;font-weight:800;padding:2px 7px;border-radius:6px;background:color-mix(in srgb,var(--accent) 18%,transparent);color:var(--accent);flex-shrink:0}
1915
+ .dsh-jump-badge.is-ev{background:rgba(16,185,129,.18);color:#10B981}
1916
+ .dsh-jump-main{display:flex;flex-direction:column;min-width:0}
1917
+ .dsh-jump-main strong{font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
1918
+ .dsh-jump-main small{font-size:11.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
1919
+ .dsh-jump-empty{color:var(--muted);justify-content:center;cursor:default!important}
1201
1920
  #review-panel{background:var(--panel);color:var(--fg);border:1px solid var(--muted);border-radius:18px;width:min(620px,calc(100vw - 24px));max-height:85vh;padding:24px;overflow:auto}
1202
1921
  #review-panel::backdrop{background:rgba(0,0,0,.65)}
1203
1922
  .review-head{display:flex;justify-content:space-between;align-items:center;gap:16px}
@@ -1223,5 +1942,19 @@ button:focus-visible,a:focus-visible,input:focus-visible{outline:2px solid var(-
1223
1942
  #notes-panel,#help-panel{bottom:160px}
1224
1943
  #review-panel{padding:18px}
1225
1944
  }
1226
- @media print{#delivery-bar,#review-panel,#dsh-laser-dot{display:none!important}}
1945
+ #dsh-review-comments{position:fixed;top:64px;right:22px;z-index:93;width:min(360px,calc(100vw - 24px));max-height:74vh;display:flex;flex-direction:column;gap:8px;padding:14px;border-radius:14px;background:color-mix(in srgb,var(--panel) 97%,transparent);color:var(--fg);border:1px solid var(--accent);box-shadow:0 18px 46px rgba(0,0,0,.38);backdrop-filter:blur(8px);overflow:hidden}
1946
+ #dsh-review-comments[hidden]{display:none}
1947
+ .dsh-rc-head{display:flex;justify-content:space-between;align-items:center;font-size:13px}
1948
+ .dsh-rc-head button{border:1px solid var(--muted);border-radius:8px;background:transparent;color:var(--fg);padding:2px 7px;cursor:pointer}
1949
+ .dsh-rc-ctx{font-size:12px;font-weight:700;color:var(--accent)}
1950
+ #dsh-rc-author,#dsh-rc-input{width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--muted);background:var(--bg);color:var(--fg);font:inherit;font-size:12.5px}
1951
+ .dsh-rc-actions{display:flex;gap:8px}
1952
+ .dsh-rc-actions button{flex:1;padding:7px 10px;border-radius:8px;border:1px solid var(--accent);background:var(--accent);color:var(--bg);font:inherit;font-size:12px;font-weight:700;cursor:pointer}
1953
+ #dsh-rc-export{background:var(--bg);color:var(--fg);border-color:var(--muted)}
1954
+ #dsh-rc-list{list-style:none;margin:0;padding:0;overflow:auto;display:flex;flex-direction:column;gap:6px;max-height:30vh}
1955
+ #dsh-rc-list li{display:flex;gap:6px;align-items:flex-start;background:var(--bg);border:1px solid color-mix(in srgb,var(--muted) 30%,transparent);border-radius:8px;padding:7px 8px;font-size:12px}
1956
+ .dsh-rc-jump{flex:1;text-align:left;background:transparent;border:0;color:var(--fg);font:inherit;cursor:pointer;padding:0;line-height:1.4}
1957
+ .dsh-rc-del{background:transparent;border:0;color:var(--muted);cursor:pointer;padding:0 4px}
1958
+ .dsh-rc-empty{color:var(--muted);justify-content:center}
1959
+ @media print{#delivery-bar,#review-panel,#dsh-review-comments,#dsh-laser-dot,#dsh-draw-canvas,#dsh-draw-bar,#dsh-qa-timer,#dsh-sub-bar,#dsh-jump-dialog{display:none!important}}
1227
1960
  `