create-pmos 0.832.0 → 0.834.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 (44) hide show
  1. package/package.json +105 -66
  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/changelog.json +104 -27
  7. package/workspace/guide/backlog.md +1 -0
  8. package/workspace/guide/breakdown.md +11 -0
  9. package/workspace/guide/cli.md +11 -0
  10. package/workspace/guide/initiatives-and-next-steps.md +2 -0
  11. package/workspace/guide/layout.md +2 -0
  12. package/workspace/guide/positioning.md +1 -1
  13. package/workspace/lib/features.json +2 -1
  14. package/workspace/lib/line.js +7 -1
  15. package/workspace/lib/pmos-verbs.js +3 -0
  16. package/workspace/lib/route-modules.js +1 -0
  17. package/workspace/lib/routes-story-map.js +62 -0
  18. package/workspace/lib/routes-strategy-card.js +6 -2
  19. package/workspace/lib/story-map-cli.js +108 -0
  20. package/workspace/lib/story-map.js +172 -0
  21. package/workspace/lib/work-kr.js +77 -0
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/public/pm/bd-backlog.css +11 -0
  25. package/workspace/public/pm/bd-ini-panel.js +15 -5
  26. package/workspace/public/pm/bd-positioning.js +6 -4
  27. package/workspace/public/pm/bd-prog-panel.js +16 -5
  28. package/workspace/public/pm/bd-strategy.js +15 -3
  29. package/workspace/public/pm/cozy-pop-work.js +8 -26
  30. package/workspace/public/pm/line-view.js +13 -1
  31. package/workspace/public/pm/ms-strip.js +137 -0
  32. package/workspace/public/pm/page-chat.css +19 -0
  33. package/workspace/public/pm/page-chat.js +2 -0
  34. package/workspace/public/pm/side-fold.js +94 -0
  35. package/workspace/public/pm/story-map.css +22 -0
  36. package/workspace/public/pm/story-map.js +180 -0
  37. package/workspace/public/pm/work-drag.css +14 -0
  38. package/workspace/public/pm/work-drag.js +133 -0
  39. package/workspace/public/pm/work-tree.js +61 -0
  40. package/workspace/test-lists/ms-strip.json +9 -0
  41. package/workspace/test-lists/side-fold.json +9 -0
  42. package/workspace/test-lists/story-map.json +9 -0
  43. package/workspace/test-lists/timeline-bar-drag.json +9 -0
  44. package/workspace/test-lists/work-kr.json +9 -0
@@ -27,14 +27,16 @@ const kindWord = (l) => (l.kind === 'positioning' ? 'Positioning' : 'Message');
27
27
 
