create-pmos 0.397.0 → 0.398.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 (145) hide show
  1. package/package.json +13 -13
  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 +101 -52
  8. package/workspace/briefing-premium-board-test.js +252 -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 +86 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  13. package/workspace/briefing-premium-initiative-test.js +159 -296
  14. package/workspace/briefing-premium-insights-test.js +337 -219
  15. package/workspace/briefing-premium-metrics-test.js +53 -97
  16. package/workspace/briefing-premium-products-test.js +40 -27
  17. package/workspace/briefing-premium-sources-test.js +66 -48
  18. package/workspace/briefing-premium-test.js +150 -647
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +12 -0
  21. package/workspace/fixtures/board-premium-trail.js +32 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  23. package/workspace/guide/briefing-premium.md +3 -1
  24. package/workspace/guide/home.md +47 -0
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/lib/agent-roles.js +71 -0
  27. package/workspace/lib/board-premium.js +85 -19
  28. package/workspace/lib/board-trail.js +223 -0
  29. package/workspace/lib/home-work-item.js +58 -0
  30. package/workspace/lib/insights-goals.js +196 -0
  31. package/workspace/lib/insights-premium.js +62 -14
  32. package/workspace/lib/insights-records.js +101 -0
  33. package/workspace/lib/jira-tickets.js +1 -1
  34. package/workspace/lib/route-modules.js +4 -0
  35. package/workspace/lib/routes-board-trail.js +33 -0
  36. package/workspace/lib/routes-home-desk.js +176 -0
  37. package/workspace/lib/routes-insights-premium.js +12 -3
  38. package/workspace/lib/routes-insights-records.js +129 -0
  39. package/workspace/lib/routes-notes.js +1 -0
  40. package/workspace/lib/routes-viewer.js +108 -0
  41. package/workspace/lib/transcript-steps.js +123 -0
  42. package/workspace/lib/viewer-meeting.js +205 -0
  43. package/workspace/lib/viewer-report.js +89 -0
  44. package/workspace/package-lock.json +2 -2
  45. package/workspace/package.json +1 -1
  46. package/workspace/premium-board-actions-test.js +85 -75
  47. package/workspace/premium-briefing-depth-test.js +66 -53
  48. package/workspace/premium-chat-attach-test.js +54 -63
  49. package/workspace/premium-chat-chart-tab-test.js +35 -37
  50. package/workspace/premium-chat-context-test.js +19 -18
  51. package/workspace/premium-chat-goal-view-test.js +23 -23
  52. package/workspace/premium-chat-notes-test.js +26 -31
  53. package/workspace/premium-chat-report-tab-test.js +32 -28
  54. package/workspace/premium-chat-term-test.js +16 -16
  55. package/workspace/premium-chat-viewer-test.js +60 -59
  56. package/workspace/premium-core-doc-issue-test.js +50 -43
  57. package/workspace/premium-html-viewer-test.js +14 -17
  58. package/workspace/premium-phone-card-test.js +7 -2
  59. package/workspace/premium-phone-room-test.js +41 -35
  60. package/workspace/premium-report-read-test.js +115 -197
  61. package/workspace/premium-viewer-download-test.js +19 -22
  62. package/workspace/premium-viewer-flicker-test.js +11 -16
  63. package/workspace/premium-viewer-share-test.js +6 -9
  64. package/workspace/premium-viewer-test.js +41 -60
  65. package/workspace/premium-vw-backlog-test.js +53 -33
  66. package/workspace/premium-vw-cal-test.js +82 -128
  67. package/workspace/premium-vw-copy-test.js +17 -33
  68. package/workspace/premium-vw-doc-test.js +11 -10
  69. package/workspace/premium-vw-item-test.js +50 -49
  70. package/workspace/premium-vw-jira-test.js +53 -27
  71. package/workspace/premium-vw-meet-test.js +118 -187
  72. package/workspace/premium-vw-notes-test.js +85 -108
  73. package/workspace/premium-vw-rec-test.js +72 -194
  74. package/workspace/premium-vw-slides-test.js +46 -50
  75. package/workspace/premium-welcome-test.js +3 -2
  76. package/workspace/premium-work-depth-test.js +61 -53
  77. package/workspace/public/pm/bd-acts.js +305 -0
  78. package/workspace/public/pm/bd-span.js +186 -82
  79. package/workspace/public/pm/bd-stages.js +25 -11
  80. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  81. package/workspace/public/pm/c3-md.js +3 -395
  82. package/workspace/public/pm/c3-phone-detail.js +1 -1
  83. package/workspace/public/pm/c3-phone-model.js +3 -68
  84. package/workspace/public/pm/chat-term.js +3 -3
  85. package/workspace/public/pm/cozy-board.css +497 -230
  86. package/workspace/public/pm/cozy-home.css +570 -142
  87. package/workspace/public/pm/cozy-home.js +5 -3
  88. package/workspace/public/pm/cozy-insights.css +296 -167
  89. package/workspace/public/pm/cozy-md.js +396 -0
  90. package/workspace/public/pm/cozy-nav.js +17 -6
  91. package/workspace/public/pm/cozy-placeholder.js +26 -0
  92. package/workspace/public/pm/cozy-viewer.css +3 -3
  93. package/workspace/public/pm/cozy-viewer.js +144 -0
  94. package/workspace/public/pm/cozy-vw.css +485 -0
  95. package/workspace/public/pm/cozy.css +83 -1
  96. package/workspace/public/pm/home-adddoc.js +48 -0
  97. package/workspace/public/pm/home-app.js +905 -0
  98. package/workspace/public/pm/home-around.js +515 -0
  99. package/workspace/public/pm/home-chat.js +459 -0
  100. package/workspace/public/pm/home-data.js +312 -0
  101. package/workspace/public/pm/home-draft.js +68 -0
  102. package/workspace/public/pm/home-more.js +249 -0
  103. package/workspace/public/pm/home-phone-card.js +109 -0
  104. package/workspace/public/pm/home-work.js +519 -0
  105. package/workspace/public/pm/phone-moment.js +69 -0
  106. package/workspace/public/pm/pm-work-view.js +1 -1
  107. package/workspace/public/pm/premium-attach.js +4 -0
  108. package/workspace/public/pm/premium-board.js +423 -394
  109. package/workspace/public/pm/premium-chart-tab.js +110 -62
  110. package/workspace/public/pm/premium-deck.js +3 -3
  111. package/workspace/public/pm/premium-first.js +25 -21
  112. package/workspace/public/pm/premium-insights.js +792 -568
  113. package/workspace/public/pm/premium-meeting.js +61 -549
  114. package/workspace/public/pm/premium-notes.js +1 -1
  115. package/workspace/public/pm/premium-report-frame.css +20 -0
  116. package/workspace/public/pm/premium-report-read.js +509 -480
  117. package/workspace/public/pm/premium-report-tab.js +87 -63
  118. package/workspace/public/pm/premium-shell.js +72 -119
  119. package/workspace/public/pm/premium-viewer.js +22 -1
  120. package/workspace/public/pm/premium-vw-cal.js +187 -48
  121. package/workspace/public/pm/premium-vw-doc.css +6 -0
  122. package/workspace/public/pm/premium-vw-doc.js +40 -2
  123. package/workspace/public/pm/premium-vw-file.js +2 -2
  124. package/workspace/public/pm/premium-vw-meet.js +6 -83
  125. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  126. package/workspace/public/pm/premium-vw-notes.js +56 -69
  127. package/workspace/public/pm/premium-vw-open.js +35 -0
  128. package/workspace/public/pm/premium-vw-page.js +16 -0
  129. package/workspace/public/pm/premium-vw-rec.js +11 -218
  130. package/workspace/public/pm/premium-vw-slides.css +5 -0
  131. package/workspace/public/pm/premium-vw-slides.js +44 -8
  132. package/workspace/public/pm/term-view.js +22 -0
  133. package/workspace/public/premium-board.html +28 -70
  134. package/workspace/public/premium-initiative.html +8 -48
  135. package/workspace/public/premium-insights.html +22 -60
  136. package/workspace/public/premium-viewer.html +20 -0
  137. package/workspace/public/premium.html +16 -107
  138. package/workspace/server.js +18 -3
  139. package/workspace/test-files.json +1 -0
  140. package/workspace/test-lists/home-libs.json +9 -0
  141. package/workspace/test-lists/premium-report-read.json +1 -1
  142. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  143. package/workspace/test-lists/premium-vw-notes.json +1 -1
  144. package/workspace/public/pm/premium-work.js +0 -729
  145. package/workspace/public/pm/premium.js +0 -1146
@@ -1,4 +1,13 @@
1
- /* pm/premium-vw-cal.js — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8).
1
+ /* pm/premium-vw-cal.js — Calendar | Notes in the Viewer (initiative premium-agreed-design, area viewer; Main.dc.html viewer props cal and
2
+ * notelist), and the pure calendar model of the earlier grid (initiative premium-viewer, R8), kept for its suite.
3
+ * THE VIEW (openCalendar): one card with a Calendar | Notes switch and New note.
4
+ * Calendar Mon to Fri, each day with its load bar (meeting count) and its hours; the picked day's meetings and the untitled notes of that
5
+ * day, each with its status chip (Done, Next · 45 min, Recording, Not linked, Link it); the footer line. "Day, week and month"
6
+ * opens a plain list of any range (the design has none yet: it carries the Waiting for design marker).
7
+ * Notes the meeting notes grouped by initiative, a series as one row; search what was said (GET /api/notes/search).
8
+ * Reads GET /api/calendar-views (view=week, and day|week|month for the list), GET /api/notes, GET /api/notes/search. A meeting or a note opens
9
+ * the meeting card (premium-vw-mtg.js). New note starts an untitled note now (POST /api/notes/new) and records it.
10
+ * THE OLD GRID's pure half follows (calModel, calHtml, placeAll); the view no longer draws calHtml.
2
11
  * Reads GET /api/calendar-views?view=day|week|month&date=YYYY-MM-DD only, the same answer the console's Calendar draws (pm/calendar-views.js).
3
12
  * Meetings come from the answer's cells; the all-day row also carries the answer's dated layers (an initiative's promised date, a plan item,
4
13
  * a release, a report, your own due items). Nothing is invented: a range with no meeting says so, and a calendar that did not answer says why.
@@ -9,7 +18,11 @@
9
18
  * or one tied to no initiative, prep or record) drawn muted. A week is at least 620px wide and scrolls sideways in a narrower pane.
10
19
  * calModel(r, view, date, today) pure · calHtml(M, esc) pure · mountCal(el, st, d) · openCalendar(d, st?) */
11
20
  import { weekView } from './premium-meeting.js';
12
- import { vwOpen, vwShow, vwStyle } from './premium-viewer.js';
21
+ import { open as vOpen, current as vCur } from './cozy-viewer.js';
22
+ import { placeholderHtml } from './cozy-placeholder.js';
23
+ import { pmGet } from './http.js';
24
+ import { notesGroups } from './premium-vw-notes.js';
25
+ import './premium-vw-open.js'; // registers window.czViews
13
26
 
14
27
  export const VIEWS = [['day', 'Day'], ['week', 'Week'], ['month', 'Month']];
15
28
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -158,61 +171,187 @@ export function placeAll(el) {
158
171
  });
159
172
  }
160
173
 
161
- const S = new WeakMap(); // host -> { st, M, seq }
174
+ /* ── the view (pure half) ─────────────────────────────────────────────────────────────────────────────────────── */
175
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
176
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
177
+ const hmOf = (iso) => { const t = new Date(iso); return Number.isFinite(t.getTime()) ? pad(t.getHours()) + ':' + pad(t.getMinutes()) : ''; };
178
+ const localKey = (iso) => { const t = new Date(iso); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
179
+ const hrsText = (min) => (!min ? '' : min < 60 ? min + ' min' : (Math.round(min / 6) / 10) + ' h');
180
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many || one + 's');
181
+ export const CAL_FOOT = 'From your calendar. PMOS never writes to it. A meeting with no initiative stays Not linked until you link it.';
182
+ export const NEW_NOTE_TIP = 'Starts an untitled note now. It needs no calendar event; link it to an initiative later.';
183
+ export const SEARCH_HINT = 'Search notes and what was said';
184
+ const sameEv = (m, row) => !!m && m.kind === 'event' && ((m.event_id && row.id && m.event_id === row.id) || (Date.parse(m.start) === Date.parse(row.at) && String(m.title || '').toLowerCase().trim() === String(row.title || '').toLowerCase().trim()));
162
185
 
163
- /** Draws the grid in `el` and keeps it live. st = { view, date }. d = { pmGet, esc, ws(), openRow(row) } */
164
- export function mountCal(el, st, d) {
165
- vwStyle('cal');
166
- const me = { st: { view: (st && st.view) || 'week', date: (st && st.date) || todayKey() }, M: null, seq: 0 };
167
- S.set(el, me); el.classList.add('vc');
168
- const nowMin = () => { const t = new Date(); return t.getHours() * 60 + t.getMinutes(); };
169
- const paint = () => { el.innerHTML = me.M ? calHtml(me.M, d.esc, nowMin()) : `<div class="vc-w"><p class="vc-empty" role="status">Reading the calendar PMOS holds.</p></div>`; placeAll(el); };
170
- const read = async () => {
171
- const n = ++me.seq, { view, date } = me.st, w = d.ws && d.ws();
172
- const res = await d.pmGet(`/api/calendar-views?view=${view}&date=${date}${w ? '&ws=' + encodeURIComponent(w) : ''}`);
173
- if (n !== me.seq || !el.isConnected) return;
174
- me.M = calModel(res, view, date, todayKey()); paint();
175
- };
176
- const go = (view, date, focus) => { me.st = { view, date }; read().then(() => { if (!focus) return; const b = el.querySelector(focus); if (b) b.focus(); }); };
177
- el.onclick = (e) => { // delegated: every control of the grid is a button inside el
178
- const b = e.target.closest('button'); if (!b || !el.contains(b)) return;
179
- if (b.dataset.cv) return go(b.dataset.cv, me.st.date, `[data-cv="${b.dataset.cv}"]`);
180
- if (b.dataset.cn != null) { const dir = +b.dataset.cn; return go(me.st.view, dir ? shift(me.st.view, me.st.date, dir) : todayKey(), `[data-cn="${b.dataset.cn}"]`); }
181
- if (b.dataset.day) return go('day', b.dataset.day, '[data-cv="day"]');
182
- if (b.dataset.ev) {
183
- const [k, i] = b.dataset.ev.split('|'), x = me.M && me.M.days.find((y) => y.key === k);
184
- const hit = x && [...x.timed, ...x.allday].find((y) => y.ref === k + '|' + i);
185
- if (hit && hit.row && d.openRow) d.openRow(hit.row, { ...me.st });
186
+ /** Monday to Friday of the week answer (weekView W), with the day `picked` pressed. A day's bar is its meeting count; its line is "done" for a
187
+ * past day with meetings, else its meeting hours, and "today". */
188
+ export function stripModel(W, picked, today) {
189
+ const keys = (() => { const [y, m, d] = parts(today), w0 = (new Date(Date.UTC(y, m - 1, d)).getUTCDay() + 6) % 7; return [0, 1, 2, 3, 4].map((i) => keyOf(new Date(Date.UTC(y, m - 1, d - w0 + i)))); })();
190
+ const ok = !!(W && W.state === 'ok');
191
+ return keys.map((k) => {
192
+ const rows = ok ? ((W.days.find((x) => x.key === k) || {}).rows || []) : [];
193
+ const min = rows.reduce((a, r) => { const v = hasTime(r.at) && hasTime(r.end) ? Math.round((Date.parse(r.end) - Date.parse(r.at)) / 60000) : 0; return a + (v > 0 && v < 1440 ? v : 0); }, 0);
194
+ const past = k < today, now = k === today;
195
+ return { key: k, dow: DOW[wd(k)].toUpperCase(), n: parts(k)[2], count: rows.length, on: k === picked, today: now,
196
+ bar: rows.length ? Math.min(1, 0.35 + rows.length * 0.22) : 0,
197
+ sub: [past && rows.length ? 'done' : hrsText(min), now ? 'today' : ''].filter(Boolean).join(' · ') };
198
+ });
199
+ }
200
+ /** The picked day's entries: its meetings from the week answer and the notes of that day with no calendar event. notes = GET /api/notes rows. */
201
+ export function dayModel(W, notes, picked, today, now = Date.now()) {
202
+ const day = W && W.state === 'ok' ? W.days.find((x) => x.key === picked) : null;
203
+ const rows = day ? day.rows : [];
204
+ const N = Array.isArray(notes) ? notes : [];
205
+ let nextDone = false;
206
+ const ents = rows.map((r) => {
207
+ const n = N.filter((x) => sameEv(x.meeting, r)).sort((a, b) => String(b.updated_at || '').localeCompare(String(a.updated_at || '')))[0] || null;
208
+ const at = Date.parse(r.at), end = Date.parse(r.end), linked = !!r.about;
209
+ const about = r.level ? (r.level.kind === 'portfolio' ? 'Portfolio' : clip(r.level.name || r.level.id, 50)) : (n && n.initiative && n.initiative.id ? clip(n.initiative.title || n.initiative.id, 50) : '');
210
+ let chip = '', k = '', next = false;
211
+ if (n && (n.state === 'recording' || n.state === 'paused')) { chip = n.state === 'paused' ? 'Paused' : 'Recording'; k = 'rec'; }
212
+ else if (n && n.state === 'ended') { chip = 'Done'; k = 'ok'; }
213
+ else if (picked === today && hasTime(r.at) && at > now && !nextDone) { nextDone = true; next = true; const m = Math.max(1, Math.round((at - now) / 60000)); chip = 'Next · ' + (m < 60 ? m + ' min' : Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '')); k = 'warn'; }
214
+ else if (!about) chip = 'Not linked';
215
+ else if (picked > today) chip = DOW[wd(picked)];
216
+ else if (Number.isFinite(end) && end < now) chip = 'Ended';
217
+ else chip = hasTime(r.at) ? 'Today' : 'All day';
218
+ const status = n && n.state === 'ended' ? 'notes ready' : n && (n.state === 'recording' || n.state === 'paused') ? 'recording' : '';
219
+ const who = (r.who || []).slice(0, 3).join(', ') + ((r.who || []).length > 3 ? ' and ' + ((r.who || []).length - 3) + ' more' : '');
220
+ return { kind: 'event', t: Number.isFinite(at) ? at : 0, time: hasTime(r.at) ? hmOf(r.at) : 'All day', title: r.title, sub: [about || 'Not linked', who, status].filter(Boolean).join(' · '), chip, k, next, linked: !!about || linked, row: r, note: n ? n.id : '' };
221
+ });
222
+ for (const n of N) {
223
+ const m = n.meeting;
224
+ if (m && m.kind === 'event') continue;
225
+ const s = (m && m.start) || n.recorded_from || n.created_at; if (!s || localKey(s) !== picked) continue;
226
+ const ini = n.initiative && n.initiative.id ? clip(n.initiative.title || n.initiative.id, 50) : '';
227
+ const len = n.meeting_ms >= 60000 ? Math.round(n.meeting_ms / 60000) + ' min' : '';
228
+ const live = n.state === 'recording' || n.state === 'paused';
229
+ ents.push({ kind: 'note', t: Date.parse(s) || 0, time: hmOf(s), title: clip(n.title || 'Untitled note', 120), sub: ['Recorded without a calendar event', len, ini || 'not linked'].filter(Boolean).join(' · '),
230
+ chip: live ? (n.state === 'paused' ? 'Paused' : 'Recording') : ini ? (n.state === 'ended' ? 'Done' : 'Note') : 'Link it', k: live ? 'rec' : ini && n.state === 'ended' ? 'ok' : '', next: false, linked: !!ini, note: n.id });
231
+ }
232
+ ents.sort((a, b) => a.t - b.t);
233
+ const [, m, d] = parts(picked);
234
+ const label = DOW[wd(picked)] + ' ' + d + ' ' + MON[m - 1];
235
+ return { title: picked === today ? 'Today, ' + label : label, sub: ents.length ? plural(ents.length, 'entry', 'entries') : 'No meetings', rows: ents, state: W && W.state === 'error' ? 'error' : 'ok', reason: W && W.reason };
236
+ }
237
+ const chipHtml = (c, k) => `<span class="vz-cc" data-k="${k || ''}">${esc(c)}</span>`;
238
+ /** The card's body. st = { tab, picked, q, searching, more: { view, date, M } | null }. */
239
+ export function calViewHtml(st, X) {
240
+ const h = [];
241
+ h.push(`<div class="vz-r1"><div class="vz-seg" role="tablist" aria-label="Meetings">${[['cal', 'Calendar'], ['notes', 'Notes']].map(([k, l]) => `<button type="button" role="tab" aria-selected="${st.tab === k}" data-c="tab" data-k="${k}">${l}</button>`).join('')}</div><span class="vz-sp"></span><button type="button" class="vz-new vz-hv" data-c="new" title="${esc(NEW_NOTE_TIP)}"><i aria-hidden="true"></i>New note</button></div>`);
242
+ if (X.msg) h.push(`<p class="vz-msg" role="status" data-tone="${X.msg.tone || ''}">${esc(X.msg.text)}</p>`);
243
+ if (st.tab === 'cal') {
244
+ const S = X.strip || [], D = X.day;
245
+ h.push(`<div class="vz-days" role="group" aria-label="This week">${S.map((d) => `<button type="button" class="vz-day vz-hv" aria-pressed="${d.on}" data-c="day" data-k="${d.key}" aria-label="${esc(d.dow + ' ' + d.n + (d.today ? ', today' : '') + ': ' + plural(d.count, 'meeting'))}"><span>${d.dow}</span><b>${d.n}</b><i aria-hidden="true"${d.count ? ` data-on="${Math.min(3, d.count)}"` : ''}></i><small>${esc(d.sub || ' ')}</small></button>`).join('')}</div>`);
246
+ if (!D) h.push('<p class="vz-empty" role="status">Reading the calendar PMOS holds.</p>');
247
+ else if (D.state === 'error') h.push(`<p class="vz-empty" role="status">The calendar was not read. ${esc(D.reason || '')}</p>`);
248
+ else {
249
+ h.push(`<h3>${esc(D.title)} <small>${esc(D.sub)}</small></h3>`);
250
+ D.rows.forEach((r, i) => h.push(`<button type="button" class="vz-row vz-hv" data-c="open" data-i="${i}"${r.next ? ' data-next' : ''}><time>${esc(r.time)}</time><span><b>${esc(r.title)}</b><small>${esc(r.sub)}</small></span>${r.chip === 'Link it' || r.chip === 'Not linked' ? `<span class="vz-cc" data-c="link" data-i="${i}" role="button" tabindex="0" title="Link it to an initiative">${esc(r.chip)}</span>` : chipHtml(r.chip, r.k)}</button>`));
186
251
  }
187
- };
188
- paint(); read();
189
- return { state: () => ({ ...me.st }), reload: read };
252
+ h.push(`<p class="vz-note">${esc(CAL_FOOT)}</p>`);
253
+ h.push(`<div class="vz-more2"><div class="vz-r1"><button type="button" class="vz-link vz-hv" data-c="more" aria-expanded="${!!st.more}">Day, week and month</button>${st.more ? `<span class="vz-wait" data-cz-placeholder="Day/Week/Month calendar">Waiting for design</span>` : ''}</div>${st.more ? moreHtml(st.more) : ''}</div>`);
254
+ } else {
255
+ h.push(`<input type="search" class="vz-search" data-c="q" aria-label="${esc(SEARCH_HINT)}" placeholder="${esc(SEARCH_HINT)}" value="${esc(st.q || '')}">`);
256
+ const G = X.groups;
257
+ if (!G) h.push('<p class="vz-empty" role="status">Reading the notes.</p>');
258
+ else if (G.state === 'error') h.push(`<p class="vz-empty" role="status">The notes could not be read. ${esc(G.error)}</p>`);
259
+ else if (!G.total) h.push('<p class="vz-empty">No notes yet. Notes you record show here, grouped by initiative.</p>');
260
+ else if (!G.groups.length) h.push(`<p class="vz-empty" role="status">${st.searching ? 'Searching what was said.' : 'No note matches “' + esc(st.q) + '”.'}</p>`);
261
+ else G.groups.forEach((g, gi) => h.push(`<section class="vz-grp"><h3>${esc(g.title)} <small>${esc(g.n)}</small></h3>${g.rows.map((r, ri) => `<button type="button" class="vz-row vz-sm vz-hv" data-c="note" data-id="${esc(r.id)}"${r.series ? ` data-series="${esc(r.series)}"` : ''}><span><b>${esc(r.title)}</b><small>${esc(r.sub)}</small></span>${chipHtml(r.chip, r.k)}</button>`).join('')}</section>`));
262
+ }
263
+ return `<div class="vz vz-cal" data-tab="${st.tab}">${h.join('')}</div>`;
264
+ }
265
+ function moreHtml(M0) {
266
+ const M = M0.M;
267
+ const seg = `<div class="vz-r1"><div class="vz-seg" role="group" aria-label="Range">${VIEWS.map(([k, l]) => `<button type="button" aria-pressed="${M0.view === k}" data-c="mv" data-k="${k}">${l}</button>`).join('')}</div><span class="vz-sp"></span><button type="button" class="vz-ib vz-small vz-hv" data-c="mn" data-k="-1" aria-label="Before"><svg viewBox="0 0 24 24" width="14" height="14"><path d="M15 6l-6 6 6 6"/></svg></button><button type="button" class="vz-link vz-hv" data-c="mn" data-k="0">Today</button><button type="button" class="vz-ib vz-small vz-hv" data-c="mn" data-k="1" aria-label="After"><svg viewBox="0 0 24 24" width="14" height="14"><path d="M9 6l6 6-6 6"/></svg></button></div>`;
268
+ if (!M) return seg + '<p class="vz-empty" role="status">Reading the calendar.</p>';
269
+ if (M.state !== 'ok') return seg + `<p class="vz-empty">The calendar was not read. ${esc(M.reason || '')}</p>`;
270
+ const days = M.days.filter((d) => d.inRange && d.meetings);
271
+ return seg + `<h3>${esc(M.title)} <small>${esc(M.caption)}</small></h3>` + (days.length ? days.map((d) => `<p class="vz-dayh">${esc(d.label)}${d.today ? ' · today' : ''}</p>` + [...d.timed, ...d.allday.filter((x) => x.row)].map((x) => `<button type="button" class="vz-row vz-sm vz-hv" data-c="mrow" data-ref="${esc(x.ref)}"><time>${esc(x.time ? x.time.slice(0, 5) : 'All day')}</time><span><b>${esc(x.title)}</b><small>${esc([x.about, x.sub].filter(Boolean).join(' · '))}</small></span></button>`).join('')).join('') : `<p class="vz-empty">${esc(M.empty || 'No meetings.')}</p>`);
190
272
  }
191
273
 
192
- /** The calendar on its own: a dialog whose detail is the grid. d = { openDlg, setMode, turnA, ptx, $, pmGet, esc, ws(), openRow(row) } where openRow
193
- * opens the meeting dialog. After a meeting opens, the grid comes back as a tab beside it at the same view and date. */
194
- export function openCalendar(d, st) {
195
- const open = (row, at) => {
196
- d.openRow(row); // openDlg runs at once inside, so the tab below belongs to the meeting's dialog
197
- vwOpen({ id: 'cal', title: 'Calendar', icon: 'cal', render: (el) => { el.classList.add('vc'); mountCal(el, at, { ...d, openRow: open }); } });
198
- vwShow('main');
199
- };
200
- d.openDlg({ eye: 'Calendar · real data', title: 'Calendar', stream: d.turnA(d.ptx('This is the calendar PMOS holds. Press a meeting to open its detail; the calendar stays as a tab beside it.')),
201
- pane: '<div class="vc" id="vcMain"></div>', label: 'Calendar' });
202
- const f = d.$('#askF'); if (f) f.hidden = true;
203
- if (d.setMode) d.setMode('detail'); // the grid takes the whole dialog; the dialog's own button brings the conversation back
204
- return mountCal(d.$('#vcMain'), st || { view: 'week', date: todayKey() }, { ...d, openRow: open });
274
+ /* ── the view (page half) ─────────────────────────────────────────────────────────────────────────────────────── */
275
+ let CV = null;
276
+ export function calendarUrl(tab, ws) { return '/premium-viewer.html?' + ['open=' + (tab === 'notes' ? 'notes' : 'calendar'), ws ? 'ws=' + encodeURIComponent(ws) : ''].filter(Boolean).join('&'); }
277
+ /** Opens Calendar | Notes in the Viewer. o = { ws, tab: 'cal' | 'notes', date, view, initiative } */
278
+ export function openCalendar(o = {}) {
279
+ if (o && (o.openDlg || o.$)) o = {}; // an old caller passed the shell's deps
280
+ const today = todayKey();
281
+ const me = CV = { ws: o.ws || new URLSearchParams(location.search).get('ws') || '', st: { tab: o.tab === 'notes' ? 'notes' : 'cal', picked: o.date && /^\d{4}-\d{2}-\d{2}$/.test(o.date) ? o.date : today, q: '', more: o.view && o.view !== 'day' ? { view: o.view, date: today, M: null } : null }, X: {}, today, seq: 0, initiative: o.initiative || '' };
282
+ vOpen({ id: 'calendar', kind: 'Meetings', title: 'Calendar and notes', icon: 'cal', url: calendarUrl(me.st.tab, me.ws), render: (b) => paintCal(me, b), onClose: () => { if (CV === me) CV = null; } });
283
+ readCal(me);
284
+ if (me.st.more) readMore(me);
285
+ return me;
286
+ }
287
+ export const openNotesTab = (o = {}) => openCalendar({ ...o, tab: 'notes' });
288
+ const calBody = (me) => (CV === me && vCur() && vCur().id === 'calendar' ? document.querySelector('#czViewer .cz-vw-body') : null);
289
+ function paintCal(me, b) {
290
+ const body = b || calBody(me); if (!body) return;
291
+ const keep = document.activeElement && document.activeElement.dataset && document.activeElement.dataset.c === 'q' ? document.activeElement.selectionStart : null;
292
+ me.X.strip = stripModel(me.W, me.st.picked, me.today);
293
+ me.X.day = me.W ? dayModel(me.W, me.notes, me.st.picked, me.today) : null;
294
+ body.innerHTML = calViewHtml(me.st, me.X);
295
+ if (keep != null) { const i = body.querySelector('[data-c="q"]'); if (i) { i.focus(); i.setSelectionRange(keep, keep); } }
296
+ body.onclick = (e) => calPress(me, e);
297
+ body.oninput = (e) => { if (e.target.dataset.c === 'q') search(me, e.target.value); };
298
+ body.onkeydown = (e) => { if ((e.key === 'Enter' || e.key === ' ') && e.target.dataset.c === 'link') { e.preventDefault(); calPress(me, e); } };
299
+ }
300
+ async function readCal(me) {
301
+ const wsq = me.ws ? '&ws=' + encodeURIComponent(me.ws) : '';
302
+ const weekOfPicked = me.st.picked;
303
+ const [w, n] = await Promise.all([pmGet('/api/calendar-views?view=week&date=' + weekOfPicked + wsq), pmGet('/api/notes')]);
304
+ if (CV !== me) return;
305
+ me.W = weekView(w, me.today); me.notesAnswer = n; me.notes = n && n.ok ? n.notes || [] : [];
306
+ me.X.groups = notesGroups(n, { q: me.st.q, found: me.found, initiative: me.initiative });
307
+ paintCal(me);
308
+ }
309
+ async function readMore(me) {
310
+ const m = me.st.more; if (!m) return;
311
+ const wsq = me.ws ? '&ws=' + encodeURIComponent(me.ws) : '';
312
+ const r = await pmGet('/api/calendar-views?view=' + m.view + '&date=' + m.date + wsq);
313
+ if (CV !== me || me.st.more !== m) return;
314
+ m.M = calModel(r, m.view, m.date, me.today); paintCal(me);
315
+ }
316
+ let searchT = null;
317
+ function search(me, v) {
318
+ me.st.q = v; clearTimeout(searchT);
319
+ me.found = null; me.st.searching = String(v).trim().length >= 2;
320
+ me.X.groups = notesGroups(me.notesAnswer, { q: v, found: null, initiative: me.initiative }); paintCal(me);
321
+ if (!me.st.searching) return;
322
+ searchT = setTimeout(async () => {
323
+ const r = await pmGet('/api/notes/search?q=' + encodeURIComponent(v.trim()));
324
+ if (CV !== me || me.st.q !== v) return;
325
+ me.found = new Set(r && r.ok && Array.isArray(r.ids) ? r.ids : []); me.st.searching = false;
326
+ me.X.groups = notesGroups(me.notesAnswer, { q: v, found: me.found, initiative: me.initiative }); paintCal(me);
327
+ }, 250);
328
+ }
329
+ const mtg = () => import('./premium-vw-mtg.js');
330
+ async function calPress(me, e) {
331
+ const t = e.target.closest('[data-c]'); if (!t) return;
332
+ const c = t.dataset.c, D = me.X.day;
333
+ if (c === 'tab') { me.st.tab = t.dataset.k; return paintCal(me); }
334
+ if (c === 'day') { const was = me.st.picked; me.st.picked = t.dataset.k; paintCal(me); if (me.W && !me.W.days.some((d) => d.key === t.dataset.k) && was !== t.dataset.k) readCal(me); return; }
335
+ if (c === 'new') { t.disabled = true; const M = await mtg(); const r = await M.newNote(me.ws); if (r && !r.ok) { me.X.msg = { text: r.error, tone: 'bad' }; t.disabled = false; paintCal(me); } return; }
336
+ if (c === 'link') { e.stopPropagation(); const r = D && D.rows[+t.dataset.i]; if (!r) return; const M = await mtg(); await M.openMeeting(r.note ? { note: r.note } : r.row, { ws: me.ws, about: true }); return; }
337
+ if (c === 'open') { const r = D && D.rows[+t.dataset.i]; if (!r) return; const M = await mtg(); return M.openMeeting(r.note && r.kind === 'note' ? { note: r.note } : r.row, { ws: me.ws }); }
338
+ if (c === 'note') { const M = await mtg(); return M.openMeeting({ note: t.dataset.id }, { ws: me.ws }); }
339
+ if (c === 'more') { me.st.more = me.st.more ? null : { view: 'week', date: me.today, M: null }; paintCal(me); return readMore(me); }
340
+ if (c === 'mv') { me.st.more = { view: t.dataset.k, date: me.st.more.date, M: null }; paintCal(me); return readMore(me); }
341
+ if (c === 'mn') { const m = me.st.more, dir = +t.dataset.k; me.st.more = { view: m.view, date: dir ? shift(m.view, m.date, dir) : me.today, M: null }; paintCal(me); return readMore(me); }
342
+ if (c === 'mrow') { const M0 = me.st.more && me.st.more.M; const [k] = t.dataset.ref.split('|'); const d = M0 && M0.days.find((x) => x.key === k); const hit = d && [...d.timed, ...d.allday].find((x) => x.ref === t.dataset.ref); if (hit && hit.row) { const M = await mtg(); return M.openMeeting(hit.row, { ws: me.ws }); } }
205
343
  }
206
344
 
207
- /** The Briefing's Calendar card gets a button that opens the full calendar. */
345
+ /** Kept for Home's old Calendar card: a button that opens Calendar | Notes. Nothing is drawn when the card is not on the page. */
208
346
  export function mountCalEntry(card, d) {
209
347
  if (!card || card.querySelector('.vc-open')) return;
210
- vwStyle('cal');
211
348
  const b = document.createElement('button'); b.type = 'button'; b.className = 'vc-open'; b.setAttribute('aria-label', 'Open the calendar'); b.title = 'Open the calendar';
212
- b.innerHTML = '<svg class="i" viewBox="0 0 24 24"><path d="M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7"/></svg><span>Full calendar</span>';
213
- const h = card.querySelector('.ch'), menu = card.querySelector('#calMenu'), fold = h && h.querySelector('.foldb');
214
- if (menu) menu.append(b); else if (fold) fold.before(b); else if (h) h.append(b); // in the header's ⋯ menu (premium-calmer-first-screen)
215
- b.onclick = () => openCalendar(d);
349
+ b.innerHTML = '<span>Calendar</span>';
350
+ const h = card.querySelector('.ch'), menu = card.querySelector('#calMenu');
351
+ if (menu) menu.append(b); else if (h) h.append(b); else card.append(b);
352
+ b.onclick = () => openCalendar({ ws: d && d.ws ? d.ws() : '' });
216
353
  }
354
+ /** The earlier grid's mount is the plain list now (no old layout). Kept so an old caller gets the view. */
355
+ export function mountCal(el, st) { return openCalendar({ view: st && st.view, date: st && st.date }); }
217
356
 
218
357
  if (typeof window !== 'undefined') window.__premiumCal = { calModel, openCalendar };
@@ -227,3 +227,9 @@ iframe.vwprint{position:fixed;right:0;bottom:0;width:1px;height:1px;border:0;opa
227
227
  .vwsm,.vwsrow2,.vwsoff,.vwshp .vwseg,.vwsgo{min-height:44px}.vwsw{width:48px;height:30px}.vwsw::after{width:22px;height:22px}.vwsw[aria-checked="true"]::after{left:23px}
228
228
  }
229
229
  @media (prefers-reduced-motion:reduce){.vwsw::after{transition:none}}
230
+ /* The Edit log and Proposals under the page: a plain minimal section until the Agreed design draws them (initiative premium-agreed-design) */
231
+ .vwside{display:grid;gap:8px;margin:18px 0 0;padding:14px 0 0;border-top:1px solid var(--hair)}
232
+ .vwside .vwmp{display:grid;gap:8px}
233
+ .vwprop{display:grid;gap:4px;padding:10px 12px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid)}
234
+ .vwprop>p{margin:0}
235
+ .vwside .evl{display:grid;gap:4px}
@@ -7,7 +7,7 @@
7
7
  import { pmPost } from './http.js';
8
8
  import { vwOpen, vwStyle, vwConfirm } from './premium-viewer.js';
9
9
  import { $, $$, esc, toast, AI, CHECK } from './premium-shell.js';
10
- import { editBody, acceptBody, rejectBody, askBody, askLine, relationsOf, copyKindOf, copyView } from './premium-doc-edit.js';
10
+ import { editBody, acceptBody, rejectBody, askBody, askLine, relationsOf, copyKindOf, copyView, proposalsModel } from './premium-doc-edit.js';
11
11
  import { bodyHtml, pageHead, propHtml, splitDoc, overlay, overlayLine, mergeEdit, readMinutes, dayOf, PANELS } from './premium-vw-doc-model.js';
12
12
 
13
13
  const I = (d) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${d}</svg>`;
@@ -230,6 +230,28 @@ function makePage(d, ctx) {
230
230
  + `<p class="vwerr" id="vwErr" role="alert">${esc(P.msg)}</p><div class="vwrow"><span class="vwmut" id="vwSv">${P.mode === 'edit' ? 'Type straight into the page. Press / for a block.' : 'The file as it is on disk.'}</span>`
231
231
  + `<button type="button" class="vwbtn" data-vd="cancel">Cancel</button><button type="button" class="vwbtn pri" data-vd="save"${P.busy ? ' disabled' : ''}>Save as v${v() + 1}</button></div></div>`;
232
232
  }
233
+ /** The Edit log and the Proposals list under the page. The Agreed design does not draw them yet, so this is a plain minimal section with a
234
+ * "Waiting for design" marker (initiative premium-agreed-design). Each revision shows its reason; each proposal shows who asked, the request, each
235
+ * section, and Accept (only the sections still current) or Reject (with a reason). Closed proposals keep their state and reason. */
236
+ function sideHtml() {
237
+ if (ctx.host) return '';
238
+ const m = proposalsModel(P.props), revs = (P.log && P.log.revisions) || [];
239
+ const tab = (k, label, n) => `<button type="button" class="vwbtn" data-vd="side:${k}" aria-expanded="${P.side === k}">${label}${n ? ` <em>${n}</em>` : ''}</button>`;
240
+ const one = (p) => {
241
+ const secs = p.sections.map((x) => `<p class="vwmut"><b>${esc(x.name)}</b> ${x.kind === 'removed' ? esc(x.add) : '+ ' + esc(x.add)}${x.stale ? ' · Changed since this was proposed' : ''}</p>`).join('');
242
+ const acts = p.open ? `<div class="vwrow">${p.canAccept ? `<button type="button" class="vwbtn pri" data-vd="pacc:${esc(p.id)}"${P.busy ? ' disabled' : ''}>Accept</button>` : ''}<button type="button" class="vwbtn" data-vd="prej:${esc(p.id)}"${P.busy ? ' disabled' : ''}>Reject</button></div>`
243
+ + (P.rej === p.id ? `<div class="vwrow"><input id="vwRj" class="vwin" placeholder="Why are you rejecting it? Kept in the Edit log." aria-label="Why are you rejecting it" value="${esc(P.rejWhy || '')}"><button type="button" class="vwbtn pri" data-vd="prejgo:${esc(p.id)}"${P.busy ? ' disabled' : ''}>Reject it</button><button type="button" class="vwbtn" data-vd="prejno">Cancel</button></div>` : '') : '';
244
+ return `<div class="vwprop ${esc(p.state)}" data-prop="${esc(p.id)}"><p><b>${esc(p.who)}</b> ${esc(p.request)}${p.open ? '' : ` · <em>${esc(p.label)}</em>${p.why ? ' · ' + esc(p.why) : ''}`}</p>${secs}`
245
+ + (p.staleAll ? '<p class="vwmut">The document changed since this was proposed, so it cannot be accepted. Ask again.</p>' : '') + acts + '</div>';
246
+ };
247
+ const body = P.side === 'log'
248
+ ? (revs.length ? `<div class="evl">${revs.slice().reverse().map((r) => `<p class="vwmut"><b>v${esc(r.rev)}</b> ${esc(r.why || (r.by === 'baseline' ? 'The file as the sheet first saw it' : 'No reason recorded'))} · ${esc(whoOf(r))}${r.at ? ' · ' + esc(dayOf(r.at)) : ''}</p>`).join('')}</div>` : '<p class="vwmut">No revision is recorded.</p>')
249
+ : P.side === 'props'
250
+ ? `<p class="vwlab">Open proposals · ${m.count}</p>${m.open.length ? m.open.map(one).join('') : '<p class="vwmut">No open proposals.</p>'}${m.closed.length ? `<p class="vwlab">Closed · ${m.closed.length}</p>${m.closed.map(one).join('')}` : ''}`
251
+ : '';
252
+ return `<section class="vwside" aria-label="Edit log and proposals"><p class="hx-wait"><i aria-hidden="true"></i>Waiting for design</p><div class="vwrow">${tab('log', 'Edit log')}${tab('props', 'Proposals', m.count)}</div>`
253
+ + `<p class="vwerr" id="vwSideErr" role="alert">${esc(P.sideErr || '')}</p>${body ? `<div class="vwmp" role="region" aria-label="${P.side === 'log' ? 'Edit log' : 'Proposals'}">${body}</div>` : ''}</section>`;
254
+ }
233
255
  function pageHtml() {
234
256
  if (P.err) return `<p class="vwempty">${esc(P.err)}</p>`;
235
257
  if (P.text == null) return '<p class="vwempty">Reading the file.</p>';
@@ -241,7 +263,7 @@ function makePage(d, ctx) {
241
263
  return toolsHtml(p) + (P.mode === 'read' ? moreBar() : '') + unsaved + agentBar(p, o) + (P.mode === 'edit' ? editBar() : '')
242
264
  + `<article class="cf${P.mode === 'edit' ? ' editing' : ''}">${headHtml(h)}<div class="cfb"${P.mode === 'edit' ? ' contenteditable="true" spellcheck="true" aria-label="The page" role="textbox" aria-multiline="true"' : ''}>${body || '<p class="vwmut">The file has no text yet.</p>'}</div>`
243
265
  + `<footer class="cff"><span>${v() ? 'v' + v() + (p ? ' · edited by the agent, not kept yet' : '') : ''}</span><span class="gap"></span><code>${esc(d.path)}</code></footer></article>`
244
- + (P.mode === 'edit' ? saveRow() : '');
266
+ + (P.mode === 'edit' ? saveRow() : '') + (P.mode === 'read' ? sideHtml() : '');
245
267
  }
246
268
  function draw() {
247
269
  if (!el || !el.isConnected) return;
@@ -382,6 +404,21 @@ function makePage(d, ctx) {
382
404
  if (!res || res.ok !== true || !res.id) { P.ask = { state: 'failed', error: (res && res.error) || 'The agent could not be asked.' }; draw(); return; }
383
405
  P.askText = ''; P.askOpen = false; P.ask = { state: 'working', id: res.id }; draw(); pollAsk(res.id); return;
384
406
  }
407
+ if (k === 'side') { P.side = P.side === arg ? null : arg; P.sideErr = ''; draw(); return; }
408
+ if (k === 'prejno') { P.rej = null; P.rejWhy = ''; P.sideErr = ''; draw(); return; }
409
+ if (k === 'prej') { P.rej = arg; P.rejWhy = ''; P.sideErr = ''; draw(); const f = $('#vwRj', el); if (f) f.focus(); return; }
410
+ if (k === 'pacc' || k === 'prejgo') {
411
+ const raw = (P.props || []).find((x) => x.id === arg); if (!raw) return;
412
+ const r = k === 'pacc' ? acceptBody(d.path, raw, raw.sections.filter((x) => !x.stale).map((x) => x.name)) : rejectBody(d.path, raw, ($('#vwRj', el) || {}).value || P.rejWhy);
413
+ if (r.error) { P.sideErr = r.error; draw(); return; }
414
+ P.busy = true; P.sideErr = ''; draw();
415
+ const res = await pmPost('/api/doc-sheet/' + (k === 'pacc' ? 'accept' : 'reject') + (ws() ? '?ws=' + encodeURIComponent(ws()) : ''), r.body).catch(() => null);
416
+ P.busy = false;
417
+ if (!res || res.ok !== true) { P.sideErr = (res && res.error) || (k === 'pacc' ? 'The proposal could not be accepted.' : 'The proposal could not be rejected.'); await load(); return; }
418
+ P.rej = null; P.rejWhy = ''; P.kept = null; P.pop = null;
419
+ toast(k === 'pacc' ? 'Accepted. The new version is in the Edit log.' : 'Rejected. The reason is in the Edit log.');
420
+ await load(); if (ctx.onWrite) ctx.onWrite(); return;
421
+ }
385
422
  if (!p) return;
386
423
  if (k === 'keep') {
387
424
  const o = overlay(P.text, p, P.kept);
@@ -451,6 +488,7 @@ function makePage(d, ctx) {
451
488
  if (e.target.id === 'vwWhy') { P.why = e.target.value; return; }
452
489
  if (e.target.id === 'vwMd') return;
453
490
  if (e.target.id === 'vwCpUrl') { P.cpUrl = e.target.value; return; }
491
+ if (e.target.id === 'vwRj') { P.rejWhy = e.target.value; return; }
454
492
  if (!e.target.closest || !e.target.closest('.cfb')) return;
455
493
  if (e.inputType === 'insertText' && e.data === '/') { slash = { q: '' }; showMenu(caretRect(), BLOCKS, (it) => { const n = slash ? slash.q.length + 1 : 1; slash = null; delBack(n); doBlock(it.k); }, { slash: true }); }
456
494
  else if (slash && menu) {
@@ -160,7 +160,7 @@ export function openChatFile(p, ctx = {}) {
160
160
  };
161
161
  const pane = vwOpen({ id, title: base(p), icon: 'doc', render: (el) => { el.innerHTML = fileHtml(st.f, st.view); wire(el); } });
162
162
  const draw = () => {
163
- const el = document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(id)}"]`);
163
+ const el = document.querySelector(`.obody.vw[data-vw="${CSS.escape(id)}"]`);
164
164
  if (!el) return false;
165
165
  const y = el.scrollTop; el.innerHTML = fileHtml(st.f, st.view); wire(el); el.scrollTop = y;
166
166
  return true;
@@ -179,7 +179,7 @@ export function openChatFile(p, ctx = {}) {
179
179
  clearTimeout(st.timer);
180
180
  const tick = async () => {
181
181
  const changed = await read();
182
- if (!document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(id)}"]`)) { OPEN.delete(id); return; } // the tab or the dialog closed: stop checking
182
+ if (!document.querySelector(`.obody.vw[data-vw="${CSS.escape(id)}"]`)) { OPEN.delete(id); return; } // the tab or the dialog closed: stop checking
183
183
  if (changed) draw();
184
184
  st.timer = setTimeout(tick, CHECK_MS);
185
185
  };
@@ -8,7 +8,7 @@
8
8
  * After Since the last one (each next step of the meeting before: Done, Raised again or Not mentioned, then the new ones),
9
9
  * the summary, Decision and Why, Next step with owner, due and Make task, open questions, the screenshots of the
10
10
  * shared screen and the folded transcript.
11
- * An earlier or later meeting of the series opens as a viewer tab (openNoteTab), with the same sheet.
11
+ * openNoteTab(d, id) opens the note as the Viewer's meeting card (premium-vw-mtg.js); the html builders below are kept for their suites.
12
12
  *
13
13
  * WHERE EACH PART COMES FROM. GET /api/notes/one?id= answers { note, recording, screen: { frames }, place } (lib/routes-notes.js).
14
14
  * The parts are read as the console reads them (dest-notes.js partsOf, c3-notes.js): the final notes after Stop, else what was
@@ -16,7 +16,7 @@
16
16
  * Not drawn, because no record or route backs them here: re-linking the note to another calendar event (the console's own
17
17
  * meeting picker), and Make task on a Since the last one row (the console has none either). */
18
18
  import { agendaHeard, peopleOf } from './notes-context.js';
19
- import { vwOpen, vwStyle } from './premium-viewer.js';
19
+ import './premium-vw-open.js'; // registers window.czViews (openMeeting, openCalendar, openNotes, openReport) for the pages that load this module
20
20
 
21
21
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
22
22
  const pad = (n) => String(n).padStart(2, '0');
@@ -278,85 +278,8 @@ export function aboutBody(id, v, choices) {
278
278
  const c = (choices || []).find((x) => x.v === v);
279
279
  return c ? { id, ...c.body } : null;
280
280
  }
281
- const aboutPickHtml = (choices, cur, esc) => choices ? `<div class="mtg-link vm-nabout"><select aria-label="What this note is about">${[['', 'Choose what it is about'], ...choices.map((c) => [c.v, c.label]), ...(cur ? [['none', 'Not linked']] : [])].map(([v, l]) => `<option value="${esc(v)}"${v && v === cur ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select><button type="button" class="addb pri" data-vm="nsave">Save</button></div>` : '<p class="note vm-nabout" role="status">Reading the boards.</p>';
282
281
 
283
- /* ── the viewer tab: a meeting of the series, opened beside the dialog's own meeting ─────────────────────────────── */
284
-
285
- /** Loads this view's stylesheet once (the frame keeps one link per view). */
286
- export const vmStyle = () => { if (typeof document !== 'undefined') vwStyle('meet'); };
287
-
288
- /** Opens a note in the viewer: one tab that pages through its series. The Notes list (premium-vw-notes.js) and the meeting dialog's
289
- * series line open it. deps: { pmGet, pmPost, esc, toast, task(sheet, step) → Promise<{ ok, text }>, changed?() after a write } */
290
- export async function openNoteTab(d, id) {
291
- vmStyle();
292
- const st = { id, note: null, sheet: null, error: '', phase: 'after', open: {}, tasked: new Set(), say: '', about: false, choices: null };
293
- const ctx = () => ({ esc: d.esc, tasked: st.tasked, replayBtn: false, where: 'tab', id: st.id, reread: () => read(st.id) });
294
- const html = () => {
295
- const S = st.sheet;
296
- if (!S) return `<article class="paper doc mtg vm"><p class="note" role="status">${st.error ? 'The note could not be read: ' + d.esc(st.error) : 'Reading the note.'}</p></article>`;
297
- const parts = Object.fromEntries(PHASES.map(([k]) => [k, stageHtml(k, S, ctx())]));
298
- return `<article class="paper doc mtg vm"><p class="note mtg-status" role="status"${st.say ? '' : ' hidden'}>${d.esc(st.say)}</p><div class="mh2"><div><h3 class="d1">${d.esc(S.title)}</h3><p class="mt">${d.esc([S.day, S.minutes ? S.minutes + ' min' : ''].filter(Boolean).join(' · '))}</p></div></div>${linksHtml(S, d.esc, { change: true, open: st.about })}${st.about ? aboutPickHtml(st.choices, aboutNow(st.note), d.esc) : ''}${seriesHtml(S, d.esc)}${partsHtml(st.phase, parts, st.open, d.esc)}</article>`;
299
- };
300
- let el = null;
301
- const wireParts = () => { if (!el || !st.sheet) return; for (const [k] of PHASES) wireStage(k, el.querySelector(`.vm-body[data-part="${k}"]`), st.sheet, ctx()); };
302
- const paint = () => { if (el && el.isConnected) { partKeep(el, st.open); el.innerHTML = html(); wireParts(); } };
303
- async function read(noteId) {
304
- const fresh = noteId !== st.id || !st.sheet;
305
- st.id = noteId; if (fresh) { st.sheet = null; st.tasked = new Set(); st.about = false; st.open = {}; } st.error = ''; st.say = ''; paint();
306
- const one = await d.pmGet('/api/notes/one?id=' + encodeURIComponent(noteId));
307
- if (st.id !== noteId) return;
308
- const was = st.sheet;
309
- st.sheet = noteSheet(one); st.note = st.sheet ? one.note : null; st.error = st.sheet ? '' : (one && one.error) || 'no answer';
310
- if (st.sheet && (fresh || !was)) st.phase = phaseOf({ noteState: st.sheet.state, hasNotes: !!(st.sheet.overview || st.sheet.decisions.length || st.sheet.actions.length) });
311
- el = vwOpen({ id: 'meet-note', title: st.sheet ? st.sheet.title : 'Meeting note', icon: 'notes', html: html(), wire });
312
- wireParts();
313
- }
314
- async function boards() {
315
- const r = await d.pmGet('/api/boards');
316
- const list = r && r.ok && Array.isArray(r.boards) ? r.boards.filter((b) => b && b.id && !b.error) : [];
317
- await Promise.all(list.map(async (b) => {
318
- const x = await d.pmGet('/api/boards/backlog?ws=' + encodeURIComponent(b.ws || '') + '&board=' + encodeURIComponent(b.id) + '&limit=100');
319
- b.inis = x && x.ok && Array.isArray(x.rows) ? x.rows : [];
320
- }));
321
- return aboutChoices(list);
322
- }
323
- function wire(pane) {
324
- el = pane;
325
- pane.onclick = async (e) => {
326
- if (partToggle(e, st.open)) return;
327
- const b = e.target.closest('button'); if (!b || !st.sheet) return;
328
- if ((b.dataset.vm === 'prev' || b.dataset.vm === 'next') && b.dataset.id) return read(b.dataset.id);
329
- if (b.dataset.vm === 'nabout') {
330
- st.about = !st.about; paint();
331
- if (st.about && !st.choices) { st.choices = await boards(); if (st.about) paint(); }
332
- const sel = el.querySelector('.vm-nabout select'); if (sel) sel.focus();
333
- return;
334
- }
335
- if (b.dataset.vm === 'nsave') {
336
- const sel = el.querySelector('.vm-nabout select'), body = sel && aboutBody(st.sheet.id, sel.value, st.choices);
337
- if (!body) { d.toast('Choose what the note is about first.'); return; }
338
- b.disabled = true;
339
- const r = await d.pmPost('/api/notes/link', body);
340
- if (!r || !r.ok) { b.disabled = false; d.toast('Not saved' + (r && r.error ? ': ' + r.error : '.')); return; }
341
- d.toast(sel.value === 'none' ? 'Not linked to the Portfolio, a board or an initiative.' : 'Saved. The note moved into its group.');
342
- st.about = false; if (d.changed) d.changed();
343
- return read(st.sheet.id);
344
- }
345
- if (b.dataset.vm === 'serout' || b.dataset.vm === 'serback') {
346
- const r = await d.pmPost('/api/notes/series-member', { id: st.sheet.id, key: b.dataset.vm === 'serout' ? 'off' : null });
347
- d.toast(r && r.ok ? (b.dataset.vm === 'serout' ? 'Taken out of the series.' : 'Back in its series.') : 'Not saved' + (r && r.error ? ': ' + r.error : '.'));
348
- if (r && r.ok) { if (d.changed) d.changed(); read(st.sheet.id); }
349
- return;
350
- }
351
- if (b.dataset.task !== undefined) {
352
- const i = +b.dataset.task, step = st.sheet.actions[i]; if (!step) return;
353
- b.disabled = true;
354
- const res = await d.task(st.sheet, step);
355
- if (res.ok) st.tasked.add(i);
356
- st.say = res.text; paint();
357
- }
358
- };
359
- }
360
- el = vwOpen({ id: 'meet-note', title: 'Meeting note', icon: 'notes', html: html(), wire });
361
- await read(id);
362
- }
282
+ /* ── the old viewer tab is gone (Agreed design): a note opens as the Viewer's meeting card (premium-vw-mtg.js) ── */
283
+ export const vmStyle = () => {};
284
+ /** Opens a note in the Viewer card. d is ignored; kept so the old callers work. */
285
+ export async function openNoteTab(d, id) { const M = await import('./premium-vw-mtg.js'); return M.openMeeting({ note: id }); }