create-pmos 0.398.0 → 0.399.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 (126) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +18 -14
  7. package/workspace/briefing-premium-board-test.js +80 -48
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +6 -2
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +46 -42
  18. package/workspace/briefing-premium-work-test.js +9 -9
  19. package/workspace/changelog.json +12 -0
  20. package/workspace/ev-everywhere-test.js +210 -0
  21. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  22. package/workspace/guide/home.md +39 -18
  23. package/workspace/guide/index.md +1 -1
  24. package/workspace/lib/board-grill.js +63 -0
  25. package/workspace/lib/board-premium.js +36 -5
  26. package/workspace/lib/initiative-layout.js +77 -0
  27. package/workspace/lib/insights-premium.js +3 -2
  28. package/workspace/lib/insights-records.js +21 -7
  29. package/workspace/lib/meeting-points.js +52 -0
  30. package/workspace/lib/news-for-you.js +88 -0
  31. package/workspace/lib/notes-series.js +29 -6
  32. package/workspace/lib/report-confirm.js +48 -0
  33. package/workspace/lib/route-modules.js +8 -0
  34. package/workspace/lib/routes-board-docs.js +46 -0
  35. package/workspace/lib/routes-board-grill.js +90 -0
  36. package/workspace/lib/routes-home-review.js +108 -0
  37. package/workspace/lib/routes-initiative-layout.js +57 -0
  38. package/workspace/lib/routes-insights-premium.js +4 -1
  39. package/workspace/lib/routes-insights-records.js +8 -4
  40. package/workspace/lib/routes-meeting-points.js +37 -0
  41. package/workspace/lib/routes-news.js +57 -0
  42. package/workspace/lib/routes-notes.js +2 -1
  43. package/workspace/lib/routes-report-confirm.js +31 -0
  44. package/workspace/lib/routes-search.js +38 -0
  45. package/workspace/lib/search-index.js +176 -0
  46. package/workspace/package-lock.json +2 -2
  47. package/workspace/package.json +1 -1
  48. package/workspace/premium-board-actions-test.js +86 -50
  49. package/workspace/premium-briefing-depth-test.js +55 -54
  50. package/workspace/premium-chat-chart-tab-test.js +4 -2
  51. package/workspace/premium-chat-report-tab-test.js +16 -2
  52. package/workspace/premium-core-doc-issue-test.js +15 -13
  53. package/workspace/premium-phone-card-test.js +5 -3
  54. package/workspace/premium-report-read-test.js +55 -18
  55. package/workspace/premium-vw-backlog-test.js +2 -2
  56. package/workspace/premium-vw-cal-test.js +50 -35
  57. package/workspace/premium-vw-doc-test.js +9 -3
  58. package/workspace/premium-vw-item-test.js +1 -1
  59. package/workspace/premium-vw-jira-test.js +2 -2
  60. package/workspace/premium-vw-meet-test.js +37 -40
  61. package/workspace/premium-vw-notes-test.js +21 -19
  62. package/workspace/premium-vw-rec-test.js +11 -12
  63. package/workspace/premium-welcome-test.js +3 -3
  64. package/workspace/premium-work-depth-test.js +3 -3
  65. package/workspace/public/pm/bd-acts.js +303 -225
  66. package/workspace/public/pm/bd-asks.js +261 -0
  67. package/workspace/public/pm/bd-pop.js +59 -0
  68. package/workspace/public/pm/bd-span.js +49 -13
  69. package/workspace/public/pm/bd-views.js +169 -0
  70. package/workspace/public/pm/cozy-board.css +301 -0
  71. package/workspace/public/pm/cozy-ev.css +228 -0
  72. package/workspace/public/pm/cozy-evmodel.js +106 -0
  73. package/workspace/public/pm/cozy-evui.js +47 -0
  74. package/workspace/public/pm/cozy-insights.css +148 -10
  75. package/workspace/public/pm/cozy-nav.js +103 -39
  76. package/workspace/public/pm/cozy-news.js +140 -0
  77. package/workspace/public/pm/cozy-search.js +203 -0
  78. package/workspace/public/pm/cozy-settings.js +198 -0
  79. package/workspace/public/pm/cozy-sources.js +89 -0
  80. package/workspace/public/pm/cozy-today.css +217 -0
  81. package/workspace/public/pm/cozy-viewer.js +1 -0
  82. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  83. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  84. package/workspace/public/pm/home-adddoc.js +5 -5
  85. package/workspace/public/pm/home-app.js +329 -55
  86. package/workspace/public/pm/home-around.js +24 -126
  87. package/workspace/public/pm/home-chat.js +67 -14
  88. package/workspace/public/pm/home-data.js +6 -6
  89. package/workspace/public/pm/home-dictate.js +54 -0
  90. package/workspace/public/pm/home-draft.js +6 -6
  91. package/workspace/public/pm/home-ini-model.js +190 -0
  92. package/workspace/public/pm/home-ini.css +171 -0
  93. package/workspace/public/pm/home-ini.js +456 -0
  94. package/workspace/public/pm/home-list.js +276 -0
  95. package/workspace/public/pm/home-more.js +17 -134
  96. package/workspace/public/pm/home-phone-card.js +4 -4
  97. package/workspace/public/pm/home-review.js +104 -0
  98. package/workspace/public/pm/home-task.js +67 -0
  99. package/workspace/public/pm/home-today.js +144 -0
  100. package/workspace/public/pm/home-work.js +54 -26
  101. package/workspace/public/pm/premium-board.js +163 -39
  102. package/workspace/public/pm/premium-chart-tab.js +4 -5
  103. package/workspace/public/pm/premium-first.js +5 -7
  104. package/workspace/public/pm/premium-insights.js +499 -202
  105. package/workspace/public/pm/premium-mtg-present.js +138 -0
  106. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  107. package/workspace/public/pm/premium-report-read.js +216 -52
  108. package/workspace/public/pm/premium-report-tab.js +44 -19
  109. package/workspace/public/pm/premium-shell.js +7 -7
  110. package/workspace/public/pm/premium-vw-cal.js +150 -60
  111. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  112. package/workspace/public/pm/premium-vw-notes.js +61 -0
  113. package/workspace/public/pm/rp-parts.js +269 -0
  114. package/workspace/public/premium-board.html +4 -3
  115. package/workspace/public/premium-insights.html +10 -10
  116. package/workspace/public/premium.html +3 -1
  117. package/workspace/r/m1.png +0 -0
  118. package/workspace/r/m2.png +0 -0
  119. package/workspace/r/m3.png +0 -0
  120. package/workspace/r/nl.png +0 -0
  121. package/workspace/test-lists/initiative-layout.json +9 -0
  122. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  123. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  124. package/workspace/test-lists/uf-everywhere.json +15 -0
  125. package/workspace/test-lists/uf-home.json +9 -0
  126. package/workspace/test-lists/uncovered-board.json +9 -0
