create-pmos 0.426.0 → 0.428.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 (78) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/board-programs-test.js +16 -2
  7. package/workspace/briefing-premium-board-test.js +25 -20
  8. package/workspace/briefing-premium-test.js +2 -1
  9. package/workspace/changelog.json +24 -0
  10. package/workspace/guide/briefing-premium.md +4 -2
  11. package/workspace/guide/claude-proposes.md +3 -1
  12. package/workspace/guide/home.md +32 -7
  13. package/workspace/guide/programs.md +1 -0
  14. package/workspace/home-other-product-test.js +12 -2
  15. package/workspace/lib/context-use.js +54 -0
  16. package/workspace/lib/routes-live.js +3 -1
  17. package/workspace/lib/routes-meeting-material.js +22 -1
  18. package/workspace/lib/settings-store.js +14 -0
  19. package/workspace/lib/transcript-read.js +9 -2
  20. package/workspace/milestone-pins-test.js +13 -0
  21. package/workspace/milestone-suggest-test.js +10 -4
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/premium-board-actions-test.js +40 -13
  25. package/workspace/premium-rec-tab-test.js +8 -0
  26. package/workspace/premium-vw-item-test.js +7 -3
  27. package/workspace/premium-vw-jira-test.js +2 -1
  28. package/workspace/program-charter-test.js +1 -1
  29. package/workspace/program-leave-test.js +2 -2
  30. package/workspace/program-order-test.js +3 -2
  31. package/workspace/program-panel-test.js +2 -1
  32. package/workspace/public/pm/bd-acts.js +20 -26
  33. package/workspace/public/pm/bd-ini-panel.js +90 -32
  34. package/workspace/public/pm/bd-pin-card.js +4 -1
  35. package/workspace/public/pm/bd-span.js +22 -12
  36. package/workspace/public/pm/cozy-home.css +7 -0
  37. package/workspace/public/pm/cozy-live-pill.css +1 -0
  38. package/workspace/public/pm/cozy-live-pill.js +2 -1
  39. package/workspace/public/pm/cozy-rec-tab.js +12 -3
  40. package/workspace/public/pm/cozy-today.css +3 -0
  41. package/workspace/public/pm/cozy-viewer.js +157 -23
  42. package/workspace/public/pm/cozy-vw-shell.css +13 -0
  43. package/workspace/public/pm/cozy.css +6 -0
  44. package/workspace/public/pm/ctx-wedge.js +45 -0
  45. package/workspace/public/pm/hi-pop.css +82 -0
  46. package/workspace/public/pm/hi-pop.js +65 -0
  47. package/workspace/public/pm/home-app.js +70 -28
  48. package/workspace/public/pm/home-chat.js +7 -2
  49. package/workspace/public/pm/home-data.js +2 -1
  50. package/workspace/public/pm/home-ini.css +6 -76
  51. package/workspace/public/pm/home-ini.js +50 -68
  52. package/workspace/public/pm/home-list.js +29 -3
  53. package/workspace/public/pm/home-today.js +26 -9
  54. package/workspace/public/pm/ini-more.js +67 -0
  55. package/workspace/public/pm/ini-view-model.js +3 -2
  56. package/workspace/public/pm/ini-view.css +3 -1
  57. package/workspace/public/pm/ini-view.js +7 -5
  58. package/workspace/public/pm/live-model.js +1 -1
  59. package/workspace/public/pm/order-model.js +85 -0
  60. package/workspace/public/pm/premium-board.js +57 -11
  61. package/workspace/public/pm/premium-insights.js +11 -1
  62. package/workspace/public/pm/premium-vw-item.js +3 -1
  63. package/workspace/public/pm/premium-vw-jira.js +2 -0
  64. package/workspace/public/pm/prog-order.js +15 -2
  65. package/workspace/public/pm/sort-order.css +17 -0
  66. package/workspace/public/pm/sort-order.js +108 -0
  67. package/workspace/public/pm/tk-view.js +3 -2
  68. package/workspace/public/pm/wf-page.js +1 -1
  69. package/workspace/public/premium-board.html +1 -0
  70. package/workspace/server.js +28 -0
  71. package/workspace/sort-order-test.js +201 -0
  72. package/workspace/stage-card-test.js +1 -0
  73. package/workspace/task-card-test.js +1 -1
  74. package/workspace/test-lists/batch13-context-use.json +5 -0
  75. package/workspace/test-lists/sort-order.json +6 -0
  76. package/workspace/test-lists/viewer-trail.json +5 -0
  77. package/workspace/tk-tasks-test.js +5 -3
  78. package/workspace/viewer-trail-test.js +145 -0
@@ -44,13 +44,22 @@
44
44
  * render called with the body element to draw into; html is the same as a string. Neither: the body is left empty for the caller.
45
45
  * id optional; current() returns it, so a caller can tell whether its item is the one shown
46
46
  * onClose called once when this item leaves the card (Close, Escape, close(), or another open())
47
- * close() · back() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
47
+ * close() · back() · forward() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
48
48
  * drill() the next open() keeps the item shown now behind it, as back: true does (a page opens a task or a document from its own
49
49
  * rows through a module that does not know it is a drill-in: Home's initiative page, canvas HbCDrill)
50
50
  * Overlay (canvas HbCNarrow): a host marked data-cz-vw-overlay keeps its list when there is no room beside the chat; the Viewer then
51
51
  * lies over the chat (body.cz-vw-over) instead of folding the list to a rail. Open wide still folds it.
52
+ * One trail (feedback batch 14 item 7, canvas Exploring · Navigation NvADesk, NvAPhone, NvAPhoneTrail, NvAFlow):
53
+ * - a press inside the Viewer keeps the item shown behind the one it opens (a drill-in), as back: true and drill() do; a press on the page
54
+ * outside starts a new trail; fresh: true always starts one. Opening the item shown again (the same id) draws it again in its place.
55
+ * - ← goes one step back, and its name says where ("Back to PSLE Landing Page"); at the trail's first item a desk shows no ←, a phone's
56
+ * ← closes. → shows only after a back, and any new open drops it. Hover ← or → (desk) or hold it (phone): the trail, newest first,
57
+ * ending at the page it started on; a press jumps there.
58
+ * - every step is a browser history entry ({ czvw: { s, i } }), so the browser's Back and Forward and a phone's back swipe walk the same
59
+ * trail; Back at the first item closes the Viewer. Close (×, Escape, close()) takes the trail's entries off again, so Back never
60
+ * lands on a closed item. A page writes its own address with replaceUrl(url), which waits while the history is still moving.
52
61
  * placeholder(featureName, { kind?, icon? }) opens the card with czPlaceholder(featureName) in it (cozy-placeholder.js)
53
- * onChange(fn) → fn({ open, id, kind, title }) after each open and close; document also gets the event 'cz-viewer' with the same detail.
62
+ * onChange(fn) → fn({ open, id, kind, title, via }) after each open and close (via 'history' when the browser's Back closed it); document also gets the event 'cz-viewer' with the same detail.
54
63
  * czSummary({ line, tone, right, text, meta, primary, also, extra }) → the summary card's markup: one line of state, the words, one quiet meta
55
64
  * line and ONE primary press ({ label, act } → data-czs-act="<act>", or { label, href }). tone 'you' (blue dot), 'warn' (amber), 'live' (red).
56
65
  * also: [{ act, label, icon }] quiet icon-only presses after the primary (the Done check of a task). second: { label, act } one quiet
@@ -87,7 +96,7 @@ const P = {
87
96
  add: 'M12 5v14M5 12h14', back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
88
97
  wide: 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7', side: 'M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7',
89
98
  chat: 'M5 6.5A2.5 2.5 0 0 1 7.5 4h9A2.5 2.5 0 0 1 19 6.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4 3.5V16h.5A2.5 2.5 0 0 1 5 13.5z',
90
- tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
99
+ fwd: 'M10 6l6 6-6 6', home: 'M4 11l8-7 8 7v9H4z', tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
91
100
  };
92
101
  export const PHONE = 760;
93
102
  const NARROW = 1100, MIN = 420, CHAT = 360, RAIL = 64, MAXF = 0.7, W2 = 760, FLOAT = 560;
@@ -102,7 +111,7 @@ const isPhone = () => typeof innerWidth === 'number' && innerWidth <= PHONE;
102
111
  const onHome = () => typeof document !== 'undefined' && !!document.body && document.body.classList.contains('cz-home');
103
112
  const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file · .*/, 'file').replace(/[^a-z0-9]+/g, '-').slice(0, 40) || 'item';
104
113
 
105
- const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, rail: false, w: 0, drill: false, over: false };
114
+ const V = { el: null, cur: null, back: null, subs: [], stack: [], fwd: [], wide: false, rail: false, w: 0, drill: false, over: false };
106
115
 
107
116
  /** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
108
117
  const sameAs = (kind, title) => { const k = String(kind || '').trim().toLowerCase().replace(/^file · /, ''), t = String(title || '').trim().toLowerCase(); return !!t && (k === t || k.split('/').pop() === t || k.split('/').pop().replace(/\.[a-z]+$/, '') === t); };
@@ -115,7 +124,8 @@ function renHtml(o) {
115
124
  return `<form class="cz-vw-ren" data-cz-vw-ren data-esc-layer><input id="czVwTitle" type="text" value="${esc(o.renValue != null ? o.renValue : o.title || '')}" maxlength="${max}" aria-label="Name" autocomplete="off"${o.renBusy ? ' disabled' : ''}>`
116
125
  + `<button type="submit" class="cz-vw-sv" aria-label="Save the name" title="Save (Enter). Esc cancels."${o.renBusy ? ' disabled' : ''}>${svg('M5 12.5l4.5 4.5L19 7.5', 16, 2.2)}</button></form>` + j + err;
117
126
  }
118
- /** The header's markup for one item; pure, so a unit test can read it. o.canBack: ← is drawn; o.isWide: ⤢ reads "Back to the side". */
127
+ /** The header's markup for one item; pure, so a unit test can read it. o.canBack: ← is drawn (o.backTo names where it goes); o.fwdTo: → is
128
+ * drawn after a back; o.isWide: ⤢ reads "Back to the side". */
119
129
  export function headHtml(it) {
120
130
  const o = it || {};
121
131
  const phone = !!o.phone;
@@ -128,7 +138,8 @@ export function headHtml(it) {
128
138
  : `<button type="button" class="cz-vw-ib" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 18)}</button>`).join('');
129
139
  const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
130
140
  const chip = o.chip && (o.chip.n > 0 || o.chip.looking) ? `<button type="button" class="cz-vw-chip${o.chip.looking ? ' live' : ''}" data-cz-vw="chip" aria-haspopup="dialog" aria-label="${esc(o.chip.label || 'Claude proposes ' + o.chip.n + '. Open')}" title="${esc(o.chip.label || 'Claude proposes')}">${svg(ICONS.spark, 13, 2)}${o.chip.n > 0 ? `<b>${esc(o.chip.n)}</b>` : ''}</button>` : '';
131
- return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
141
+ return (o.canBack || phone ? ib('back', o.canBack ? (o.backTo ? 'Back to ' + o.backTo : 'Back') : 'Close the viewer', P.back) : '')
142
+ + (o.fwdTo ? ib('fwd', 'Forward to ' + o.fwdTo, P.fwd) : '')
132
143
  + (o.check ? `<button type="button" class="cz-vw-tile cz-vw-chk s-${esc(o.check.state || 'todo')}" data-cz-vw="press" data-cz-vw-p="check" aria-label="${esc(o.check.label || 'Mark done')}" title="${esc(o.check.title || o.check.label || 'Mark done')}"${o.check.disabled ? ' disabled' : ''}><span class="bx"></span></button>`
133
144
  : `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
134
145
  + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
@@ -362,7 +373,8 @@ function mount() {
362
373
  const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
363
374
  const a = b.dataset.czVw;
364
375
  if (a === 'close') guarded(close, b);
365
- else if (a === 'back') guarded(() => { if (V.stack.length) back(); else close(); }, b);
376
+ else if (a === 'back') { if (!held(b)) guarded(() => { if (V.stack.length) step(-1); else close(); }, b); }
377
+ else if (a === 'fwd') { if (!held(b)) guarded(() => step(1), b); }
366
378
  else if (a === 'press') { if (V.cur && typeof V.cur.onPress === 'function') V.cur.onPress(b.dataset.czVwP, b); }
367
379
  else if (a === 'more') moreMenu(b);
368
380
  else if (a === 'chip') { if (V.cur && V.cur.chip && typeof V.cur.chip.on === 'function') V.cur.chip.on(b); }
@@ -370,6 +382,7 @@ function mount() {
370
382
  else if (a === 'wide') wide();
371
383
  else if (a === 'discuss') discuss();
372
384
  });
385
+ holdable(el);
373
386
  el.addEventListener('submit', (e) => { if (e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); saveRename(); } });
374
387
  el.addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); e.stopPropagation(); endRename(); } });
375
388
  el.addEventListener('input', (e) => { if (e.target.id === 'czVwTitle' && V.cur && V.cur.renaming) V.cur.renValue = e.target.value; });
@@ -389,7 +402,7 @@ function place(el) {
389
402
  else { if (el.parentNode !== document.body) document.body.appendChild(el); el.classList.add('cz-vw-float'); }
390
403
  }
391
404
  function emit() {
392
- const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null };
405
+ const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null, via: V.cur ? '' : V.via || '' }; // via 'history': the browser's Back closed it
393
406
  document.body.classList.toggle('cz-vw-on', d.open);
394
407
  V.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
395
408
  document.dispatchEvent(new CustomEvent('cz-viewer', { detail: d }));
@@ -408,7 +421,8 @@ function redraw() {
408
421
  if (!V.el || !V.cur) return;
409
422
  V.ph = isPhone();
410
423
  const hd = V.el.querySelector('.cz-vw-hd');
411
- hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, isWide: V.wide || V.rail, phone: V.ph, home: onHome() });
424
+ const bk = V.stack[V.stack.length - 1], fw = V.fwd[V.fwd.length - 1];
425
+ hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide || V.rail, phone: V.ph, home: onHome() });
412
426
  hd.classList.toggle('cz-vw-renon', !!V.cur.renaming);
413
427
  }
414
428
 
@@ -464,14 +478,24 @@ export function open(it) {
464
478
  }
465
479
  const el = mount(); place(el);
466
480
  if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
467
- if ((o.back || V.drill) && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back && !o.keep) V.stack = [];
468
- V.drill = false;
481
+ const was = isOpen(), pos = V.stack.length, how = stepOf(o);
482
+ if (how === 'nav') { V.stack = o._trail.stack; V.fwd = o._trail.fwd; }
483
+ else if (how === 'drill') { V.stack.push(V.cur.args); V.fwd = []; hq({ push: 1, s: H.s, i: V.stack.length }); }
484
+ else if (how === 'new') {
485
+ // a press starts a trail on its own entry; an open no press led to (the page drew it, or Back from another page restored it) takes the
486
+ // page's entry, so Back from it leaves the page as before. A new trail from a press takes the place of a pressed one.
487
+ const auto = !(H.press && Date.now() - H.press.t < 10000) || H.adopt, wasAuto = H.auto;
488
+ V.stack = []; V.fwd = []; H.s = serial(); H.auto = auto && !(was && !wasAuto);
489
+ if (was && pos) hq({ go: -pos }); // back to where this trail started
490
+ if ((was && !(wasAuto && !auto)) || (!was && auto)) hq({ s: H.s, i: 0, auto: H.auto }); else hq({ push: 1, s: H.s, i: 0 });
491
+ }
492
+ V.drill = false; H.adopt = false;
469
493
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
470
494
  leave();
471
495
  V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
472
496
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
473
497
  redraw();
474
- const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
498
+ el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
475
499
  const body = el.querySelector('.cz-vw-body');
476
500
  body.innerHTML = ''; body.scrollTop = 0;
477
501
  body.className = 'cz-vw-body'; body.onclick = null; body.oninput = null; body.onchange = null; body.onkeydown = null; // what one item's render added to the body does not reach the next
@@ -485,21 +509,30 @@ export function open(it) {
485
509
  }
486
510
  /** The next open() is a drill-in: the item shown now stays behind it, and ← comes back to it. Nothing open: nothing to keep. */
487
511
  export function drill() { V.drill = isOpen(); }
488
- /** ← : the item that was shown before this drill-in, drawn again. With nothing behind, ← closes. */
489
- export function back() {
490
- const prev = V.stack.pop();
491
- if (!prev) { close(); return null; }
492
- return open({ ...prev, back: false, _back: true });
493
- }
494
- /** Close the Viewer. Focus goes back to what had it before the Viewer opened. The list comes back from the rail. */
495
- export function close() {
512
+ /** ← : the item that was shown before this one, drawn again. With nothing behind, ← closes. */
513
+ export function back() { if (!V.stack.length) { close(); return null; } return step(-1); }
514
+ /** → : after a back, the item that was shown after this one. Nothing ahead: nothing happens. */
515
+ export function forward() { return V.fwd.length ? step(1) : null; }
516
+ /** The trail for the tests and the trail list: { back: [titles, nearest first], here, ahead: [titles, nearest first] }. */
517
+ export function trail() {
518
+ const t = (a) => (a && a.title) || '';
519
+ return { back: V.stack.map(t).reverse(), here: V.cur ? V.cur.title : null, ahead: V.fwd.map(t).reverse() };
520
+ }
521
+ /** Close the Viewer. Focus goes back to what had it before the Viewer opened. The list comes back from the rail. o.quiet: the browser
522
+ * already left the trail (its Back at the first item), so the history is not moved again. */
523
+ export function close(o = {}) {
496
524
  if (!V.el || V.el.hidden) return;
525
+ const pos = V.stack.length;
497
526
  leave();
498
- V.stack = []; V.wide = false; V.drill = false;
527
+ // the trail's entries come off, so Back never lands on a closed item; a trail on the page's own entry gives that entry back
528
+ if (!o.quiet && H.s) { if (H.auto) { if (pos) hq({ go: -pos }); hq({ clear: 1 }); } else hq({ go: -(pos + 1) }); }
529
+ H.s = ''; H.auto = false;
530
+ V.via = o.quiet ? 'history' : '';
531
+ V.stack = []; V.fwd = []; V.wide = false; V.drill = false;
499
532
  if (V.over) { V.over = false; document.body.classList.remove('cz-vw-over'); }
500
533
  V.el.hidden = true;
501
534
  V.el.querySelector('.cz-vw-body').innerHTML = '';
502
- const m = V.el.querySelector('.cz-vw-menu'); if (m) m.remove();
535
+ V.el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
503
536
  setRail(false);
504
537
  emit();
505
538
  const b = V.back; V.back = null;
@@ -514,6 +547,103 @@ export function placeholder(featureName, o = {}) {
514
547
  return open({ id: 'placeholder:' + featureName, kind: o.kind || featureName, title: featureName, icon: o.icon || 'info', render: (el) => czPlaceholder(el, featureName) });
515
548
  }
516
549
 
550
+ /* ── one trail: ← →, the browser's Back and Forward, a phone's back swipe (batch 14 item 7) ── */
551
+ const H = { s: '', n: 0, adopt: false, auto: false, q: [], wait: 0, press: null };
552
+ const canHist = () => typeof history !== 'undefined' && typeof history.pushState === 'function' && typeof location !== 'undefined';
553
+ const serial = () => Date.now().toString(36) + '-' + (++H.n);
554
+ /** How an open moves the trail: 'nav' (← →, a jump), 'keep' (the same item again, a view switch), 'drill' (it keeps the item behind it), 'new'. */
555
+ function stepOf(o) {
556
+ if (o._nav) return 'nav';
557
+ const p = H.press && Date.now() - H.press.t < 10000 ? H.press : null; // the press that led here: an open often waits for a module or a read
558
+ if (o.keep && V.cur) return 'keep';
559
+ if (V.cur && V.cur.args && !o.fresh && (o.back || V.drill)) return 'drill'; // asked for: a view of the same item drills in too (Stage, Documents)
560
+ if (V.cur && o.id != null && V.cur.id === String(o.id) && !(p && !p.inside) && !o.fresh) return 'keep';
561
+ if (V.cur && V.cur.args && !o.fresh && p && p.inside) return 'drill';
562
+ return 'new';
563
+ }
564
+ /** The history follows the trail. A go() waits for its popstate before the next push or replace, so the order holds. */
565
+ function hq(op) { if (!canHist()) return; H.q.push(op); hRun(); }
566
+ function hRun() {
567
+ while (H.q.length && !H.wait) {
568
+ const op = H.q.shift();
569
+ try {
570
+ if (op.go) { const t = H.wait = Date.now(); history.go(op.go); setTimeout(() => { if (H.wait === t) { H.wait = 0; hRun(); } }, 700); }
571
+ else if (op.url != null) history.replaceState(history.state, '', op.url);
572
+ else if (op.clear) { const { czvw, ...rest } = history.state && typeof history.state === 'object' ? history.state : {}; history.replaceState(czvw && Object.keys(rest).length ? rest : czvw ? null : history.state, '', location.href); }
573
+ else if (op.push) history.pushState({ czvw: { s: op.s, i: op.i } }, '', location.href);
574
+ else history.replaceState({ ...(history.state && typeof history.state === 'object' ? history.state : {}), czvw: { s: op.s, i: op.i, ...(op.auto ? { auto: 1 } : {}) } }, '', location.href);
575
+ } catch { H.wait = 0; }
576
+ }
577
+ }
578
+ /** A page writes its own address here (in place of history.replaceState): it waits while the history is still moving, so it lands on the
579
+ * entry the page shows. */
580
+ export function replaceUrl(url) { if (canHist()) hq({ url: String(url) }); }
581
+ /** n steps along the trail (← is -1, → is 1, the trail list jumps). Past its start the Viewer closes. o.quiet: the browser already moved. */
582
+ function step(n, o = {}) {
583
+ if (!V.cur || !n) return null;
584
+ const seq = [...V.stack, V.cur.args, ...V.fwd.slice().reverse()], at = V.stack.length + n;
585
+ if (at < 0) { close(o); return null; }
586
+ if (at >= seq.length) return null;
587
+ const to = seq[at];
588
+ if (!o.quiet) hq({ go: n });
589
+ return open({ ...to, back: false, keep: false, _asked: true, _nav: true, _trail: { stack: seq.slice(0, at), fwd: seq.slice(at + 1).reverse() } });
590
+ }
591
+ /** The browser moved (Back, Forward, a swipe, a long press on its own ←). An item with unsaved changes asks first: the browser goes back to
592
+ * where it was, and the move runs on Save or Discard. */
593
+ function popped(e) {
594
+ if (H.wait) { H.wait = 0; hRun(); return; } // the history moving after ← → or a close: the Viewer is already there
595
+ const st = e && e.state && e.state.czvw;
596
+ if (!st) { if (isOpen()) follow(-(V.stack.length + 1)); return; } // before the trail: the page as it was
597
+ if (st.s === H.s && isOpen()) { const n = st.i - V.stack.length; if (n) follow(n); return; }
598
+ if (st.auto) { if (isOpen()) follow(-(V.stack.length + 1)); return; } // an item the page drew itself: the page, before this trail
599
+ hq({ go: -1 }); // a closed trail's entry (Forward after a close): nothing to show, so on to the page
600
+ }
601
+ function follow(n) {
602
+ let now = true, ran = false;
603
+ guarded(() => { ran = true; if (now) step(n, { quiet: true }); else step(n); });
604
+ now = false;
605
+ if (!ran) hq({ go: -n });
606
+ }
607
+ /* where a press was: inside the Viewer it drills in, outside it starts a new trail */
608
+ function pressAt(e) { const t = e.target; H.press = { t: Date.now(), inside: !!(V.el && t && t.nodeType === 1 && V.el.contains(t) && !t.closest('.cz-vw-trail')) }; }
609
+ /* the trail list: hover ← or → for a moment (a mouse), or hold it (a touch). It names every step, newest first, and the page it started on. */
610
+ let HOLD = { t: 0, fired: 0 };
611
+ function holdable(el) {
612
+ el.addEventListener('pointerover', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b || e.pointerType === 'touch' || !V.stack.length && !V.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => trailMenu(b), 500); });
613
+ el.addEventListener('pointerout', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) clearTimeout(HOLD.t); });
614
+ el.addEventListener('pointerdown', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b) return; HOLD.fired = 0; if (e.pointerType === 'mouse' || !V.stack.length && !V.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => { HOLD.fired = Date.now(); trailMenu(b); }, 500); });
615
+ ['pointerup', 'pointercancel'].forEach((k) => el.addEventListener(k, () => clearTimeout(HOLD.t)));
616
+ el.addEventListener('contextmenu', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) e.preventDefault(); });
617
+ }
618
+ /** A hold that opened the trail list is not also a press. */
619
+ function held() { if (HOLD.fired && Date.now() - HOLD.fired < 800) { HOLD.fired = 0; return true; } return false; }
620
+ const PAGES = { '/premium.html': 'Home', '/premium-board.html': 'Board', '/premium-insights.html': 'Insights' };
621
+ function trailMenu(b) {
622
+ if (!V.cur || !V.el) return;
623
+ const old = V.el.querySelector('.cz-vw-trail'); if (old) old.remove();
624
+ const seq = [...V.stack, V.cur.args, ...V.fwd.slice().reverse()], here = V.stack.length;
625
+ const row = (it, i) => `<button type="button" role="menuitem" data-cz-vw-go="${i - here}"${i === here ? ' aria-current="page" class="here"' : i > here ? ' class="ahead"' : ''}>`
626
+ + `<span class="t">${svg(it.check ? ICONS.task : path(it.icon), 15)}</span><span>${esc(it.title || it.kind || 'Item')}</span>${i === here ? '<i class="dot" aria-hidden="true"></i>' : ''}</button>`;
627
+ const m = document.createElement('div');
628
+ m.className = 'cz-vw-trail'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'This trail'); m.dataset.escLayer = '1';
629
+ m.innerHTML = seq.map((it, i) => ({ it, i })).reverse().map(({ it, i }) => row(it, i)).join('')
630
+ + `<button type="button" role="menuitem" class="pg" data-cz-vw-go="${-(here + 1)}"><span class="t">${svg(P.home, 15)}</span><span>${esc(PAGES[location.pathname] || document.title || 'The page')}</span></button>`;
631
+ const off = () => { m.remove(); document.removeEventListener('pointerdown', away, true); };
632
+ const away = (e) => { if (!m.contains(e.target)) off(); };
633
+ m.addEventListener('click', (e) => { const x = e.target.closest('[data-cz-vw-go]'); if (!x) return; const n = +x.dataset.czVwGo; off(); if (n) guarded(() => step(n), b); });
634
+ m.addEventListener('keydown', (e) => {
635
+ const bs = [...m.querySelectorAll('button')], at = bs.indexOf(document.activeElement);
636
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); off(); b.focus(); }
637
+ else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); const n = bs[(at + (e.key === 'ArrowDown' ? 1 : -1) + bs.length) % bs.length]; if (n) n.focus(); }
638
+ });
639
+ m.addEventListener('pointerleave', (e) => { if (e.pointerType === 'mouse' && !(e.relatedTarget && b.contains(e.relatedTarget))) off(); });
640
+ V.el.appendChild(m);
641
+ const r = b.getBoundingClientRect(), h = V.el.getBoundingClientRect();
642
+ m.style.left = Math.max(8, r.left - h.left) + 'px'; m.style.top = (r.bottom - h.top + 6) + 'px';
643
+ document.addEventListener('pointerdown', away, true);
644
+ const c = m.querySelector('.here') || m.querySelector('button'); if (c) c.focus({ preventScroll: true });
645
+ }
646
+
517
647
  if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
518
648
  // Escape closes the Viewer first, unless a layer over it (a menu, a confirm) is open: that layer closes first. The listener is on
519
649
  // window in the capture phase and is added before premium-shell.js adds its own, so the old dialog does not also close on the same key.
@@ -522,5 +652,9 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
522
652
  if (document.querySelector('[data-esc-layer]')) return;
523
653
  e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
524
654
  }, true);
655
+ window.addEventListener('click', pressAt, true);
656
+ window.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') pressAt(e); }, true);
657
+ window.addEventListener('popstate', popped);
658
+ try { H.adopt = !!(history.state && history.state.czvw); } catch { H.adopt = false; } // back here from another page, or a reload: the first open takes this entry
525
659
  }
526
- if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
660
+ if (typeof window !== 'undefined') window.czViewer = { open, close, back, forward, trail, replaceUrl, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
@@ -54,6 +54,17 @@ body.cz-vw-drag, body.cz-vw-drag * { cursor: col-resize !important; user-select:
54
54
  .cz-vw-menu hr { border: 0; border-top: 1px solid var(--cz-hair); margin: 4px 6px; }
55
55
  .cz-vw-menu .k { margin-left: auto; color: var(--cz-ink3); font-size: 12px; }
56
56
  .cz-vw-menu .bad { color: var(--cz-red); }
57
+ /* the trail list (batch 14 item 7, canvas NvADesk, NvAPhoneTrail): hover ← → on a desk, hold it on a phone; newest first, then the page */
58
+ .cz-vw-hd [data-cz-vw="fwd"] { margin-left: -6px; }
59
+ .cz-vw-trail { position: absolute; width: 280px; max-height: 60vh; overflow: auto; background: var(--cz-card); border-radius: 16px; box-shadow: var(--cz-sheet), 0 0 0 1px var(--cz-hair); padding: 6px; z-index: 7; display: flex; flex-direction: column; gap: 2px; }
60
+ .cz-vw-trail button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 12px; font: 600 14px var(--cz-sans); color: var(--cz-ink); background: none; border: 0; text-align: left; cursor: pointer; }
61
+ .cz-vw-trail button > span:not(.t) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
62
+ .cz-vw-trail button:hover, .cz-vw-trail button:focus-visible { background: var(--cz-well); outline: none; }
63
+ .cz-vw-trail .t { width: 28px; height: 28px; border-radius: 8px; background: var(--cz-bluebg); color: var(--cz-blueink); display: inline-grid; place-items: center; flex: none; }
64
+ .cz-vw-trail .here { background: var(--cz-well); font-weight: 800; cursor: default; }
65
+ .cz-vw-trail .ahead { color: var(--cz-ink2); }
66
+ .cz-vw-trail .ahead .t, .cz-vw-trail .pg .t { background: var(--cz-well); color: var(--cz-ink2); }
67
+ .cz-vw-trail .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--cz-blue); flex: none; }
57
68
 
58
69
  /* the summary card: one state line, the words, one quiet meta line, one primary */
59
70
  .czs-sum { background: color-mix(in srgb, var(--cz-well) 60%, var(--cz-card)); border-radius: 20px; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
@@ -140,6 +151,8 @@ body.cz-vw-rail [data-cz-vw-list] > :not(.cz-vw-railbar), body.cz-vw-rail #hmLis
140
151
  .cz-vw-sv { width: 36px; height: 36px; }
141
152
  .cz-vw-body { padding: 4px 16px 16px; }
142
153
  .cz-vw-menu { right: 8px; }
154
+ .cz-vw-trail { position: fixed; left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-height: 70vh; border-radius: 24px 24px 0 0; padding: 10px 12px 28px; }
155
+ .cz-vw-trail button { min-height: 52px; font-size: 15px; }
143
156
  .cz-vw-menu button, .czs-ib { min-height: 44px; }
144
157
  .czs-pri, .czs-sec2 { height: 44px; min-height: 44px; }
145
158
  .czs-ib { width: 44px; }
@@ -190,6 +190,12 @@ body.cz { margin: 0; font-family: var(--cz-sans); color: var(--cz-ink); backgrou
190
190
  .cz-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; position: relative; }
191
191
  .cz-dot.you { background: var(--cz-blue); } .cz-dot.late { background: var(--cz-dot-late); } .cz-dot.risk { background: var(--cz-dot-risk); }
192
192
  .cz-dot.red { background: var(--cz-dot-red); } .cz-dot.ok { background: var(--cz-dot-ok); } .cz-dot.q { background: var(--cz-dot-q); }
193
+ /* How full a session's context is (batch 13 item 8, XctxA1Desk): a small pie at the row's end, from 50%. Grey, amber from 70%, red from 90%
194
+ * with the critical pulse. A pie, not a ring: the hollow ring already means running. pm/ctx-wedge.js draws it. */
195
+ .cz-ctx { --c: var(--cz-ink3); width: 14px; height: 14px; border-radius: 50%; flex: none; display: inline-block; position: relative; background: conic-gradient(var(--c) var(--p, 0%), var(--cz-well2) 0); }
196
+ .cz-ctx.warn { --c: var(--cz-dot-risk); } .cz-ctx.crit { --c: var(--cz-dot-red); }
197
+ .cz-ctx.p50 { --p: 50%; } .cz-ctx.p55 { --p: 55%; } .cz-ctx.p60 { --p: 60%; } .cz-ctx.p65 { --p: 65%; } .cz-ctx.p70 { --p: 70%; } .cz-ctx.p75 { --p: 75%; } .cz-ctx.p80 { --p: 80%; } .cz-ctx.p85 { --p: 85%; } .cz-ctx.p90 { --p: 90%; } .cz-ctx.p95 { --p: 95%; } .cz-ctx.p100 { --p: 100%; }
198
+ .cz-ctx.crit::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--c); animation: cz-crit 1.6s ease-out infinite; }
193
199
 
194
200
  /* ── Motion signals importance only, by level. Nothing else moves. ── */
195
201
  .cz-dot.m-info::after, .cz-dot.m-warn::after, .cz-dot.m-crit::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit; }
@@ -0,0 +1,45 @@
1
+ /* ctx-wedge.js — how full a session's context is, as Home, the chat header and the Live pill draw it (batch 13 item 8, canvas XctxA1Desk).
2
+ *
3
+ * A session row from /api/sessions carries `ctx` (lib/context-use.js): { used, window, pct, level, at, advise }. Under 50% nothing shows
4
+ * (zero is silence). From 50% a small pie at the row's end; amber from 70%, red with the critical pulse from 90%. Hover or a long press
5
+ * says "116k of 200k used · last turn 10:12". `advise: 'compact'` is Claude's ✦ proposal: the row's quiet line says so and ✓ types /compact.
6
+ * Safe to close (item 7) outranks it: a row keeps one ✦. */
7
+
8
+ const esc = (x) => String(x == null ? '' : x).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
9
+ const k = (n) => (n >= 1e6 ? (n / 1e6).toFixed(n % 1e6 ? 1 : 0) + 'M' : Math.round(n / 1000) + 'k');
10
+ const hm = (iso) => { const d = new Date(iso); return isNaN(d) ? '' : String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
11
+
12
+ /** "116k of 200k used · last turn 10:12" */
13
+ export function ctxLine(c) {
14
+ if (!c || !(c.used > 0)) return '';
15
+ const head = c.window ? `${k(c.used)} of ${k(c.window)} used` : `${k(c.used)} used`;
16
+ const t = c.at ? hm(c.at) : '';
17
+ return t ? `${head} · last turn ${t}` : head;
18
+ }
19
+ /** The pie, or '' under 50% or with no window. */
20
+ export function wedgeHtml(c) {
21
+ if (!c || c.pct == null || c.pct < 50) return '';
22
+ const say = `Context ${c.pct}% full: ${ctxLine(c)}`;
23
+ // the fill is a class in 5-point steps (cozy.css .cz-ctx.p50 … .p100): no inline style (conformance R28-1)
24
+ const step = Math.min(100, Math.floor(c.pct / 5) * 5);
25
+ return `<span class="cz-ctx p${step}${c.level === 'warn' || c.level === 'crit' ? ' ' + c.level : ''}" role="img" aria-label="${esc(say)}" title="${esc(ctxLine(c))}"></span>`;
26
+ }
27
+ /* ✕ on the proposal (and ✓, until the compact lands) hides it until the session is 10 points fuller; a pie that shrank starts again.
28
+ * Kept in this browser only. */
29
+ const HID = 'cz-ctx-x:';
30
+ const hidAt = (sid) => { try { const v = Number(localStorage.getItem(HID + sid)); return v > 0 ? v : 0; } catch { return 0; } };
31
+ export function hideOffer(sid, pct) { try { localStorage.setItem(HID + sid, String(pct || 0)); } catch { /* a private window: it shows again */ } }
32
+ /** Claude proposes to compact it: the words of the ✦ line, else null. `closes`: the row already proposes closing (item 7), which wins. */
33
+ export function compactOffer(c, closes = false, sid = '') {
34
+ if (closes || !c || c.advise !== 'compact') return null;
35
+ const h = sid ? hidAt(sid) : 0;
36
+ if (h && c.pct < h) { try { localStorage.removeItem(HID + sid); } catch { /* nothing kept */ } } // it shrank: it was compacted, start again
37
+ else if (h && c.pct < h + 10) return null;
38
+ return c.pct >= 90 ? `${c.pct}% full. Compact now, or new turns may lose the start of this chat` : `${c.pct}% full. Compact it before the next task`;
39
+ }
40
+ /** The ✓ that accepts it: types /compact into that session (POST /api/session/compact). */
41
+ export function compactBtnHtml(sid, pct) {
42
+ const say = `Compact this session; Claude says its context is ${pct}% full`;
43
+ // the same ✓ as item 7's close (.hm-cls): one look for "accept what Claude proposes" on a row
44
+ return `<button type="button" class="ut-ib hv-ib hm-cls" data-hm-compact="${esc(sid)}" aria-label="${esc(say)}" title="Compact this session (types /compact)"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12l5 5 9-10"/></svg></button>`;
45
+ }
@@ -0,0 +1,82 @@
1
+ /* hi-pop.css — the initiative's popovers, menus and the toast with Undo (pm/hi-pop.js), the same on Home and the Board (feedback batch 14
2
+ * item 5). Moved out of home-ini.css, which Home loads after this sheet, so Home's phone rules still win. Every class starts with hi-. */
3
+ /* buttons, as the canvas draws them */
4
+ .hi-btn { height: 36px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13.5px; font-weight: 700; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); white-space: nowrap; cursor: pointer; }
5
+ .hi-btn svg { flex: none; }
6
+ .hi-btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
7
+ .hi-btn.dark { background: var(--cz-ink); border-color: transparent; color: var(--cz-card); }
8
+ .hi-btn.ghost { border-color: transparent; background: transparent; color: var(--cz-ink2); }
9
+ .hi-btn.ghost:hover { background: var(--cz-well); }
10
+ .hi-btn:disabled { opacity: .45; cursor: default; }
11
+ .hi-ib { width: 32px; height: 32px; border-radius: 999px; display: inline-grid; place-items: center; flex: none; padding: 0; border: 0; background: none; color: var(--cz-ink2); cursor: pointer; }
12
+ .hi-ib:hover { background: var(--cz-well2); }
13
+ .hi-ib.solid { background: var(--cz-ink); color: var(--cz-card); }
14
+ .hi-ib.sm { width: 28px; height: 28px; }
15
+ /* ── the popovers: Move anyway, Back, the menus ── */
16
+ .hi-pop { position: fixed; z-index: 90; left: var(--hi-x, 24px); top: var(--hi-y, 24px); width: 360px; max-width: calc(100vw - 24px); box-sizing: border-box; background: var(--cz-card); color: var(--cz-ink); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 10px; font-family: var(--cz-sans); font-size: 14px; box-shadow: 0 24px 60px -24px rgba(42,46,53,.45), 0 0 0 1px var(--cz-hair); }
17
+ .hi-pop.menu { width: 290px; padding: 8px; gap: 2px; }
18
+ .hi-pop.sheet { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; border-radius: 28px 28px 0 0; padding: 10px 16px 28px; box-shadow: 0 -20px 50px -20px rgba(42,46,53,.35); }
19
+ .hi-pop.sheet .hi-btn { height: 48px; justify-content: center; }
20
+ .hi-pop.sheet .hi-acts { flex-direction: column; align-items: stretch; }
21
+ .hi-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--cz-c-d9dce1); align-self: center; margin-bottom: 4px; }
22
+ .hi-scrim { position: fixed; inset: 0; z-index: 89; background: rgba(42,46,53,.18); }
23
+ .hi-pop p { margin: 0; }
24
+ .hi-h3 { font-size: 15px; font-weight: 800; }
25
+ .hi-lbl { margin: 0; font-size: 12px; font-weight: 800; color: var(--cz-ink3); }
26
+ .hi-small { margin: 0; font-size: 12.5px; color: var(--cz-ink3); }
27
+ .hi-warn { background: var(--cz-riskbg); color: var(--cz-risk); border-radius: 14px; padding: 12px 14px; font-size: 12.5px; }
28
+ .hi-field { display: flex; flex-direction: column; gap: 6px; }
29
+ .hi-field > span { font-size: 12.5px; font-weight: 800; color: var(--cz-ink2); }
30
+ .hi-field em { font-style: normal; font-weight: 600; color: var(--cz-ink3); }
31
+ .hi-field input, .hi-field textarea { box-sizing: border-box; width: 100%; border: 0; border-radius: 14px; background: var(--cz-well); color: var(--cz-ink); font: inherit; font-size: 14px; padding: 10px 14px; outline: 0; }
32
+ .hi-field input { height: 42px; }
33
+ .hi-field textarea { min-height: 56px; resize: vertical; }
34
+ .hi-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
35
+ .hi-chips { display: flex; flex-wrap: wrap; gap: 6px; }
36
+ .hi-chips .cz-chip[aria-pressed="true"] { background: var(--cz-bluebg); border-color: transparent; color: var(--cz-blueink); }
37
+ .hi-cks { display: flex; flex-direction: column; gap: 4px; }
38
+ .hi-pop:not(.sheet) .hi-cks { display: none; } /* the card shows the items; the phone's sheet repeats them (InPhone) */
39
+ .hi-ck { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cz-ink2); padding: 2px 0; }
40
+ .hi-ck i { width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--cz-c-c5c9d0); box-sizing: border-box; display: inline-grid; place-items: center; flex: none; color: var(--cz-card); }
41
+ .hi-ck.on i { background: var(--cz-ink); border-color: var(--cz-ink); }
42
+ .hi-mlbl { margin: 0; font-size: 12px; font-weight: 800; color: var(--cz-ink3); padding: 8px 12px 4px; }
43
+ .hi-hr { height: 1px; background: var(--cz-hair); margin: 4px 0; }
44
+ .hi-mi { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 12px; font: inherit; font-size: 14px; font-weight: 600; color: var(--cz-ink); width: 100%; border: 0; background: none; cursor: pointer; text-align: left; }
45
+ .hi-mi:hover, .hi-mi.on { background: var(--cz-well); }
46
+ .hi-mi span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
47
+ .hi-mi em { font-style: normal; margin-left: auto; font-size: 12px; color: var(--cz-ink3); font-weight: 600; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
48
+ .hi-mi:disabled { opacity: .45; cursor: default; }
49
+ .hi-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
50
+
51
+ /* the toast with Undo: info, so it does not move */
52
+ .hi-toast { position: fixed; z-index: 95; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--cz-ink); color: var(--cz-card); font-family: var(--cz-sans); font-size: 13px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); max-width: calc(100vw - 32px); }
53
+ .hi-toast[hidden] { display: none; }
54
+ .hi-toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
55
+ .hi-toast button { height: 32px; padding: 0 12px; border-radius: 999px; border: 0; background: rgba(255,255,255,.14); color: inherit; font: inherit; font-weight: 700; cursor: pointer; flex: none; }
56
+ .hi-pop.wide:not(.sheet) { width: 560px; }
57
+ .hi-pop.menu .hi-mi .wfi { margin-left: -2px; }
58
+ .hi-wfpad { padding: 4px 12px 6px; }
59
+ .hi-wfchain { line-height: 1.5; }
60
+ .hi-mut { color: var(--cz-ink3); }
61
+ .hi-wfh { display: flex; align-items: center; gap: 8px; }
62
+ .hi-wfh .hi-h3 { flex: 1; min-width: 0; }
63
+ .hi-wfrows { display: flex; flex-direction: column; }
64
+ .hi-wfrow { display: grid; grid-template-columns: minmax(0, 130px) 14px minmax(0, 130px) minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--cz-hair); font-size: 13.5px; }
65
+ .hi-wfrow:first-child { border-top: 0; }
66
+ .hi-wfrow span { min-width: 0; }
67
+ .hi-wfrow em { display: block; font-style: normal; font-size: 12px; color: var(--cz-ink3); }
68
+ .hi-wfland { display: flex; align-items: center; gap: 8px; }
69
+ .hi-wfland span { flex: 1; }
70
+ .hi-wfland select { font: inherit; font-size: 13px; font-weight: 700; color: var(--cz-ink); background: var(--cz-well); border: 0; border-radius: 10px; padding: 6px 10px; max-width: 60%; }
71
+ .hi-end { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--cz-well); font-size: 13px; }
72
+ .hi-end p { margin: 0; flex: 1; min-width: 0; color: var(--cz-ink2); }
73
+ .hi-endi { display: inline-flex; color: var(--cz-ink3); }
74
+ @media (max-width: 760px) {
75
+ .hi-wfrow { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); }
76
+ .hi-wfrow > .hi-small { grid-column: 1 / -1; }
77
+ .hi-end { flex-wrap: wrap; }
78
+ }
79
+ .hi-pop .wfi { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 6px; background: var(--cz-well); color: var(--cz-ink2); }
80
+ .hi-pop .wfi svg { width: 70%; height: 70%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
81
+ /* a small form in the Viewer (the Board's Add a stakeholder) */
82
+ .hi-form { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 24px; font-size: 14px; color: var(--cz-ink); }
@@ -0,0 +1,65 @@
1
+ /* pm/hi-pop.js — the initiative's small popovers and the toast with Undo, the same on Home and the Board (feedback batch 14 item 5).
2
+ * Home's initiative page drew them first (home-ini.js); the one ⋯ menu (pm/ini-more.js) opens them on the Board too, so they live here.
3
+ *
4
+ * ensureCss() adds hi-pop.css once, before home-ini.css, so Home's phone rules still win
5
+ * openPop(anchor, kind, html, onClick, o?) a dialog (or o.menu: a menu) under the button that opened it; a sheet on a phone.
6
+ * o: { menu, wide, role, label, focus, sheetFocus }. → the popover element
7
+ * closePop() · popEl() the open popover, or null
8
+ * undoToast(text, undo) the dark toast with Undo, for 9 seconds */
9
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
10
+ const PHONE = 760;
11
+ const isPhone = () => innerWidth <= PHONE;
12
+ const P = { pop: null, toastT: 0 };
13
+
14
+ export function ensureCss() {
15
+ if (typeof document === 'undefined' || document.querySelector('link[data-hi-pop-css]')) return;
16
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./hi-pop.css', import.meta.url).href; l.dataset.hiPopCss = '';
17
+ const home = document.querySelector('link[data-hi-css]');
18
+ if (home) home.before(l); else document.head.appendChild(l);
19
+ }
20
+ export const popEl = () => (P.pop ? P.pop.el : null);
21
+ export function closePop() {
22
+ if (!P.pop) return;
23
+ const a = P.pop.anchor; P.pop.el.remove(); if (P.pop.scrim) P.pop.scrim.remove(); P.pop = null;
24
+ if (a && a.isConnected) { a.setAttribute('aria-expanded', 'false'); try { a.focus(); } catch { /* gone */ } }
25
+ }
26
+ export function openPop(anchor, kind, html, onClick, o = {}) {
27
+ ensureCss();
28
+ closePop();
29
+ const el = document.createElement('div');
30
+ const sheet = isPhone() && !o.menu;
31
+ el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '') + (o.wide ? ' wide' : '');
32
+ el.setAttribute('role', o.role || (o.menu ? 'menu' : 'dialog')); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
33
+ el.innerHTML = (sheet ? '<div class="hi-grab" aria-hidden="true"></div>' : '') + html;
34
+ let scrim = null;
35
+ if (sheet) { scrim = document.createElement('div'); scrim.className = 'hi-scrim'; scrim.onclick = closePop; document.body.appendChild(scrim); }
36
+ document.body.appendChild(el);
37
+ if (!sheet) { // under the button that opened it, kept inside the window: run-time geometry, set as two custom properties
38
+ const r = anchor.getBoundingClientRect(), w = el.offsetWidth, hh = el.offsetHeight;
39
+ const col = !o.menu && anchor.closest('#hmList'); // a dialog from the list column opens beside the column (InStage), not over it
40
+ let x, y;
41
+ if (col) { const c = col.getBoundingClientRect(); x = c.right + 12; y = Math.min(innerHeight - hh - 12, Math.max(12, r.top - 60)); }
42
+ else { x = r.left + w > innerWidth - 12 ? r.right - w : r.left; y = r.bottom + 8 + hh > innerHeight - 12 ? r.top - hh - 8 : r.bottom + 8; }
43
+ x = Math.max(12, Math.min(innerWidth - w - 12, x)); y = Math.max(12, y);
44
+ el.style.setProperty('--hi-x', Math.round(x) + 'px'); el.style.setProperty('--hi-y', Math.round(y) + 'px');
45
+ }
46
+ anchor.setAttribute('aria-expanded', 'true');
47
+ P.pop = { el, scrim, anchor, kind };
48
+ el.addEventListener('click', (e) => { const b = e.target.closest('button'); if (b && !b.disabled) onClick(b, el); });
49
+ el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); closePop(); } });
50
+ const f = el.querySelector((sheet && o.sheetFocus) || o.focus || 'input, textarea, button:not([disabled])'); if (f) setTimeout(() => f.focus(), 0);
51
+ return el;
52
+ }
53
+ export function undoToast(text, undo) {
54
+ ensureCss();
55
+ let el = document.getElementById('hiToast');
56
+ if (!el) { el = document.createElement('div'); el.id = 'hiToast'; el.className = 'hi-toast'; el.setAttribute('role', 'status'); el.setAttribute('aria-live', 'polite'); document.body.appendChild(el); }
57
+ el.innerHTML = `<span>${esc(text)}</span><button type="button" data-hi-undo>Undo</button>`;
58
+ el.hidden = false; el.classList.add('on');
59
+ el.querySelector('[data-hi-undo]').onclick = () => { hide(); undo(); };
60
+ const hide = () => { el.classList.remove('on'); el.hidden = true; };
61
+ clearTimeout(P.toastT); P.toastT = setTimeout(hide, 9000);
62
+ }
63
+ // Escape closes the popover first: on window in the capture phase, so the page's own Escape (the phone's list sheet, the Viewer) waits for the next press
64
+ if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && P.pop) { e.stopPropagation(); e.preventDefault(); closePop(); } }, true);
65
+ if (typeof document !== 'undefined') document.addEventListener('mousedown', (e) => { if (P.pop && !P.pop.el.contains(e.target) && !(P.pop.anchor && P.pop.anchor.contains(e.target)) && !(P.pop.scrim && P.pop.scrim === e.target)) closePop(); }, true);