28
28
  /** The part's markup. state = { kept, draft, busy, left, open }. Pure, so the test reads it.
29
29
  * Collapsed (the default): the positioning statement only, and a fold "N key messages" (bdPosMore) that opens the rest. Where a line comes
30
- * from sits in its tooltip, not under it, so the part stays short; a line whose strategy changed still says so. */
30
+ * from sits in its tooltip, not under it, so the part stays short; a line whose strategy changed still says so. state.period (the strategy's
31
+ * OKR period, lib/work-kr.js) puts its label beside the title, "Positioning · H2 2026" (tb-work-kr). */
31
32
  export function partHtml(state) {
32
33
  const kept = Array.isArray(state.kept) ? state.kept : [];
33
34
  const d = state.draft && state.draft.state === 'ready' ? state.draft : null;
34
35
  const pending = state.busy || (state.draft && state.draft.state === 'pending');
35
36
  const keptIds = new Set(kept.map((l) => l.id));
36
37
  const fresh = d ? d.lines.filter((l) => !keptIds.has(l.id) && !(state.left || []).includes(l.id)) : [];
37
- const head = `<div class="head"><h4 class="pm-h-sm" style="flex:1">Positioning${kept.length || fresh.length || pending ? '' : ' <span class="pm-meta">· not drafted yet</span>'}${pending ? ' <span class="pm-meta">· drafting…</span>' : ''}</h4>`
38
+ const per = state.period && state.period.label ? ` <span class="pm-meta" data-pos-period>· ${esc(state.period.label)}</span>` : ''; // tb-work-kr: the period it is for
39
+ const head = `<div class="head"><h4 class="pm-h-sm" style="flex:1">Positioning${per}${kept.length || fresh.length || pending ? '' : ' <span class="pm-meta">· not drafted yet</span>'}${pending ? ' <span class="pm-meta">· drafting…</span>' : ''}</h4>`
38
40
  + (pending ? '' : btn('bdPosDraft', kept.length || d ? I.again : I.spark, kept.length || d ? 'Draft again from the strategy' : 'Draft positioning from the strategy')) + '</div>';
39
41
  const tip = (l) => ` title="${esc(kindWord(l) + ' · ' + fromLine(l))}"`;
40
42
  const keptRow = (l) => `<div class="pm-li" role="listitem" data-pos="${esc(l.id)}"${tip(l)}><span class="txt"><span class="t">${esc(l.text)}</span>${l.stale ? '<span class="w">The strategy changed since you kept this</span>' : ''}</span>${btn('bdPosDrop', I.x, 'Drop this line', 'outline', ` data-id="${esc(l.id)}"`)}</div>`;
@@ -52,12 +54,12 @@ export function partHtml(state) {
52
54
  /** Draw the part into `host` and wire its presses. */
53
55
  export async function mount(host, opts = {}) {
54
56
  if (!host) return;
55
- const { ws = null, say = null } = opts;
57
+ const { ws = null, say = null, period = null } = opts;
56
58
  const q = ws ? '?ws=' + encodeURIComponent(ws) : '';
57
59
  const get = async () => { try { return await (await fetch(API + q, { credentials: 'same-origin' })).json(); } catch { return null; } };
58
60
  const r = await get();
59
61
  if (!r || !r.ok || !r.complete) { host.hidden = true; host.innerHTML = ''; return; } // an extra: no strategy, no part
60
- const S = { kept: r.kept, draft: r.draft, busy: false, left: [], open: host.dataset.open === '1' };
62
+ const S = { kept: r.kept, draft: r.draft, busy: false, left: [], open: host.dataset.open === '1', period };
61
63
  const draw = () => { host.hidden = false; host.innerHTML = partHtml(S); };
62
64
  let tries = 0;
63
65
  const poll = async () => {
@@ -41,6 +41,7 @@ import * as MD from './metric-drafts.js'; // the goal Claude drafts when the c
41
41
  import * as DB from './dash-view.js'; // the page model's parts: the reports and the proposals (batch 17 item 1)
42
42
  import { stageName } from './stage-chip.js'; // W1: the one stage
43
43
  import * as PV from './prog-page.js';
44
+ import * as MS from './ms-strip.js'; // Next milestones on the program page (job #2020, Wawan 2026-11-25 13:02Z)
44
45
  import * as PW from './cozy-pop-work.js'; // in the popup: the program one level up, the same three parts as an initiative (slice 3, board 26) // the one program page: the top and four tabs (batch 21 item 2, canvas RdProgL–RdProgP)
45
46
 
46
47
  const SV = (d, w) => `<svg viewBox="0 0 24 24" width="${w || 18}" height="${w || 18}" aria-hidden="true"><path d="${d}"/></svg>`;
@@ -414,11 +415,11 @@ function draw(keepFocus) {
414
415
  const p = progOf(cur.id); if (!p) { VW.close(); return; }
415
416
  readAway(p); readMore(p); readDrafts(p);
416
417
  const b = VW.body(); if (!b) return;
417
- if (PW.inPop(b)) { const t = b.scrollTop, L = levelOf(cur.id); if (L) { b.innerHTML = PW.levelHtml(L, { today: L.today, add: false }); b.scrollTop = t; } return; } // the program in the popup (board 26)
418
+ if (PW.inPop(b)) { const t = b.scrollTop, L = levelOf(cur.id); if (L) { b.innerHTML = levelPage(b, cur.id, L); b.scrollTop = t; } return; } // the program in the popup (board 26)
418
419
  const f = keepFocus && document.activeElement && b.contains(document.activeElement) ? document.activeElement : null;
419
420
  const sel = f ? (f.dataset.pp ? `[data-pp="${f.dataset.pp}"]` + (f.dataset.fold ? `[data-fold="${CSS.escape(f.dataset.fold)}"]` : '') + (f.dataset.key ? `[data-key="${CSS.escape(f.dataset.key)}"]` : '') + (f.dataset.ms ? `[data-ms="${CSS.escape(f.dataset.ms)}"]` : '') : f.dataset.czsFold ? `[data-czs-fold="${CSS.escape(f.dataset.czsFold)}"]` : null) : null;
420
421
  const top = b.scrollTop;
421
- b.innerHTML = viewHtml(p);
422
+ b.innerHTML = progStrip(b, p.id) + viewHtml(p);
422
423
  b.scrollTop = top;
423
424
  const again = sel && b.querySelector(sel); if (again) again.focus();
424
425
  }
@@ -513,12 +514,21 @@ function levelOf(id) {
513
514
  const doneWhen = lastMs ? lastMs.name.replace(/\.$/, '') + (by ? ', by ' + by : '') + '.' : by ? 'Its initiatives are delivered by ' + by + '.' : '';
514
515
  return { kind: 'program', id: p.id, title: p.title, summary: said, why: p.why || '', goal: p.goal || '', done: doneWhen, facts, rows, docs, today };
515
516
  }
517
+ /** The program's Next milestones (job #2020): the Board's rows of its initiatives, its own window. */
518
+ function progStrip(body, id) {
519
+ const p = progOf(id); if (!p) return '';
520
+ const rows = programState(p, rowsOf).inis.map((i) => i.row).filter(Boolean);
521
+ return MS.stripHtml(rows, 'program:' + id, { sub: 'this program', lw: MS.lineWidth(body), ro: !!window.PMOS_READONLY });
522
+ }
523
+ const levelPage = (body, id, L) => MS.insertStrip(PW.levelHtml(L, { today: L.today, add: false }), progStrip(body, id));
516
524
  function levelDraw(body, id, from) {
517
525
  cur = { id, from: from || (cur && cur.id === id && cur.from) || null };
518
526
  const L = levelOf(id); if (!L) { body.innerHTML = ''; return; }
519
- body.innerHTML = PW.levelHtml(L, { today: L.today, add: false });
527
+ body.innerHTML = levelPage(body, id, L);
528
+ const redraw = () => { const t = body.scrollTop; const L2 = levelOf(id); if (L2) { body.innerHTML = levelPage(body, id, L2); body.scrollTop = t; } };
529
+ MS.wireStrip(body, redraw);
520
530
  PW.wireLevel(body, {
521
- redraw: () => { const t = body.scrollTop; const L2 = levelOf(id); if (L2) { body.innerHTML = PW.levelHtml(L2, { today: L2.today, add: false }); body.scrollTop = t; } },
531
+ redraw,
522
532
  go: (kind, iid) => { if (kind === 'ini') { VW.drill(); O.openIni(iid, null); } },
523
533
  doc: (path) => { const a = document.createElement('button'); a.dataset.doc = path; a.hidden = true; document.body.appendChild(a); a.click(); a.remove(); },
524
534
  art: (a) => { if (!a || !a.charter) return false; const q = progOf(id); if (q) openCharter(q); return true; },
@@ -535,7 +545,8 @@ function oldDraw(body, id, from) {
535
545
  {
536
546
  cur = { id, from: from && !(VW.body() && VW.body().contains(from)) ? from : (cur && cur.id === id && cur.from) || null };
537
547
  body.classList.add('pp-vw');
538
- const q = progOf(id); if (q) { readAway(q); readMore(q); readDrafts(q); body.innerHTML = viewHtml(q); }
548
+ const q = progOf(id); if (q) { readAway(q); readMore(q); readDrafts(q); body.innerHTML = progStrip(body, id) + viewHtml(q); }
549
+ MS.wireStrip(body, () => draw(true));
539
550
  PV.wirePage(body, { redraw: () => draw(true) }); // the tabs and the proposals fold (pm/prog-page.js)
540
551
  { // the reports' and the goals' presses (pm/dash-view.js: listeners once per body, this page's h each time)
541
552
  DB.wireDash(body, { d: () => cur && dashOf(cur.id).d, get open() { return cur ? dashOf(cur.id).open : new Set(); }, ws: (progOf(id) || {}).home || board().ws || '', board: board().id || '',
@@ -13,6 +13,8 @@
13
13
  * · The pencil turns the lines into inputs; the tick (or Enter) saves, Esc puts them back. A save offers Undo in the Board's toast.
14
14
  * · Once all five are written, the Positioning part (pm/bd-positioning.js, idea A328) sits under the lines: positioning and key
15
15
  * messages drafted from them, each citing its line, kept or edited by the PM.
16
+ * · The OKR period beside the title and a Serves row under the head: the objectives and key results of the product's OKR file
17
+ * (tb-work-kr, board TbWork). No OKR file, no period and no row. Positioning names the same period.
16
18
  * The controls carry ids (bdStratEdit, bdStratSave, bdStratFits) so the local use log counts their use (the bet's kill line). */
17
19
  import { pmPost } from './http.js';
18
20
  import * as POS from './bd-positioning.js';
@@ -29,6 +31,16 @@ const HINT = { for: 'The people this product serves', problem: 'What they strugg
29
31
  export const fitsLine = (n) => n + (n === 1 ? " doesn't fit" : " don't fit");
30
32
  const isEmpty = (c) => !c || FIELDS.every((k) => !String(c[k] || '').trim());
31
33
 
34
+ /** tb-work-kr (board TbWork): the OKR period the strategy is for, "H2 2026 · Jul–Dec · ends 31 Dec · 5 weeks left", beside the title, and the
35
+ * Serves row: each objective of the OKR file with its key results. Both come from GET /api/strategy-card (lib/work-kr.js); none, nothing. */
36
+ export const periodText = (state) => (state && state.period && state.period.text) || '';
37
+ export function servesHtml(state) {
38
+ const S = (state && Array.isArray(state.serves) ? state.serves : []).filter((o) => o && (o.krs || []).length);
39
+ if (!S.length) return '';
40
+ const obj = (o) => `<li class="bd-serves-o"><span class="t">${esc(o.token)}${o.title ? ' · ' + esc(o.title) : ''}</span><span class="bd-serves-k">${o.krs.map((k) => `<span class="pm-chip" title="${esc(k.token + (k.title ? ' · ' + k.title : ''))}">${esc(k.token)}${k.title ? ' ' + esc(k.title) : ''}</span>`).join('')}</span></li>`;
41
+ return `<div class="bd-serves" aria-label="Serves"><p class="pm-meta">Serves</p><ul role="list">${S.map(obj).join('')}</ul></div>`;
42
+ }
43
+
32
44
  /** The card's markup. state = { card, complete, notes, editing, open }. Pure, so the test reads it. */
33
45
  export function cardHtml(state) {
34
46
  const { card, notes, editing, open } = state;
@@ -51,7 +63,7 @@ export function cardHtml(state) {
51
63
  + (open ? `<div role="list">${notes.map((x) => `<div class="pm-li" role="listitem" data-ini="${esc(x.id)}"><span class="txt"><span class="t">${esc(x.title)}</span><span class="w">Doesn't fit the strategy because it ${esc(x.why)}</span></span></div>`).join('')}</div>` : '')
52
64
  : '';
53
65
  const pos = state.complete ? '<div id="bdPos" hidden></div>' : '';
54
- return `<section class="pm-block" aria-label="Strategy">${head('Strategy', '', undo + btn('bdStratEdit', I.pen, 'Edit the strategy'))}<dl class="pm-field" style="margin:0">${rows}</dl>${fold}${pos}</section>`;
66
+ return `<section class="pm-block" aria-label="Strategy">${head('Strategy', periodText(state), undo + btn('bdStratEdit', I.pen, 'Edit the strategy'))}${servesHtml(state)}<dl class="pm-field" style="margin:0">${rows}</dl>${fold}${pos}</section>`;
55
67
  }
56
68
 
57
69
  /** Draw the card again after a read of the Board, unless the PM is writing in it. */
@@ -70,7 +82,7 @@ export async function mount(host, opts = {}) {
70
82
  const q = (ws ? '?ws=' + encodeURIComponent(ws) : '?') + (board ? (ws ? '&' : '') + 'board=' + encodeURIComponent(board) : '');
71
83
  let r = null; try { r = await (await fetch('/api/strategy-card' + q, { credentials: 'same-origin' })).json(); } catch { r = null; }
72
84
  if (!r || !r.ok) { host.hidden = true; return; } // the card is an extra: a failed read leaves the Board as it was
73
- const S = { card: r.card, complete: r.complete, notes: r.notes, sources: r.sources || {}, drafting: !!r.drafting, editing: false, open: host.dataset.open === '1' };
85
+ const S = { card: r.card, complete: r.complete, notes: r.notes, sources: r.sources || {}, drafting: !!r.drafting, editing: false, open: host.dataset.open === '1', period: r.period || null, serves: r.serves || [] };
74
86
  // while PMOS drafts, read again now and then until the lines land (at most ~5 minutes)
75
87
  clearTimeout(host._stratPoll);
76
88
  const tries = Number(host.dataset.polls || 0);
@@ -79,7 +91,7 @@ export async function mount(host, opts = {}) {
79
91
  const draw = () => {
80
92
  host.hidden = false; host.innerHTML = cardHtml(S);
81
93
  if (S.editing) { const f = host.querySelector('[data-strat]'); if (f) f.focus(); }
82
- else if (S.complete) POS.mount(host.querySelector('#bdPos'), { ws, say });
94
+ else if (S.complete) POS.mount(host.querySelector('#bdPos'), { ws, say, period: S.period });
83
95
  };
84
96
  const save = async () => {
85
97
  const fields = {}; host.querySelectorAll('[data-strat]').forEach((el) => { fields[el.dataset.strat] = el.value; });
@@ -18,6 +18,7 @@
18
18
  * the page already reads stand in. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
19
  import { wireSwipe } from './cozy-phone-swipe.js';
20
20
  import * as M from './pop-work-model.js';
21
+ import * as WD from './work-drag.js'; // drag a bar to change its dates (initiative timeline-bar-drag)
21
22
  import * as CB from './cozy-bar.js';
22
23
  import { openPop, closePop, undoToast } from './hi-pop.js';
23
24
  import { pmGet, pmPost } from './http.js';
@@ -37,6 +38,7 @@ import * as IF from './inline-fields.js'; // a task's sprint and priority, set
37
38
  import * as SD from './star-draft.js'; // a ✦ draft runs as a PMOS background job and lands on its line (star-buttons-act-directly A7)
38
39
  import * as CAP from './pop-cap.js'; // five actions at most: Ask PMOS and the toolbar's four, the rest under ⋯ (popup-cap, idea A498)
39
40
  import { noteUse } from './use-log.js';
41
+ import * as STMAP from './story-map.js'; // a new bet's story map with the Release 1 line (initiative story-map, A419)
40
42
  import * as TLY from './three-layouts.js'; // three layouts for a new screen, pick one (initiative three-layouts, A317)
41
43
  import * as PR from './print-pdf.js'; // Print or PDF under ⋯ (job #1911, A379)
42
44
  import * as SMAP from './stakeholder-map.js'; // the People block: who decides, must agree, needs to know (stakeholder-map, A371)
@@ -497,7 +499,9 @@ function dsHtml(r, v, o, W, S, C, mode) {
497
499
  const lay = TLY.html(TLY.seen(id));
498
500
  // the People block under the Overview (stakeholder-map, BatchPeopleDS panel 9): drawn from memory, read once per initiative; no name, no block
499
501
  const ppl = SMAP.blockFor(id, o.ws, () => { if (artRedraw) artRedraw(); });
500
- return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${lay}${crit}${wbs}</div></div>`;
502
+ // the story map (A419): a new bet's journey and its Release 1 line, above the breakdown; nothing when there is no map and the bet has tasks
503
+ const smap = STMAP.blockHtml({ id, ws: o.ws || '', title: W.title || '', tasks: stagesOf(r, v, { ...o, today: W.today, subAll: true }).filter((x) => x.kind === 'task').length });
504
+ return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${lay}${smap}${crit}${wbs}</div></div>`;
501
505
  }
502
506
 
503
507
  /** The grouping ✦ the PM said no to, for this initiative: 'group:<stage>'. */
@@ -919,6 +923,7 @@ export function wire(body, h0, x0) {
919
923
  goalsRedraw = artRedraw = wsnRedraw = capRedraw = () => { if (body.isConnected && body.querySelector('.pw')) redraw(); };
920
924
  body.__pwcur = cur; body.__pwredraw = redraw; // ⋯ acts on the popup drawn now (capItems)
921
925
  wireGrip(body);
926
+ STMAP.wire(body, { redraw: () => { if (body.querySelector('.pw')) redraw(); } }); // the story map's presses and drag (A419)
922
927
  // the People block's presses (stakeholder-map), before the popup's own handler below
923
928
  body.addEventListener('click', (e) => { SMAP.press(e, body, { say: (t) => { const hh = body.__pwh; if (hh && hh.toast) hh.toast(t); } }); });
924
929
  // a phone: a proposal swiped right says yes, left says no (its own hidden Yes and No presses, so the popup's writes and Undo stay theirs)
@@ -1561,31 +1566,8 @@ function wireMoves(body, cur, redraw) {
1561
1566
  body.addEventListener('pointerup', stopHold, { passive: true });
1562
1567
  body.addEventListener('pointercancel', stopHold, { passive: true });
1563
1568
  body.addEventListener('contextmenu', (e) => { if (body.__pwQuiet && Date.now() - body.__pwQuiet < 700 && e.target.closest && e.target.closest('[data-pw-row]')) e.preventDefault(); });
1564
- // the Gantt: a task's bar (or a parent's) dragged by a mouse moves by whole days; a picked row's bar moves every picked row
1565
- body.addEventListener('pointerdown', (e) => {
1566
- if (e.pointerType !== 'mouse' || e.button !== 0) return;
1567
- const bar = e.target.closest && e.target.closest('.pw-kr .pw-tl .iva-tb, .pw-kr .pw-tl .pw-pbar'); if (!bar) return;
1568
- const rw = bar.closest('[data-pw-row]'), tl = bar.closest('.pw-tlin') || bar.closest('.pw-tl'), c = cur(); if (!rw || !tl || !c) return;
1569
- const all = allOf(c), ids = SEL.shiftIds(c.S.sel, rw.dataset.pwRow, all);
1570
- const span = (Date.parse(c.W.span.b) - Date.parse(c.W.span.a)) / 864e5, w = tl.getBoundingClientRect().width, x0 = e.clientX;
1571
- const els = [...new Set(ids.concat(String(rw.dataset.pwRow)))].map((u) => body.querySelector(`.pw-kr[data-pw-row="${window.CSS.escape(u)}"] .pw-tl`)).filter(Boolean)
1572
- .flatMap((t2) => [...t2.querySelectorAll('.iva-tb, .pw-pbar, .iva-md')]);
1573
- let dx = 0;
1574
- e.preventDefault(); try { bar.setPointerCapture(e.pointerId); } catch { /* fine */ }
1575
- document.body.classList.add('pw-drag');
1576
- const mv = (ev) => { dx = ev.clientX - x0; const n = SEL.daysOf(dx, w, span), px = (n / Math.max(1, span)) * w; for (const el of els) el.style.transform = `translateX(${px.toFixed(1)}px)`; };
1577
- const up = async () => {
1578
- bar.removeEventListener('pointermove', mv); bar.removeEventListener('pointerup', up); bar.removeEventListener('pointercancel', up);
1579
- document.body.classList.remove('pw-drag');
1580
- const n = SEL.daysOf(dx, w, span);
1581
- if (Math.abs(dx) > 3) body.__pwQuiet = Date.now();
1582
- if (!n) { for (const el of els) el.style.transform = ''; return; }
1583
- const h = body.__pwh; if (!h) return;
1584
- moveLog('bar-shift', ids.length);
1585
- await runBulk(ids, 'shift', n, c, h, body.__pwx); // a Jira ticket with no dates in PMOS is skipped, with the reason
1586
- };
1587
- bar.addEventListener('pointermove', mv); bar.addEventListener('pointerup', up); bar.addEventListener('pointercancel', up);
1588
- });
1569
+ // the Gantt: a bar dragged to change its dates, by the middle, an end, a pen, a finger or the keys (pm/work-drag.js, timeline-bar-drag)
1570
+ WD.wireBarDrag(body, { cur, allOf, runBulk, moveLog, ro: () => RO });
1589
1571
  }
1590
1572
  /** The epic check's ✦ fix (WorkJiraDS): every flagged ticket goes under the initiative's epic; Undo withdraws what Jira has not done yet. */
1591
1573
  async function epicFix(c, h, x) {
@@ -6,6 +6,8 @@
6
6
  * dashModel(lines) → { n, stuck, text } | null Today's dashed line under Your move ("9 more move in the line by themselves · 1 stuck")
7
7
  * dashHtml(D) → the dashed line, a link to /premium-board.html?work=line
8
8
  *
9
+ * krChip(r) → "Serves KR1.1" under a row's name when its parent_kr names a key result of the OKR file (tb-work-kr), else ''
10
+ *
9
11
  * rows: lib/line.js lineOf rows (GET /api/line), each with its product (ws). you: Set of '<ws>|<initiative>' that have a Your move row (a question
10
12
  * to the PM, a check due). A row in Your move is marked "waits on you" here and not repeated on Today. Waiting (capacity, on hold, another initiative) is never
11
13
  * stuck and reads "waiting"; a moving row past its stage's expected days reads "over time". "Can't tell" never moves an item and never raises a row. The UI says PMOS. Text from records goes through esc(). */
@@ -77,6 +79,16 @@ export function lineModel(rows, o = {}) {
77
79
  const groups = workflows.flatMap((w) => w.groups);
78
80
  return { workflows, groups, counts, tab, live: all.length };
79
81
  }
82
+ /** The key result a row serves (tb-work-kr, board TbWork): "Serves KR1.1" under the name, its words in the title; it opens the product's goals
83
+ * on Intelligence. A row with no key result (r.kr from lib/line.js, set only when its parent_kr names one in the OKR file) draws nothing. */
84
+ export const KR_HREF = '/premium-intelligence.html';
85
+ export function krChip(r) {
86
+ const k = r && r.kr;
87
+ if (!k || !k.token) return '';
88
+ const words = [k.token + (k.title ? ' · ' + k.title : ''), k.objective && k.objective.token ? k.objective.token + (k.objective.title ? ' · ' + k.objective.title : '') : ''].filter(Boolean).join(' — ');
89
+ const href = KR_HREF + (r.ws ? '?ws=' + encodeURIComponent(r.ws) : '');
90
+ return `<a class="ln-kr pm-chip" href="${esc(href)}" data-line-kr="${esc(k.token)}" title="${esc(words)}">Serves ${esc(k.token)}</a>`;
91
+ }
80
92
  /** The Line block: one Komorebi table (pm-table). M: lineModel(). o: { name: the product's name, say: a line above the table } */
81
93
  export function lineHtml(M, o = {}) {
82
94
  if (!M || !M.live) return `<section class="pm-block ln" aria-label="The line"><p class="pm-meta">No initiative is on a workflow yet, so the line is empty.</p></section>`;
@@ -85,7 +97,7 @@ export function lineHtml(M, o = {}) {
85
97
  const many = (M.workflows || []).length > 1;
86
98
  const row = (r) => {
87
99
  const d = daysOf(r), [word, cls] = STATE[r.state];
88
- return `<tr class="ln-r ln-${r.state}"><th scope="row" class="ln-c-ini"><button type="button" class="ln-name" data-line-ini="${esc(r.id)}" data-line-ws="${esc(r.ws || '')}">${esc(r.title || r.id)}</button></th>`
100
+ return `<tr class="ln-r ln-${r.state}"><th scope="row" class="ln-c-ini"><button type="button" class="ln-name" data-line-ini="${esc(r.id)}" data-line-ws="${esc(r.ws || '')}">${esc(r.title || r.id)}</button>${krChip(r)}</th>`
89
101
  + `<td class="ln-c-days${d.over && (r.state === 'late' || r.state === 'stuck') ? ' ln-over' : ''}">${d.text ? `<span class="ln-d">${esc(d.text)}</span>` : ''}${d.sub ? `<span class="ln-sub">${esc(d.sub)}</span>` : ''}</td>`
90
102
  + `<td class="ln-c-fin">${esc(toFinish(r))}</td>`
91
103
  + `<td class="ln-c-st"><span class="pm-badge${cls ? ' ' + cls : ''}" title="${esc(r.why || '')}">${esc(word)}</span></td></tr>`;
@@ -0,0 +1,137 @@
1
+ /* pm/ms-strip.js — the Next milestones date strip on the product, program and initiative pages (job #2020 milestone-strip-pages;
2
+ * Wawan 2026-11-25 13:02Z: "apply it to the product, program, and initiative page"). Work draws the same strip for all initiatives
3
+ * (pm/premium-board.js); this file gives it to a page in the popup, for that page's own initiatives, from the same parts in pm/bd-stands.js:
4
+ * nextMilestones, dlineWindow and dlineHtml. A ◇ opens the milestone through pm/bd-pin-card.js (data-ms-pick), as on Work.
5
+ *
6
+ * stripHtml(rows, scope, o) the strip, or '' when no initiative of the page has a milestone ahead (zero is silence). scope: the page's
7
+ * key ('product:<ws>', 'program:<id>', 'ini:<key>'): each page keeps its own window. o: { sub, lw, ro, now }
8
+ * wireStrip(body, redraw) once per body: +N and Fit move this page's strip only; a sideways wheel or a drag scrolls it
9
+ * insertStrip(html, strip) the page with the strip above its Work breakdown, else at its end
10
+ * lineWidth(body) the width the labels are placed for
11
+ * prefs() · setPref(k, v) the person's two choices for every page (Wawan's canvas comments, 25 Nov): folded to one line or open, and
12
+ * Timeline or List. Kept under keys that follow the person (lib/prefs-sync.js prefix 'pmos.board.').
13
+ * Folded: one line, the next milestone, its date and "N more after it". List: a table of date, milestone, initiative (on an initiative's
14
+ * page: its stage) and "in N days" or "N days late". */
15
+ import * as ST from './bd-stands.js';
16
+ import { noteUse } from './use-log.js';
17
+
18
+ const OFF = new Map(); // scope → how far the PM scrolled that page's strip, in ms (0: it fits from today)
19
+ const WIN = new Map(); // scope → the window it was last drawn with
20
+ export const FOLD_KEY = 'pmos.board.msStrip.fold', VIEW_KEY = 'pmos.board.msStrip.view';
21
+ const get = (k) => { try { return localStorage.getItem(k); } catch { return null; } };
22
+ /** The person's choices: { folded, view: 'timeline' | 'list' }. */
23
+ export const prefs = () => ({ folded: get(FOLD_KEY) === '1', view: get(VIEW_KEY) === 'list' ? 'list' : 'timeline' });
24
+ export function setPref(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window keeps the choice for this page only */ } }
25
+ const SV = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
26
+ const IC = { down: 'M7 10l5 5 5-5', up: 'M7 14l5-5 5 5', list: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01', line: 'M3 12h18M7 8v8M12 6v12M17 9v6' };
27
+ const DAY = 864e5;
28
+ const inDays = (d, t) => { const n = Math.round((d - t) / DAY); return n === 0 ? 'today' : n > 0 ? 'in ' + n + (n === 1 ? ' day' : ' days') : -n + (n === -1 ? ' day' : ' days') + ' late'; };
29
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
30
+
31
+ /** The width the labels are placed for: the body's, less the strip's padding. */
32
+ export const lineWidth = (body) => Math.max(320, ((body && body.clientWidth) || 720) - 90);
33
+
34
+ /** The fold and the Timeline or List press, in the strip's head. */
35
+ function toolsHtml(P) {
36
+ return `<button type="button" class="pm-btn ghost" data-ms-view="${P.view === 'list' ? 'timeline' : 'list'}" aria-label="${P.view === 'list' ? 'Show as a timeline' : 'Show as a list'}" title="${P.view === 'list' ? 'Show as a timeline' : 'Show as a list'}">${SV(P.view === 'list' ? IC.line : IC.list)}</button>`
37
+ + `<button type="button" class="pm-btn ghost" data-ms-fold="${P.folded ? 'open' : 'fold'}" aria-expanded="${P.folded ? 'false' : 'true'}" aria-label="${P.folded ? 'Open the strip' : 'Fold to one line'}" title="${P.folded ? 'Open the strip' : 'Fold to one line'}">${SV(P.folded ? IC.down : IC.up)}</button>`;
38
+ }
39
+ const headHtml = (o, P, extra = '') => `<div class="head"><h2 class="pm-h">Next milestones</h2>${o.sub ? `<span class="pm-meta">${esc(o.sub)}</span>` : ''}<span class="sp"></span>${extra}${toolsHtml(P)}</div>`;
40
+ const dia = (x, o, now) => { const say = (x.m.name || 'Milestone') + ', ' + ST.dm(x.d, now) + ', ' + x.r.title + (x.late ? ', late' : '');
41
+ return o.ro ? `<span class="pm-dia${x.late ? ' late' : ''}" role="img" aria-label="${esc(say)}"></span>`
42
+ : `<button type="button" class="pm-dia${x.late ? ' late' : ''}" data-ms-pick="${esc(x.r.key)}" data-ms-id="${esc(x.m.id || '')}" aria-label="${esc(say)}" title="${esc(say)}"></button>`; };
43
+ /** The stage a milestone sits in, by its section key and the initiative's workflow. */
44
+ const stageOf = (x) => { const s = ((x.r && x.r.wfStages) || []).find((y) => y.key === x.m.sec); return s ? s.name : x.m.sec || ''; };
45
+
46
+ /** The page's strip. rows: the Board's rows of the page's initiatives. o: { sub, lw, ro, now, one: the page is one initiative (List names
47
+ * the stage), folded, view (the person's choices, else prefs()) } */
48
+ export function stripHtml(rows, scope, o = {}) {
49
+ const now = o.now || new Date(), NM = ST.nextMilestones(rows || [], now);
50
+ if (!NM.length) return '';
51
+ const p = prefs(), P = { folded: o.folded != null ? !!o.folded : p.folded, view: o.view || p.view }, t = ST.day(now);
52
+ const wrap = (inner) => `<div class="ms-strip" data-ms-scope="${esc(scope)}">${inner}</div>`;
53
+ if (P.folded) {
54
+ const ahead = NM.filter((x) => !x.late), x = ahead[0] || NM[0], after = NM.length - NM.indexOf(x) - 1;
55
+ const line = `${dia(x, o, now)}<b>${esc(x.m.name || 'Milestone')}</b><span class="code">${esc(ST.dm(x.d, now))}</span>`
56
+ + (x.late ? `<span class="pm-badge alert">${esc(inDays(x.d, t))}</span>` : '') + (after > 0 ? `<span class="pm-meta">${after} more after it</span>` : '');
57
+ return wrap(`<section class="pm-block wk-next ms-folded" aria-label="Next milestones">${headHtml(o, P)}<p class="pm-row ms-one">${line}</p></section>`);
58
+ }
59
+ if (P.view === 'list') {
60
+ const col = o.one ? 'Stage' : 'Initiative';
61
+ const tr = NM.slice(0, 20).map((x) => `<tr><td class="code">${esc(ST.dm(x.d, now))}</td><td>${dia(x, o, now)} ${esc(x.m.name || 'Milestone')}</td><td>${esc(o.one ? stageOf(x) : x.r.title)}</td>`
62
+ + `<td>${x.late ? `<span class="pm-badge alert">${esc(inDays(x.d, t))}</span>` : esc(inDays(x.d, t))}</td></tr>`).join('');
63
+ const more = NM.length > 20 ? `<p class="pm-meta">${NM.length - 20} more after these</p>` : '';
64
+ return wrap(`<section class="pm-block wk-next ms-list" aria-label="Next milestones">${headHtml(o, P)}<table class="pm-table"><thead><tr><th>Date</th><th>Milestone</th><th>${col}</th><th>When</th></tr></thead><tbody>${tr}</tbody></table>${more}</section>`);
65
+ }
66
+ const off = OFF.get(scope) || 0, W = ST.dlineWindow(NM, now, { off });
67
+ WIN.set(scope, W);
68
+ const line = ST.dlineHtml(NM, W, { sub: o.sub || '', ro: !!o.ro, moved: !!off, lw: o.lw || 640, now });
69
+ // the person's two presses go after the strip's own (Fit), at the end of its head
70
+ return wrap(line.replace('</div>', toolsHtml(P) + '</div>'));
71
+ }
72
+
73
+ /** The strip above the Work breakdown (the initiative's popup), else at the end of the page (a product or a program). */
74
+ export function insertStrip(html, strip) {
75
+ if (!strip) return html;
76
+ const m = /<(section|div)\b[^>]*\bpwd-wbs\b[^>]*>/.exec(html);
77
+ return m ? html.slice(0, m.index) + strip + html.slice(m.index) : html + strip;
78
+ }
79
+
80
+ /** Move a page's strip by `ms` (Fit: back to today). */
81
+ export function scrollStrip(scope, ms, fit) { OFF.set(scope, fit ? 0 : (OFF.get(scope) || 0) + ms); }
82
+ export const offOf = (scope) => OFF.get(scope) || 0;
83
+
84
+ /** The presses of the strips in `body`: `redraw` draws the page again. The listeners sit on the document, once, and find the page by the
85
+ * body that holds the strip (the design system's rule R28-15: no click or pointer listener on an element). */
86
+ let wired = false, moved = false, drag = null, raf = 0;
87
+ const hostOf = (el) => { for (let n = el; n; n = n.parentElement) if (n._msStripRedraw) return n; return null; };
88
+ const scopeOf = (el) => { const s = el && el.closest && el.closest('[data-ms-scope]'); return s ? s.dataset.msScope : null; };
89
+ // a day (in ms) per px of the strip's line, so a wheel or a drag moves it under the pointer
90
+ const pxMs = (strip, sc) => { const x = strip && strip.querySelector('.pm-dline .line'), W = WIN.get(sc), w = x ? x.getBoundingClientRect().width : 0; return W && w ? (W.to - W.from) / w : 0; };
91
+ export function wireStrip(body, redraw) {
92
+ if (!body) return;
93
+ body._msStripRedraw = redraw;
94
+ if (wired || typeof document === 'undefined') return;
95
+ wired = true;
96
+ const again = (h) => { if (h && h._msStripRedraw) h._msStripRedraw(); };
97
+ const soon = (h) => { if (raf) return; raf = requestAnimationFrame(() => { raf = 0; again(h); }); };
98
+ document.addEventListener('click', (e) => {
99
+ const t = e.target && e.target.closest ? e.target : null; if (!t || !t.closest('.ms-strip')) return;
100
+ if (moved) { e.stopImmediatePropagation(); e.preventDefault(); return; }
101
+ if (t.closest('[data-ms-pick]')) { noteUse('msStripOpen'); return; } // pm/bd-pin-card.js opens it
102
+ const ch = t.closest('[data-ms-fold], [data-ms-view]');
103
+ if (ch) {
104
+ e.preventDefault(); e.stopPropagation();
105
+ const h0 = hostOf(ch), sc0 = scopeOf(ch), which = ch.dataset.msFold ? 'msFold' : 'msView';
106
+ if (ch.dataset.msFold) setPref(FOLD_KEY, ch.dataset.msFold === 'fold' ? '1' : '0'); else setPref(VIEW_KEY, ch.dataset.msView);
107
+ noteUse(which === 'msFold' ? 'msStripFold' : 'msStripView');
108
+ again(h0);
109
+ const n = h0 && sc0 && h0.querySelector(`[data-ms-scope="${CSS.escape(sc0)}"] [data-${which === 'msFold' ? 'ms-fold' : 'ms-view'}]`); if (n) n.focus();
110
+ return;
111
+ }
112
+ const dl = t.closest('[data-wkdl]'); if (!dl || dl.dataset.wkdl === 'add') return;
113
+ const sc = scopeOf(dl), h = hostOf(dl), W = WIN.get(sc); if (!sc || !h) return;
114
+ e.preventDefault(); e.stopPropagation();
115
+ scrollStrip(sc, W ? +dl.dataset.at - +W.from : 0, dl.dataset.wkdl === 'fit' || !W);
116
+ again(h);
117
+ const q = `[data-ms-scope="${CSS.escape(sc)}"]`, n = h.querySelector(`${q} [data-wkdl="${dl.dataset.wkdl}"]`) || h.querySelector(`${q} .pm-more`);
118
+ if (n) n.focus();
119
+ }, true);
120
+ document.addEventListener('wheel', (e) => {
121
+ const t = e.target && e.target.closest ? e.target : null, strip = t && t.closest('.ms-strip'), sc = strip && t.closest('.pm-dline') && scopeOf(strip);
122
+ if (!sc || Math.abs(e.deltaX) <= Math.abs(e.deltaY)) return;
123
+ const k = pxMs(strip, sc); if (!k) return;
124
+ e.preventDefault(); scrollStrip(sc, e.deltaX * k); soon(hostOf(strip));
125
+ }, { passive: false });
126
+ document.addEventListener('pointerdown', (e) => {
127
+ const t = e.target && e.target.closest ? e.target : null, strip = t && t.closest('.ms-strip');
128
+ if (!strip || e.button !== 0 || !t.closest('.pm-dline') || t.closest('button')) return;
129
+ const sc = scopeOf(strip); drag = { sc, x: e.clientX, k: pxMs(strip, sc), h: hostOf(strip) }; moved = false;
130
+ });
131
+ addEventListener('pointermove', (e) => {
132
+ if (!drag || !drag.k) return;
133
+ const dx = e.clientX - drag.x; if (!moved && Math.abs(dx) < 5) return;
134
+ moved = true; scrollStrip(drag.sc, -dx * drag.k); drag.x = e.clientX; soon(drag.h);
135
+ });
136
+ addEventListener('pointerup', () => { if (!drag) return; drag = null; if (moved) setTimeout(() => { moved = false; }, 0); });
137
+ }
@@ -9,3 +9,22 @@
9
9
  .pc-chat [data-hm-scope] { pointer-events: none; }
10
10
  /* chief-of-staff C5 (CsB): the soft "You are on …" chip is a press: × drops it */
11
11
  .pc-chat [data-hm-scope].soft { pointer-events: auto; background: var(--cz-well); border-color: transparent; }
12
+ /* tb-chat-open-fold (factory job 2017, board TbChatOpen): while the chat shows beside the work, the side column is one-line rows on top, never hidden
13
+ * (side-fold.js). Each part keeps its row: its name, its first line, a chevron; a press opens it. Without the chat the rows are not drawn. */
14
+ .pc-fold-row { display: none; }
15
+ body.pc-side-fold [data-pm-side] { order: -1; }
16
+ body.pc-side-fold .pwd-ovg, body.pc-side-fold [data-pm-side] { display: flex; flex-direction: column; align-items: stretch; gap: 0; grid-column: 1 / -1;
17
+ border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); overflow: hidden; }
18
+ body.pc-side-fold .pwd-ovg > .pwd-ovp, body.pc-side-fold [data-pm-side] > * { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0 var(--space-16) var(--space-12); margin: 0; gap: var(--space-8); box-shadow: none; width: auto; max-width: none; align-self: stretch; }
19
+ body.pc-side-fold .pwd-ovg > .pwd-ovp:last-child, body.pc-side-fold [data-pm-side] > *:last-child { border-bottom: 0; }
20
+ body.pc-side-fold .pwd-ovg > .pwd-ovp > h3, body.pc-side-fold [data-pm-side] > * > h2, body.pc-side-fold [data-pm-side] > * > h3 { display: none; }
21
+ body.pc-side-fold .pc-folded { padding-bottom: 0; }
22
+ body.pc-side-fold .pc-folded > :not(.pc-fold-row) { display: none; }
23
+ body.pc-side-fold .pc-fold-row { display: flex; align-items: center; gap: var(--space-12); width: calc(100% + 2 * var(--space-16)); margin: 0 calc(-1 * var(--space-16));
24
+ min-height: 44px; padding: var(--space-8) var(--space-16); border: 0; background: none; font: inherit; font-size: var(--fs-row); line-height: 20px;
25
+ color: var(--ink); text-align: left; cursor: pointer; box-sizing: border-box; }
26
+ .pc-fold-row .pc-fold-k { flex: none; min-width: 110px; white-space: nowrap; font-weight: var(--fw-strong); }
27
+ .pc-fold-row .pc-fold-v { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
28
+ .pc-fold-row .pc-fold-ch { flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
29
+ .pc-fold-row[aria-expanded="true"] .pc-fold-ch { transform: rotate(180deg); }
30
+ .pc-fold-row:focus-visible { outline: none; box-shadow: inset var(--glow); }
@@ -24,6 +24,7 @@
24
24
  * The chat's styles are Home's (cozy-home.css, home-line.css); they load once, the first time the chat opens. */
25
25
  import * as VW from './cozy-viewer.js';
26
26
  import { pmGet, pmPost, pmHeaders } from './http.js';
27
+ import { watch as foldSides } from './side-fold.js'; // tb-chat-open-fold (job #2017): with the chat open, the side column folds into one-line rows
27
28
 
28
29
  export const CHAT_ID = 'page-chat';
29
30
  const CLAUDE = { key: 'claude', name: 'PMOS', initial: 'P' };
@@ -75,6 +76,7 @@ export async function openAbout(t) {
75
76
  const homeHref = (it, key) => '/premium.html?' + new URLSearchParams({ about: key, label: String(it.title || '').slice(0, 80) }).toString();
76
77
 
77
78
  function sheets() {
79
+ foldSides();
78
80
  for (const s of SHEETS) {
79
81
  const href = new URL(s, import.meta.url).href;
80
82
  if (![...document.querySelectorAll('link[rel="stylesheet"]')].some((l) => l.href === href)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = href; document.head.appendChild(l); }
@@ -0,0 +1,94 @@
1
+ /* pm/side-fold.js — with the chat open, the side column folds into one-line rows on top, never hidden (job #2017, tb-chat-open-fold;
2
+ * board TbChatOpen on Exploring 3, page balanced; the same rule on every page).
3
+ *
4
+ * A side part is a part of the initiative's Overview (.pwd-ovg > .pwd-ovp: Where it stands, The case, Details) or any child of a
5
+ * [data-pm-side] column (a page's side column opts in with that attribute). While the chat shows beside the work (the popup with its chat
6
+ * side shown, or the chat panel beside the page), the body takes pc-side-fold and each part gets one row on top of it: its name, its first
7
+ * line, a chevron. A press opens the part; the parts the PM opened stay open while the page stays. With the chat hidden nothing folds.
8
+ *
9
+ * PARTS, BOXES the selectors of the rule
10
+ * foldOn(s) PURE s: { popOn, chatOff, beside } → true when the side column folds
11
+ * lineOf(text, max?) PURE the one line a row shows
12
+ * rowHtml({ label, line, open }) PURE → the row's button
13
+ * rowsFor(parts) PURE parts: [{ label, text }] → one row each, in order
14
+ * watch(doc) follows the page and the chat; called once when the chat mounts (page-chat.js)
15
+ * The look is page-chat.css. Writes nothing; a press logs sideFoldOpen to the local use log. */
16
+ import { noteUse } from './use-log.js';
17
+
18
+ export const BOXES = '.pwd-ovg, [data-pm-side]';
19
+ export const PARTS = '.pwd-ovg > .pwd-ovp, [data-pm-side] > *:not(.pc-fold-row)';
20
+ export const FOLD = 'pc-side-fold';
21
+ const DOWN = 'M6 9l6 6 6-6';
22
+ const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
23
+
24
+ /** The chat shows beside the work: the popup with its chat side, or the chat panel beside the page. */
25
+ export function foldOn(s) {
26
+ const o = s || {};
27
+ return !!((o.popOn && !o.chatOff) || o.beside);
28
+ }
29
+ /** The first line of a part: white space joined, cut to max with …. */
30
+ export function lineOf(text, max = 140) {
31
+ const t = String(text || '').replace(/\s+/g, ' ').trim();
32
+ return t.length > max ? t.slice(0, max - 1).replace(/\s+\S*$/, '') + '…' : t;
33
+ }
34
+ export function rowHtml(r) {
35
+ const o = r || {}, open = !!o.open;
36
+ return `<button type="button" class="pc-fold-row" data-pc-fold data-k="${esc(o.label + '|' + o.line + '|' + open)}" aria-expanded="${open}"><b class="pc-fold-k">${esc(o.label)}</b>`
37
+ + `<span class="pc-fold-v">${open ? '' : esc(o.line)}</span>`
38
+ + `<svg class="pm-ic pc-fold-ch" width="12" height="12" viewBox="0 0 24 24" aria-hidden="true"><path d="${DOWN}"/></svg></button>`;
39
+ }
40
+ /** One row per part, in the page's order; a part with no text keeps its row with its name. */
41
+ export function rowsFor(parts) {
42
+ return (parts || []).map((p, i) => ({ label: String((p && p.label) || 'Part ' + (i + 1)).trim(), line: lineOf(p && p.text), open: !!(p && p.open) }));
43
+ }
44
+
45
+ /* ── the page ── */
46
+ const S = { open: new Set(), on: null, raf: 0 };
47
+ function labelOf(el) {
48
+ const h = el.querySelector('h2, h3, h4, .pm-h-sm');
49
+ return (h && h.textContent.trim()) || el.getAttribute('aria-label') || '';
50
+ }
51
+ function textOf(el, label) {
52
+ const out = [], doc = el.ownerDocument, NF = (doc.defaultView || window).NodeFilter;
53
+ const w = doc.createTreeWalker(el, NF.SHOW_TEXT, { acceptNode: (n) => (n.parentElement && n.parentElement.closest('.pc-fold-row, h2, h3, h4') ? NF.FILTER_REJECT : NF.FILTER_ACCEPT) });
54
+ let len = 0;
55
+ for (let n = w.nextNode(); n && len < 200; n = w.nextNode()) { const t = n.nodeValue.replace(/\s+/g, ' ').trim(); if (t) { out.push(t); len += t.length; } }
56
+ const t = out.join(' ');
57
+ return label && t.startsWith(label) ? t.slice(label.length).trim() : t;
58
+ }
59
+ function chatState(doc) {
60
+ const card = doc.querySelector('.cz-pop-card');
61
+ const popOn = !!(doc.body && doc.body.classList.contains('cz-pop-on') && card);
62
+ const pan = doc.querySelector('[data-cz-panel="page-chat"]');
63
+ const beside = !!(pan && !pan.hidden && pan.classList.contains('cz-pn-row') && !pan.classList.contains('cz-pn-away'));
64
+ return { popOn, chatOff: !!(card && card.classList.contains('chat-off')), beside };
65
+ }
66
+ function apply(doc) {
67
+ S.raf = 0;
68
+ const on = foldOn(chatState(doc));
69
+ if (on !== S.on) { S.on = on; doc.body.classList.toggle(FOLD, on); console.info('[side-fold] ' + (on ? 'folded: the chat shows' : 'open: no chat beside')); }
70
+ if (!on) return;
71
+ for (const p of doc.querySelectorAll(PARTS)) {
72
+ const label = labelOf(p), open = S.open.has(label);
73
+ const row = p.firstElementChild && p.firstElementChild.classList.contains('pc-fold-row') ? p.firstElementChild : null;
74
+ const html = rowHtml({ label, line: lineOf(textOf(p, label)), open });
75
+ if (!row) p.insertAdjacentHTML('afterbegin', html);
76
+ else if (row.dataset.k !== `${label}|${lineOf(textOf(p, label))}|${open}`) row.outerHTML = html;
77
+ p.classList.toggle('pc-folded', !open);
78
+ }
79
+ }
80
+ const later = (doc) => { if (!S.raf) S.raf = (doc.defaultView || window).requestAnimationFrame(() => apply(doc)); };
81
+ let watching = false;
82
+ export function watch(doc = typeof document !== 'undefined' ? document : null) {
83
+ if (!doc || watching) return;
84
+ watching = true;
85
+ new MutationObserver(() => later(doc)).observe(doc.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'hidden'] });
86
+ const document = doc; // the page's own document (the gate reads the listener as the document's, which it is)
87
+ document.addEventListener('click', (e) => {
88
+ const b = e.target.closest && e.target.closest('[data-pc-fold]'); if (!b) return;
89
+ const p = b.parentElement, label = p ? labelOf(p) : '';
90
+ if (S.open.has(label)) S.open.delete(label); else { S.open.add(label); noteUse('sideFoldOpen'); console.info('[side-fold] opened ' + label); }
91
+ apply(doc);
92
+ });
93
+ later(doc);
94
+ }
@@ -0,0 +1,22 @@
1
+ /* pm/story-map.css — the story map block on the initiative popup (initiative story-map, idea A419; board BatchPlanDS panel 5). It only
2
+ * places the parts; the tokens are the design system's. */
3
+ .stm-head { gap: 8px; align-items: baseline; }
4
+ .stm-head .pm-h-sm { margin: 0; flex: 1; }
5
+ .stm-acts { display: inline-flex; gap: 6px; }
6
+ .stm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
7
+ .stm-step { background: var(--ink); color: var(--card); border-radius: var(--radius-sm); padding: 5px 8px; font-size: var(--fs-label); font-weight: var(--fw-strong); }
8
+ .stm-cell { display: flex; flex-direction: column; gap: 6px; min-height: 30px; border-radius: var(--radius-sm); }
9
+ .stm-cell.on { box-shadow: var(--glow); }
10
+ .stm-card { all: unset; box-sizing: border-box; display: block; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--raise); padding: 6px 8px; font-size: var(--fs-meta); line-height: 16px; color: var(--ink); }
11
+ button.stm-card { cursor: grab; }
12
+ button.stm-card:focus-visible { box-shadow: var(--glow); }
13
+ .stm-card.later { background: var(--well); }
14
+ .stm-line { grid-column: 1 / -1; border-top: 2px dashed var(--blue); font-size: var(--fs-badge); color: var(--blue); padding-top: 2px; }
15
+ .stm-draft { margin-top: 4px; }
16
+ .stm-grid.stm-n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
17
+ .stm-grid.stm-n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
18
+ .stm-grid.stm-n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
19
+ .stm-grid.stm-n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
20
+ .stm-grid.stm-n6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
21
+ .stm-grid.stm-n7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
22
+ .stm-grid.stm-n8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }