create-pmos 0.397.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 (195) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +105 -52
  8. package/workspace/briefing-premium-board-test.js +284 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +85 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +99 -83
  13. package/workspace/briefing-premium-initiative-test.js +175 -290
  14. package/workspace/briefing-premium-insights-test.js +414 -219
  15. package/workspace/briefing-premium-metrics-test.js +55 -97
  16. package/workspace/briefing-premium-products-test.js +44 -28
  17. package/workspace/briefing-premium-sources-test.js +70 -49
  18. package/workspace/briefing-premium-test.js +155 -648
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +24 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/board-premium-trail.js +32 -0
  23. package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
  24. package/workspace/guide/briefing-premium.md +3 -1
  25. package/workspace/guide/home.md +68 -0
  26. package/workspace/guide/index.md +1 -0
  27. package/workspace/lib/agent-roles.js +71 -0
  28. package/workspace/lib/board-grill.js +63 -0
  29. package/workspace/lib/board-premium.js +121 -24
  30. package/workspace/lib/board-trail.js +223 -0
  31. package/workspace/lib/home-work-item.js +58 -0
  32. package/workspace/lib/initiative-layout.js +77 -0
  33. package/workspace/lib/insights-goals.js +196 -0
  34. package/workspace/lib/insights-premium.js +64 -15
  35. package/workspace/lib/insights-records.js +115 -0
  36. package/workspace/lib/jira-tickets.js +1 -1
  37. package/workspace/lib/meeting-points.js +52 -0
  38. package/workspace/lib/news-for-you.js +88 -0
  39. package/workspace/lib/notes-series.js +29 -6
  40. package/workspace/lib/report-confirm.js +48 -0
  41. package/workspace/lib/route-modules.js +12 -0
  42. package/workspace/lib/routes-board-docs.js +46 -0
  43. package/workspace/lib/routes-board-grill.js +90 -0
  44. package/workspace/lib/routes-board-trail.js +33 -0
  45. package/workspace/lib/routes-home-desk.js +176 -0
  46. package/workspace/lib/routes-home-review.js +108 -0
  47. package/workspace/lib/routes-initiative-layout.js +57 -0
  48. package/workspace/lib/routes-insights-premium.js +16 -4
  49. package/workspace/lib/routes-insights-records.js +133 -0
  50. package/workspace/lib/routes-meeting-points.js +37 -0
  51. package/workspace/lib/routes-news.js +57 -0
  52. package/workspace/lib/routes-notes.js +3 -1
  53. package/workspace/lib/routes-report-confirm.js +31 -0
  54. package/workspace/lib/routes-search.js +38 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/search-index.js +176 -0
  57. package/workspace/lib/transcript-steps.js +123 -0
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-board-actions-test.js +128 -82
  63. package/workspace/premium-briefing-depth-test.js +104 -90
  64. package/workspace/premium-chat-attach-test.js +54 -63
  65. package/workspace/premium-chat-chart-tab-test.js +37 -37
  66. package/workspace/premium-chat-context-test.js +19 -18
  67. package/workspace/premium-chat-goal-view-test.js +23 -23
  68. package/workspace/premium-chat-notes-test.js +26 -31
  69. package/workspace/premium-chat-report-tab-test.js +46 -28
  70. package/workspace/premium-chat-term-test.js +16 -16
  71. package/workspace/premium-chat-viewer-test.js +60 -59
  72. package/workspace/premium-core-doc-issue-test.js +52 -43
  73. package/workspace/premium-html-viewer-test.js +14 -17
  74. package/workspace/premium-phone-card-test.js +10 -3
  75. package/workspace/premium-phone-room-test.js +41 -35
  76. package/workspace/premium-report-read-test.js +152 -197
  77. package/workspace/premium-viewer-download-test.js +19 -22
  78. package/workspace/premium-viewer-flicker-test.js +11 -16
  79. package/workspace/premium-viewer-share-test.js +6 -9
  80. package/workspace/premium-viewer-test.js +41 -60
  81. package/workspace/premium-vw-backlog-test.js +53 -33
  82. package/workspace/premium-vw-cal-test.js +97 -128
  83. package/workspace/premium-vw-copy-test.js +17 -33
  84. package/workspace/premium-vw-doc-test.js +17 -10
  85. package/workspace/premium-vw-item-test.js +50 -49
  86. package/workspace/premium-vw-jira-test.js +53 -27
  87. package/workspace/premium-vw-meet-test.js +115 -187
  88. package/workspace/premium-vw-notes-test.js +88 -109
  89. package/workspace/premium-vw-rec-test.js +71 -194
  90. package/workspace/premium-vw-slides-test.js +46 -50
  91. package/workspace/premium-welcome-test.js +3 -2
  92. package/workspace/premium-work-depth-test.js +61 -53
  93. package/workspace/public/pm/bd-acts.js +383 -0
  94. package/workspace/public/pm/bd-asks.js +261 -0
  95. package/workspace/public/pm/bd-pop.js +59 -0
  96. package/workspace/public/pm/bd-span.js +222 -82
  97. package/workspace/public/pm/bd-stages.js +25 -11
  98. package/workspace/public/pm/bd-views.js +169 -0
  99. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  100. package/workspace/public/pm/c3-md.js +3 -395
  101. package/workspace/public/pm/c3-phone-detail.js +1 -1
  102. package/workspace/public/pm/c3-phone-model.js +3 -68
  103. package/workspace/public/pm/chat-term.js +3 -3
  104. package/workspace/public/pm/cozy-board.css +798 -230
  105. package/workspace/public/pm/cozy-ev.css +228 -0
  106. package/workspace/public/pm/cozy-evmodel.js +106 -0
  107. package/workspace/public/pm/cozy-evui.js +47 -0
  108. package/workspace/public/pm/cozy-home.css +570 -142
  109. package/workspace/public/pm/cozy-home.js +5 -3
  110. package/workspace/public/pm/cozy-insights.css +437 -170
  111. package/workspace/public/pm/cozy-md.js +396 -0
  112. package/workspace/public/pm/cozy-nav.js +104 -29
  113. package/workspace/public/pm/cozy-news.js +140 -0
  114. package/workspace/public/pm/cozy-placeholder.js +26 -0
  115. package/workspace/public/pm/cozy-search.js +203 -0
  116. package/workspace/public/pm/cozy-settings.js +198 -0
  117. package/workspace/public/pm/cozy-sources.js +89 -0
  118. package/workspace/public/pm/cozy-today.css +217 -0
  119. package/workspace/public/pm/cozy-viewer.css +3 -3
  120. package/workspace/public/pm/cozy-viewer.js +145 -0
  121. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  122. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  123. package/workspace/public/pm/cozy-vw.css +485 -0
  124. package/workspace/public/pm/cozy.css +83 -1
  125. package/workspace/public/pm/home-adddoc.js +48 -0
  126. package/workspace/public/pm/home-app.js +1179 -0
  127. package/workspace/public/pm/home-around.js +413 -0
  128. package/workspace/public/pm/home-chat.js +512 -0
  129. package/workspace/public/pm/home-data.js +312 -0
  130. package/workspace/public/pm/home-dictate.js +54 -0
  131. package/workspace/public/pm/home-draft.js +68 -0
  132. package/workspace/public/pm/home-ini-model.js +190 -0
  133. package/workspace/public/pm/home-ini.css +171 -0
  134. package/workspace/public/pm/home-ini.js +456 -0
  135. package/workspace/public/pm/home-list.js +276 -0
  136. package/workspace/public/pm/home-more.js +132 -0
  137. package/workspace/public/pm/home-phone-card.js +109 -0
  138. package/workspace/public/pm/home-review.js +104 -0
  139. package/workspace/public/pm/home-task.js +67 -0
  140. package/workspace/public/pm/home-today.js +144 -0
  141. package/workspace/public/pm/home-work.js +547 -0
  142. package/workspace/public/pm/phone-moment.js +69 -0
  143. package/workspace/public/pm/pm-work-view.js +1 -1
  144. package/workspace/public/pm/premium-attach.js +4 -0
  145. package/workspace/public/pm/premium-board.js +548 -395
  146. package/workspace/public/pm/premium-chart-tab.js +109 -62
  147. package/workspace/public/pm/premium-deck.js +3 -3
  148. package/workspace/public/pm/premium-first.js +23 -21
  149. package/workspace/public/pm/premium-insights.js +1102 -581
  150. package/workspace/public/pm/premium-meeting.js +61 -549
  151. package/workspace/public/pm/premium-mtg-present.js +138 -0
  152. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  153. package/workspace/public/pm/premium-notes.js +1 -1
  154. package/workspace/public/pm/premium-report-frame.css +20 -0
  155. package/workspace/public/pm/premium-report-read.js +669 -476
  156. package/workspace/public/pm/premium-report-tab.js +116 -67
  157. package/workspace/public/pm/premium-shell.js +76 -123
  158. package/workspace/public/pm/premium-viewer.js +22 -1
  159. package/workspace/public/pm/premium-vw-cal.js +277 -48
  160. package/workspace/public/pm/premium-vw-doc.css +6 -0
  161. package/workspace/public/pm/premium-vw-doc.js +40 -2
  162. package/workspace/public/pm/premium-vw-file.js +2 -2
  163. package/workspace/public/pm/premium-vw-meet.js +6 -83
  164. package/workspace/public/pm/premium-vw-mtg.js +958 -0
  165. package/workspace/public/pm/premium-vw-notes.js +116 -68
  166. package/workspace/public/pm/premium-vw-open.js +35 -0
  167. package/workspace/public/pm/premium-vw-page.js +16 -0
  168. package/workspace/public/pm/premium-vw-rec.js +11 -218
  169. package/workspace/public/pm/premium-vw-slides.css +5 -0
  170. package/workspace/public/pm/premium-vw-slides.js +44 -8
  171. package/workspace/public/pm/rp-parts.js +269 -0
  172. package/workspace/public/pm/term-view.js +22 -0
  173. package/workspace/public/premium-board.html +29 -70
  174. package/workspace/public/premium-initiative.html +8 -48
  175. package/workspace/public/premium-insights.html +26 -64
  176. package/workspace/public/premium-viewer.html +20 -0
  177. package/workspace/public/premium.html +18 -107
  178. package/workspace/r/m1.png +0 -0
  179. package/workspace/r/m2.png +0 -0
  180. package/workspace/r/m3.png +0 -0
  181. package/workspace/r/nl.png +0 -0
  182. package/workspace/server.js +18 -3
  183. package/workspace/test-files.json +1 -0
  184. package/workspace/test-lists/home-libs.json +9 -0
  185. package/workspace/test-lists/initiative-layout.json +9 -0
  186. package/workspace/test-lists/premium-report-read.json +1 -1
  187. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  188. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  189. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  190. package/workspace/test-lists/premium-vw-notes.json +1 -1
  191. package/workspace/test-lists/uf-everywhere.json +15 -0
  192. package/workspace/test-lists/uf-home.json +9 -0
  193. package/workspace/test-lists/uncovered-board.json +9 -0
  194. package/workspace/public/pm/premium-work.js +0 -729
  195. package/workspace/public/pm/premium.js +0 -1146
