create-pmos 0.267.0 → 0.269.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.
@@ -0,0 +1,217 @@
1
+ /* pm/premium-studio.js — the Insight Studio on the premium Insights page, part 1: dashboards (initiative premium-studio-dashboard).
2
+ * The mockup's Studio (prototype/premium-ux-concept/build-src/stu.js.txt) in its Dashboard mode: a conversation on the left, and on the right a brief of
3
+ * chips, a library, a live preview and checks. A turn changes the draft in the page and writes nothing. The one write is Save (or Remove), through the
4
+ * existing POST /api/premium-dashboards/save behind the launch nonce. Every title and chart comes from the page's model: the KR metric records and the
5
+ * board's saved dashboards. No demo measure is drawn.
6
+ *
7
+ * openStudio(P) P = { M, D (the saved dashboard to edit, or null), tile (the page's chart tile), save (body → answer), done (saved id | null) } */
8
+ import { $, esc, openDlg, closeDlg, toast, turnA, turnU, ptx, setFull } from './premium-shell.js';
9
+
10
+ const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
11
+ const UPI = ICO('<path d="M12 19V5M6 11l6-6 6 6"/>'), DNI = ICO('<path d="M12 5v14M6 13l6 6 6-6"/>'), XI = ICO('<path d="M6 6l12 12M18 6 6 18"/>');
12
+ const OKI = ICO('<path d="M5 12.5l4.5 4.5L19 7.5"/>'), WRN = ICO('<path d="M12 4 2.5 20h19z"/><path d="M12 10v4M12 17v.5"/>'), CHV = ICO('<path d="M6 9l6 6 6-6"/>');
13
+ const DSI = ICO('<rect x="3" y="3" width="8" height="8" rx="2"/><rect x="13" y="3" width="8" height="8" rx="2"/><rect x="3" y="13" width="8" height="8" rx="2"/><rect x="13" y="13" width="8" height="8" rx="2"/>');
14
+ const MAX_UNDO = 30;
15
+
16
+ let P = null; // the page's hand: { M, D, tile, save, done }
17
+ let st = null; // the Studio: { d: draft, h: undo stack, pop, lib, ck, msg, armed, busy }
18
+
19
+ const measures = () => P.M.measures || [];
20
+ const chartOf = (id) => (P.M.charts || []).find((c) => c.id === id) || null;
21
+ const titleOf = (id) => { const m = measures().find((x) => x.id === id); return m ? m.title : id; };
22
+ const savedDash = () => (P.M.dashboards || []).filter((x) => x.saved);
23
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
24
+
25
+ /* ── the draft and its undo ── */
26
+ const snap = () => { const h = st.h, cur = JSON.stringify(st.d); if (h.length && h[h.length - 1] === cur) return; h.push(cur); if (h.length > MAX_UNDO) h.shift(); };
27
+ const undo = () => { if (!st.h.length) return false; st.d = JSON.parse(st.h.pop()); return true; };
28
+ const blank = () => ({ id: null, name: '', use: '', charts: [], main: false });
29
+
30
+ /* ── the canvas ── */
31
+ const chip = (k, l, v) => `<button type="button" class="suc${st.pop === k ? ' on' : ''}${v === 'Not set' ? ' req' : ''}" data-st="chip|${k}" aria-expanded="${st.pop === k}"><em>${esc(l)}</em><b>${esc(v)}</b></button>`;
32
+ function briefHtml() {
33
+ const d = st.d;
34
+ return `<div class="stbr" role="group" aria-label="Brief">${chip('name', 'Name', d.name || 'Not set')}${chip('use', 'Purpose', d.use || 'Not set')}${chip('charts', 'Charts', String(d.charts.length))}${chip('main', 'Main dashboard', d.main ? 'Yes' : 'No')}</div>`;
35
+ }
36
+ const opt = (act, l, sub, on) => `<button type="button" class="sto" data-st="${act}" aria-pressed="${!!on}"><b>${esc(l)}</b>${sub ? `<small>${esc(sub)}</small>` : ''}</button>`;
37
+ const field = (f, v, ph, max) => `<input class="sti" id="stI" data-stf="${f}" value="${esc(v)}" placeholder="${esc(ph)}" maxlength="${max}" aria-label="${esc(ph)}" autocomplete="off">`;
38
+ function trayHtml() {
39
+ const p = st.pop, d = st.d; if (!p) return '';
40
+ let h = '';
41
+ if (p === 'name') h = field('name', d.name, 'For example: Weekly partner review', 60);
42
+ else if (p === 'use') h = field('use', d.use, 'What routine is this for?', 200);
43
+ else if (p === 'main') h = `<div class="sol">${opt('set|main|1', 'Yes', 'It opens first on this board. One dashboard is main.', d.main)}${opt('set|main|0', 'No', 'Keep it as another dashboard', !d.main)}</div>`;
44
+ else if (p === 'charts') {
45
+ h = (d.charts.length ? `<ul class="sul">${d.charts.map((id, i) => `<li><span>${esc(titleOf(id))}${chartOf(id) ? '' : '<small>No series yet</small>'}</span><span class="stlc"><button type="button" data-st="mv|${i}|-1" aria-label="Move ${esc(titleOf(id))} up"${i ? '' : ' disabled'}>${UPI}</button><button type="button" data-st="mv|${i}|1" aria-label="Move ${esc(titleOf(id))} down"${i < d.charts.length - 1 ? '' : ' disabled'}>${DNI}</button><button type="button" data-st="rm|${i}" aria-label="Remove ${esc(titleOf(id))}">${XI}</button></span></li>`).join('')}</ul>` : '<p class="note">No charts yet.</p>')
46
+ + '<button type="button" class="dmcta alt" data-st="lib">Add from the library</button>';
47
+ }
48
+ return h ? `<div class="sup" role="group" aria-label="Change this">${h}<button type="button" class="lk stdone" data-st="chip|${p}">Done</button></div>` : '';
49
+ }
50
+ const W = 96, H = 30;
51
+ function spark(c) {
52
+ if (!c) return '<span class="stlic" aria-hidden="true"></span>';
53
+ const d = c.pts.map((p, i) => (i ? 'L' : 'M') + (2 + p.fx * (W - 4)).toFixed(1) + ',' + (2 + (1 - p.fy) * (H - 4)).toFixed(1)).join('');
54
+ return `<svg class="spk" viewBox="0 0 ${W} ${H}" aria-hidden="true"><path d="${d}"/></svg>`;
55
+ }
56
+ function libHtml() {
57
+ if (!st.lib) return '';
58
+ const d = st.d, L = measures(), S = savedDash().filter((x) => x.id !== d.id);
59
+ const rows = L.map((m) => { const on = d.charts.includes(m.id), c = chartOf(m.id); return `<button type="button" class="stli" data-st="libc|${esc(m.id)}"${on ? ' disabled' : ''}>${spark(c)}<span><b>${esc(m.title)}</b><small>${esc(c ? c.sub : 'No series yet')}</small></span><em>${on ? 'Added' : 'Add'}</em></button>`; }).join('');
60
+ const dl = S.map((x) => `<button type="button" class="stli" data-st="libd|${esc(x.id)}"><span class="stlic">${DSI}</span><span><b>${esc(x.name)}</b><small>${plural(x.charts.length, 'chart', 'charts')}</small></span><em>Add its charts</em></button>`).join('');
61
+ return `<div class="stlib" role="region" aria-label="Library of ${esc(P.M.board.name || 'this board')}"><div class="stlh"><b>Library</b><small>${esc(P.M.board.name || '')}</small><button type="button" class="lk" data-st="lib">Close</button></div>`
62
+ + `<p class="label">Measures · ${L.length}</p>${L.length ? `<div class="stlg">${rows}</div>` : '<p class="note">No KR metric is recorded for this workspace.</p>'}`
63
+ + (dl ? `<p class="label">Dashboards · ${S.length}</p><div class="stlg">${dl}</div>` : '') + '</div>';
64
+ }
65
+ function previewHtml() {
66
+ const d = st.d, L = d.charts.map(chartOf).filter(Boolean), gone = d.charts.filter((id) => !chartOf(id));
67
+ return `<div class="stpvw"><h3 class="ndt">${esc(d.name || 'Untitled dashboard')}${d.main ? '<span class="npin2">Main dashboard</span>' : ''}</h3><p class="mut stuse">${esc(d.use || 'No purpose yet.')}</p>`
68
+ + (L.length ? `<div class="ngrid">${L.map((c) => `<div class="ntw">${P.tile(c)}</div>`).join('')}</div>` : '<p class="note">No chart is drawn yet. Add a measure with a series.</p>')
69
+ + (gone.length ? `<p class="label ngl">Not drawn · ${gone.length}</p>${gone.map((id) => `<p class="note stgone"><b>${esc(titleOf(id))}</b> has fewer than two readings, so it has no chart.</p>`).join('')}` : '') + '</div>';
70
+ }
71
+ /* The six checks of the mockup, computed from the draft. A fix is an action the Studio can take in one press. */
72
+ function checks() {
73
+ const d = st.d, dup = d.charts.length - new Set(d.charts).size, other = savedDash().some((x) => x.main && x.id !== d.id);
74
+ return [
75
+ { ok: !!d.name.trim(), l: 'It has a name', d: d.name.trim() || 'Give it a name.', fix: ['Name it', 'chip|name'] },
76
+ { ok: !!d.use.trim(), l: 'It says what routine it serves', d: d.use.trim() || 'A dashboard without a purpose collects charts.', fix: ['Say the purpose', 'chip|use'] },
77
+ { ok: d.charts.length > 0, l: 'It has a chart', d: plural(d.charts.length, 'chart', 'charts') + '.', fix: ['Open the library', 'lib'] },
78
+ { ok: d.charts.length <= 6, l: 'Six charts or fewer', d: d.charts.length > 6 ? d.charts.length + ' charts. Past six, readers stop looking at each one.' : 'The count is easy to scan.', fix: ['Choose which to keep', 'chip|charts'] },
79
+ { ok: !dup, l: 'No measure appears twice', d: dup ? plural(dup, 'measure is', 'measures are') + ' drawn twice.' : 'Each measure appears once.', fix: ['Take out the repeats', 'dedup'] },
80
+ { ok: d.main || other, l: 'The board has a main dashboard', d: d.main || other ? 'One dashboard opens first.' : 'No dashboard opens first on this board.', fix: ['Make it the main one', 'set|main|1'] },
81
+ ];
82
+ }
83
+ function checksHtml() {
84
+ const L = checks(), bad = L.filter((x) => !x.ok), n = L.length - bad.length;
85
+ return `<div class="suck${bad.length ? ' bad' : ''}"><button type="button" class="suckb" data-st="ck" aria-expanded="${st.ck}">${bad.length ? WRN : OKI}<b>${n} of ${L.length} checks pass</b>${bad.length && !st.ck ? `<span>${esc(bad[0].d)}</span>` : ''}${CHV}</button>`
86
+ + `<div class="mprog stbar" role="progressbar" aria-label="Checks passing" aria-valuemin="0" aria-valuemax="${L.length}" aria-valuenow="${n}" data-n="${n}"><b></b></div>`
87
+ + (st.ck ? `<ul class="sucl">${L.map((x, i) => `<li class="${x.ok ? 'ok' : 'bad'}">${x.ok ? OKI : WRN}<span><b>${esc(x.l)}</b><small>${esc(x.d)}</small></span>${!x.ok && x.fix ? `<button type="button" class="dmcta alt" data-st="fix|${i}">${esc(x.fix[0])}</button>` : ''}</li>`).join('')}</ul>` : '') + '</div>';
88
+ }
89
+ function footHtml() {
90
+ const saved = !!st.d.id;
91
+ return `<div class="stft"><button type="button" class="dmcta alt" data-st="undo"${st.h.length ? '' : ' disabled'}>Undo</button>${saved ? `<button type="button" class="dmcta alt" data-st="del">${st.armed ? 'Press again to remove it' : 'Remove the dashboard'}</button>` : ''}<span class="sp"></span><button type="button" class="dmcta alt" data-st="cancel">Cancel</button><button type="button" class="dmcta" data-st="save"${st.busy ? ' disabled' : ''}>${saved ? 'Save changes' : 'Save the dashboard'}</button></div>`;
92
+ }
93
+ const guide = () => 'A dashboard answers one routine. Give it a purpose and keep it to six charts or fewer.' + (st.d.id ? ' <button type="button" class="lk" data-st="new">Start a new one instead</button>' : '');
94
+ function canvasHtml() {
95
+ return `<div class="stu"><div class="stt"><span class="stx"><button type="button" class="lk" data-st="lib" aria-expanded="${st.lib}">Library</button></span></div><p class="stsug" id="stG">${guide()}</p><div id="stBr">${briefHtml()}</div><div id="stTr">${trayHtml()}</div><div id="stLb">${libHtml()}</div><div id="stPv">${previewHtml()}</div><div id="stCk">${checksHtml()}</div><p class="note stmsg" id="stMsg" role="status"></p><div id="stFt">${footHtml()}</div></div>`;
96
+ }
97
+ function draw(parts) {
98
+ const all = !parts, set = (id, h) => { const e = $('#' + id); if (e) e.innerHTML = h; };
99
+ if (all || parts.includes('g')) set('stG', guide());
100
+ if (all || parts.includes('br')) set('stBr', briefHtml());
101
+ if (all || parts.includes('tr')) set('stTr', trayHtml());
102
+ if (all || parts.includes('lb')) set('stLb', libHtml());
103
+ if (all || parts.includes('pv')) set('stPv', previewHtml());
104
+ if (all || parts.includes('ck')) set('stCk', checksHtml());
105
+ if (all || parts.includes('ft')) set('stFt', footHtml());
106
+ const m = $('#stMsg'); if (m) m.textContent = st.msg;
107
+ const l = $('.stu [data-st="lib"]'); if (l) l.setAttribute('aria-expanded', st.lib);
108
+ }
109
+
110
+ /* ── doing things ── */
111
+ function act(a) {
112
+ const [k, x, y] = a; st.msg = '';
113
+ if (k !== 'del') st.armed = false;
114
+ if (k === 'chip') { st.pop = st.pop === x ? null : x; draw(['br', 'tr', 'ft']); const i = $('#stI'); if (i) { i.focus(); try { i.setSelectionRange(i.value.length, i.value.length); } catch { /* no caret */ } } return; }
115
+ if (k === 'lib') { st.lib = !st.lib; draw(['lb', 'tr', 'ft']); return; }
116
+ if (k === 'ck') { st.ck = !st.ck; draw(['ck']); return; }
117
+ if (k === 'fix') { const f = checks()[+x]; if (f && f.fix) act(f.fix[1].split('|')); return; }
118
+ if (k === 'undo') { if (undo()) { st.pop = null; draw(); } return; }
119
+ if (k === 'cancel') { closeDlg(); return; }
120
+ if (k === 'save') { save(); return; }
121
+ if (k === 'del') { remove(); return; }
122
+ if (k === 'new') { snap(); st.d = blank(); st.pop = null; draw(); return; }
123
+ if (k === 'set' && x === 'main') { snap(); st.d.main = y === '1'; st.pop = null; draw(); return; }
124
+ if (k === 'dedup') { snap(); st.d.charts = st.d.charts.filter((id, i) => st.d.charts.indexOf(id) === i); draw(); return; }
125
+ if (k === 'mv') { const i = +x, j = i + +y, c = st.d.charts; if (j < 0 || j >= c.length) return; snap(); [c[i], c[j]] = [c[j], c[i]]; draw(); const b = $(`#stTr [data-st="mv|${j}|${y}"]`) || $(`#stTr [data-st="mv|${j}|${-y}"]`); if (b) b.focus(); return; }
126
+ if (k === 'rm') { snap(); st.d.charts.splice(+x, 1); draw(); return; }
127
+ if (k === 'libc') { if (st.d.charts.includes(x)) return; snap(); st.d.charts.push(x); draw(); return; }
128
+ if (k === 'libd') { const D = savedDash().find((q) => q.id === x); if (!D) return; snap(); D.charts.forEach((id) => { if (!st.d.charts.includes(id)) st.d.charts.push(id); }); draw(); }
129
+ }
130
+ let typed = false; // one undo step per text field edit, not per key
131
+ function onInput(e) {
132
+ const f = e.target.dataset && e.target.dataset.stf; if (!f) return;
133
+ if (!typed) { snap(); typed = true; }
134
+ st.d[f] = e.target.value; st.msg = ''; draw(['g', 'br', 'pv', 'ck', 'ft']);
135
+ }
136
+ async function save() {
137
+ const d = st.d, name = d.name.trim(), use = d.use.trim();
138
+ if (!name) { st.msg = 'Give the dashboard a name.'; draw(['ft']); return; }
139
+ if (!use) { st.msg = 'Say what the dashboard is for, in one line.'; draw(['ft']); return; }
140
+ st.busy = true; st.msg = 'Saving.'; draw(['ft']);
141
+ const res = await P.save({ id: d.id || undefined, name, purpose: use, charts: d.charts, main: d.main });
142
+ st.busy = false;
143
+ if (!res || res.ok !== true) { st.msg = (res && res.error) || 'The dashboard could not be saved.'; draw(['ft']); return; }
144
+ closeDlg(); toast('Dashboard "' + name + '" saved in the workspace\'s state folder.'); P.done(res.dashboard ? res.dashboard.id : d.id);
145
+ }
146
+ async function remove() {
147
+ if (!st.armed) { st.armed = true; st.msg = 'Removing takes the dashboard off this board. The measures and their records stay.'; draw(['ft']); return; }
148
+ st.busy = true; draw(['ft']);
149
+ const res = await P.save({ id: st.d.id, remove: true });
150
+ st.busy = false;
151
+ if (!res || res.ok !== true) { st.armed = false; st.msg = (res && res.error) || 'The dashboard could not be removed.'; draw(['ft']); return; }
152
+ closeDlg(); toast('Dashboard removed. The line is saved in the workspace\'s state folder.'); P.done(null);
153
+ }
154
+
155
+ /* ── the conversation: the phrases the Studio understands. A turn changes the draft only; it writes nothing and starts no agent. ── */
156
+ const HELP = 'I understand: add or remove a measure by its name, move a measure up, down or first, call it something, it is for something, make it the main dashboard (or not), undo, and start a new one.';
157
+ const clean = (s) => s.trim().replace(/^["']|["']$/g, '').replace(/[.\s]+$/, '').trim();
158
+ function hits(low) { return measures().map((m) => ({ m, i: low.indexOf(m.title.toLowerCase()) })).filter((x) => x.i >= 0 && x.m.title).sort((a, b) => a.i - b.i || b.m.title.length - a.m.title.length); }
159
+ function command(text) {
160
+ const t = text.trim(), low = t.toLowerCase(), d = st.d, said = [];
161
+ if (/^undo\b/.test(low)) return undo() ? (st.pop = null, 'Done: one step undone.') : 'I changed nothing. There is nothing to undo.';
162
+ if (/\b(start (a )?new|new dashboard|start over)\b/.test(low)) { snap(); st.d = blank(); return 'Done: a new, empty dashboard. Name it and say what it is for.'; }
163
+ const before = JSON.stringify(d); snap();
164
+ const nm = t.match(/(?:call it|name it|rename it to|rename it|called|named)\s+(.+?)(?=,|;|\s+and\s+(?:it|make|add|remove|for)\b|$)/i);
165
+ if (nm && clean(nm[1])) { d.name = clean(nm[1]).slice(0, 60); said.push('named it "' + d.name + '"'); }
166
+ const us = t.match(/(?:(?:it is|it's|its purpose is|purpose is|purpose:|use it)\s+for|purpose[:\s]+)\s*(.+?)(?=;|$)/i);
167
+ if (us && clean(us[1])) { d.use = clean(us[1]).slice(0, 200); said.push('the purpose is "' + d.use + '"'); }
168
+ if (/\b(not|no longer|don't make it|do not make it)\b[^.]*\bmain\b/.test(low)) { if (d.main) { d.main = false; said.push('it is not the main dashboard'); } }
169
+ else if (/\bmain\b/.test(low) && /\b(make|set|mark|as)\b/.test(low)) { if (!d.main) { d.main = true; said.push('it is the main dashboard'); } }
170
+ const H = hits(low), verbs = H.reduce((v, x) => v.split(x.m.title.toLowerCase()).join(' '), low); // the verbs, read with the measures' names taken out ("Time to first call" is not "first")
171
+ if (H.length && /\b(remove|take off|take out|drop|delete|without)\b/.test(verbs)) {
172
+ H.forEach(({ m }) => { const i = d.charts.indexOf(m.id); if (i >= 0) { d.charts.splice(i, 1); said.push('removed ' + m.title); } });
173
+ } else if (H.length && /\b(move|put|first|top|up|down|last|bottom)\b/.test(verbs)) {
174
+ const m = H[0].m, i = d.charts.indexOf(m.id);
175
+ if (i >= 0) {
176
+ const j = /\b(first|top)\b/.test(verbs) ? 0 : /\b(last|bottom)\b/.test(verbs) ? d.charts.length - 1 : /\bup\b/.test(verbs) ? Math.max(0, i - 1) : Math.min(d.charts.length - 1, i + 1);
177
+ if (j !== i) { d.charts.splice(i, 1); d.charts.splice(j, 0, m.id); said.push('moved ' + m.title + ' to place ' + (j + 1)); }
178
+ }
179
+ } else if (H.length && /\b(add|include|show|put in|with)\b/.test(verbs)) {
180
+ H.forEach(({ m }) => { if (!d.charts.includes(m.id)) { d.charts.push(m.id); said.push('added ' + m.title + (chartOf(m.id) ? '' : ' (it has no series yet, so it is listed, not drawn)')); } });
181
+ }
182
+ if (JSON.stringify(d) === before) { st.h.pop(); return 'I changed nothing. ' + (H.length || !/\b(add|remove)\b/.test(low) ? HELP : 'No measure of this board has that name. Open the Library to see them.'); }
183
+ st.pop = null;
184
+ return 'Done: ' + said.join(', ') + '.';
185
+ }
186
+ function onSay(e) {
187
+ e.preventDefault(); e.stopPropagation();
188
+ const inp = $('#stIn'), text = inp.value.trim(); if (!text) return;
189
+ inp.value = ''; const answer = command(text);
190
+ const s = $('#dBody .stream'); if (s) { s.insertAdjacentHTML('beforeend', turnU(text) + turnA(ptx(answer))); s.scrollTop = s.scrollHeight; }
191
+ draw();
192
+ }
193
+
194
+ /* ── opening ── */
195
+ export function openStudio(p) {
196
+ P = p; typed = false;
197
+ const D = p.D;
198
+ st = { d: D ? { id: D.id, name: D.name, use: D.purpose || '', charts: D.charts.slice(), main: !!D.main } : blank(), h: [], pop: null, lib: !D, ck: false, msg: '', armed: false, busy: false };
199
+ const board = p.M.board.name || 'this board';
200
+ const say = D ? 'This is "' + D.name + '". Tell me what to change: measures to add or remove, a new purpose, or make it the main dashboard. Nothing is saved until you press Save.'
201
+ : 'Name the dashboard and say what it is for. Then add measures from the library, or tell me which. Nothing is saved until you press Save.';
202
+ openDlg({ eye: 'Insight Studio · ' + board, title: 'Insight Studio', sub: 'Make a dashboard from ' + board + '. Say it, or use the brief.', stream: turnA(ptx(say)), noteKey: null, pane: canvasHtml(), label: 'Dashboard' });
203
+ $('#dlg').classList.add('stud');
204
+ $('#askF').hidden = true; const an = $('#askNote'); if (an) an.hidden = true;
205
+ $('#dBody').insertAdjacentHTML('beforeend', `<form class="askbar" id="stF"><input id="stIn" placeholder="Say what to change" maxlength="400" autocomplete="off" aria-label="Say what to change in the dashboard"><button type="submit" aria-label="Send" title="Send">${ICO('<path d="M5 12h14M13 6l6 6-6 6"/>')}</button></form><p class="fine2">${esc(HELP)} Nothing is saved until you press Save.</p>`);
206
+ $('#stF').onsubmit = onSay;
207
+ if (innerWidth >= 1000) setFull(true);
208
+ draw();
209
+ }
210
+ /* The Studio's presses. The dialog is shared, so each listener first asks whether the Studio is what it holds. */
211
+ const inStudio = (e) => $('#dlg').classList.contains('stud') && $('#dlg').classList.contains('on') && e.target.closest('#oMain');
212
+ document.addEventListener('click', (e) => { if (!inStudio(e)) return; const t = e.target.closest('[data-st]'); if (t && !t.disabled) act(t.dataset.st.split('|')); });
213
+ document.addEventListener('input', (e) => { if (inStudio(e)) onInput(e); });
214
+ document.addEventListener('focusout', (e) => { if (e.target && e.target.id === 'stI') typed = false; });
215
+ document.addEventListener('keydown', (e) => { if (e.key === 'Enter' && e.target.id === 'stI' && inStudio(e)) { e.preventDefault(); st.pop = null; typed = false; draw(['br', 'tr']); } });
216
+ /* Another dialog of the page opens without the Studio's class. */
217
+ new MutationObserver(() => { const d = $('#dlg'); if (d && !d.classList.contains('on') && d.classList.contains('stud')) d.classList.remove('stud'); }).observe($('#dlg'), { attributes: true, attributeFilter: ['class'] });
@@ -826,6 +826,77 @@ a.round{color:inherit;text-decoration:none}
826
826
  .addf .cact{display:flex;flex-wrap:wrap;gap:10px}.addf .note[role="status"]{margin:0;min-height:1.2em}
827
827
  @media (max-width:760px){.inirw>.ini2{padding-right:48px}.baiact .dmcta,.lifeb .dmcta,.baa .dmcta{height:44px}.baa .baact .dmcta{flex:1;justify-content:center}.bapl button{min-height:44px}}
828
828
 
829
+ /* ── Insight Studio (initiative premium-studio-dashboard): the mockup's Dashboard mode; brief, tray, library, preview, checks and footer ── */
830
+ #dlg.stud .p-out .obody{padding-bottom:0}
831
+ .stu{display:grid;gap:12px;min-width:0}
832
+ .stt{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}
833
+ #dlg.stud #askF,#dlg.stud #askNote{display:none}
834
+ .stx{display:flex;align-items:center;gap:12px}
835
+ .stx .lk,.stlh .lk,.stdone{min-height:44px;padding:0 10px;font-size:13px}
836
+ .stsug{margin:0;font-size:13.5px;color:var(--ink-2);line-height:1.5;padding:0 2px}
837
+ .stbr{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px}
838
+ .suc{display:grid;gap:2px;align-content:center;min-height:52px;padding:8px 12px;border-radius:14px;background:var(--well);box-shadow:inset 0 0 0 1px var(--hair);max-width:100%;text-align:left;transition:background .2s}
839
+ .suc em{font-style:normal;font-size:11px;font-weight:600;color:var(--ink-3);white-space:nowrap}
840
+ .suc b{font-size:14px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
841
+ .suc.on{background:var(--solid);color:var(--on-solid)}
842
+ .suc.on em{color:color-mix(in oklab,var(--on-solid) 70%,transparent)}
843
+ .suc.req{box-shadow:inset 0 0 0 1.5px color-mix(in oklab,var(--ember) 60%,transparent)}
844
+ .sup{padding:14px;border-radius:18px;background:var(--well);display:grid;gap:10px}
845
+ .stdone{justify-self:end}
846
+ .sol{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:8px}
847
+ .sto{display:grid;gap:2px;text-align:left;padding:10px 12px;border-radius:14px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);align-content:start;min-height:44px}
848
+ .sto b{font-size:13.5px}
849
+ .sto small{font-size:12px;color:var(--ink-3);line-height:1.35}
850
+ .sto[aria-pressed="true"]{box-shadow:inset 0 0 0 2px var(--ink)}
851
+ .sti{width:100%;height:44px;border-radius:12px;border:1px solid var(--hair);background:var(--card-solid);padding:0 12px;font:inherit;font-size:14px;color:var(--ink)}
852
+ .sti:focus{outline:2px solid var(--ember);outline-offset:1px}
853
+ .sul{list-style:none;margin:0;padding:0;display:grid;gap:6px}
854
+ .sul li{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;border-radius:12px;background:var(--card-solid)}
855
+ .sul small{display:block;color:var(--ink-3);font-size:12px}
856
+ .stlc{display:flex;gap:4px;flex:none}
857
+ .stlc button{min-width:44px;height:44px;border-radius:10px;background:var(--well);display:grid;place-items:center;padding:0 10px}
858
+ .stlc svg{width:15px;height:15px}
859
+ .stlc button:disabled{opacity:.35}
860
+ .stlib{padding:14px;border-radius:18px;background:var(--well)}
861
+ .stlh{display:flex;align-items:center;gap:10px}
862
+ .stlh small{color:var(--ink-3);margin-right:auto}
863
+ .stlib .label{margin:10px 0 0}
864
+ .stlg{display:grid;gap:6px;margin-top:6px}
865
+ .stli{display:grid;grid-template-columns:96px minmax(0,1fr) auto;gap:12px;align-items:center;text-align:left;padding:8px 12px;border-radius:12px;background:var(--card-solid);min-height:44px}
866
+ .stli .spk{width:96px;height:30px}
867
+ .stli .spk path{fill:none;stroke:var(--ink-2);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
868
+ .stli b{font-size:13.5px}
869
+ .stli small{display:block;color:var(--ink-3);font-size:12px}
870
+ .stli em{font-style:normal;font-size:12.5px;font-weight:650;color:var(--ink-2)}
871
+ .stli:disabled{opacity:.5}
872
+ .stlic{display:grid;place-items:center;width:96px}
873
+ .stlic svg{width:22px;height:22px;color:var(--ink-3)}
874
+ .stpvw{padding:16px;border-radius:18px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);min-width:0}
875
+ .stpvw .ndt{margin:0;font-size:18px;font-weight:650;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
876
+ .stpvw .npin2{font-size:11.5px;font-weight:650;padding:3px 9px;border-radius:999px;background:var(--well);color:var(--ink-2)}
877
+ .stpvw .stuse{margin:4px 0 10px;font-size:13.5px}
878
+ .stgone{margin:4px 0 0}
879
+ .suck{border-radius:16px;background:var(--well);overflow:hidden}
880
+ .suckb{display:flex;align-items:center;gap:10px;width:100%;min-height:48px;padding:10px 14px;text-align:left}
881
+ .suckb svg{width:18px;height:18px;flex:none}
882
+ .suckb b{font-size:13.5px;white-space:nowrap}
883
+ .suckb span{font-size:12.5px;color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}
884
+ .suckb svg:last-child{margin-left:auto;transition:transform .2s}
885
+ .suckb[aria-expanded="true"] svg:last-child{transform:rotate(180deg)}
886
+ .suck.bad .suckb>svg:first-child{color:var(--ember-ink)}
887
+ .stbar{margin:0 14px 12px;width:auto}
888
+ .stbar b{width:0}.stbar[data-n="1"] b{width:16.67%}.stbar[data-n="2"] b{width:33.33%}.stbar[data-n="3"] b{width:50.0%}.stbar[data-n="4"] b{width:66.67%}.stbar[data-n="5"] b{width:83.33%}.stbar[data-n="6"] b{width:100.0%}
889
+ .sucl{list-style:none;margin:0;padding:0 14px 12px;display:grid;gap:8px}
890
+ .sucl li{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center}
891
+ .sucl li svg{width:16px;height:16px}
892
+ .sucl li.bad svg{color:var(--ember-ink)}
893
+ .sucl b{font-size:13px;display:block}
894
+ .sucl small{font-size:12px;color:var(--ink-3)}
895
+ .stmsg{min-height:1.2em;margin:0;color:var(--ember-ink)}
896
+ .stft{display:flex;gap:8px;align-items:center;flex-wrap:wrap;position:sticky;bottom:0;padding:10px 0 12px;background:linear-gradient(to top,var(--card-solid) 70%,transparent)}
897
+ .stft .sp{flex:1}
898
+ .stft .dmcta{height:44px}
899
+ @media (max-width:700px){.sol{grid-template-columns:minmax(0,1fr)}.stli{grid-template-columns:72px minmax(0,1fr)}.stli .spk,.stlic{width:72px}.stli em{grid-column:2}.stt{gap:8px}.sucl li{grid-template-columns:18px minmax(0,1fr)}.sucl li .dmcta{grid-column:2;justify-self:start}}
829
900
  /* ── initiative page (initiative briefing-premium-initiative) ── */
830
901
  .ckr.current i{background:var(--ember)}
831
902
  .ckr.done i{background:var(--ok)}
@@ -1300,6 +1371,31 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
1300
1371
  .top:has(#iH1) .tools-top{flex-basis:100%;justify-content:flex-start}
1301
1372
  #cIniChk .ckr small{overflow-wrap:anywhere}
1302
1373
 
1374
+ /* search and the bell in the header (initiative premium-search-bell); the look is the mockup's overlays ov-pal and ov-bell */
1375
+ .pv-hp{position:relative}
1376
+ .pv-bdg{position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;padding:0 5px;border-radius:999px;display:grid;place-items:center;background:var(--ember);color:rgb(255,255,255);font:700 11.5px var(--mono)}
1377
+ .pv-bdg[hidden]{display:none}
1378
+ .pv-scrim{position:fixed;inset:0;z-index:44;background:rgba(30,34,60,.34);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;pointer-events:none;transition:opacity .3s}
1379
+ .pv-scrim.on{opacity:1;pointer-events:auto}
1380
+ .pv-ov{position:fixed;z-index:45;left:50%;top:12vh;transform:translateX(-50%);width:min(640px,calc(100% - 32px));max-height:72vh;overflow:auto;overscroll-behavior:contain;background:var(--card-solid);border:1px solid var(--hair);border-radius:var(--r-card);box-shadow:var(--card-shadow);padding:14px}
1381
+ .pv-ov[hidden]{display:none}
1382
+ .pv-ov.bell{left:auto;right:max(16px,calc((100vw - 1360px)/2 + 16px));top:96px;transform:none;width:min(420px,calc(100% - 32px))}
1383
+ .pv-pin{display:flex;align-items:center;gap:12px;height:56px;padding:0 16px;border-radius:999px;background:var(--well)}
1384
+ .pv-pin input{flex:1;min-width:0;height:100%;border:0;background:transparent;color:var(--ink);font:inherit;font-size:16px;outline:0}
1385
+ .pv-pin kbd{font:600 11.5px var(--mono);color:var(--ink-3);border:1px solid var(--b3);border-radius:8px;padding:2px 6px}
1386
+ .pv-grp{font:600 var(--t-micro) var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);padding:18px 14px 6px}
1387
+ .pv-lst{display:grid;gap:2px;margin-top:8px}
1388
+ .pv-row{display:grid;grid-template-columns:40px minmax(0,1fr);gap:14px;align-items:center;width:100%;min-height:56px;padding:8px 14px;border-radius:var(--r-in);text-align:left}
1389
+ .pv-row:hover,.pv-row[aria-selected="true"],.pv-row:focus-visible{background:var(--well)}
1390
+ .pv-row .gl{width:40px;height:40px;border-radius:14px;display:grid;place-items:center;background:var(--well);color:var(--ink-2)}
1391
+ .pv-row b{display:block;font-weight:620;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1392
+ .pv-row small{display:block;color:var(--ink-3);font-size:var(--t-small);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1393
+ .pv-lst .pv-row .gl{background:var(--spot);color:var(--ember-ink)}
1394
+ .pv-hd{display:flex;align-items:baseline;gap:10px;padding:8px 6px 4px}.pv-hd h2{margin:0;font-size:18px}.pv-hd small{color:var(--ink-3);font:600 12px var(--mono)}
1395
+ .pv-note{margin:0;padding:10px 14px 4px;color:var(--ink-3);font-size:var(--t-small)}
1396
+ @media (max-width:700px){.pv-ov{top:8vh}.pv-ov.bell{right:16px}}
1397
+ .pv-row .gl svg{width:20px;height:20px}
1398
+ @media (max-width:700px){.top .tools{position:relative}.pkw{position:static}.pkmenu{left:0;right:0;min-width:0}}
1303
1399
  /* Settings dialog rows (initiative premium-settings) */
1304
1400
  .sr{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px;padding:8px 0;border-bottom:1px solid var(--hair)}
1305
1401
  .sr .sn{display:grid;gap:2px;min-width:0}.sr .sn b{font-size:15px}.sr .sn em{font-style:normal;font-size:12.5px;color:var(--ink-3);overflow-wrap:anywhere}
@@ -1362,3 +1458,11 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
1362
1458
  .ssdone{color:var(--ok);font-weight:650}
1363
1459
  .sse{padding:34px 20px;text-align:center;border-radius:var(--r-in);background:var(--well)}.sse b{display:block;font-size:17px;font-weight:650}.sse p{color:var(--ink-2);margin-top:6px;font-size:var(--t-small)}
1364
1460
  @media (max-width:700px){.ssr{grid-template-columns:auto minmax(0,1fr)}.ssr>.cta{grid-column:2}}
1461
+
1462
+ /* Issue it on a core document draft (initiative premium-core-doc-issue) */
1463
+ .dsiss{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding:12px 16px;border-radius:14px;background:color-mix(in oklab,var(--ember) 12%,transparent);margin:0 0 12px;font-size:12.5px}
1464
+ .dsiss>span:first-child{display:inline-flex;gap:8px;align-items:center;flex:1 1 220px;min-width:0}
1465
+ .dsiss svg{width:15px;height:15px;flex:none;color:var(--ember-ink)}
1466
+ .dsiss .dsa{display:flex;gap:8px;flex-wrap:wrap}
1467
+ .dsiss.dsok{background:color-mix(in oklab,var(--ok) 12%,transparent)}
1468
+ .dsiss.dsok svg{color:var(--ok)}
@@ -4,7 +4,7 @@
4
4
  * Slice 3: the reply box asks a read-only agent. A control with nothing honest to write stays disabled and says why. */
5
5
  import { pmPost, pmGet } from './http.js';
6
6
  import { mountMeeting } from './premium-meeting.js';
7
- import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail } from './premium-shell.js';
7
+ import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail, pvFeed } from './premium-shell.js';
8
8
  const ICON = {
9
9
  meeting: '<rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/>',
10
10
  merge: '<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="9" r="2"/><path d="M6 8v8M18 11c0 4-6 3-12 5"/>',
@@ -259,6 +259,7 @@ async function load() {
259
259
  const ws = new URLSearchParams(location.search).get('ws');
260
260
  try { const res = await fetch('/api/briefing-premium' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
261
261
  clearInterval(readTimer);
262
+ pvFeed(r);
262
263
  if (r && r.state === 'reading') {
263
264
  // the first read has no end I can promise: say how long it has run, and ask again
264
265
  const t0 = Date.now() - (r.elapsed_ms || 0), tick = () => { $('#brief').textContent = 'Reading the products for the first time. ' + Math.round((Date.now() - t0) / 1000) + ' s so far. This page shows nothing until it has read, rather than guess.'; };
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Initiative premium-core-doc-issue: Issue it on a core document draft, from the premium Board's reader and the premium initiative sheet, against the real server on a scratch team repo.",
3
+ "panels": [
4
+ "premium-core-doc-issue-test.js"
5
+ ],
6
+ "seconds": {
7
+ "premium-core-doc-issue-test.js": 150
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Initiative premium-studio-dashboard: the Insight Studio's Dashboard mode on the premium Insights page, against the real server on a scratch repository's KR metric records.",
3
+ "panels": [
4
+ "premium-studio-test.js"
5
+ ],
6
+ "seconds": {
7
+ "premium-studio-test.js": 120
8
+ }
9
+ }