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,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,10 @@
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 { pmGet } from './http.js';
23
+ import { notesCards } from './premium-vw-notes.js';
24
+ import './premium-vw-open.js'; // registers window.czViews
13
25
 
14
26
  export const VIEWS = [['day', 'Day'], ['week', 'Week'], ['month', 'Month']];
15
27
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -158,61 +170,278 @@ export function placeAll(el) {
158
170
  });
159
171
  }
160
172
 
161
- const S = new WeakMap(); // host -> { st, M, seq }
173
+ /* ── the view (pure half) ─────────────────────────────────────────────────────────────────────────────────────── */
174
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
175
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
176
+ const hmOf = (iso) => { const t = new Date(iso); return Number.isFinite(t.getTime()) ? pad(t.getHours()) + ':' + pad(t.getMinutes()) : ''; };
177
+ const localKey = (iso) => { const t = new Date(iso); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
178
+ const hrsText = (min) => (!min ? '' : min < 60 ? min + ' min' : (Math.round(min / 6) / 10) + ' h');
179
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many || one + 's');
180
+ export const CAL_FOOT = 'From your calendar. PMOS never writes to it. A meeting with no initiative stays Not linked until you link it.';
181
+ export const NEW_NOTE_TIP = 'Starts an untitled note now. It needs no calendar event; link it to an initiative later.';
182
+ export const SEARCH_HINT = 'Search notes and what was said';
183
+ 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
184
 
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
- }
185
+ /** Monday to Friday of the week of `anchor` (today when left out) in the week answer (weekView W), with the day `picked` pressed. A day's bar is its meeting count; its line is "done" for a
186
+ * past day with meetings, else its meeting hours, and "today". */
187
+ export function stripModel(W, picked, today, anchor = today) {
188
+ const keys = (() => { const [y, m, d] = parts(anchor), 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)))); })();
189
+ const ok = !!(W && W.state === 'ok');
190
+ return keys.map((k) => {
191
+ const rows = ok ? ((W.days.find((x) => x.key === k) || {}).rows || []) : [];
192
+ 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);
193
+ const past = k < today, now = k === today;
194
+ return { key: k, dow: DOW[wd(k)].toUpperCase(), n: parts(k)[2], count: rows.length, on: k === picked, today: now,
195
+ bar: rows.length ? Math.min(1, 0.35 + rows.length * 0.22) : 0,
196
+ sub: [past && rows.length ? 'done' : hrsText(min), now ? 'today' : ''].filter(Boolean).join(' · ') };
197
+ });
198
+ }
199
+ /** 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. */
200
+ export function dayModel(W, notes, picked, today, now = Date.now()) {
201
+ const day = W && W.state === 'ok' ? W.days.find((x) => x.key === picked) : null;
202
+ const rows = day ? day.rows : [];
203
+ const N = Array.isArray(notes) ? notes : [];
204
+ let nextDone = false;
205
+ const ents = rows.map((r) => {
206
+ const n = N.filter((x) => sameEv(x.meeting, r)).sort((a, b) => String(b.updated_at || '').localeCompare(String(a.updated_at || '')))[0] || null;
207
+ const at = Date.parse(r.at), end = Date.parse(r.end), linked = !!r.about;
208
+ 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) : '');
209
+ let chip = '', k = '', next = false;
210
+ if (n && (n.state === 'recording' || n.state === 'paused')) { chip = n.state === 'paused' ? 'Paused' : 'Recording'; k = 'rec'; }
211
+ else if (n && n.state === 'ended') { chip = 'Done'; k = 'ok'; }
212
+ 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'; }
213
+ else if (!about) chip = 'Not linked';
214
+ else if (picked > today) chip = DOW[wd(picked)];
215
+ else if (Number.isFinite(end) && end < now) chip = 'Ended';
216
+ else chip = hasTime(r.at) ? 'Today' : 'All day';
217
+ const status = n && n.state === 'ended' ? 'notes ready' : n && (n.state === 'recording' || n.state === 'paused') ? 'recording' : '';
218
+ const who = (r.who || []).slice(0, 3).join(', ') + ((r.who || []).length > 3 ? ' and ' + ((r.who || []).length - 3) + ' more' : '');
219
+ 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 : '' };
220
+ });
221
+ for (const n of N) {
222
+ const m = n.meeting;
223
+ if (m && m.kind === 'event') continue;
224
+ const s = (m && m.start) || n.recorded_from || n.created_at; if (!s || localKey(s) !== picked) continue;
225
+ const ini = n.initiative && n.initiative.id ? clip(n.initiative.title || n.initiative.id, 50) : '';
226
+ const len = n.meeting_ms >= 60000 ? Math.round(n.meeting_ms / 60000) + ' min' : '';
227
+ const live = n.state === 'recording' || n.state === 'paused';
228
+ 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(' · '),
229
+ 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 });
230
+ }
231
+ ents.sort((a, b) => a.t - b.t);
232
+ const [, m, d] = parts(picked);
233
+ const label = DOW[wd(picked)] + ' ' + d + ' ' + MON[m - 1];
234
+ 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 };
235
+ }
236
+ const chipHtml = (c, k) => `<span class="vz-cc" data-k="${k || ''}">${esc(c)}</span>`;
237
+ const SVG = { prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6', plus: 'M12 5v14M5 12h14', find: 'M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14M20 20l-4-4', x: 'M6 6l12 12M18 6L6 18',
238
+ chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', mic: 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3z' };
239
+ const sv = (k, w = 16) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${SVG[k]}"/></svg>`;
240
+ export const CAL_HINT = 'Press a meeting to open its prep or notes here';
241
+ /** The range's name as the design writes it (MtCalendar): "19 to 25 Oct", "28 Sep to 4 Oct", "Thu 22 Oct", "October 2026". */
242
+ export function rangeTitle(view, date, today) {
243
+ if (view === 'month') { const [y, m] = parts(date); return `${MONTH[m - 1]} ${y}`; }
244
+ if (view === 'day') { const [, m, d] = parts(date); return `${DOW[wd(date)]} ${d} ${MON[m - 1]}${date === today ? ' · today' : ''}`; }
245
+ const a = addDays(date, -wd(date)), b = addDays(a, 6), [, m1, d1] = parts(a), [, m2, d2] = parts(b);
246
+ return m1 === m2 ? `${d1} to ${d2} ${MON[m2 - 1]}` : `${d1} ${MON[m1 - 1]} to ${d2} ${MON[m2 - 1]}`;
247
+ }
248
+ /** A meeting block's words beside its title: what it is about, and whether its notes or its recording are there. */
249
+ function evSub(row, notes) {
250
+ const n = (Array.isArray(notes) ? notes : []).filter((x) => sameEv(x.meeting, row)).sort((a, b) => String(b.updated_at || '').localeCompare(String(a.updated_at || '')))[0] || null;
251
+ const about = row.level ? (row.level.kind === 'portfolio' ? 'Portfolio' : clip(row.level.name || row.level.id, 40)) : '';
252
+ const st = n && n.state === 'ended' ? 'notes ready' : n && (n.state === 'recording' || n.state === 'paused') ? 'recording' : '';
253
+ return { linked: !!row.level, text: [about, st].filter(Boolean).join(' · '), note: n ? n.id : '' };
254
+ }
255
+ /** The week grid (MtCalendar): an hour gutter, Monday to Friday, Saturday and Sunday narrow; each day head with its load bar and hours; each
256
+ * meeting a block, linked ones filled and the others dashed with "Link it"; the next or current meeting today ringed; the now line on today. */
257
+ export function weekHtml(M, notes, nowMin, now = Date.now()) {
258
+ const H = 52, hours = []; for (let m = M.from; m < M.to; m += 60) hours.push(m);
259
+ const top = (m) => ((m - M.from) / 60) * H;
260
+ const today = M.days.find((x) => x.today);
261
+ const ring = today ? (today.timed.find((e) => e.s <= nowMin && e.e > nowMin) || today.timed.filter((e) => e.s > nowMin).sort((a, b) => a.s - b.s)[0] || null) : null;
262
+ const pct = (h) => Math.min(100, (h / DAY_LOAD) * 100).toFixed(1) + '%';
263
+ const col = (x) => {
264
+ const hd = `<div class="vzc-hd${x.today ? ' now' : ''}${x.weekend ? ' we' : ''}"><button type="button" class="vzc-dn" data-c="gday" data-k="${x.key}" aria-label="${esc('Open ' + x.label + (x.today ? ', today' : ''))}">${x.dow} ${x.n}${x.today ? ' · today' : ''}</button>${x.weekend ? '' : `<span class="vzc-lb" data-tl="${pct(x.hrs)}"><i></i></span><small>${x.hrs ? +x.hrs.toFixed(1) + ' h' : ' '}</small>`}</div>`;
265
+ const blocks = x.timed.map((e) => { const S = evSub(e.row, notes); return `<button type="button" class="vzc-ev${S.linked ? '' : ' un'}${e === ring ? ' ring' : ''}${e.past ? ' past' : ''}" data-c="ev" data-ref="${esc(e.ref)}" data-tl="${top(e.s) + 1}px ${Math.max(22, ((e.e - e.s) / 60) * H - 3)}px ${e.lane} ${e.lanes}" title="${esc(e.title + ', ' + e.time)}"><b>${esc(e.title)}</b>${S.linked ? (S.text ? `<span>${esc(S.text)}</span>` : '') : '<span class="vzc-link" data-c="link" data-ref="' + esc(e.ref) + '">Link it</span>'}</button>`; }).join('');
266
+ const allday = x.allday.filter((a) => a.row).map((a) => `<button type="button" class="vzc-ad" data-c="ev" data-ref="${esc(a.ref)}">${esc(a.title)}</button>`).join('');
267
+ return `<div class="vzc-col${x.weekend ? ' we' : ''}">${hd}${allday ? `<div class="vzc-ads">${allday}</div>` : ''}<div class="vzc-body${x.today ? ' now' : ''}" data-tl="${hours.length * H}px">${x.today && nowMin != null && nowMin >= M.from && nowMin <= M.to ? `<i class="vzc-nl" data-tl="${top(nowMin)}px" aria-hidden="true"></i>` : ''}${blocks}</div></div>`;
187
268
  };
188
- paint(); read();
189
- return { state: () => ({ ...me.st }), reload: read };
269
+ const gut = `<div class="vzc-col vzc-gut"><div class="vzc-hd"></div><div class="vzc-body" data-tl="${hours.length * H}px">${hours.map((m, i) => `<i data-tl="${i * H}px">${pad(m / 60)}</i>`).join('')}</div></div>`;
270
+ return `<div class="vzc-wk">${gut}${M.days.map(col).join('')}</div>`;
271
+ }
272
+ /** The day (MtPhone right): the five weekdays, "3 meetings · 2 h", then each entry at its time; linked filled, the others dashed with Link it. */
273
+ export function dayHtml(strip, D) {
274
+ const mins = D.rows.reduce((a, r) => a + (r.row && hasTime(r.row.at) && hasTime(r.row.end) ? Math.max(0, (Date.parse(r.row.end) - Date.parse(r.row.at)) / 60000) : 0), 0);
275
+ const h = [`<div class="vzc-days" role="group" aria-label="This week">${strip.map((d) => `<button type="button" class="vzc-dy" 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[0] + d.dow.slice(1).toLowerCase()}</span><b>${d.n}</b></button>`).join('')}</div>`];
276
+ if (D.state === 'error') return h.join('') + `<p class="vz-empty" role="status">The calendar was not read. ${esc(D.reason || '')}</p>`;
277
+ const allEv = D.rows.every((r) => r.kind === 'event');
278
+ h.push(`<p class="vzc-mut">${D.rows.length ? (allEv ? plural(D.rows.length, 'meeting') : plural(D.rows.length, 'entry', 'entries')) + (mins ? ' · ' + hrsText(Math.round(mins)) : '') : 'No meetings on this day'}</p>`);
279
+ D.rows.forEach((r, i) => h.push(`<div class="vzc-hr"><span class="vzc-t">${esc(r.time)}</span><button type="button" class="vzc-de${r.linked ? '' : ' un'}${r.next ? ' ring' : ''}" data-c="open" data-i="${i}"${r.next ? ' data-next' : ''}><b>${esc(r.title)}</b><small>${esc(r.sub)}</small>${r.chip === 'Link it' || r.chip === 'Not linked' ? `<span class="vz-cc vzc-link" data-c="link" data-i="${i}" role="button" tabindex="0" title="Link it to an initiative">Link it</span>` : chipHtml(r.chip, r.k)}</button></div>`));
280
+ return h.join('');
281
+ }
282
+ /** The month (Day, Week and Month): a grid of weeks, each day with its number, how many meetings, the first three and "+N more". */
283
+ export function monthHtml(M) {
284
+ const cells = M.days.map((x) => {
285
+ const ev = [...x.allday.filter((a) => a.row), ...x.timed].sort((a, b) => (a.s || 0) - (b.s || 0));
286
+ return `<div class="vzc-md${x.inRange ? '' : ' out'}${x.today ? ' now' : ''}"><button type="button" class="vzc-mn" data-c="gday" data-k="${x.key}" aria-label="${esc(x.label + (x.today ? ', today' : '') + ': ' + plural(x.meetings, 'meeting'))}"><b>${x.n}</b>${x.meetings ? `<i>${x.meetings}</i>` : ''}</button>${ev.slice(0, 3).map((e) => `<button type="button" class="vzc-me${e.row && e.row.level ? '' : ' un'}" data-c="ev" data-ref="${esc(e.ref)}" title="${esc(e.title)}">${e.s != null ? `<time>${hh(e.s)}</time>` : ''}${esc(e.title)}</button>`).join('')}${ev.length > 3 ? `<button type="button" class="vzc-more" data-c="gday" data-k="${x.key}">+${ev.length - 3} more</button>` : ''}</div>`;
287
+ }).join('');
288
+ return `<div class="vzc-mg"><div class="vzc-mh">${DOW.map((d) => `<span>${d}</span>`).join('')}</div><div class="vzc-mb">${cells}</div></div>`;
289
+ }
290
+ /** The card's body. st = { tab, view, date, q, filter, open: Set of series keys, searching }. X = { M (calModel of the range), W (weekView), notes,
291
+ * strip, day, cards (notesCards), msg, nowMin } */
292
+ export function calViewHtml(st, X) {
293
+ const h = [];
294
+ h.push(`<div class="vzm-tabs vzc-tabs" role="tablist" aria-label="Meetings">${[['cal', 'Calendar'], ['notes', 'Notes']].map(([k, l]) => `<button type="button" role="tab" class="vzm-tab" aria-selected="${st.tab === k}" data-c="tab" data-k="${k}">${l}</button>`).join('')}</div>`);
295
+ if (X.msg) h.push(`<p class="vz-msg" role="status" data-tone="${X.msg.tone || ''}">${esc(X.msg.text)}</p>`);
296
+ if (st.tab === 'cal') {
297
+ h.push(`<div class="vzc-head"><h2 class="vzm-h2">${esc(rangeTitle(st.view, st.date, X.today))}</h2><button type="button" class="vzm-ib vz-hv" data-c="nav" data-k="-1" aria-label="Previous ${st.view}">${sv('prev')}</button><button type="button" class="vzm-ib vz-hv" data-c="nav" data-k="1" aria-label="Next ${st.view}">${sv('next')}</button><button type="button" class="vzm-btn vzm-soft" data-c="nav" data-k="0">Today</button><span class="vz-sp"></span>`
298
+ + `<div class="vzp-seg" role="group" aria-label="Range">${VIEWS.map(([k, l]) => `<button type="button" data-c="view" data-k="${k}" aria-pressed="${st.view === k}">${l}</button>`).join('')}</div><button type="button" class="vzm-ib vzm-solid" data-c="new" aria-label="New note" title="${esc(NEW_NOTE_TIP)}">${sv('plus')}</button></div>`);
299
+ const M = X.M;
300
+ if (!M) h.push('<p class="vz-empty" role="status">Reading the calendar PMOS holds.</p>');
301
+ else if (M.state !== 'ok' && st.view !== 'day') h.push(`<p class="vz-empty" role="status">The calendar was not read. ${esc(M.reason || '')}</p>`);
302
+ else if (st.view === 'week') h.push(weekHtml(M, X.notes, X.nowMin) + (M.empty ? `<p class="vz-empty" role="status">${esc(M.empty)}</p>` : ''));
303
+ else if (st.view === 'month') h.push(monthHtml(M) + (M.empty ? `<p class="vz-empty" role="status">${esc(M.empty)}</p>` : ''));
304
+ else h.push(X.day ? dayHtml(X.strip, X.day) : '<p class="vz-empty" role="status">Reading the calendar PMOS holds.</p>');
305
+ h.push(`<div class="vzc-leg"><span><i class="vzc-sw"></i>Linked</span><span><i class="vzc-sw un"></i>Not linked</span><span class="vz-sp"></span><span title="${esc(CAL_FOOT)}">${esc(CAL_HINT)}</span></div>`);
306
+ } else {
307
+ const C = X.cards;
308
+ h.push(`<div class="vzm-in vzc-find">${sv('find')}<input type="search" data-c="q" aria-label="${esc(SEARCH_HINT)}" placeholder="${esc(SEARCH_HINT)}" value="${esc(st.q || '')}">${st.q ? `<span class="vzc-mut">${C && C.state === 'ok' ? plural(C.count, 'note') : ''}</span><button type="button" class="vzm-ib vz-hv" data-c="clear" aria-label="Clear the search">${sv('x', 14)}</button>` : ''}</div>`);
309
+ h.push(`<div class="vzc-chips" role="group" aria-label="Show">${NOTE_FILTERS.map(([k, l]) => `<button type="button" class="vzm-chip${(st.filter || 'all') === k ? ' on' : ''}" data-c="filter" data-k="${k}" aria-pressed="${(st.filter || 'all') === k}">${l}</button>`).join('')}</div>`);
310
+ if (!C) h.push('<p class="vz-empty" role="status">Reading the notes.</p>');
311
+ else if (C.state === 'error') h.push(`<p class="vz-empty" role="status">The notes could not be read. ${esc(C.error)}</p>`);
312
+ else if (!C.total) h.push('<p class="vz-empty">No notes yet. Notes you record show here, grouped by initiative.</p>');
313
+ else if (!C.groups.length) h.push(`<p class="vz-empty" role="status">${st.searching ? 'Searching what was said.' : st.q ? 'No note matches “' + esc(st.q) + '”.' : 'No note of this kind.'}</p>`);
314
+ else C.groups.forEach((g) => h.push(`<section class="vzc-grp"><p class="vzm-lbl">${esc(g.title)} <small>${esc(g.n)}</small></p>${g.entries.map((e) => entryHtml(e, st)).join('')}</section>`));
315
+ }
316
+ return `<div class="vz vz-cal" data-tab="${st.tab}" data-view="${st.view}">${h.join('')}</div>`;
317
+ }
318
+ const NOTE_FILTERS = [['all', 'All'], ['linked', 'Linked'], ['unlinked', 'Not linked'], ['nomeeting', 'No meeting']];
319
+ /** A snippet with the searched words marked; everything else escaped. */
320
+ export function markHtml(text, q) {
321
+ const ws = String(q || '').toLowerCase().split(/\s+/).filter((w) => w.length >= 2);
322
+ let out = esc(text);
323
+ for (const w of ws) out = out.replace(new RegExp('(' + esc(w).replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ')', 'gi'), '<mark>$1</mark>');
324
+ return out;
325
+ }
326
+ const noteRow = (r, st) => `<button type="button" class="vz-hv vzc-nr${r.noMeeting ? ' nm' : ''}" data-c="note" data-id="${esc(r.id)}">${r.noMeeting ? `<span class="vzc-mic">${sv('mic')}</span>` : ''}<span><b>${esc(r.title)}</b>${r.len ? ` <span class="vzc-mut">· ${esc(r.len)}</span>` : ''}${r.noMeeting ? ' <span class="vzm-pill vzc-dash">No meeting</span>' : ''}<small>${r.snip ? markHtml(r.snip, st.q) : esc(r.sub)}</small></span>${r.chip === 'Link it' ? `<span class="vz-cc vzc-link" data-c="nlink" data-id="${esc(r.id)}" role="button" tabindex="0">Link it</span>` : r.chip ? chipHtml(r.chip, r.k) : ''}</button>`;
327
+ function entryHtml(e, st) {
328
+ if (e.kind === 'note') return noteRow(e.row, st);
329
+ const open = st.open && st.open.has(e.key) ? true : st.shut && st.shut.has(e.key) ? false : e.match > 0;
330
+ return `<div class="vzc-card"><button type="button" class="vzc-ch" data-c="ser" data-k="${esc(e.key)}" aria-expanded="${open}">${sv(open ? 'down' : 'chev', 14)}<b>${esc(e.title)}</b><span class="vzc-mut">${esc(e.line)}</span>${e.chip ? chipHtml(e.chip, 'warn') : ''}</button>${open ? e.rows.map((r) => noteRow(r, st)).join('') : ''}</div>`;
190
331
  }
191
332
 
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 });
333
+ /* ── the view (page half) ─────────────────────────────────────────────────────────────────────────────────────── */
334
+ let CV = null;
335
+ export function calendarUrl(tab, ws) { return '/premium-viewer.html?' + ['open=' + (tab === 'notes' ? 'notes' : 'calendar'), ws ? 'ws=' + encodeURIComponent(ws) : ''].filter(Boolean).join('&'); }
336
+ const narrow = () => typeof window !== 'undefined' && window.innerWidth <= 760;
337
+ /** Opens Calendar | Notes in the Viewer. o = { ws, tab: 'cal' | 'notes', date, view, initiative } */
338
+ export function openCalendar(o = {}) {
339
+ if (o && (o.openDlg || o.$)) o = {}; // an old caller passed the shell's deps
340
+ const today = todayKey();
341
+ const view = VIEWS.some(([k]) => k === o.view) ? o.view : narrow() ? 'day' : 'week';
342
+ const me = CV = { ws: o.ws || new URLSearchParams(location.search).get('ws') || '', st: { tab: o.tab === 'notes' ? 'notes' : 'cal', view, date: o.date && /^\d{4}-\d{2}-\d{2}$/.test(o.date) ? o.date : today, q: '', filter: 'all', open: new Set() }, X: { today }, today, initiative: o.initiative || '' };
343
+ import('./premium-vw-mtg.js').then((M) => { M.mtgStyle(); if (CV === me) M.widen('cal'); });
344
+ 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; import('./premium-vw-mtg.js').then((M) => { if (!CV) M.widen(''); }); } } });
345
+ readCal(me); readNotes(me);
346
+ return me;
347
+ }
348
+ export const openNotesTab = (o = {}) => openCalendar({ ...o, tab: 'notes' });
349
+ const calBody = (me) => (CV === me && vCur() && vCur().id === 'calendar' ? document.querySelector('#czViewer .cz-vw-body') : null);
350
+ const nowMinOf = () => { const t = new Date(); return t.getHours() * 60 + t.getMinutes(); };
351
+ /** The run-time geometry of the week grid: data-tl on a block is "top height lane lanes"; on a day column and the gutter its height; on a load
352
+ * bar its width; on an hour label and the now line their top. Set as custom properties, so the markup carries no inline style. */
353
+ export function placeWeek(el) {
354
+ el.querySelectorAll('[data-tl]').forEach((n) => {
355
+ const v = n.dataset.tl.split(' ');
356
+ if (n.classList.contains('vzc-ev')) ['--t', '--h', '--l', '--lc'].forEach((k, i) => n.style.setProperty(k, v[i]));
357
+ else if (n.classList.contains('vzc-body')) n.style.setProperty('--hh', v[0]);
358
+ else if (n.classList.contains('vzc-lb')) n.style.setProperty('--w', v[0]);
359
+ else n.style.setProperty('--t', v[0]);
360
+ });
361
+ }
362
+ function paintCal(me, b) {
363
+ const body = b || calBody(me); if (!body) return;
364
+ const keep = document.activeElement && document.activeElement.dataset && document.activeElement.dataset.c === 'q' ? document.activeElement.selectionStart : null;
365
+ if (me.W) { me.X.strip = stripModel(me.W, me.st.date, me.today, me.st.date); me.X.day = dayModel(me.W, me.notes, me.st.date, me.today); }
366
+ me.X.notes = me.notes; me.X.nowMin = nowMinOf();
367
+ me.X.cards = notesCards(me.notesAnswer, { q: me.st.q, found: me.found, hits: me.hits, filter: me.st.filter, initiative: me.initiative });
368
+ body.innerHTML = calViewHtml(me.st, me.X);
369
+ placeWeek(body);
370
+ if (keep != null) { const i = body.querySelector('[data-c="q"]'); if (i) { i.focus(); i.setSelectionRange(keep, keep); } }
371
+ body.onclick = (e) => calPress(me, e);
372
+ body.oninput = (e) => { if (e.target.dataset.c === 'q') search(me, e.target.value); };
373
+ body.onkeydown = (e) => { if ((e.key === 'Enter' || e.key === ' ') && /^(link|nlink)$/.test(e.target.dataset.c || '')) { e.preventDefault(); calPress(me, e); } };
374
+ }
375
+ async function readCal(me) {
376
+ const wsq = me.ws ? '&ws=' + encodeURIComponent(me.ws) : '';
377
+ const v = me.st.view, d = me.st.date, seq = me.seq = (me.seq || 0) + 1;
378
+ me.X.M = null; paintCal(me);
379
+ const r = await pmGet('/api/calendar-views?view=' + (v === 'month' ? 'month' : 'week') + '&date=' + d + wsq);
380
+ if (CV !== me || me.seq !== seq) return;
381
+ me.X.M = calModel(r, v === 'month' ? 'month' : 'week', d, me.today);
382
+ if (v !== 'month') me.lastWeek = r;
383
+ me.W = v === 'month' ? me.W : weekView(r, me.today);
384
+ paintCal(me);
385
+ }
386
+ async function readNotes(me) {
387
+ const n = await pmGet('/api/notes');
388
+ if (CV !== me) return;
389
+ me.notesAnswer = n; me.notes = n && n.ok ? n.notes || [] : [];
390
+ paintCal(me);
391
+ }
392
+ let searchT = null;
393
+ function search(me, v) {
394
+ me.st.q = v; clearTimeout(searchT);
395
+ me.found = null; me.hits = null; me.st.searching = String(v).trim().length >= 2;
396
+ paintCal(me);
397
+ if (!me.st.searching) return;
398
+ searchT = setTimeout(async () => {
399
+ const r = await pmGet('/api/notes/search?q=' + encodeURIComponent(v.trim()));
400
+ if (CV !== me || me.st.q !== v) return;
401
+ me.found = new Set(r && r.ok && Array.isArray(r.ids) ? r.ids : []); me.st.searching = false;
402
+ me.hits = new Map((r && r.ok && Array.isArray(r.hits) ? r.hits : []).map((x) => [x.id, x]));
403
+ paintCal(me);
404
+ }, 250);
405
+ }
406
+ const mtg = () => import('./premium-vw-mtg.js');
407
+ const blockAt = (me, ref) => { const M = me.X.M; if (!M || !ref) return null; const [k] = ref.split('|'); const d = M.days.find((x) => x.key === k); return d ? [...d.timed, ...d.allday].find((x) => x.ref === ref) || null : null; };
408
+ async function calPress(me, e) {
409
+ const t = e.target.closest('[data-c]'); if (!t) return;
410
+ const c = t.dataset.c, D = me.X.day;
411
+ if (c === 'tab') { me.st.tab = t.dataset.k; return paintCal(me); }
412
+ if (c === 'view') { // Day and Week draw from the same week answer: switching between them reads nothing
413
+ const was = me.st.view; me.st.view = t.dataset.k;
414
+ if (was !== 'month' && me.st.view !== 'month' && me.X.M && me.X.M.state === 'ok') { me.X.M = calModel(me.lastWeek, 'week', me.st.date, me.today); return paintCal(me); }
415
+ return readCal(me);
416
+ }
417
+ if (c === 'nav') { const k = +t.dataset.k; me.st.date = k ? shift(me.st.view, me.st.date, k) : me.today; return readCal(me); }
418
+ if (c === 'gday') { me.st.view = 'day'; me.st.date = t.dataset.k; return readCal(me); }
419
+ if (c === 'day') { const was = me.st.date; me.st.date = t.dataset.k; if (me.W && me.W.days.some((d) => d.key === t.dataset.k)) return paintCal(me); if (was !== t.dataset.k) return readCal(me); return; }
420
+ 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; }
421
+ if (c === 'link') {
422
+ e.stopPropagation();
423
+ const r = t.dataset.ref ? blockAt(me, t.dataset.ref) : D && D.rows[+t.dataset.i]; if (!r) return;
424
+ const M = await mtg(); return M.openMeeting(r.note && r.kind === 'note' ? { note: r.note } : r.row, { ws: me.ws, about: true });
425
+ }
426
+ if (c === 'nlink') { e.stopPropagation(); const M = await mtg(); return M.openMeeting({ note: t.dataset.id }, { ws: me.ws, about: true }); }
427
+ if (c === 'ev') { const b = blockAt(me, t.dataset.ref); if (b && b.row) { const M = await mtg(); return M.openMeeting(b.row, { ws: me.ws }); } return; }
428
+ 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 }); }
429
+ if (c === 'note') { const M = await mtg(); return M.openMeeting({ note: t.dataset.id }, { ws: me.ws }); }
430
+ if (c === 'filter') { me.st.filter = t.dataset.k; return paintCal(me); }
431
+ if (c === 'clear') { me.st.q = ''; me.found = null; me.hits = null; me.st.searching = false; return paintCal(me); }
432
+ if (c === 'ser') { const k = t.dataset.k, open = t.getAttribute('aria-expanded') === 'true'; if (open) { me.st.open.delete(k); (me.st.shut = me.st.shut || new Set()).add(k); } else me.st.open.add(k); return paintCal(me); }
205
433
  }
206
434
 
207
- /** The Briefing's Calendar card gets a button that opens the full calendar. */
435
+ /** 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
436
  export function mountCalEntry(card, d) {
209
437
  if (!card || card.querySelector('.vc-open')) return;
210
- vwStyle('cal');
211
438
  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);
439
+ b.innerHTML = '<span>Calendar</span>';
440
+ const h = card.querySelector('.ch'), menu = card.querySelector('#calMenu');
441
+ if (menu) menu.append(b); else if (h) h.append(b); else card.append(b);
442
+ b.onclick = () => openCalendar({ ws: d && d.ws ? d.ws() : '' });
216
443
  }
444
+ /** The earlier grid's mount opens the calendar on that range. Kept so an old caller gets the view. */
445
+ export function mountCal(el, st) { return openCalendar({ view: st && st.view, date: st && st.date }); }
217
446
 
218
447
  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
  };