@@ -1,42 +1,45 @@
1
- /* pm/premium-chart-tab.js — the Chart tab beside a chat (initiative premium-reports-from-chat, slice C; PRD C1–C3). It replaces the Insight Studio's
2
- * Chart and Dashboard modes: the PM asks in the chat, Claude ends its answer with a `pmos-report` block of kind chart or dashboard
3
- * (public/pm/report-chat.js), and this tab draws it from the KR metric records, as the Insights page draws it (premium-chart-draw.js).
1
+ /* pm/premium-chart-tab.js — a chart or a dashboard from a chat, in the Viewer card (initiative premium-reports-from-chat, slice C; PRD C1–C3;
2
+ * re-drawn for premium-agreed-design, area viewer: Main.dc.html viewer "metrics"). The PM asks in the chat, Claude ends its answer with a
3
+ * `pmos-report` block of kind chart or dashboard (public/pm/report-chat.js), and this view draws it from the KR metric records.
4
4
  *
5
- * A CHART (block.kind 'chart'): the measure's chart as proposed, with its four forms to pick from. Save chart posts POST /api/premium-charts/save.
6
- * A saved chart (block.id) shows as saved; a change Claude proposes to it shows drawn, and Save the change posts the whole chart. Delete chart
7
- * asks once, then posts { id, remove: true }.
8
- * A DASHBOARD (block.kind 'dashboard'): its name, what it is for and its charts in order. Save dashboard posts POST /api/premium-dashboards/save;
9
- * Delete dashboard asks once, then posts { id, remove: true }. Pinning stays on the Insights page.
5
+ * A CHART (block.kind 'chart'): the design's metrics view: three stat tiles (now, since the last reading, the target), then the readings as a
6
+ * chart with the newest one in ember. Below it, the setup block (premium-uncovered-features, drawn in the cozy viewer style): the four forms to pick from
7
+ * (Line, Bars, Number, Meter), Save chart (POST /api/premium-charts/save), and Delete chart, which asks once in the card ({ id, remove: true }).
8
+ * A saved chart (block.id) shows as saved; a change Claude proposes to it shows drawn, and Save the change posts the whole chart.
9
+ * A DASHBOARD (block.kind 'dashboard'): its charts in order as small tiles (a measure with fewer than two readings is named, not drawn), then
10
+ * Save dashboard (POST /api/premium-dashboards/save) and Delete dashboard. Pinning stays on the Insights page.
10
11
  *
11
- * The model is GET /api/insights-premium (the board the page shows). Every value drawn is a reading of a record; a measure with fewer than two
12
- * readings is named, not drawn. Every write is a press here, behind the launch nonce (http.js pmPost). Claude writes nothing: the routes refuse an
13
- * agent session. Nothing is sent outward. */
12
+ * The model is GET /api/insights-premium (the board Insights shows). Every value drawn is a reading of a record. Every write is a press here,
13
+ * behind the launch nonce (http.js pmPost). Claude writes nothing: the routes refuse an agent session. Nothing is sent outward.
14
+ * The view draws in the czViewer card (cozy-viewer.js): no #dlg, no old tab, no premium.css. */
14
15
  import { pmGet, pmPost } from './http.js';
