create-pmos 0.401.0 → 0.403.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 (127) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +227 -0
  8. package/workspace/board-shot.js +54 -0
  9. package/workspace/briefing-premium-adddoc-test.js +28 -22
  10. package/workspace/briefing-premium-board-test.js +107 -82
  11. package/workspace/briefing-premium-calendar-2-test.js +23 -10
  12. package/workspace/briefing-premium-calendar-3-test.js +23 -19
  13. package/workspace/briefing-premium-calendar-test.js +20 -15
  14. package/workspace/briefing-premium-initiative-test.js +25 -12
  15. package/workspace/briefing-premium-insights-test.js +31 -18
  16. package/workspace/briefing-premium-metrics-test.js +8 -8
  17. package/workspace/briefing-premium-sources-test.js +15 -10
  18. package/workspace/briefing-premium-test.js +39 -16
  19. package/workspace/changelog.json +24 -0
  20. package/workspace/fixtures/board-premium-facts.js +20 -3
  21. package/workspace/fixtures/briefing-premium-facts.js +18 -2
  22. package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
  23. package/workspace/fixtures/program-ascent.js +101 -0
  24. package/workspace/guide/home.md +11 -7
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/guide/jira.md +38 -6
  27. package/workspace/guide/programs.md +37 -0
  28. package/workspace/home-rows-test.js +184 -0
  29. package/workspace/lib/briefing-premium-products.js +4 -4
  30. package/workspace/lib/briefing-premium.js +2 -2
  31. package/workspace/lib/calendar-layers.js +8 -4
  32. package/workspace/lib/initiative-layout.js +4 -3
  33. package/workspace/lib/jira-cli.js +17 -12
  34. package/workspace/lib/jira-status.js +1 -1
  35. package/workspace/lib/jira-tickets.js +126 -24
  36. package/workspace/lib/meeting-files.js +58 -0
  37. package/workspace/lib/meeting-learn.js +139 -0
  38. package/workspace/lib/meeting-material.js +12 -5
  39. package/workspace/lib/notes.js +3 -0
  40. package/workspace/lib/programs.js +129 -0
  41. package/workspace/lib/route-modules.js +1 -0
  42. package/workspace/lib/routes-brief-page.js +8 -1
  43. package/workspace/lib/routes-briefing-premium.js +1 -1
  44. package/workspace/lib/routes-calendar-views.js +24 -3
  45. package/workspace/lib/routes-meeting-material.js +38 -0
  46. package/workspace/lib/routes-meeting-points.js +23 -3
  47. package/workspace/lib/routes-programs.js +122 -0
  48. package/workspace/package-lock.json +2 -2
  49. package/workspace/package.json +1 -1
  50. package/workspace/premium-board-actions-test.js +31 -25
  51. package/workspace/premium-chat-context-test.js +1 -1
  52. package/workspace/premium-chat-goal-view-test.js +1 -1
  53. package/workspace/premium-chat-viewer-test.js +1 -1
  54. package/workspace/premium-core-doc-issue-test.js +13 -7
  55. package/workspace/premium-discuss-landing-test.js +83 -0
  56. package/workspace/premium-link-suggest-test.js +103 -0
  57. package/workspace/premium-report-read-test.js +86 -82
  58. package/workspace/premium-vw-backlog-test.js +6 -5
  59. package/workspace/premium-vw-cal-test.js +45 -19
  60. package/workspace/premium-vw-item-test.js +8 -6
  61. package/workspace/premium-vw-jira-test.js +3 -2
  62. package/workspace/premium-vw-meet-test.js +122 -66
  63. package/workspace/premium-vw-notes-test.js +7 -6
  64. package/workspace/premium-vw-rec-test.js +14 -13
  65. package/workspace/premium-vw-slides-test.js +11 -5
  66. package/workspace/program-panel-test.js +152 -0
  67. package/workspace/public/pm/bd-acts.js +24 -15
  68. package/workspace/public/pm/bd-asks.js +111 -30
  69. package/workspace/public/pm/bd-ini-panel.js +229 -0
  70. package/workspace/public/pm/bd-pop.js +2 -2
  71. package/workspace/public/pm/bd-prog-panel.js +436 -0
  72. package/workspace/public/pm/bd-prog.js +191 -0
  73. package/workspace/public/pm/bd-span.js +98 -15
  74. package/workspace/public/pm/bd-views.js +93 -29
  75. package/workspace/public/pm/cozy-board.css +214 -20
  76. package/workspace/public/pm/cozy-evui.js +4 -2
  77. package/workspace/public/pm/cozy-home-rows.css +54 -0
  78. package/workspace/public/pm/cozy-home.css +35 -0
  79. package/workspace/public/pm/cozy-insights.css +1 -2
  80. package/workspace/public/pm/cozy-mtg-present.css +160 -0
  81. package/workspace/public/pm/cozy-panel.css +155 -0
  82. package/workspace/public/pm/cozy-rec-pill.css +12 -0
  83. package/workspace/public/pm/cozy-rec-pill.js +46 -0
  84. package/workspace/public/pm/cozy-today.css +189 -0
  85. package/workspace/public/pm/cozy-viewer.js +307 -43
  86. package/workspace/public/pm/cozy-vw-mtg.css +96 -94
  87. package/workspace/public/pm/cozy-vw-rp.css +40 -25
  88. package/workspace/public/pm/cozy-vw-shell.css +127 -0
  89. package/workspace/public/pm/cozy-xv.css +51 -0
  90. package/workspace/public/pm/cozy-xv.js +34 -0
  91. package/workspace/public/pm/home-app.js +192 -72
  92. package/workspace/public/pm/home-chat.js +17 -4
  93. package/workspace/public/pm/home-data.js +1 -1
  94. package/workspace/public/pm/home-day.js +64 -0
  95. package/workspace/public/pm/home-ini-model.js +1 -1
  96. package/workspace/public/pm/home-ini.js +197 -54
  97. package/workspace/public/pm/home-list.js +100 -27
  98. package/workspace/public/pm/home-mentions.js +187 -0
  99. package/workspace/public/pm/home-rec-row.js +67 -0
  100. package/workspace/public/pm/home-review.js +20 -10
  101. package/workspace/public/pm/home-task.js +19 -18
  102. package/workspace/public/pm/home-today.js +137 -59
  103. package/workspace/public/pm/premium-board.js +294 -288
  104. package/workspace/public/pm/premium-insights.js +118 -82
  105. package/workspace/public/pm/premium-mtg-present.js +408 -100
  106. package/workspace/public/pm/premium-mtg-replay.js +70 -10
  107. package/workspace/public/pm/premium-report-read.js +118 -63
  108. package/workspace/public/pm/premium-vw-cal.js +62 -34
  109. package/workspace/public/pm/premium-vw-mtg.js +348 -192
  110. package/workspace/public/pm/program-model.js +192 -0
  111. package/workspace/public/pm/rec-state.js +63 -0
  112. package/workspace/public/pm/rp-parts.js +33 -8
  113. package/workspace/public/pm/tk-draft.js +107 -0
  114. package/workspace/public/pm/tk-model.js +134 -0
  115. package/workspace/public/pm/tk-send.js +124 -0
  116. package/workspace/public/pm/tk-tasks.css +120 -0
  117. package/workspace/public/premium-board.html +4 -2
  118. package/workspace/server.js +4 -2
  119. package/workspace/skills/jira-push.skill +3 -3
  120. package/workspace/test-lists/board-programs.json +9 -0
  121. package/workspace/test-lists/prd-to-jira.json +6 -0
  122. package/workspace/test-lists/program-hierarchy.json +11 -0
  123. package/workspace/test-lists/program-panel.json +9 -0
  124. package/workspace/test-lists/viewer-home-rows.json +9 -0
  125. package/workspace/test-lists/viewer-meetings.json +9 -0
  126. package/workspace/test-lists/viewer-shell-a.json +15 -0
  127. package/workspace/tk-tasks-test.js +199 -0
