create-pmos 0.427.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 (63) hide show
  1. package/package.json +13 -13
  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 +12 -0
  10. package/workspace/guide/briefing-premium.md +4 -2
  11. package/workspace/guide/home.md +32 -7
  12. package/workspace/guide/programs.md +1 -0
  13. package/workspace/home-other-product-test.js +12 -2
  14. package/workspace/lib/routes-meeting-material.js +22 -1
  15. package/workspace/lib/settings-store.js +14 -0
  16. package/workspace/milestone-pins-test.js +13 -0
  17. package/workspace/milestone-suggest-test.js +10 -4
  18. package/workspace/package-lock.json +2 -2
  19. package/workspace/package.json +1 -1
  20. package/workspace/premium-board-actions-test.js +40 -13
  21. package/workspace/premium-rec-tab-test.js +8 -0
  22. package/workspace/premium-vw-item-test.js +7 -3
  23. package/workspace/premium-vw-jira-test.js +2 -1
  24. package/workspace/program-charter-test.js +1 -1
  25. package/workspace/program-leave-test.js +2 -2
  26. package/workspace/program-order-test.js +3 -2
  27. package/workspace/program-panel-test.js +2 -1
  28. package/workspace/public/pm/bd-acts.js +20 -26
  29. package/workspace/public/pm/bd-ini-panel.js +90 -32
  30. package/workspace/public/pm/bd-pin-card.js +4 -1
  31. package/workspace/public/pm/bd-span.js +22 -12
  32. package/workspace/public/pm/cozy-rec-tab.js +12 -3
  33. package/workspace/public/pm/cozy-viewer.js +157 -23
  34. package/workspace/public/pm/cozy-vw-shell.css +13 -0
  35. package/workspace/public/pm/hi-pop.css +82 -0
  36. package/workspace/public/pm/hi-pop.js +65 -0
  37. package/workspace/public/pm/home-app.js +55 -26
  38. package/workspace/public/pm/home-ini.css +6 -76
  39. package/workspace/public/pm/home-ini.js +50 -68
  40. package/workspace/public/pm/home-list.js +29 -3
  41. package/workspace/public/pm/home-today.js +18 -7
  42. package/workspace/public/pm/ini-more.js +67 -0
  43. package/workspace/public/pm/ini-view-model.js +3 -2
  44. package/workspace/public/pm/ini-view.css +3 -1
  45. package/workspace/public/pm/ini-view.js +7 -5
  46. package/workspace/public/pm/order-model.js +85 -0
  47. package/workspace/public/pm/premium-board.js +57 -11
  48. package/workspace/public/pm/premium-insights.js +11 -1
  49. package/workspace/public/pm/premium-vw-item.js +3 -1
  50. package/workspace/public/pm/premium-vw-jira.js +2 -0
  51. package/workspace/public/pm/prog-order.js +15 -2
  52. package/workspace/public/pm/sort-order.css +17 -0
  53. package/workspace/public/pm/sort-order.js +108 -0
  54. package/workspace/public/pm/tk-view.js +3 -2
  55. package/workspace/public/pm/wf-page.js +1 -1
  56. package/workspace/public/premium-board.html +1 -0
  57. package/workspace/sort-order-test.js +201 -0
  58. package/workspace/stage-card-test.js +1 -0
  59. package/workspace/task-card-test.js +1 -1
  60. package/workspace/test-lists/sort-order.json +6 -0
  61. package/workspace/test-lists/viewer-trail.json +5 -0
  62. package/workspace/tk-tasks-test.js +5 -3
  63. package/workspace/viewer-trail-test.js +145 -0
@@ -27,7 +27,10 @@ function cardHtml(r, msId) {
27
27
  if (!L.length) return `<p class="bd-pc-h">${esc(r.title)}</p><p class="bd-amut bd-pc-sub">No milestone yet. Flag a task as a milestone ◇ in the initiative's Tasks.</p>`;
28
28
  const m0 = L.find((m) => m.id === msId) || null, on = shownMs(r).length;
29
29
  const head = m0 ? `<p class="bd-pc-h">${esc(m0.name)}</p><p class="bd-amut bd-pc-sub">${esc(when(m0.date))} · ${on} of ${L.length} ${L.length === 1 ? 'milestone' : 'milestones'} on the timeline</p>`
30
- : `<p class="bd-pc-h">${esc(r.title)}</p><p class="bd-amut bd-pc-sub">${on} of ${L.length} ${L.length === 1 ? 'milestone' : 'milestones'} on the timeline</p>`;
30
+ : r.end && /^\d{4}-\d{2}-\d{2}/.test(String(r.end))
31
+ // the row's plain end ◇ (no milestone task stands for it): the card says what the row's label says, "Deliver Jun 9 ’27" (batch 14 item 1)
32
+ ? `<p class="bd-pc-h">${esc(r.track && r.track.k >= 6 ? 'Evaluate' : 'Deliver')} ${esc(when(String(r.end).slice(0, 10)))}</p><p class="bd-amut bd-pc-sub">The end of ${esc(r.title)} · ${on} of ${L.length} ${L.length === 1 ? 'milestone' : 'milestones'} on the timeline</p>`
33
+ : `<p class="bd-pc-h">${esc(r.title)}</p><p class="bd-amut bd-pc-sub">${on} of ${L.length} ${L.length === 1 ? 'milestone' : 'milestones'} on the timeline</p>`;
31
34
  const row = (m) => {
32
35
  const p = isPinned(r, m), late = !m.done && m.date < today;
33
36
  const say = (p ? 'Shown on the timeline: ' : 'Show on the timeline: ') + m.name;
@@ -209,9 +209,11 @@ function qBar(r, X, now, phone, fmt, pxPct, ms = {}) {
209
209
  const sw = slipWords(r, e); if (sw) hover.push(sw);
210
210
  // the committed end is the ◇ (PgTimeline); a milestone task in the stage it stands for IS that ◇ (say it once, batch 11 item 3): its name and its done
211
211
  const isLate = !!(over || clash || r.late || (et && msLate(et, now)));
212
- const name = landsOf(r, et), eTitle = name + ' · ' + md(e) + (et && et.stage ? ' · ◆ ' + et.stage : '') + (et && et.done ? ' · done' : isLate ? ' · late' : '');
213
- out += `<button type="button" class="tg-end${et && et.done ? ' dn' : ''}${isLate ? ' late' : ''}" data-ms-pick="${esc(r.key)}" data-ms-id="${esc(et ? et.id : '')}" style="left:${P(X(e))}" aria-haspopup="dialog" aria-label="${esc(eTitle + '. Milestones of ' + r.title)}" title="${esc(eTitle + (clash ? '. ' + clash : ''))}"></button>`;
214
- out += endLabel(Math.max(X(e), over ? X(now) : 0, late ? X(fc) : 0), name, e, isLate ? 'late' : risk, now, pxPct, hover, slipHtml(r));
212
+ // the ◇ and its label carry the milestone's own date; the initiative's end, when it differs, is the hover (batch 14 item 1)
213
+ const ed = et ? day(et.date) : e; if (+ed !== +e) hover.push('Initiative ends ' + dy(e, now));
214
+ const name = landsOf(r, et), eTitle = name + ' · ' + md(ed) + (et && et.stage ? ' · ◆ ' + et.stage : '') + (et && et.done ? ' · done' : isLate ? ' · late' : '');
215
+ out += `<button type="button" class="tg-end${et && et.done ? ' dn' : ''}${isLate ? ' late' : ''}" data-ms-pick="${esc(r.key)}" data-ms-id="${esc(et ? et.id : '')}" style="left:${P(X(ed))}" aria-haspopup="dialog" aria-label="${esc(eTitle + '. Milestones of ' + r.title)}" title="${esc(eTitle + (clash ? '. ' + clash : ''))}"></button>`;
216
+ out += endLabel(Math.max(X(e), X(ed), over ? X(now) : 0, late ? X(fc) : 0), name, ed, isLate ? 'late' : risk, now, pxPct, hover, slipHtml(r));
215
217
  } else if (fc) {
216
218
  out += `<span class="tg-fc solo" style="left:${P(X(fc))};width:12px;margin-left:-12px" title="Jira forecast ${esc(md(fc))}"></span>` + endLabel(X(fc), 'Jira forecast', fc, '', now, pxPct, [], '');
217
219
  } else if (r.draft && day(r.draft.start)) {
@@ -326,12 +328,15 @@ const lastMs = (r) => { const S = (r.wfStages || []).filter((x) => x && x.milest
326
328
  /** The ◆ stage a milestone task sits in, by name, or ''. */
327
329
  const msStage = (r, m) => { if (!m.sec) return ''; const st = (r.wfStages || []).find((x) => x.key === m.sec); return st ? (st.milestone ? st.name : '') : /^(deliver|evaluate)$/i.test(m.sec) ? m.sec.replace(/^./, (c) => c.toUpperCase()) : ''; };
328
330
  /** The milestone task the bar's end ◇ stands for, or null. The end ◇ is the workflow's last ◆ stage (Evaluate on Product feature): the latest
329
- * milestone task in that stage IS it, else one on the end's own day; it takes that task's name and done, and is not drawn twice. A task in an
330
- * earlier ◆ stage keeps its own ◇. M: the row's dated milestones. */
331
+ * milestone task in that stage IS it, else one on the end's own day, else the latest task in any ◆ stage (Deliver: batch 14 item 1, so a
332
+ * "rolled out" task in Deliver names the row's end). It takes that task's name, date and done, and is not drawn twice. A task outside the ◆
333
+ * stages keeps its own ◇. M: the row's dated milestones. */
331
334
  function endTask(r, M) {
332
- const e = day(r.end); if (!e) return null;
333
- const last = lastMs(r), inLast = M.filter((m) => m.sec && m.sec.toLowerCase() === last);
334
- const end = inLast.length ? inLast[inLast.length - 1] : M.find((m) => +day(m.date) === +e) || null;
335
+ const e = day(r.end); if (!e || !M.length) return null;
336
+ const S = M.slice().sort((a, b) => day(a.date) - day(b.date));
337
+ const last = lastMs(r), inLast = S.filter((m) => m.sec && m.sec.toLowerCase() === last);
338
+ const inMs = S.filter((m) => msStage(r, m));
339
+ const end = inLast.length ? inLast[inLast.length - 1] : S.find((m) => +day(m.date) === +e) || inMs[inMs.length - 1];
335
340
  return end ? { ...end, stage: msStage(r, end) } : null;
336
341
  }
337
342
  /** One ◇ per milestone task the Filter shows (batch 13 item 4, XcalmA5Milestones; pm/bd-pins.js shownMs: the pinned ones, by default the last),
@@ -368,7 +373,7 @@ export function laneMilestones(rows, now) {
368
373
  for (const m of M) if (!et || m.id !== et.id) out.push({ id: m.id, name: m.name, date: m.date, done: !!m.done, late: msLate(m, now), row: r });
369
374
  if (!s || !e) continue;
370
375
  const ob = openBack(r, now), late = (r.over && now > e) || (ob && ob > e) || (et && msLate(et, now));
371
- out.push({ id: et ? et.id : '', name: et ? et.name : r.track && r.track.k >= 6 ? 'Evaluate' : 'Deliver', date: iso(e), done: !!(et && et.done), late: !!late, row: r });
376
+ out.push({ id: et ? et.id : '', name: et ? et.name : r.track && r.track.k >= 6 ? 'Evaluate' : 'Deliver', date: et ? String(et.date).slice(0, 10) : iso(e), done: !!(et && et.done), late: !!late, row: r });
372
377
  }
373
378
  return out.sort((a, b) => day(a.date) - day(b.date));
374
379
  }
@@ -492,11 +497,16 @@ function scaled(rows, M, o) {
492
497
  // program's initiatives were missing from their product on the timeline)
493
498
  // By product, a program's undated initiative keeps its "No dates" row under its product too (batch 11 item 19: they disappeared once grouped by product)
494
499
  const onList = new Set(list.map((r) => r.key));
500
+ // a product with no dated initiative keeps its head and its initiatives as "No dates" rows, so the product is not missing from the Board
501
+ // (batch 14 item 2: pmos-microsites, all undated outside its program, had no group at all); those rows leave the foot's names
502
+ const keepOf = (R) => { const k = R.filter((r) => onList.has(r.key) || r.inProgram); return k.length ? k : R.slice(); };
503
+ const shownNd = new Set(o.groups ? o.groups.filter((g) => g.kind !== 'program' && !g.rows.some((r) => onList.has(r.key) || r.inProgram)).flatMap((g) => g.rows.map((r) => r.key)) : []);
504
+ const footNone = none.filter((r) => !shownNd.has(r.key));
495
505
  // a timeline reads in time (batch 11 item 22): each group's rows by start, then end; undated ones last. The health dot still says late or at risk
496
506
  const at = (r) => { const x = extentOf(r, now); return x ? [+x.a, +x.b] : [Infinity, Infinity]; };
497
507
  const byTime = (L) => L.map((r) => [at(r), r]).sort((p, q) => p[0][0] - q[0][0] || p[0][1] - q[0][1]).map((x) => x[1]);
498
508
  list.splice(0, list.length, ...byTime(list));
499
- const G = o.groups ? o.groups.map((g) => (g.kind === 'program' ? { ...g, products: g.products.filter((x) => x.rows.length).map((x) => ({ ...x, rows: byTime(x.rows) })) } : { ...g, rows: byTime(g.rows.filter((r) => onList.has(r.key) || r.inProgram)) })).filter((g) => g.rows.length || g.kind === 'program') : null;
509
+ const G = o.groups ? o.groups.map((g) => (g.kind === 'program' ? { ...g, products: g.products.filter((x) => x.rows.length).map((x) => ({ ...x, rows: byTime(x.rows) })) } : { ...g, rows: byTime(keepOf(g.rows)) })).filter((g) => g.rows.length || g.kind === 'program') : null;
500
510
  const empty = '<p class="tg-empty">No initiative on screen has a date on record.</p>';
501
511
  const ext = (r) => { const x = extentOf(r, now); return x ? ` data-a="${X(x.a).toFixed(3)}" data-b="${X(x.b).toFixed(3)}"` : ''; };
502
512
  // a product's head carries its lane from Quarter on (batch 11 item 17); Sprint on a phone, and a page that gives no head cell, keep the plain head
@@ -510,7 +520,7 @@ function scaled(rows, M, o) {
510
520
  return `<div class="tgq-r tg-pg${shut ? ' closed' : ''}" data-prow="${esc(g.program.id)}"><div class="tgq-n tg-pgn">${progName(g, st, o, shut ? offDots(g.rows, now) : '')}</div><div class="tg-p">${ov}${tr}</div></div>` + (shut ? '' : g.products.map((x) => x.rows.map(one).join('')).join(''));
511
521
  }).join('') : list.map(one).join('');
512
522
  const top = `<div class="tgq-h"><div class="tg-p">${ticks}${pill}</div></div>`;
513
- const below = none.length ? `<div class="tg-none"><span>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates</span>${askBtn}</div>` : '';
523
+ const below = none.length ? `<div class="tg-none">${footNone.length ? `<span>${footNone.length} ${footNone.length === 1 ? 'has' : 'have'} no dates</span>` : ''}${askBtn}</div>` : '';
514
524
  // the Deliveries lane (batch 13 item 4, XcalmA6Phone): a phone shows the next deliveries above the rows (o.lane draws it; none: nothing)
515
525
  const lanePh = o.lane ? o.lane({ W, X, rows: list, groups: G, now, phone: true, pxPct }) || '' : '';
516
526
  return { html: lanePh + `<div class="tg tg-s tgq" ${attrs}><div class="tg-scw"><div class="tg-sc" tabindex="0" role="group" aria-label="Timeline" style="${style}"><div class="tg-in">${top}<div class="tg-body">${body || empty}</div></div></div>${back}<i class="tg-fade l" aria-hidden="true"></i><i class="tg-fade r" aria-hidden="true"></i></div></div>${below}`, none };
@@ -529,7 +539,7 @@ function scaled(rows, M, o) {
529
539
  // the sprint band and the release keep their labels under the axis on Quarter, where a week is wide enough to read them
530
540
  const axl = sp === 'quarter' ? `${sa && sb && sb > W.from && sa < W.to ? `<span class="tg-axl sb" style="left:${P(X(sa))}">Jira ${esc(sprint.name.toLowerCase())} · ${esc(md(sa))} – ${esc(md(sb))}</span>` : ''}${ra && ra > W.from && ra < W.to ? `<span class="tg-axl rl" style="left:${P(X(ra))}">${SV(FLAG)}${esc(rel.name)} · ${esc(md(ra))}</span>` : ''}` : '';
531
541
  const axis = axl ? `<div class="tg-ax"><span class="tg-n"></span><div class="tg-p">${axl}</div></div>` : '';
532
- const foot = none.length ? `<div class="tg-ft">${none.length ? `<span class="tg-none"><b>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates:</b> <span>${esc(none.slice(0, 4).map((r) => r.title).join(', '))}${none.length > 4 ? ' and ' + (none.length - 4) + ' more' : ''}</span>${askBtn}</span>` : '<span></span>'}</div>` : '';
542
+ const foot = none.length ? `<div class="tg-ft">${footNone.length ? `<span class="tg-none"><b>${footNone.length} ${footNone.length === 1 ? 'has' : 'have'} no dates:</b> <span>${esc(footNone.slice(0, 4).map((r) => r.title).join(', '))}${footNone.length > 4 ? ' and ' + (footNone.length - 4) + ' more' : ''}</span>${askBtn}</span>` : `<span class="tg-none">${askBtn}</span>`}</div>` : '';
533
543
  // the Deliveries lane (batch 13 item 4, XcalmA6Lane): one row under the axis, a list per column (o.lane draws it; none: nothing)
534
544
  const laneH = o.lane ? o.lane({ W, X, rows: list, groups: G, now, phone: false, pxPct }) || '' : '';
535
545
  return { html: `<div class="tg tg-q tg-s" ${attrs}><div class="tg-scw"><div class="tg-sc" tabindex="0" role="group" aria-label="Timeline" style="${style}"><div class="tg-in">${head}${laneH}<div class="tg-body">${body || empty}</div>${axis}</div></div><i class="tg-fade l" aria-hidden="true"></i><i class="tg-fade r" aria-hidden="true"></i></div>${foot}</div>`, none };
@@ -41,6 +41,8 @@ const P = { star: '<path d="M12 3.8l2.5 5.2 5.7.8-4.1 4 1 5.7L12 16.8l-5.1 2.7 1
41
41
  const svg = (k, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24">${P[k]}</svg>`;
42
42
  const btn = (a, label, icon, cls = '') => `<button type="button" class="rt-b${cls ? ' ' + cls : ''}" data-a="${a}" aria-label="${esc(label)}" title="${esc(label)}">${svg(icon, a === 'stop' ? 20 : 18)}</button>`;
43
43
 
44
+ const BUSY_MS = 30000; // the longest a press waits for its answer
45
+ let READING = false; // one read at a time
44
46
  const S = { row: null, one: null, focus: null, readAt: Date.now(), mode: 'idle', ask: null, msg: '', busy: false, video: null, on: { note: new Set(), mode: new Set(), tick: new Set() } };
45
47
  const fire = (k, v) => { for (const fn of S.on[k]) { try { fn(v); } catch { /* the slot's own */ } } };
46
48
  const note = () => (S.one && S.one.note) || null;
@@ -164,7 +166,13 @@ async function readFocus() {
164
166
  /* ── the presses ───────────────────────────────────────────────────────────────────────────────────────── */
165
167
  async function act(a, t) {
166
168
  if (S.busy && a !== 'askno') return;
167
- const run = async (fn) => { S.busy = true; if (t) t.disabled = true; try { await fn(); } finally { S.busy = false; await read(); } };
169
+ // a press that gets no answer gives up after BUSY_MS, so the buttons come back (Wawan, 2026-10-27: a stuck press froze the tab)
170
+ const run = async (fn) => {
171
+ S.busy = true; if (t) t.disabled = true;
172
+ let late = null;
173
+ try { await Promise.race([fn(), new Promise((ok) => { late = setTimeout(() => { S.msg = 'That took too long. Try again.'; ok(); }, window.__rtBusyMs || BUSY_MS); })]); }
174
+ finally { clearTimeout(late); S.busy = false; if (t) t.disabled = false; await read(); }
175
+ };
168
176
  switch (a) {
169
177
  case 'hl': { const r = await C.highlight(); S.msg = r.ok ? 'Keeping the last 30 seconds and the next ones as a highlight.' : r.error; return draw(); }
170
178
  case 'pause': return run(async () => { const r = await C.pause(); S.msg = r.ok ? '' : r.error; });
@@ -213,7 +221,8 @@ else {
213
221
  if (S.row && S.row.state !== 'recording' && S.row.state !== 'ended') act('start');
214
222
  }
215
223
  });
216
- setInterval(() => { if (!S.busy) { tick(); drawAlert(); drawLine(); beat(); } }, 1000); // beat(): a change (Not hearing the meeting) reaches the snippets within a second
217
- setInterval(() => { if (!S.busy) read(); beat(true); }, 5000);
224
+ // the clock, the line and the transcript never wait on a press: a press that hangs must not freeze the meeting (Wawan, 2026-10-27)
225
+ setInterval(() => { tick(); drawAlert(); drawLine(); beat(); }, 1000); // beat(): a change (Not hearing the meeting) reaches the snippets within a second
226
+ setInterval(() => { if (!READING) { READING = true; read().catch(() => {}).finally(() => { READING = false; }); } beat(true); }, 5000);
218
227
  setInterval(readFocus, 15000);
219
228
  }
@@ -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; }
@@ -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); }