15
- import { vwOpen, vwStyle, vwConfirm } from './premium-viewer.js';
16
- import { tileHtml, deriveChart } from './premium-chart-draw.js';
16
+ import { open as vOpen, current as vCur, body as vBody } from './cozy-viewer.js';
17
+ import { vzStyle } from './premium-vw-open.js';
18
+ import { deriveChart, unitTxt } from './premium-chart-draw.js';
17
19
 
18
20
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
19
21
  const FORMS = [['line', 'Line'], ['bars', 'Bars'], ['number', 'Number'], ['meter', 'Meter']];
20
22
  const ws = () => new URLSearchParams(location.search).get('ws') || '';
21
23
  const post = (p, body) => pmPost(p, Object.assign(ws() ? { ws: ws() } : {}, body)).catch(() => null);
22
- const btn = (a, label, o = {}) => `<button type="button" class="btn${o.sec ? ' sec' : ''}${o.cls ? ' ' + o.cls : ''}" data-ct="${esc(a)}"${o.off ? ' disabled' : ''}${o.pressed != null ? ` aria-pressed="${o.pressed}"` : ''}>${esc(label)}</button>`;
24
+ const btn = (a, label, o = {}) => `<button type="button" class="${o.sec ? 'vz-sec2' : 'vz-issue'} vz-hv${o.cls ? ' ' + o.cls : ''}" data-ct="${esc(a)}"${o.off ? ' disabled' : ''}>${esc(label)}</button>`;
23
25
 
24
- const T = new Map(); // tab id → its state
25
- /** Open (or refresh) the Chart tab for a checked chart or dashboard block (report-chat.js cleanBlock). */
26
+ const T = new Map(); // view id → its state
27
+ /** Open (or refresh) the view of a checked chart or dashboard block (report-chat.js cleanBlock). */
26
28
  export function openChartTab(block) {
27
29
  if (!block || (block.kind !== 'chart' && block.kind !== 'dashboard')) return null;
28
- vwStyle('report');
30
+ vzStyle();
29
31
  const P = block.proposal || {};
30
32
  const id = block.kind + ':' + String(block.id || P.measure || P.name || 'new').toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 60);
31
33
  let t = T.get(id);
32
34
  if (!t || JSON.stringify(t.block) !== JSON.stringify(block)) {
33
- t = { id, block, M: null, loaded: false, busy: false, msg: '', d: null, gone: false, removed: false };
35
+ t = { id, block, M: null, loaded: false, busy: false, msg: '', d: null, gone: false, removed: false, ask: null };
34
36
  T.set(id, t);
35
37
  load(t);
36
38
  }
37
- return vwOpen({ id, title: block.kind === 'chart' ? 'Chart' : 'Dashboard', icon: 'list', render: (el) => draw(t, el), wire: (el) => { el.onclick = (e) => press(t, e); } });
39
+ return vOpen({ id, kind: block.kind === 'chart' ? 'Chart' : 'Dashboard', title: titleOf(t), icon: 'chart', render: (el) => { el.onclick = (e) => press(t, e); draw(t, el); } });
38
40
  }
39
- const paneOf = (t) => document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(t.id)}"]`);
41
+ const titleOf = (t) => { const P = t.block.proposal || {}, d = t.d || {}; return t.block.kind === 'chart' ? d.title || P.title || P.measure || t.block.id || 'Chart' : d.name || P.name || t.block.id || 'Dashboard'; };
42
+ const paneOf = (t) => (vCur() && vCur().id === t.id ? vBody() : null);
40
43
  const redraw = (t) => { const el = paneOf(t); if (el) draw(t, el); };
41
44
 
42
45
  async function load(t) {
@@ -59,18 +62,43 @@ async function load(t) {
59
62
  redraw(t);
60
63
  }
61
64
 
62
- /** A measure's or a saved chart's tile, as Insights draws it. */
63
- function chartOf(M, ref) {
64
- return (M.mine || []).find((c) => c.id === ref) || (M.charts || []).find((c) => c.id === ref) || null;
65
+ /* ── drawing (Main.dc.html viewer "metrics") ── */
66
+ const shortDay = (s) => String(s || '').replace(/^\d{4}-/, '').replace(/^(\d{2})-(\d{2}).*$/, (m, a, b) => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+a - 1] + ' ' + +b);
67
+ const labelOf = (p) => shortDay(String(p.at || p.d || '').slice(0, 10)) || String(p.d || '');
68
+ /** The three stat tiles: the reading now, the step since the last one, and the target. */
69
+ function kpisHtml(c, d) {
70
+ const u = c.unit && /^[%°]/.test(c.unit) ? c.unit : c.unit ? ' ' + c.unit : '';
71
+ const step = c.step === 0 ? 'No change' : (c.step > 0 ? 'Up ' : 'Down ') + Math.abs(c.step) + u;
72
+ const K = [['Now', c.v, 'on ' + c.at], ['Since the last reading', step, c.good === null ? 'Same as before' : c.good ? 'The right way' : 'The wrong way'],
73
+ ['Target', c.target !== null ? unitTxt(c, c.target) : 'None set', d.better === 'lower' ? 'Lower is better' : 'Higher is better']];
74
+ return `<div class="vz-kpis">${K.map(([l, v, n]) => `<div class="vz-kpi"><p>${esc(l)}</p><b>${esc(v)}</b><small>${esc(n)}</small></div>`).join('')}</div>`;
65
75
  }
66
- function draftTile(t) {
67
- const d = t.d, base = (t.M.charts || []).find((c) => c.id === d.measure);
68
- if (!base) {
69
- const m = (t.M.measures || []).find((x) => x.id === d.measure);
70
- return `<p class="rt-msg">${esc(m ? m.title + ' has fewer than two readings, so it has no chart yet.' : 'No KR metric record is called ' + d.measure + ' in this workspace.')}</p>`;
76
+ /** The readings drawn in the picked form, the newest in ember. Bars and a meter start at zero; a value below zero is drawn as a line. */
77
+ function figHtml(c, form, cap) {
78
+ const pts = c.pts, n = pts.length, neg = pts.some((p) => p.v < 0) || (c.target !== null && c.target < 0);
79
+ const f = form === 'bars' && !neg ? 'bars' : form === 'meter' && !neg && c.target !== null ? 'meter' : form === 'number' ? 'number' : 'line';
80
+ const alt = `${c.title}: ${n} readings from ${pts[0].txt} on ${pts[0].d} to ${c.v} on ${c.at}${c.targetTxt ? ', ' + c.targetTxt : ''}`;
81
+ if (f === 'number') return `<figure class="vz-mx-fig" data-form="number"><figcaption>${esc(cap)}</figcaption><p class="vz-mx-big" role="img" aria-label="${esc(alt)}">${esc(c.v)}</p></figure>`;
82
+ const W = 440, H = 150, B = 128, top = 22;
83
+ const hi = Math.max(...pts.map((p) => p.v), c.target !== null ? c.target : 0) || 1;
84
+ if (f === 'meter') {
85
+ const v = pts[n - 1].v, mx = Math.max(v, c.target) * 1.15 || 1, x = (k) => (k / mx * W).toFixed(1);
86
+ return `<figure class="vz-mx-fig" data-form="meter"><figcaption>${esc(cap)}</figcaption><svg class="vz-mx-svg" viewBox="0 0 ${W} 44" role="img" aria-label="${esc(alt)}"><rect class="vz-trk0" x="0" y="14" width="${W}" height="14" rx="7"/><rect class="vz-bar now" x="0" y="14" width="${x(v)}" height="14" rx="7"/><line class="vz-tgt" x1="${x(c.target)}" x2="${x(c.target)}" y1="6" y2="36"/></svg><p class="vz-note">${esc(c.v)} against ${esc(c.targetTxt)}</p></figure>`;
71
87
  }
72
- const c = deriveChart(base, { title: d.title || base.title, form: d.form || 'line', range: d.range || null, target: d.target, better: d.better || 'higher', note: d.note || '' });
73
- return c ? `<div class="ntw ct-tile">${tileHtml(c)}</div>` : '<p class="rt-msg">The range holds fewer than two readings, so nothing is drawn.</p>';
88
+ const slot = W / n, bw = Math.min(36, slot * 0.6), yOf = (v) => B - (v / hi) * (B - top);
89
+ const ty = c.target !== null ? yOf(c.target) : null;
90
+ let g = `<line class="vz-ax" x1="0" x2="${W}" y1="${B}" y2="${B}"/>`;
91
+ if (f === 'bars') g += pts.map((p, i) => { const y = yOf(Math.max(0, p.v)); return `<text class="vz-bv" x="${(slot * i + slot / 2).toFixed(1)}" y="${(y - 6).toFixed(1)}">${esc(p.txt)}</text><rect class="vz-bar${i === n - 1 ? ' now' : ''}" x="${(slot * i + (slot - bw) / 2).toFixed(1)}" y="${y.toFixed(1)}" width="${bw.toFixed(1)}" height="${Math.max(1, B - y).toFixed(1)}" rx="6"/>`; }).join('');
92
+ else {
93
+ const lo = Math.min(...pts.map((p) => p.v), c.target !== null ? c.target : Infinity), rg = (hi - lo) || 1, yL = (v) => B - ((v - lo) / rg) * (B - top);
94
+ const P = pts.map((p, i) => [slot * i + slot / 2, yL(p.v)]);
95
+ g += `<polyline class="vz-ln" points="${P.map((q) => q[0].toFixed(1) + ',' + q[1].toFixed(1)).join(' ')}"/>` + P.map((q, i) => `<circle class="vz-pt${i === n - 1 ? ' now' : ''}" cx="${q[0].toFixed(1)}" cy="${q[1].toFixed(1)}" r="${i === n - 1 ? 6 : 4}"/><text class="vz-bv" x="${q[0].toFixed(1)}" y="${(q[1] - 10).toFixed(1)}">${esc(pts[i].txt)}</text>`).join('');
96
+ if (c.target !== null) g += `<line class="vz-tgt" x1="0" x2="${W}" y1="${yL(c.target).toFixed(1)}" y2="${yL(c.target).toFixed(1)}"/>`;
97
+ }
98
+ if (f === 'bars' && ty !== null) g += `<line class="vz-tgt" x1="0" x2="${W}" y1="${ty.toFixed(1)}" y2="${ty.toFixed(1)}"/>`;
99
+ g += pts.map((p, i) => `<text class="vz-bx" x="${(slot * i + slot / 2).toFixed(1)}" y="${H - 4}">${esc(labelOf(p))}</text>`).join('');
100
+ const why = form !== f ? (neg ? 'A value is below zero, so it is drawn as a line.' : 'No target is set, so it is drawn as a line.') : '';
101
+ return `<figure class="vz-mx-fig" data-form="${f}"><figcaption>${esc(cap)}</figcaption><svg class="vz-mx-svg" viewBox="0 0 ${W} ${H}" role="img" aria-label="${esc(alt)}">${g}</svg>${c.target !== null ? '<p class="vz-note">The dashed line is the target.</p>' : ''}${why ? `<p class="vz-note">${esc(why)}</p>` : ''}</figure>`;
74
102
  }
75
103
  const sameChart = (a, b) => ['measure', 'title', 'question', 'form', 'range', 'target', 'better', 'note'].every((k) => (a[k] == null ? '' : String(a[k])) === (b[k] == null ? '' : String(b[k])));
76
104
 
@@ -78,46 +106,62 @@ function chartHtml(t) {
78
106
  const d = t.d, s = t.saved, base = (t.M.charts || []).find((c) => c.id === d.measure);
79
107
  const changed = !s || !sameChart(s, d);
80
108
  const eye = !s ? 'New chart · from this chat' : changed ? 'Chart change · from this chat' : 'Saved chart';
81
- const forms = `<div class="rt-seg" role="group" aria-label="Form">${FORMS.map(([f, l]) => btn('form|' + f, l, { sec: (d.form || 'line') !== f, pressed: (d.form || 'line') === f })).join('')}</div>`;
82
- const meter = d.form === 'meter' && (d.target === null || d.target === undefined) ? '<p class="rt-note">A meter needs a target. Say one in the chat, or pick another form.</p>' : '';
83
- return `<p class="rt-eye">${esc(eye)}</p><h3 class="rt-h">${esc(d.title || (base ? base.title : d.measure))}</h3>${d.question ? `<p class="rt-sub">${esc(d.question)}</p>` : ''}`
84
- + `<p class="rt-meta">${esc(base ? base.title : d.measure)}${d.range ? ' · last ' + d.range + ' readings' : ' · every reading'}${d.target != null ? ' · target ' + esc(d.target) : ''} · ${d.better === 'lower' ? 'lower is better' : 'higher is better'}</p>`
85
- + forms + draftTile(t) + meter
86
- + `<div class="rt-foot">${changed ? btn('save', t.busy ? 'Saving' : s ? 'Save the change' : 'Save chart', { off: t.busy || !base || !!meter }) : ''}</div>`
87
- + `<p class="rt-note">${s ? 'It shows on Insights under Your charts.' : 'Saved, it shows on Insights under Your charts and can go on a dashboard.'} Ask in the chat to change it.</p>`
88
- + (s ? `<div class="rt-foot rt-end">${btn('remove', 'Delete chart', { sec: true, cls: 'rt-del', off: t.busy })}</div>` : '');
109
+ const form = d.form || 'line';
110
+ let shown;
111
+ if (!base) { const m = (t.M.measures || []).find((x) => x.id === d.measure); shown = `<p class="vz-msg">${esc(m ? m.title + ' has fewer than two readings, so it has no chart yet.' : 'No KR metric record is called ' + d.measure + ' in this workspace.')}</p>`; }
112
+ else {
113
+ const c = deriveChart(base, { title: d.title || base.title, form, range: d.range || null, target: d.target, better: d.better || 'higher', note: d.note || '' });
114
+ const cap = (d.question || c && c.title || base.title) + (d.better === 'lower' ? ' (lower is better)' : '');
115
+ shown = c ? kpisHtml(c, d) + figHtml(c, form, cap) + (d.note ? `<p class="vz-note">${esc(d.note)}</p>` : '') : '<p class="vz-msg">The range holds fewer than two readings, so nothing is drawn.</p>';
116
+ }
117
+ const meter = form === 'meter' && (d.target === null || d.target === undefined) ? '<p class="vz-note">A meter needs a target. Say one in the chat, or pick another form.</p>' : '';
118
+ return shown
119
+ + `<section class="vz-blk" aria-label="${esc(eye)}"><div class="vz-r1"><h3>${esc(eye)}</h3></div>`
120
+ + `<p class="vz-note">${esc(base ? base.title : d.measure)}${d.range ? ' · last ' + d.range + ' readings' : ' · every reading'}${d.target != null ? ' · target ' + esc(d.target) : ''}</p>`
121
+ + `<div class="vz-sg" role="group" aria-label="Form">${FORMS.map(([f, l]) => `<button type="button" data-ct="form|${f}" aria-pressed="${form === f}">${l}</button>`).join('')}</div>${meter}`
122
+ + (changed ? `<div class="vz-r1">${btn('save', t.busy ? 'Saving' : s ? 'Save the change' : 'Save chart', { off: t.busy || !base || !!meter })}</div>` : '')
123
+ + `<p class="vz-note">${s ? 'It shows on Insights under Your charts.' : 'Saved, it shows on Insights under Your charts and can go on a dashboard.'} Ask in the chat to change it.</p>`
124
+ + (s ? `<div class="vz-r1">${btn('remove', 'Delete chart', { sec: true, off: t.busy })}</div>` : '') + '</section>';
125
+ }
126
+ /** A dashboard's chart as a small tile: its name, the reading now and its readings as small bars. */
127
+ function tileHtml(c) {
128
+ const pts = c.pts, n = pts.length, hi = Math.max(...pts.map((p) => Math.max(0, p.v))) || 1, slot = 200 / n, bw = Math.min(16, slot * 0.6);
129
+ return `<div class="vz-mx-tile"><p>${esc(c.title)}</p><b>${esc(c.v)}</b><small>on ${esc(c.at)}${c.targetTxt ? ' · ' + esc(c.targetTxt) : ''}</small>`
130
+ + `<svg class="vz-mx-svg" viewBox="0 0 200 44" role="img" aria-label="${esc(c.title + ': ' + n + ' readings, now ' + c.v)}">${pts.map((p, i) => { const h = Math.max(1, Math.max(0, p.v) / hi * 40); return `<rect class="vz-bar${i === n - 1 ? ' now' : ''}" x="${(slot * i + (slot - bw) / 2).toFixed(1)}" y="${(44 - h).toFixed(1)}" width="${bw.toFixed(1)}" height="${h.toFixed(1)}" rx="3"/>`; }).join('')}</svg></div>`;
89
131
  }
90
132
  function dashHtml(t) {
91
133
  const d = t.d, s = t.saved, M = t.M;
92
134
  const changed = !s || d.name !== s.name || d.purpose !== s.purpose || d.charts.join() !== s.charts.join();
93
135
  const eye = !s ? 'New dashboard · from this chat' : changed ? 'Dashboard change · from this chat' : 'Saved dashboard';
94
136
  const tiles = d.charts.map((ref) => {
95
- const c = chartOf(M, ref);
96
- if (c) return `<div class="ntw">${tileHtml(c)}</div>`;
137
+ const c = (M.mine || []).find((x) => x.id === ref) || (M.charts || []).find((x) => x.id === ref);
138
+ if (c) return tileHtml(c);
97
139
  const m = (M.measures || []).find((x) => x.id === ref);
98
- return `<div class="nempty"><p><b>${esc(m ? m.title : ref)}</b><br>${esc(m ? 'It has fewer than two readings, so it has no chart yet.' : 'No KR metric record or saved chart is called ' + ref + '.')}</p></div>`;
140
+ return `<div class="vz-mx-none"><p><b>${esc(m ? m.title : ref)}</b></p><small>${esc(m ? 'It has fewer than two readings, so it has no chart yet.' : 'No KR metric record or saved chart is called ' + ref + '.')}</small></div>`;
99
141
  }).join('');
100
- const many = d.charts.length > 6 ? '<p class="rt-note">This dashboard holds more than six charts. A dashboard that serves one routine usually holds six or fewer.</p>' : '';
101
- return `<p class="rt-eye">${esc(eye)}</p><h3 class="rt-h">${esc(d.name)}</h3>${d.purpose ? `<p class="rt-sub">${esc(d.purpose)}</p>` : ''}`
102
- + `<p class="rt-meta">${d.charts.length} ${d.charts.length === 1 ? 'chart' : 'charts'}${s && s.main ? ' · pinned on Insights' : ''}</p>`
103
- + `<div class="ngrid ct-grid">${tiles}</div>${many}`
104
- + `<div class="rt-foot">${changed ? btn('save', t.busy ? 'Saving' : s ? 'Save the change' : 'Save dashboard', { off: t.busy }) : ''}</div>`
105
- + `<p class="rt-note">${s ? 'It is in the list on Insights.' : 'Saved, it is in the list on Insights, where you can pin it.'} Ask in the chat to change it.</p>`
106
- + (s ? `<div class="rt-foot rt-end">${btn('remove', 'Delete dashboard', { sec: true, cls: 'rt-del', off: t.busy })}</div>` : '');
142
+ const many = d.charts.length > 6 ? '<p class="vz-note">This dashboard holds more than six charts. A dashboard that serves one routine usually holds six or fewer.</p>' : '';
143
+ return `${d.purpose ? `<p class="vz-sum">${esc(d.purpose)}</p>` : ''}<div class="vz-mx-grid">${tiles}</div>${many}`
144
+ + `<section class="vz-blk" aria-label="${esc(eye)}"><div class="vz-r1"><h3>${esc(eye)}</h3></div>`
145
+ + `<p class="vz-note">${d.charts.length} ${d.charts.length === 1 ? 'chart' : 'charts'}${s && s.main ? ' · pinned on Insights' : ''}</p>`
146
+ + (changed ? `<div class="vz-r1">${btn('save', t.busy ? 'Saving' : s ? 'Save the change' : 'Save dashboard', { off: t.busy })}</div>` : '')
147
+ + `<p class="vz-note">${s ? 'It is in the list on Insights.' : 'Saved, it is in the list on Insights, where you can pin it.'} Ask in the chat to change it.</p>`
148
+ + (s ? `<div class="vz-r1">${btn('remove', 'Delete dashboard', { sec: true, off: t.busy })}</div>` : '') + '</section>';
107
149
  }
108
150
  function bodyHtml(t) {
109
151
  const noun = t.block.kind;
110
- if (!t.loaded) return `<p class="rt-note" role="status">Reading the ${noun}.</p>`;
111
- if (!t.M) return `<p class="rt-note">The Insights records could not be read, so the ${noun} cannot be drawn. Try again in a moment.</p>`;
112
- if (t.removed) return `<p class="rt-eye">${noun === 'chart' ? 'Chart' : 'Dashboard'}</p><p class="rt-note">Deleted. Ask in the chat for a new one.</p>`;
113
- if (t.gone) return `<p class="rt-eye">${noun === 'chart' ? 'Chart' : 'Dashboard'}</p><h3 class="rt-h">${esc(t.block.id)}</h3><p class="rt-note">This ${noun} is deleted, or it is not saved on this board.</p>`;
114
- if (!t.M.board.id) return '<p class="rt-note">This workspace has no board to save on, so nothing can be saved here.</p>';
152
+ if (!t.loaded) return `<p class="vz-empty" role="status">Reading the ${noun}.</p>`;
153
+ if (!t.M) return `<p class="vz-msg">The Insights records could not be read, so the ${noun} cannot be drawn. Try again in a moment.</p>`;
154
+ if (t.removed) return '<p class="vz-msg">Deleted. Ask in the chat for a new one.</p>';
155
+ if (t.gone) return `<p class="vz-msg">This ${noun} (${esc(t.block.id)}) is deleted, or it is not saved on this board.</p>`;
156
+ if (!t.M.board.id) return '<p class="vz-msg">This workspace has no board to save on, so nothing can be saved here.</p>';
115
157
  return noun === 'chart' ? chartHtml(t) : dashHtml(t);
116
158
  }
159
+ function askHtml(t) {
160
+ const A = t.ask; if (!A) return '';
161
+ return `<div class="vz-ask2" role="group" aria-label="${esc(A.yes)}"><span>${esc(A.text)}</span><div><button type="button" class="vz-issue vz-hv vz-h36" data-ct="askyes" data-k="bad">${esc(A.yes)}</button><button type="button" class="vz-sec2 vz-hv vz-h36" data-ct="askno">${esc(A.no)}</button></div></div>`;
162
+ }
117
163
  function draw(t, el) {
118
- const ask = el.querySelector(':scope > .vcf'); // an open confirm card outlives a redraw, so its answer still lands
119
- el.innerHTML = `<div class="rt">${bodyHtml(t)}${t.msg ? `<p class="rt-msg" role="status">${esc(t.msg)}</p>` : ''}</div>`;
120
- if (ask) el.prepend(ask);
164
+ el.innerHTML = `<div class="vz vz-mx" data-vw="${esc(t.id)}">${askHtml(t)}${bodyHtml(t)}${t.msg ? `<p class="vz-msg" role="status">${esc(t.msg)}</p>` : ''}</div>`;
121
165
  }
122
166
 
123
167
  async function act(t, fn) { t.busy = true; t.msg = ''; redraw(t); const m = await fn(); t.busy = false; if (m != null) t.msg = m; redraw(t); }
@@ -127,6 +171,8 @@ async function press(t, e) {
127
171
  const [a, v] = [b.dataset.ct.split('|')[0], b.dataset.ct.slice(b.dataset.ct.indexOf('|') + 1)];
128
172
  const board = t.M && t.M.board.id, kind = t.block.kind;
129
173
  if (a === 'form') { t.d = Object.assign({}, t.d, { form: v }); t.msg = ''; redraw(t); return; }
174
+ if (a === 'askno') { t.ask = null; redraw(t); return; }
175
+ if (a === 'askyes') { const A = t.ask; t.ask = null; if (A) await A.run(); return; }
130
176
  if (a === 'save') {
131
177
  await act(t, async () => {
132
178
  if (kind === 'chart') {
@@ -147,11 +193,12 @@ async function press(t, e) {
147
193
  }
148
194
  if (a === 'remove') {
149
195
  const noun = kind === 'chart' ? 'chart' : 'dashboard';
150
- if (!(await vwConfirm(paneOf(t), { text: kind === 'chart' ? 'Delete this chart? A dashboard that holds it shows it as removed.' : 'Delete this dashboard? Its charts and records stay.', yes: 'Delete ' + noun, no: 'Keep it' }))) return;
151
- await act(t, async () => {
152
- const r = await post(kind === 'chart' ? '/api/premium-charts/save' : '/api/premium-dashboards/save', { board, id: t.saved.id, remove: true });
153
- if (!r || !r.ok) return 'It was not deleted: ' + why(r, 'the page could not reach PMOS') + '.';
154
- t.removed = true; return null;
155
- });
196
+ t.ask = { text: kind === 'chart' ? 'Delete this chart? A dashboard that holds it shows it as removed.' : 'Delete this dashboard? Its charts and records stay.', yes: 'Delete ' + noun, no: 'Keep it',
197
+ run: () => act(t, async () => {
198
+ const r = await post(kind === 'chart' ? '/api/premium-charts/save' : '/api/premium-dashboards/save', { board, id: t.saved.id, remove: true });
199
+ if (!r || !r.ok) return 'It was not deleted: ' + why(r, 'the page could not reach PMOS') + '.';
200
+ t.removed = true; return null;
201
+ }) };
202
+ redraw(t);
156
203
  }
157
204
  }
@@ -15,7 +15,7 @@
15
15
  export const W = 960, H = 540;
16
16
  export const LAYOUTS = [['title', 'Title'], ['content', 'Title and text'], ['two', 'Two columns'], ['chart', 'Chart and text'], ['big', 'Big number'], ['image', 'Image and text'], ['quote', 'Quote'], ['section', 'Section break']];
17
17
  export const ROLES = [['title', 'Title'], ['heading', 'Heading'], ['body', 'Body'], ['small', 'Small'], ['kicker', 'Kicker'], ['big', 'Big number'], ['quote', 'Quote']];
18
- export const THEMES = [['ember', 'Ember'], ['paper', 'Paper'], ['sky', 'Sky']];
18
+ export const THEMES = [['report', 'Report blue'], ['ember', 'Ember'], ['paper', 'Paper'], ['sky', 'Sky']]; // report: the report panel's slide (ReportPanel.dc.html), the default
19
19
  export const COLORS = [['', 'Theme text'], ['acc', 'Accent'], ['mut', 'Muted']];
20
20
  export const FILLS = [['acc', 'Accent'], ['fg', 'Text colour'], ['soft', 'Soft']];
21
21
  const has = (list, k) => list.some((x) => x[0] === k);
@@ -108,7 +108,7 @@ export function mkLayout(l, c = {}) {
108
108
  const T = (k, role, x, y, w, h, html, align) => ({ t: 'text', k, role, x, y, w, h, html, align: align || 'left' });
109
109
  const ti = c.title != null ? c.title : '', bo = c.body != null ? c.body : '';
110
110
  switch (l) {
111
- case 'title': return [T('kicker', 'kicker', 72, 232, 816, 28, c.kicker || ''), T('title', 'title', 72, 272, 816, 140, ti), T('body', 'body', 72, 424, 816, 70, bo)];
111
+ case 'title': return [T('kicker', 'kicker', 48, 44, 816, 36, c.kicker || ''), T('title', 'title', 48, 96, 640, 150, ti), T('body', 'body', 48, 420, 816, 80, bo)]; // the report's title slide: tag, title, then the lines at the foot
112
112
  case 'two': return [T('title', 'heading', 72, 60, 816, 56, ti), T('body', 'body', 72, 150, 390, 330, bo), T('body2', 'body', 498, 150, 390, 330, c.body2 || '')];
113
113
  case 'chart': return [T('title', 'heading', 72, 60, 816, 56, ti), c.chart ? { ...c.chart, k: 'chart', x: 72, y: 150, w: 520, h: 320 } : { t: 'chart', k: 'chart', x: 72, y: 150, w: 520, h: 320, kind: 'bar', data: [['', 0]] }, T('body', 'body', 624, 160, 264, 310, bo)];
114
114
  case 'big': return [T('big', 'big', 72, 96, 816, 170, c.big || ''), T('body', 'body', 72, 300, 700, 140, bo), ...(ti ? [T('title', 'small', 72, 470, 700, 40, ti)] : [])];
@@ -158,7 +158,7 @@ function fromSection(head, body, l) {
158
158
  /** The file as a deck. A file with no blocks (a report) is read as its title slide and one slide per section, as the report reader does. */
159
159
  export function parseDeck(md, fallbackTitle) {
160
160
  const { front, rest } = splitFront(String(md || '').replace(/\r\n/g, '\n'));
161
- const theme = has(THEMES, frontVal(front, 'deck_theme')) ? frontVal(front, 'deck_theme') : 'ember';
161
+ const theme = has(THEMES, frontVal(front, 'deck_theme')) ? frontVal(front, 'deck_theme') : 'report';
162
162
  const secs = []; let cur = null, pre = [];
163
163
  for (const line of rest.split('\n')) {
164
164
  const h1 = /^# (?!#)(.*)/.exec(line), h2 = /^## (?!#)(.*)/.exec(line);
@@ -1,36 +1,38 @@
1
- /* pm/premium-first.js — the "Your first Briefing" card on the premium Briefing (initiative premium-welcome). It shows only when the page was opened with
2
- * first=<import id>, which the premium Welcome sets after an import. It reads GET /api/onboarding/briefing, lists each item, the state of the tools the PM
3
- * ticked (what Welcome recorded in this browser) and Undo this import (POST /api/onboarding/undo), which goes back to Welcome's found step.
4
- * The card keeps the page's own rows untouched: it is inserted above the columns. Text from the scanned folder is untrusted and goes through esc(). */
1
+ /* pm/premium-first.js — the "Your first Briefing" card on Home (initiative premium-welcome; rebuilt for the Agreed design, initiative
2
+ * premium-agreed-design, Home; restyled for premium-uncovered-features to the Today card of canvas HmDay). It shows only when Home was opened with first=<import id>, which the premium Welcome sets after an import.
3
+ * It reads GET /api/onboarding/briefing, lists each item, the state of the tools the PM ticked (what Welcome recorded in this browser) and
4
+ * Undo this import (POST /api/onboarding/undo), which goes back to Welcome's found step.
5
+ * mountFirst() → the card element (a <section id="wlFirst">), or null when the address has no first=. Home puts it at the top of its list.
6
+ * Text from the scanned folder is untrusted and goes through esc(). */
5
7
  import { pmGet, pmPost } from './http.js';
6
8
  import { firstView, FIRST_KEY } from './premium-welcome-model.js';
7
9
 
8
10
  const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
9
- const SUN = '<svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>';
10
11
 
11
12
  function toolState() {
12
13
  try { return JSON.parse(sessionStorage.getItem(FIRST_KEY) || '{}'); } catch { return {}; }
13
14
  }
14
- export async function mountFirst() {
15
+ export function mountFirst() {
15
16
  const q = new URLSearchParams(location.search), id = q.get('first'), ws = q.get('ws') || '';
16
- const cols = document.querySelector('.cols2');
17
- if (!id || !cols || document.getElementById('wlFirst')) return;
18
- const r = await pmGet(`/api/onboarding/briefing?ws=${encodeURIComponent(ws)}`);
19
- const v = firstView(r, toolState());
17
+ if (!id) return null;
20
18
  const sec = document.createElement('section');
21
- sec.className = 'card wl-first'; sec.id = 'wlFirst'; sec.setAttribute('aria-labelledby', 'hWl');
22
- const items = v.items.map((f, i) => `<li class="wl-row"><span class="wl-ic wl-n">${String(i + 1).padStart(2, '0')}</span><span><b>${esc(f.title)}</b>${f.why ? `<small>${esc(f.why)}</small>` : ''}<span class="path">${f.ini ? esc(f.ini) + ' · ' : ''}${esc(f.ref)}</span></span><span></span></li>`).join('');
23
- const tools = v.tools.map((t) => `<li class="wl-row"><span class="wl-ic">${SUN}</span><span><b>${esc(t.name)}</b><small${t.started ? '' : ' class="wl-bad"'}>${t.started ? `${esc(t.name)} is being read in an agent session. Its items join your Briefing when it finishes.` : esc(t.error || 'It did not start.')}</small></span><span></span></li>`).join('');
24
- sec.innerHTML = `<div class="ch"><span class="ic">${SUN}</span><h2 id="hWl">Your first Briefing</h2><small>From the scan</small></div>
25
- <p class="note wl-first-note">${r && r.ok ? (v.calm ? 'Your portfolio is in. Nothing needs you right now.' : 'Your portfolio is in. These need you first.') : esc((r && r.error) || 'The scan\'s Briefing could not be read.')}</p>
26
- ${items ? `<ol class="wl-list">${items}</ol>` : ''}${tools ? `<p class="wl-sec">Your tools</p><ul class="wl-list">${tools}</ul>` : ''}
27
- <div class="wl-actions"><button class="wl-btn alt" type="button" id="wlUndo">Undo this import</button></div><p class="note wl-first-err" id="wlUndoErr" role="alert" hidden></p>`;
28
- cols.parentNode.insertBefore(sec, cols);
29
- document.addEventListener('click', async (e) => {
19
+ sec.className = 'hm-first hx hm-tc'; sec.id = 'wlFirst'; sec.setAttribute('aria-labelledby', 'hWl');
20
+ sec.innerHTML = '<h2 id="hWl" class="ut-h2">Your first Briefing</h2><p class="ut-small ut-mut">Reading what the scan found.</p>';
21
+ pmGet(`/api/onboarding/briefing?ws=${encodeURIComponent(ws)}`).then((r) => {
22
+ const v = firstView(r, toolState());
23
+ const items = v.items.map((f) => `<li class="hx-row"><span class="hx-t"><b>${esc(f.title)}</b>${f.why ? `<em>${esc(f.why)}</em>` : ''}<small>${f.ini ? esc(f.ini) + ' · ' : ''}${esc(f.ref)}</small></span></li>`).join('');
24
+ const tools = v.tools.map((t) => `<li class="hx-row"><span class="hx-t"><b>${esc(t.name)}</b><em${t.started ? '' : ' class="bad"'}>${t.started ? `${esc(t.name)} is being read in an agent session. Its items join your list when it finishes.` : esc(t.error || 'It did not start.')}</em></span></li>`).join('');
25
+ const lede = r && r.ok ? (v.calm ? 'Your portfolio is in. Nothing needs you right now.' : 'Your portfolio is in. These need you first.') : esc((r && r.error) || 'The scan\'s Briefing could not be read.');
26
+ sec.innerHTML = `<h2 id="hWl" class="ut-h2">Your first Briefing</h2><p class="ut-small ut-mut">${lede}</p>`
27
+ + (items ? `<ol class="hm-first-l">${items}</ol>` : '') + (tools ? `<h4>Your tools</h4><ul class="hm-first-l">${tools}</ul>` : '')
28
+ + '<div class="ut-acts"><button class="ut-btn sm ghost" type="button" id="wlUndo">Undo this import</button></div><p class="hx-n" id="wlUndoErr" role="alert" hidden></p>';
29
+ });
30
+ sec.onclick = async (e) => {
30
31
  const b = e.target.closest('#wlUndo'); if (!b || b.disabled) return;
31
32
  b.disabled = true;
32
33
  const u = await pmPost('/api/onboarding/undo', { ws, import_id: id });
33
- if (!u || !u.ok) { b.disabled = false; const e = document.getElementById('wlUndoErr'); e.textContent = (u && u.error) || 'Undo did not work.'; e.hidden = false; return; }
34
+ if (!u || !u.ok) { b.disabled = false; const m = sec.querySelector('#wlUndoErr'); m.textContent = (u && u.error) || 'Undo did not work.'; m.hidden = false; return; }
34
35
  location.assign('/premium-welcome.html?ws=' + encodeURIComponent(ws) + '&step=found');
35
- });
36
+ };
37
+ return sec;
36
38
  }