create-pmos 0.609.0 → 0.611.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 +69 -27
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/board-columns-test.js +2 -1
  7. package/workspace/board-deliveries-test.js +2 -1
  8. package/workspace/board-programs-test.js +9 -5
  9. package/workspace/board-publish-ui-test.js +2 -1
  10. package/workspace/board-shared-ui-test.js +2 -1
  11. package/workspace/board-workflows-test.js +2 -1
  12. package/workspace/briefing-premium-adddoc-test.js +2 -1
  13. package/workspace/briefing-premium-board-test.js +10 -9
  14. package/workspace/briefing-premium-doc-edit-test.js +2 -1
  15. package/workspace/briefing-premium-initiative-test.js +7 -6
  16. package/workspace/briefing-premium-insights-test.js +12 -11
  17. package/workspace/briefing-premium-products-test.js +4 -2
  18. package/workspace/briefing-premium-sources-test.js +1 -1
  19. package/workspace/briefing-premium-test.js +6 -5
  20. package/workspace/briefing-premium-work-test.js +1 -1
  21. package/workspace/calm-timeline-test.js +2 -1
  22. package/workspace/changelog.json +68 -0
  23. package/workspace/core-docs-workflow-test.js +2 -1
  24. package/workspace/ev-everywhere-test.js +11 -10
  25. package/workspace/guide/home.md +2 -2
  26. package/workspace/guide/index.md +4 -0
  27. package/workspace/guide/layout.md +92 -11
  28. package/workspace/guide/programs.md +16 -2
  29. package/workspace/guide/routine.md +50 -0
  30. package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
  31. package/workspace/guide/settings-and-switches.md +1 -1
  32. package/workspace/home-other-product-test.js +2 -1
  33. package/workspace/home-railcard-test.js +2 -1
  34. package/workspace/impact-screens-test.js +3 -1
  35. package/workspace/ini-workflow-test.js +2 -1
  36. package/workspace/lib/beside-page.js +15 -0
  37. package/workspace/lib/classic-board.js +15 -0
  38. package/workspace/lib/events-place.js +216 -0
  39. package/workspace/lib/library-items.js +78 -0
  40. package/workspace/lib/notes.js +6 -1
  41. package/workspace/lib/route-modules.js +4 -0
  42. package/workspace/lib/routes-events-place.js +166 -0
  43. package/workspace/lib/routes-library.js +89 -0
  44. package/workspace/lib/routes-pop-work.js +39 -0
  45. package/workspace/lib/routes-report-setups.js +20 -0
  46. package/workspace/lib/routes-today-log.js +48 -0
  47. package/workspace/lib/routine-reports.js +52 -0
  48. package/workspace/lib/today-log.js +131 -0
  49. package/workspace/live-pill-round-test.js +11 -9
  50. package/workspace/metric-drafts-ui-test.js +3 -1
  51. package/workspace/milestone-pins-test.js +2 -1
  52. package/workspace/milestone-suggest-test.js +3 -1
  53. package/workspace/package-lock.json +2 -2
  54. package/workspace/package.json +1 -1
  55. package/workspace/panels-test.js +6 -4
  56. package/workspace/premium-board-actions-test.js +3 -1
  57. package/workspace/premium-chat-context-test.js +6 -6
  58. package/workspace/premium-chat-line-test.js +1 -1
  59. package/workspace/premium-chat-notes-test.js +1 -1
  60. package/workspace/premium-core-doc-issue-test.js +2 -1
  61. package/workspace/premium-rec-tab-test.js +2 -1
  62. package/workspace/premium-vw-backlog-test.js +3 -1
  63. package/workspace/premium-vw-cal-test.js +1 -1
  64. package/workspace/premium-vw-doc-test.js +2 -1
  65. package/workspace/premium-vw-item-test.js +3 -1
  66. package/workspace/premium-vw-jira-test.js +3 -1
  67. package/workspace/product-lane-test.js +2 -1
  68. package/workspace/program-charter-test.js +3 -1
  69. package/workspace/program-leave-test.js +3 -1
  70. package/workspace/program-order-test.js +2 -1
  71. package/workspace/program-panel-test.js +5 -3
  72. package/workspace/public/pm/bd-ini-panel.js +75 -8
  73. package/workspace/public/pm/bd-prog-panel.js +55 -8
  74. package/workspace/public/pm/bd-scroll.js +4 -2
  75. package/workspace/public/pm/bd-work.css +130 -0
  76. package/workspace/public/pm/bd-work.js +356 -0
  77. package/workspace/public/pm/cozy-board.css +3 -0
  78. package/workspace/public/pm/cozy-ev.css +52 -0
  79. package/workspace/public/pm/cozy-events-view.js +142 -0
  80. package/workspace/public/pm/cozy-events.css +107 -0
  81. package/workspace/public/pm/cozy-events.js +210 -0
  82. package/workspace/public/pm/cozy-evmodel.js +1 -1
  83. package/workspace/public/pm/cozy-library.css +36 -0
  84. package/workspace/public/pm/cozy-live-pill.js +3 -1
  85. package/workspace/public/pm/cozy-nav.js +70 -7
  86. package/workspace/public/pm/cozy-panels.js +1 -1
  87. package/workspace/public/pm/cozy-pick.css +3 -0
  88. package/workspace/public/pm/cozy-pick.js +6 -2
  89. package/workspace/public/pm/cozy-pop-work.css +165 -0
  90. package/workspace/public/pm/cozy-pop-work.js +427 -0
  91. package/workspace/public/pm/cozy-popup.css +113 -0
  92. package/workspace/public/pm/cozy-popup.js +408 -0
  93. package/workspace/public/pm/cozy-routine-model.js +111 -0
  94. package/workspace/public/pm/cozy-routine-pop.js +196 -0
  95. package/workspace/public/pm/cozy-routine.css +102 -0
  96. package/workspace/public/pm/cozy-routine.js +156 -0
  97. package/workspace/public/pm/cozy-schedwork.js +6 -5
  98. package/workspace/public/pm/cozy-settings.js +10 -1
  99. package/workspace/public/pm/cozy-today-app.js +236 -0
  100. package/workspace/public/pm/cozy-today-model.js +176 -0
  101. package/workspace/public/pm/cozy-today-page.css +100 -0
  102. package/workspace/public/pm/cozy-today-view.js +76 -0
  103. package/workspace/public/pm/cozy-viewer.js +66 -18
  104. package/workspace/public/pm/home-app.js +29 -6
  105. package/workspace/public/pm/home-ini.js +39 -7
  106. package/workspace/public/pm/library-model.js +69 -0
  107. package/workspace/public/pm/library-open.js +34 -0
  108. package/workspace/public/pm/page-chat.js +16 -4
  109. package/workspace/public/pm/pop-sessions.js +65 -0
  110. package/workspace/public/pm/pop-work-model.js +335 -0
  111. package/workspace/public/pm/premium-board.js +137 -11
  112. package/workspace/public/pm/premium-insights.js +14 -2
  113. package/workspace/public/pm/premium-library.js +122 -0
  114. package/workspace/public/pm/premium-shell.js +1 -1
  115. package/workspace/public/premium-board.html +1 -0
  116. package/workspace/public/premium-events.html +42 -0
  117. package/workspace/public/premium-library.html +31 -0
  118. package/workspace/public/premium-routine.html +31 -0
  119. package/workspace/public/today.html +50 -0
  120. package/workspace/ready-dash-ui-test.js +3 -1
  121. package/workspace/rename-test.js +2 -1
  122. package/workspace/run-tests.js +4 -1
  123. package/workspace/server.js +3 -2
  124. package/workspace/sort-order-test.js +2 -1
  125. package/workspace/split-merge-ui-test.js +3 -1
  126. package/workspace/stage-card-tasks-test.js +5 -3
  127. package/workspace/stage-card-test.js +2 -1
  128. package/workspace/task-card-test.js +2 -1
  129. package/workspace/task-delete-test.js +3 -1
  130. package/workspace/task-links-test.js +4 -2
  131. package/workspace/task-milestones-test.js +4 -2
  132. package/workspace/task-plans-test.js +3 -1
  133. package/workspace/task-press-test.js +3 -1
  134. package/workspace/task-views-test.js +10 -8
  135. package/workspace/test-lists/events-place.json +11 -0
  136. package/workspace/test-lists/library-place.json +9 -0
  137. package/workspace/test-lists/one-popup.json +9 -0
  138. package/workspace/test-lists/pop-work.json +9 -0
  139. package/workspace/test-lists/routine-place.json +9 -0
  140. package/workspace/test-lists/today-log.json +9 -0
  141. package/workspace/test-lists/work-view.json +9 -0
  142. package/workspace/timeline-holds-test.js +3 -1
  143. package/workspace/tk-tasks-test.js +3 -1
  144. package/workspace/viewer-trail-test.js +1 -1
  145. package/workspace/workflows-setup-test.js +1 -1
@@ -0,0 +1,427 @@
1
+ /* pm/cozy-pop-work.js — what the popup shows for work (slice 3 of the six-place navigation; boards 3, 20, 21, 22, 25, 26, 27 on Exploring 2, page
2
+ * "Navigation: Today, Work, Goals, Events, Library, Routine"). Draws pm/pop-work-model.js in the popup's Viewer (pm/cozy-popup.js) and wires its
3
+ * presses to the host's own handlers, the same ones the old initiative page uses (pm/ini-view.js wireView). The look is cozy-pop-work.css.
4
+ *
5
+ * on(body) → true when the body is in the popup and the PM did not ask for every part (the old page): the host then
6
+ * draws html() and wires wire() in place of viewHtml() and wireView()
7
+ * html(r, v, o) → the initiative: Overview (summary ✦, PMOS suggests, the facts), Work breakdown (one view: the rows and the
8
+ * timeline on their right), Artefacts. o: what workOf() takes, plus ws, board, id (the record id)
9
+ * wire(body, h, x) once per body. h: the host's handlers (status, dates, addTask, openTask, openTicket, stagePick, planDates,
10
+ * next, wf, program, doc, sm, redraw, reload, toast, where); x: { r(), v(), o(), more(): the old ⋯ entries }
11
+ * moreItems(x, h) → the ⋯ entries the popup adds: Every part (the old page, as a drill-in), Dashboard, All PMOS suggests
12
+ * levelHtml(L, o) / wireLevel(body, h, L) a program or a product one level up (boards 26, 27)
13
+ *
14
+ * Writes, each on the PM's press only: a task's status and dates and a new task (the host's), ✓ and ✕ on a suggestion (POST /api/proposals/keep,
15
+ * /drop, Undo /undo), the summary changed or confirmed in place (POST /api/initiative/describe, Undo /api/initiative/describe-undo). Saved on
16
+ * leave, with Undo for a moment. Values read from the work (Gate, Open) and Jira tasks are not edited here.
17
+ * Reads: GET /api/library-items?ws&initiative (the Library's rows, slice 7) once per initiative; when that route is not there the core documents
18
+ * the page already reads stand in. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
+ import * as M from './pop-work-model.js';
20
+ import { openPop, closePop, undoToast } from './hi-pop.js';
21
+ import { pmGet, pmPost } from './http.js';
22
+ import * as VW from './cozy-viewer.js';
23
+ import * as ED from './ini-edit.js'; // the rename and its Undo, the same write as the old List (batch 18 item 16)
24
+
25
+ const CSS = new URL('./cozy-pop-work.css', import.meta.url).href;
26
+ if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
27
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
28
+ }
29
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
30
+ const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
31
+ const P = {
32
+ check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', right: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', plus: 'M12 5v14M5 12h14',
33
+ tune: 'M4 7h10M18 7h2M4 17h4M12 17h8M14 5v4M8 15v4', full: 'M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5', in: 'M9 4v5H4M15 4v5h5M15 20v-5h5M9 20v-5H4',
34
+ hide: 'M13 6l6 6-6 6M5 6l6 6-6 6', show: 'M11 6l-6 6 6 6M19 6l-6 6 6 6', open: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chat: 'M4 5h16v11H9l-5 4z', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
35
+ };
36
+ const STATES = ['To do', 'In progress', 'Done', "Won't do"];
37
+ const store = {
38
+ get(k, d) { try { const v = localStorage.getItem(k); return v == null ? d : JSON.parse(v); } catch { return d; } },
39
+ set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* a private window */ } },
40
+ };
41
+ const COLS = 'pw-cols', SPAN = 'pw-span', BIG = 'pw-big';
42
+ const cols = () => ({ status: true, date: true, tl: true, kind: true, when: true, ...store.get(COLS, {}) });
43
+ const ST = new Map(); // initiative id → { open, shut, doneOpen, farOpen, details, top }
44
+ const stOf = (id) => { if (!ST.has(id)) ST.set(id, { open: new Set(), shut: new Set(), doneOpen: new Set(), farOpen: false, details: null, top: 0 }); return ST.get(id); };
45
+ const ITEMS = new Map(); // initiative id → the Library's rows | null while reading | false when the route is not there
46
+ const ib = (attr, label, d, cls = '') => `<button type="button" class="pw-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(d)}</button>`;
47
+
48
+ /** The body is in the popup, and the PM did not ask for the old page there. */
49
+ export function on(body) { return !!(body && body.closest && body.closest('.cz-pop') && !body.closest('[data-pw-all]') && !(body.dataset && body.dataset.pwAll)); }
50
+
51
+ /* ── reads ── */
52
+ function readItems(id, ws, redraw) {
53
+ if (!id || ITEMS.has(id)) return;
54
+ ITEMS.set(id, null);
55
+ pmGet('/api/library-items?initiative=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) : ''))
56
+ .then((x) => { ITEMS.set(id, x && x.ok && Array.isArray(x.items) ? x.items : false); if (x && x.ok && (x.items || []).length) redraw(); })
57
+ .catch(() => ITEMS.set(id, false));
58
+ }
59
+ export const resetItems = () => ITEMS.clear();
60
+
61
+ /* ── the parts ── */
62
+ function overviewHtml(W, S, x) {
63
+ const fold = S.details == null ? W.many : !S.details;
64
+ const sm = W.summary;
65
+ const mark = sm.own ? '' : `<span class="pw-spark" aria-label="PMOS wrote this">${SVG(P.spark, 14, 2)}</span>`;
66
+ const conf = !sm.own && sm.draft ? ib('data-pw-sum-ok', 'Keep this description', P.check, 'sm') : '';
67
+ const sum = `<div class="pw-sum">${mark}<p class="pw-sum-t"><span class="pw-lead${sm.lead ? '' : ' ph'}" data-pw-sum tabindex="0" role="button" aria-label="${sm.lead ? 'Change what it is' : 'Say what it is'}">${esc(sm.lead || 'What it is')}</span>${sm.status ? ' ' + esc(sm.status) : ''}</p>${conf}</div>`;
68
+ const sug = W.suggests.length ? `<div class="pw-sugs" role="list" aria-label="PMOS suggests"><p class="pw-sugh">PMOS suggests</p>${W.suggests.map((s) => sugLine(s)).join('')}${W.more ? `<button type="button" class="pw-lk" data-pw-props>${esc(W.more + ' more')}</button>` : ''}</div>` : '';
69
+ const facts = fold ? '' : `<dl class="pw-facts">${W.facts.map((f) => `<div class="pw-f"><dt>${esc(f.k)}</dt><dd>${f.act && !f.read ? `<button type="button" class="pw-fv" data-pw-fact="${esc(f.act)}">` : '<span class="pw-fv ro">'}<span class="${f.grey ? 'grey' : ''}${f.warn && !f.note ? ' warn' : ''}">${esc(f.v)}</span>${f.note ? ` · <span class="${f.warn ? 'warn' : ''}">${esc(f.note)}</span>` : ''}${f.warn && !f.note ? '' : ''}${f.act && !f.read ? '</button>' : '</span>'}</dd></div>`).join('')}</dl>`;
70
+ const det = `<button type="button" class="pw-det" data-pw-details aria-expanded="${!fold}">${fold ? 'Details' : 'Less'}${SVG(fold ? P.right : P.down, 14)}</button>`;
71
+ return `<section class="pw-ov" aria-label="Overview"><div class="pw-ovh"><h3>Overview</h3>${det}</div>${sum}${sug}${facts}</section>`;
72
+ }
73
+ function sugLine(s, under) {
74
+ return `<div class="pw-sug${under ? ' under' : ''}" role="listitem"><button type="button" class="pw-sugt" data-pw-sug="${esc(s.id)}">${SVG(P.spark, 13, 2)}<span>${esc(s.say)}</span>${SVG(P.right, 14)}</button>`
75
+ + `<span class="pw-sugb">${ib(`data-pw-keep="${esc(s.id)}"`, 'Yes, do it', P.check, 'sm')}${ib(`data-pw-drop="${esc(s.id)}"`, 'No', P.x, 'sm')}</span></div>`;
76
+ }
77
+ function headCells(C, W, mode, kind) {
78
+ const mk = M.marksOf(W.span, W.today);
79
+ const tl = C.tl ? `<div class="pw-tl pw-tlh">${ib('data-pw-tl', 'Hide the timeline', P.hide, 'xs')}<button type="button" class="pw-span" data-pw-span aria-haspopup="menu">${esc((M.MODES.find((m) => m[0] === mode) || M.MODES[5])[1])}${SVG(P.down, 12)}</button>`
80
+ + mk.months.filter((m) => m.x > 26 && m.x < 90 && !(mk.today != null && mk.today > 30 && m.x > mk.today - 18 && m.x < mk.today + 7)).map((m) => `<span class="pw-mk" style="left:${m.x.toFixed(2)}%">${esc(m.label)}</span>`).join('') + (mk.today != null && mk.today > 30 ? `<span class="pw-tday" style="left:${mk.today.toFixed(2)}%">Today</span>` : '') + '</div>' : '';
81
+ return `<div class="pw-tr pw-th" role="row"><span role="columnheader">${kind || 'Item'}</span>${C.status ? '<span role="columnheader">Status</span>' : ''}${C.date ? '<span role="columnheader">Date</span>' : ''}${tl}</div>`;
82
+ }
83
+ function barHtml(x, W) {
84
+ const done = x.done || x.kind === 'done';
85
+ const b = M.barOf({ start: x.start, end: x.end, done, open: !done }, W.span, W.today);
86
+ if (!b || b.off) return '';
87
+ const lt = b.late ? `<i class="pw-late" style="left:${b.late.l.toFixed(2)}%;width:${b.late.w.toFixed(2)}%"></i><i class="pw-dia" style="left:${b.ms.toFixed(2)}%"></i>` : '';
88
+ return `<i class="pw-bar${x.kind === 'task' ? ' t' : ''}${b.dot ? ' dot' : ''}" style="left:${b.l.toFixed(2)}%;width:${b.w.toFixed(2)}%"><b style="width:${(b.w ? Math.min(100, (b.pass / b.w) * 100) : 0).toFixed(1)}%"></b></i>${lt}`;
89
+ }
90
+ function rowHtml(x, W, C, sugRows) {
91
+ const tl = C.tl ? `<div class="pw-tl">${(x.kind === 'stage' || x.kind === 'task' || x.kind === 'done') ? barHtml(x, W) : ''}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div>` : '';
92
+ const stc = C.status ? `<span class="pw-st">${x.kind === 'task' && !x.jira ? `<button type="button" class="pw-cell" data-pw-status="${esc(x.uid)}" aria-haspopup="menu" aria-label="${esc('Status: ' + x.status + '. Change it')}">${esc(x.status)}</button>` : esc(x.status || '')}</span>` : '';
93
+ const dtc = C.date ? `<span class="pw-dt${x.late ? ' warn' : ''}">${x.kind === 'task' && !x.jira ? `<button type="button" class="pw-cell${x.date ? '' : ' empty'}" data-pw-date="${esc(x.uid)}" aria-label="${esc((x.date ? 'Due ' + x.date : 'No date') + '. Set the date')}">${esc(x.date || 'Set a date')}</button>` : esc(x.date || '')}</span>` : '';
94
+ if (x.kind === 'stage') {
95
+ const lead = `<button type="button" class="pw-stg" data-pw-fold="${esc(x.key)}" aria-expanded="${x.open}"${x.can ? '' : ' disabled'}><span class="pw-n">${esc(x.n)}</span><b>${esc(x.name)}</b>${x.can ? SVG(x.open ? P.down : P.right, 14) : ''}<small>${esc(x.count)}</small></button>`;
96
+ return `<div class="pw-tr pw-sr${x.now ? ' now' : ''}" role="row"><span class="pw-it">${lead}</span>${stc}${dtc}${tl}</div>`;
97
+ }
98
+ if (x.kind === 'far') return `<div class="pw-tr pw-sr" role="row"><span class="pw-it"><button type="button" class="pw-stg" data-pw-far aria-expanded="false"><span class="pw-n">${esc(x.n)}</span><b>${esc(x.name)}</b>${SVG(P.right, 14)}<small>${esc(x.count)}</small></button></span>${stc}${C.date ? '<span></span>' : ''}${tl}</div>`;
99
+ if (x.kind === 'done') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-done="${esc(x.key)}" aria-expanded="${x.open}">${esc(x.label)}${SVG(x.open ? P.down : P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${tl}</div>`;
100
+ const s = sugRows.get(x.uid);
101
+ const title = x.jira ? `<span class="pw-tt">${esc(x.title)}</span>` : `<button type="button" class="pw-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
102
+ return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
103
+ + (s ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(s, true)}</span></div>` : '');
104
+ }
105
+ function breakdownHtml(W, C, mode, full) {
106
+ const sugRows = W.rowSuggests;
107
+ const add = (key, name) => `<div class="pw-tr pw-add" role="row"><span class="pw-it"><label class="pw-addf">${SVG(P.plus, 14)}<input data-pw-add="${esc(key)}" data-pw-add-name="${esc(name)}" placeholder="Add a task" aria-label="${esc('Add a task to ' + name)}" maxlength="200" autocomplete="off"></label></span></div>`;
108
+ let out = '', curSec = null;
109
+ for (let i = 0; i < W.rows.length; i++) {
110
+ const x = W.rows[i];
111
+ out += rowHtml(x, W, C, sugRows);
112
+ if (x.kind === 'stage' && x.open) curSec = x;
113
+ const nx = W.rows[i + 1];
114
+ if (curSec && (!nx || nx.kind === 'stage' || nx.kind === 'far')) { if (curSec.key !== '' ) out += add(curSec.key, curSec.name); curSec = null; }
115
+ }
116
+ const tools = `<span class="pw-tools">${ib(`data-pw-big aria-pressed="${!!full}"`, full ? 'Back to the initiative' : 'Give the work breakdown the whole popup', full ? P.in : P.full)}${ib('data-pw-tune="wbs" aria-haspopup="menu"', 'Show or hide columns', P.tune)}</span>`;
117
+ const show = !C.tl ? ib('data-pw-tl', 'Show the timeline', P.show, 'xs') : '';
118
+ return `<section class="pw-sec" aria-label="Work breakdown">${full ? `<div class="pw-sech">${tools}</div>` : `<div class="pw-sech"><h3>Work breakdown</h3>${show}${tools}</div>`}`
119
+ + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}" role="table" aria-label="Work breakdown">${headCells(C, W, mode)}${out || '<div class="pw-tr pw-empty" role="row"><span>No task yet.</span></div>'}</div>`
120
+ + (C.tl ? '<p class="pw-key"><span><i class="k-bar"></i>Passed and still planned</span><span><i class="k-dia"></i>Missed date</span><span><i class="k-late"></i>Late</span></p>' : '') + '</section>';
121
+ }
122
+ function artefactsHtml(rows, C, add = true) {
123
+ const body = rows.map((a, i) => `<div class="pw-ar${a.missing ? ' miss' : ''}" role="row"><span role="cell">${a.missing ? esc(a.title) : `<button type="button" class="pw-an" data-pw-art="${i}">${esc(a.title)}${a.link ? SVG(P.open, 13) : ''}</button>`}</span>`
124
+ + (C.kind ? `<span role="cell">${esc(a.kind)}</span>` : '') + (C.when ? `<span role="cell"${a.missing ? ' class="warn"' : ''}>${esc(a.missing || a.when || '')}</span>` : '') + '</div>').join('');
125
+ return `<section class="pw-sec" aria-label="Artefacts"><div class="pw-sech"><h3>Artefacts</h3><span class="pw-tools">${ib('data-pw-tune="art" aria-haspopup="menu"', 'Show or hide columns', P.tune)}</span></div>`
126
+ + `<div class="pw-card pw-arts${C.kind ? '' : ' nok'}${C.when ? '' : ' now'}" role="table" aria-label="Artefacts"><div class="pw-ar pw-th" role="row"><span role="columnheader">Artefact</span>${C.kind ? '<span role="columnheader">Kind</span>' : ''}${C.when ? '<span role="columnheader">Updated</span>' : ''}</div>${body}`
127
+ + (add ? `<button type="button" class="pw-ar pw-addart" data-pw-addart>${SVG(P.plus, 14)}<span>Add an artefact: a file, a link, or a new document</span></button>` : '') + '</div></section>';
128
+ }
129
+
130
+ /* ── the initiative ── */
131
+ const keyOf = (v, o) => String((o && o.id) || (v && (v.id || v.key)) || '');
132
+ function model(r, v, o) {
133
+ const id = keyOf(v, o), S = stOf(id), it = ITEMS.get(id);
134
+ const W = M.workOf(r, v, { ...o, open: S.open, shut: S.shut, doneOpen: S.doneOpen, farOpen: S.farOpen, mode: store.get(SPAN, 'full'), items: it || [] });
135
+ const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
136
+ return { W, S, id };
137
+ }
138
+ export function html(r, v, o = {}) {
139
+ const { W, S } = model(r, v, o), C = cols(), mode = store.get(SPAN, 'full');
140
+ if (S.big) return `<div class="pw" data-pw-big-on>${breakdownHtml(W, C, mode, true)}</div>`;
141
+ return `<div class="pw">${overviewHtml(W, S)}${breakdownHtml(W, C, mode, false)}${artefactsHtml(W.artefacts, C)}</div>`;
142
+ }
143
+
144
+ /* ── the suggestion as its own page (board 22) ── */
145
+ function sugPageHtml(s, W) {
146
+ const items = (s.items || []).slice(0, 8);
147
+ const ch = items.length && s.group === 'dates' ? `<h4>What changes if you say yes</h4><div class="pw-card pw-chg" role="table"><div class="pw-cr pw-th" role="row"><span>What</span><span>Now</span><span>After</span></div>`
148
+ + items.map((x) => `<div class="pw-cr" role="row"><span>${esc(x.title || x.task || '')}</span><span class="${x.from && x.from.due && x.from.due < W.today ? 'warn' : ''}">${esc(x.from && x.from.due ? M.dateLate(x.from.due, W.today).text : '—')}</span><span><b>${esc(x.to && x.to.due ? M.dayText(x.to.due, W.today) : '—')}</b></span></div>`).join('') + '</div>'
149
+ : items.length ? `<h4>What changes if you say yes</h4><ul class="pw-ul">${items.map((x) => `<li>${esc(x.title || x.task || x.stage || x.text || '')}</li>`).join('')}</ul>` : '';
150
+ const read = (s.sources || []).length ? `<h4>What PMOS read</h4><div class="pw-card">${s.sources.map((x, i) => `<button type="button" class="pw-src" data-pws-src="${i}"><span>${esc(x.label || x.ref || '')}</span>${x.ref ? SVG(P.right, 14) : ''}</button>`).join('')}</div>` : '';
151
+ return `<div class="pw pw-sp"><div class="pw-spc"><p class="pw-sugh">${SVG(P.spark, 13, 2)} PMOS suggests</p><h3>${esc(s.say)}</h3>`
152
+ + `<span class="pw-spb">${ib(`data-pws-keep="${esc(s.id)}"`, 'Yes, do it', P.check, 'solid')}${ib(`data-pws-drop="${esc(s.id)}"`, 'No', P.x)}</span></div>`
153
+ + (s.why ? `<h4>Why</h4><p>${esc(s.why)}</p>` : '') + ch + read
154
+ + `<button type="button" class="pw-ask" data-pws-ask>${SVG(P.chat, 15)}Ask PMOS about this</button></div>`;
155
+ }
156
+
157
+ /* ── writes ── */
158
+ async function keepSug(s, x, h) {
159
+ if (s.sm) { if (h.sm) h.sm('yes'); return; }
160
+ const w = h.where ? h.where() : {}, res = await pmPost('/api/proposals/keep', { ...w, initiative: x.o().id, ids: [s.id] }).catch(() => null);
161
+ if (!res || res.ok === false) { if (h.toast) h.toast((res && res.error) || 'Nothing was kept.'); return; }
162
+ const batch = res.batch;
163
+ undoToast(res.said || 'Done.', async () => {
164
+ const u = await pmPost('/api/proposals/undo', { ...w, batch }).catch(() => null);
165
+ if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
166
+ if (h.reload) await h.reload();
167
+ });
168
+ if (h.reload) await h.reload();
169
+ }
170
+ async function dropSug(s, x, h) {
171
+ if (s.sm) { if (h.sm) h.sm('no'); return; }
172
+ const w = h.where ? h.where() : {}, res = await pmPost('/api/proposals/drop', { ...w, initiative: x.o().id, sig: s.sig }).catch(() => null);
173
+ if (!res || res.ok === false) { if (h.toast) h.toast((res && res.error) || 'Nothing was changed.'); return; }
174
+ if (h.reload) await h.reload();
175
+ }
176
+ async function saveDesc(text, x, h) {
177
+ const w = h.where ? h.where() : {}, id = x.o().id;
178
+ const res = await pmPost('/api/initiative/describe', { ws: w.ws, id, text }).catch(() => null);
179
+ if (!res || res.ok === false) { if (h.toast) h.toast((res && res.error) || 'It was not saved.'); return false; }
180
+ if (!res.same) undoToast('Saved.', async () => {
181
+ const u = await pmPost('/api/initiative/describe-undo', { ws: w.ws, id, from: res.from || '', to: res.text }).catch(() => null);
182
+ if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
183
+ if (h.reload) await h.reload();
184
+ });
185
+ if (h.reload) await h.reload();
186
+ return true;
187
+ }
188
+ const findSug = (W, id) => W.suggests.find((s) => s.id === id) || [...W.rowSuggests.values()].find((s) => s.id === id) || null;
189
+
190
+ /* ── the presses ── */
191
+ export function wire(body, h0, x0) {
192
+ if (!body) return;
193
+ // the Viewer reuses its body for the next item: the presses read the item shown now from the body, so one set of listeners serves all
194
+ body.__pwh = ED.writes(h0); body.__pwx = x0;
195
+ { const c = cur(); if (c) { readItems(c.id, (x0.o() || {}).ws, () => redraw()); if (c.S.top) body.scrollTop = c.S.top; } }
196
+ if (body.__pw) return;
197
+ body.__pw = true;
198
+ function cur() { const x = body.__pwx, r = x && x.r(), v = x && x.v(); return r && v ? { r, v, ...model(r, v, x.o()) } : null; }
199
+ function redraw() { if (body.__pwh && body.__pwh.redraw) body.__pwh.redraw(); }
200
+ const live = (e) => !!body.__pwx && !!e.target.closest('.pw') && !e.target.closest('.pw-sp, [data-pw-level]');
201
+ body.addEventListener('scroll', () => { if (!body.querySelector(':scope > .pw, .pw:not(.pw-sp)')) return; const c = cur(); if (c) c.S.top = body.scrollTop; }, { passive: true });
202
+ body.addEventListener('click', async (e) => {
203
+ if (!live(e)) return;
204
+ const b = e.target.closest('button, [data-pw-sum]'); if (!b || b.disabled || !body.contains(b)) return;
205
+ const c = cur(); if (!c) return;
206
+ const h = body.__pwh, x = body.__pwx;
207
+ const d = b.dataset, S = c.S, W = c.W;
208
+ if ('pwDetails' in d) { S.details = !(S.details == null ? !W.many : S.details); redraw(); return; }
209
+ if (d.pwFold != null) { const k = d.pwFold, open = b.getAttribute('aria-expanded') === 'true'; S.open.delete(k); S.shut.delete(k); (open ? S.shut : S.open).add(k); redraw(); return; }
210
+ if ('pwFar' in d) { S.farOpen = true; redraw(); return; }
211
+ if (d.pwDone != null) { if (S.doneOpen.has(d.pwDone)) S.doneOpen.delete(d.pwDone); else S.doneOpen.add(d.pwDone); redraw(); return; }
212
+ if ('pwTl' in d) { store.set(COLS, { ...cols(), tl: !cols().tl }); redraw(); return; }
213
+ if ('pwSpan' in d) { spanMenu(b, redraw); return; }
214
+ if (d.pwTune) { tuneMenu(b, d.pwTune, redraw); return; }
215
+ if ('pwBig' in d) { big(c, x, h); return; }
216
+ if (d.pwKeep) { const s = findSug(W, d.pwKeep); if (s) { b.disabled = true; await keepSug(s, x, h); if (VW.current() && /^sug:/.test(VW.current().id)) VW.back(); } return; }
217
+ if (d.pwDrop) { const s = findSug(W, d.pwDrop); if (s) { b.disabled = true; await dropSug(s, x, h); if (VW.current() && /^sug:/.test(VW.current().id)) VW.back(); } return; }
218
+ if (d.pwSug) { const s = findSug(W, d.pwSug); if (s) openSug(s, c, x, h); return; }
219
+ if ('pwProps' in d) { if (h.props) h.props(); return; }
220
+ if ('pwSumOk' in d) { const dr = W.summary.draft; if (dr) { b.disabled = true; await keepSug({ id: dr.id }, x, h); } return; }
221
+ if ('pwSum' in d) { editSum(b, c, x, h); return; }
222
+ if (d.pwFact) { fact(d.pwFact, b, c, h); return; }
223
+ if (d.pwStatus) { statusMenu(b, d.pwStatus, h); return; }
224
+ if (d.pwDate) { dateMenu(b, d.pwDate, c, h); return; }
225
+ if (d.pwName) { rename(b, d.pwName, h); return; }
226
+ if (d.pwOpen) { if (h.openTask) h.openTask(d.pwOpen); return; }
227
+ if (d.pwArt != null) { openArt(W.artefacts[+d.pwArt], h, x); return; }
228
+ if ('pwAddart' in d) { addArt(x, h); return; }
229
+ });
230
+ body.addEventListener('keydown', async (e) => {
231
+ if (!live(e)) return;
232
+ const t = e.target, h = body.__pwh;
233
+ if (t.matches && t.matches('[data-pw-sum]') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); t.click(); return; }
234
+ if (t.matches && t.matches('[data-pw-add]') && e.key === 'Enter') {
235
+ e.preventDefault(); const v = t.value.trim(); if (!v || !h.addTask) return;
236
+ const sec = t.dataset.pwAdd;
237
+ await h.addTask(v, t, { section: sec, name: t.dataset.pwAddName });
238
+ // Enter only adds the row; the field stays for the next one
239
+ setTimeout(() => { const f = body.querySelector(`[data-pw-add="${CSS.escape(sec)}"]`); if (f) { f.value = ''; f.focus(); } }, 0);
240
+ }
241
+ });
242
+ }
243
+ function big(c, x, h) {
244
+ const S = c.S;
245
+ if (S.big) { S.big = false; VW.back(); return; }
246
+ // the breakdown takes the whole popup (board 25): a drill-in of its own, the chat gives way; ← or the same button comes back
247
+ const r = c.r, title = (x.v() || {}).title || r.title || '';
248
+ S.big = true;
249
+ const hide = document.querySelector('.cz-pop [data-pop="hide"]');
250
+ const hid = !!(hide && !document.querySelector('.cz-pop-card.cz-pop-nochat'));
251
+ if (hide) hide.click();
252
+ VW.drill();
253
+ VW.open({ kind: 'Work breakdown', title: 'Work breakdown', icon: 'list', id: 'wbs:' + c.id, back: true,
254
+ render: (b) => { b.dataset.pwBig = '1'; const o = x.o(); S.big = true; b.innerHTML = html(x.r(), x.v(), o); wire(b, { ...h, redraw: () => { const t = b.scrollTop; b.innerHTML = html(x.r(), x.v(), x.o()); b.scrollTop = t; } }, x); },
255
+ onClose: () => { S.big = false; if (hid) { const ask = document.querySelector('.cz-pop [data-pop="ask"]'); if (ask && !ask.closest('[hidden]')) ask.click(); } } });
256
+ void title;
257
+ }
258
+ function openSug(s, c, x, h) {
259
+ VW.drill();
260
+ VW.open({ kind: 'Suggestion', title: 'Suggestion', icon: 'spark', id: 'sug:' + s.id, back: true,
261
+ render: (b) => {
262
+ const W = model(x.r(), x.v(), x.o()).W, s2 = findSug(W, s.id) || s;
263
+ b.innerHTML = sugPageHtml(s2, W);
264
+ b.onclick = async (e) => {
265
+ const t = e.target.closest('button'); if (!t) return;
266
+ const d = t.dataset;
267
+ if (d.pwsKeep) { t.disabled = true; await keepSug(s2, x, h); VW.back(); return; }
268
+ if (d.pwsDrop) { t.disabled = true; await dropSug(s2, x, h); VW.back(); return; }
269
+ if ('pwsAsk' in d) { askAbout(s2, x); return; }
270
+ if (d.pwsSrc != null) { const src = (s2.sources || [])[+d.pwsSrc]; if (src && src.ref) openRef(src.ref, h); }
271
+ };
272
+ } });
273
+ }
274
+ /** "Ask PMOS about this": the suggestion goes into the chat on the right, as a draft the PM sends. */
275
+ function askAbout(s, x) {
276
+ const ask = document.querySelector('.cz-pop [data-pop="ask"]'); if (ask && !ask.closest('[hidden]')) ask.click();
277
+ const ta = document.querySelector('.cz-pop-chat textarea, .cz-pop-chat [contenteditable="true"]');
278
+ const text = 'About this suggestion on ' + ((x.v() || {}).title || '') + ': "' + s.say + '". ' + (s.why ? 'You said: ' + s.why + ' ' : '') + 'Why do you suggest it, and what else would it change?';
279
+ if (ta) { if ('value' in ta) { ta.value = text; ta.dispatchEvent(new Event('input', { bubbles: true })); } else ta.textContent = text; ta.focus(); }
280
+ }
281
+ function openRef(ref, h) {
282
+ const s = String(ref);
283
+ if (/^https?:/.test(s)) { window.open(s, '_blank', 'noopener'); return; }
284
+ if (/^task:/.test(s) && h.openTask) { h.openTask(s.slice(5)); return; }
285
+ if (/\.(md|txt|html|pdf|docx?)$/i.test(s) && h.doc) h.doc(s);
286
+ }
287
+ function fact(act, b, c, h) {
288
+ if (act === 'stage' && h.stagePick) h.stagePick(b);
289
+ else if (act === 'dates' && h.planDates) h.planDates(b);
290
+ else if (act === 'next' && h.next) h.next(b);
291
+ else if (act === 'wf' && h.wf) h.wf(b);
292
+ else if (act === 'product' && h.product) h.product(b);
293
+ else if (act === 'program' && h.program) { const p = (c.v.summary || {}).program; if (p) h.program(p.id, b); }
294
+ else if (act.startsWith('task:') && h.openTask) h.openTask(act.slice(5));
295
+ }
296
+ function editSum(el, c, x, h) {
297
+ if (el.querySelector('textarea')) return;
298
+ const was = c.W.summary.lead || '';
299
+ const ta = document.createElement('textarea');
300
+ ta.className = 'pw-sumed'; ta.value = c.W.summary.own ? was : was; ta.rows = 3; ta.maxLength = 600; ta.setAttribute('aria-label', 'What this initiative is');
301
+ el.replaceWith(ta); ta.focus();
302
+ let done = false;
303
+ const leave = async (save) => {
304
+ if (done) return; done = true;
305
+ const v = ta.value.replace(/\s+/g, ' ').trim();
306
+ if (save && v && v !== was) await saveDesc(v, x, h);
307
+ else if (h.redraw) h.redraw();
308
+ };
309
+ ta.addEventListener('blur', () => leave(true));
310
+ ta.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); leave(false); } else if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); ta.blur(); } });
311
+ }
312
+ function rename(btn, uid, h) {
313
+ const inp = document.createElement('input');
314
+ inp.className = 'pw-namei'; inp.value = btn.textContent; inp.maxLength = 200; inp.setAttribute('aria-label', 'Name of the task');
315
+ const was = btn.textContent;
316
+ btn.replaceWith(inp); inp.focus(); inp.select();
317
+ let done = false;
318
+ const leave = async (save) => {
319
+ if (done) return; done = true;
320
+ const v = inp.value.trim();
321
+ if (save && v && v !== was && h.rename) await h.rename(uid, v);
322
+ else if (h.redraw) h.redraw();
323
+ };
324
+ inp.addEventListener('blur', () => leave(true));
325
+ inp.addEventListener('keydown', (e) => {
326
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); leave(false); return; }
327
+ if (e.key === 'Enter') {
328
+ // Enter saves the name and opens "Add a task" under the same stage
329
+ e.preventDefault();
330
+ const row = inp.closest('[data-pw-row]'), sec = row ? row.dataset.pwSec : null;
331
+ inp.blur();
332
+ if (sec != null) setTimeout(() => { const f = document.querySelector(`.cz-pop [data-pw-add="${CSS.escape(sec)}"]`); if (f) f.focus(); }, 60);
333
+ }
334
+ });
335
+ }
336
+ function statusMenu(btn, uid, h) {
337
+ openPop(btn, 'pw-status', STATES.map((s) => `<button type="button" class="hi-mi" role="menuitem" data-st="${esc(s)}">${esc(s)}</button>`).join(''), (b) => {
338
+ closePop(); if (b.dataset.st && h.status) h.status(uid, b.dataset.st);
339
+ }, { menu: true, label: 'Status' });
340
+ }
341
+ function dateMenu(btn, uid, c, h) {
342
+ const row = c.W.rows.find((x) => x.uid === uid) || {};
343
+ const el = openPop(btn, 'pw-date', `<label class="hi-field"><span>Due</span><input type="date" id="pwDue" value="${esc(row.end || '')}"></label>`
344
+ + `<div class="hi-acts"><button type="button" class="hi-btn ghost" data-clear>No date</button></div>`, (b) => {
345
+ if ('clear' in b.dataset) { closePop(); if (h.dates) h.dates(uid, { due: '' }); }
346
+ }, { label: 'Set the date', focus: '#pwDue' });
347
+ const i = el.querySelector('#pwDue');
348
+ i.addEventListener('change', () => { if (/^\d{4}-\d{2}-\d{2}$/.test(i.value)) { closePop(); if (h.dates) h.dates(uid, { due: i.value }); } });
349
+ }
350
+ function spanMenu(btn, redraw) {
351
+ const cur = store.get(SPAN, 'full');
352
+ openPop(btn, 'pw-span', M.MODES.map(([k, l]) => `<button type="button" class="hi-mi" role="menuitemradio" aria-checked="${k === cur}" data-sp="${k}">${esc(l)}</button>`).join(''), (b) => {
353
+ closePop(); if (b.dataset.sp) { store.set(SPAN, b.dataset.sp); redraw(); }
354
+ }, { menu: true, label: 'Span of the timeline' });
355
+ }
356
+ function tuneMenu(btn, which, redraw) {
357
+ const C = cols();
358
+ const L = which === 'art' ? [['kind', 'Kind'], ['when', 'Updated']] : [['status', 'Status'], ['date', 'Date'], ['tl', 'Timeline, on the right']];
359
+ openPop(btn, 'pw-tune', `<p class="hi-h3">${which === 'art' ? 'Artefact always shows' : 'Item always shows'}</p>` + L.map(([k, l]) => `<button type="button" class="hi-mi pw-sw" role="menuitemcheckbox" aria-checked="${!!C[k]}" data-col="${k}"><span>${esc(l)}</span><i aria-hidden="true"></i></button>`).join('')
360
+ + '<button type="button" class="hi-mi" data-reset>Reset</button>', (b) => {
361
+ if (b.dataset.col) { const n = { ...cols(), [b.dataset.col]: !cols()[b.dataset.col] }; store.set(COLS, n); b.setAttribute('aria-checked', String(!!n[b.dataset.col])); redraw(); return; }
362
+ if ('reset' in b.dataset) { store.set(COLS, {}); store.set(SPAN, 'full'); closePop(); redraw(); }
363
+ }, { menu: true, label: 'Columns' });
364
+ }
365
+ async function openArt(a, h, x) {
366
+ if (!a || a.missing) return;
367
+ if (a.url) { window.open(a.url, '_blank', 'noopener'); return; }
368
+ if (a.item) {
369
+ if (a.item.kind === 'link' && a.item.open && a.item.open.url) { window.open(a.item.open.url, '_blank', 'noopener'); return; }
370
+ try { const L = await import('./library-open.js'); VW.drill(); await L.openItem(a.item); return; } catch { /* the Library's opener is not there: the path below */ }
371
+ const p = a.item.open && a.item.open.path; if (p && h.doc) { h.doc(p); return; }
372
+ }
373
+ if (a.path && h.doc) h.doc(a.path);
374
+ }
375
+ async function addArt(x, h) {
376
+ const o = x.o(), w = h.where ? h.where() : {};
377
+ if (h.addDoc) { h.addDoc(); return; }
378
+ const A = await import('./home-adddoc.js');
379
+ VW.drill();
380
+ A.openAddDocVw({ VW, pmPost, toast: h.toast || (() => {}), ws: w.ws || o.ws, scope: 'initiative:' + o.id, title: (x.v() || {}).title || '', back: () => VW.back(),
381
+ onAdded: async () => { ITEMS.delete(o.id); if (h.reload) await h.reload(); VW.back(); } });
382
+ }
383
+
384
+ /** The ⋯ entries the popup adds before the host's own: every part of the old page, as a drill-in, and every suggestion. */
385
+ export function moreItems(x, h) {
386
+ const out = [];
387
+ if (h.allParts) out.push({ label: 'Every part', on: () => h.allParts() });
388
+ if (h.props) out.push({ label: 'Everything PMOS suggests', on: () => h.props() });
389
+ return out.length ? out.concat({ sep: true }) : out;
390
+ }
391
+
392
+ /* ── one level up: a program or a product (boards 26, 27) ── */
393
+ export function levelHtml(L, o = {}) {
394
+ const W = M.levelOf(L, { today: o.today, mode: store.get(SPAN, 'full') }), C = cols(), mode = store.get(SPAN, 'full');
395
+ const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
396
+ const sug = W.suggests.length ? `<div class="pw-sugs" role="list" aria-label="PMOS suggests"><p class="pw-sugh">PMOS suggests</p>${W.suggests.map((s) => sugLine(s)).join('')}</div>` : '';
397
+ const facts = W.facts.length ? `<dl class="pw-facts">${W.facts.map((f) => `<div class="pw-f"><dt>${esc(f.k)}</dt><dd><span class="pw-fv ro"><span>${esc(f.v)}</span>${f.note ? ` · <span class="${f.warn ? 'warn' : ''}">${esc(f.note)}</span>` : ''}</span></dd></div>`).join('')}</dl>` : '';
398
+ const ov = `<section class="pw-ov" aria-label="Overview"><div class="pw-ovh"><h3>Overview</h3></div>${W.summary ? `<div class="pw-sum"><span class="pw-spark" aria-label="PMOS wrote this">${SVG(P.spark, 14, 2)}</span><p class="pw-sum-t">${esc(W.summary)}</p></div>` : ''}${sug}${facts}</section>`;
399
+ const head = o.rowsTitle || (W.kind === 'product' ? 'Programs and initiatives' : 'Initiatives');
400
+ const rows = W.rows.map((x) => {
401
+ const tl = C.tl ? `<div class="pw-tl">${barHtml({ ...x, kind: 'stage' }, W)}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div>` : '';
402
+ const lead = x.group ? `<b class="pw-grp">${esc(x.title)}</b>` : `<button type="button" class="pw-stg lv${x.sub ? ' sub' : ''}" data-pw-go="${esc(x.kind + ':' + x.id)}"><b>${esc(x.title)}</b>${SVG(P.right, 14)}${x.count ? `<small>${esc(x.count)}</small>` : ''}</button>`;
403
+ return `<div class="pw-tr pw-sr" role="row"><span class="pw-it">${lead}</span>${C.status ? `<span class="pw-st">${esc(x.stage || '')}</span>` : ''}${C.date ? `<span class="pw-dt${x.late ? ' warn' : ''}">${esc(x.date || '')}</span>` : ''}${tl}</div>`;
404
+ }).join('');
405
+ const wbs = `<section class="pw-sec" aria-label="${esc(head)}"><div class="pw-sech"><h3>${esc(head)}</h3>${!C.tl ? ib('data-pw-tl', 'Show the timeline', P.show, 'xs') : ''}<span class="pw-tools">${ib('data-pw-tune="wbs" aria-haspopup="menu"', 'Show or hide columns', P.tune)}</span></div>`
406
+ + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}" role="table">${headCells(C, W, mode, W.kind === 'product' ? 'Program or initiative' : 'Initiative').replace('<span role="columnheader">Status</span>', '<span role="columnheader">Stage</span>')}${rows || '<div class="pw-tr pw-empty" role="row"><span>Nothing one level down yet.</span></div>'}</div></section>`;
407
+ return `<div class="pw" data-pw-level>${ov}${wbs}${W.artefacts.length || o.add !== false ? artefactsHtml(W.artefacts, C, o.add !== false) : ''}</div>`;
408
+ }
409
+ export function wireLevel(body, h0, L0) {
410
+ if (!body) return;
411
+ body.__pwlh = h0; body.__pwlL = L0;
412
+ if (body.__pwl) return;
413
+ body.__pwl = true;
414
+ body.addEventListener('click', (e) => {
415
+ if (!e.target.closest('[data-pw-level]')) return;
416
+ const h = body.__pwlh, L = body.__pwlL, redraw = () => { if (h.redraw) h.redraw(); };
417
+ const b = e.target.closest('button'); if (!b || b.disabled) return;
418
+ const d = b.dataset;
419
+ if ('pwTl' in d) { store.set(COLS, { ...cols(), tl: !cols().tl }); redraw(); return; }
420
+ if ('pwSpan' in d) { spanMenu(b, redraw); return; }
421
+ if (d.pwTune) { tuneMenu(b, d.pwTune, redraw); return; }
422
+ if (d.pwGo) { const i = d.pwGo.indexOf(':'); if (h.go) h.go(d.pwGo.slice(0, i), d.pwGo.slice(i + 1), b); return; }
423
+ if (d.pwArt != null) { const a = M.levelOf(L()).artefacts[+d.pwArt]; if (a && h.art && h.art(a, b)) return; if (a && a.url) window.open(a.url, '_blank', 'noopener'); else if (a && a.path && h.doc) h.doc(a.path); return; }
424
+ if ('pwAddart' in d) { if (h.addDoc) h.addDoc(b); return; }
425
+ if (d.pwKeep || d.pwDrop) { if (h.suggest) h.suggest(d.pwKeep ? 'keep' : 'drop', d.pwKeep || d.pwDrop, b); }
426
+ });
427
+ }
@@ -0,0 +1,113 @@
1
+ /* pm/cozy-popup.css — the one popup (slice 2 of the six-place navigation, boards 3, 7 and 23): the work on the left, Ask PMOS on the right. */
2
+ .cz-pop { position: fixed; inset: 0; z-index: 72; /* above the page and a floating Viewer (70), below the menus, pickers and toasts a press inside opens (74 and up) */ font-family: var(--cz-sans); color: var(--cz-ink); }
3
+ .cz-pop[hidden] { display: none; }
4
+ .cz-pop-sc { position: absolute; inset: 0; background: rgba(30, 34, 42, .28); }
5
+ .cz-pop-card { --pop-chat: 460px; position: absolute; inset: 16px 20px; display: flex; min-width: 0; overflow: hidden; border-radius: 28px;
6
+ background: var(--cz-card); box-shadow: 0 40px 100px -30px rgba(20, 24, 32, .6), 0 0 0 1px var(--cz-hair); }
7
+ .cz-pop-card:focus { outline: none; }
8
+ /* the left side: the page's Viewer, lifted in (cozy-viewer.js popInst) */
9
+ .cz-pop-l { flex: 1 1 auto; min-width: 480px; display: flex; min-height: 0; }
10
+ .cz-pop .cz-vw.cz-vw-pop { position: static !important; flex: 1 1 auto !important; width: auto !important; max-width: none !important; height: auto !important;
11
+ margin: 0 !important; transform: none !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; }
12
+ .cz-pop .cz-vw.cz-vw-pop > .cz-vw-grip { display: none; }
13
+ .cz-pop .cz-vw.cz-vw-pop .cz-vw-hd { border-bottom: 0; padding: 18px 20px 10px 22px; }
14
+ .cz-pop-card.chat-off .cz-vw.cz-vw-pop .cz-vw-hd { padding-right: 200px; }
15
+ .cz-vw-path { display: inline-flex; align-items: baseline; gap: 6px; flex: 0 1 auto; min-width: 0; max-width: 55%; overflow: hidden; white-space: nowrap; }
16
+ .cz-vw-path button { all: unset; cursor: pointer; font-size: var(--fs-meta); color: var(--cz-ink3); overflow: hidden; text-overflow: ellipsis; border-radius: 6px; }
17
+ .cz-vw-path button:hover { color: var(--cz-ink); text-decoration: underline; }
18
+ .cz-vw-path button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
19
+ .cz-vw-path span { color: var(--cz-ink3); font-size: var(--fs-meta); }
20
+ /* the grip: the line between the two sides, with its handle */
21
+ .cz-pop-grip { position: relative; flex: none; width: 1px; background: var(--cz-hair); cursor: col-resize; touch-action: none; }
22
+ .cz-pop-grip::before { content: ''; position: absolute; inset: 0 -6px; }
23
+ .cz-pop-grip i { position: absolute; left: -3px; top: 50%; width: 7px; height: 44px; margin-top: -22px; border-radius: 4px; background: var(--cz-card); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cz-ink3) 45%, transparent); }
24
+ .cz-pop-grip:hover i, .cz-pop-grip:focus-visible i { background: var(--cz-well); }
25
+ .cz-pop-grip:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
26
+ body.cz-pop-drag, body.cz-pop-drag * { cursor: col-resize !important; user-select: none !important; }
27
+ /* the right side: Ask PMOS */
28
+ .cz-pop-r { position: relative; flex: 0 0 var(--pop-chat); width: var(--pop-chat); min-width: 360px; display: flex; flex-direction: column; min-height: 0; }
29
+ .cz-pop-card.chat-off .cz-pop-r, .cz-pop-card.chat-off .cz-pop-grip { display: none; }
30
+ .cz-pop-hd { flex: none; display: flex; align-items: center; gap: 8px; padding: 18px 16px 10px 18px; }
31
+ .cz-pop-tile { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--cz-bluebg); color: var(--cz-blueink); }
32
+ .cz-pop-tile svg, .cz-pop-ib svg, .cz-pop-t svg, .cz-pop-f svg, .cz-pop-s svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
33
+ .cz-pop-t { all: unset; box-sizing: border-box; cursor: pointer; min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px;
34
+ background: var(--cz-well); font-size: var(--fs-row); font-weight: var(--fw-strong); color: var(--cz-ink); }
35
+ .cz-pop-t span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
36
+ .cz-pop-go:focus-visible, .cz-pop-t:focus-visible, .cz-pop-ib:focus-visible, .cz-pop-x:focus-visible, .cz-pop-sr:focus-visible, .cz-pop-f:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
37
+ .cz-pop-tw { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
38
+ .cz-pop-ib { all: unset; box-sizing: border-box; flex: none; cursor: pointer; width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; color: var(--cz-ink2); }
39
+ .cz-pop-ib:hover { background: var(--cz-well); color: var(--cz-ink); }
40
+ .cz-pop-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
41
+ .cz-pop-chat > .hm-chat { flex: 1 1 auto !important; min-height: 0 !important; width: auto !important; max-width: none !important; margin: 0 !important; border: 0 !important;
42
+ border-radius: 0 !important; box-shadow: none !important; background: transparent !important; position: relative !important; transform: none !important; display: flex; flex-direction: column; }
43
+ .cz-pop-chat .hm-chd, .cz-pop-chat .hm-reopen { display: none !important; } /* the popup's own top bar names the session */
44
+ .cz-pop-chat .ut-mic { all: unset; box-sizing: border-box; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
45
+ .cz-pop-chat .ut-mic:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
46
+ /* the state of the session shown, on the chat's last line (board 7) */
47
+ .cz-pop-st { display: flex; align-items: center; gap: 8px; padding: 4px 22px 10px; font-size: var(--fs-meta); font-weight: var(--fw-strong); }
48
+ .cz-pop-st[hidden] { display: none; }
49
+ .cz-pop-st.wait { color: var(--cz-risk); }
50
+ .cz-pop-st.work { color: var(--cz-blueink); }
51
+ .cz-pop-st i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
52
+ .cz-pop-st button { all: unset; cursor: pointer; margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink2);
53
+ padding: 4px 10px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--cz-hair); }
54
+ .cz-pop-st button b { width: 8px; height: 8px; border-radius: 2px; background: var(--cz-ink2); }
55
+ /* the session rows: the chooser and All sessions */
56
+ .cz-pop-sr { box-sizing: border-box; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto 28px; align-items: center; column-gap: 10px; padding: 9px 10px; border-radius: 10px;
57
+ cursor: pointer; width: 100%; text-align: left; }
58
+ .cz-pop-go { all: unset; box-sizing: border-box; min-width: 0; cursor: pointer; border-radius: 6px; }
59
+ .cz-pop-sr:hover, .cz-pop-sr.on { background: var(--cz-well); }
60
+ .cz-pop-sr b { display: block; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
61
+ .cz-pop-sr small { display: block; font-size: var(--fs-meta); color: var(--cz-ink3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
62
+ .cz-pop-sr em { font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); white-space: nowrap; }
63
+ .cz-pop-sr em.work { color: var(--cz-blueink); }
64
+ .cz-pop-sr em.wait { color: var(--cz-risk); }
65
+ .cz-pop-d { width: 8px; height: 8px; border-radius: 50%; justify-self: center; }
66
+ .cz-pop-d.work { background: var(--cz-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cz-blue) 20%, transparent); }
67
+ .cz-pop-d.wait { background: var(--cz-risk); }
68
+ .cz-pop-x { all: unset; box-sizing: border-box; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-card);
69
+ box-shadow: inset 0 0 0 1px var(--cz-hair); }
70
+ .cz-pop-x i { width: 9px; height: 9px; border-radius: 2px; background: var(--cz-ink2); }
71
+ .cz-pop-x:hover { box-shadow: inset 0 0 0 1px var(--cz-ink3); }
72
+ .cz-pop-m { position: absolute; z-index: 25; left: 12px; top: 62px; width: min(388px, calc(100% - 24px)); max-height: calc(100% - 80px); overflow: auto; box-sizing: border-box; padding: 8px;
73
+ border-radius: 16px; background: var(--cz-card); box-shadow: 0 18px 48px -12px rgba(30, 34, 42, .34), 0 0 0 1px var(--cz-hair); }
74
+ .cz-pop-m h6, .cz-pop-all h6 { margin: 6px 10px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink3); }
75
+ .cz-pop-m hr { border: 0; border-top: 1px solid var(--cz-hair); margin: 6px 4px; }
76
+ .cz-pop-f { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-size: var(--fs-body); font-weight: var(--fw-regular); color: var(--cz-ink2); }
77
+ .cz-pop-f:hover { background: var(--cz-well); color: var(--cz-ink); }
78
+ .cz-pop-f span { margin-left: auto; font-size: var(--fs-meta); color: var(--cz-ink3); }
79
+ /* All sessions (board 23): the full list on the chat side, or on the left when the session is about no work */
80
+ .cz-pop-all { position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; top: 64px; box-sizing: border-box; display: flex; flex-direction: column; padding: 6px 16px 16px; background: var(--cz-card); }
81
+ .cz-pop-all[hidden] { display: none; }
82
+ .cz-pop-r.all-on .cz-pop-chat { visibility: hidden; } /* the card's colour is see-through: the chat under the list does not show */
83
+ .cz-pop-list { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
84
+ .cz-pop-scr { flex: 1 1 auto; min-height: 0; overflow: auto; }
85
+ .cz-pop-s { flex: none; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px; border-radius: 12px; background: var(--cz-well); color: var(--cz-ink3); margin: 0 0 6px; }
86
+ .cz-pop-s input:focus-visible { outline: none; }
87
+ .cz-pop-s:focus-within { box-shadow: inset 0 0 0 2px var(--cz-blue); }
88
+ .cz-pop-s input { all: unset; flex: 1; min-width: 0; font-size: var(--fs-body); color: var(--cz-ink); }
89
+ .cz-pop-s input::placeholder { color: var(--cz-ink3); }
90
+ .cz-pop-c { border-radius: 14px; box-shadow: inset 0 0 0 1px var(--cz-hair); overflow: hidden; }
91
+ .cz-pop-c .cz-pop-sr { border-radius: 0; padding: 9px 12px; }
92
+ .cz-pop-c .cz-pop-sr + .cz-pop-sr { box-shadow: inset 0 1px 0 var(--cz-hair); }
93
+ .cz-pop-list h6 { margin: 14px 6px 4px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink3); }
94
+ .cz-pop-none { margin: 16px 6px; font-size: var(--fs-body); color: var(--cz-ink3); }
95
+ .cz-pop-n { all: unset; box-sizing: border-box; flex: none; cursor: pointer; margin-top: 12px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
96
+ font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); background: var(--cz-well); }
97
+ .cz-pop-n svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
98
+ .cz-pop-n:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
99
+ .cz-pop-l .cz-pop-list { padding: 4px 22px 22px; height: 100%; box-sizing: border-box; }
100
+ /* chat hidden: its way back and the close, at the top right of the work */
101
+ .cz-pop-tools { position: absolute; z-index: 6; top: 18px; right: 18px; display: flex; align-items: center; gap: 6px; }
102
+ .cz-pop-tools[hidden] { display: none; }
103
+ .cz-pop-ask { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: var(--fs-body); font-weight: var(--fw-strong);
104
+ color: var(--cz-ink); background: var(--cz-well); }
105
+ .cz-pop-ask svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
106
+ .cz-pop-ask:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
107
+ /* "Session ended · Undo" for a few seconds */
108
+ .cz-pop-toast { position: absolute; z-index: 30; left: 16px; right: 16px; bottom: 96px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px;
109
+ background: var(--cz-solid); color: var(--cz-onsolid); font-size: var(--fs-body); box-shadow: var(--cz-float); }
110
+ .cz-pop-toast[hidden] { display: none; }
111
+ .cz-pop-toast button { all: unset; cursor: pointer; margin-left: auto; font-weight: var(--fw-strong); text-decoration: underline; }
112
+ .cz-pop-toast button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
113
+ body.cz-pop-on { overflow: hidden; }