create-pmos 0.397.0 → 0.399.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 (195) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +105 -52
  8. package/workspace/briefing-premium-board-test.js +284 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +85 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +99 -83
  13. package/workspace/briefing-premium-initiative-test.js +175 -290
  14. package/workspace/briefing-premium-insights-test.js +414 -219
  15. package/workspace/briefing-premium-metrics-test.js +55 -97
  16. package/workspace/briefing-premium-products-test.js +44 -28
  17. package/workspace/briefing-premium-sources-test.js +70 -49
  18. package/workspace/briefing-premium-test.js +155 -648
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +24 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/board-premium-trail.js +32 -0
  23. package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
  24. package/workspace/guide/briefing-premium.md +3 -1
  25. package/workspace/guide/home.md +68 -0
  26. package/workspace/guide/index.md +1 -0
  27. package/workspace/lib/agent-roles.js +71 -0
  28. package/workspace/lib/board-grill.js +63 -0
  29. package/workspace/lib/board-premium.js +121 -24
  30. package/workspace/lib/board-trail.js +223 -0
  31. package/workspace/lib/home-work-item.js +58 -0
  32. package/workspace/lib/initiative-layout.js +77 -0
  33. package/workspace/lib/insights-goals.js +196 -0
  34. package/workspace/lib/insights-premium.js +64 -15
  35. package/workspace/lib/insights-records.js +115 -0
  36. package/workspace/lib/jira-tickets.js +1 -1
  37. package/workspace/lib/meeting-points.js +52 -0
  38. package/workspace/lib/news-for-you.js +88 -0
  39. package/workspace/lib/notes-series.js +29 -6
  40. package/workspace/lib/report-confirm.js +48 -0
  41. package/workspace/lib/route-modules.js +12 -0
  42. package/workspace/lib/routes-board-docs.js +46 -0
  43. package/workspace/lib/routes-board-grill.js +90 -0
  44. package/workspace/lib/routes-board-trail.js +33 -0
  45. package/workspace/lib/routes-home-desk.js +176 -0
  46. package/workspace/lib/routes-home-review.js +108 -0
  47. package/workspace/lib/routes-initiative-layout.js +57 -0
  48. package/workspace/lib/routes-insights-premium.js +16 -4
  49. package/workspace/lib/routes-insights-records.js +133 -0
  50. package/workspace/lib/routes-meeting-points.js +37 -0
  51. package/workspace/lib/routes-news.js +57 -0
  52. package/workspace/lib/routes-notes.js +3 -1
  53. package/workspace/lib/routes-report-confirm.js +31 -0
  54. package/workspace/lib/routes-search.js +38 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/search-index.js +176 -0
  57. package/workspace/lib/transcript-steps.js +123 -0
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-board-actions-test.js +128 -82
  63. package/workspace/premium-briefing-depth-test.js +104 -90
  64. package/workspace/premium-chat-attach-test.js +54 -63
  65. package/workspace/premium-chat-chart-tab-test.js +37 -37
  66. package/workspace/premium-chat-context-test.js +19 -18
  67. package/workspace/premium-chat-goal-view-test.js +23 -23
  68. package/workspace/premium-chat-notes-test.js +26 -31
  69. package/workspace/premium-chat-report-tab-test.js +46 -28
  70. package/workspace/premium-chat-term-test.js +16 -16
  71. package/workspace/premium-chat-viewer-test.js +60 -59
  72. package/workspace/premium-core-doc-issue-test.js +52 -43
  73. package/workspace/premium-html-viewer-test.js +14 -17
  74. package/workspace/premium-phone-card-test.js +10 -3
  75. package/workspace/premium-phone-room-test.js +41 -35
  76. package/workspace/premium-report-read-test.js +152 -197
  77. package/workspace/premium-viewer-download-test.js +19 -22
  78. package/workspace/premium-viewer-flicker-test.js +11 -16
  79. package/workspace/premium-viewer-share-test.js +6 -9
  80. package/workspace/premium-viewer-test.js +41 -60
  81. package/workspace/premium-vw-backlog-test.js +53 -33
  82. package/workspace/premium-vw-cal-test.js +97 -128
  83. package/workspace/premium-vw-copy-test.js +17 -33
  84. package/workspace/premium-vw-doc-test.js +17 -10
  85. package/workspace/premium-vw-item-test.js +50 -49
  86. package/workspace/premium-vw-jira-test.js +53 -27
  87. package/workspace/premium-vw-meet-test.js +115 -187
  88. package/workspace/premium-vw-notes-test.js +88 -109
  89. package/workspace/premium-vw-rec-test.js +71 -194
  90. package/workspace/premium-vw-slides-test.js +46 -50
  91. package/workspace/premium-welcome-test.js +3 -2
  92. package/workspace/premium-work-depth-test.js +61 -53
  93. package/workspace/public/pm/bd-acts.js +383 -0
  94. package/workspace/public/pm/bd-asks.js +261 -0
  95. package/workspace/public/pm/bd-pop.js +59 -0
  96. package/workspace/public/pm/bd-span.js +222 -82
  97. package/workspace/public/pm/bd-stages.js +25 -11
  98. package/workspace/public/pm/bd-views.js +169 -0
  99. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  100. package/workspace/public/pm/c3-md.js +3 -395
  101. package/workspace/public/pm/c3-phone-detail.js +1 -1
  102. package/workspace/public/pm/c3-phone-model.js +3 -68
  103. package/workspace/public/pm/chat-term.js +3 -3
  104. package/workspace/public/pm/cozy-board.css +798 -230
  105. package/workspace/public/pm/cozy-ev.css +228 -0
  106. package/workspace/public/pm/cozy-evmodel.js +106 -0
  107. package/workspace/public/pm/cozy-evui.js +47 -0
  108. package/workspace/public/pm/cozy-home.css +570 -142
  109. package/workspace/public/pm/cozy-home.js +5 -3
  110. package/workspace/public/pm/cozy-insights.css +437 -170
  111. package/workspace/public/pm/cozy-md.js +396 -0
  112. package/workspace/public/pm/cozy-nav.js +104 -29
  113. package/workspace/public/pm/cozy-news.js +140 -0
  114. package/workspace/public/pm/cozy-placeholder.js +26 -0
  115. package/workspace/public/pm/cozy-search.js +203 -0
  116. package/workspace/public/pm/cozy-settings.js +198 -0
  117. package/workspace/public/pm/cozy-sources.js +89 -0
  118. package/workspace/public/pm/cozy-today.css +217 -0
  119. package/workspace/public/pm/cozy-viewer.css +3 -3
  120. package/workspace/public/pm/cozy-viewer.js +145 -0
  121. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  122. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  123. package/workspace/public/pm/cozy-vw.css +485 -0
  124. package/workspace/public/pm/cozy.css +83 -1
  125. package/workspace/public/pm/home-adddoc.js +48 -0
  126. package/workspace/public/pm/home-app.js +1179 -0
  127. package/workspace/public/pm/home-around.js +413 -0
  128. package/workspace/public/pm/home-chat.js +512 -0
  129. package/workspace/public/pm/home-data.js +312 -0
  130. package/workspace/public/pm/home-dictate.js +54 -0
  131. package/workspace/public/pm/home-draft.js +68 -0
  132. package/workspace/public/pm/home-ini-model.js +190 -0
  133. package/workspace/public/pm/home-ini.css +171 -0
  134. package/workspace/public/pm/home-ini.js +456 -0
  135. package/workspace/public/pm/home-list.js +276 -0
  136. package/workspace/public/pm/home-more.js +132 -0
  137. package/workspace/public/pm/home-phone-card.js +109 -0
  138. package/workspace/public/pm/home-review.js +104 -0
  139. package/workspace/public/pm/home-task.js +67 -0
  140. package/workspace/public/pm/home-today.js +144 -0
  141. package/workspace/public/pm/home-work.js +547 -0
  142. package/workspace/public/pm/phone-moment.js +69 -0
  143. package/workspace/public/pm/pm-work-view.js +1 -1
  144. package/workspace/public/pm/premium-attach.js +4 -0
  145. package/workspace/public/pm/premium-board.js +548 -395
  146. package/workspace/public/pm/premium-chart-tab.js +109 -62
  147. package/workspace/public/pm/premium-deck.js +3 -3
  148. package/workspace/public/pm/premium-first.js +23 -21
  149. package/workspace/public/pm/premium-insights.js +1102 -581
  150. package/workspace/public/pm/premium-meeting.js +61 -549
  151. package/workspace/public/pm/premium-mtg-present.js +138 -0
  152. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  153. package/workspace/public/pm/premium-notes.js +1 -1
  154. package/workspace/public/pm/premium-report-frame.css +20 -0
  155. package/workspace/public/pm/premium-report-read.js +669 -476
  156. package/workspace/public/pm/premium-report-tab.js +116 -67
  157. package/workspace/public/pm/premium-shell.js +76 -123
  158. package/workspace/public/pm/premium-viewer.js +22 -1
  159. package/workspace/public/pm/premium-vw-cal.js +277 -48
  160. package/workspace/public/pm/premium-vw-doc.css +6 -0
  161. package/workspace/public/pm/premium-vw-doc.js +40 -2
  162. package/workspace/public/pm/premium-vw-file.js +2 -2
  163. package/workspace/public/pm/premium-vw-meet.js +6 -83
  164. package/workspace/public/pm/premium-vw-mtg.js +958 -0
  165. package/workspace/public/pm/premium-vw-notes.js +116 -68
  166. package/workspace/public/pm/premium-vw-open.js +35 -0
  167. package/workspace/public/pm/premium-vw-page.js +16 -0
  168. package/workspace/public/pm/premium-vw-rec.js +11 -218
  169. package/workspace/public/pm/premium-vw-slides.css +5 -0
  170. package/workspace/public/pm/premium-vw-slides.js +44 -8
  171. package/workspace/public/pm/rp-parts.js +269 -0
  172. package/workspace/public/pm/term-view.js +22 -0
  173. package/workspace/public/premium-board.html +29 -70
  174. package/workspace/public/premium-initiative.html +8 -48
  175. package/workspace/public/premium-insights.html +26 -64
  176. package/workspace/public/premium-viewer.html +20 -0
  177. package/workspace/public/premium.html +18 -107
  178. package/workspace/r/m1.png +0 -0
  179. package/workspace/r/m2.png +0 -0
  180. package/workspace/r/m3.png +0 -0
  181. package/workspace/r/nl.png +0 -0
  182. package/workspace/server.js +18 -3
  183. package/workspace/test-files.json +1 -0
  184. package/workspace/test-lists/home-libs.json +9 -0
  185. package/workspace/test-lists/initiative-layout.json +9 -0
  186. package/workspace/test-lists/premium-report-read.json +1 -1
  187. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  188. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  189. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  190. package/workspace/test-lists/premium-vw-notes.json +1 -1
  191. package/workspace/test-lists/uf-everywhere.json +15 -0
  192. package/workspace/test-lists/uf-home.json +9 -0
  193. package/workspace/test-lists/uncovered-board.json +9 -0
  194. package/workspace/public/pm/premium-work.js +0 -729
  195. package/workspace/public/pm/premium.js +0 -1146
@@ -0,0 +1,140 @@
1
+ /* pm/cozy-news.js — New for you, in the Viewer (initiative premium-uncovered-features, E2; canvas EvInbox, HmAround). It replaces the Inbox
2
+ * (the bell) and Around you.
3
+ *
4
+ * For your information only: Mentions, Given to you, Finished while you were away (GET /api/news-for-you), and today's digests from the
5
+ * morning brief (GET /api/briefing-premium). An item leaves once it is seen: the items shown are marked seen when the card closes, and
6
+ * Mark all seen marks them at once (POST /api/news-for-you/seen). Open on a row shows the item: a mention with Make it a task, Mark read and
7
+ * Open in its source; a task with its source; finished work opens where it waits. What Around you also showed has one home each, named
8
+ * under "Where the rest went", and each line opens it (home-around.js keeps those views). The prep line Around you held (the meetings left
9
+ * today and how many are prepped, GET /api/brief-page) sits under the head when a meeting is still ahead.
10
+ * openNews({ go? }) → the body element */
11
+ import { pmGet, pmPost } from './http.js';
12
+ import { open as vwOpen, current as vwCurrent } from './cozy-viewer.js';
13
+ import { esc, svg, ICON, toast, wsParam, wsQ, skelRows, cantRead, allClear } from './cozy-evui.js';
14
+ import { initials, ago } from './cozy-evmodel.js';
15
+
16
+ const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail' };
17
+ const N = { r: null, dig: null, prep: '', view: '', body: null, shown: new Set(), madd: new Set(), mread: new Set(), busy: false };
18
+ const homeUrl = (params) => { const q = new URLSearchParams(params); if (wsParam()) q.set('ws', wsParam()); return '/premium.html?' + q.toString(); };
19
+ const https = (u) => (/^https:\/\/\S+$/i.test(String(u || '')) ? u : '');
20
+ /** The deep link of a finished item, as the bell's was: a My work item opens its dialog; anything else opens on Home. */
21
+ const finHref = (it) => (/^item:/.test(it.open) ? homeUrl({ item: it.open.slice(5) }) : homeUrl(it.pws ? { open: it.open, pws: it.pws } : { open: it.open }));
22
+ const taskLine = (m) => (m.asks ? 'Reply to ' + String(m.who || 'the sender').split(/\s+/)[0] + ' (' + (SRC[m.source] || m.source || 'source') + ') by today' : 'Read ' + String(m.who || 'the sender').split(/\s+/)[0] + '\'s note (' + (SRC[m.source] || m.source || 'source') + ')');
23
+
24
+ function items() { return N.r && N.r.ok ? N.r.groups.flatMap((g) => g.items) : []; }
25
+ function rowHtml(it) {
26
+ const who = it.kind === 'mention' ? it.who : it.kind === 'task' ? (it.from || 'Someone') : (it.product || 'Agent');
27
+ const av = `<span class="ev-av${it.kind === 'finished' ? ' b' : ''}" aria-hidden="true">${esc(initials(who))}</span>`;
28
+ const sub = it.kind === 'mention' ? ['“' + it.text + '”', [SRC[it.source] || it.source, it.where].filter(Boolean).join(' '), ago(it.at ? new Date(it.at).toISOString() : '')].filter(Boolean).join(' · ')
29
+ : it.kind === 'task' ? ['From ' + (it.from || 'a source') + (it.key ? ' ' + it.key : ''), it.due ? 'due ' + it.due : '', it.initiative ? 'filed under ' + it.initiative : ''].filter(Boolean).join(' · ')
30
+ : [it.what, it.product, it.target, it.at ? ago(new Date(it.at).toISOString()) : ''].filter(Boolean).join(' · ');
31
+ return `<div class="ev-trow" data-ev-id="${esc(it.id)}"><i class="ev-dot you" aria-hidden="true"></i>${av}<div class="ev-tx"><p><b>${esc(it.title)}</b></p><p class="ev-small ev-mut">${esc(sub)}</p></div>`
32
+ + `<button type="button" class="ev-ib" data-ev-open="${esc(it.id)}" aria-label="Open: ${esc(it.title)}" title="Open">${svg(ICON.open, 16)}</button></div>`;
33
+ }
34
+ const REST = [
35
+ ['pulse', 'Portfolio pulse', 'Insights · Goals. Home does not repeat it.'],
36
+ ['rep', 'Found in your work', 'Insights · Library, at the top.'],
37
+ ['prop', 'Proposals', 'the initiative’s next step, because they need an answer.'],
38
+ ['scan', 'Scan now', 'Ask in chat: “scan for billing news”.'],
39
+ ];
40
+ function digHtml() {
41
+ const d = N.dig; if (!d || !d.length) return '';
42
+ return `<section id="aroundDig" class="ev-dig"><p class="ev-lbl">Digests ${d.length}</p>${d.map((e) => { const x = e.dialog || {}, p = x.pane || {}, l = https(x.link);
43
+ return `<div class="ev-trow"><i class="ev-dot none" aria-hidden="true"></i><span class="ev-av" aria-hidden="true">${esc(initials(e.title))}</span><div class="ev-tx"><p><b>${esc(e.title)}</b></p><p class="ev-small ev-mut">${esc(e.sub || '')}</p>${(p.paras || []).map((t) => `<p class="ev-small">${esc(t)}</p>`).join('')}</div>${l ? `<a class="ev-ib srcLink" href="${esc(l)}" target="_blank" rel="noopener noreferrer" aria-label="Open ${esc(x.linkLabel || 'it')}" title="${esc(x.linkLabel || 'Open it')}">${svg(ICON.open, 16)}</a>` : ''}</div>`; }).join('')}</section>`;
44
+ }
45
+ function listHtml() {
46
+ const r = N.r;
47
+ const head = `<div class="ev-head"><h2 class="ev-h2">New since this morning</h2>${r && r.ok && r.count ? '<button type="button" class="ev-btn sm ghost" data-ev-all>Mark all seen</button>' : ''}</div>`;
48
+ const two = '<div class="ev-two"><div class="ev-box"><b>Initiatives</b> (left)<br><span class="ev-mut">Each shows its next step. It stays until you act.</span></div><div class="ev-box blue"><b>New for you</b> (here)<br><span class="ev-mut">For your information. It goes once you have seen it.</span></div></div>';
49
+ let body;
50
+ if (!r) body = skelRows(3) + '<p class="ev-small ev-mut">Reading what is new for you</p>';
51
+ else if (!r.ok) body = cantRead({ what: 'New for you', why: r.error || '' });
52
+ else if (!r.count) body = allClear('Nothing new since you last looked');
53
+ else body = r.groups.map((g) => `<p class="ev-lbl">${esc(g.label)}</p>` + g.items.map(rowHtml).join('')).join('');
54
+ const notRead = r && r.ok && r.read ? [['mentions', 'Mentions'], ['inbox', 'The agents\' results'], ['work', 'Your tasks']].filter(([k]) => r.read[k] === false).map(([, l]) => l) : [];
55
+ const rest = `<p class="ev-lbl">Where the rest went</p><div class="ev-box ev-rest">${REST.map(([k, t, w]) => `<button type="button" data-ev-rest="${k}"><b>${esc(t)}</b><span>${esc(w)}</span></button>`).join('')}</div>`;
56
+ const foot = '<div class="ev-foot"><div class="ev-box ev-small"><b>Not here, so nothing shows twice</b><br>A mention that asks you something, a passed review or a proposal becomes the next step of its initiative. A task given to you shows here once, then sits under its initiative. Goal trends live in Insights.</div></div>';
57
+ return head + (N.prep || '') + two + body + (notRead.length ? `<p class="ev-small ev-mut" role="status">Not read: ${esc(notRead.join(', '))}.</p>` : '') + digHtml() + rest + foot;
58
+ }
59
+ function detailHtml(it) {
60
+ const back = '<div class="ev-head"><button type="button" class="ev-btn sm ghost" data-ev-back>' + svg(ICON.back, 16) + 'New for you</button></div>';
61
+ if (it.kind === 'mention') {
62
+ const l = https(it.link), done = N.madd.has(it.id), read = N.mread.has(it.id);
63
+ return back + `<p class="ev-lbl">${esc([SRC[it.source] || it.source, it.where, ago(it.at ? new Date(it.at).toISOString() : '')].filter(Boolean).join(' · '))}${it.asks ? ' · asks you something' : ''}</p><h2 class="ev-h2">${esc(it.title)}</h2><p class="ev-q">${esc(it.text)}</p>`
64
+ + (it.initiative ? `<p class="ev-small ev-mut">${esc(it.initiative)}</p>` : '')
65
+ + `<div class="ev-acts">${done ? '<span class="ev-pill ok">In your tasks</span>' : '<button type="button" class="ev-btn sm pri" data-ev-act="task">Make it a task</button>'}${read ? '<span class="ev-pill">Marked read</span>' : '<button type="button" class="ev-btn sm" data-ev-act="read">Mark read</button>'}${l ? `<a class="ev-btn sm" href="${esc(l)}" target="_blank" rel="noopener noreferrer">Open in ${esc(SRC[it.source] || 'its source')}</a>` : ''}</div>`
66
+ + (done ? '' : `<p class="ev-small ev-mut">Make it a task adds “${esc(taskLine(it))}” to your tasks. Mark read keeps it out of today's list. Nothing here replies or posts.</p>`);
67
+ }
68
+ const l = https(it.link);
69
+ return back + `<p class="ev-lbl">Given to you · ${esc(it.from || 'a source')}</p><h2 class="ev-h2">${esc(it.title.replace(/^New task: /, ''))}</h2>`
70
+ + `<p class="ev-small ev-mut">${esc([it.key, it.due ? 'due ' + it.due : '', it.initiative ? 'filed under ' + it.initiative : ''].filter(Boolean).join(' · '))}</p>`
71
+ + `<div class="ev-acts"><a class="ev-btn sm pri" href="${esc(homeUrl({ item: it.tid }))}">Open in Home</a>${l ? `<a class="ev-btn sm" href="${esc(l)}" target="_blank" rel="noopener noreferrer">Open in ${esc(it.from || 'its source')}</a>` : ''}</div>`;
72
+ }
73
+ function draw() {
74
+ const b = N.body; if (!b || !b.isConnected) return;
75
+ { const c = vwCurrent(); if (!c || c.id !== 'news') return; } // the Viewer moved on to another item: a late read draws nothing
76
+ const it = N.view && items().find((x) => x.id === N.view);
77
+ b.innerHTML = it ? detailHtml(it) : listHtml();
78
+ if (!it) for (const x of items()) N.shown.add(x.id);
79
+ }
80
+ async function read() {
81
+ const [r, d, bp] = await Promise.all([pmGet('/api/news-for-you' + wsQ()), N.dig ? Promise.resolve(null) : pmGet('/api/briefing-premium' + wsQ()), pmGet('/api/brief-page' + wsQ())]);
82
+ N.prep = bp && bp.ok !== false ? await import('./home-around.js').then((M) => M.prepHtmlOf(bp)).catch(() => '') : '';
83
+ N.r = r && r.ok ? r : { ok: false, error: (r && r.error) || 'the server did not answer' };
84
+ if (d && d.ok && d.model) { const T = d.model.today || {}; N.dig = [].concat(T.earlier || [], T.ahead || []).filter((e) => e && e.kind === 'digest'); }
85
+ draw();
86
+ if (N.r.ok) document.dispatchEvent(new CustomEvent('cz:news', { detail: { count: N.r.count } }));
87
+ }
88
+ /** Mark ids seen; the count in the menu follows. */
89
+ async function seen(ids) {
90
+ const L = [...ids].filter(Boolean); if (!L.length) return true;
91
+ let ok = true;
92
+ for (let i = 0; i < L.length; i += 300) { const r = await pmPost('/api/news-for-you/seen', { ids: L.slice(i, i + 300) }); if (!r || !r.ok) ok = false; }
93
+ document.dispatchEvent(new CustomEvent('cz:news', {}));
94
+ return ok;
95
+ }
96
+
97
+ export function openNews(o = {}) {
98
+ N.view = ''; N.shown = new Set();
99
+ N.body = vwOpen({ id: 'news', kind: 'For your information', title: 'New for you', icon: ICON.news, render: (b) => { b.classList.add('ev-card-b', 'ev-news'); N.body = b; draw(); wire(b, o); },
100
+ onClose: () => { const ids = [...N.shown]; N.shown = new Set(); seen(ids); } }); // an item leaves once seen: what the card showed is seen when it closes
101
+ read();
102
+ return N.body;
103
+ }
104
+ function wire(b, o) {
105
+ b.onclick = async (e) => {
106
+ const t = e.target.closest('button'); if (!t || N.busy) return;
107
+ if ('evRetry' in t.dataset) { N.r = null; draw(); read(); return; }
108
+ if ('evSources' in t.dataset) { import('./cozy-sources.js').then((M) => M.openSources()); return; }
109
+ if ('evBack' in t.dataset) { N.view = ''; draw(); const f = b.querySelector('[data-ev-open]'); if (f) f.focus(); return; }
110
+ if ('evAll' in t.dataset) {
111
+ N.busy = true; const ids = items().map((x) => x.id);
112
+ const ok = await seen(ids); N.busy = false;
113
+ if (!ok) { toast('It was not marked seen. The server did not answer.'); return; }
114
+ N.shown = new Set(); toast('Marked seen.'); N.r = null; draw(); read(); return;
115
+ }
116
+ if (t.dataset.evRest) {
117
+ const k = t.dataset.evRest;
118
+ // each opens its view, so every press the old Around you held (keep, dismiss, Scan now, set up) is still one press away
119
+ import('./home-around.js').then((M) => M.openAround(k)); return;
120
+ }
121
+ if (t.dataset.evOpen) {
122
+ const it = items().find((x) => x.id === t.dataset.evOpen); if (!it) return;
123
+ N.shown.add(it.id);
124
+ if (it.kind === 'finished') { await seen([it.id]); location.assign(finHref(it)); return; }
125
+ N.view = it.id; draw(); const f = b.querySelector('[data-ev-back]'); if (f) f.focus(); return;
126
+ }
127
+ if (t.dataset.evAct) {
128
+ const it = items().find((x) => x.id === N.view); if (!it) return;
129
+ N.busy = true; t.disabled = true;
130
+ const r = t.dataset.evAct === 'task' ? await pmPost('/api/pm-items/add', { line: taskLine(it) }) : await pmPost('/api/mentions/read', { id: it.mid, read: true });
131
+ N.busy = false;
132
+ if (!r || r.ok === false) { toast('That did not go through' + (r && r.error ? ': ' + r.error : '.')); t.disabled = false; return; }
133
+ if (t.dataset.evAct === 'task') { N.madd.add(it.id); toast('Added to your tasks: ' + taskLine(it).replace(/ by today$/, '')); } else { N.mread.add(it.id); toast('Marked read.'); }
134
+ draw();
135
+ }
136
+ };
137
+ void o;
138
+ }
139
+ /** Still open on this item? For a page that redraws around the Viewer. */
140
+ export const isNewsOpen = () => { const c = vwCurrent(); return !!(c && c.id === 'news'); };
@@ -0,0 +1,26 @@
1
+ /* pm/cozy-placeholder.js — the card for a feature the Agreed design does not draw yet (initiative premium-agreed-design).
2
+ *
3
+ * The rebuilt pages show only what the design draws. Where a feature has no design yet, a page draws this small calm card in its place,
4
+ * so the feature is named and nothing old is shown instead:
5
+ * czPlaceholder(el, featureName, note?) → el. It puts the card in el (it replaces what el held) and returns el.
6
+ * placeholderHtml(featureName, note?) → the same card as a string, for a page that builds its markup as text.
7
+ * The card reads "<featureName> · Waiting for design". note is one optional short line under it. The look is in cozy.css (.cz-ph). */
8
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
9
+ const ICON = 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 7v5l3 2';
10
+
11
+ /** The words of the card's line; pure, for a unit test. */
12
+ export const placeholderText = (featureName) => (String(featureName || '').trim() || 'This part') + ' · Waiting for design';
13
+
14
+ export function placeholderHtml(featureName, note) {
15
+ return `<div class="cz-ph" role="note" data-cz-placeholder="${esc(String(featureName || '').trim())}">`
16
+ + `<span class="cz-ph-ic" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="${ICON}"/></svg></span>`
17
+ + `<div class="cz-ph-t"><p class="cz-ph-l">${esc(placeholderText(featureName))}</p>${note ? `<p class="cz-ph-n">${esc(note)}</p>` : ''}</div></div>`;
18
+ }
19
+
20
+ export function czPlaceholder(el, featureName, note) {
21
+ if (!el) return el;
22
+ el.innerHTML = placeholderHtml(featureName, note);
23
+ return el;
24
+ }
25
+
26
+ if (typeof window !== 'undefined') { window.czPlaceholder = czPlaceholder; window.czPlaceholderHtml = placeholderHtml; }
@@ -0,0 +1,203 @@
1
+ /* pm/cozy-search.js — Search (initiative premium-uncovered-features, E1; canvas EvSearch, and EvPhone on the right).
2
+ *
3
+ * One palette over the page: the query, the kind chips with their counts (All, Initiatives, Documents, Slides, Reports, Artifacts, Meetings)
4
+ * and the worktree picker ("main + 3 worktrees"); the results grouped (Initiatives · Documents, slides and reports · Artifacts and designs ·
5
+ * Meetings), and last "Ask Claude about …", which starts a chat in Home. ↑ ↓ move, ↵ opens, Esc closes. On a phone it is the whole screen.
6
+ * openSearch({ go?, q? }) go: the page's own opener ({ ini } | { ses } | { doc }), used before a page change
7
+ * closeSearch()
8
+ * It reads GET /api/find (the repository and every worktree: lib/search-index.js), GET /api/boards/backlog (the initiatives' stage) and
9
+ * GET /api/sessions. A result opens in the Viewer when it can: a document of main as its page (premium-vw-doc.js), a meeting as its card,
10
+ * any other file read-only from its worktree (GET /api/find/file). Nothing here writes. */
11
+ import { esc, svg, ICON, wsParam, wsQ, skelRows, cantRead, failedItem } from './cozy-evui.js';
12
+ const ARROW = { up: 'M12 19V5M6 11l6-6 6 6', down: 'M12 5v14M6 13l6 6 6-6', enter: 'M20 5v7a3 3 0 0 1-3 3H5M9 11l-4 4 4 4' }; // the footer's keys, drawn (R28-13: no glyph as a control)
13
+ import { SEARCH_KINDS, PHONE_KINDS, searchGroups, resultSub, resultTag, wtChip } from './cozy-evmodel.js';
14
+ import { open as vwOpen, current as vwCurrent } from './cozy-viewer.js';
15
+
16
+ const PHONE = 760;
17
+ const isPhone = () => innerWidth <= PHONE;
18
+ const S = { el: null, q: '', kind: 'all', at: 0, rows: [], res: null, busy: false, err: '', wt: null, wtOpen: false, back: null, go: null, seq: 0, boards: null, sessions: null, t: 0 };
19
+ const KIND_ICON = { initiative: ICON.flag, document: ICON.doc, slides: ICON.slides, report: ICON.report, artifact: ICON.design, file: ICON.file, meeting: ICON.meet, session: ICON.session };
20
+ async function getj(p) { try { const r = await fetch(p, { credentials: 'same-origin' }); const j = await r.json().catch(() => null); return j || { ok: false, error: 'the server did not answer' }; } catch { return { ok: false, error: 'the server did not answer' }; } }
21
+ const WT_KEY = 'pmos.search.wt';
22
+ const wtPick = () => { try { const v = JSON.parse(localStorage.getItem(WT_KEY) || 'null'); return Array.isArray(v) ? v : null; } catch { return null; } };
23
+
24
+ function mount() {
25
+ if (S.el && S.el.isConnected) return S.el;
26
+ const d = document.createElement('div');
27
+ d.innerHTML = '<div class="ev-sp-scrim" id="evSpScrim" hidden></div>'
28
+ + '<div class="ev-sp" id="evSearch" role="dialog" aria-modal="true" aria-label="Search" hidden>'
29
+ + `<div class="ev-sp-in">${svg(ICON.search, 20)}<label for="evQ" class="ev-vh">Search PMOS</label><input id="evQ" type="text" autocomplete="off" spellcheck="false" placeholder="Search initiatives, documents, slides, reports, artifacts and meetings" role="combobox" aria-expanded="true" aria-controls="evRes" aria-autocomplete="list"><span class="ev-kbd">Esc</span><button type="button" class="ev-ib x" data-ev="close" aria-label="Close search">${svg(ICON.close, 18)}</button></div>`
30
+ + '<div class="ev-sp-chips" id="evChips" role="group" aria-label="Kind"></div>'
31
+ + '<div class="ev-sp-list" id="evRes" role="listbox" aria-label="Results"></div>'
32
+ + `<div class="ev-sp-ft"><span><span class="ev-kbd" role="img" aria-label="Arrow up">${svg(ARROW.up, 12)}</span> <span class="ev-kbd" role="img" aria-label="Arrow down">${svg(ARROW.down, 12)}</span> move</span><span><span class="ev-kbd" role="img" aria-label="Enter">${svg(ARROW.enter, 12)}</span> open</span><span class="ev-r">Searches the repo and every worktree. Opens in the Viewer when it can.</span></div>`
33
+ + '</div>';
34
+ document.body.append(...d.childNodes);
35
+ S.el = document.getElementById('evSearch');
36
+ document.getElementById('evSpScrim').addEventListener('click', closeSearch);
37
+ const q = S.el.querySelector('#evQ');
38
+ q.addEventListener('input', () => { S.q = q.value; S.at = 0; schedule(); });
39
+ q.addEventListener('keydown', (e) => {
40
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); const n = S.rows.length; if (n) { S.at = (S.at + (e.key === 'ArrowDown' ? 1 : n - 1)) % n; drawList(); } }
41
+ else if (e.key === 'Enter') { e.preventDefault(); const r = S.rows[S.at]; if (r) go(r); }
42
+ });
43
+ S.el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); if (S.wtOpen) { S.wtOpen = false; drawChips(); return; } closeSearch(); } });
44
+ S.el.addEventListener('click', (e) => {
45
+ const b = e.target.closest('button, input[type="checkbox"]'); if (!b) return;
46
+ if (b.dataset.ev === 'close') { closeSearch(); return; }
47
+ if (b.dataset.evKind) { S.kind = b.dataset.evKind; S.at = 0; draw(); q.focus(); return; }
48
+ if ('evWt' in b.dataset) { S.wtOpen = !S.wtOpen; drawChips(); return; }
49
+ if (b.dataset.evWtId) { const all = (S.res && S.res.worktrees || []).filter((w) => !w.main).map((w) => w.id); const cur = new Set(S.wt || all); if (b.checked) cur.add(b.dataset.evWtId); else cur.delete(b.dataset.evWtId); S.wt = [...cur]; try { localStorage.setItem(WT_KEY, JSON.stringify(S.wt)); } catch { /* no storage */ } run(); return; }
50
+ if (b.dataset.evI != null) { const r = S.rows[+b.dataset.evI]; if (r) go(r); }
51
+ });
52
+ return S.el;
53
+ }
54
+
55
+ export function openSearch(o = {}) {
56
+ const el = mount();
57
+ S.go = typeof o.go === 'function' ? o.go : null;
58
+ if (!el.hidden) { el.querySelector('#evQ').focus(); return el; }
59
+ const ae = document.activeElement; S.back = ae && ae !== document.body ? ae : null;
60
+ S.wt = wtPick(); S.wtOpen = false; S.kind = 'all'; S.at = 0;
61
+ if (o.q != null) S.q = String(o.q);
62
+ el.hidden = false; document.getElementById('evSpScrim').hidden = false; el.setAttribute('data-esc-layer', '');
63
+ const q = el.querySelector('#evQ'); q.value = S.q; q.focus(); q.select();
64
+ if (!S.boards) getj('/api/boards/backlog?limit=200' + wsQ('&')).then((b) => { S.boards = b && b.ok && Array.isArray(b.rows) ? b : { rows: [] }; draw(); });
65
+ if (!S.sessions) getj('/api/sessions').then((s) => { S.sessions = s && Array.isArray(s.sessions) ? s.sessions.filter((x) => !x.automatic && x.shown !== 'exited') : []; draw(); });
66
+ run();
67
+ return el;
68
+ }
69
+ export function closeSearch() {
70
+ if (!S.el || S.el.hidden) return;
71
+ S.el.hidden = true; document.getElementById('evSpScrim').hidden = true; S.el.removeAttribute('data-esc-layer');
72
+ const b = S.back; S.back = null; if (b && b.isConnected) { try { b.focus(); } catch { /* gone */ } }
73
+ }
74
+ export const isSearchOpen = () => !!(S.el && !S.el.hidden);
75
+
76
+ function schedule() { clearTimeout(S.t); S.t = setTimeout(run, 160); draw(); }
77
+ async function run() {
78
+ const q = S.q.trim(), my = ++S.seq;
79
+ if (q.length < 2) { S.res = S.res && { ...S.res, results: [], counts: {} }; S.busy = false; S.err = ''; draw(); if (!S.res) { const r = await getj('/api/find?q=' + wsQ('&')); if (my === S.seq && r.ok) { S.res = r; drawChips(); } } return; }
80
+ S.busy = true; S.err = ''; draw();
81
+ const wt = S.wt ? '&wt=' + encodeURIComponent(S.wt.join(',') || '-') : '';
82
+ const r = await getj('/api/find?q=' + encodeURIComponent(q) + wsQ('&') + wt);
83
+ if (my !== S.seq) return;
84
+ S.busy = false;
85
+ if (!r.ok) { S.err = r.error || 'the server did not answer'; draw(); return; }
86
+ S.res = r; draw();
87
+ }
88
+
89
+ /** Every row the palette shows for the query: the search's results, the board's initiatives and the sessions that match, each once. */
90
+ function allRows() {
91
+ const q = S.q.trim().toLowerCase();
92
+ if (q.length < 2 || !S.res) return [];
93
+ const res = (S.res.results || []).slice();
94
+ const B = (S.boards && S.boards.rows) || [];
95
+ const seen = new Set(res.filter((r) => r.kind === 'initiative').map((r) => r.id));
96
+ for (const r of res) if (r.kind === 'initiative') { const b = B.find((x) => x.id === r.id); if (b) Object.assign(r, { stage: b.stage, lane: r.lane || b.lane, days: b.days_in_stage || b.days || null, title: b.title || r.title, board: S.boards.board, bws: S.boards.ws }); }
97
+ for (const b of B) if (!seen.has(b.id) && (String(b.title || '') + ' ' + b.id).toLowerCase().includes(q)) res.unshift({ kind: 'initiative', group: 'initiative', id: b.id, title: b.title || b.id, lane: b.lane, stage: b.stage, days: b.days_in_stage || null, board: S.boards.board, bws: S.boards.ws, why: 'name' });
98
+ for (const s of S.sessions || []) if ((String(s.name || '') + ' ' + String((s.hx && s.hx.title) || '')).toLowerCase().includes(q)) res.push({ kind: 'session', group: 'meeting', id: s.id, title: (s.hx && s.hx.title) || s.name || s.id, where: s.cwd && s.cwd !== '.' ? s.cwd : '', state: s.state || '', why: 'name' });
99
+ return res;
100
+ }
101
+ const countsOf = (rows) => { const c = { all: rows.length }; for (const r of rows) { const k = r.group === 'session' ? 'meeting' : r.group || r.kind; c[k] = (c[k] || 0) + 1; } return c; };
102
+
103
+ function drawChips() {
104
+ const box = S.el && S.el.querySelector('#evChips'); if (!box) return;
105
+ const rows = allRows(), c = countsOf(rows), K = isPhone() ? PHONE_KINDS : SEARCH_KINDS, wts = (S.res && S.res.worktrees) || [];
106
+ const on = (w) => !S.wt || S.wt.includes(w.id);
107
+ const shown = wts.map((w) => ({ ...w, on: w.main || on(w) }));
108
+ box.innerHTML = K.map(([k, l]) => `<button type="button" class="ev-chip${S.kind === k ? ' on' : ''}" data-ev-kind="${k}" aria-pressed="${S.kind === k}">${esc(l)}${!isPhone() && S.q.trim().length >= 2 ? ' ' + (c[k] || 0) : ''}</button>`).join('')
109
+ + `<button type="button" class="ev-chip gh ev-wt" data-ev-wt aria-expanded="${S.wtOpen}" aria-haspopup="true" title="Which worktrees Search reads">${svg(ICON.branch, 14)}${esc(wtChip(shown))}</button>`
110
+ + `<div class="ev-wtm" role="group" aria-label="Worktrees"${S.wtOpen ? '' : ' hidden'}>${shown.map((w) => `<label><input type="checkbox" ${w.main ? 'checked disabled' : `data-ev-wt-id="${esc(w.id)}"${w.on ? ' checked' : ''}`}><span>${esc(w.main ? 'main' : w.name)}</span><small>${w.main ? 'always' : w.error ? esc(w.error) : esc(w.id)}</small></label>`).join('')}</div>`;
111
+ }
112
+ function rowHtml(r, i) {
113
+ const tag = resultTag(r), sub = resultSub(r);
114
+ const right = r.kind === 'document' && r.draft ? '<span class="ev-pill y">Draft</span>' : esc(tag);
115
+ const title = r.kind === 'initiative' ? `<b>${esc(r.title)}</b>` : esc(r.title);
116
+ const subHtml = r.draft ? esc(sub).replace(/^worktree (\S+)/, 'worktree <b>$1</b>') : esc(sub);
117
+ const two = isPhone() ? `<span class="ev-t">${title}${sub ? `<br><span class="ev-small ev-mut">${subHtml}</span>` : ''}</span>` : `<span class="ev-t">${title}${sub ? ` <span class="ev-mut">· ${subHtml}</span>` : ''}</span>`;
118
+ return `<button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}">${svg(KIND_ICON[r.kind] || ICON.doc, 18)}${two}${right ? `<span class="ev-k">${right}</span>` : ''}</button>`;
119
+ }
120
+ function drawList() {
121
+ const box = S.el && S.el.querySelector('#evRes'); if (!box) return;
122
+ const q = S.q.trim();
123
+ let rows = allRows();
124
+ if (S.kind !== 'all') rows = rows.filter((r) => (S.kind === 'artifact' ? ['artifact', 'file'].includes(r.kind) : S.kind === 'meeting' ? ['meeting', 'session'].includes(r.kind) : r.kind === S.kind));
125
+ const groups = searchGroups(rows, { phone: isPhone() });
126
+ S.rows = groups.flatMap((g) => g.rows);
127
+ const ask = q.length >= 2 ? { kind: 'ask', title: q } : null;
128
+ if (ask) S.rows.push(ask);
129
+ S.at = Math.min(S.at, Math.max(0, S.rows.length - 1));
130
+ let h = '', i = 0;
131
+ if (q.length < 2) h = '<p class="ev-sp-empty">Type two letters or more. Search reads the initiatives, the documents, slides and reports, the artifacts and designs, and the meetings, in the repository and every worktree.</p>';
132
+ else if (S.err) h = cantRead({ what: 'Search', why: S.err, sources: false });
133
+ else if (S.busy && !groups.length) h = skelRows(3);
134
+ else if (!groups.length) h = `<p class="ev-sp-empty" role="status">Nothing matches “${esc(q)}”${S.kind !== 'all' ? ' in this kind' : ''}.</p>`;
135
+ groups.forEach((g, gi) => {
136
+ h += `<p class="ev-mlbl">${esc(g.label)}</p>` + g.rows.map((r) => rowHtml(r, i++)).join('');
137
+ if (gi === 0 && isPhone() && g.key === 'initiative') h += '<div class="ev-sp-chips ev-phchips" aria-hidden="true"></div>';
138
+ });
139
+ if (S.res && S.res.more && q.length >= 2) h += `<p class="ev-sp-empty">${S.res.more} more match. Pick a kind to see them.</p>`;
140
+ if (ask) h += `<div class="ev-hr" role="separator"></div><button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}">${svg(ICON.chat, 18)}<span class="ev-t">Ask Claude about <b>“${esc(q)}”</b></span><span class="ev-k">Starts a chat in Home</span></button>`;
141
+ const chips = S.el.querySelector('#evChips');
142
+ if (chips && chips.parentNode !== S.el) S.el.insertBefore(chips, box); // home first, so the redraw below never drops it
143
+ box.innerHTML = h;
144
+ // the phone draws the kind chips after the Initiatives group (EvPhone)
145
+ const ph = box.querySelector('.ev-phchips');
146
+ if (ph && chips) ph.replaceWith(chips);
147
+ const r = box.querySelector('[data-ev-retry]'); if (r) r.onclick = () => run();
148
+ const a = box.querySelector('#evo' + S.at); if (a) { S.el.querySelector('#evQ').setAttribute('aria-activedescendant', a.id); a.scrollIntoView({ block: 'nearest' }); }
149
+ }
150
+ function draw() { if (!S.el || S.el.hidden) return; drawChips(); drawList(); }
151
+ addEventListener('resize', () => draw());
152
+
153
+ /* ── open a result ── */
154
+ const onHome = () => /^\/(?:premium(?:\.html)?|index\.html)?$/.test(location.pathname);
155
+ function homeUrl(params) { const q = new URLSearchParams(params); if (wsParam()) q.set('ws', wsParam()); return '/premium.html?' + q.toString(); }
156
+ function go(r) {
157
+ closeSearch();
158
+ if (r.kind === 'ask') { askClaude(r.title); return; }
159
+ if (r.kind === 'initiative') { if (S.go) { S.go({ ini: r.id }); return; } location.assign(homeUrl(r.board ? { ini: r.id, board: r.board } : { ini: r.id })); return; }
160
+ if (r.kind === 'session') { if (S.go) { S.go({ ses: r.id }); return; } location.assign(homeUrl({ session: r.id })); return; }
161
+ if (r.kind === 'meeting') { import('./premium-vw-open.js').then(() => window.czViews.openMeeting({ note: r.id }, { ws: wsParam() })).catch(() => openFileCard(r)); return; }
162
+ if (r.main && /\.md$/i.test(r.path)) {
163
+ import('./premium-vw-doc.js').then((M) => { if (!M.openDocPage({ path: r.path, title: r.title }, { ws: () => wsParam() })) openFileCard(r); }).catch(() => openFileCard(r));
164
+ return;
165
+ }
166
+ openFileCard(r);
167
+ }
168
+ /** "Ask Claude about …" starts a chat in Home: the question is put in Home's box, not sent. */
169
+ function askClaude(q) {
170
+ const text = 'Tell me about “' + q + '” in this product.';
171
+ const box = onHome() && document.getElementById('hmIn');
172
+ if (box) { box.value = text; box.dispatchEvent(new Event('input', { bubbles: true })); box.focus(); return; }
173
+ location.assign(homeUrl({ say: text }));
174
+ }
175
+
176
+ /** A file read-only from its worktree, in the Viewer: Markdown as text, HTML as a still picture (no scripts), anything else as text. */
177
+ export function openFileCard(r) {
178
+ const kind = { document: 'Document', slides: 'Slides', report: 'Report', artifact: 'Artifact', file: 'File' }[r.kind] || 'File';
179
+ const where = r.main ? 'main' : 'worktree ' + (r.branch || r.wt);
180
+ const vid = 'search:' + (r.wt || 'main') + ':' + r.path;
181
+ const body = vwOpen({ id: vid, kind: kind + ' · ' + where, title: r.title || r.path, icon: r.kind === 'slides' ? 'slides' : r.kind === 'report' ? 'report' : 'doc', render: (b) => { b.classList.add('ev-card-b'); b.innerHTML = skelRows(3); } });
182
+ const load = async () => {
183
+ const f = await getj('/api/find/file?wt=' + encodeURIComponent(r.wt || 'main') + '&path=' + encodeURIComponent(r.path) + wsQ('&'));
184
+ if (!body.isConnected || !vwCurrent() || vwCurrent().id !== vid) return; // the Viewer moved on: a late read draws nothing
185
+ if (!f.ok) {
186
+ body.innerHTML = `<h2 class="ev-h2">${esc(r.title || r.path)}</h2>` + failedItem({ what: 'This ' + kind.toLowerCase(), why: f.error, find: (r.path || '').split('/').pop().replace(/\.[^.]+$/, '') });
187
+ body.querySelector('[data-ev-retry]').onclick = () => { body.innerHTML = skelRows(3); load(); };
188
+ const fi = body.querySelector('[data-ev-find]'); if (fi) fi.onclick = () => openSearch({ q: fi.dataset.evFind });
189
+ return;
190
+ }
191
+ const head = `<p class="ev-lbl">${esc(f.path)} · ${esc(f.main ? 'main' : 'worktree ' + (f.branch || f.wt))}${f.main ? '' : ' · not merged'}</p>`;
192
+ if (/\.html?$/i.test(f.path)) {
193
+ body.innerHTML = head + '<iframe class="ev-frame" sandbox="" referrerpolicy="no-referrer" title="' + esc(r.title || f.path) + '"></iframe><p class="ev-small ev-mut">A still picture of the page: its scripts do not run here.</p>';
194
+ body.querySelector('iframe').srcdoc = f.text;
195
+ } else if (/\.(md|mdx|txt)$/i.test(f.path)) {
196
+ body.innerHTML = head + '<div class="ev-md"></div>';
197
+ try { const M = await import('./cozy-md.js'); const box = body.querySelector('.ev-md'); box.append(...M.toDom(M.parseMd(f.text.replace(/^---\n[\s\S]*?\n---\n/, '')), document)); }
198
+ catch { body.querySelector('.ev-md').outerHTML = `<pre class="ev-pre">${esc(f.text)}</pre>`; }
199
+ } else body.innerHTML = head + `<pre class="ev-pre">${esc(f.text)}</pre>`;
200
+ };
201
+ load();
202
+ return body;
203
+ }
@@ -0,0 +1,198 @@
1
+ /* pm/cozy-settings.js — Settings (initiative premium-uncovered-features, E3; canvas EvSettings). A dialog over the page, its sections on the left:
2
+ * General Theme (this device), Viewer opens as a column or a popup (this device), Product (which products Home reads: the Products card),
3
+ * Your day (when the end-of-day card shows: time.workEnd, POST /api/settings), Agents write to Jira (fixed: only after Commit)
4
+ * Connectors what PMOS reads on its own, and the connectors your sessions have (GET and POST /api/proactive/settings)
5
+ * Workspaces the repositories PMOS works in (GET and POST /api/workspaces, POST /api/workspaces/forget; the folder is never touched)
6
+ * Updates the versions and Check now, Update, Restart to update (GET /api/kit/status, POST /api/kit/check | update | upgrade-app)
7
+ * What's new what each published kit changed, newest first (the kit status's changelog lines)
8
+ * The card at the bottom of General says when an update is ready. Every write is the PM's press (pmPost carries the launch nonce).
9
+ * openSettings(section?) */
10
+ import { pmGet, pmPost } from './http.js';
11
+ import { esc, svg, ICON, toast } from './cozy-evui.js';
12
+
13
+ const SECTIONS = [['general', 'General'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['updates', 'Updates'], ['whatsnew', "What's new"]];
14
+ const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
15
+ const VIEWER_KEY = 'pmos.cz.viewer';
16
+ const T = { el: null, sec: 'general', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null };
17
+ const cmpVer = (a, b) => { const x = String(a || '0').split('-')[0].split('.').map(Number), y = String(b || '0').split('-')[0].split('.').map(Number); for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) < (y[i] || 0) ? -1 : 1; return 0; };
18
+ const home = () => (T.ws && T.ws[0] ? T.st[T.ws[0].id] : null);
19
+ const latest = () => { const s = home(); return (s && (s.latest || (s.lastCheck && s.lastCheck.latest))) || null; };
20
+ const fromGit = () => { const s = home(); return !!(s && s.app && s.app.fromCheckout && !(s.source && s.source.kind === 'local')); };
21
+ const kitsBehind = () => (T.ws || []).filter((w) => T.st[w.id] && T.st[w.id].kitBehind);
22
+ const appBehind = () => { const s = home(); return !!(s && s.appBehind && !fromGit()); };
23
+ const ready = () => appBehind() || kitsBehind().length > 0;
24
+ const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* no storage */ } } };
25
+ const pad = (n) => String(n).padStart(2, '0');
26
+
27
+ function changes() {
28
+ const s = home(); if (!s) return [];
29
+ const all = new Map();
30
+ for (const e of [...((s.lastCheck && s.lastCheck.changes) || []), ...(s.latestChanges || []), ...(s.changes || [])]) if (e && e.v && !all.has(e.v)) all.set(e.v, e);
31
+ return [...all.values()].sort((a, b) => cmpVer(b.v, a.v));
32
+ }
33
+ const seg = (label, key, cur, opts) => `<span class="ev-seg" role="group" aria-label="${esc(label)}">${opts.map(([k, w]) => `<button type="button" data-ev-seg="${key}" data-v="${k}" aria-pressed="${cur === k}">${esc(w)}</button>`).join('')}</span>`;
34
+ const trow = (title, sub, right) => `<div class="ev-trow"><div class="ev-tx"><b>${esc(title)}</b>${sub ? `<p class="ev-small ev-mut">${esc(sub)}</p>` : ''}</div>${right}</div>`;
35
+ const sw = (on, attrs, label) => `<button type="button" class="ev-sw" role="switch" aria-checked="${!!on}" aria-label="${esc(label)}" ${attrs}>${on ? 'On' : 'Off'}</button>`;
36
+
37
+ function general() {
38
+ const theme = (() => { const t = store.get('pmos.c3.theme'); return t === 'light' || t === 'dark' ? t : 'auto'; })();
39
+ const vw = store.get(VIEWER_KEY) === 'popup' ? 'popup' : 'column';
40
+ const P = T.prods, on = P ? P.filter((x) => x.on) : null;
41
+ const pname = !P ? 'Reading' : !P.length ? 'No product' : on.length === 1 ? on[0].name : on.length + ' of ' + P.length + ' products';
42
+ const we = T.set && Array.isArray(T.set.settings) ? T.set.settings.find((x) => x.key === 'time.workEnd') : null, end = we ? Number(we.value) : 18;
43
+ const hours = []; for (let h = 13; h <= 23; h++) hours.push(h);
44
+ const upd = ready() ? `<div class="ev-card ev-upd"><span class="ev-pill y">Update</span><p><b>PMOS ${esc(latest())} is ready.</b> <span class="ev-mut">${esc(firstLine())}</span></p><button type="button" class="ev-btn sm" data-ev-go="whatsnew">What's new</button><button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button></div>` : '';
45
+ return trow('Theme', 'Auto follows your computer', seg('Theme', 'theme', theme, [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]))
46
+ + trow('Viewer opens as', 'A column beside the chat, or a popup over it', seg('Viewer opens as', 'viewer', vw, [['column', 'Column'], ['popup', 'Popup']]))
47
+ + trow('Product', 'Which products Home, Board and Insights read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="dialog">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
48
+ + trow('Your day', 'When the end-of-day card shows', `<label class="ev-vh" for="evDay">Your day ends at</label><select id="evDay" class="ev-inp" data-ev-day>${hours.map((h) => `<option value="${h}"${h === end ? ' selected' : ''}>${pad(h)}:00</option>`).join('')}</select>`)
49
+ + trow('Agents write to Jira', 'Only after you press Commit. Never on their own.', '<span class="ev-pill ok">Fixed</span>')
50
+ + upd;
51
+ }
52
+ const firstLine = () => { const c = changes().find((e) => e.v === latest()); const p = c && c.prs && c.prs[0]; return p ? (p.t || p.s || '') : ''; };
53
+ function connectors() {
54
+ if (T.src === null) return '<p class="ev-small ev-mut">Reading the connectors.</p>';
55
+ const brief = Object.keys(SRC).filter((k) => k in T.src).map((k) => trow(SRC[k], T.src[k] ? 'PMOS reads it on its own' : 'PMOS does not read it on its own', sw(T.src[k], `data-ev-src="${k}"`, SRC[k])));
56
+ const more = T.conn.filter((c) => !c.source).map((c) => trow(c.label, T.con[c.name] ? 'On. Your sessions can use it' : 'Your sessions can use it', sw(T.con[c.name], `data-ev-conn="${esc(c.name)}"`, c.label)));
57
+ return '<p class="ev-small ev-mut">Every connector your Claude session has. A switch chooses only what PMOS reads on its own. PMOS reads and never posts.</p>' + brief.join('') + more.join('');
58
+ }
59
+ function workspaces() {
60
+ if (T.ws === null) return '<p class="ev-small ev-mut">Reading the repositories.</p>';
61
+ return '<p class="ev-small ev-mut">A workspace is one repository PMOS works in. Removing one forgets the address only; the folder is not deleted.</p>'
62
+ + T.ws.map((x) => trow(x.label || x.name || x.id, (x.root || '') + (x.home ? ' · home' : ''), x.home ? '<span class="ev-pill">Home</span>' : `<button type="button" class="ev-btn sm" data-ev-rm="${esc(x.id)}">Remove</button>`)).join('')
63
+ + '<div class="ev-add"><label class="ev-vh" for="evRoot">Folder path of a repository</label><input id="evRoot" class="ev-inp" placeholder="Folder path of a repository"><button type="button" class="ev-btn pri" data-ev-add>Add</button></div>';
64
+ }
65
+ function updates() {
66
+ const s = home();
67
+ if (!s) return '<p class="ev-small ev-mut">Reading the versions.</p>';
68
+ const app = (s.app && s.app.version) || '?', L = latest();
69
+ const head = T.phase === 'busy' ? `<b>Updating to ${esc(L)}</b><p class="ev-small ev-mut" role="status" aria-live="polite">${esc(T.say || 'Working.')}</p>`
70
+ : ready() ? `<b>PMOS ${esc(L)} is ready</b><p class="ev-small ev-mut">You have ${esc(app)}.${appBehind() ? ' PMOS stops for about a minute while it installs. Open terminals keep running.' : ''}</p>`
71
+ : L ? `<b>PMOS ${esc(app)} is up to date</b><p class="ev-small ev-mut">${fromGit() && s.appBehind ? esc(L) + ' is published. This PMOS runs from a checkout: update it with git pull.' : 'The newest published kit is ' + esc(L) + '.'}</p>`
72
+ : `<b>PMOS ${esc(app)}</b><p class="ev-small ev-mut">Press Check now to ask for the latest version.</p>`;
73
+ const acts = T.phase === 'busy' ? '' : T.phase === 'confirm' ? '<button type="button" class="ev-btn sm" data-ev-upd="cancel">Cancel</button><button type="button" class="ev-btn sm dark" data-ev-upd="go">Restart and update</button>'
74
+ : `<button type="button" class="ev-btn sm" data-ev-upd="check"${T.busy ? ' disabled' : ''}>Check now</button>${ready() ? `<button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button>` : ''}`;
75
+ const kits = (T.ws || []).map((w) => { const k = T.st[w.id], kit = k && k.kit; return trow(w.label || w.name || w.id, kit && kit.present ? 'kit ' + (kit.version || 'vendored by hand') : 'no kit in this workspace', k && k.kitBehind && L ? `<span class="ev-pill y">${esc(L)} ready</span>` : kit && kit.present && (k.lastCheck || k.latest) ? '<span class="ev-pill ok">Up to date</span>' : ''); }).join('');
76
+ const last = s.lastCheck ? 'Last checked ' + new Date(s.lastCheck.at).toLocaleString() + '. ' : '';
77
+ return `<div class="ev-card ev-upd"><div class="ev-tx ev-grow">${head}</div>${acts}</div>${kits}<p class="ev-small ev-mut">${esc(last)}${s.checkDaily ? 'PMOS checks once a day while a page is open; Check now asks again.' : 'PMOS checks only when you press Check now.'}</p>`;
78
+ }
79
+ function whatsnew() {
80
+ const L = changes(), s = home(), mine = s && s.app && !fromGit() ? s.app.version : null;
81
+ if (!L.length) return '<p class="ev-small ev-mut">No kit summaries yet. Each kit published from now on carries one, and Check now reads the newest ones.</p>';
82
+ return `<ul class="ev-kv">${L.slice(0, 40).map((e) => `<li><b>${esc(e.v)}</b><div class="ev-tx">${mine && e.v === mine ? '<span class="ev-pill">Yours</span> ' : mine && cmpVer(e.v, mine) > 0 ? '<span class="ev-pill y">Newer</span> ' : ''}${(e.prs || []).map((p) => `<p>${esc(p.t && p.t !== p.s ? p.t + ': ' + p.s : p.s)}${p.n ? ' <span class="ev-mut">#' + esc(p.n) + '</span>' : ''}</p>`).join('') || '<p class="ev-mut">No summary was recorded for this kit.</p>'}</div></li>`).join('')}</ul>`;
83
+ }
84
+ const BODY = { general, connectors, workspaces, updates, whatsnew };
85
+ function draw() {
86
+ const el = T.el; if (!el || el.hidden) return;
87
+ // a redraw replaces the nodes: keep focus on the same control (by its data-ev-* key), else on the open section, never on the body
88
+ const ae = document.activeElement, had = ae && el.contains(ae), key = had ? [...ae.attributes].find((a) => a.name.startsWith('data-ev-')) : null;
89
+ const n = { connectors: T.src === null ? '' : Object.keys(SRC).filter((k) => T.src[k]).length + T.conn.filter((c) => !c.source && T.con[c.name]).length, workspaces: T.ws ? T.ws.length : '', updates: ready() ? '<span class="ev-pill y">1</span>' : '' };
90
+ el.querySelector('.ev-st-nav').innerHTML = '<h2 class="ev-h2">Settings</h2>' + SECTIONS.map(([k, l]) => `<a href="#${k}" class="ev-mi" data-ev-sec="${k}"${T.sec === k ? ' aria-current="page"' : ''}>${esc(l)}${n[k] !== undefined && n[k] !== '' ? `<span class="ev-k">${typeof n[k] === 'number' ? n[k] : n[k]}</span>` : ''}</a>`).join('');
91
+ const label = (SECTIONS.find((x) => x[0] === T.sec) || SECTIONS[0])[1];
92
+ el.querySelector('.ev-st-main').innerHTML = `<div class="ev-top"><h3 class="ev-h2" id="evStTitle">${esc(label)}</h3><button type="button" class="ev-ib" data-ev-close aria-label="Close settings" title="Close settings">${svg(ICON.close, 18)}</button></div>`
93
+ + BODY[T.sec]() + `<p role="status">${esc(T.msg)}</p>`;
94
+ if (had && !ae.isConnected) { const f = (key && el.querySelector(`[${key.name}="${CSS.escape(key.value)}"]`)) || el.querySelector('[aria-current="page"]'); if (f) f.focus(); }
95
+ }
96
+ function mount() {
97
+ if (T.el && T.el.isConnected) return T.el;
98
+ const d = document.createElement('div');
99
+ d.innerHTML = '<div class="ev-st-scrim" id="evStScrim" hidden></div><div class="ev-st" id="evSettings" role="dialog" aria-modal="true" aria-label="Settings" hidden><nav class="ev-st-nav" aria-label="Settings sections"></nav><div class="ev-st-main"></div></div>';
100
+ document.body.append(...d.childNodes);
101
+ T.el = document.getElementById('evSettings');
102
+ document.getElementById('evStScrim').addEventListener('click', closeSettings);
103
+ T.el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeSettings(); } });
104
+ // the dialog is modal: Escape closes it even when focus is outside it (a click on the scrim's edge, a redraw)
105
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && T.el && !T.el.hidden && !T.el.contains(e.target)) { e.preventDefault(); e.stopPropagation(); closeSettings(); } }, true);
106
+ T.el.addEventListener('change', async (e) => {
107
+ if (!e.target.matches('[data-ev-day]')) return;
108
+ const r = await pmPost('/api/settings', { key: 'time.workEnd', value: Number(e.target.value) });
109
+ T.msg = r && r.ok ? 'Saved. The end-of-day card shows from ' + pad(Number(e.target.value)) + ':00.' : (r && r.error) || 'Not saved.';
110
+ const we = r && r.ok && T.set && Array.isArray(T.set.settings) ? T.set.settings.find((x) => x.key === 'time.workEnd') : null; if (we) we.value = Number(e.target.value);
111
+ draw();
112
+ });
113
+ T.el.addEventListener('click', press);
114
+ return T.el;
115
+ }
116
+ async function press(e) {
117
+ const t = e.target.closest('a[data-ev-sec], button'); if (!t) return;
118
+ if (t.dataset.evSec) { e.preventDefault(); T.sec = t.dataset.evSec; T.msg = ''; draw(); const f = T.el.querySelector(`[data-ev-sec="${T.sec}"]`); if (f) f.focus(); return; }
119
+ if ('evClose' in t.dataset) { closeSettings(); return; }
120
+ if (t.dataset.evGo) { T.sec = t.dataset.evGo; draw(); return; }
121
+ if (t.dataset.evSeg === 'theme') { const M = await import('./cozy-nav.js'); M.setTheme(t.dataset.v); draw(); return; }
122
+ if (t.dataset.evSeg === 'viewer') { store.set(VIEWER_KEY, t.dataset.v); document.body.classList.toggle('ev-vw-popup', t.dataset.v === 'popup'); draw(); return; }
123
+ if ('evProducts' in t.dataset) { closeSettings(); import('./home-more.js').then((M) => M.openProducts()); return; }
124
+ if (T.busy) return;
125
+ T.busy = true; T.msg = '';
126
+ try {
127
+ if (t.dataset.evSrc) { const k = t.dataset.evSrc, on = !T.src[k]; const r = await pmPost('/api/proactive/settings', { briefSources: { [k]: on } }); if (r && r.ok) T.src[k] = on; else T.msg = (r && r.error) || 'Not saved.'; }
128
+ else if (t.dataset.evConn) { const k = t.dataset.evConn, on = !T.con[k]; const r = await pmPost('/api/proactive/settings', { connectors: { [k]: on } }); if (r && r.ok) T.con[k] = on; else T.msg = (r && r.error) || 'Not saved.'; }
129
+ else if ('evAdd' in t.dataset) {
130
+ const root = (T.el.querySelector('#evRoot').value || '').trim();
131
+ if (!root) T.msg = 'Paste the folder path of a repository.';
132
+ else { const r = await pmPost('/api/workspaces', { root, focus: false }); if (r && r.ok) { T.ws = [...T.ws.filter((y) => y.id !== r.workspace.id), r.workspace]; toast('Added.'); } else T.msg = (r && r.error) || 'Not added.'; }
133
+ } else if (t.dataset.evRm) { const r = await pmPost('/api/workspaces/forget', { id: t.dataset.evRm }); if (r && r.ok) { T.ws = T.ws.filter((y) => y.id !== t.dataset.evRm); toast('Removed. The folder is untouched.'); } else T.msg = (r && (r.error || r.reason)) || 'Not removed.'; }
134
+ else if (t.dataset.evUpd) await upd(t.dataset.evUpd);
135
+ } finally { T.busy = false; }
136
+ draw();
137
+ }
138
+ async function upd(a) {
139
+ if (a === 'cancel') { T.phase = ''; return; }
140
+ if (a === 'check') {
141
+ for (const w of T.ws || []) { const r = await pmPost('/api/kit/check', { ws: w.id }); if (r && r.ok) T.st[w.id] = { ...(T.st[w.id] || {}), ...r }; else T.msg = (r && r.error) || 'The check failed.'; }
142
+ if (!T.msg) toast(ready() ? 'PMOS ' + latest() + ' is ready' : 'Checked. PMOS is up to date');
143
+ return;
144
+ }
145
+ if (a === 'update' && appBehind()) { T.sec = 'updates'; T.phase = 'confirm'; return; }
146
+ const v = latest(); T.sec = 'updates'; T.phase = 'busy';
147
+ for (const w of kitsBehind()) {
148
+ T.say = 'Updating the kit in ' + (w.label || w.name || w.id) + '.'; draw();
149
+ const r = await pmPost('/api/kit/update', { ws: w.id, version: v });
150
+ if (!(r && r.ok)) { T.phase = ''; T.msg = (r && r.error) || 'The kit was not updated.'; return; }
151
+ T.st[w.id] = { ...T.st[w.id], ...r, kitBehind: false };
152
+ }
153
+ if (!appBehind()) { T.phase = ''; toast('Updated the kits to ' + v + '.'); return; }
154
+ T.say = 'Installing PMOS ' + v + '. This page reloads when the new version starts.'; draw();
155
+ const from = home() && home().app && home().app.version;
156
+ const r = await pmPost('/api/kit/upgrade-app', { ws: T.ws[0].id, version: v });
157
+ if (!r || r.ok === false) { T.phase = ''; T.msg = (r && r.error) || 'The update did not start.'; return; }
158
+ waitRestart(from, r.log || 'the update log');
159
+ }
160
+ /** The app update stops this server and starts a new one: wait for it, then reload. */
161
+ async function waitRestart(from, log) {
162
+ let down = false; const until = Date.now() + 5 * 60000;
163
+ while (Date.now() < until) {
164
+ await new Promise((ok) => setTimeout(ok, 2000));
165
+ const j = await pmGet('/api/sessions').catch(() => null);
166
+ if (!j || j.ok === false || !j.version) { down = true; continue; }
167
+ if (j.version !== from) { location.reload(); return; }
168
+ if (down) { T.phase = ''; T.msg = 'PMOS started again on ' + j.version + ', so the update did not finish. The update log is ' + log + '.'; draw(); return; }
169
+ }
170
+ T.phase = ''; T.msg = 'PMOS did not come back on this address. Type pmos in a terminal to open it. The update log is ' + log + '.'; draw();
171
+ }
172
+ async function load() {
173
+ const [w, p, s, b] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings'), pmGet('/api/settings'), pmGet('/api/briefing-premium')]);
174
+ T.ws = w && Array.isArray(w.workspaces) ? w.workspaces : [];
175
+ T.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {}; T.con = p && p.ok && p.settings ? { ...p.settings.connectors } : {};
176
+ T.conn = p && p.connectors && Array.isArray(p.connectors.list) ? p.connectors.list : [];
177
+ T.set = s && s.ok ? s : null;
178
+ T.prods = b && b.ok && b.model && b.model.products ? b.model.products.available || [] : [];
179
+ if (!w || !Array.isArray(w.workspaces)) T.msg = 'The repositories could not be read.'; else if (!p || !p.ok) T.msg = 'The connectors could not be read.';
180
+ draw();
181
+ await Promise.all(T.ws.map(async (x) => { const r = await pmGet('/api/kit/status?ws=' + encodeURIComponent(x.id)); if (r && r.ok) T.st[x.id] = r; }));
182
+ draw();
183
+ }
184
+ export function openSettings(section) {
185
+ const el = mount();
186
+ if (section && BODY[section]) T.sec = section;
187
+ if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; }
188
+ el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
189
+ draw();
190
+ const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();
191
+ load();
192
+ return el;
193
+ }
194
+ export function closeSettings() {
195
+ if (!T.el || T.el.hidden) return;
196
+ T.el.hidden = true; document.getElementById('evStScrim').hidden = true; T.el.removeAttribute('data-esc-layer');
197
+ const b = T.back; T.back = null; if (b && b.isConnected) { try { b.focus(); } catch { /* gone */ } }
198
+ }