@@ -1,18 +1,30 @@
1
- /* pm/premium-report-read.js — a report cycle in the Viewer card (initiative premium-agreed-design, area viewer; ReportPanel.dc.html).
1
+ /* pm/premium-report-read.js — a report cycle in the Viewer card (initiative premium-agreed-design, area viewer; ReportPanel.dc.html; the
2
+ * uncovered parts drawn by premium-uncovered-features, workstream reports: canvas RpBrief, RpStates, RpDoc, RpLive, RpPhone).
2
3
  *
3
- * One report cycle, drawn as the design's report panel inside the czViewer card (cozy-viewer.js): no conversation, no tabs, nothing in #dlg.
4
+ * One report cycle, drawn as the design's report panel inside the czViewer card (cozy-viewer.js): no conversation, nothing in #dlg.
4
5
  * Header kind "Report · <audience>" (the template's audience), the report's name.
5
- * Chips the cycle chip (Draft · Oct 21, Issued · Oct 21; orange "Editing the Oct 21 draft" while editing), the schedule chip and its
6
- * popover (Every week, Every 2 weeks, Every month on the 1st, Something else: say it in the chat; Mon to Fri; the time; Cancel and
7
- * Schedule it), and Brief.
8
- * Toolbar Slides | Page, Edit, Present, Share (its popover: Link | Send a file, Ends in, Password, Create link, the open links and Turn off),
9
- * the blue Issue button and More (PPTX DOCX PDF XLSX CSV MD, Print, Versions "N cycles", Discard this draft… or Archive).
6
+ * Tabs Report | Brief, Brief with the count of what waits for the PM's confirm (RpBrief).
7
+ * Chips the cycle chip (Draft · Oct 21, Issued · Oct 21; orange "Editing the Oct 21 draft" while editing) and its menu in groups:
8
+ * Draft, Issued, Archived with Bring back, and Archive <cycle> (RpStates); the schedule chip and its popover (Every week, Every
9
+ * 2 weeks, Every month on the 1st, Something else: say it in the chat; Mon to Fri; the time; Cancel and Schedule it).
10
+ * Toolbar Slides | Document | Live page, Edit, Present, Share (its popover: Link | Send a file, Ends in, Password, Create link, the open
11
+ * links and Turn off), Download (PDF or Word), the blue Issue button and More (PPTX DOCX PDF XLSX CSV MD, Print, Versions
12
+ * "N cycles", Discard this draft… or Archive).
10
13
  * Issue a confirm with the three checks of GET /api/viewer-report/checks, Issue it and Not yet. POST /api/report/issue freezes the cycle.
14
+ * Issued the lock line "Issued, so it stays as sent. Changes go into the next cycle." with Start the next cycle (RpStates).
15
+ * Discard a card at the foot of the panel: "Discard the Oct 12 draft?", the cycle that stays, "This cannot be undone." (RpStates).
11
16
  * Slides the current slide, "Slides", the counter (1 of 5) with previous and next, and a thumbnail of each slide.
12
- * Phone Slides | Page as icons, Issue and More; More also holds Edit, Present, Share and Brief.
13
- * Parts the design does not draw yet carry the "Waiting for design" marker: the Brief, the cycle menu (Versions), Discard and Archive confirms,
14
- * the issued and archived states, Present, the page editor that Edit mounts on Page (premium-vw-doc.js), and the slide editor's tools the design
15
- * does not draw (the slide tools, the selected item's tools, the speaker notes).
17
+ * Document the words as paper pages: the eyebrow, the title, "In one minute", numbered sections, tables, the sources as footnotes,
18
+ * "Page n of N" and Download as PDF or Word (RpDoc; rp-parts.js paperModel). A designed cycle shows its designed page.
19
+ * Live page the numbers Insights reads (GET /api/insights-premium): the goal tiles, Goals on track, Shipped and At risk, the picked goal's
20
+ * line with its range and its points, the shipped rows that open for detail (RpLive; rp-parts.js liveModel). An issued cycle
21
+ * reads only the readings up to its day, so its page never changes later.
22
+ * Brief At a glance (For, Read by, Goes out, Built from), Please confirm (Confirm or Correct, Use it or Read again), Why it looks like
23
+ * this, Earlier looks with Go back to it (RpBrief; rp-parts.js briefModel).
24
+ * Present the slide over the whole page, "Slide n of N", the numbered strip, ← → and B to blank the screen, Stop presenting.
25
+ * Phone Report | Brief, Slides | Page, the slide, "Slide 1 of 6 · swipe for the next", the lock line and Present (RpPhone).
26
+ * The page editor that Edit mounts on Document (premium-vw-doc.js) and the slide editor's own tools have no artboard: they keep the "Waiting
27
+ * for design" marker.
16
28
  * Edit (Slides) the design's edit mode: the tip, the slide with a dashed outline and the selected item boxed, then "Slides ‹ n of N ›" and the
17
29
  * thumbnails; Undo and Redo dim when there is nothing to take back or do again. premium-vw-slides.js draws it in the card.
18
30
  *
@@ -22,14 +34,18 @@
22
34
  * slideHtml(lines) a section's lines as html (pure) · splitRender(html) · slideCard(s, mini) · fit(root) · schedLabel(setup) (pure)
23
35
  *
24
36
  * READS: GET /api/doc, /api/report-design/cycle and cycle-html (a cycle drawn to its saved design), /api/report-setups (schedule and audience),
25
- * /api/viewer-report/checks, /api/shares, /api/shares/password, /api/report-export (the files). Every render is HTML the server sanitized,
26
- * shown in a frame with an empty sandbox: nothing in it runs.
37
+ * /api/viewer-report/checks, /api/report-structure and /api/report-design (the Brief), /api/report-confirm, /api/insights-premium (Live page),
38
+ * /api/shares, /api/shares/password, /api/report-export (the files). Every render is HTML the server sanitized, shown in a frame with an empty
39
+ * sandbox: nothing in it runs.
27
40
  * WRITES (each a press, pmPost behind the launch nonce): /api/report/issue, /api/report-setups/edit or /setup (Schedule it),
28
- * /api/report-documents/discard and /archive, /api/shares and /api/shares/off. */
41
+ * /api/report-documents/discard and /archive, /api/shares and /api/shares/off, /api/report-confirm (Confirm, Use it), /api/report/draft
42
+ * (Read again: a redraft that keeps the notes; Start the next cycle without a template), /api/report-setups/draft (Start the next cycle),
43
+ * /api/report-design/revert (Go back to it). */
29
44
  import { pmGet, pmPost } from './http.js';
30
45
  import { open as vOpen, current as vCur } from './cozy-viewer.js';
31
46
  import { placeholderHtml } from './cozy-placeholder.js';
32
47
  import './premium-vw-open.js'; // registers window.czViews
48
+ import { cycleGroups, cycleName, briefModel, briefHtml, paperModel, paperHtml, liveModel, liveHtml, presentHtml, dayMon } from './rp-parts.js';
33
49
 
34
50
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
35
51
  const svg = (p, n = 18) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true">${p}</svg>`;
@@ -42,7 +58,7 @@ const P = {
42
58
  page: '<path d="M6 3h9l4 4v14H6zM14 3v5h5"/>', print: '<path d="M7 9V4h10v5M7 17H5v-6h14v6h-2M8 14h8v6H8z"/>', hist: '<path d="M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5M12 7v5l3 2"/>',
43
59
  bin: '<path d="M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13"/>', box: '<path d="M4 5h16v4H4zM5 9v10h14V9M10 13h4"/>', lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',
44
60
  redo2: '<path d="M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7"/>', undo: '<path d="M9 14 4 9l5-5M4 9h11a5 5 0 0 1 0 10h-3"/>', redo: '<path d="m15 14 5-5-5-5M20 9H9a5 5 0 0 0 0 10h3"/>',
45
- plus: '<path d="M12 5v14M5 12h14"/>', layout: '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 10h16M10 10v10"/>',
61
+ plus: '<path d="M12 5v14M5 12h14"/>', dl: '<path d="M12 4v11M7 10l5 5 5-5M5 20h14"/>', live: '<path d="M3 17l5-5 4 4 8-8M16 8h4v4"/>', layout: '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 10h16M10 10v10"/>',
46
62
  theme: '<path d="M12 3a9 9 0 1 0 0 18c1 0 1.5-.8 1.5-1.6 0-1-.8-1.4-.8-2.4 0-1 .8-1.6 1.8-1.6H17a4 4 0 0 0 4-4c0-4.6-4-8.4-9-8.4z"/><circle cx="7.5" cy="11" r="1"/><circle cx="10.5" cy="7.5" r="1"/><circle cx="15" cy="7.5" r="1"/>',
47
63
  };
48
64
  const ic = (k, n) => svg(P[k], n);
@@ -51,7 +67,12 @@ const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
51
67
  const W = 1280;
52
68
  const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
53
69
  const inline = (s) => esc(s).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>').replace(/`([^`]+)`/g, '<code>$1</code>');
54
- const WAIT = (f) => `<span class="vz-wait" data-cz-placeholder="${esc(f)}">Waiting for design</span>`;
70
+ const WAIT = (f) => `<span class="vz-wait" data-cz-placeholder="${esc(f)}">Waiting for design</span>`; // only the page editor keeps it
71
+ /** The reader's own sheet (cozy-vw-rp.css), added to the page once. */
72
+ function rpStyle() {
73
+ if (typeof document === 'undefined' || document.querySelector('link[data-rp-css]')) return;
74
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '/pm/cozy-vw-rp.css'; l.setAttribute('data-rp-css', ''); document.head.appendChild(l);
75
+ }
55
76
  /** "Oct 21", from a cycle's YYYY-MM-DD slot. */
56
77
  export const shortSlot = (s) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s || '')); return m ? MONS[+m[2] - 1] + ' ' + +m[3] : String(s || ''); };
57
78
 
@@ -179,11 +200,17 @@ function chipsHtml() {
179
200
  const st = R.issued ? (R.archived ? 'Archived' : 'Issued') : 'Draft';
180
201
  const sched = R.setup === undefined ? '' : chip(R.pop === 'sched' ? 'open' : '', `${ic('clock', 14)}${esc(schedLabel(R.setup))}${ic('chev', 14)}`, 'sched', { exp: R.pop === 'sched', pop: 'dialog', label: 'Schedule: ' + schedLabel(R.setup) + '. Change it' });
181
202
  return `<div class="vz-rpc">${chip(R.issued ? 'issued' : '', `<i aria-hidden="true"></i>${st} · ${esc(when)}${ic('chev', 14)}`, 'cycm', { exp: R.pop === 'cyc', label: st + ', ' + when + '. Other cycles' })}`
182
- + `${R.issued ? WAIT(R.archived ? 'Archived state' : 'Issued state') : ''}${sched}${chip('line', `${ic('brief', 14)}Brief`, 'brief', { cls: ' vz-dko', exp: R.pop === 'brief', pop: 'dialog' })}`
183
- + `${R.pop === 'sched' ? schedPop() : R.pop === 'cyc' ? cycPop() : ''}</div>`;
203
+ + `${sched}${R.pop === 'sched' ? schedPop() : R.pop === 'cyc' ? cycPop() : ''}</div>`;
204
+ }
205
+ /** Report | Brief (RpBrief). Brief carries the count of what waits for the PM's confirm. */
206
+ function tabsHtml() {
207
+ const n = R.BF ? R.BF.count : 0;
208
+ return `<div class="cz-tabs rp-tabs" role="tablist" aria-label="Report or its brief"><button type="button" role="tab" class="cz-tab" data-r="tab|report" aria-selected="${R.tab === 'report'}">Report</button>`
209
+ + `<button type="button" role="tab" class="cz-tab" data-r="tab|brief" aria-selected="${R.tab === 'brief'}">Brief${n ? ` <span class="cz-pill late rp-n" aria-label="${n} to confirm">${n}</span>` : ''}</button></div>`;
184
210
  }
185
211
  function toolHtml() {
186
- const seg = `<div class="vz-sg" role="group" aria-label="${R.edit ? 'Edit as' : 'Read as'}"><button type="button" data-r="view|deck" aria-pressed="${R.view === 'deck'}" aria-label="Slides" title="Slides">${ic('slides', 16)}<span class="vz-dko">Slides</span></button><button type="button" data-r="view|doc" aria-pressed="${R.view === 'doc'}" aria-label="Page" title="Page">${ic('page', 16)}<span class="vz-dko">Page</span></button></div>`;
212
+ const sb = (k, icon, l, cls) => `<button type="button" data-r="view|${k}" aria-pressed="${R.view === k}" aria-label="${l}" title="${l}"${cls ? ` class="${cls}"` : ''}>${ic(icon, 16)}<span class="vz-dko">${l}</span></button>`;
213
+ const seg = `<div class="vz-sg" role="group" aria-label="${R.edit ? 'Edit as' : 'Read as'}">${sb('deck', 'slides', 'Slides')}${sb('doc', 'page', R.edit ? 'Page' : 'Document')}${R.edit ? '' : sb('live', 'live', 'Live page', 'vz-dko')}</div>`;
187
214
  if (R.edit) {
188
215
  const deck = R.view === 'deck';
189
216
  const SS = slideState(); // Undo and Redo are dimmed while there is nothing to take back or to do again (ReportPanel.dc.html: Redo at .4)
@@ -196,8 +223,15 @@ function toolHtml() {
196
223
  return `<div class="vz-tb">${seg}<span class="vz-sp"></span>`
197
224
  + (R.issued ? '' : ib('edit', ic('pen'), R.view === 'deck' ? 'Edit the slides' : 'Edit the words', { cls: ' vz-dko' }))
198
225
  + ib('present', ic('play'), 'Present', { cls: ' vz-dko' }) + ib('share', ic('share'), 'Share a link to a copy', { cls: ' vz-dko', exp: R.pop === 'share', pop: 'dialog' })
226
+ + ib('dlm', ic('dl'), 'Download', { cls: ' vz-dko', exp: R.pop === 'dl' })
199
227
  + (issue ? '<span class="vz-sep vz-dko"></span>' + issue : '') + ib('more', ic('more'), 'More', { exp: R.pop === 'more' })
200
- + (R.pop === 'more' ? morePop() : R.pop === 'share' ? sharePop() : '') + '</div>';
228
+ + (R.pop === 'more' ? morePop() : R.pop === 'share' ? sharePop() : R.pop === 'dl' ? dlPop() : '') + '</div>';
229
+ }
230
+ /** Download (RpDoc): the paper as PDF (the browser prints it) or Word. The other files stay in More. */
231
+ function dlPop() {
232
+ return `<div class="vz-pop vz-pop-dl" data-esc-layer="1" role="menu" aria-label="Download"><button type="button" class="vz-mi vz-hv" role="menuitem" data-r="pdf">${ic('print')}<span class="vz-grow">PDF</span><small class="vz-note">keeps the look</small></button>`
233
+ + `<a class="vz-mi vz-hv" role="menuitem" data-r="dl|docx" href="/api/report-export?${esc(q({ ws: R.ws, path: R.row.path, fmt: 'docx' }))}" download>${ic('page')}<span class="vz-grow">Word</span><small class="vz-note">to change the words</small></a>`
234
+ + `<p class="vz-note vz-padmi">Slides, tables and Markdown are in More.</p></div>`;
201
235
  }
202
236
  function schedPop() {
203
237
  const k = R.sch, opts = [['weekly', 'Every week'], ['bi-weekly', 'Every 2 weeks'], ['monthly', 'Every month, on the 1st'], ['else', 'Something else: say it in the chat']];
@@ -213,17 +247,21 @@ function schedPop() {
213
247
  }
214
248
  /** The times the schedule's chip offers, 24-hour, every half hour from 06:00 to 20:00, with the saved one kept. */
215
249
  export const times = (cur) => { const L = []; for (let h = 6; h <= 20; h++) for (const m of ['00', '30']) L.push(String(h).padStart(2, '0') + ':' + m); if (cur && !L.includes(cur)) L.push(cur); return L.sort(); };
250
+ /** The cycle menu (RpStates): Draft, Issued and Archived, an archived cycle with Bring back, and Archive for the open issued cycle. */
216
251
  function cycPop() {
217
- const C = R.cycles.length ? R.cycles : [R.row];
218
- const st = (x) => (x.state === 'issued' ? (x.archived ? 'Archived' : 'Issued') : 'Draft');
219
- return `<div class="vz-pop vz-pop-cyc" data-esc-layer="1" role="menu" aria-label="Cycles"><p class="vz-lab">Cycles ${WAIT('Cycle menu')}</p>`
220
- + C.map((x) => `<button type="button" class="vz-mi vz-hv" role="menuitemradio" aria-checked="${x.path === R.row.path}" data-r="cyc|${esc(x.path)}"><span class="vz-grow">${esc(shortSlot(x.slot || x.date))}</span><small class="vz-note">${st(x)}</small></button>`).join('') + '</div>';
252
+ const G = cycleGroups(R.cycles.length ? R.cycles : [R.row], R.row.path, R.id);
253
+ const row = (x, g) => g === 'archived'
254
+ ? `<div class="vz-mi rp-arch"><span class="vz-grow">${esc(x.name)}</span><button type="button" class="rp-btn soft" data-r="unarch|${esc(x.path)}"${R.busy ? ' disabled' : ''}>Bring back</button></div>`
255
+ : `<button type="button" class="vz-mi vz-hv" role="menuitemradio" aria-checked="${x.cur}" data-r="cyc|${esc(x.path)}"><span class="vz-grow">${esc(x.name)}</span><small class="vz-note">${esc(x.when)}</small></button>`;
256
+ return `<div class="vz-pop vz-pop-cyc" data-esc-layer="1" role="menu" aria-label="Cycles">`
257
+ + G.map((g) => `<p class="vz-lab">${g.t}</p>` + g.rows.map((x) => row(x, g.k)).join('')).join('')
258
+ + (R.issued && !R.archived && !R.edit ? `<hr><button type="button" class="vz-mi vz-hv" role="menuitem" data-r="archive">${ic('box')}Archive ${esc(cycleName(R.row, R.id))}</button>` : '') + '</div>';
221
259
  }
222
260
  function morePop() {
223
261
  const fmt = (k, l) => (k === 'pdf' || k === 'md' ? `<button type="button" class="vz-fmt" data-r="${k}">${l}</button>` : `<a class="vz-fmt" data-r="dl|${k}" href="/api/report-export?${esc(q({ ws: R.ws, path: R.row.path, fmt: k }))}" download>${l}</a>`);
224
262
  const n = R.cycles.length || 1;
225
263
  return `<div class="vz-pop vz-pop-more" data-esc-layer="1" role="menu" aria-label="More">`
226
- + `<span class="vz-pho">${R.issued ? '' : mi('edit', 'pen', 'Edit')}${mi('present', 'play', 'Present')}${mi('share', 'share', 'Share')}${mi('brief', 'brief', 'Brief')}<hr></span>`
264
+ + `<span class="vz-pho">${R.issued ? '' : mi('edit', 'pen', 'Edit')}${mi('present', 'play', 'Present')}${mi('share', 'share', 'Share')}<hr></span>`
227
265
  + `<p class="vz-lab">Download</p><div class="vz-fmts">${fmt('pptx', 'PPTX')}${fmt('docx', 'DOCX')}${fmt('pdf', 'PDF')}${fmt('xlsx', 'XLSX')}${fmt('csv', 'CSV')}${fmt('md', 'MD')}</div>`
228
266
  + `<p class="vz-note vz-padmi">Slides as PowerPoint, words as Word or Markdown, tables as Excel or CSV. PDF keeps the look.</p>`
229
267
  + mi('print', 'print', 'Print') + `<button type="button" class="vz-mi vz-hv" role="menuitem" data-r="cycm">${ic('hist')}<span class="vz-grow">Versions</span><small class="vz-note">${n} ${n === 1 ? 'cycle' : 'cycles'}</small></button><hr>`
@@ -270,26 +308,44 @@ function confHtml() {
270
308
  + (R.issueErr ? `<p class="vz-msg" data-tone="bad" role="alert">${esc(R.issueErr)}</p>` : '')
271
309
  + `<div><button type="button" class="vz-issue vz-hv vz-h36" data-r="issueok"${R.busy ? ' disabled' : ''}>${ic('check', 16)}Issue it</button><button type="button" class="vz-sec2 vz-hv vz-h36" data-r="issueno"${R.busy ? ' disabled' : ''}>Not yet</button></div></div>`;
272
310
  }
273
- if (R.ask) {
274
- const T = { discard: ['Discard this draft? The file is deleted. Issued reports are not touched.', 'Discard', 'Keep it', 'Discard confirm'],
275
- archive: ['Archive this report? It is kept for good and moved to the end of the Reports list.', 'Archive', 'Cancel', 'Archive confirm'] }[R.ask];
276
- return `<div class="vz-ask2" role="group" aria-label="${esc(T[1])}"><span>${esc(T[0])} ${WAIT(T[3])}</span>${R.askErr ? `<p class="vz-msg" data-tone="bad" role="alert">${esc(R.askErr)}</p>` : ''}<div><button type="button" class="vz-issue vz-hv vz-h36" data-r="askok"${R.ask === 'discard' ? ' data-k="bad"' : ''}${R.busy ? ' disabled' : ''}>${esc(T[1])}</button><button type="button" class="vz-sec2 vz-hv vz-h36" data-r="askno">${esc(T[2])}</button></div></div>`;
277
- }
278
311
  return '';
279
312
  }
313
+ /** Discard or Archive asks in a card at the foot of the panel (RpStates: "Discard draft 2? Draft 1 stays. This cannot be undone."). */
314
+ function askHtml() {
315
+ if (!R.ask) return '';
316
+ const name = cycleName(R.row, R.id), other = R.cycles.filter((x) => x.path !== R.row.path && !x.archived)[0];
317
+ const T = R.ask === 'discard'
318
+ ? [`Discard the ${name} draft?`, (other ? cycleName(other, R.id) + ' stays. ' : '') + 'This cannot be undone.', 'Discard']
319
+ : [`Archive ${name}?`, 'It stays as sent, at the end of the Reports list. Bring it back from the cycle menu.', 'Archive'];
320
+ return `<div class="rp-ask" role="alertdialog" aria-label="${esc(T[0])}"><p><b>${esc(T[0])}</b> <span class="rp-mut">${esc(T[1])}</span></p>`
321
+ + (R.askErr ? `<p class="vz-msg" data-tone="bad" role="alert">${esc(R.askErr)}</p>` : '')
322
+ + `<div><button type="button" class="rp-btn${R.ask === 'discard' ? ' bad' : ' dark'}" data-r="askok"${R.busy ? ' disabled' : ''}>${esc(T[2])}</button><button type="button" class="rp-btn" data-r="askno">Keep it</button></div></div>`;
323
+ }
324
+ /** The lock line of an issued or archived cycle (RpStates, RpPhone). */
325
+ function lockHtml() {
326
+ if (!R.issued || R.edit) return '';
327
+ return `<div class="rp-lock">${ic('lock', 14)}<span>${R.archived ? 'Archived, so it stays as sent. Bring it back from the cycle menu.' : 'Issued, so it stays as sent. Changes go into the next cycle.'}</span>`
328
+ + (R.archived ? `<button type="button" class="rp-btn" data-r="unarch|${esc(R.row.path)}"${R.busy ? ' disabled' : ''}>Bring back</button>` : `<button type="button" class="rp-btn" data-r="nextcyc"${R.busy ? ' disabled' : ''}>Start the next cycle</button>`) + '</div>';
329
+ }
280
330
  function deckHtml() {
281
331
  const L = slides();
282
- if (!L.length) return '<p class="vz-empty">This cycle has no slides. Read it as a page.</p>';
332
+ if (!L.length) return '<p class="vz-empty">This cycle has no slides. Read it as a document.</p>';
283
333
  const i = R.i = Math.max(0, Math.min(R.i, L.length - 1));
284
334
  return `<div class="vz-slide" tabindex="0" role="group" aria-roledescription="slide" aria-label="Slide ${i + 1} of ${L.length}: ${esc(L[i].h)}. Use the arrow keys to change slide." data-r="slide">${slideCard(L[i])}</div>`
285
- + `<div class="vz-snav"><b>Slides</b><span class="vz-sp"></span>${ib('prev', ic('prev', 16), 'Previous slide', { cls: ' vz-small', off: i === 0 })}<span aria-live="polite">${i + 1} of ${L.length}</span>${ib('next', ic('next', 16), 'Next slide', { cls: ' vz-small', off: i === L.length - 1 })}</div>`
335
+ + `<div class="vz-snav rp-dkn"><b>Slides</b><span class="vz-sp"></span>${ib('prev', ic('prev', 16), 'Previous slide', { cls: ' vz-small', off: i === 0 })}<span aria-live="polite">${i + 1} of ${L.length}</span>${ib('next', ic('next', 16), 'Next slide', { cls: ' vz-small', off: i === L.length - 1 })}</div>`
336
+ + `<p class="rp-swipe rp-pho">Slide ${i + 1} of ${L.length} · swipe for the next</p>`
286
337
  + `<div class="vz-thumbs" role="group" aria-label="Slides">${L.map((x, j) => `<button type="button" class="vz-th vz-hv" data-r="go|${j}"${j === i ? ' aria-current="true"' : ''} aria-label="Slide ${j + 1}: ${esc(x.h)}"><span>${j === i || x.k === 'frame' ? slideCard(x, true) : ''}</span><span>${j + 1} · ${esc(x.h)}</span></button>`).join('')}</div>`;
287
338
  }
288
339
  function pageHtml() {
289
340
  if (R.cyc) return `<div class="vz-pagefr">${frame(R.cyc.style, R.cyc.body, '', 'The report as a page')}</div>`;
290
341
  const w = R.W || { title: R.name, sections: [] };
291
- return `<article class="vz-page"><h2>${esc(w.title)}</h2>${w.sections.map((x) => `<h4>${esc(x.h)}</h4>${slideHtml(x.lines)}`).join('')}</article>`;
342
+ return paperHtml(paperModel(w, { audience: R.audience, name: R.name, slot: R.row.slot }), { state: R.archived ? 'archived' : R.issued ? 'issued' : 'draft', issuedOn: dayMon(R.row.slot) });
292
343
  }
344
+ function liveView() {
345
+ const L = R.LV && R.LV.m ? liveModel(R.LV.m, { upTo: R.issued ? R.row.slot : null, range: R.LV.range, pick: R.LV.pick, open: R.LV.open }) : R.LV && R.LV.err ? { none: R.LV.err } : null;
346
+ return liveHtml(L, { name: R.name, audience: R.audience, period: R.issued ? 'As issued · ' + dayMon(R.row.slot) : 'Now', issued: R.issued, readAgo: R.LV && agoOf(R.LV.at), hover: R.LV ? R.LV.hover : null, prodOpen: R.pop === 'prod', products: R.LV && R.LV.m && R.LV.m.board ? R.LV.m.board.switcher : [] });
347
+ }
348
+ const agoOf = (t) => { if (!t) return ''; const m = Math.round((Date.now() - t) / 60000); return m < 1 ? 'just now' : m === 1 ? '1 min ago' : m < 60 ? m + ' min ago' : Math.round(m / 60) + ' h ago'; };
293
349
  function bodyHtml() {
294
350
  if (R.edit) {
295
351
  const SS = slideState(), n = SS ? SS.deck.slides.length : slides().length, at = SS ? SS.i : R.i;
@@ -297,9 +353,11 @@ function bodyHtml() {
297
353
  + (R.view === 'deck' && !R.noTip ? `<p class="vz-tip"><span>${tipText(at, n)}</span>${ib('notip', ic('x', 14), 'Hide this tip', { cls: ' vz-small' })}</p>` : '')
298
354
  + (R.view === 'deck' ? '' : `<div class="vz-r1">${WAIT('Page editor')}</div>`) + '<div class="vz-ed" data-vz-ed></div></div>';
299
355
  }
300
- return `<div class="vz-rpb">${confHtml()}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}`
301
- + (R.pop === 'brief' ? `<div class="vz-ask2"><div><b>Brief</b><span class="vz-sp"></span>${ib('pop|', ic('x', 14), 'Close the brief', { cls: ' vz-small' })}</div>${placeholderHtml('Report brief', 'How this report is made: its sources, sections and look.')}</div>` : '')
302
- + (R.err ? `<p class="vz-msg" data-tone="bad" role="alert">The document could not be read: ${esc(R.err)}</p>` : !R.W ? '<p class="vz-empty" role="status">Reading the report.</p>' : R.view === 'deck' ? deckHtml() : pageHtml()) + '</div>';
356
+ if (R.tab === 'brief') return `<div class="vz-rpb">${briefHtml(R.BF, { issued: R.issued, busy: R.busy, msg: R.bfMsg })}</div>`;
357
+ const view = R.err ? `<p class="vz-msg" data-tone="bad" role="alert">The document could not be read: ${esc(R.err)}</p>` : !R.W ? '<p class="vz-empty" role="status">Reading the report.</p>'
358
+ : R.view === 'deck' ? deckHtml() : R.view === 'live' ? liveView() : pageHtml();
359
+ return `<div class="vz-rpb">${confHtml()}${R.msg ? `<p class="vz-msg" role="status" data-tone="${R.msg.tone || ''}">${esc(R.msg.text)}</p>` : ''}${lockHtml()}${view}`
360
+ + (R.view === 'deck' && R.W && !R.err ? `<button type="button" class="rp-btn rp-present rp-pho" data-r="present">${ic('play', 16)}Present</button>` : '') + askHtml() + '</div>';
303
361
  }
304
362
  const tipText = (i, n) => `Slide ${i + 1} of ${n}. Click an item to change it; double-click text to type.`;
305
363
  /** The editor's slide and its undo history changed: the tip and the dimmed Undo and Redo follow it. */
@@ -310,7 +368,7 @@ function edState(S) {
310
368
  if (u) u.classList.toggle('vz-dim', !S.hist.length); if (r) r.classList.toggle('vz-dim', !S.fut.length);
311
369
  }
312
370
  /** The whole panel as html. */
313
- export function panelHtml() { return `<div class="vz vz-rp0" data-view="${R.view}"${R.edit ? ' data-edit' : ''}><div class="vz-rph">${chipsHtml()}${toolHtml()}</div>${bodyHtml()}</div>`; }
371
+ export function panelHtml() { return `<div class="vz vz-rp0" data-view="${R.view}" data-tab="${R.tab}"${R.edit ? ' data-edit' : ''}><div class="vz-rph">${R.edit ? '' : tabsHtml()}${R.tab === 'brief' && !R.edit ? '' : chipsHtml() + toolHtml()}</div>${bodyHtml()}</div>`; }
314
372
 
315
373
  const bodyEl = () => (R && vCur() && vCur().id === R.vid ? document.querySelector('#czViewer .cz-vw-body') : null);
316
374
  function draw() {
@@ -331,7 +389,7 @@ function wire(b) {
331
389
  const t = e.target.closest('[data-r]');
332
390
  if (!t) { if (R.pop && R.pop !== 'brief' && !e.target.closest('.vz-pop')) { R.pop = null; draw(); } return; }
333
391
  if (t.disabled || t.tagName === 'INPUT' || t.tagName === 'SELECT') return;
334
- if (t.tagName === 'A' && t.dataset.r.startsWith('dl|')) { R.pop = null; setTimeout(draw, 0); return; }
392
+ if (t.tagName === 'A') { if (t.dataset.r.startsWith('dl|')) { R.pop = null; setTimeout(draw, 0); } return; } // a download or a link to another page
335
393
  e.preventDefault(); act(t.dataset.r.split('|'), t);
336
394
  };
337
395
  b.onchange = (e) => { if (e.target.dataset.r === 'stime') R.sch.time = e.target.value || '09:00'; };
@@ -340,6 +398,14 @@ function wire(b) {
340
398
  if (e.key === 'Escape' && R.pop) { e.preventDefault(); e.stopPropagation(); R.pop = null; draw(); return; }
341
399
  if (!R.edit && R.view === 'deck' && /^Arrow(Left|Right)$/.test(e.key) && !e.target.closest('input')) { const L = slides().length, j = R.i + (e.key === 'ArrowRight' ? 1 : -1); if (j >= 0 && j < L) { e.preventDefault(); R.i = j; draw(); const s = bodyEl().querySelector('.vz-slide'); if (s) s.focus(); } }
342
400
  };
401
+ /* a phone swipes the slide (RpPhone "swipe for the next") */
402
+ let x0 = null;
403
+ b.ontouchstart = (e) => { x0 = !R.edit && R.view === 'deck' && e.target.closest('.vz-slide') && e.touches.length === 1 ? e.touches[0].clientX : null; };
404
+ b.ontouchend = (e) => {
405
+ if (x0 == null) return; const dx = e.changedTouches[0].clientX - x0; x0 = null;
406
+ if (Math.abs(dx) < 40) return; const j = R.i + (dx < 0 ? 1 : -1); if (j >= 0 && j < slides().length) { R.i = j; draw(); }
407
+ };
408
+ b.onmousemove = (e) => { if (R.view !== 'live' || !R.LV) return; const pt = e.target.closest('.rp-pt'); if (pt) { const h = +pt.dataset.r.split('|')[2]; if (R.LV.hover !== h) { R.LV.hover = h; draw(); } } };
343
409
  }
344
410
  /* a 1280 x 720 frame scales to its slide's width */
345
411
  const RO = typeof ResizeObserver === 'function' ? new ResizeObserver((es) => { for (const e of es) scaleOf(e.target, e.contentRect.width); }) : null;
@@ -350,7 +416,13 @@ export function fit(root) { root.querySelectorAll('.vz-fr').forEach((c) => { if
350
416
  const say = (text, tone) => { R.msg = { text, tone }; draw(); };
351
417
  async function act([k, v], t) {
352
418
  if (k === 'pop') { R.pop = v || null; return draw(); }
353
- if (k === 'view') { if (R.view === v) return; R.view = v; R.pop = null; const ed = R.edit && bodyEl() && bodyEl().querySelector('[data-vz-ed]'); if (ed) delete ed.dataset.mounted; return draw(); }
419
+ if (k === 'tab') { if (R.tab === v) return; R.tab = v; R.pop = null; R.conf = false; R.ask = ''; if (v === 'brief' && !R.BF) readBrief(); return draw(); }
420
+ if (k === 'bf') return briefAct(v, t.dataset.r.split('|').slice(2).join('|'));
421
+ if (k === 'lv') return liveAct(v, t.dataset.r.split('|').slice(2).join('|'));
422
+ if (k === 'dlm') { R.pop = R.pop === 'dl' ? null : 'dl'; return draw(); }
423
+ if (k === 'nextcyc') return nextCycle();
424
+ if (k === 'unarch') { R.pop = null; return lifeIt('unarchive', v); }
425
+ if (k === 'view') { if (R.view === v) return; R.view = v; R.pop = null; if (v === 'live' && !R.LV) readLive(); const ed = R.edit && bodyEl() && bodyEl().querySelector('[data-vz-ed]'); if (ed) delete ed.dataset.mounted; return draw(); }
354
426
  if (k === 'cycm') { R.pop = R.pop === 'cyc' ? null : 'cyc'; return draw(); }
355
427
  if (k === 'cyc') { const row = R.cycles.find((x) => x.path === v); R.pop = null; if (row && row.path !== R.row.path) return openReport(row, R.hand); return draw(); }
356
428
  if (k === 'sched') { if (R.pop !== 'sched') { R.sch = schedPick(R.setup); R.schErr = ''; } R.pop = R.pop === 'sched' ? null : 'sched'; return draw(); }
@@ -358,7 +430,6 @@ async function act([k, v], t) {
358
430
  if (k === 'sday') { R.sch.day = v; return draw(); }
359
431
  if (k === 'sgo') return schedIt(schedOf(R.sch));
360
432
  if (k === 'soff') return schedIt('off');
361
- if (k === 'brief') { R.pop = R.pop === 'brief' ? null : 'brief'; return draw(); }
362
433
  if (k === 'more') { R.pop = R.pop === 'more' ? null : 'more'; return draw(); }
363
434
  if (k === 'share') { if (R.pop !== 'share') openShare(); else { R.pop = null; draw(); } return; }
364
435
  if (k === 'prev' || k === 'next') { R.i += k === 'next' ? 1 : -1; return draw(); }
@@ -438,11 +509,11 @@ async function issueIt() {
438
509
  say('Issued and frozen. Nothing was sent to anyone; share it yourself.');
439
510
  if (R.onIssue) R.onIssue(R.row);
440
511
  }
441
- async function lifeIt(k) {
512
+ async function lifeIt(k, at) {
442
513
  if (R.busy) return;
443
- const me = R; R.busy = true; R.askErr = ''; draw();
514
+ const me = R, rel = at || R.row.path; R.busy = true; R.askErr = ''; draw();
444
515
  const archived = k === 'archive';
445
- const r = await pmPost('/api/report-documents/' + (k === 'discard' ? 'discard' : 'archive'), k === 'discard' ? { ws: R.ws, path: R.row.path } : { ws: R.ws, path: R.row.path, archived }).catch(() => null);
516
+ const r = await pmPost('/api/report-documents/' + (k === 'discard' ? 'discard' : 'archive'), k === 'discard' ? { ws: R.ws, path: rel } : { ws: R.ws, path: rel, archived }).catch(() => null);
446
517
  if (R !== me) return;
447
518
  R.busy = false;
448
519
  if (!r || r.ok !== true) { R.askErr = (k === 'discard' ? 'The draft was not discarded: ' : 'Nothing changed: ') + ((r && r.error) || 'the page could not reach PMOS') + '.'; if (!R.ask) R.msg = { text: R.askErr, tone: 'bad' }; return draw(); }
@@ -454,11 +525,100 @@ async function lifeIt(k) {
454
525
  const b = bodyEl(); if (b) b.innerHTML = '<div class="vz"><p class="vz-empty" role="status">The draft is discarded.</p></div>';
455
526
  return;
456
527
  }
457
- R.archived = archived; R.row = { ...R.row, archived };
458
- R.cycles = R.cycles.map((x) => (x.path === R.row.path ? { ...x, archived } : x));
459
- say(archived ? 'Archived. It is kept, at the end of the Reports list.' : 'It is back in the Reports list.');
528
+ R.cycles = R.cycles.map((x) => (x.path === rel ? { ...x, archived } : x));
529
+ if (rel === R.row.path) { R.archived = archived; R.row = { ...R.row, archived }; }
530
+ say(archived ? 'Archived. It is kept, at the end of the Reports list.' : (rel === R.row.path ? 'It is back in the Reports list.' : cycleName(R.cycles.find((x) => x.path === rel) || {}, R.id) + ' is back in the Reports list.'));
460
531
  if (R.onChange) R.onChange();
461
532
  }
533
+ /** Start the next cycle (RpStates): the template drafts its next cycle; a report with no template drafts one now. The new draft opens. */
534
+ async function nextCycle() {
535
+ if (R.busy) return;
536
+ const me = R, c = cycleOf(R.row); R.busy = true; draw();
537
+ const r = R.setup ? await pmPost('/api/report-setups/draft', { ws: R.ws, id: R.setup.id }).catch(() => null) : await pmPost('/api/report/draft', { ws: R.ws, cadence: c.cadence }).catch(() => null);
538
+ if (R !== me) return;
539
+ R.busy = false;
540
+ if (!r || r.ok !== true) return say('The next cycle was not started: ' + ((r && r.error) || 'the page could not reach PMOS') + '.', 'bad');
541
+ if (R.onChange) R.onChange();
542
+ const at = (r.drafted && r.drafted.path) || r.path;
543
+ if (!at) return say('PMOS is drafting the next cycle. It shows in the cycle menu when it is ready.');
544
+ const slot = (r.drafted && r.drafted.slot) || r.slot || '';
545
+ const row = { path: at, slot, state: 'draft', cadence: c.cadence };
546
+ return openReport(row, { ...R.hand, name: R.name, cycles: [row].concat(R.cycles.filter((x) => x.path !== at)) });
547
+ }
548
+
549
+ /* ── the Brief (RpBrief): the template, its structure and look, the checks and what the PM confirmed ── */
550
+ async function readBrief() {
551
+ const me = R;
552
+ const [st, de, ch, cf] = await Promise.all([
553
+ R.setup ? pmGet('/api/report-structure?' + q({ ws: R.ws, id: R.id })) : null, R.setup ? pmGet('/api/report-design?' + q({ ws: R.ws, id: R.id })) : null,
554
+ R.issued ? null : pmGet('/api/viewer-report/checks?' + q({ ws: R.ws, path: R.row.path, slot: R.row.slot })), pmGet('/api/report-confirm?' + q({ path: R.row.path })),
555
+ ].map((x) => Promise.resolve(x).catch(() => null)));
556
+ if (R !== me) return;
557
+ R.bfRaw = { structure: st && st.ok ? st.structure : null, design: de && de.ok ? de.design : null, checks: ch, confirms: cf && cf.ok ? cf.keys : [] };
558
+ buildBrief(); draw();
559
+ }
560
+ function buildBrief() {
561
+ const x = R.bfRaw; if (!x) return;
562
+ const goes = R.issued ? 'Issued ' + dayMon(R.row.slot) : R.setup && R.setup.status !== 'paused' ? schedLabel(R.setup) + (R.setup.next_draft ? ' · next ' + dayMon(String(R.setup.next_draft).slice(0, 10)) : '') : '';
563
+ R.BF = briefModel({ ...x, setup: R.setup, W: R.W, issued: R.issued, goesOut: goes, hasTemplate: !!R.setup });
564
+ }
565
+ async function briefAct(a, v) {
566
+ const me = R;
567
+ if (a === 'fix') {
568
+ const it = R.BF && R.BF.confirm.find((c) => c.key === v); if (!it) return;
569
+ const text = (it.where === 'Brief' ? 'Answer' : 'Correct') + ' "' + R.name + '", ' + it.where.toLowerCase() + ': ' + it.text + ' → ';
570
+ const ta = document.getElementById('hmIn'); // Home's chat box, when the Viewer sits beside it
571
+ if (ta) { ta.value = text; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); R.bfMsg = 'Say the correction in the chat. The report changes on its next draft.'; }
572
+ else R.bfMsg = 'Say the correction in the chat on Home: ' + it.where + ': ' + it.text;
573
+ return draw();
574
+ }
575
+ if (a === 'ok' || a === 'use') {
576
+ R.busy = true; draw();
577
+ const r = await pmPost('/api/report-confirm', { path: R.row.path, key: v, act: a === 'use' ? 'use' : 'confirm' }).catch(() => null);
578
+ if (R !== me) return;
579
+ R.busy = false;
580
+ if (!r || !r.ok) { R.bfMsg = 'That was not kept: ' + ((r && r.error) || 'the page could not reach PMOS') + '.'; return draw(); }
581
+ R.bfRaw.confirms = (R.bfRaw.confirms || []).concat(v); buildBrief(); R.bfMsg = a === 'use' ? 'Kept: it goes out with that figure.' : 'Confirmed.'; return draw();
582
+ }
583
+ if (a === 'again') {
584
+ const c = cycleOf(R.row); R.busy = true; R.bfMsg = 'Reading the sources again.'; draw();
585
+ const r = await pmPost('/api/report/draft', { ws: R.ws, cadence: c.cadence, slot: c.slot, redraft: true }).catch(() => null);
586
+ if (R !== me) return;
587
+ R.busy = false;
588
+ if (!r || !r.ok) { R.bfMsg = 'It was not read again: ' + ((r && r.error) || 'the page could not reach PMOS') + '.'; return draw(); }
589
+ await reread(); if (R !== me) return; R.bfMsg = 'Read again. Your notes are kept.'; return readBrief();
590
+ }
591
+ if (a === 'back') {
592
+ R.busy = true; draw();
593
+ const r = await pmPost('/api/report-design/revert', { ws: R.ws, id: R.id, n: +v }).catch(() => null);
594
+ if (R !== me) return;
595
+ R.busy = false;
596
+ if (!r || !r.ok) { R.bfMsg = 'The look did not change: ' + ((r && r.error) || 'the page could not reach PMOS') + '.'; return draw(); }
597
+ R.bfMsg = 'Back to D' + v + '. Press Use it in the report\'s design to keep it for the next cycle.'; return readBrief();
598
+ }
599
+ }
600
+
601
+ /* ── the live page (RpLive): GET /api/insights-premium, the numbers Insights reads ── */
602
+ async function readLive(board) {
603
+ const me = R;
604
+ R.LV = Object.assign(R.LV || { range: '8w', pick: null, open: null, hover: null }, { m: null, err: '' });
605
+ const qq = board ? q({ ws: board.ws, board: board.id }) : q({ ws: R.ws });
606
+ let j = null;
607
+ try { const res = await fetch('/api/insights-premium' + (qq ? '?' + qq : ''), { credentials: 'same-origin' }); j = await res.json(); } catch { j = null; }
608
+ if (R !== me) return;
609
+ if (!j || !j.ok || !j.model) R.LV.err = 'The numbers could not be read' + (j && j.error ? ': ' + j.error : '') + '.';
610
+ else { R.LV.m = j.model; R.LV.at = j.as_of ? Date.parse(j.as_of) || Date.now() : Date.now(); }
611
+ draw();
612
+ }
613
+ function liveAct(a, v) {
614
+ const L = R.LV; if (!L) return;
615
+ if (a === 'goal') { L.pick = v; L.hover = null; return draw(); }
616
+ if (a === 'range') { L.range = v; L.hover = null; return draw(); }
617
+ if (a === 'pt') { L.hover = +v; return draw(); }
618
+ if (a === 'row') { L.open = L.open === v ? null : v; return draw(); }
619
+ if (a === 'prod') { R.pop = R.pop === 'prod' ? null : 'prod'; return draw(); }
620
+ if (a === 'board') { const [ws, id] = v.split('~'); R.pop = null; return readLive({ ws, id }); }
621
+ }
462
622
 
463
623
  /* ── share (Link | Send a file): POST /api/shares makes a copy of the file as it is now ── */
464
624
  async function openShare() {
@@ -574,23 +734,25 @@ function printIt() {
574
734
  w.focus(); setTimeout(() => { try { w.print(); } catch { /* the PM prints from the window */ } }, 300);
575
735
  }
576
736
 
577
- /* ── Present: the current slide on the whole screen (Waiting for design) ── */
737
+ /* ── Present: the current slide on the whole screen (RpPhone Present; the strip and the hint of MtPresent) ── */
578
738
  function present(on) {
579
739
  let p = document.getElementById('vzPres');
580
740
  if (!on) { if (!p) return; p.remove(); if (document.fullscreenElement) document.exitFullscreen().catch(() => {}); if (R) draw(); const b = bodyEl() && bodyEl().querySelector('[data-r="present"]'); if (b) b.focus(); return; }
581
741
  const L = slides(); if (!L.length) return say('This cycle has no slides to present.');
582
742
  if (!p) {
583
- p = document.createElement('div'); p.id = 'vzPres'; p.className = 'vz vz-pres'; p.setAttribute('role', 'dialog'); p.setAttribute('aria-modal', 'true'); p.setAttribute('aria-label', 'Presenting ' + R.name); p.tabIndex = -1; p.dataset.escLayer = '1';
584
- p.onclick = (e) => { const t = e.target.closest('[data-r]'); if (!t || t.disabled) return; const k = t.dataset.r; if (k === 'end') return present(false); R.i += k === 'next' ? 1 : -1; present(true); };
743
+ p = document.createElement('div'); p.id = 'vzPres'; p.className = 'vz vz-pres rp-pres'; p.setAttribute('role', 'dialog'); p.setAttribute('aria-modal', 'true'); p.setAttribute('aria-label', 'Presenting ' + R.name); p.tabIndex = -1; p.dataset.escLayer = '1';
744
+ R.blank = false;
745
+ p.onclick = (e) => { const t = e.target.closest('[data-r]'); if (!t || t.disabled) return; const [k, v] = t.dataset.r.split('|'); if (k === 'end') return present(false); if (k === 'go') R.i = +v; else R.i += k === 'next' ? 1 : -1; R.blank = false; present(true); };
585
746
  p.onkeydown = (e) => {
586
747
  if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); return present(false); }
587
- if (/^Arrow(Left|Right)$/.test(e.key)) { e.preventDefault(); const j = R.i + (e.key === 'ArrowRight' ? 1 : -1); if (j >= 0 && j < slides().length) { R.i = j; present(true); } }
748
+ if (e.key === 'b' || e.key === 'B') { e.preventDefault(); R.blank = !R.blank; return present(true); }
749
+ if (/^Arrow(Left|Right)$/.test(e.key)) { e.preventDefault(); const j = R.i + (e.key === 'ArrowRight' ? 1 : -1); if (j >= 0 && j < slides().length) { R.i = j; R.blank = false; present(true); } }
588
750
  };
589
751
  document.body.appendChild(p);
590
752
  if (p.requestFullscreen && !document.fullscreenElement) p.requestFullscreen().catch(() => {});
591
753
  }
592
754
  const i = R.i = Math.max(0, Math.min(R.i, L.length - 1));
593
- p.innerHTML = `<div class="vz-slide">${slideCard(L[i])}</div><div class="vz-snav">${ib('prev', ic('prev', 16), 'Previous slide', { off: i === 0 })}<span>${i + 1} of ${L.length}</span>${ib('next', ic('next', 16), 'Next slide', { off: i === L.length - 1 })}${ib('end', ic('x', 16), 'Stop presenting')}${WAIT('Present')}</div>`;
755
+ p.innerHTML = presentHtml({ name: R.name, i, n: L.length, slide: slideCard(L[i]), blank: R.blank });
594
756
  fit(p); p.focus();
595
757
  }
596
758
  if (typeof document !== 'undefined') document.addEventListener('fullscreenchange', () => { if (!document.fullscreenElement && document.getElementById('vzPres')) present(false); });
@@ -610,9 +772,10 @@ export async function openReport(row, hand = {}) {
610
772
  if (!row || !row.path) return null;
611
773
  const c = cycleOf(row);
612
774
  row = { ...row, cadence: c.cadence, slot: c.slot };
775
+ rpStyle();
613
776
  if (R) present(false);
614
777
  const me = R = { row, ws: hand.ws || '', id: c.cadence, name: hand.name || row.name || c.cadence || 'Report', audience: hand.audience || '', issued: row.state === 'issued', archived: !!row.archived,
615
- text: '', err: '', W: null, view: 'deck', i: 0, cyc: null, setup: undefined, pop: null, conf: false, checks: null, issueErr: '', busy: false, ask: '', askErr: '', edit: false, msg: null,
778
+ text: '', err: '', W: null, view: 'deck', tab: 'report', BF: null, bfRaw: null, bfMsg: '', LV: null, blank: false, i: 0, cyc: null, setup: undefined, pop: null, conf: false, checks: null, issueErr: '', busy: false, ask: '', askErr: '', edit: false, msg: null,
616
779
  sch: schedPick(null), schErr: '', shr: null, hand, cycles: (hand.cycles || []).slice(), onIssue: hand.onIssue || null, onChange: hand.onChange || null, vid: 'report:' + row.path };
617
780
  const head = () => ({ id: me.vid, kind: 'Report' + (me.audience ? ' · ' + me.audience : ''), title: me.name, icon: 'report', full: true, url: viewUrl(row, me.ws), render: (b) => { b.innerHTML = panelHtml(); wire(b); }, onClose: () => { if (R === me && !me.reopen) { present(false); R = null; } } });
618
781
  vOpen(head());
@@ -625,6 +788,7 @@ export async function openReport(row, hand = {}) {
625
788
  }
626
789
  await Promise.all([readCycle(), readSetup()]);
627
790
  if (R !== me) return me;
791
+ readBrief(); // the Brief tab's count shows at once
628
792
  if (vCur() && vCur().id === me.vid && (vCur().title !== me.name || me.audience)) { me.reopen = true; vOpen(head()); me.reopen = false; } // the name and audience are known now
629
793
  draw();
630
794
  return me;