@@ -1,31 +1,45 @@
1
- /* pm/cozy-viewer.js — the Viewer of the Agreed design (initiative premium-agreed-design; Main.dc.html section.viewer, M:897-913).
1
+ /* pm/cozy-viewer.js — the Viewer: one shell, summary first (initiative viewer-shell-a V1, V2; canvas XvOptADoc, XvOptAJira, XvOptAPhone, XvOptBRead).
2
2
  *
3
- * One card shows one item at a time. Opening another item replaces the one shown: there is no strip of tabs, no grey label band,
4
- * no conversation pane and no Detail / Conversation switch. The header is the design's: a 34px icon tile, the kind (12px), the title
5
- * (15px/700), "Open in a new tab" and Close, with a hairline under them.
6
- * Desktop: the card is at most 500px wide. A page that has a place for it marks that element with data-cz-viewer-host, and the card
7
- * goes in it as a flex column beside the chat or the page. With no host, the card floats at the right of the window.
8
- * Phone (760px or less): the card covers the whole screen.
3
+ * One card shows one item at a time. Opening another item replaces the one shown: there is no strip of tabs. The header is shell A's:
4
+ * a 32px icon tile, the title once (16px/800), then the item's presses: Discuss in chat (outside Home only), ⋯ (everything the item can do
5
+ * besides its one primary), ⤢ open wide, and ×. A drill-in (a ticket opened from its initiative) shows ← before the tile, and ← goes back.
6
+ * The kind is no longer drawn (say it once): it stays as words for a screen reader, in the Viewer's name and a hidden line.
7
+ * Desktop: a page that has a place for it marks that element with data-cz-viewer-host, and the card goes in it as a flex column beside
8
+ * the chat. With no host (Board, Insights), the card floats over the right edge of the page and does not push it.
9
+ * Width (the xvWidth note): a grip on the left edge sets it; double-click resets it. PMOS remembers it per kind of item. The default is
10
+ * half the space right of the list, the least is 420 px, and the chat keeps 360 px. Past that the list folds to a rail, so the Viewer
11
+ * can reach about 70% of the window. Under 1100 px the list folds to a rail as soon as the Viewer opens. A Viewer 760 px or wider gets
12
+ * .cz-vw-w2: its summary and contents sit in a column beside the text, which keeps a readable line.
13
+ * Phone (760px or less): the card covers the whole screen, ← takes the place of ×, and there is no grip and no ⤢.
9
14
  *
10
15
  * The API (also on window.czViewer, for scripts that do not import modules):
11
- * open({ kind, title, icon?, url?, render?(body), html?, id?, onClose? }) → the body element the content goes in
12
- * kind the small line over the title, for example "Meeting notes", "Report", "Settings"
13
- * title the item's name
14
- * icon a key of ICONS below (doc, cal, notes, meet, report, chart, jira, goal, gear, source, info, list, mic, slides) or an SVG path "M…"
15
- * url the item's own address; with none, "Open in a new tab" is drawn disabled and says "Not available yet"
16
- * full true: the report panel's header (ReportPanel.dc.html): the kind over a 16px title, and "Open full" (expand arrows) in place of
17
- * "Open in a new tab", hidden on a phone, where only Close shows
18
- * 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.
19
- * id optional; current() returns it, so a caller can tell whether its item is the one shown
16
+ * open({ kind, title, icon?, url?, render?(body), html?, id?, onClose?, more?, discuss?, back?, full? }) → the body element the content goes in
17
+ * kind what the item is, for example "Meeting notes", "Report", "Settings"; also the key its width is remembered under
18
+ * title the item's name, shown once
19
+ * icon a key of ICONS below or an SVG path "M…"
20
+ * url the item's own address: "Open in a new tab" goes under ⋯ (full: true names it "Open in full")
21
+ * more [{ label, on(moreButton), note?, danger?, icon?, disabled? } | { sep: true }], or a function that returns it: the ⋯ menu; on() gets the ⋯ button as an anchor, in the xvMore order (change it, look back, stop or remove last)
22
+ * discuss true, { href }, or fn(): the quiet "Discuss in chat" icon before ⋯. Never drawn on Home, where the chat is already beside it.
23
+ * true goes to Home with ?about=<kind>:<id>&label=<title>; { href } goes there; fn() runs instead.
24
+ * back true: keep the item shown now, so ← comes back to it. Without back, opening an item forgets what was behind it.
25
+ * 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.
26
+ * id optional; current() returns it, so a caller can tell whether its item is the one shown
20
27
  * onClose called once when this item leaves the card (Close, Escape, close(), or another open())
21
- * close() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
28
+ * close() · back() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
22
29
  * placeholder(featureName, { kind?, icon? }) opens the card with czPlaceholder(featureName) in it (cozy-placeholder.js)
23
30
  * onChange(fn) → fn({ open, id, kind, title }) after each open and close; document also gets the event 'cz-viewer' with the same detail.
24
- * The look is in cozy.css (.cz-vw…). The old #dlg path (premium-viewer.js) is separate and keeps working until its callers move here. */
31
+ * czSummary({ line, tone, right, text, meta, primary, also, extra }) → the summary card's markup: one line of state, the words, one quiet meta
32
+ * line and ONE primary press ({ label, act } → data-czs-act="<act>", or { label, href }). tone 'you' (blue dot), 'warn' (amber), 'live' (red).
33
+ * also: [{ act, label, icon }] quiet icon-only presses after the primary (the Done check of a task). second: { label, act } one quiet
34
+ * word press, only where a decision has two answers (Return it | Keep it as is).
35
+ * czSections([{ id, title, count, open, render | html }], { key }) → the folding rows. A row folds and unfolds in place, and the fold
36
+ * is remembered per key and id (localStorage, a private window forgets it). render(): a string of markup, called once when drawn.
37
+ * widthOf(kind) · setWidth(px) · wide(on?) · railOn() for the page and the tests.
38
+ * The look is in cozy-vw-shell.css (loaded here once) over cozy.css (.cz-vw…). The old #dlg path (premium-viewer.js) is separate. */
25
39
  import { czPlaceholder } from './cozy-placeholder.js';
26
40
 
27
41
  export const ICONS = {
28
- doc: 'M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h5',
42
+ doc: 'M7 3h7l5 5v13H7zM14 3v5h5',
29
43
  notes: 'M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h5',
30
44
  cal: 'M3.5 5h17v15h-17zM3.5 10h17M8 3v4M16 3v4',
31
45
  meet: 'M3.5 5h17v15h-17zM3.5 10h17M8 3v4M16 3v4',
@@ -40,45 +54,276 @@ export const ICONS = {
40
54
  source: 'M12 3c4.4 0 8 1.3 8 3s-3.6 3-8 3-8-1.3-8-3 3.6-3 8-3M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6',
41
55
  info: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 11v5M12 8h.01',
42
56
  export: 'M12 4v11M7 10l5 5 5-5M5 20h14',
57
+ flag: 'M5 21V4M5 4h12l-2 4 2 4H5',
58
+ at: 'M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1',
59
+ spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
60
+ task: 'M5 5h14v14H5zM8.5 12.5l2.5 2.5 4.5-5',
61
+ warn: 'M12 3l9 16H3zM12 10v4M12 17h.01',
62
+ };
63
+ const P = {
64
+ back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
65
+ wide: 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7', side: 'M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7',
66
+ 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',
67
+ 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',
43
68
  };
44
- const OPEN_NEW = 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6';
45
- const OPEN_FULL = 'M14 4h6v6M20 4l-7 7M10 20H4v-6M4 20l7-7';
46
- const CLOSE = 'M6 6l12 12M18 6L6 18';
47
69
  export const PHONE = 760;
70
+ const NARROW = 1100, MIN = 420, CHAT = 360, RAIL = 64, MAXF = 0.7, W2 = 760, FLOAT = 560;
48
71
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
49
72
  const path = (icon) => (/^M/.test(icon || '') ? icon : ICONS[icon] || ICONS.doc);
50
- const svg = (d, w) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${esc(d)}"/></svg>`;
73
+ const svg = (d, w, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${esc(d)}"/></svg>`;
74
+ const store = {
75
+ get(k) { try { return localStorage.getItem(k); } catch { return null; } },
76
+ set(k, v) { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, String(v)); } catch { /* a private window */ } },
77
+ };
78
+ const isPhone = () => typeof innerWidth === 'number' && innerWidth <= PHONE;
79
+ const onHome = () => typeof document !== 'undefined' && !!document.body && document.body.classList.contains('cz-home');
80
+ const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file · .*/, 'file').replace(/[^a-z0-9]+/g, '-').slice(0, 40) || 'item';
51
81
 
52
- const V = { el: null, cur: null, back: null, subs: [] };
82
+ const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, rail: false, w: 0 };
53
83
 
54
- /** The header's markup for one item; pure, so a unit test can read it. */
55
84
  /** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
56
85
  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); };
86
+ const ib = (act, label, d, extra = '') => `<button type="button" class="cz-vw-ib" data-cz-vw="${act}" aria-label="${esc(label)}" title="${esc(label)}"${extra}>${svg(d, 18, act === 'more' ? 3 : 1.8)}</button>`;
87
+ /** 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". */
57
88
  export function headHtml(it) {
58
89
  const o = it || {};
59
- const nm = o.full ? 'Open full' : 'Open in a new tab', ico = o.full ? OPEN_FULL : OPEN_NEW, cls = o.full ? 'cz-vw-ib cz-vw-wide' : 'cz-vw-ib';
60
- const tab = o.url
61
- ? `<button type="button" class="${cls}" data-cz-vw="tab" aria-label="${nm}" title="${nm}">${svg(ico, 16)}</button>`
62
- : ''; // no greyed "Open in a new tab" when there is nothing to open: it read as a second share button (testing fixes)
63
- return `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 18)}</span>`
64
- + `<div class="cz-vw-t${o.full ? ' cz-vw-t2' : ''}">${o.kind && !sameAs(o.kind, o.title) ? `<p class="cz-vw-kind">${esc(o.kind)}</p>` : ''}<h3 class="cz-vw-title" id="czVwTitle">${esc(o.title || '')}</h3></div>`
65
- + tab
66
- + `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close the viewer">${svg(CLOSE, 16)}</button>`;
90
+ const phone = !!o.phone;
91
+ const kind = o.kind && !sameAs(o.kind, o.title) ? `<p class="cz-vw-kind">${esc(o.kind)}</p>` : '';
92
+ const disc = o.discuss && !o.home ? ib('discuss', 'Discuss in chat', P.chat) : '';
93
+ const more = typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
94
+ return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
95
+ + `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`
96
+ + `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${esc(o.title || '')}</h3></div>`
97
+ + disc + more
98
+ + (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
99
+ + (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
100
+ }
101
+
102
+ /* ── summary first: the card and the folding rows ── */
103
+ const TONE = { you: 'you', warn: 'warn', live: 'live', ok: 'ok' };
104
+ /** The summary card (XvOptADoc .sum): one state line, the words, one quiet meta line, one primary. Empty parts are not drawn. */
105
+ export function czSummary(o = {}) {
106
+ const tone = TONE[o.tone] || '';
107
+ const line = o.line || o.right ? `<div class="czs-line${tone ? ' ' + tone : ''}">${tone && tone !== 'ok' ? '<span class="czs-dot" aria-hidden="true"></span>' : ''}<span>${esc(o.line || '')}</span>${o.right ? `<span class="czs-r">${esc(o.right)}</span>` : ''}</div>` : '';
108
+ const text = o.text ? (o.textHtml ? `<p class="czs-p">${o.text}</p>` : `<p class="czs-p">${esc(o.text)}</p>`) : '';
109
+ const meta = o.meta ? `<p class="czs-meta">${esc(o.meta)}</p>` : '';
110
+ const p = o.primary;
111
+ // also: quiet icon-only presses after the primary (XvATask's Done check), each { act, label, icon }; never a second word button
112
+ const also = (o.also || []).filter(Boolean).map((x) => `<button type="button" class="czs-ib" data-czs-act="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}"${x.disabled ? ' disabled' : ''}>${svg(path(x.icon), 16, 2)}</button>`).join('');
113
+ // second: one quiet word press beside the primary, only where a decision has two answers (XvAReturn: Return it | Keep it as is)
114
+ const sec = o.second && o.second.label ? `<button type="button" class="czs-sec2" data-czs-act="${esc(o.second.act || 'second')}">${esc(o.second.label)}</button>` : '';
115
+ const pri = (p && p.label) || also || sec
116
+ ? `<div class="czs-acts">${!p || !p.label ? '' : p.href ? `<a class="czs-pri" href="${esc(p.href)}"${p.blank ? ' target="_blank" rel="noopener"' : ''}>${esc(p.label)}</a>` : `<button type="button" class="czs-pri" data-czs-act="${esc(p.act || 'primary')}"${p.disabled ? ' disabled' : ''}>${esc(p.label)}</button>`}${sec}${also}</div>`
117
+ : '';
118
+ return `<div class="czs-sum">${line}${text}${meta}${o.extra || ''}${pri}</div>`;
119
+ }
120
+ const foldKey = (key, id) => 'cz-vw-fold:' + kindKey(key) + ':' + String(id);
121
+ /** The folding rows (XvOptADoc .secs). A count of 0 is not drawn (zero is silence). The open row draws its body below it. */
122
+ export function czSections(list, opt = {}) {
123
+ const rows = (list || []).filter(Boolean);
124
+ if (!rows.length) return '';
125
+ const key = opt.key || 'item';
126
+ return `<div class="czs-secs" data-czs-key="${esc(key)}">` + rows.map((s, i) => {
127
+ const id = s.id || 'sec' + i;
128
+ const saved = store.get(foldKey(key, id));
129
+ const open = saved == null ? !!s.open : saved === '1';
130
+ const body = typeof s.render === 'function' ? s.render() : s.html || '';
131
+ const n = s.count === 0 || s.count == null || s.count === '' ? '' : `<span class="czs-n">${esc(s.count)}</span>`;
132
+ const can = !!body || typeof s.on === 'string';
133
+ return `<div class="czs-sec${open && body ? ' on' : ''}" data-czs-id="${esc(id)}">`
134
+ + `<button type="button" class="czs-row" ${body ? `data-czs-fold="${esc(id)}" aria-expanded="${open ? 'true' : 'false'}"` : can ? `data-czs-act="${esc(s.on)}"` : 'disabled'}>`
135
+ + `<b>${esc(s.title)}</b>${n}${can ? `<span class="czs-cv">${svg(open && body ? P.down : P.chev, 15, 2)}</span>` : ''}</button>`
136
+ + (body ? `<div class="czs-body"${open ? '' : ' hidden'}>${body}</div>` : '')
137
+ + '</div>';
138
+ }).join('') + '</div>';
139
+ }
140
+ function toggleFold(b) {
141
+ const sec = b.closest('.czs-sec'), box = b.closest('.czs-secs'); if (!sec || !box) return;
142
+ const open = b.getAttribute('aria-expanded') !== 'true';
143
+ b.setAttribute('aria-expanded', String(open)); sec.classList.toggle('on', open);
144
+ const body = sec.querySelector('.czs-body'); if (body) body.hidden = !open;
145
+ const cv = b.querySelector('.czs-cv'); if (cv) cv.innerHTML = svg(open ? P.down : P.chev, 15, 2);
146
+ store.set(foldKey(box.dataset.czsKey, b.dataset.czsFold), open ? '1' : '0');
147
+ }
148
+
149
+ /* ── the width (xvWidth) ── */
150
+ function sheet() {
151
+ if (typeof document === 'undefined' || typeof document.getElementById !== 'function' || !document.head || document.getElementById('czVwShellCss')) return; // a stubbed document (unit tests) has no head
152
+ const l = document.createElement('link'); l.id = 'czVwShellCss'; l.rel = 'stylesheet';
153
+ try { l.href = new URL('./cozy-vw-shell.css', import.meta.url).href; } catch { l.href = '/pm/cozy-vw-shell.css'; }
154
+ document.head.appendChild(l);
155
+ }
156
+ sheet(); // at import, not at the first open: a Viewer opened as the page boots finds its header styled (no flash of the old square buttons)
157
+ const listEl = () => document.querySelector('[data-cz-vw-list]') || document.getElementById('hmList');
158
+ /** What the page gives the Viewer: the room right of the list, with the list shown and with it folded to a rail. */
159
+ function room() {
160
+ const el = V.el, host = el && el.parentNode;
161
+ if (!el || el.classList.contains('cz-vw-float') || !host || !host.parentNode) {
162
+ const max = Math.round(innerWidth * MAXF);
163
+ return { float: true, def: Math.min(FLOAT, max), side: max, wideMax: max };
164
+ }
165
+ const desk = host.parentNode, cs = getComputedStyle(desk);
166
+ const inner = desk.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
167
+ const gap = parseFloat(cs.columnGap || cs.gap) || 0;
168
+ const list = listEl(), lw = list && list.parentNode === desk && !V.rail ? list.offsetWidth : list && list.parentNode === desk ? (V.lw || 316) : 0;
169
+ const right = inner - (lw ? lw + gap : 0);
170
+ const side = right - gap - CHAT;
171
+ const wideMax = Math.min(Math.round(innerWidth * MAXF), inner - (list ? RAIL + gap : 0) - gap - CHAT);
172
+ return { float: false, def: Math.max(MIN, Math.round(right / 2)), side, wideMax: Math.max(wideMax, side), hasList: !!list };
173
+ }
174
+ export const widthOf = (kind) => { const n = parseInt(store.get('cz-vw-w:' + kindKey(kind)) || '', 10); return n > 0 ? n : null; };
175
+ function setRail(on) {
176
+ const list = listEl();
177
+ if (!on && !V.rail) return;
178
+ if (on && !V.rail && list) V.lw = list.offsetWidth;
179
+ V.rail = !!on && !!list;
180
+ document.body.classList.toggle('cz-vw-rail', V.rail);
181
+ if (!list) return;
182
+ let bar = list.querySelector(':scope > .cz-vw-railbar');
183
+ if (!V.rail) { if (bar) bar.remove(); return; }
184
+ if (!bar) {
185
+ bar = document.createElement('div'); bar.className = 'cz-vw-railbar';
186
+ bar.innerHTML = `<button type="button" class="cz-vw-ib" data-cz-vw-rail="show" aria-label="Show the list" title="Show the list">${svg(P.list, 18)}</button><div class="cz-vw-railtiles"></div>`;
187
+ bar.addEventListener('click', (e) => {
188
+ const b = e.target.closest('[data-cz-vw-rail]'); if (!b) return;
189
+ if (b.dataset.czVwRail === 'show') { V.wide = false; apply(Math.min(V.w, sideMax())); redraw(); return; }
190
+ // a group's tile: the list comes back, at that group
191
+ const src = list.querySelector('[data-cz-rail-tile="' + CSS.escape(b.dataset.czVwRail) + '"]');
192
+ V.wide = false; apply(Math.min(V.w, sideMax())); redraw();
193
+ if (src && src.scrollIntoView) src.scrollIntoView({ block: 'nearest' });
194
+ });
195
+ list.prepend(bar);
196
+ }
197
+ // the groups of the list mark their tile with data-cz-rail-tile="<id>" and data-cz-rail-name: the rail shows those tiles, nothing else
198
+ const tiles = [...list.querySelectorAll('[data-cz-rail-tile]')].slice(0, 8);
199
+ const box = bar.querySelector('.cz-vw-railtiles'); box.innerHTML = '';
200
+ tiles.forEach((t) => { // a copy of the tile itself (its tint, initials and dot), in a press that names the group
201
+ const nm = t.dataset.czRailName || t.textContent.trim();
202
+ const btn = document.createElement('button'); btn.type = 'button'; btn.className = 'cz-vw-railtile'; btn.dataset.czVwRail = t.dataset.czRailTile;
203
+ btn.setAttribute('aria-label', 'Show the list at ' + nm); btn.title = nm;
204
+ const c = t.cloneNode(true); c.removeAttribute('data-cz-rail-tile'); c.removeAttribute('data-cz-rail-name'); btn.appendChild(c); box.appendChild(btn);
205
+ });
206
+ }
207
+ const sideMax = () => { const r = room(); return r.float ? r.side : Math.max(MIN, r.side); };
208
+ /** Set the width in px: past what the chat leaves, the list folds to a rail first; never under 420 or over about 70%. */
209
+ function apply(px) {
210
+ const el = V.el; if (!el) return;
211
+ if (isPhone()) { el.style.width = ''; el.style.flexBasis = ''; el.classList.remove('cz-vw-w2'); setRail(false); return; }
212
+ let r = room();
213
+ if (!r.float && r.hasList && r.side < MIN) { setRail(true); r = room(); } // under 1100 px: the list folds as the Viewer opens
214
+ let w = Math.max(MIN, Math.round(px || r.def));
215
+ if (!r.float) {
216
+ if (w > r.side && r.hasList && r.wideMax > r.side) { setRail(true); r = room(); w = Math.min(w, r.wideMax); }
217
+ else if (r.side >= MIN && w <= r.side && !V.wide) { setRail(false); r = room(); w = Math.min(w, Math.max(MIN, r.side)); }
218
+ else w = Math.min(w, Math.max(MIN, V.rail ? r.wideMax : r.side));
219
+ } else w = Math.min(w, r.wideMax);
220
+ V.w = w;
221
+ el.style.width = w + 'px'; el.style.flexBasis = w + 'px';
222
+ el.classList.toggle('cz-vw-w2', w >= W2);
223
+ const g = el.querySelector('.cz-vw-grip'); if (g) { g.setAttribute('aria-valuenow', String(w)); g.setAttribute('aria-valuemin', String(MIN)); g.setAttribute('aria-valuemax', String(r.wideMax)); }
224
+ }
225
+ export function setWidth(px, keep = true) { apply(px); if (keep && V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); }
226
+ export const railOn = () => V.rail;
227
+ /** Open wide (the list folds to a rail, the Viewer takes about 70%), or back to the side at the width this kind keeps. */
228
+ export function wide(on) {
229
+ if (!V.cur || isPhone()) return false;
230
+ V.wide = on == null ? !V.wide : !!on;
231
+ if (V.wide) apply(room().wideMax);
232
+ else { const k = widthOf(V.cur.kind); apply(k && k <= sideMax() ? k : room().def); }
233
+ redraw();
234
+ return V.wide;
235
+ }
236
+ function grip(el) {
237
+ const g = document.createElement('div');
238
+ g.className = 'cz-vw-grip'; g.setAttribute('role', 'separator'); g.setAttribute('aria-orientation', 'vertical'); g.tabIndex = 0;
239
+ g.setAttribute('aria-label', 'Drag to change the Viewer width. Double-click to reset.'); g.title = 'Drag to change the width. Double-click to reset.';
240
+ g.innerHTML = '<i></i>';
241
+ g.addEventListener('pointerdown', (e) => {
242
+ if (e.button !== 0) return;
243
+ e.preventDefault(); g.setPointerCapture(e.pointerId); document.body.classList.add('cz-vw-drag');
244
+ const right = el.getBoundingClientRect().right;
245
+ const mv = (ev) => { V.wide = false; apply(right - ev.clientX); };
246
+ const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-vw-drag'); if (V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); redraw(); };
247
+ g.addEventListener('pointermove', mv); g.addEventListener('pointerup', up); g.addEventListener('pointercancel', up);
248
+ });
249
+ g.addEventListener('dblclick', () => { if (!V.cur) return; store.set('cz-vw-w:' + kindKey(V.cur.kind), null); V.wide = false; setRail(false); apply(room().def); redraw(); });
250
+ g.addEventListener('keydown', (e) => { // the grip is a separator: arrows move it 24 px, Home resets it
251
+ const d = e.key === 'ArrowLeft' ? 24 : e.key === 'ArrowRight' ? -24 : 0;
252
+ if (d) { e.preventDefault(); V.wide = false; setWidth(V.w + d); redraw(); } else if (e.key === 'Home') { e.preventDefault(); g.dispatchEvent(new MouseEvent('dblclick')); }
253
+ });
254
+ return g;
255
+ }
256
+
257
+ /* ── the ⋯ menu ── */
258
+ function moreMenu(b) {
259
+ const old = V.el.querySelector('.cz-vw-menu');
260
+ if (old) { old.remove(); b.setAttribute('aria-expanded', 'false'); return; }
261
+ const items = ((typeof V.cur.more === 'function' ? V.cur.more() : V.cur.more) || []).filter(Boolean).slice(); // a function is asked each time ⋯ opens, so its notes are current
262
+ if (V.cur.url) { // the item's own address looks back, so it goes before the red stop-or-remove group, which stays last
263
+ const at = items.findIndex((x) => x && x.danger), tab = { label: V.cur.full ? 'Open in full' : 'Open in a new tab', on: () => window.open(V.cur.url, '_blank', 'noopener') };
264
+ if (at < 0) items.push({ sep: true }, tab); else items.splice(at > 0 && items[at - 1].sep ? at - 1 : at, 0, { sep: true }, tab);
265
+ }
266
+ while (items.length && items[0].sep) items.shift();
267
+ for (let i = items.length - 1; i > 0; i--) if (items[i].sep && items[i - 1].sep) items.splice(i, 1);
268
+ const m = document.createElement('div');
269
+ m.className = 'cz-vw-menu'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'More'); m.dataset.escLayer = '1';
270
+ m.innerHTML = items.map((it, i) => (it.sep ? '<hr>' : `<button type="button" role="menuitem" data-cz-vw-mi="${i}"${it.danger ? ' class="bad"' : ''}${it.disabled ? ' disabled' : ''}>${it.icon ? svg(path(it.icon), 16) : ''}<span>${esc(it.label)}</span>${it.note || it.hint ? `<span class="k">${esc(it.note || it.hint)}</span>` : ''}</button>`)).join('');
271
+ m.addEventListener('click', (e) => {
272
+ const x = e.target.closest('[data-cz-vw-mi]'); if (!x) return;
273
+ const it = items[+x.dataset.czVwMi]; m.remove(); b.setAttribute('aria-expanded', 'false');
274
+ if (it && typeof it.on === 'function') { try { it.on(b); } catch (err) { console.error(err); } }
275
+ });
276
+ m.addEventListener('keydown', (e) => {
277
+ const bs = [...m.querySelectorAll('button:not([disabled])')], at = bs.indexOf(document.activeElement);
278
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); m.remove(); b.setAttribute('aria-expanded', 'false'); b.focus(); }
279
+ 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(); }
280
+ });
281
+ V.el.appendChild(m); b.setAttribute('aria-expanded', 'true');
282
+ const f = m.querySelector('button:not([disabled])'); if (f) f.focus();
283
+ setTimeout(() => document.addEventListener('click', function off(e) { if (!e.target.closest('.cz-vw-menu,[data-cz-vw="more"]')) { m.remove(); b.setAttribute('aria-expanded', 'false'); } document.removeEventListener('click', off); }), 0);
284
+ }
285
+ /** The chat-key prefix Home accepts for an item's kind (home-app.js KEY): an initiative, a document, a work-item, a measure, a board view, else a chat. */
286
+ export const aboutPrefix = (k) => /initiative/.test(k) ? 'init' : /(^|-)(doc|document|prd|brd|spec|file|page)(-|$)/.test(k) ? 'doc'
287
+ : /(task|work|epic|ticket|item)/.test(k) ? 'work' : /(insight|goal|metric|measure|report|chart|dashboard)/.test(k) ? 'ins'
288
+ : /(program|board|stage|lane|release)/.test(k) ? 'board' : 'chat';
289
+ function discuss() {
290
+ const d = V.cur && V.cur.discuss; if (!d) return;
291
+ if (typeof d === 'function') { d(); return; }
292
+ if (d && d.href) { location.href = d.href; return; }
293
+ // Home opens the chat about it, with the item in the Viewer beside it (XvABoardChat): ?about=<prefix>:<id> is the chat's key, and ?vk/?vid
294
+ // carry the item's own kind and id, so Home can reopen it (an initiative, a document by its path, a work-item)
295
+ const k = kindKey(V.cur.kind), raw = String(V.cur.id || V.cur.title);
296
+ const q = new URLSearchParams();
297
+ q.set('about', aboutPrefix(k) + ':' + raw.replace(/[^A-Za-z0-9._:-]+/g, '-').replace(/^[^A-Za-z0-9]+/, '').slice(0, 100));
298
+ q.set('label', String(V.cur.title || '').slice(0, 80));
299
+ q.set('vk', k); q.set('vid', raw.slice(0, 200));
300
+ location.href = '/premium.html?' + q.toString();
67
301
  }
68
302
 
69
303
  function mount() {
70
304
  if (V.el && V.el.isConnected) return V.el;
305
+ sheet();
71
306
  const el = document.createElement('section');
72
307
  el.className = 'cz-vw'; el.id = 'czViewer'; el.hidden = true;
73
308
  el.setAttribute('aria-labelledby', 'czVwTitle'); el.tabIndex = -1;
74
309
  el.innerHTML = '<header class="cz-vw-hd"></header><div class="cz-vw-body"></div>';
75
- el.addEventListener('click', (e) => { // delegated to the header's two buttons
76
- const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled) return;
77
- if (b.dataset.czVw === 'close') close();
78
- else if (V.cur && V.cur.url) window.open(V.cur.url, '_blank', 'noopener');
310
+ el.prepend(grip(el));
311
+ el.addEventListener('click', (e) => { // the header's presses, and the folds of czSections in the body
312
+ const f = e.target.closest('[data-czs-fold]'); if (f && el.contains(f)) { toggleFold(f); return; }
313
+ const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
314
+ const a = b.dataset.czVw;
315
+ if (a === 'close') close();
316
+ else if (a === 'back') { if (V.stack.length) back(); else close(); }
317
+ else if (a === 'more') moreMenu(b);
318
+ else if (a === 'wide') wide();
319
+ else if (a === 'discuss') discuss();
79
320
  });
80
321
  place(el);
81
322
  V.el = el;
323
+ if (typeof ResizeObserver !== 'undefined') new ResizeObserver(() => {
324
+ // crossing the phone width redraws the header too (← and no grip on a phone, × on a desk) without reopening the item
325
+ if (isOpen() && !document.body.classList.contains('cz-vw-drag')) { const was = V.w, ph = V.ph; V.ph = isPhone(); apply(V.wide ? room().wideMax : V.w); if (V.w !== was || V.ph !== ph) redraw(); }
326
+ }).observe(document.documentElement);
82
327
  return el;
83
328
  }
84
329
  /** In the page's own place for it when there is one (data-cz-viewer-host), else at the end of the body, floating. */
@@ -97,31 +342,50 @@ function leave() {
97
342
  const was = V.cur; V.cur = null;
98
343
  if (was && typeof was.onClose === 'function') { try { was.onClose(); } catch { /* the caller's own fault */ } }
99
344
  }
345
+ function redraw() {
346
+ if (!V.el || !V.cur) return;
347
+ V.ph = isPhone();
348
+ V.el.querySelector('.cz-vw-hd').innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, isWide: V.wide || V.rail, phone: V.ph, home: onHome() });
349
+ }
100
350
 
101
351
  /** Show one item in the Viewer, in place of the one shown. Returns the body element the content is in. */
102
352
  export function open(it) {
103
353
  const o = it || {};
104
354
  const el = mount(); place(el);
105
355
  if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
356
+ if (o.back && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back) V.stack = [];
357
+ const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
106
358
  leave();
107
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', url: o.url || '', onClose: o.onClose };
359
+ 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, args: o };
108
360
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
109
- el.querySelector('.cz-vw-hd').innerHTML = headHtml(o);
361
+ redraw();
362
+ const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
110
363
  const body = el.querySelector('.cz-vw-body');
111
364
  body.innerHTML = ''; body.scrollTop = 0;
112
365
  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
113
- if (typeof o.render === 'function') o.render(body); else if (o.html) body.innerHTML = o.html;
366
+ const wasHidden = el.hidden;
114
367
  el.hidden = false;
368
+ if (!(sameKind && !wasHidden && (V.wide || V.rail))) { const k = widthOf(o.kind); V.wide = false; apply(k || room().def); redraw(); }
369
+ if (typeof o.render === 'function') o.render(body); else if (o.html) body.innerHTML = o.html;
115
370
  emit();
116
- if (innerWidth <= PHONE) el.focus();
371
+ if (isPhone()) el.focus();
117
372
  return body;
118
373
  }
119
- /** Close the Viewer. Focus goes back to what had it before the Viewer opened. */
374
+ /** ← : the item that was shown before this drill-in, drawn again. With nothing behind, ← closes. */
375
+ export function back() {
376
+ const prev = V.stack.pop();
377
+ if (!prev) { close(); return null; }
378
+ return open({ ...prev, back: false, _back: true });
379
+ }
380
+ /** Close the Viewer. Focus goes back to what had it before the Viewer opened. The list comes back from the rail. */
120
381
  export function close() {
121
382
  if (!V.el || V.el.hidden) return;
122
383
  leave();
384
+ V.stack = []; V.wide = false;
123
385
  V.el.hidden = true;
124
386
  V.el.querySelector('.cz-vw-body').innerHTML = '';
387
+ const m = V.el.querySelector('.cz-vw-menu'); if (m) m.remove();
388
+ setRail(false);
125
389
  emit();
126
390
  const b = V.back; V.back = null;
127
391
  if (b && b.isConnected) { try { b.focus(); } catch { /* gone */ } }
@@ -144,4 +408,4 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
144
408
  e.preventDefault(); e.stopImmediatePropagation(); close();
145
409
  }, true);
146
410
  }
147
- if (typeof window !== 'undefined') window.czViewer = { open, close, isOpen, current, body, onChange, placeholder, ICONS };
411
+ if (typeof window !== 'undefined') window.czViewer = { open, close, back, isOpen, current, body, onChange, placeholder, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };