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,12 +1,10 @@
1
- /* pm/premium-meeting.js — Calendar in the premium Briefing's Today card (initiative briefing-premium-calendar, slices 1 and 2).
2
- * The Today / This week switch, the week list and the meeting dialog. Reads GET /api/calendar-views?view=week, GET /api/meeting-replay, GET /api/meeting-material and
3
- * GET /api/meeting-material/suggest. The writes are "Link it" (POST /api/calendar-links), Add and Remove material (POST /api/meeting-material) and Make task
4
- * (POST /api/plan-items). Every word is a field of a record: the pure half (weekView, meetingView, the body builders) takes the routes' answers and returns what the page
5
- * draws or sends, so a test reads it without a DOM. Recording and Focus are slice 3.
6
- * The dialog's detail is one scroll (PM, 2026-10-20: no Before, During and After switch): a short head with the meeting's state, its people folded to a count,
7
- * what it is about, its series line, Record and one More menu (Focus, Change what it is about, What Record and Focus do). Then the part that fits the meeting's
8
- * state, open, and the other parts folded. The parts that come from the meeting's note (GET /api/notes/one) are drawn by premium-vw-meet.js. */
9
- import { noteSheet, phaseOf, partsHtml, partToggle, partKeep, seriesHtml, stageHtml, wireStage, PHASES, notesTablesHtml, openNoteTab, vmStyle } from './premium-vw-meet.js';
1
+ /* pm/premium-meeting.js — meetings: the pure half the Viewer's meeting card reads (initiative briefing-premium-calendar; rebuilt for the Agreed
2
+ * design, initiative premium-agreed-design, area viewer), and the page's recorder.
3
+ * The pure half (weekView, meetingView, prevOf, statusChips, linkBody, the material bodies, taskEvent, recState, focusView, replayModel) takes the
4
+ * routes' answers and returns what is drawn or sent, so a test reads it without a DOM.
5
+ * The page half is recCore(d): the one recorder of the page (view-notes.js's microphone and meeting-sound capture), shared by every view through
6
+ * window.__premiumRec, and mountMeeting(d): the controller Home mounts. It draws nothing: every meeting opens in the Viewer card
7
+ * (premium-vw-mtg.js openMeeting). */
10
8
 
11
9
  const pad = (n) => String(n).padStart(2, '0');
12
10
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
@@ -226,7 +224,8 @@ const normT = (t) => String(t == null ? '' : t).toLowerCase().replace(/\s+/g, '
226
224
  const minuteOf = (s) => { const t = Date.parse(s); return Number.isFinite(t) ? Math.floor(t / 60000) : null; };
227
225
  const dayOf = (ms) => { const t = new Date(ms); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
228
226
  export const RECORD_GRACE_MS = 10 * 60000;
229
- export const mmss = (ms) => { const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)); return Math.floor(s / 60) + ':' + pad(s % 60); };
227
+ /** A time in a recording as mm:ss, zero-padded (Main.dc.html: "03:10", "12:40 of 31:05"). */
228
+ export const mmss = (ms) => { const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)); return pad(Math.floor(s / 60)) + ':' + pad(s % 60); };
230
229
 
231
230
  /** Can this meeting still be recorded now? A meeting of today that has not ended more than 10 minutes ago, as the console's Record menu lists it. */
232
231
  export function recordable(row, now = Date.now()) {
@@ -340,58 +339,15 @@ export function replayAt(m, pos) {
340
339
 
341
340
  /* ── the page half ─────────────────────────────────────────────────────────────────────────────────────── */
342
341
 
343
- /** deps: { $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, wsq(), ws() }. Returns { mode, draw, openToday }. The card's day strip and chevron are drawn here (initiative premium-calendar-card). */
344
- export function mountMeeting(d) {
345
- const { $, $$, esc } = d;
346
- let picked = null, W = null, listItems = null, seq = 0, busy = false;
347
- const today = () => { const t = new Date(); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
348
- const other = () => !!picked && picked !== today();
349
- const wsq = (first) => { const w = d.ws(); return w ? (first ? '?' : '&') + 'ws=' + encodeURIComponent(w) : ''; };
350
- const ICON = '<rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/>';
351
- const fold = mountFold($('#todayCard'), 'brief');
352
-
353
- async function readWeek() {
354
- const n = ++seq; busy = true;
355
- const res = await d.pmGet('/api/calendar-views?view=week&date=' + today() + wsq());
356
- if (n !== seq) return;
357
- busy = false; W = weekView(res, today());
358
- }
359
- async function readItems() { const r = await d.pmGet('/api/pm-items' + wsq(true)); listItems = r && r.ok === true && Array.isArray(r.items) ? r.items : []; }
360
- const rowHtml = (r, k) => `<button class="ev src-meeting${r.past ? ' wkpast' : ''}" data-w="${esc(k)}" aria-haspopup="dialog"><time>${esc(r.time)}</time><span class="gl-t"><svg class="i" viewBox="0 0 24 24">${ICON}</svg></span><span><b>${esc(r.title)}</b><span class="d">${esc([r.sub, r.about].filter(Boolean).join(' · ') || 'No other people listed')}</span></span></button>`;
361
- /** The day strip and the hidden line. Drawn once the week and the list are read. */
362
- function drawStrip() {
363
- if (!W || !listItems) return;
364
- const S = stripOf(W, listItems, today());
365
- $('#wkStrip').innerHTML = stripHtml(S, picked || today(), esc);
366
- fold.line(S, foldLine(S, W), esc);
367
- }
368
- /** Today picked: false, and the page draws its Today timeline. Another day picked: that day's meetings and due items, and true. */
369
- function draw() {
370
- const card = $('#todayCard');
371
- drawStrip();
372
- card.classList.toggle('wkm', other());
373
- if (!other()) { $('#tl').setAttribute('aria-label', 'Today. Use the up and down arrow keys to move between rows.'); return false; }
374
- const x = W && W.state === 'ok' ? W.days.find((y) => y.key === picked) : null;
375
- $('#tl').setAttribute('aria-label', (x ? x.label : 'That day') + '. Use the up and down arrow keys to move between rows.');
376
- if (!W) { $('#todayCap').textContent = 'Reading the calendar'; $('#tl').innerHTML = '<div class="empty">Reading the calendar PMOS holds.</div>'; return true; }
377
- if (W.state === 'error') { $('#todayCap').textContent = W.caption; $('#tl').innerHTML = `<div class="empty" role="status">Calendar not read. ${esc(W.reason)}</div>`; return true; }
378
- const due = (listItems || []).filter((it) => it && !it.done && it.due === picked);
379
- $('#todayCap').textContent = x ? (x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : 'No meetings') + (due.length ? ' · ' + due.length + ' due' : '') : '';
380
- $('#tl').innerHTML = x ? `<div class="wkd">${esc(x.label)}<em>${x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : ''}</em></div>`
381
- + due.map((it) => `<div class="wkdue"><span>Due</span><b>${esc(clip(it.title, 140))}</b></div>`).join('')
382
- + (x.rows.length ? x.rows.map((r, i) => rowHtml(r, x.key + '|' + i)).join('') : '<div class="empty">No meetings.</div>') : '<div class="empty">That day is not in this week.</div>';
383
- $$('#tl .ev').forEach((e, i) => { e.tabIndex = i ? -1 : 0; });
384
- mark();
385
- return true;
386
- }
387
- const rowOf = (k) => { const [day, i] = k.split('|'); const x = W && W.days.find((y) => y.key === day); return x ? x.rows[+i] : null; };
388
-
389
- /* ── recording: the notes the server holds, the recorder this page holds, and the presses on both ───────────────────────── */
390
- let NR = [], HOLD = null, R = null, evOf = null, cur = null;
342
+ /** The page's one recorder: the notes the server holds, the recorder this page holds, and the presses on both. Made once per page; every
343
+ * later call returns the same one. d: { pmGet, pmPost, ws() }. It also sets window.__premiumRec (the shell's Record control and the chat read it). */
344
+ export function recCore(d) {
345
+ if (typeof window !== 'undefined' && window.__pmRecCore) return window.__pmRecCore;
346
+ let NR = [], HOLD = null, R = null;
391
347
  const bump = () => { try { window.dispatchEvent(new CustomEvent('premium-rec')); } catch { /* no window */ } };
392
348
  async function readNotes() {
393
349
  const r = await d.pmGet('/api/notes');
394
- if (r && r.ok === true && Array.isArray(r.notes)) { const was = JSON.stringify(NR); NR = r.notes; if (was !== JSON.stringify(NR)) bump(); mark(); }
350
+ if (r && r.ok === true && Array.isArray(r.notes)) { const was = JSON.stringify(NR); NR = r.notes; if (was !== JSON.stringify(NR)) bump(); }
395
351
  return NR;
396
352
  }
397
353
  /** The recorder is the console's own (view-notes.js): microphone, the meeting's sound, POST /api/notes/record and /audio. Loaded the first time it is pressed. */
@@ -399,7 +355,7 @@ export function mountMeeting(d) {
399
355
  if (typeof window !== 'undefined' && window.__premiumRecorder) return window.__premiumRecorder;
400
356
  if (R) return R;
401
357
  const [V, ST] = await Promise.all([import('./view-notes.js'), import('./state.js')]);
402
- const ctx = { state: { wsId: d.ws() }, setState: bump, FIXTURE: ST.FIXTURE };
358
+ const ctx = { state: { wsId: d.ws ? d.ws() : null }, setState: bump, FIXTURE: ST.FIXTURE };
403
359
  R = {
404
360
  listen: (id) => V.listenNow(ctx, id), pause: () => V.pauseListening(ctx), listening: () => V.listeningId(), started: () => V.liveStarted(), banner: () => V.takeBanner(),
405
361
  highlight: (id) => V.highlightNow(ctx, id), highlighting: () => V.highlightBusy(),
@@ -413,22 +369,23 @@ export function mountMeeting(d) {
413
369
  return R;
414
370
  }
415
371
  const setHold = (id) => { HOLD = id ? { id } : null; window.__premiumHolding = HOLD; bump(); };
416
- const ctl = {
372
+ const started = () => { const r = window.__premiumRecorder || R; return r ? r.started() : null; };
373
+ const C = {
417
374
  async record(row) {
418
375
  const blocking = liveRows(NR).find((n) => n.state === 'recording' && !sameMeeting(n.meeting, row));
419
376
  if (blocking || HOLD) return { ok: false, error: (blocking ? clip(blocking.title, 60) : 'A meeting') + ' is recording. Pause or stop it first.' };
420
377
  const made = await d.pmPost('/api/notes/new', noteBody(row));
421
378
  if (!made || made.ok !== true) return { ok: false, error: (made && made.error) || 'The note was not made.' };
422
- return ctl.resume(made.note.id);
379
+ return C.resume(made.note.id);
423
380
  },
424
- /** New in the Record control: an untitled note with no meeting, listened to at once (the console's recordNew). */
381
+ /** New meeting: an untitled note with no calendar event, listened to at once (the console's recordNew). */
425
382
  async fresh() {
426
383
  if (HOLD || liveRows(NR).some((n) => n.state === 'recording')) return { ok: false, error: 'A meeting is recording. Pause or stop it first.' };
427
384
  const made = await d.pmPost('/api/notes/new', { title: '' });
428
385
  if (!made || made.ok !== true) return { ok: false, error: (made && made.error) || 'The note was not made.' };
429
- const res = await ctl.resume(made.note.id); return res.ok ? { ok: true, id: made.note.id } : res;
386
+ const res = await C.resume(made.note.id); return res.ok ? { ok: true, id: made.note.id } : { ...res, id: made.note.id };
430
387
  },
431
- /** Highlight: the last 30 seconds and the next ones, made into a highlight from the transcript when the window closes (the console's highlightNow). */
388
+ /** Highlight: the last 30 seconds and the next ones, made into a highlight from the transcript when the window closes. */
432
389
  async highlight() {
433
390
  if (!HOLD) return { ok: false, error: 'This page is not recording.' };
434
391
  const rec = await recorder(); const ok = rec.highlight ? rec.highlight(HOLD.id) : false;
@@ -441,7 +398,7 @@ export function mountMeeting(d) {
441
398
  setHold(id); return { ok: true };
442
399
  },
443
400
  async pause() {
444
- if (!HOLD) return { ok: false, error: 'This page is not recording.' };
401
+ if (!HOLD) { const live = liveRows(NR).find((n) => n.state === 'recording'); if (!live) return { ok: false, error: 'This page is not recording.' }; const r = await d.pmPost('/api/notes/pause', { id: live.id }); await readNotes(); return r && r.ok ? { ok: true } : { ok: false, error: (r && r.error) || 'Not paused.' }; }
445
402
  const rec = await recorder(); await rec.pause(); setHold(null); await readNotes(); return { ok: true };
446
403
  },
447
404
  async stop(id) {
@@ -449,501 +406,56 @@ export function mountMeeting(d) {
449
406
  const res = await d.pmPost('/api/notes/stop', { id }); await readNotes(); bump();
450
407
  return res && res.ok === true ? { ok: true } : { ok: false, error: (res && res.error) || 'The meeting was not stopped.' };
451
408
  },
409
+ refresh: readNotes, notes: () => NR, note: (id) => NR.find((n) => n.id === id) || null, started, holding: () => HOLD,
410
+ highlighting: () => { const r = window.__premiumRecorder || R; return r && r.highlighting ? r.highlighting() : null; },
452
411
  };
453
- /** Today's meetings the Record menu lists: of today, not ended more than 10 minutes ago (recordable), from the week the card read. */
454
- async function todayRows() {
455
- if (!W || W.state !== 'ok') await readWeek();
456
- return W && W.state === 'ok' ? W.days.flatMap((x) => x.rows).filter((r) => recordable(r)) : [];
457
- }
458
- window.__premiumRec = { pause: ctl.pause, resume: ctl.resume, stop: ctl.stop, record: ctl.record, fresh: ctl.fresh, highlight: ctl.highlight, today: todayRows,
459
- highlighting: () => { const r = window.__premiumRecorder || R; return r && r.highlighting ? r.highlighting() : null; }, started: () => { const r = window.__premiumRecorder || R; return r ? r.started() : null; }, notes: () => NR,
460
- note: (id) => NR.find((n) => n.id === id) || null, refresh: readNotes, open: (id) => openNote(id) };
461
- /* Leaving the Briefing while it holds the recorder: the browser asks first, and if the PM leaves, the meeting is paused (it stays open for an hour) so the record never says "recording" for audio nobody is capturing. */
412
+ window.__pmRecCore = C;
413
+ window.__premiumRec = { pause: C.pause, resume: C.resume, stop: C.stop, record: C.record, fresh: C.fresh, highlight: C.highlight, today: async () => [],
414
+ highlighting: C.highlighting, started, notes: () => NR, note: C.note, refresh: readNotes, open: (id) => import('./premium-vw-mtg.js').then((M) => M.openMeeting({ note: id })) };
415
+ /* Leaving the page while it holds the recorder: the browser asks first, and if the PM leaves, the meeting is paused (it stays open for an hour). */
462
416
  addEventListener('beforeunload', (e) => { if (HOLD) { e.preventDefault(); e.returnValue = ''; } });
463
- // a page kept for Back (persisted) is not left: a phone that locks or switches apps can hide the page this way, and comes back to it
464
417
  addEventListener('pagehide', (e) => { if (HOLD && !(e && e.persisted)) d.pmPost('/api/notes/pause', { id: HOLD.id }, { keepalive: true }); });
465
418
  setInterval(() => { readNotes(); }, 20000);
466
- addEventListener('premium-rec', () => { if (cur && cur.alive()) cur.repaint(); mark(); });
419
+ readNotes();
420
+ return C;
421
+ }
467
422
 
468
- /** The mark on a meeting row whose note records or is paused. `evOf(i)` gives the Today event of a Today row. */
469
- function mark(f) {
470
- if (f) evOf = f;
471
- $$('#tl .ev.src-meeting').forEach((b) => {
472
- let row = null;
473
- if (b.dataset.w) row = rowOf(b.dataset.w);
474
- else if (evOf && b.dataset.i !== undefined) { const e = evOf(+b.dataset.i); if (e && Number.isFinite(e.at)) row = { id: null, at: new Date(e.at).toISOString(), title: clip(e.title, 120) }; }
475
- const old = b.querySelector('.m3-mark'); if (old) old.remove();
476
- const t = row ? rowMark(NR, row) : '';
477
- if (t) b.querySelector('b').insertAdjacentHTML('afterend', `<em class="m3-mark${t === 'Paused' ? ' m3-paused' : ''}">${t}</em>`);
478
- });
423
+ /** The controller Home mounts. deps: { pmGet, pmPost, toast, ws(), redraw? }. It reads the week and the notes and opens meetings in the Viewer;
424
+ * it draws no card of its own. Returns { mode, draw, openToday, busy, mark, openNote, task, openRow } as before: draw() is false (the page
425
+ * draws its own Today), mark() does nothing. */
426
+ export function mountMeeting(d) {
427
+ let W = null, seq = 0, busy = false;
428
+ const today = () => { const t = new Date(); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
429
+ const wsq = () => { const w = d.ws ? d.ws() : null; return w ? '&ws=' + encodeURIComponent(w) : ''; };
430
+ const C = recCore(d);
431
+ async function readWeek() {
432
+ const n = ++seq; busy = true;
433
+ const res = await d.pmGet('/api/calendar-views?view=week&date=' + today() + wsq());
434
+ if (n !== seq) return;
435
+ busy = false; W = weekView(res, today());
479
436
  }
480
- async function openNote(id) {
481
- await readNotes(); const n = NR.find((x) => x.id === id);
482
- if (!n) return d.toast('That note could not be found.');
437
+ const view = () => import('./premium-vw-mtg.js');
438
+ const ws = () => (d.ws ? d.ws() : '') || '';
439
+ const openRow = async (row) => (await view()).openMeeting(row, { ws: ws() });
440
+ async function openNote(id) { return (await view()).openMeeting({ note: id }, { ws: ws() }); }
441
+ /** A Today row: the week answer says which calendar event it is. false when the calendar does not list it. */
442
+ async function openToday(e) {
483
443
  if (!W || W.state !== 'ok') await readWeek();
484
- const hit = W && W.state === 'ok' ? W.days.flatMap((x) => x.rows).find((r) => sameMeeting(n.meeting, r)) : null;
485
- if (!hit) return d.toast('That meeting is not in this week’s calendar.');
486
- return openRow(hit, 'week');
487
- }
488
-
489
- const consented = new Set();
490
- const keyOf = (row) => (row.id || row.title) + '|' + row.at;
491
- const recMode = (row) => recState(NR, row, HOLD && HOLD.id);
492
- const clockText = () => { const t = window.__premiumRecorder ? window.__premiumRecorder.started() : (R ? R.started() : null); return Number.isFinite(t) ? mmss(Date.now() - t) : ''; };
493
- /** The Record row of the dialog: what the meeting's note is doing now, from the note rows and the recorder, and the presses that fit. */
494
- function recBarHtml(row, ui) {
495
- const st = recMode(row), n = st.note, name = esc(clip((n && n.title) || row.title, 60));
496
- const b = (act, label, cls) => `<button class="mtg-b${cls ? ' ' + cls : ''}" data-m3="${act}">${label}</button>`;
497
- const msg = ui.recMsg ? `<p class="note m3-msg" role="status">${esc(ui.recMsg)}</p>` : '';
498
- if (ui.ask === 'consent') return `<div class="m3-cons" role="alert"><p><b>Tell everyone first.</b> ${esc(CONSENT_LINE.replace('Tell everyone first. ', ''))}</p><p class="note">${esc(RECORD_LINE)}</p><div>${b('go', 'I told them, start', 'cta')}${b('no', 'Not yet')}</div></div>`;
499
- if (ui.ask === 'stop') return `<div class="m3-cons" role="alert"><p><b>Stop “${name}” for good?</b> ${esc(STOP_LINE)}</p><div>${b('stopno', 'Cancel')}${st.mode === 'recording' ? b('stoppause', 'Pause instead') : ''}${b('stopgo', 'Stop for good', 'cta')}</div></div>`;
500
- let h = '';
501
- if (st.mode === 'recording') h = `<div class="m3-row"><span class="m3-dot" aria-hidden="true"></span><b>Recording</b><span class="note" id="m3Clk">${esc(clockText())}</span>${b('pause', 'Pause')}${b('stop', 'Stop')}</div>`;
502
- else if (st.mode === 'stale') h = `<div class="m3-row"><b>Marked recording</b>${b('resume', 'Resume')}${b('stop', 'Stop')}</div><p class="note">The server holds this meeting as recording, but this page is not capturing audio. Resume starts listening again.</p>`;
503
- else if (st.mode === 'paused') h = `<div class="m3-row"><b>Paused</b>${n && n.resume_until ? `<span class="note">Open until ${esc(hhmm(n.resume_until))}</span>` : ''}${b('resume', 'Resume')}${b('stop', 'Stop')}</div><p class="note">${esc(RESUME_LINE)}</p>`;
504
- else if (recordable(row) && st.mode !== 'ended') h = `<button class="addb pri" data-m3="rec" title="${esc(RECORD_LINE)}">${ic('mic')}Record</button>`; // an ended note shows Done in the head and no Record
505
- return h + msg;
506
- }
507
- /* Record up front; Focus, the link and the explanations behind one More menu */
508
- const actsHtml = (row, ui, aboutNow, S) => `<div class="acts2"><div id="m3Rec" class="m3r">${recBarHtml(row, ui)}</div><details class="vm-menu"><summary class="addb" aria-label="More for this meeting" title="More for this meeting">${ic('dots')}More</summary><div class="vm-mn">`
509
- + `<button type="button" data-m3="focus" title="${esc(FOCUS_LINE)}">${ic('scale')}Focus</button><button type="button" data-vm="about" aria-expanded="${!!ui.about}">${ic('link')}${aboutNow ? 'Change what it is about' : 'Choose what it is about'}</button>${S && S.series ? `<button type="button" data-vm="serout">${ic('x')}Not part of this series</button>` : ''}<button type="button" data-m3="why" aria-expanded="false">${ic('info')}What Record and Focus do</button></div></details>`
510
- + `<div class="note why" hidden><p>${esc(RECORD_LINE)}</p><p>${esc(FOCUS_LINE)}</p></div></div>`;
511
-
512
- /* the dialog */
513
- const sec = (label, body) => `<div class="mtg-sec"><span class="label">${esc(label)}</span>${body}</div>`;
514
- const IC = { spark: '<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>', clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>', scale: '<path d="M12 4v16M6 20h12M5 8h14M5 8l-2 6a3 3 0 0 0 4 0zM19 8l-2 6a3 3 0 0 0 4 0z"/>', doc: '<path d="M7 3h7l4 4v14H7zM14 3v4h4"/>', user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c1-4 4-6 8-6s7 2 8 6"/>', link: '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>', mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>',
515
- dec: '<path d="M6 4v8a4 4 0 0 0 4 4h9"/><path d="M15 12l4 4-4 4"/>', task: '<rect x="3" y="4" width="7" height="7" rx="1.5"/><path d="M4.8 7.6l1.4 1.3 2.3-2.6M14 7.5h7M14 17.5h7"/><rect x="3" y="14" width="7" height="7" rx="1.5"/>',
516
- undo: '<path d="M9 14L4 9l5-5"/><path d="M4 9h11a5 5 0 0 1 0 10h-3"/>', play: '<path d="M7 5l12 7-12 7z"/>', pause: '<path d="M9 5v14M15 5v14"/>', lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',
517
- xp: '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 10l3 3 3-3"/>', search: '<circle cx="11" cy="11" r="6.5"/><path d="M16 16l4 4"/>', back: '<path d="M15 6l-6 6 6 6"/>', plus: '<path d="M12 5v14M5 12h14"/>', x: '<path d="M6 6l12 12M18 6 6 18"/>', check: '<path d="M5 12.5l4.5 4.5L19 7.5"/>',
518
- dots: '<circle cx="5" cy="12" r="1.4"/><circle cx="12" cy="12" r="1.4"/><circle cx="19" cy="12" r="1.4"/>', info: '<circle cx="12" cy="12" r="9"/><path d="M12 11v5M12 8v.01"/>' };
519
- const ic = (n) => `<svg class="i" viewBox="0 0 24 24">${IC[n]}</svg>`;
520
- const secH = (t, tag, extra) => `<h4 class="sh">${esc(t)}${tag ? ` <small>${esc(tag)}</small>` : ''}${extra || ''}</h4>`;
521
- const pickLi = (it, key, on) => `<li class="mtg-pick"><span>${esc(clip(it.title, 120))}<em>${esc([it.kind, it.meta].filter(Boolean).join(' · '))}</em></span>${on ? '<span class="mtg-on">Picked</span>' : `<button class="mtg-b" data-pick="${esc(key)}">Pick</button>`}</li>`;
522
-
523
- function detailHtml(v, boards, inis, saved, ui) {
524
- const r = v.row, lv = r.level, note = noteOfRow(NR, r), S = v.sheet;
525
- const aboutNow = lv ? aboutOf(lv) : saved || '';
526
- const opts = [['', aboutNow ? 'Change what it is about' : 'Choose what it is about'], ['portfolio', 'Portfolio']].concat(boards.map((b) => ['board|' + b.ws + '|' + b.id, 'Board: ' + b.name]), inis.map((i) => ['initiative|' + i.id, 'Initiative: ' + i.name]), [['none', 'Remove the link']]);
527
- const link = `<div class="mtg-link"><select id="mtgSel" aria-label="What this meeting is about">${opts.map(([val, t]) => `<option value="${esc(val)}">${esc(t)}</option>`).join('')}</select><button class="addb pri" id="mtgLink" disabled>Link it</button></div>
528
- <p class="note" id="mtgMsg" role="status">The link applies to every occurrence of “${esc(r.title)}”. The calendar itself is never written.</p>`;
529
- const n = v.notes;
530
- const person = (nm) => `<span class="pp"><i class="av2">${esc(String(nm).trim().charAt(0).toUpperCase())}</i>${esc(clip(nm, 40))}</span>`;
531
- const prow = (x) => `<div class="prow"><span class="pi${x.ok ? '' : ' w'}">${ic(x.ic)}</span><div><b>${esc(x.l)}</b><div class="pv">${x.about && aboutNow ? '<span>It is about <b>' + esc(aboutNow) + '</b>.</span>' : x.people ? x.people.slice(0, 2).map(person).join('') + (x.people.length > 2 ? `<span class="mut">and ${x.people.length - 2} more</span>` : '') : x.chips && x.chips.length ? x.chips.map((c) => `<span class="chp sm">${ic('doc')}${esc(c)}</span>`).join('') : '<span>' + esc(x.text) + '</span>'}</div></div>${x.ok ? '<span class="chp ok sm"><i></i>Ready</span>' : '<span class="chp warn sm"><i></i>Not yet</span>'}</div>`;
532
- const ready = v.prepReady;
533
- const prep = secH('Prepared for you', ready === v.prep.length ? 'all ready' : ready + ' of ' + v.prep.length + ' ready') + `<div class="prows">${v.prep.map(prow).join('')}</div>`;
534
- const mats = v.materialLine ? `<p class="mut">${esc(v.materialLine)}</p>` : `<div class="mats">${v.material.map((m) => `<div class="mat"><span class="kd">${esc(m.kind || 'link')}</span><div><b>${esc(m.title)}</b><small>${esc([m.topic, 'for ' + m.scope].filter(Boolean).join(' · '))}</small></div><span class="mb">${m.preview ? `<button class="ib2 mtg-pv" data-mpv="${m.n}" aria-label="Preview ${esc(m.title)}" title="Preview in the viewer">${ic('doc')}</button>` : ''}${m.removable ? `<button class="ib2 mtg-rm" data-rm="${m.n}" aria-label="Remove ${esc(m.title)}" title="${esc(m.line)}">${ic('x')}</button>` : ''}</span></div>`).join('')}</div>`;
535
- const mat = secH('Material', v.material && v.material.length ? v.material.length + ' linked' : '', `<button class="addb" id="mmAdd" title="Your calendar invite is not changed.">${ic('plus')}Add material</button>`) + mats;
536
- const prev = secH('Previous meetings', v.prev.length ? v.prev.length + ' before this' : '') + (v.prev.length ? `<div class="prevs">${v.prev.map((p) => `<div class="pvx"><div class="pvh"><time>${esc(p.date)}</time><span>${p.decided} decided</span><span>${p.steps} new next ${p.steps === 1 ? 'step' : 'steps'}</span></div></div>`).join('')}</div>` : '<p class="mut">No earlier notes of this meeting are kept.</p>');
537
- const tops = secH('Topics', v.planned.length ? 'planned' : '') + (v.planned.length ? `<div class="tops">${v.planned.map((t, i) => `<div class="tp plan"><i>${i + 1}</i><span>${esc(clip(t.text, 120))}</span><small>planned</small></div>`).join('')}</div>` : '<p class="mut">The meeting has no topics yet.</p>');
538
- /* After: from the note's own record when the meeting has one (premium-vw-meet.js), else the decisions, steps and questions the replay answer holds */
539
- const task = { has: (i) => ui.tasked.has(i) };
540
- const sx = { esc, tasked: task, replayBtn: !!v.replay, where: 'meeting', id: S ? S.id : null, brief: v.brief };
541
- const after = S ? stageHtml('after', S, sx)
542
- : secH('Notes', v.notesLine ? '' : 'from the meeting note') + (v.notesLine ? `<p class="mut">${esc(v.notesLine)}</p>` : (n.title ? `<p><b>${esc(n.title)}</b></p>` : '') + notesTablesHtml(n, esc, task) + ((n.decisions.length + n.actions.length + n.questions.length) ? '' : '<p class="mut">The note holds no decisions, next steps or questions yet.</p>'))
543
- + (v.replay ? secH('Replay', 'kept on this machine') + `<p>A recording is kept: ${v.replay.minutes ? v.replay.minutes + ' min, ' : ''}${v.replay.keyPoints} key ${v.replay.keyPoints === 1 ? 'point' : 'points'}.</p><div class="mtg-foot"><button class="addb pri" data-m3="replay">Replay</button><span class="note">Plays the note’s audio kept on this machine, with the transcript and the key points.</span></div>` : '');
544
- const chips = statusChips(r, note).map((c) => `<span class="chp sm${c.kind ? ' ' + c.kind : ''}"><i></i>${esc(c.text)}</span>`).join('');
545
- const status = ui.status ? `<p class="note mtg-status" id="mtgStatus" role="status">${esc(ui.status.text)}${ui.status.undo ? ' <button class="mtg-b" id="mtgUndo">Undo</button>' : ''}</p>` : '<p class="note mtg-status" id="mtgStatus" role="status" hidden></p>';
546
- /* the dialog's own head already says the title, day, time and length: the detail adds the state, the people folded to a count, and what it is about */
547
- const ppl = v.people.length ? `<button type="button" class="vm-lk vm-ppb" data-vm="ppl" aria-expanded="${!!ui.ppl}">${ic('user')}${v.people.length} ${v.people.length === 1 ? 'person' : 'people'}</button>` : '';
548
- const lines = `<div class="vm-ln vm-st2">${chips}${ppl}</div>${ppl ? `<div class="pv vm-ppl"${ui.ppl ? '' : ' hidden'}>${v.people.map(person).join('')}</div>` : ''}`
549
- + (aboutNow ? `<div class="vm-ln">${ic('link')}<span>It is about <b>${esc(aboutNow)}</b>.${lv && lv.why ? ' ' + esc(lv.why) + '.' : ''}</span></div>` : '') + `<div class="vm-about"${ui.about ? '' : ' hidden'}>${link}</div>`;
550
- const parts = { before: stageHtml('before', S, sx) + [prep, mat, prev, tops].join(''), during: stageHtml('during', S, sx), after };
551
- return `<article class="paper doc mtg vm">${status}${lines}${seriesHtml(S, esc, { noOut: true })}${actsHtml(r, ui, aboutNow, S)}${partsHtml(ui.phase || 'before', parts, ui.open, esc)}</article>`;
552
- }
553
- function sheetHtml(row) {
554
- return `<article class="paper doc mtg mtg-sheet"><button class="mtg-b" id="mmBack">Back to the meeting</button>
555
- <p class="note">${esc(row.title)} · ${esc(row.day)} ${esc(row.time)}. PMOS keeps the link on its record of this meeting. The invite in your calendar is not changed.</p>
556
- ${sec('Suggested for this meeting', '<div id="mmSug"></div>')}${sec('Find in PMOS', '<input class="mtg-in" id="mmFind" type="search" placeholder="A document, report or deck" aria-label="Find a document, report or deck in PMOS" autocomplete="off"><div id="mmFound"></div>')}
557
- ${sec('Or paste a link', '<input class="mtg-in" id="mmLinkIn" type="url" placeholder="Any https address" aria-label="Paste a link" autocomplete="off"><div id="mmPaste"></div>')}<div id="mmOpts"></div></article>`;
444
+ const at = Number.isFinite(e.at) ? e.at : Date.parse(e.start || e.at);
445
+ const hit = W && W.state === 'ok' ? W.days.flatMap((x) => x.rows).find((r) => (e.id && r.id === e.id) || (Date.parse(r.at) === at && r.title === clip(e.title, 120))) : null;
446
+ if (!hit) return false;
447
+ await openRow(hit);
448
+ return true;
558
449
  }
559
-
560
- /** Make task: the step goes into the first stage of the note's initiative (POST /api/plan-items). Answers { ok, text, undo? }. */
561
- async function planTask(n, step) {
450
+ async function task(n, step) {
562
451
  if (!n || !n.initiative) return { ok: false, text: taskEvent(n, step, null).reason };
563
452
  const lay = await d.pmGet('/api/plan-items?ladder=0&ws=' + encodeURIComponent(n.initiative.ws) + '&id=' + encodeURIComponent(n.initiative.id));
564
453
  const plan = taskEvent(n, step, lay && lay.ok && (lay.stages || [])[0]);
565
454
  if (!plan.ok) return { ok: false, text: 'The task was not made: ' + plan.reason };
566
455
  const res = await d.pmPost('/api/plan-items', { ws: plan.ws, events: [plan.event] });
567
- if (!res || res.ok !== true) return { ok: false, text: 'The task was not made' + (res && res.error ? ': ' + res.error : '.') };
568
- const item = res.written && res.written[0] && res.written[0].item;
569
- return { ok: true, text: `Added to ${n.initiative.name}, under ${(lay.stages[0].label || lay.stages[0].id)}.`, undo: item ? async () => {
570
- const u = await d.pmPost('/api/plan-items', { ws: plan.ws, events: [{ ev: 'withdrawn', item, initiative: n.initiative.id }] });
571
- return u && u.ok === true ? { ok: true } : { ok: false, text: 'The task was not withdrawn' + (u && u.error ? ': ' + u.error : '.') };
572
- } : null };
456
+ return res && res.ok === true ? { ok: true, text: `Added to ${n.initiative.name}, under ${(lay.stages[0].label || lay.stages[0].id)}.` } : { ok: false, text: 'The task was not made' + (res && res.error ? ': ' + res.error : '.') };
573
457
  }
574
-
575
- async function openRow(row, via) {
576
- delete $('#oMain').dataset.ready;
577
- { const g = document.getElementById('dlg'); if (g) g.classList.remove('rpw'); } // a Replay left open when the dialog closed
578
- let replay = null, material = null, extra = { prev: [], topics: [] }, boards = W ? W.boards : [], inis = W ? W.initiatives : [], saved = '';
579
- const ui = { view: 'detail', status: null, tasked: new Set(), phase: 'before', open: {} }, SH = { sug: null, found: [], pick: null, scope: 'meeting', q: '', link: '', token: 0, topics: [], topic: null };
580
- let stT = null, findT = null, undoFn = null;
581
- const view = () => meetingView(row, replay, material, extra);
582
- const say = (text, undo) => { clearTimeout(stT); undoFn = undo || null; ui.status = { text, undo: undo || null }; if (ui.view === 'detail') { paint(); stT = setTimeout(() => { ui.status = null; if (ui.view === 'detail') paint(); }, 9000); } else d.toast(text); };
583
- const paint = () => {
584
- const pane = $('#dOut'), top = pane ? pane.scrollTop : 0, same = ui.last === ui.view; ui.last = ui.view;
585
- if (ui.view === 'detail') partKeep($('#oMain'), ui.open); // a part opened or folded before the presses were live stays so
586
- $('#oMain').innerHTML = ({ add: () => sheetHtml(row), focus: focusHtml, replay: replayHtml }[ui.view] || (() => detailHtml(view(), boards, inis, saved, ui)))();
587
- if (ui.view === 'add') paintSheet();
588
- else if (ui.view === 'detail') { const S = view().sheet, sx = { esc, tasked: { has: (i) => ui.tasked.has(i) }, replayBtn: !!view().replay, where: 'meeting', id: S ? S.id : null, brief: extra.brief || null, reread: async () => { await readSheet(); paint(); } }; for (const [k] of PHASES) wireStage(k, $(`#oMain .vm-body[data-part="${k}"]`), S, sx); }
589
- if (pane && same) pane.scrollTop = top;
590
- };
591
- const alive = (v) => ui.view === v && $('#dlg').classList.contains('on') && $('#dTitle').textContent === row.title;
592
- const paintRec = () => { const e = $('#m3Rec'); if (e) e.innerHTML = recBarHtml(row, ui); };
593
- cur = { row, repaint: paintRec, alive: () => $('#dlg').classList.contains('on') && $('#dTitle').textContent === row.title };
594
- let fT = null, F = null, clkT = null, RP = null, repM = null;
595
- const tickClock = () => { clearInterval(clkT); clkT = setInterval(() => { if (!cur || cur.row !== row || !cur.alive() || !HOLD) { clearInterval(clkT); return; } const c = $('#m3Clk'); if (c) c.textContent = clockText(); }, 1000); };
596
-
597
- /* Focus: the meeting as it is now, read every 3 seconds while the view is open (GET /api/meeting-focus) */
598
- function focusHtml() {
599
- const head = `<div class="m3-fh"><button class="mtg-b" data-m3="unfocus">Leave focus</button><div class="m3-fti"><b>${esc(row.title)}</b><span class="note">${esc(F && F.state === 'ok' ? F.status : 'Reading the meeting')}</span></div></div><div id="m3Rec">${recBarHtml(row, ui)}</div>`;
600
- if (!F) return `<article class="paper doc mtg">${head}<p class="note">Reading the meeting.</p></article>`;
601
- if (F.state === 'error') return `<article class="paper doc mtg">${head}<p class="note" role="status">Focus could not read this meeting: ${esc(F.reason)}</p></article>`;
602
- const first = F.phase === 'before';
603
- const nowTopic = first ? F.topics[0] : F.current;
604
- let h = head;
605
- if (F.stretches.length) h += `<div class="m3-trk" role="img" aria-label="What the room talked about, in order. Numbers match the topic list.">${F.stretches.map((x) => `<span class="m3-stc${x.on ? ' on' : ''}" style="flex:${x.flex}">${x.n}</span>`).join('')}</div>`;
606
- h += `<div class="m3-now"><span class="label">${first ? 'First up' : 'Now'}</span><b>${esc(nowTopic ? nowTopic.text : 'No topic is current yet')}</b>${F.topics.length ? `<button class="mtg-b" data-m3="chg" aria-expanded="${!!ui.change}">Change</button>` : ''}</div>`;
607
- if (ui.change && F.topics.length) h += `<div class="m3-chg" role="group" aria-label="Topics"><p class="note">Sets the topic Focus follows. It records one correction on this meeting; PMOS’s companion may move it on later.</p>${F.topics.map((t) => `<button class="mtg-b" data-m3="topic" data-n="${t.n}" aria-pressed="${t.state === 'now'}">${t.n}. ${esc(t.text)}</button>`).join('')}</div>`;
608
- if (F.gist) h += `<p class="m3-say">${esc(F.gist)}</p>`;
609
- if (F.chips.length) h += `<div class="m3-chips">${F.chips.map((c) => `<span class="m3-chp" title="${esc(c.sub)}">${esc(c.label)}${c.sub ? `<small>${esc(c.sub)}</small>` : ''}</span>`).join('')}</div>`;
610
- h += `<span class="label">${F.rec ? 'Live transcript' : 'Transcript'}</span>`;
611
- h += F.tail.length ? `<div class="m3-ftr">${F.tail.map((l, i) => `<p${i === F.tail.length - 1 ? ' class="cur"' : ''}><b>${esc(l.who)}</b> ${esc(l.text)}</p>`).join('')}</div>` : `<p class="note">${F.rec ? 'Nothing has been said yet.' : 'The transcript starts when you record.'}</p>`;
612
- h += '<span class="label">Topics</span>' + (F.topics.length ? `<div class="m3-tops">${F.topics.map((t) => `<div class="m3-tp ${t.state}"><i>${t.n}</i><span>${esc(t.text)}</span><small>${t.state === 'now' ? 'now' : t.state === 'done' ? (t.minutes ? t.minutes + ' min' : 'done') : t.state === 'parked' ? 'parked' : 'planned'}</small></div>`).join('')}</div>` : '<p class="note">The meeting has no topics yet.</p>');
613
- h += '<span class="label">Material</span>' + (F.material.length ? `<ul class="mtg-l">${F.material.map((m) => `<li>${esc(m.title)}<em>${esc([m.kind, m.topic ? 'on ' + m.topic : ''].filter(Boolean).join(' · '))}</em></li>`).join('')}</ul>` : '<p class="note">No material linked. Add some from the meeting.</p>');
614
- if (F.rec || F.paused || F.phase === 'done') h += `<span class="label">Captured so far</span><div class="m3-cap"><div><b>${F.captured.decisions}</b><span>Decisions</span></div><div><b>${F.captured.actions}</b><span>Next steps</span></div><div><b>${F.captured.questions}</b><span>Questions</span></div></div>`;
615
- if (F.companion) h += `<p class="note">${esc(F.companion)}</p>`;
616
- return `<article class="paper doc mtg">${h}</article>`;
617
- }
618
- async function readFocus() {
619
- const r = await d.pmGet('/api/meeting-focus?event=' + encodeURIComponent(row.id) + '&date=' + row.day);
620
- F = focusView(r);
621
- }
622
- async function focusLoop() {
623
- clearTimeout(fT);
624
- if (!alive('focus')) return;
625
- await readFocus();
626
- if (!alive('focus')) return;
627
- paint(); fT = setTimeout(focusLoop, 3000);
628
- }
629
-
630
- /* Replay: the note's audio, the transcript and the key points on one track (GET /api/meeting-replay, GET /api/notes/recording) */
631
- /* Replay, laid out as the prototype's replay (prototype/premium-conversation-shell, PR 901) and the console's (c3-replay.js), from GET /api/meeting-replay:
632
- * the head with the player and the time of day, the topic track with a mark for each key point (ringed when it needs you) and each PMOS note,
633
- * what was on screen beside the conversation (All, Key points, PMOS, search), and the key points in three columns with Confirm all. */
634
- const RPK = { decision: ['dec', 'Decision', 'Decisions'], action: ['task', 'Next step', 'Next steps'], question: ['undo', 'Question', 'Questions'] };
635
- function replayHtml() {
636
- const back = `<button class="mtg-b" data-m3="unreplay">${ic('back')}Back to the meeting</button>`;
637
- const head0 = `<div class="m3-fh">${back}<div class="m3-fti"><b>${esc(row.title)}</b><span class="note">Replay · ${esc(row.time)}</span></div></div>`;
638
- if (repM === undefined) return `<article class="paper doc mtg">${head0}<p class="note" role="status">${esc(RP && RP.error ? 'Replay could not be read: ' + RP.error : 'Reading the recording.')}</p></article>`;
639
- if (!repM) return `<article class="paper doc mtg">${head0}<p class="note">Reading the recording.</p></article>`;
640
- const m = repM, pct = (t) => Math.min(100, Math.max(0, t / m.len * 100)).toFixed(2), w = (t) => wallOf(m, t);
641
- const day = m.at && Number.isFinite(Date.parse(m.at)) ? new Date(m.at).toLocaleDateString(undefined, { weekday: 'short', day: 'numeric', month: 'short' }) : row.day;
642
- const chips = [day, m.start != null ? w(0) + ' to ' + w(m.len) : '', Math.max(1, Math.round(m.len / 60000)) + ' min', m.people ? m.people + (m.people === 1 ? ' person' : ' people') : ''].filter(Boolean).join(' · ');
643
- const kept = (m.audio ? 'audio' : 'no audio') + (m.shots.length ? ' and ' + m.shots.length + (m.shots.length === 1 ? ' screen shot' : ' screen shots') : '');
644
- const need = m.keys.filter((k) => k.need).length;
645
- let h = `<section class="rp-hd"><div class="m3-fh">${back}<div class="m3-fti"><b>${esc(m.title || row.title)}</b><span class="note">${esc(chips)} · ${ic('lock')}${esc(kept)}</span></div>
646
- <div class="rp-clk"><b id="rpPos">${mmss(0)} / ${mmss(m.len)}</b><small id="rpClk">${esc(w(0))}</small></div></div>`;
647
- h += `<div class="m3-rctl"><button class="mtg-b" data-m3="back10" aria-label="Back 10 seconds">${ic('undo')}Back 10 s</button><button class="mtg-b cta" data-m3="play" id="rpPlay">Play</button><div class="seg2" role="group" aria-label="Speed">${[1, 1.5, 2].map((v) => `<button class="mtg-b" data-m3="spd" data-v="${v}" aria-pressed="${RP.spd === v}">${v}x</button>`).join('')}</div></div>`;
648
- const marks = m.keys.filter((k) => k.t != null).map((k) => `<button class="rp-mk ${k.k}${k.need ? ' need' : ''}" style="left:${pct(k.t)}%" data-rp="seek" data-t="${k.t}" aria-label="${RPK[k.k][1]} at ${esc(w(k.t))}: ${esc(k.text)}" title="${esc(RPK[k.k][1] + ' · ' + k.text)}"><span>${ic(RPK[k.k][0])}</span></button>`)
649
- .concat(m.pmos.map((x) => `<button class="rp-mk pm" style="left:${pct(x.t)}%" data-rp="seek" data-t="${x.t}" aria-label="PMOS note at ${esc(w(x.t))}: ${esc(x.body)}" title="${esc('PMOS · ' + x.body)}"><span>${ic('spark')}</span></button>`)).join('');
650
- const track = m.stretches.map((x) => `<button class="m3-stc" style="flex:${x.to - x.from}" data-m3="seek" data-t="${x.from}" data-from="${x.from}" data-to="${x.to}" aria-label="${esc((x.text || 'Topic ' + x.n) + ' from ' + w(x.from))}">${x.n}</button>`).join('');
651
- const dots = m.keys.filter((k) => k.t != null).map((k) => `<i class="m3-mk ${k.k}" style="left:${pct(k.t)}%"></i>`).join('');
652
- const gaps = m.gaps.map((g) => `<i class="rp-gap" style="left:${pct(g.from)}%;width:${(Math.max(0.6, (g.to - g.from) / m.len * 100)).toFixed(2)}%" title="Not recorded ${esc(w(g.from))} to ${esc(w(g.to))}"></i>`).join('');
653
- const ticks = [0, 0.25, 0.5, 0.75, 1].map((f) => `<span>${esc(w(m.len * f))}</span>`).join('');
654
- h += `<div class="rp-tl"><div class="rp-mks">${marks}</div><div class="m3-trk${track ? '' : ' none'}" role="group" aria-label="The meeting by topic">${track || `<button class="m3-stc" style="flex:1" data-m3="seek" data-t="0" aria-label="From the start">${m.topics.length ? '' : 'No topics were kept'}</button>`}${dots}${gaps}<b class="m3-ph" id="rpPh"></b></div><div class="rp-sc">${ticks}</div></div>`;
655
- h += `<div class="m3-lgd"><span>${ic('dec')}Decisions</span><span>${ic('undo')}Questions</span><span>${ic('task')}Next steps</span><span>${ic('spark')}PMOS notes</span><span><i class="ring"></i>needs you</span></div></section>`;
656
- h += `<div class="m3-now"><span class="label">Topic</span><b id="rpTopic"></b><span class="note" id="rpNear"></span>${m.shots.length ? `<span class="chp sm" id="rpShK">${ic('xp')}<span></span></span>` : ''}${m.keys.length ? `<button class="mtg-b" data-rp="keys">${ic('check')}${m.keys.length} key ${m.keys.length === 1 ? 'point' : 'points'}${need ? ' · ' + need + ' need you' : ''}</button>` : ''}</div>`;
657
- const strip = m.shots.map((x) => `<button class="mtg-b" data-m3="seek" data-t="${x.t}" data-shot="${x.t}" title="${esc(x.why || 'The shared screen at ' + w(x.t))}">${esc(w(x.t))}</button>`).join('');
658
- h += `<div class="rp-g"><section class="rp-box rp-st"><div class="rp-cap">${ic('xp')}<b>On screen</b><span class="note">Kept when the screen changed${m.aside ? ' · ' + m.aside + ' set aside' : ''}</span></div><div id="rpShot"></div>${strip ? `<div class="rp-ts" role="group" aria-label="Screen shots kept, by time">${strip}</div>` : ''}</section>
659
- <section class="rp-box rp-cv"><div class="rp-cvh"><b>Conversation</b><div class="seg2" role="group" aria-label="Show">${[['a', 'All'], ['k', 'Key points'], ['p', 'PMOS']].map(([k, l]) => `<button class="mtg-b" data-rp="tab" data-v="${k}" aria-pressed="${RP.tab === k}">${l}</button>`).join('')}</div></div>
660
- <div class="m3-ftr all" id="rpLines">${convHtml()}</div><label class="rp-q">${ic('search')}<input id="rpQ" type="search" placeholder="Search what was said" aria-label="Search what was said" value="${esc(RP.q)}" autocomplete="off"></label></section></div>`;
661
- h += `<section class="rp-box" id="rpKeys"><div class="rp-cvh"><div class="rp-cap">${ic('check')}<b>Key points</b></div>${m.keys.some((k) => k.k === 'action') ? `<button class="mtg-b cta" data-rp="confirm" title="Make a task of each next step on the note’s initiative">${ic('check')}Confirm all</button>` : ''}</div>`
662
- + (m.keys.length ? `<div class="m3-kps rp-kc">${['decision', 'action', 'question'].map((k) => { const l = m.keys.filter((x) => x.k === k); return `<div class="rp-col"><h4>${ic(RPK[k][0])}${RPK[k][2]}<small>${l.length}</small></h4>${l.length ? l.map(keyHtml).join('') : '<p class="note">None caught.</p>'}</div>`; }).join('')}</div><p class="note">Each one plays from the moment it was said. Confirm all makes a task of each next step on the note’s initiative.</p>` : '<p class="note">The note holds no decisions, next steps or questions.</p>') + '</section>';
663
- h += `<p class="note">${m.audio && !RP.noAudio ? 'Plays the note’s audio, kept on this machine.' : 'No audio is kept for this meeting, so the playhead keeps its own clock.'}</p>`;
664
- return `<article class="paper doc mtg rpv">${h}</article>`;
665
- }
666
- function keyHtml(k) {
667
- const meta = k.k === 'decision' ? (k.by || 'the group') : k.k === 'action' ? (k.owner ? [k.owner, k.due && 'due ' + k.due].filter(Boolean).join(' · ') : 'no owner') : k.state === 'answered' ? 'answered' : 'still open';
668
- const tags = `<span class="rp-tg"><span class="${k.need ? 'warn' : ''}">${esc(meta)}</span>${k.k === 'question' ? '' : `<span>${RP.done.has(k.id) ? 'task made' : 'draft'}</span>`}</span>`;
669
- const kind = `<span class="kd">${esc(RPK[k.k][1])}</span>`;
670
- return k.t != null ? `<button data-m3="seek" data-t="${k.t}" class="${k.need ? 'need' : ''}">${kind}<span>${esc(k.text)}${tags}</span><time>${esc(wallOf(repM, k.t))}</time></button>`
671
- : `<div class="m3-kp0${k.need ? ' need' : ''}">${kind}<span>${esc(k.text)}${tags}</span><em>No time</em></div>`;
672
- }
673
- function convHtml() {
674
- const m = repM, q = RP.q.trim().toLowerCase();
675
- const all = [...m.lines.map((l) => ({ t: l.t, l })), ...m.pmos.map((p) => ({ t: p.t, p }))].sort((a, b) => a.t - b.t || (a.p ? 1 : 0) - (b.p ? 1 : 0))
676
- .filter((x) => RP.tab === 'a' || (RP.tab === 'k' ? x.l && x.l.key : x.p)).filter((x) => !q || (x.l ? x.l.who + ' ' + x.l.text : x.p.body).toLowerCase().includes(q));
677
- if (!all.length) return `<p class="note">${q ? 'Nothing said matches “' + esc(RP.q) + '”.' : RP.tab === 'p' ? 'PMOS made no notes during this meeting.' : RP.tab === 'k' ? 'No line was caught as a key point.' : 'The recording holds no transcript.'}</p>`;
678
- return all.map((x) => x.p ? `<button class="m3-ln pm" data-m3="seek" data-t="${x.t}"><time>${esc(wallOf(m, x.t))}</time><b>PMOS</b><span>${esc(x.p.body)}</span></button>`
679
- : `<button class="m3-ln" id="rl${x.l.i}" data-m3="seek" data-t="${x.l.t}"><time>${esc(wallOf(m, x.l.t))}</time><b>${esc(x.l.who || 'You')}</b><span>${x.l.key && RPK[x.l.key] ? `<em class="rp-kt">${esc(RPK[x.l.key][1])}</em>` : ''}${esc(x.l.text)}</span></button>`).join('');
680
- }
681
- function replayPaint() {
682
- const m = repM; if (!m || !alive('replay')) return;
683
- const pos = RP.pos, at = replayAt(m, pos), $q = (id) => document.getElementById(id);
684
- if ($q('rpPos')) $q('rpPos').textContent = mmss(pos) + ' / ' + mmss(m.len);
685
- if ($q('rpClk')) $q('rpClk').textContent = wallOf(m, pos);
686
- if ($q('rpPh')) $q('rpPh').style.left = Math.min(100, pos / m.len * 100).toFixed(2) + '%';
687
- if ($q('rpTopic')) $q('rpTopic').textContent = at.stretch ? (at.stretch.text || 'Topic ' + at.stretch.n) : m.stretches.length ? 'Between topics' : 'No topics were kept';
688
- if ($q('rpNear')) $q('rpNear').textContent = at.near ? at.near + (at.near === 1 ? ' key point near' : ' key points near') : '';
689
- if ($q('rpPlay')) $q('rpPlay').textContent = RP.play ? 'Pause' : 'Play';
690
- $$('#oMain .m3-stc[data-from]').forEach((b) => b.classList.toggle('on', pos >= +b.dataset.from && pos < +b.dataset.to));
691
- const prev = RP.line; RP.line = at.line;
692
- if (prev !== at.line) { if (prev >= 0 && $q('rl' + prev)) $q('rl' + prev).classList.remove('cur'); const c = at.line >= 0 ? $q('rl' + at.line) : null; if (c) { c.classList.add('cur'); if (RP.play) { const L = $q('rpLines'); if (L) L.scrollTop = Math.max(0, c.offsetTop - L.offsetTop - L.clientHeight / 3); } } }
693
- $$('#oMain .m3-ln.pm').forEach((b) => b.classList.toggle('fut', +b.dataset.t > pos));
694
- const want = at.shot >= 0 ? m.shots[at.shot] : null;
695
- if ($q('rpShK')) $q('rpShK').lastChild.textContent = want ? 'Screen shot from ' + wallOf(m, want.t) : 'Nothing shared yet';
696
- $$('#oMain [data-shot]').forEach((b) => b.setAttribute('aria-pressed', String(!!want && +b.dataset.shot === want.t)));
697
- const sh = $q('rpShot'); if (sh) { const have = sh.dataset.t, key = want ? String(want.t) : 'none'; if (key !== have) { sh.dataset.t = key; sh.innerHTML = want && m.noteId ? `<figure class="m3-shot"><img src="/api/notes/screen?id=${encodeURIComponent(m.noteId)}&t=${want.t}" alt="${esc(want.why || 'The shared screen at ' + mmss(want.t))}" loading="lazy"><figcaption class="note">${esc(want.why || 'The shared screen at ' + mmss(want.t))} · ${esc(wallOf(m, want.t))}</figcaption></figure>` : `<p class="note rp-none">${m.shots.length ? 'Nothing was shared yet. The first screen shot is at ' + esc(wallOf(m, m.shots[0].t)) + '.' : 'No screen shots were kept for this meeting.'}</p>`; } }
698
- }
699
- /* Confirm all: each next step not yet made becomes a task of the note's initiative, as Make task does (POST /api/plan-items) */
700
- async function confirmAll(btn) {
701
- const m = repM, todo = m.keys.filter((k) => k.k === 'action' && !RP.done.has(k.id));
702
- if (!todo.length) return say('Every next step is already a task.');
703
- if (!m.note || !m.note.initiative) return say('Link the note to an initiative first. Confirm all adds each next step to its breakdown.');
704
- if (btn) btn.disabled = true;
705
- let made = 0, last = '';
706
- for (const k of todo) { const res = await planTask(m.note, { text: k.text, owner: k.owner, due: k.due }); if (!res.ok) { last = res.text; break; } RP.done.add(k.id); made++; }
707
- if (!alive('replay')) return;
708
- const L = $('#rpKeys'); if (L) { const fresh = document.createElement('div'); fresh.innerHTML = replayHtml(); const k2 = fresh.querySelector('#rpKeys'); if (k2) L.replaceWith(k2); }
709
- say(made ? `${made} next ${made === 1 ? 'step is' : 'steps are'} now ${made === 1 ? 'a task' : 'tasks'} in ${m.note.initiative.name}.${last ? ' ' + last : ''}` : last);
710
- replayPaint();
711
- }
712
- function replayStop() { clearInterval(RP && RP.tm); if (RP && RP.aud) { try { RP.aud.pause(); } catch { /* gone */ } } if (RP) RP.play = false; }
713
- function replaySeek(ms, play) {
714
- RP.pos = Math.max(0, Math.min(repM.len, ms));
715
- if (RP.aud) { try { RP.aud.currentTime = RP.pos / 1000; } catch { /* not loaded */ } }
716
- if (play && !RP.play) replayToggle(); else replayPaint();
717
- }
718
- function replayToggle() {
719
- if (RP.play) { RP.play = false; if (RP.aud) RP.aud.pause(); replayPaint(); return; }
720
- if (RP.pos >= repM.len - 200) replaySeek(0, false);
721
- RP.play = true; RP.last = performance.now();
722
- if (RP.aud) { RP.aud.playbackRate = RP.spd; const pr = RP.aud.play(); if (pr && pr.catch) pr.catch(() => { RP.aud = null; RP.noAudio = true; RP.last = performance.now(); say('The audio could not be played, so the playhead keeps its own clock.'); }); }
723
- clearInterval(RP.tm);
724
- RP.tm = setInterval(() => {
725
- if (!alive('replay')) { replayStop(); return; }
726
- const now = performance.now();
727
- if (RP.aud && !RP.aud.paused) RP.pos = RP.aud.currentTime * 1000; else if (RP.play) RP.pos += (now - RP.last) * RP.spd; RP.last = now;
728
- if (RP.pos >= repM.len) { RP.pos = repM.len; RP.play = false; if (RP.aud) RP.aud.pause(); clearInterval(RP.tm); }
729
- replayPaint();
730
- }, 500);
731
- replayPaint();
732
- }
733
- async function openReplay() {
734
- ui.view = 'replay'; repM = null; RP = { pos: 0, play: false, spd: 1, aud: null, tm: null, line: -2, noAudio: false, tab: 'a', q: '', done: new Set() };
735
- wide(true); paint();
736
- const r = await d.pmGet('/api/meeting-replay?event=' + encodeURIComponent(row.id) + '&date=' + row.day);
737
- if (!alive('replay')) return;
738
- repM = replayModel(r);
739
- if (!repM) { repM = undefined; RP.error = r && r.ok === true ? 'the recording holds no length and no lines' : (r && r.error) || 'no answer'; paint(); return; }
740
- if (repM.audio) { RP.aud = new Audio(repM.audio.url); RP.aud.preload = 'metadata'; RP.aud.addEventListener('error', () => { RP.aud = null; RP.noAudio = true; }); }
741
- paint(); $('#rpPlay') && $('#rpPlay').focus(); replayPaint();
742
- }
743
- /* Replay takes the whole window with the conversation hidden, as the prototype's replay does; leaving it puts the dialog back as it was */
744
- let wasDlg = null;
745
- function wide(on) {
746
- const g = document.getElementById('dlg'); if (!g || !d.setFull || !d.setMode) return;
747
- if (on) { if (!wasDlg) wasDlg = { full: g.classList.contains('full'), mode: g.dataset.mode || 'split' }; d.setFull(true); d.setMode('detail'); g.classList.add('rpw'); return; }
748
- g.classList.remove('rpw'); if (wasDlg) { d.setFull(wasDlg.full); d.setMode(wasDlg.mode); wasDlg = null; }
749
- }
750
- const leave = (to) => { clearTimeout(fT); if (ui.view === 'replay') { replayStop(); wide(false); } ui.view = to; ui.change = false; paint(); const b = $('#oMain [data-m3="' + (to === 'detail' ? (RP && repM ? 'replay' : 'focus') : '') + '"]'); if (b) b.focus(); };
751
-
752
- /* the presses of the Record row, Focus and Replay */
753
- async function m3Press(act, t) {
754
- const st = recMode(row), k = keyOf(row);
755
- const started = async (kind) => {
756
- ui.ask = null; ui.recMsg = ''; if (t) t.disabled = true;
757
- const res = kind === 'resume' ? await ctl.resume(st.note.id) : await ctl.record(row);
758
- ui.recMsg = res.ok ? (kind === 'resume' ? 'Resumed. Let people know.' : 'Recording. Notes are being taken on this machine. Let people know.') : res.error;
759
- if (res.ok) tickClock(); paintRec();
760
- if (res.ok && ui.view === 'detail') d.toast('Recording started.');
761
- };
762
- switch (act) {
763
- case 'why': { const n = $('#oMain .acts2 > .why'), on = n && n.hidden; if (n) { n.hidden = !on; t.setAttribute('aria-expanded', String(on)); } return; }
764
- case 'rec': if (!consented.has(k)) { ui.ask = 'consent'; paintRec(); const g = $('#m3Rec [data-m3="go"]'); if (g) g.focus(); return; } return started('rec');
765
- case 'go': consented.add(k); return started('rec');
766
- case 'no': ui.ask = null; paintRec(); { const b = $('#m3Rec [data-m3="rec"]'); if (b) b.focus(); } return;
767
- case 'resume': return started('resume');
768
- case 'pause': { t.disabled = true; const res = await ctl.pause(); ui.recMsg = res.ok ? 'Paused. You can resume within 1 hour.' : res.error; paintRec(); return; }
769
- case 'stop': ui.ask = 'stop'; paintRec(); { const b = $('#m3Rec [data-m3="stopno"]'); if (b) b.focus(); } return;
770
- case 'stopno': ui.ask = null; paintRec(); return;
771
- case 'stoppause': { ui.ask = null; const res = await ctl.pause(); ui.recMsg = res.ok ? 'Paused. You can resume within 1 hour.' : res.error; paintRec(); return; }
772
- case 'stopgo': { ui.ask = null; const res = await ctl.stop(st.note.id); ui.recMsg = res.ok ? (res.discarded ? 'Nothing was recorded, so the note was deleted.' : 'Stopped for good. The final notes are written now.') : res.error; paintRec(); return; }
773
- case 'focus': ui.view = 'focus'; F = null; ui.change = false; paint(); { const b = $('#oMain [data-m3="unfocus"]'); if (b) b.focus(); } focusLoop(); return;
774
- case 'unfocus': return leave('detail');
775
- case 'chg': ui.change = !ui.change; paint(); return;
776
- case 'topic': {
777
- const tp = F && F.state === 'ok' ? F.topics[+t.dataset.n - 1] : null, body = tp ? topicBody(row, tp.text) : null; if (!body) return;
778
- const res = await d.pmPost('/api/meeting-focus/topic', body);
779
- ui.recMsg = res && res.ok === true ? '' : 'The topic was not set: ' + ((res && res.error) || 'no answer'); ui.change = false;
780
- if (res && res.ok === true) await readFocus(); paint(); if (ui.recMsg) d.toast(ui.recMsg); return;
781
- }
782
- case 'replay': return openReplay();
783
- case 'unreplay': replayStop(); wide(false); ui.view = 'detail'; paint(); { const b = $('#oMain [data-m3="replay"]'); if (b) b.focus(); } return;
784
- case 'play': if (repM && RP) replayToggle(); return;
785
- case 'back10': if (repM && RP) replaySeek(RP.pos - 10000, false); return;
786
- case 'spd': if (RP) { RP.spd = +t.dataset.v; if (RP.aud) RP.aud.playbackRate = RP.spd; $$('#oMain [data-m3="spd"]').forEach((b) => b.setAttribute('aria-pressed', +b.dataset.v === RP.spd)); } return;
787
- case 'seek': if (repM && RP) replaySeek(+t.dataset.t, true); return;
788
- default:
789
- }
790
- }
791
-
792
- function paintSheet() {
793
- const list = (L, k) => (L.length ? `<ul class="mtg-l">${L.map((it, i) => pickLi(it, k + ':' + i, SH.pick && (SH.pick.ref || SH.pick.url) === (it.ref || it.url) && SH.pick.kind === it.kind)).join('')}</ul>` : '');
794
- const q = $('#mmSug'); if (!q) return;
795
- q.innerHTML = SH.sug == null ? '<p class="note">Looking in PMOS.</p>' : SH.sug.length ? list(SH.sug, 'sug') : '<p class="note">Nothing to suggest yet. Search below, or paste a link.</p>';
796
- $('#mmFound').innerHTML = SH.q.length >= 2 ? (SH.foundBusy ? '<p class="note">Searching.</p>' : SH.found.length ? list(SH.found, 'found') : '<p class="note">Nothing in PMOS matches that.</p>') : '';
797
- const pst = pasteOf(SH.link);
798
- $('#mmPaste').innerHTML = pst ? list([pst], 'paste') : `<p class="note">${SH.link ? 'Paste an https address.' : 'A web page opens in a new tab and PMOS does not read it.'}</p>`;
799
- const k = SH.pick;
800
- $('#mmOpts').innerHTML = k ? `<div class="mtg-sec"><span class="label">For</span><div class="seg2" role="group" aria-label="For"><button class="mtg-b" data-scope="meeting" aria-pressed="${SH.scope === 'meeting'}">This meeting</button><button class="mtg-b" data-scope="series" aria-pressed="${SH.scope === 'series'}">${row.series ? 'Every meeting in the series' : 'Every meeting with this title'}</button></div>
801
- ${SH.topics.length ? `<div class="mtg-sec"><span class="label">Topic</span><div class="seg2" role="group" aria-label="Topic"><button class="mtg-b" data-topic="" aria-pressed="${!SH.topic}">Whole meeting</button>${SH.topics.map((t, i) => `<button class="mtg-b" data-topic="${i + 1}" aria-pressed="${SH.topic === t.text}">${i + 1}. ${esc(clip(t.text, 60))}</button>`).join('')}</div></div>` : ''}<p class="note" id="mmLine">${esc(addLine(k, SH.scope, SH.topic))}</p><div class="mtg-foot"><button class="cta" id="mmDo">Add to the meeting</button><button class="mtg-b" id="mmCancel">Cancel</button></div></div>` : '';
802
- }
803
- async function reload() {
804
- const mt = await d.pmGet(matPath());
805
- material = mt && mt.ok === true ? { state: 'ok', items: mt.items || [] } : { state: 'error', error: (mt && mt.error) || 'no answer' };
806
- }
807
- /* The meeting's note, as the console's note sheet reads it (GET /api/notes/one): Before, During and After draw its parts. */
808
- async function readSheet() {
809
- const nt = noteOfRow(NR, row);
810
- const one = nt ? await d.pmGet('/api/notes/one?id=' + encodeURIComponent(nt.id)) : null;
811
- extra = { ...extra, sheet: noteSheet(one) };
812
- }
813
- /* The part that comes first and open: Recording while the note records, Notes once there are notes, else Prep. */
814
- function pickPhase() {
815
- const v = view(), n = v.notes, nt = noteOfRow(NR, row);
816
- ui.phase = phaseOf({ noteState: nt && nt.state, hasNotes: !!(v.sheet && v.sheet.overview) || !!v.replay || !!(n && n.decisions.length + n.actions.length + n.questions.length) });
817
- }
818
- const matPath = () => '/api/meeting-material?event=' + encodeURIComponent(row.id) + '&title=' + encodeURIComponent(row.title) + (row.series ? '&series=' + encodeURIComponent(row.series) : '') + '&date=' + row.day;
819
- vmStyle();
820
- d.openDlg({ eye: 'Calendar · real data', title: row.title, sub: [dayLabel(row.day), row.end && hasTime(row.end) ? row.time + ' to ' + hhmm(row.end) : [row.time, row.len].filter(Boolean).join(' · ')].filter(Boolean).join(' · '), compact: true, noteKey: via === 'today' ? 'ev:meeting:' + Date.parse(row.at) : 'pop:meeting:' + (String(row.day || '') + '-' + String(row.id || row.title)).replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^[^A-Za-z0-9]+/, '').slice(0, 90),
821
- stream: d.turnA(d.ptx('This meeting is in the calendar PMOS holds. Its notes, material and recording appear here only if PMOS holds them.')), pane: detailHtml(meetingView(row, null, null), boards, inis, '', ui), label: 'Meeting' });
822
- const [rp, mt] = await Promise.all([d.pmGet('/api/meeting-replay?event=' + encodeURIComponent(row.id) + '&date=' + row.day), d.pmGet(matPath())]);
823
- if ($('#dTitle').textContent !== row.title) return;
824
- replay = rp && rp.ok === true ? { state: 'ok', body: rp } : rp && rp.status === 404 ? { state: 'none' } : { state: 'error', error: (rp && rp.error) || 'no answer' };
825
- material = mt && mt.ok === true ? { state: 'ok', items: mt.items || [] } : { state: 'error', error: (mt && mt.error) || 'no answer' };
826
- await readNotes();
827
- if ($('#dTitle').textContent !== row.title) return;
828
- await readSheet();
829
- if ($('#dTitle').textContent !== row.title) return;
830
- pickPhase(); paint(); if (HOLD) tickClock(); mark();
831
- {
832
- /* the meeting prep for Before: the brief the console's Calendar card shows (GET /api/meeting-focus with brief=1, so it is not counted as a Focus read; lib/calendar-layers.js briefOf) */
833
- const sk = (noteOfRow(NR, row) || {}).series, [sr, tp, mf] = await Promise.all([sk && sk.key ? d.pmGet('/api/notes/series?key=' + encodeURIComponent(sk.key)) : null, d.pmGet(matPath() + '&topics=1'), d.pmGet('/api/meeting-focus?event=' + encodeURIComponent(row.id) + '&date=' + row.day + '&brief=1')]);
834
- if ($('#dTitle').textContent !== row.title) return;
835
- extra = { ...extra, prev: prevOf(sr, row), topics: tp && tp.ok && Array.isArray(tp.topics) ? tp.topics.filter((t) => t && t.text).slice(0, 8) : [], brief: mf && mf.ok === true && mf.brief ? mf.brief : null };
836
- if (ui.view === 'detail') paint();
837
- }
838
-
839
- const write = async (body) => { const res = await d.pmPost('/api/meeting-material', body); return res && res.ok === true ? res : { ok: false, error: (res && res.error) || 'The material was not saved.' }; };
840
- async function removeItem(item) {
841
- const body = removeBody(row, item); if (!body) return;
842
- const res = await write(body);
843
- if (!res.ok) return say('The material was not removed: ' + res.error);
844
- await reload();
845
- say('Removed “' + clip(item.title, 80) + '” from ' + scopeText(item.scope) + '. The document itself is not changed.', async () => { const back = await write({ ...addBody(row, item, item.scope), ...(item.topic ? { topic: item.topic } : {}), present: !!item.present }); await reload(); say(back.ok ? 'Put back.' : 'It was not put back: ' + back.error); });
846
- }
847
- async function makeTask(i) {
848
- const n = view().notes, step = n && n.actions[i]; if (!step) return;
849
- const res = await planTask(n, step);
850
- if (!res.ok) return say(res.text);
851
- ui.tasked.add(i);
852
- say(res.text, res.undo ? async () => {
853
- const u = await res.undo();
854
- if (u.ok) { ui.tasked.delete(i); say('The task is withdrawn.'); } else say(u.text);
855
- } : null);
856
- }
857
- async function member(key) {
858
- const S = view().sheet; if (!S) return;
859
- const r = await d.pmPost('/api/notes/series-member', { id: S.id, key });
860
- if (!r || r.ok !== true) return say('Not saved' + (r && r.error ? ': ' + r.error : '.'));
861
- await readSheet(); say(key === 'off' ? 'Taken out of the series.' : 'Back in its series.');
862
- }
863
- async function openSheet() {
864
- ui.view = 'add'; SH.sug = null; SH.found = []; SH.pick = null; SH.q = ''; SH.link = ''; SH.topics = []; SH.topic = null; paint();
865
- $('#mmBack').focus();
866
- const [r, tp] = await Promise.all([d.pmGet('/api/meeting-material/suggest?' + suggestQuery(row, { ws: d.ws() })), d.pmGet(matPath() + '&topics=1')]);
867
- SH.topics = tp && tp.ok && Array.isArray(tp.topics) ? tp.topics.filter((t) => t && t.text).slice(0, 8) : [];
868
- SH.sug = r && r.ok && Array.isArray(r.suggested) ? r.suggested : []; if (ui.view === 'add') paintSheet();
869
- }
870
- const closeSheet = (focusAdd) => { ui.view = 'detail'; paint(); if (focusAdd && $('#mmAdd')) $('#mmAdd').focus(); };
871
- const pickOf = (key) => { const [k, i] = key.split(':'); return (k === 'sug' ? SH.sug : k === 'found' ? SH.found : [pasteOf(SH.link)])[+i] || null; };
872
-
873
- $('#oMain').oninput = (e) => {
874
- if (e.target.id === 'rpQ' && repM && RP) { RP.q = e.target.value; $('#rpLines').innerHTML = convHtml(); RP.line = -2; replayPaint(); return; }
875
- if (e.target.id === 'mmLinkIn') { SH.link = e.target.value.trim(); const p = pasteOf(SH.link); if (p) SH.pick = p; else if (SH.pick && !SH.pick.ref) SH.pick = null; paintSheet(); }
876
- if (e.target.id === 'mmFind') {
877
- SH.q = e.target.value.trim(); SH.found = []; SH.foundBusy = SH.q.length >= 2; paintSheet(); clearTimeout(findT);
878
- if (!SH.foundBusy) return;
879
- const my = ++SH.token;
880
- findT = setTimeout(async () => { const r = await d.pmGet('/api/meeting-material/suggest?' + suggestQuery(row, { q: SH.q, ws: d.ws() })); if (my !== SH.token || ui.view !== 'add') return; SH.foundBusy = false; SH.found = r && r.ok && Array.isArray(r.found) ? r.found : []; paintSheet(); }, 220);
881
- }
882
- };
883
- $('#oMain').dataset.ready = 'meeting'; // the dialog's answers are read and its presses are live
884
- $('#oMain').onchange = (e) => { if (e.target.id === 'mtgSel') $('#mtgLink').disabled = !e.target.value; };
885
- $('#oMain').onclick = async (e) => {
886
- if (ui.view === 'detail' && partToggle(e, ui.open)) return;
887
- const t = e.target.closest('button'); if (!t) return;
888
- { const mn = t.closest('.vm-menu'); if (mn) mn.open = false; } // a press in the More menu closes it
889
- if (t.dataset.m3) return m3Press(t.dataset.m3, t);
890
- if (t.dataset.rp && repM && RP) { // the Replay's own presses: a mark on the track, the conversation tabs, the key points link and Confirm all
891
- const k = t.dataset.rp;
892
- if (k === 'seek') return replaySeek(+t.dataset.t, true);
893
- if (k === 'tab') { RP.tab = t.dataset.v; $$('#oMain [data-rp="tab"]').forEach((b) => b.setAttribute('aria-pressed', String(b === t))); $('#rpLines').innerHTML = convHtml(); RP.line = -2; replayPaint(); return; }
894
- if (k === 'keys') { const n = $('#rpKeys'); if (n) n.scrollIntoView({ behavior: 'smooth', block: 'start' }); return; }
895
- if (k === 'confirm') return confirmAll(t);
896
- return;
897
- }
898
- if (t.dataset.vm === 'ppl') { ui.ppl = !ui.ppl; t.setAttribute('aria-expanded', String(ui.ppl)); const x = $('#oMain .vm-ppl'); if (x) x.hidden = !ui.ppl; return; }
899
- if ((t.dataset.vm === 'prev' || t.dataset.vm === 'next') && t.dataset.id) return openNoteTab({ pmGet: d.pmGet, pmPost: d.pmPost, esc, toast: d.toast, task: planTask }, t.dataset.id);
900
- if (t.dataset.vm === 'about') { ui.about = !ui.about; t.setAttribute('aria-expanded', String(ui.about)); const x = $('#oMain .vm-about'); if (x) x.hidden = !ui.about; if (ui.about) $('#mtgSel').focus(); return; }
901
- if (t.dataset.vm === 'serout') return member('off');
902
- if (t.dataset.vm === 'serback') return member(null);
903
- if (t.id === 'mmAdd') return openSheet();
904
- if (t.id === 'mmBack' || t.id === 'mmCancel') return closeSheet(true);
905
- if (t.dataset.pick) { SH.pick = pickOf(t.dataset.pick); paintSheet(); return; }
906
- if (t.dataset.scope) { SH.scope = t.dataset.scope; paintSheet(); return; }
907
- if (t.dataset.topic !== undefined) { const tp = SH.topics[+t.dataset.topic - 1]; SH.topic = t.dataset.topic && tp ? tp.text : null; paintSheet(); return; }
908
- if (t.id === 'mmDo') {
909
- const body = addBody(row, SH.pick, SH.scope, SH.topic); if (!body) return;
910
- t.disabled = true;
911
- const res = await write(body);
912
- if (!res.ok) { t.disabled = false; $('#mmLine').textContent = 'The material was not saved: ' + res.error; return; }
913
- await reload(); ui.view = 'detail';
914
- say('Added “' + clip(SH.pick.title, 80) + '” to ' + scopeText(SH.scope) + (SH.topic ? ', under “' + clip(SH.topic, 60) + '”' : '') + '.');
915
- if ($('#mmAdd')) $('#mmAdd').focus();
916
- return;
917
- }
918
- if (t.dataset.mpv !== undefined) { const m = (meetingView(row, replay, material, extra).material || [])[+t.dataset.mpv]; if (m && m.preview) import('./premium-vw-copies.js').then((V) => V.openCopy({ ws: d.ws(), url: m.preview.url, kind: m.preview.kind, title: m.title, where: 'material for ' + row.title })); return; }
919
- if (t.dataset.rm !== undefined) { const it = ((material && material.items) || [])[+t.dataset.rm]; if (it) await removeItem(it); return; }
920
- if (t.dataset.task !== undefined) { t.disabled = true; await makeTask(+t.dataset.task); if (!ui.tasked.has(+t.dataset.task)) paint(); return; }
921
- if (t.id === 'mtgUndo') { const fn = undoFn; undoFn = null; if (fn) await fn(); return; }
922
- if (t.id !== 'mtgLink') return;
923
- const body = linkBody(row, $('#mtgSel').value, boards);
924
- if (!body) return;
925
- t.disabled = true;
926
- const res = await d.pmPost('/api/calendar-links', body);
927
- if (!res || res.ok !== true) { t.disabled = false; $('#mtgMsg').textContent = (res && res.error) || 'The link could not be saved.'; return; }
928
- saved = body.kind === 'none' ? '' : $('#mtgSel').selectedOptions[0].textContent; ui.about = false;
929
- d.toast(body.kind === 'none' ? 'The link is removed for every occurrence of this meeting.' : 'Linked. It applies to every occurrence of this meeting.');
930
- await readWeek(); paint(); if (other()) draw();
931
- };
932
- }
933
-
934
- /** A Today row: the week answer says which calendar event it is. With no match the page keeps the plain dialog. */
935
- async function openToday(e) {
936
- if (!W || W.state !== 'ok') await readWeek();
937
- const hit = W && W.state === 'ok' ? W.days.flatMap((x) => x.rows).find((r) => Date.parse(r.at) === e.at && r.title === clip(e.title, 120)) : null;
938
- if (!hit) return false;
939
- await openRow(hit, 'today');
940
- return true;
941
- }
942
-
943
- $('#wkStrip').addEventListener('click', (e) => { const b = e.target.closest('[data-day]'); if (!b || b.dataset.day === (picked || today())) return; picked = b.dataset.day; if (d.redraw) d.redraw(); });
944
- Promise.all([readWeek(), readItems()]).then(() => { if (d.redraw) d.redraw(); else drawStrip(); });
945
- $('#tl').addEventListener('click', (e) => { const b = e.target.closest('.ev[data-w]'); if (!b) return; e.stopImmediatePropagation(); const r = rowOf(b.dataset.w); if (r) openRow(r, 'week'); }, true);
946
- readNotes().then(() => mark());
947
- { const want = new URLSearchParams(location.search).get('meeting'); if (want) { history.replaceState(null, '', location.pathname + location.search.replace(/[?&]meeting=[^&]*/, '').replace(/^&/, '?')); setTimeout(() => openNote(want), 600); } }
948
- return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote, task: planTask, openRow: (row) => openRow(row, 'week') }; // openRow: the full calendar (premium-vw-cal.js)
458
+ readWeek().then(() => { if (d.redraw) d.redraw(); });
459
+ window.__premiumRec.today = async () => { if (!W || W.state !== 'ok') await readWeek(); return W && W.state === 'ok' ? W.days.flatMap((x) => x.rows).filter((r) => recordable(r)) : []; };
460
+ return { mode: () => 'today', draw: () => false, openToday, busy: () => busy, mark: () => {}, openNote, task, openRow, rec: C };
949
461
  }