create-pmos 0.611.0 → 0.613.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 (97) hide show
  1. package/package.json +105 -27
  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-board-test.js +1 -1
  8. package/workspace/briefing-premium-calendar-2-test.js +3 -2
  9. package/workspace/briefing-premium-calendar-3-test.js +1 -1
  10. package/workspace/briefing-premium-calendar-test.js +1 -1
  11. package/workspace/briefing-premium-insights-test.js +1 -1
  12. package/workspace/briefing-premium-test.js +1 -1
  13. package/workspace/changelog.json +104 -0
  14. package/workspace/guide/layout.md +52 -18
  15. package/workspace/guide/programs.md +3 -3
  16. package/workspace/guide/routine.md +28 -13
  17. package/workspace/guide/settings-and-switches.md +1 -1
  18. package/workspace/lib/board-premium.js +12 -4
  19. package/workspace/lib/cos-chat.js +1 -0
  20. package/workspace/lib/doc-library.js +43 -12
  21. package/workspace/lib/doc-path.js +30 -0
  22. package/workspace/lib/engine/boards.js +4 -2
  23. package/workspace/lib/events-place.js +190 -38
  24. package/workspace/lib/events-stated.js +129 -0
  25. package/workspace/lib/initiative-chat.js +1 -0
  26. package/workspace/lib/insights-premium.js +13 -1
  27. package/workspace/lib/library-find.js +162 -0
  28. package/workspace/lib/library-items.js +196 -24
  29. package/workspace/lib/notes.js +3 -0
  30. package/workspace/lib/plan-items.js +17 -3
  31. package/workspace/lib/routes-artefacts.js +5 -2
  32. package/workspace/lib/routes-boards.js +6 -2
  33. package/workspace/lib/routes-doc-sheet.js +1 -0
  34. package/workspace/lib/routes-events-place.js +47 -10
  35. package/workspace/lib/routes-library.js +74 -8
  36. package/workspace/lib/routes-report-setups.js +13 -2
  37. package/workspace/lib/routine-reports.js +36 -4
  38. package/workspace/lib/status-when.js +36 -0
  39. package/workspace/lib/task-items.js +5 -3
  40. package/workspace/package-lock.json +2 -2
  41. package/workspace/package.json +1 -1
  42. package/workspace/premium-vw-meet-test.js +2 -1
  43. package/workspace/premium-vw-notes-test.js +3 -2
  44. package/workspace/public/pm/artefact-kind.js +87 -0
  45. package/workspace/public/pm/bd-ini-panel.js +6 -6
  46. package/workspace/public/pm/bd-span.js +7 -1
  47. package/workspace/public/pm/bd-work.css +62 -0
  48. package/workspace/public/pm/bd-work.js +195 -68
  49. package/workspace/public/pm/cozy-bar.css +11 -0
  50. package/workspace/public/pm/cozy-bar.js +99 -0
  51. package/workspace/public/pm/cozy-day-pick.css +27 -0
  52. package/workspace/public/pm/cozy-day-pick.js +97 -0
  53. package/workspace/public/pm/cozy-ev.css +0 -4
  54. package/workspace/public/pm/cozy-events-view.js +165 -33
  55. package/workspace/public/pm/cozy-events.css +75 -3
  56. package/workspace/public/pm/cozy-events.js +86 -18
  57. package/workspace/public/pm/cozy-goals.css +172 -0
  58. package/workspace/public/pm/cozy-library.css +106 -17
  59. package/workspace/public/pm/cozy-nav.js +2 -3
  60. package/workspace/public/pm/cozy-pick.css +3 -0
  61. package/workspace/public/pm/cozy-pop-work.css +83 -24
  62. package/workspace/public/pm/cozy-pop-work.js +313 -72
  63. package/workspace/public/pm/cozy-popup.css +11 -2
  64. package/workspace/public/pm/cozy-popup.js +67 -9
  65. package/workspace/public/pm/cozy-routine-job.js +203 -0
  66. package/workspace/public/pm/cozy-routine-model.js +139 -31
  67. package/workspace/public/pm/cozy-routine-pop.js +164 -42
  68. package/workspace/public/pm/cozy-routine.css +61 -8
  69. package/workspace/public/pm/cozy-routine.js +207 -28
  70. package/workspace/public/pm/cozy-settings.js +1 -5
  71. package/workspace/public/pm/cozy-status-when.js +48 -0
  72. package/workspace/public/pm/cozy-viewer.js +19 -8
  73. package/workspace/public/pm/cozy-vw-mtg.css +39 -0
  74. package/workspace/public/pm/goals-model.js +205 -0
  75. package/workspace/public/pm/goals-open.js +124 -0
  76. package/workspace/public/pm/home-chat.js +4 -2
  77. package/workspace/public/pm/home-ini.js +8 -6
  78. package/workspace/public/pm/ini-edit.js +3 -1
  79. package/workspace/public/pm/ini-view-model.js +1 -1
  80. package/workspace/public/pm/library-model.js +170 -42
  81. package/workspace/public/pm/library-open.js +8 -5
  82. package/workspace/public/pm/page-chat.js +12 -2
  83. package/workspace/public/pm/pop-work-model.js +199 -41
  84. package/workspace/public/pm/premium-board.js +108 -43
  85. package/workspace/public/pm/premium-goals.js +213 -0
  86. package/workspace/public/pm/premium-library.js +376 -62
  87. package/workspace/public/pm/premium-shell.js +1 -1
  88. package/workspace/public/pm/premium-vw-mtg.js +79 -1
  89. package/workspace/public/pm/scope-chip.js +207 -0
  90. package/workspace/public/premium-events.html +3 -1
  91. package/workspace/public/premium-goals.html +37 -0
  92. package/workspace/public/premium-library.html +15 -7
  93. package/workspace/public/premium-routine.html +2 -0
  94. package/workspace/server.js +2 -1
  95. package/workspace/test-lists/doc-path.json +9 -0
  96. package/workspace/test-lists/goals-place.json +9 -0
  97. package/workspace/test-lists/status-when.json +9 -0
@@ -17,10 +17,15 @@
17
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
18
  * the page already reads stand in. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
19
  import * as M from './pop-work-model.js';
20
+ import * as CB from './cozy-bar.js';
20
21
  import { openPop, closePop, undoToast } from './hi-pop.js';
21
22
  import { pmGet, pmPost } from './http.js';
22
23
  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
+ import * as ED from './ini-edit.js';
25
+ import * as SW from './cozy-status-when.js'; // When did this happen? after a status pick (round 3 point 18)
26
+ import * as DP from './cozy-day-pick.js'; // the app's own day field, "15 Oct 2026"
27
+ const { localToday } = DP;
28
+ import * as AK from './artefact-kind.js'; // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
24
29
 
25
30
  const CSS = new URL('./cozy-pop-work.css', import.meta.url).href;
26
31
  if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
@@ -29,6 +34,7 @@ if (typeof document !== 'undefined' && document.head && !document.querySelector(
29
34
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
30
35
  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
36
  const P = {
37
+ more: 'M5 12h.01M12 12h.01M19 12h.01', dia: 'M12 4l8 8-8 8-8-8z', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
32
38
  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
39
  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
40
  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',
@@ -38,10 +44,16 @@ const store = {
38
44
  get(k, d) { try { const v = localStorage.getItem(k); return v == null ? d : JSON.parse(v); } catch { return d; } },
39
45
  set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* a private window */ } },
40
46
  };
41
- const COLS = 'pw-cols', SPAN = 'pw-span', BIG = 'pw-big';
47
+ // 'pw-cols2': a column choice saved before round 3 (Status and Date hidden by an older tune menu) no longer hides them (round 3 point 5)
48
+ const COLS = 'pw-cols2', SPAN = 'pw-span', BIG = 'pw-big', TLW = 'pw-tlw';
42
49
  const cols = () => ({ status: true, date: true, tl: true, kind: true, when: true, ...store.get(COLS, {}) });
43
50
  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); };
51
+ const LOOSE = 'pw-loose'; // the initiatives whose Not in a stage row the PM opened (round 3 point 21), remembered on this computer
52
+ const stOf = (id) => {
53
+ if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), doneOpen: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false });
54
+ return ST.get(id);
55
+ };
56
+ const looseKeep = (id, on) => { const L = (store.get(LOOSE, []) || []).filter((x) => x !== id); if (on) L.push(id); store.set(LOOSE, L.slice(-200)); };
45
57
  const ITEMS = new Map(); // initiative id → the Library's rows | null while reading | false when the route is not there
46
58
  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
59
 
@@ -57,54 +69,145 @@ function readItems(id, ws, redraw) {
57
69
  .catch(() => ITEMS.set(id, false));
58
70
  }
59
71
  export const resetItems = () => ITEMS.clear();
72
+ /* the goal's name, not its id (board 25: "De-risk Okta dependency", not KR-C4): GET /api/boards/anchors once per product */
73
+ const GOALS = new Map(); // ws|board → [{ value, kind, label }] | null while reading | false
74
+ let goalsRedraw = null;
75
+ function goalOf(ws, board, anchor) {
76
+ const a = String(anchor || '').trim(); if (!a || !board) return '';
77
+ const k = (ws || '') + '|' + board;
78
+ if (!GOALS.has(k)) {
79
+ GOALS.set(k, null);
80
+ pmGet('/api/boards/anchors?ws=' + encodeURIComponent(ws || '') + '&board=' + encodeURIComponent(board))
81
+ .then((x) => { GOALS.set(k, x && x.ok ? x.anchors || [] : false); if (x && x.ok && goalsRedraw) goalsRedraw(); }).catch(() => GOALS.set(k, false));
82
+ return '';
83
+ }
84
+ return M.goalName(GOALS.get(k) || [], a);
85
+ }
86
+
87
+ /* the initiative's own records for the Overview (round 3 point 10): GET /api/artefacts?scope=experiment:<id> once per initiative */
88
+ const ART = new Map(); // id → artefacts | null while reading | [] when the route is not there
89
+ let artRedraw = null;
90
+ function artOf(id, ws) {
91
+ if (!id) return [];
92
+ if (!ART.has(id)) {
93
+ ART.set(id, null);
94
+ pmGet('/api/artefacts?scope=' + encodeURIComponent('experiment:' + id) + (ws ? '&ws=' + encodeURIComponent(ws) : ''))
95
+ .then((x) => { ART.set(id, x && x.ok && Array.isArray(x.artefacts) ? x.artefacts : []); if (artRedraw) artRedraw(); }).catch(() => ART.set(id, []));
96
+ }
97
+ return ART.get(id);
98
+ }
99
+ /* a product's name, never its id (round 3 point 4): GET /api/workspaces once */
100
+ let WSN = null, wsnRedraw = null;
101
+ function productName(p, ws) {
102
+ const v = String(p || '').trim();
103
+ if (v && !M.idShaped(v) && v !== ws) return v;
104
+ if (WSN == null) {
105
+ WSN = new Map();
106
+ pmGet('/api/workspaces').then((x) => { for (const w of (x && x.workspaces) || []) if (w && w.id) WSN.set(w.id, w.label || w.name || ''); if (wsnRedraw) wsnRedraw(); }).catch(() => {});
107
+ }
108
+ const n = WSN.get(v) || WSN.get(ws || '') || '';
109
+ return n && !M.idShaped(n) ? n : '';
110
+ }
60
111
 
61
112
  /* ── 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>`;
113
+ /* the Overview explains the initiative (round 3 point 10): Problem, Goal, Done when from its own records, one status line, PMOS suggests, then
114
+ * Details › for the grid. A line with no source says so in grey with a ✦ offer; nothing is invented. */
115
+ function ovLines(ov, oid, edit = true) {
116
+ const dr = dropped();
117
+ return `<div class="pw-ols">${ov.lines.map((L) => {
118
+ const ed = edit && L.edit;
119
+ const words = L.text ? esc(L.text) : 'Not written yet.'; // the label already names it: said once (round 3 design check)
120
+ const tx = ed ? `<span class="pw-otx${L.text ? '' : ' grey'}" data-pw-line="${esc(L.id)}" tabindex="0" role="button" aria-label="${esc((L.text ? 'Change the ' : 'Write the ') + L.k.toLowerCase())}">${words}</span>` : `<span class="${L.text ? '' : 'grey'}">${words}</span>`;
121
+ const src = L.text && L.src ? (L.path ? ` <button type="button" class="pw-osrc" data-pw-src="${esc(L.path)}">from ${esc(L.src)}</button>` : ` <span class="pw-osrc">from ${esc(L.src)}</span>`) : '';
122
+ const sid = 'ov:' + oid + ':' + L.id;
123
+ const off = !L.text && L.ask && !dr.has(sid) ? `<span class="pw-ooff"><span class="pw-oq">${SVG(P.spark, 12, 2)}${esc(L.miss.replace(/^.*?\. /, ''))}</span><span class="pw-sugb">${ib(`data-pw-lkeep="${esc(L.id)}"`, 'Yes, draft it', P.check, 'sm')}${ib(`data-pw-ldrop="${esc(sid)}"`, 'No', P.x, 'sm')}</span></span>` : '';
124
+ return `<div class="pw-ol"><span class="pw-ok">${esc(L.k)}</span><p class="pw-ot">${tx}${L.serves ? ' <span>' + esc(L.serves) + '</span>' : ''}${src}${off}</p></div>`;
125
+ }).join('')}</div>`;
126
+ }
127
+ function overviewHtml(W, S, oid) {
128
+ const ov = W.overview, open = !!S.details;
129
+ const mark = `<span class="pw-spark" role="img" aria-label="PMOS wrote this from the records" title="PMOS wrote this from the records">${SVG(P.spark, 14, 2)}</span>`;
130
+ const st = ov.status ? `<p class="pw-ostat">${esc(ov.status)}</p>` : '';
68
131
  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>`;
132
+ const facts = open ? factsHtml(W.facts) : '';
133
+ const det = `<button type="button" class="pw-det" data-pw-details aria-expanded="${open}">${open ? 'Less' : 'Details'}${SVG(open ? P.down : P.right, 14)}</button>`;
134
+ return `<section class="pw-ov" aria-label="Overview"><div class="pw-ovh"><h3>Overview</h3>${mark}${det}</div>${ovLines(ov, oid)}${st}${sug}${facts}</section>`;
135
+ }
136
+ function factsHtml(F) {
137
+ return `<dl class="pw-facts">${F.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.act && !f.read ? '</button>' : '</span>'}</dd></div>`).join('')}</dl>`;
72
138
  }
73
139
  function sugLine(s, under) {
140
+ // two choices (round 3 point 13: "Close them, or reopen?"): each is its own press; ✕ hides it
141
+ const acts = s.choices ? s.choices.map((c, i) => `<button type="button" class="pw-chc" data-pw-choice="${esc(s.id + '|' + i)}">${esc(c.label)}</button>`).join('') + ib(`data-pw-drop="${esc(s.id)}"`, 'Not now', P.x, 'sm')
142
+ : ib(`data-pw-keep="${esc(s.id)}"`, 'Yes, do it', P.check, 'sm') + ib(`data-pw-drop="${esc(s.id)}"`, 'No', P.x, 'sm');
74
143
  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>`;
144
+ + `<span class="pw-sugb">${acts}</span></div>`;
76
145
  }
77
146
  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>' : '';
147
+ const mk = M.marksOf(W.span, W.today), td = mk.today;
148
+ // the Today pill is always on the line when today is in the window (round 3 point 8); a month mark too close to it gives way
149
+ const tl = C.tl ? `<div class="pw-tl pw-tlh" aria-hidden="true">`
150
+ + mk.months.filter((m) => m.x > 3 && m.x < 90 && !(td != null && Math.abs(m.x - td) < 7)).map((m) => `<span class="pw-mk" style="left:${m.x.toFixed(2)}%">${esc(m.label)}</span>`).join('')
151
+ + (td != null ? `<span class="pw-tday" style="left:clamp(24px, ${td.toFixed(2)}%, calc(100% - 24px))">Today</span>` : '') + '</div>' : '';
81
152
  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
153
  }
154
+ /* the grip between the item columns and the timeline (round 3 point 1): drag it left or right; the item columns keep about 220 px (the name)
155
+ * and the timeline about 240 px. Double press or Home: back to the default. The width is remembered on this computer. */
156
+ const tlStyle = () => { const w = +store.get(TLW, 0); return w > 0 ? ` style="--pw-tlw:${Math.round(w)}px"` : ''; };
157
+ const gripHtml = () => `<div class="pw-tlgrip" role="separator" aria-orientation="vertical" tabindex="0" data-pw-grip aria-label="Drag to make the timeline wider or narrower. Double press to reset." title="Drag to make the timeline wider or narrower. Double press to reset."><i></i></div>`;
158
+ function wireGrip(root) {
159
+ if (root.__pwGrip) return; root.__pwGrip = true;
160
+ const set = (card, px) => { const r = card.getBoundingClientRect(), w = Math.max(240, Math.min(px, r.width - 220)); card.style.setProperty('--pw-tlw', Math.round(w) + 'px'); return w; };
161
+ root.addEventListener('pointerdown', (e) => {
162
+ const g = e.target.closest('[data-pw-grip]'); if (!g || e.button !== 0) return;
163
+ const card = g.closest('.pw-wbs'); if (!card) return;
164
+ e.preventDefault(); g.setPointerCapture(e.pointerId); document.body.classList.add('pw-drag');
165
+ let w = 0;
166
+ const mv = (ev) => { w = set(card, card.getBoundingClientRect().right - ev.clientX); };
167
+ const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('pw-drag'); if (w) store.set(TLW, w); };
168
+ g.addEventListener('pointermove', mv); g.addEventListener('pointerup', up); g.addEventListener('pointercancel', up);
169
+ });
170
+ root.addEventListener('dblclick', (e) => { const g = e.target.closest('[data-pw-grip]'); if (!g) return; store.set(TLW, 0); const c = g.closest('.pw-wbs'); if (c) c.style.removeProperty('--pw-tlw'); });
171
+ root.addEventListener('keydown', (e) => {
172
+ const g = e.target.closest && e.target.closest('[data-pw-grip]'); if (!g) return;
173
+ const c = g.closest('.pw-wbs'); if (!c) return;
174
+ const cur = c.querySelector('.pw-th .pw-tl'), now = cur ? cur.getBoundingClientRect().width : 0;
175
+ const d = e.key === 'ArrowLeft' ? 24 : e.key === 'ArrowRight' ? -24 : 0;
176
+ if (d && now) { e.preventDefault(); store.set(TLW, set(c, now + d)); } else if (e.key === 'Home') { e.preventDefault(); store.set(TLW, 0); c.style.removeProperty('--pw-tlw'); }
177
+ });
178
+ }
179
+ /* the bars are the original workspace bars (pm/cozy-bar.js, the same as Work): a stage in its tone with its gap line and ◇s, a task in its box's
180
+ * tone with the late line to Today, a milestone as its ◇ with its card */
181
+ const xOf = (W) => { const a = Date.parse(W.span.a), b = Date.parse(W.span.b); return (v) => ((Date.parse(String(v).slice(0, 10)) - a) / Math.max(864e5, b - a)) * 100; };
83
182
  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}`;
183
+ const X = xOf(W);
184
+ if (x.kind === 'stage') return x.start || x.end ? CB.stageBar({ start: x.start, end: x.end, tone: x.tone, late: x.late, ms: x.ms, name: x.name, gaps: x.gaps, marks: x.open ? [] : x.marks }, X, { today: W.today }) : '';
185
+ if (x.kind === 'done') return x.start || x.end ? CB.stageBar({ start: x.start, end: x.end, tone: 'dn' }, X, { today: W.today }) : '';
186
+ return CB.taskBar(x, X, W.today);
89
187
  }
90
188
  function rowHtml(x, W, C, sugRows) {
91
189
  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
190
  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>` : '';
191
+ 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 ? (x.ms ? 'Milestone ' : 'Due ') + x.date : 'No date') + '. Set the date, or make it a ' + (x.ms ? 'task' : 'milestone'))}">${esc(x.date || 'Set a date')}</button>` : esc(x.date || '')}</span>` : '';
94
192
  if (x.kind === 'stage') {
95
193
  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>`;
194
+ const ls = x.loose ? sugRows.get('stage:') : null; // the one ✦ of the Not in a stage row (round 3 point 21)
195
+ return `<div class="pw-tr pw-sr${x.now ? ' now' : ''}${x.loose ? ' loose' : ''}" role="row"><span class="pw-it">${lead}</span>${stc}${dtc}${x.loose ? (C.tl ? '<div class="pw-tl"></div>' : '') : tl}</div>`
196
+ + (ls ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(ls, true)}</span></div>` : '');
97
197
  }
98
198
  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>`;
199
+ if (x.kind === 'more') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-more="${esc(x.key)}" aria-expanded="false">${esc(x.label)}${SVG(P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${C.tl ? '<div class="pw-tl"></div>' : ''}</div>`;
99
200
  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
201
  const s = sugRows.get(x.uid);
101
202
  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>`
203
+ 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')}${ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
103
204
  + (s ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(s, true)}</span></div>` : '');
104
205
  }
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>`;
206
+ function breakdownHtml(W, C, mode, full, S) {
207
+ const sugRows = W.rowSuggests, ms = !!(S && S.msAdd);
208
+ // the add row (round 3 point 2): "◇" beside it makes the next one a milestone; typing "◇ " first does the same
209
+ 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="${ms ? 'Add a milestone' : 'Add a task'}" aria-label="${esc((ms ? 'Add a milestone to ' : 'Add a task to ') + name)}" maxlength="200" autocomplete="off"></label>`
210
+ + `<button type="button" class="pw-addty${ms ? ' on' : ''}" data-pw-addty aria-pressed="${ms}" aria-label="${ms ? 'Adds a milestone. Press to add a task' : 'Adds a task. Press to add a milestone'}" title="Task or milestone">${SVG(ms ? P.dia : P.box, 13, 2)}<span>${ms ? 'Milestone' : 'Task'}</span></button></span></div>`;
108
211
  let out = '', curSec = null;
109
212
  for (let i = 0; i < W.rows.length; i++) {
110
213
  const x = W.rows[i];
@@ -113,32 +216,50 @@ function breakdownHtml(W, C, mode, full) {
113
216
  const nx = W.rows[i + 1];
114
217
  if (curSec && (!nx || nx.kind === 'stage' || nx.kind === 'far')) { if (curSec.key !== '' ) out += add(curSec.key, curSec.name); curSec = null; }
115
218
  }
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>`;
219
+ const spanB = C.tl ? `<button type="button" class="pw-span" data-pw-span aria-haspopup="menu" aria-label="${esc('Span of the timeline: ' + (M.MODES.find((m) => m[0] === mode) || M.MODES[5])[1])}">${esc((M.MODES.find((m) => m[0] === mode) || M.MODES[5])[1])}${SVG(P.down, 12)}</button>` : '';
220
+ const tools = `<span class="pw-tools">${spanB}${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
221
  const show = !C.tl ? ib('data-pw-tl', 'Show the timeline', P.show, 'xs') : '';
118
222
  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}`
223
+ + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}" role="table" aria-label="Work breakdown"${tlStyle()}>${C.tl ? gripHtml() : ''}${headCells(C, W, mode)}${out || '<div class="pw-tr pw-empty" role="row"><span>No task yet.</span></div>'}</div>`
224
+ + (C.tl ? '<p class="pw-key"><span><i class="k-tb pr"></i>In progress</span><span><i class="k-tb"></i>To do</span><span><i class="k-tb dn"></i>Done</span><span><i class="k-md"></i>Milestone</span><span><i class="k-late"></i>Late</span><span><i class="k-gap"></i>No activity</span></p>' : '') + '</section>';
225
+ }
226
+ /* the Artefacts (round 3 point 16): one row per Kind, in lifecycle order. Kind | Artefact (the current one) | Version | Updated. Versions and the
227
+ * files of a series unfold under the row; several different files of one kind show a count, and one ✦ line above the table proposes to merge
228
+ * them (✓ asks PMOS, ✕ hides it). */
229
+ const ARTOPEN = new Set(); // kinds unfolded, per page
230
+ function artefactsHtml(rows, C, add = true, o = {}) {
231
+ const idx = new Map(rows.map((a, i) => [a, i]));
232
+ const G = AK.group(rows, { at: (a) => a.at || 0, current: (a) => !!(o.recPath && a.path && a.path.replace(/^pmos\//, '') === String(o.recPath).replace(/^pmos\//, '')), dropped: dropped() });
233
+ const scope = o.scope || '';
234
+ const nameCell = (a) => (a.missing ? esc(a.title) : `<button type="button" class="pw-an" data-pw-art="${idx.get(a)}">${esc(a.title)}${a.link ? SVG(P.open, 13) : ''}</button>`);
235
+ const body = G.groups.map((g) => {
236
+ const a = g.cur, k = scope + '|' + g.kind, open = ARTOPEN.has(k), vt = AK.versionText(g);
237
+ const ver = vt && g.earlier.length ? `<button type="button" class="pw-ver" data-pw-ver="${esc(k)}" aria-expanded="${open}">${esc(vt)}${SVG(open ? P.down : P.right, 12)}</button>` : esc(vt);
238
+ const row = `<div class="pw-ar${a.missing ? ' miss' : ''}" role="row"><span role="cell" class="pw-ak">${esc(g.kind)}</span><span role="cell">${nameCell(a)}</span><span role="cell" class="pw-av">${ver}</span>`
239
+ + (C.when ? `<span role="cell"${a.missing ? ' class="warn"' : ''}>${esc(a.missing || a.when || '')}</span>` : '') + '</div>';
240
+ const more = open ? g.earlier.map((e) => `<div class="pw-ar pw-ear" role="row"><span role="cell"></span><span role="cell">${nameCell(e)}</span><span role="cell" class="pw-av">${e.title && AK.versionOf(e.title) ? 'v' + AK.versionOf(e.title) : ''}</span>${C.when ? `<span role="cell">${esc(e.when || '')}</span>` : ''}</div>`).join('') : '';
241
+ return row + more;
242
+ }).join('');
243
+ const mg = G.merge ? `<div class="pw-sugs pw-amg" role="list" aria-label="PMOS suggests">${sugLine({ id: G.merge.id, say: G.merge.say, merge: G.merge })}</div>` : '';
244
+ 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>${mg}`
245
+ + `<div class="pw-card pw-arts${C.when ? '' : ' now'}" role="table" aria-label="Artefacts"><div class="pw-ar pw-th" role="row"><span role="columnheader">Kind</span><span role="columnheader">Artefact</span><span role="columnheader">Version</span>${C.when ? '<span role="columnheader">Updated</span>' : ''}</div>${body}`
127
246
  + (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
247
  }
248
+ const mergeOf = (rows) => AK.group(rows, { dropped: dropped() }).merge;
129
249
 
130
250
  /* ── the initiative ── */
131
251
  const keyOf = (v, o) => String((o && o.id) || (v && (v.id || v.key)) || '');
132
252
  function model(r, v, o) {
133
253
  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 || [] });
254
+ const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
255
+ const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, doneOpen: S.doneOpen, moreOpen: S.moreOpen, farOpen: S.farOpen, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
135
256
  const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
136
257
  return { W, S, id };
137
258
  }
138
259
  export function html(r, v, o = {}) {
139
260
  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>`;
261
+ if (S.big) return `<div class="pw" data-pw-big-on>${breakdownHtml(W, C, mode, true, S)}</div>`;
262
+ return `<div class="pw">${overviewHtml(W, S, keyOf(v, o))}${breakdownHtml(W, C, mode, false, S)}${artefactsHtml(W.artefacts, C, true, { scope: keyOf(v, o), recPath: v.prd && (v.prd.path || v.prd) })}</div>`;
142
263
  }
143
264
 
144
265
  /* ── the suggestion as its own page (board 22) ── */
@@ -155,7 +276,24 @@ function sugPageHtml(s, W) {
155
276
  }
156
277
 
157
278
  /* ── writes ── */
279
+ /* the suggestions PMOS reads from the record (pop-work-model.js derivedOf): ✓ puts a task in a stage, or sends the words to Ask PMOS, which
280
+ * does it in a real session; ✕ hides it on this computer */
281
+ const DROP = 'pw-dropped';
282
+ const dropped = () => new Set(store.get(DROP, []));
283
+ function sendToChat(text) {
284
+ const ask = document.querySelector('.cz-pop [data-pop="ask"]'); if (ask && !ask.closest('[hidden]')) ask.click();
285
+ const ta = document.querySelector('.cz-pop-chat textarea'); if (!ta) return false;
286
+ ta.value = text; ta.dispatchEvent(new Event('input', { bubbles: true }));
287
+ const f = ta.closest('form'); if (f && f.requestSubmit) f.requestSubmit(); else ta.focus();
288
+ return true;
289
+ }
158
290
  async function keepSug(s, x, h) {
291
+ if (s.derived) {
292
+ if (s.move && h.move) { await h.move(s.move.uid, { to: s.move.to, from: '', name: s.move.name }); return; }
293
+ if (s.moveAll) { await moveAll(s.moveAll, h); return; }
294
+ if (s.ask && !sendToChat(s.ask) && h.toast) h.toast('Open Ask PMOS to send this.');
295
+ return;
296
+ }
159
297
  if (s.sm) { if (h.sm) h.sm('yes'); return; }
160
298
  const w = h.where ? h.where() : {}, res = await pmPost('/api/proposals/keep', { ...w, initiative: x.o().id, ids: [s.id] }).catch(() => null);
161
299
  if (!res || res.ok === false) { if (h.toast) h.toast((res && res.error) || 'Nothing was kept.'); return; }
@@ -167,7 +305,22 @@ async function keepSug(s, x, h) {
167
305
  });
168
306
  if (h.reload) await h.reload();
169
307
  }
308
+ /* the tasks in no stage, all into the stage in progress, with one Undo that puts each back (round 3 point 21) */
309
+ async function moveAll(m, h) {
310
+ const w = h.where ? h.where() : {}, moved = [];
311
+ for (const uid of m.uids) {
312
+ const r = await pmPost('/api/boards/tasks/edit', { ws: w.ws, board: w.board, task: uid, section: m.to }).catch(() => null);
313
+ if (r && r.ok !== false) moved.push(uid);
314
+ }
315
+ if (h.reload) await h.reload();
316
+ if (!moved.length) { if (h.toast) h.toast('Nothing was moved.'); return; }
317
+ undoToast((moved.length === 1 ? '1 task' : moved.length + ' tasks') + ' moved to ' + m.name + '.' + (moved.length < m.uids.length ? ' ' + (m.uids.length - moved.length) + ' could not be moved.' : ''), async () => {
318
+ for (const uid of moved) await pmPost('/api/boards/tasks/edit', { ws: w.ws, board: w.board, task: uid, section: '' }).catch(() => null);
319
+ if (h.reload) await h.reload();
320
+ });
321
+ }
170
322
  async function dropSug(s, x, h) {
323
+ if (s.derived) { const d = dropped(); d.add(s.id); store.set(DROP, [...d].slice(-200)); if (h.redraw) h.redraw(); return; }
171
324
  if (s.sm) { if (h.sm) h.sm('no'); return; }
172
325
  const w = h.where ? h.where() : {}, res = await pmPost('/api/proposals/drop', { ...w, initiative: x.o().id, sig: s.sig }).catch(() => null);
173
326
  if (!res || res.ok === false) { if (h.toast) h.toast((res && res.error) || 'Nothing was changed.'); return; }
@@ -197,44 +350,60 @@ export function wire(body, h0, x0) {
197
350
  body.__pw = true;
198
351
  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
352
  function redraw() { if (body.__pwh && body.__pwh.redraw) body.__pwh.redraw(); }
353
+ goalsRedraw = artRedraw = wsnRedraw = () => { if (body.isConnected && body.querySelector('.pw')) redraw(); };
354
+ wireGrip(body);
200
355
  const live = (e) => !!body.__pwx && !!e.target.closest('.pw') && !e.target.closest('.pw-sp, [data-pw-level]');
201
356
  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
357
  body.addEventListener('click', async (e) => {
203
358
  if (!live(e)) return;
204
- const b = e.target.closest('button, [data-pw-sum]'); if (!b || b.disabled || !body.contains(b)) return;
359
+ const b = e.target.closest('button, [data-pw-line]'); if (!b || b.disabled || !body.contains(b)) return;
205
360
  const c = cur(); if (!c) return;
206
361
  const h = body.__pwh, x = body.__pwx;
207
362
  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; }
363
+ if ('pwDetails' in d) { S.details = !S.details; redraw(); return; }
364
+ 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); if (k === '') looseKeep(c.id, !open); redraw(); return; }
210
365
  if ('pwFar' in d) { S.farOpen = true; redraw(); return; }
211
366
  if (d.pwDone != null) { if (S.doneOpen.has(d.pwDone)) S.doneOpen.delete(d.pwDone); else S.doneOpen.add(d.pwDone); redraw(); return; }
212
367
  if ('pwTl' in d) { store.set(COLS, { ...cols(), tl: !cols().tl }); redraw(); return; }
213
368
  if ('pwSpan' in d) { spanMenu(b, redraw); return; }
214
369
  if (d.pwTune) { tuneMenu(b, d.pwTune, redraw); return; }
215
370
  if ('pwBig' in d) { big(c, x, h); return; }
371
+ if (d.pwKeep && /^merge:/.test(d.pwKeep)) { const m = mergeOf(W.artefacts); if (m && !sendToChat(m.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
372
+ if (d.pwDrop && /^merge:/.test(d.pwDrop)) { const dd = dropped(); dd.add(d.pwDrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
373
+ if (d.pwSug && /^merge:/.test(d.pwSug)) { const m = mergeOf(W.artefacts); if (m && !sendToChat(m.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
216
374
  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
375
  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
376
  if (d.pwSug) { const s = findSug(W, d.pwSug); if (s) openSug(s, c, x, h); return; }
219
377
  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; }
378
+ if (d.pwLine) { const L = W.overview.lines.find((q) => q.id === d.pwLine); if (L && L.edit) editLine(b, L, c, x, h); return; }
379
+ if (d.pwLkeep) { const L = W.overview.lines.find((q) => q.id === d.pwLkeep); if (L && L.ask && !sendToChat(L.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
380
+ if (d.pwLdrop) { const dd = dropped(); dd.add(d.pwLdrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
381
+ if (d.pwSrc) { if (h.doc) h.doc(d.pwSrc); return; }
382
+ if (d.pwChoice) { const [sid, k] = d.pwChoice.split('|'), s = findSug(W, sid), ch = s && s.choices && s.choices[+k]; if (ch && !sendToChat(ch.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
383
+ if (d.pwMore != null) { S.moreOpen.add(d.pwMore); redraw(); return; }
384
+ if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
385
+ if (d.pwRowMore) { rowMenu(b, d.pwRowMore, c, h); return; }
386
+ if ('pwAddty' in d) { S.msAdd = !S.msAdd; const f = b.closest('.pw-add'), k = f && f.querySelector('[data-pw-add]') && f.querySelector('[data-pw-add]').dataset.pwAdd; redraw(); if (k != null) setTimeout(() => { const i = body.querySelector(`[data-pw-add="${CSS.escape(k)}"]`); if (i) i.focus(); }, 0); return; }
222
387
  if (d.pwFact) { fact(d.pwFact, b, c, h); return; }
223
- if (d.pwStatus) { statusMenu(b, d.pwStatus, h); return; }
388
+ if (d.pwStatus) { statusMenu(b, d.pwStatus, h, c); return; }
224
389
  if (d.pwDate) { dateMenu(b, d.pwDate, c, h); return; }
225
390
  if (d.pwName) { rename(b, d.pwName, h); return; }
226
391
  if (d.pwOpen) { if (h.openTask) h.openTask(d.pwOpen); return; }
392
+ if (d.cbMs != null) { msPop(b, d.cbMs, W, h); return; }
227
393
  if (d.pwArt != null) { openArt(W.artefacts[+d.pwArt], h, x); return; }
228
394
  if ('pwAddart' in d) { addArt(x, h); return; }
229
395
  });
230
396
  body.addEventListener('keydown', async (e) => {
231
397
  if (!live(e)) return;
232
398
  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; }
399
+ if (t.matches && t.matches('[data-pw-line]') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); t.click(); return; }
234
400
  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 });
401
+ e.preventDefault(); const v0 = t.value.trim(); if (!v0 || !h.addTask) return;
402
+ const sec = t.dataset.pwAdd, c = cur();
403
+ // "◇ " first, or the ◇ choice beside the field: a milestone (the same write as the old List's Type chip, pm/ini-edit.js)
404
+ const ms = /^◇\s*/.test(v0) || !!(c && c.S.msAdd), v = v0.replace(/^◇\s*/, '');
405
+ if (!v) return;
406
+ await h.addTask(v, t, { section: sec, name: t.dataset.pwAddName, ...(ms ? { milestone: true } : {}) });
238
407
  // Enter only adds the row; the field stays for the next one
239
408
  setTimeout(() => { const f = body.querySelector(`[data-pw-add="${CSS.escape(sec)}"]`); if (f) { f.value = ''; f.focus(); } }, 0);
240
409
  }
@@ -293,22 +462,39 @@ function fact(act, b, c, h) {
293
462
  else if (act === 'program' && h.program) { const p = (c.v.summary || {}).program; if (p) h.program(p.id, b); }
294
463
  else if (act.startsWith('task:') && h.openTask) h.openTask(act.slice(5));
295
464
  }
296
- function editSum(el, c, x, h) {
465
+ /* a line of the Overview changed in place (round 3 point 10): it goes to the record it came from, with Undo. The record's description through
466
+ * POST /api/initiative/describe; an Experiment or Done test line through POST /api/artefacts/set, and its Undo /api/artefacts/undo */
467
+ function editLine(el, L, c, x, h) {
297
468
  if (el.querySelector('textarea')) return;
298
- const was = c.W.summary.lead || '';
469
+ const was = L.text || '';
299
470
  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');
471
+ ta.className = 'pw-sumed'; ta.value = was; ta.rows = 2; ta.maxLength = 600; ta.setAttribute('aria-label', L.k);
301
472
  el.replaceWith(ta); ta.focus();
302
473
  let done = false;
303
474
  const leave = async (save) => {
304
475
  if (done) return; done = true;
305
476
  const v = ta.value.replace(/\s+/g, ' ').trim();
306
- if (save && v && v !== was) await saveDesc(v, x, h);
477
+ if (save && v && v !== was) await saveLine(L, v, x, h);
307
478
  else if (h.redraw) h.redraw();
308
479
  };
309
480
  ta.addEventListener('blur', () => leave(true));
310
481
  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
482
  }
483
+ async function saveLine(L, text, x, h) {
484
+ if (L.edit.to === 'desc') return saveDesc(text, x, h);
485
+ const w = h.where ? h.where() : {}, o = x.o(), id = o.id, ws = w.ws || o.ws;
486
+ const res = await pmPost('/api/artefacts/set', { ws, scope: 'experiment:' + id, artefact: L.edit.artefact, field: L.edit.field, text }).catch(() => null);
487
+ if (!res || res.ok === false || !res.line) { if (h.toast) h.toast((res && res.error) || 'It was not saved.'); return false; }
488
+ const ref = res.line.id;
489
+ ART.delete(id);
490
+ undoToast(L.k + ' saved.', async () => {
491
+ const u = await pmPost('/api/artefacts/undo', { ws, ref }).catch(() => null);
492
+ if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
493
+ ART.delete(id); if (h.redraw) h.redraw();
494
+ });
495
+ if (h.redraw) h.redraw();
496
+ return true;
497
+ }
312
498
  function rename(btn, uid, h) {
313
499
  const inp = document.createElement('input');
314
500
  inp.className = 'pw-namei'; inp.value = btn.textContent; inp.maxLength = 200; inp.setAttribute('aria-label', 'Name of the task');
@@ -333,19 +519,57 @@ function rename(btn, uid, h) {
333
519
  }
334
520
  });
335
521
  }
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
- }
522
+ /** A milestone ◇'s card (the original workspace's milestone popup): its name, date and state, and Open the task. */
523
+ function msPop(btn, uid, W, h) {
524
+ const x = W.rows.find((r) => r.uid === uid) || W.rows.flatMap((r) => r.marks || []).find((m) => m.uid === uid);
525
+ if (!x) return;
526
+ openPop(btn, 'pw-ms', CB.msCard({ uid: x.uid, title: x.title, end: x.end, done: !!x.done }, W.today), (b) => {
527
+ if (b.dataset.cbOpen) { closePop(); if (h.openTask) h.openTask(b.dataset.cbOpen); }
528
+ }, { label: 'Milestone' });
529
+ }
530
+ /* A status pick asks when it really happened (round 3 point 18, pm/cozy-status-when.js): the line opens under the list, Today preselected, so a
531
+ * second press of the same status or Enter keeps today. Never a future day, never before the previous move; the toast says both days. */
532
+ function statusMenu(btn, uid, h, c) {
533
+ const row = (c && c.W.rows.find((x) => x.uid === uid)) || {};
534
+ let picked = null;
535
+ const save = (st, day) => { closePop(); if (h.status) h.status(uid, st, day ? { happened: day } : undefined); };
536
+ const el = openPop(btn, 'pw-status', STATES.map((s) => `<button type="button" class="hi-mi" role="menuitemradio" aria-checked="${s === row.status}" data-st="${esc(s)}">${esc(s)}</button>`).join('') + '<div class="pw-when" hidden></div>', (b) => {
537
+ const st = b.dataset.st; if (!st) return;
538
+ if (st === row.status && !picked) { closePop(); return; }
539
+ if (picked === st) { save(st, null); return; }
540
+ picked = st;
541
+ el.querySelectorAll('[data-st]').forEach((x) => x.setAttribute('aria-checked', String(x.dataset.st === st)));
542
+ const w = el.querySelector('.pw-when'); w.hidden = false; w.innerHTML = '';
543
+ SW.askWhen(w, { since: row.since || '', onPick: (day) => save(st, day === localToday() ? null : day) });
544
+ w.querySelector('[data-sw]')?.focus();
545
+ }, { label: 'Status', focus: '[aria-checked="true"]' });
546
+ }
547
+ /* Task or Milestone (round 3 point 2), in three places that do the same write (pm/ini-edit.js milestone, the host's Undo): the choice on top
548
+ * of the date popup, the row's ⋯, and the add row. A task has Start and Due; a milestone one Date. A Jira task's change is PMOS-only. */
549
+ const jiraNote = (row) => (row.jira ? '<p class="hi-small pw-jn">PMOS only. Jira is not changed.</p>' : '');
550
+ function setKind(row, on, h) { ED.milestone(h, { uid: row.uid, start: row.start, end: row.end, ms: row.ms }, on); }
341
551
  function dateMenu(btn, uid, c, h) {
342
552
  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 }); } });
553
+ const seg = `<div class="pw-seg" role="radiogroup" aria-label="Task or milestone"><button type="button" role="radio" aria-checked="${!row.ms}" data-ty="task">${SVG(P.box, 13, 2)}Task</button><button type="button" role="radio" aria-checked="${!!row.ms}" data-ty="ms">${SVG(P.dia, 13, 2)}Milestone</button></div>`;
554
+ // the app's own day form, "15 Oct 2026", with its small calendar (pm/cozy-day-pick.js), never the browser's month-first field
555
+ const fields = row.ms ? '<div class="pw-dp" data-f="due"></div>' : '<div class="pw-dp" data-f="start"></div><div class="pw-dp" data-f="due"></div>';
556
+ const el = openPop(btn, 'pw-date', seg + fields + jiraNote(row) + `<div class="hi-acts"><button type="button" class="hi-btn ghost" data-clear>No date</button></div>`, (b) => {
557
+ if (b.dataset.ty) { const on = b.dataset.ty === 'ms'; closePop(); if (on !== !!row.ms) setKind(row, on, h); return; }
558
+ if ('clear' in b.dataset) { closePop(); if (h.dates) h.dates(uid, row.ms ? { due: '' } : { start: '', due: '' }); }
559
+ }, { label: 'Set the date', focus: '.dp-in' });
560
+ const st = el.querySelector('[data-f="start"]'), due = el.querySelector('[data-f="due"]');
561
+ if (st) DP.mountDay(st, { label: 'Start', value: row.start || '', onPick: (v) => { if (h.dates) h.dates(uid, { start: v }); } });
562
+ DP.mountDay(due, { label: row.ms ? 'Date' : 'Due', value: row.end || row.start || '', open: !st, onPick: (v) => { closePop(); if (h.dates) h.dates(uid, { due: v }); } });
563
+ (st || due).querySelector('.dp-in')?.focus();
564
+ }
565
+ function rowMenu(btn, uid, c, h) {
566
+ const row = c.W.rows.find((x) => x.uid === uid) || {};
567
+ openPop(btn, 'pw-rowm', `<button type="button" class="hi-mi" role="menuitem" data-k="kind">${SVG(row.ms ? P.box : P.dia, 14, 2)} ${row.ms ? 'Make it a task' : 'Make it a milestone'}</button>`
568
+ + `<button type="button" class="hi-mi" role="menuitem" data-k="open">${SVG(P.open, 14)} Open the task</button>` + jiraNote(row), (b) => {
569
+ closePop();
570
+ if (b.dataset.k === 'kind') setKind(row, !row.ms, h);
571
+ else if (b.dataset.k === 'open' && h.openTask) h.openTask(uid);
572
+ }, { menu: true, label: 'Task' });
349
573
  }
350
574
  function spanMenu(btn, redraw) {
351
575
  const cur = store.get(SPAN, 'full');
@@ -355,8 +579,8 @@ function spanMenu(btn, redraw) {
355
579
  }
356
580
  function tuneMenu(btn, which, redraw) {
357
581
  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('')
582
+ const L = which === 'art' ? [['when', 'Updated']] : [['status', 'Status'], ['date', 'Date'], ['tl', 'Timeline, on the right']];
583
+ openPop(btn, 'pw-tune', `<p class="hi-h3">${which === 'art' ? 'Kind and Artefact always show' : '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
584
  + '<button type="button" class="hi-mi" data-reset>Reset</button>', (b) => {
361
585
  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
586
  if ('reset' in b.dataset) { store.set(COLS, {}); store.set(SPAN, 'full'); closePop(); redraw(); }
@@ -370,6 +594,11 @@ async function openArt(a, h, x) {
370
594
  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
595
  const p = a.item.open && a.item.open.path; if (p && h.doc) { h.doc(p); return; }
372
596
  }
597
+ // a document the record names opens as the document page, with its name, from the initiative's own workspace (round 3 point 17)
598
+ if (a.path && /\.md$/i.test(a.path)) {
599
+ const o = x.o() || {}, w = h.where ? h.where() : {}, ws = o.ws || w.ws || '';
600
+ try { const L = await import('./library-open.js'); VW.drill(); L.openItem({ id: 'doc:' + a.path, kind: 'doc', name: a.title, open: { doc: { path: a.path, ws } }, about: { ws, ini: o.id } }); return; } catch { /* the path below */ }
601
+ }
373
602
  if (a.path && h.doc) h.doc(a.path);
374
603
  }
375
604
  async function addArt(x, h) {
@@ -394,23 +623,29 @@ export function levelHtml(L, o = {}) {
394
623
  const W = M.levelOf(L, { today: o.today, mode: store.get(SPAN, 'full') }), C = cols(), mode = store.get(SPAN, 'full');
395
624
  const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
396
625
  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>`;
626
+ // the same Overview shape as an initiative (round 3 point 10): what it is for, its goal, done when; then the status line and Details ›
627
+ const lk = 'level:' + W.kind + ':' + (W.title || ''), S = stOf(lk), open = !!S.details;
628
+ const F = W.facts.filter((f) => f && f.v && !M.idShaped(f.v)).map((f) => ({ ...f, read: true }));
629
+ const facts = open && F.length ? factsHtml(F) : '';
630
+ const det = F.length ? `<button type="button" class="pw-det" data-pw-details="${esc(lk)}" aria-expanded="${open}">${open ? 'Less' : 'Details'}${SVG(open ? P.down : P.right, 14)}</button>` : '';
631
+ const mark = `<span class="pw-spark" role="img" aria-label="PMOS wrote this from the records" title="PMOS wrote this from the records">${SVG(P.spark, 14, 2)}</span>`;
632
+ const ov = `<section class="pw-ov" aria-label="Overview"><div class="pw-ovh"><h3>Overview</h3>${mark}${det}</div>${ovLines(W.overview, lk, false)}${W.overview.status ? `<p class="pw-ostat">${esc(W.overview.status)}</p>` : ''}${sug}${facts}</section>`;
399
633
  const head = o.rowsTitle || (W.kind === 'product' ? 'Programs and initiatives' : 'Initiatives');
400
634
  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>` : '';
635
+ const tl = C.tl ? `<div class="pw-tl">${barHtml({ ...x, kind: 'stage', tone: x.done ? 'dn' : '' }, W)}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div>` : '';
402
636
  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
637
  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
638
  }).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>`;
639
+ 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">${C.tl ? `<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>` : ''}${ib('data-pw-tune="wbs" aria-haspopup="menu"', 'Show or hide columns', P.tune)}</span></div>`
640
+ + `<div class="pw-card pw-wbs${C.tl ? '' : ' notl'}${C.status ? '' : ' nost'}${C.date ? '' : ' nodt'}" role="table"${tlStyle()}>${C.tl ? gripHtml() : ''}${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>`;
641
+ return `<div class="pw" data-pw-level>${ov}${wbs}${W.artefacts.length || o.add !== false ? artefactsHtml(W.artefacts, C, o.add !== false, { scope: lk }) : ''}</div>`;
408
642
  }
409
643
  export function wireLevel(body, h0, L0) {
410
644
  if (!body) return;
411
645
  body.__pwlh = h0; body.__pwlL = L0;
412
646
  if (body.__pwl) return;
413
647
  body.__pwl = true;
648
+ wireGrip(body);
414
649
  body.addEventListener('click', (e) => {
415
650
  if (!e.target.closest('[data-pw-level]')) return;
416
651
  const h = body.__pwlh, L = body.__pwlL, redraw = () => { if (h.redraw) h.redraw(); };
@@ -419,6 +654,12 @@ export function wireLevel(body, h0, L0) {
419
654
  if ('pwTl' in d) { store.set(COLS, { ...cols(), tl: !cols().tl }); redraw(); return; }
420
655
  if ('pwSpan' in d) { spanMenu(b, redraw); return; }
421
656
  if (d.pwTune) { tuneMenu(b, d.pwTune, redraw); return; }
657
+ if (d.pwDetails) { const S = stOf(d.pwDetails); S.details = !S.details; redraw(); return; }
658
+ if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
659
+ if ((d.pwKeep || d.pwSug) && /^merge:/.test(d.pwKeep || d.pwSug)) { const m = mergeOf(M.levelOf(L()).artefacts); if (m && !sendToChat(m.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
660
+ if (d.pwDrop && /^merge:/.test(d.pwDrop)) { const dd = dropped(); dd.add(d.pwDrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
661
+ if (d.pwLkeep) { const x = M.levelOf(L()).overview.lines.find((q) => q.id === d.pwLkeep); if (x && x.ask && !sendToChat(x.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
662
+ if (d.pwLdrop) { const dd = dropped(); dd.add(d.pwLdrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
422
663
  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
664
  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
665
  if ('pwAddart' in d) { if (h.addDoc) h.addDoc(b); return; }