create-pmos 0.443.0 → 0.444.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 (56) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-board-test.js +8 -2
  7. package/workspace/briefing-premium-insights-test.js +40 -38
  8. package/workspace/briefing-premium-test.js +2 -1
  9. package/workspace/changelog.json +12 -0
  10. package/workspace/goals-clear-ui-test.js +34 -20
  11. package/workspace/guide/home.md +5 -0
  12. package/workspace/intel-report-ui-test.js +1 -1
  13. package/workspace/lib/board-premium.js +1 -1
  14. package/workspace/lib/engine/boards.js +9 -2
  15. package/workspace/lib/routes-boards.js +40 -1
  16. package/workspace/live-pill-round-test.js +178 -0
  17. package/workspace/okr-goals-ui-test.js +21 -19
  18. package/workspace/package-lock.json +2 -2
  19. package/workspace/package.json +1 -1
  20. package/workspace/panels-test.js +231 -0
  21. package/workspace/premium-rec-tab-test.js +2 -1
  22. package/workspace/premium-vw-item-test.js +10 -2
  23. package/workspace/premium-vw-jira-test.js +3 -0
  24. package/workspace/public/pm/bd-ini-panel.js +3 -2
  25. package/workspace/public/pm/cozy-adler.js +21 -0
  26. package/workspace/public/pm/cozy-divider.css +32 -0
  27. package/workspace/public/pm/cozy-divider.js +45 -0
  28. package/workspace/public/pm/cozy-insights.css +14 -0
  29. package/workspace/public/pm/cozy-live-pill.css +16 -22
  30. package/workspace/public/pm/cozy-live-pill.js +28 -17
  31. package/workspace/public/pm/cozy-panels.css +59 -0
  32. package/workspace/public/pm/cozy-panels.js +524 -0
  33. package/workspace/public/pm/cozy-viewer.js +146 -70
  34. package/workspace/public/pm/goals-clear.js +9 -2
  35. package/workspace/public/pm/home-app.js +22 -11
  36. package/workspace/public/pm/home-ini.js +9 -3
  37. package/workspace/public/pm/home-today.js +4 -2
  38. package/workspace/public/pm/ini-edit.js +401 -0
  39. package/workspace/public/pm/ini-tasks.js +42 -18
  40. package/workspace/public/pm/ini-versions.js +18 -4
  41. package/workspace/public/pm/ini-view-model.js +8 -4
  42. package/workspace/public/pm/ini-view.css +88 -1
  43. package/workspace/public/pm/ini-view.js +42 -11
  44. package/workspace/public/pm/premium-board.js +8 -6
  45. package/workspace/public/pm/premium-insights.js +205 -43
  46. package/workspace/public/pm/task-card.css +2 -0
  47. package/workspace/public/pm/task-card.js +4 -1
  48. package/workspace/stage-card-tasks-test.js +396 -0
  49. package/workspace/stage-card-test.js +1 -1
  50. package/workspace/task-delete-test.js +9 -1
  51. package/workspace/task-milestones-test.js +3 -3
  52. package/workspace/task-press-test.js +12 -4
  53. package/workspace/task-views-test.js +8 -4
  54. package/workspace/test-lists/batch18-live-pill-round.json +10 -0
  55. package/workspace/test-lists/batch18-panels.json +9 -0
  56. package/workspace/test-lists/stage-card-tasks.json +6 -0
@@ -98,7 +98,7 @@ const P = {
98
98
  add: 'M12 5v14M5 12h14', back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
99
99
  wide: 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7', side: 'M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7',
100
100
  chat: 'M5 6.5A2.5 2.5 0 0 1 7.5 4h9A2.5 2.5 0 0 1 19 6.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4 3.5V16h.5A2.5 2.5 0 0 1 5 13.5z',
101
- fwd: 'M10 6l6 6-6 6', home: 'M4 11l8-7 8 7v9H4z', tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
101
+ place: 'M3.5 5h17v14h-17zM12 5v14', fwd: 'M10 6l6 6-6 6', home: 'M4 11l8-7 8 7v9H4z', tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
102
102
  };
103
103
  export const PHONE = 760;
104
104
  const NARROW = 1100, MIN = 420, CHAT = 360, RAIL = 64, MAXF = 0.7, W2 = 760, FLOAT = 560;
@@ -113,7 +113,35 @@ const isPhone = () => typeof innerWidth === 'number' && innerWidth <= PHONE;
113
113
  const onHome = () => typeof document !== 'undefined' && !!document.body && document.body.classList.contains('cz-home');
114
114
  const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file · .*/, 'file').replace(/[^a-z0-9]+/g, '-').slice(0, 40) || 'item';
115
115
 
116
- const V = { el: null, cur: null, back: null, subs: [], stack: [], fwd: [], wide: false, rail: false, w: 0, drill: false, over: false, card: null, railKey: null, hold: 0 };
116
+ /* Several Viewers (batch 18 item 15, canvas TbT6TwoViewers, TbT8Wide): each is one instance. V is the instance in use: the one a press, a
117
+ * key or the last open() went to, so the exported API always speaks of the Viewer used last. G is what the page has once: its list's rail,
118
+ * the listeners, the rail's card. Only the first instance (#czViewer) writes the browser history; another keeps its own ← → trail.
119
+ * Without cozy-panels.js (Board, Intelligence) the limit stays 1 and there is one Viewer, as before. */
120
+ const G = { subs: [], card: null, railKey: null, rail: false, lw: 0, hold: 0, tick: 0, limit: 1, beside: null, place: null, managed: null };
121
+ const mk = (i) => ({ i, el: null, cur: null, back: null, stack: [], fwd: [], wide: false, w: 0, drill: false, over: false, used: 0, ph: false, via: '' });
122
+ let V = mk(0);
123
+ const ALL = [V];
124
+ const shown = (x) => !!(x && x.el && !x.el.hidden && x.cur);
125
+ /** The open Viewer used last (or null). */
126
+ const mru = () => ALL.filter(shown).sort((a, b) => b.used - a.used)[0] || null;
127
+ /** A press, a key or an open on this instance: it is the one in use now. */
128
+ function use(x) { V = x; x.used = ++G.tick; return x; }
129
+ /** Run fn on instance x without making it the one used last (a resize). */
130
+ function on(x, fn) { const was = V; V = x; try { return fn(); } finally { V = was; } }
131
+ /** Where an open() goes: a drop beside (cozy-panels.js) takes a free instance, a new one under the limit, else the least recently used;
132
+ * a press inside a Viewer drills in that Viewer; anything else replaces the Viewer used last. */
133
+ function pick(o) {
134
+ const b = G.beside; G.beside = null;
135
+ if (b && Date.now() - b.t < 6000) {
136
+ const free = ALL.find((x) => !shown(x));
137
+ if (free) return free;
138
+ if (ALL.length < G.limit) { const n = mk(ALL.length); ALL.push(n); return n; }
139
+ return ALL.filter(shown).sort((a, c) => a.used - c.used)[0];
140
+ }
141
+ const p = H.press && Date.now() - H.press.t < 10000 ? H.press : null;
142
+ if (p && p.inst && shown(p.inst) && !o.fresh) return p.inst;
143
+ return mru() || ALL[0];
144
+ }
117
145
 
118
146
  /** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
119
147
  const sameAs = (kind, title) => { const k = String(kind || '').trim().toLowerCase().replace(/^file · /, ''), t = String(title || '').trim().toLowerCase(); return !!t && (k === t || k.split('/').pop() === t || k.split('/').pop().replace(/\.[a-z]+$/, '') === t); };
@@ -148,7 +176,9 @@ export function headHtml(it) {
148
176
  : `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
149
177
  + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}${o.wrap ? ' wrap' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
150
178
  + disc + own + add + more
151
- + (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
179
+ // ⧉ (batch 18 item 15, TbT7Place): where a page arranges panels, one placement press takes the place of ⤢ (Full screen is in it)
180
+ + (phone ? '' : o.place ? ib('place', 'Arrange', P.place, ' aria-haspopup="menu" aria-expanded="false"')
181
+ : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
152
182
  + (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
153
183
  }
154
184
 
@@ -221,7 +251,7 @@ function room() {
221
251
  const desk = host.parentNode, cs = getComputedStyle(desk);
222
252
  const inner = desk.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
223
253
  const gap = parseFloat(cs.columnGap || cs.gap) || 0;
224
- const list = listEl(), lw = list && list.parentNode === desk && !V.rail ? list.offsetWidth : list && list.parentNode === desk ? (V.lw || 316) : 0;
254
+ const list = listEl(), lw = list && list.parentNode === desk && !G.rail ? list.offsetWidth : list && list.parentNode === desk ? (G.lw || 316) : 0;
225
255
  const right = inner - (lw ? lw + gap : 0);
226
256
  const side = right - gap - CHAT;
227
257
  const wideMax = Math.min(Math.round(innerWidth * MAXF), inner - (list ? RAIL + gap : 0) - gap - CHAT);
@@ -230,24 +260,25 @@ function room() {
230
260
  export const widthOf = (kind) => { const n = parseInt(store.get('cz-vw-w:' + kindKey(kind)) || '', 10); return n > 0 ? n : null; };
231
261
  function setRail(on) {
232
262
  const list = listEl();
233
- if (!on && !V.rail) return;
234
- if (on && !V.rail && list) V.lw = list.offsetWidth;
235
- const was = V.rail;
236
- V.rail = !!on && !!list;
237
- document.body.classList.toggle('cz-vw-rail', V.rail);
238
- if (!V.rail) V.railKey = null;
239
- if (was !== V.rail) document.dispatchEvent(new CustomEvent('cz:vw-rail', { detail: { on: V.rail } })); // a page's rail card closes with the rail
263
+ if (!on && !G.rail) return;
264
+ if (on && !G.rail && list) G.lw = list.offsetWidth;
265
+ const was = G.rail;
266
+ G.rail = !!on && !!list;
267
+ document.body.classList.toggle('cz-vw-rail', G.rail);
268
+ if (!G.rail) G.railKey = null;
269
+ if (was !== G.rail) document.dispatchEvent(new CustomEvent('cz:vw-rail', { detail: { on: G.rail } })); // a page's rail card closes with the rail
240
270
  if (!list) return;
241
271
  let bar = list.querySelector(':scope > .cz-vw-railbar');
242
- if (!V.rail) { if (bar) bar.remove(); return; }
272
+ if (!G.rail) { if (bar) bar.remove(); return; }
243
273
  if (!bar) {
244
274
  bar = document.createElement('div'); bar.className = 'cz-vw-railbar';
245
275
  bar.innerHTML = `<button type="button" class="cz-vw-ib" data-cz-vw-rail="show" aria-label="Show the list" title="Show the list">${svg(P.list, 18)}</button><div class="cz-vw-railtiles"></div>`;
246
276
  bar.addEventListener('click', (e) => {
247
277
  const b = e.target.closest('[data-cz-vw-rail]'); if (!b) return;
278
+ if (b.dataset.czVwRail === 'show' && G.managed && ALL.some((x) => shown(x) && G.managed('v' + x.i))) { setRail(false); return; } // cozy-panels.js lays it out
248
279
  if (b.dataset.czVwRail === 'show') { V.wide = false; apply(Math.min(V.w, sideMax())); redraw(); return; }
249
280
  // a group's tile: the page's card of that group's rows, beside the tile (batch 18 item 14, FlA1); the rail and the Viewer stay
250
- if (V.card) { V.card(b.dataset.czVwRail, b, e.detail === 0); return; }
281
+ if (G.card) { G.card(b.dataset.czVwRail, b, e.detail === 0); return; }
251
282
  // a page without a card: the list comes back, at that group
252
283
  const src = list.querySelector('[data-cz-rail-tile="' + CSS.escape(b.dataset.czVwRail) + '"]');
253
284
  V.wide = false; apply(Math.min(V.w, sideMax())); redraw();
@@ -262,35 +293,37 @@ function setRail(on) {
262
293
  function railTiles(list, bar) {
263
294
  const tiles = [...list.querySelectorAll('[data-cz-rail-tile]')].slice(0, 8);
264
295
  const box = bar.querySelector('.cz-vw-railtiles');
265
- const sig = tiles.map((t) => t.outerHTML).join('') + '|' + !!V.card;
296
+ const sig = tiles.map((t) => t.outerHTML).join('') + '|' + !!G.card;
266
297
  if (box.__sig !== sig) {
267
298
  box.__sig = sig; box.innerHTML = '';
268
299
  tiles.forEach((t) => { // a copy of the tile itself (its tint, initials and dot), in a press that names the group
269
300
  const nm = t.dataset.czRailName || t.textContent.trim(), here = t.hasAttribute('data-cz-rail-here');
270
301
  const btn = document.createElement('button'); btn.type = 'button'; btn.className = 'cz-vw-railtile' + (here ? ' here' : ''); btn.dataset.czVwRail = t.dataset.czRailTile;
271
- btn.setAttribute('aria-label', (V.card ? nm + (here ? ' (open)' : '') + '. Show its initiatives' : 'Show the list at ' + nm)); btn.title = nm;
272
- if (V.card) btn.setAttribute('aria-haspopup', 'dialog');
302
+ btn.setAttribute('aria-label', (G.card ? nm + (here ? ' (open)' : '') + '. Show its initiatives' : 'Show the list at ' + nm)); btn.title = nm;
303
+ if (G.card) btn.setAttribute('aria-haspopup', 'dialog');
273
304
  const c = t.cloneNode(true); c.removeAttribute('data-cz-rail-tile'); c.removeAttribute('data-cz-rail-name'); c.removeAttribute('data-cz-rail-here'); btn.appendChild(c); box.appendChild(btn);
274
305
  });
275
306
  }
276
- box.querySelectorAll('.cz-vw-railtile').forEach((b) => { const on = b.dataset.czVwRail === V.railKey; b.classList.toggle('on', on); if (V.card) b.setAttribute('aria-expanded', String(on)); });
307
+ box.querySelectorAll('.cz-vw-railtile').forEach((b) => { const on = b.dataset.czVwRail === G.railKey; b.classList.toggle('on', on); if (G.card) b.setAttribute('aria-expanded', String(on)); });
277
308
  }
278
309
  /** A page that draws a card for a rail tile (Home): fn(key, tile, byKey) on a tile's press, in place of bringing the list back. */
279
- export function railCard(fn) { V.card = typeof fn === 'function' ? fn : null; railSync(); }
310
+ export function railCard(fn) { G.card = typeof fn === 'function' ? fn : null; railSync(); }
280
311
  /** The tile whose card is open (null: none): its ring and aria-expanded. The page calls it after a redraw of its list, so the rail's tiles
281
312
  * follow the list (a new "here" bar, a dot). */
282
313
  export function railSync(key) {
283
- if (key !== undefined) V.railKey = key || null;
284
- const list = listEl(), bar = V.rail && list && list.querySelector(':scope > .cz-vw-railbar');
314
+ if (key !== undefined) G.railKey = key || null;
315
+ const list = listEl(), bar = G.rail && list && list.querySelector(':scope > .cz-vw-railbar');
285
316
  if (bar) railTiles(list, bar);
286
317
  }
287
318
  /** The next open() keeps the Viewer as wide as it is and the rail folded (a pick from the rail's card, FlA4After). */
288
- export function keepWide() { V.hold = Date.now() + 2000; }
319
+ export function keepWide() { G.hold = Date.now() + 2000; }
289
320
  const sideMax = () => { const r = room(); return r.float ? r.side : Math.max(MIN, r.side); };
290
321
  /** Set the width in px: past what the chat leaves, the list folds to a rail first; never under 420 or over about 70%. */
291
322
  function apply(px) {
292
323
  const el = V.el; if (!el) return;
293
324
  if (isPhone()) { el.style.width = ''; el.style.flexBasis = ''; el.classList.remove('cz-vw-w2'); setRail(false); return; }
325
+ // cozy-panels.js lays the panels out itself (two Viewers, a Viewer full or sliding over): it sizes this one, the rail is its own call
326
+ if (G.managed && G.managed('v' + V.i)) { el.style.width = ''; el.classList.toggle('cz-vw-w2', el.offsetWidth >= W2); return; } // its flex is the engine's; V.w keeps the width beside the chat
294
327
  let r = room();
295
328
  // a host that keeps its list (Home, HbCNarrow): with no room beside the chat the Viewer lies over the chat, at most the room right of the list
296
329
  const over = !r.float && r.hasList && r.side < MIN && !V.wide && !!(el.parentNode && el.parentNode.hasAttribute('data-cz-vw-overlay'));
@@ -304,7 +337,7 @@ function apply(px) {
304
337
  const fold = Math.min(r.side, Math.max(MIN, r.def));
305
338
  if (w > fold && r.hasList && r.wideMax > fold) { setRail(true); r = room(); w = Math.min(w, r.wideMax); }
306
339
  else if (r.side >= MIN && w <= fold && !V.wide) { setRail(false); r = room(); w = Math.min(w, Math.max(MIN, r.side)); }
307
- else w = Math.min(w, Math.max(MIN, V.rail ? r.wideMax : r.side));
340
+ else w = Math.min(w, Math.max(MIN, G.rail ? r.wideMax : r.side));
308
341
  } else w = Math.min(w, r.wideMax);
309
342
  V.w = w;
310
343
  el.style.width = w + 'px'; el.style.flexBasis = w + 'px';
@@ -312,7 +345,7 @@ function apply(px) {
312
345
  const g = el.querySelector('.cz-vw-grip'); if (g) { g.setAttribute('aria-valuenow', String(w)); g.setAttribute('aria-valuemin', String(MIN)); g.setAttribute('aria-valuemax', String(r.wideMax)); }
313
346
  }
314
347
  export function setWidth(px, keep = true) { apply(px); if (keep && V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); }
315
- export const railOn = () => V.rail;
348
+ export const railOn = () => G.rail;
316
349
  /** Open wide (the list folds to a rail, the Viewer takes about 70%), or back to the side at the width this kind keeps. */
317
350
  export function wide(on) {
318
351
  if (!V.cur || isPhone()) return false;
@@ -322,23 +355,26 @@ export function wide(on) {
322
355
  redraw();
323
356
  return V.wide;
324
357
  }
358
+ function resetW() { if (!V.cur) return; store.set('cz-vw-w:' + kindKey(V.cur.kind), null); V.wide = false; setRail(false); apply(room().def); redraw(); }
325
359
  function grip(el) {
326
- const g = document.createElement('div');
360
+ const g = document.createElement('div'), x = V;
327
361
  g.className = 'cz-vw-grip'; g.setAttribute('role', 'separator'); g.setAttribute('aria-orientation', 'vertical'); g.tabIndex = 0;
328
362
  g.setAttribute('aria-label', 'Drag to change the Viewer width. Double-click to reset.'); g.title = 'Drag to change the width. Double-click to reset.';
329
363
  g.innerHTML = '<i></i>';
330
364
  g.addEventListener('pointerdown', (e) => {
331
365
  if (e.button !== 0) return;
366
+ use(x);
332
367
  e.preventDefault(); g.setPointerCapture(e.pointerId); document.body.classList.add('cz-vw-drag');
333
368
  const right = el.getBoundingClientRect().right;
334
- const mv = (ev) => { V.wide = false; apply(right - ev.clientX); };
335
- const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-vw-drag'); if (V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); redraw(); };
369
+ const mv = (ev) => on(x, () => { V.wide = false; apply(right - ev.clientX); });
370
+ const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-vw-drag'); on(x, () => { if (V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); redraw(); }); };
336
371
  g.addEventListener('pointermove', mv); g.addEventListener('pointerup', up); g.addEventListener('pointercancel', up);
337
372
  });
338
- g.addEventListener('dblclick', () => { if (!V.cur) return; store.set('cz-vw-w:' + kindKey(V.cur.kind), null); V.wide = false; setRail(false); apply(room().def); redraw(); });
373
+ g.addEventListener('dblclick', () => { use(x); resetW(); });
339
374
  g.addEventListener('keydown', (e) => { // the grip is a separator: arrows move it 24 px, Home resets it
375
+ use(x);
340
376
  const d = e.key === 'ArrowLeft' ? 24 : e.key === 'ArrowRight' ? -24 : 0;
341
- if (d) { e.preventDefault(); V.wide = false; setWidth(V.w + d); redraw(); } else if (e.key === 'Home') { e.preventDefault(); g.dispatchEvent(new MouseEvent('dblclick')); }
377
+ if (d) { e.preventDefault(); V.wide = false; setWidth(V.w + d); redraw(); } else if (e.key === 'Home') { e.preventDefault(); resetW(); }
342
378
  });
343
379
  return g;
344
380
  }
@@ -394,12 +430,14 @@ function discuss() {
394
430
  function mount() {
395
431
  if (V.el && V.el.isConnected) return V.el;
396
432
  sheet();
397
- const el = document.createElement('section');
398
- el.className = 'cz-vw'; el.id = 'czViewer'; el.hidden = true;
399
- el.setAttribute('aria-labelledby', 'czVwTitle'); el.tabIndex = -1;
433
+ const el = document.createElement('section'), x = V;
434
+ el.className = 'cz-vw'; el.id = V.i ? 'czViewer' + (V.i + 1) : 'czViewer'; el.hidden = true; el.dataset.czPanel = 'v' + V.i;
435
+ if (!V.i) el.setAttribute('aria-labelledby', 'czVwTitle'); // a second Viewer is named by its aria-label (the title id is the first one's)
436
+ el.tabIndex = -1;
400
437
  el.innerHTML = '<header class="cz-vw-hd"></header><div class="cz-vw-body"></div>';
401
438
  el.prepend(grip(el));
402
439
  el.addEventListener('click', (e) => { // the header's presses, and the folds of czSections in the body
440
+ use(x);
403
441
  const f = e.target.closest('[data-czs-fold]'); if (f && el.contains(f)) { toggleFold(f); return; }
404
442
  if (e.target.closest('[data-cz-vw-rn]')) { startRename(); return; } // the title is the rename press (RnATask)
405
443
  const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
@@ -412,19 +450,21 @@ function mount() {
412
450
  else if (a === 'chip') { if (V.cur && V.cur.chip && typeof V.cur.chip.on === 'function') V.cur.chip.on(b); }
413
451
  else if (a === 'add') { if (V.cur && V.cur.add && typeof V.cur.add.on === 'function') V.cur.add.on(b); }
414
452
  else if (a === 'wide') wide();
453
+ else if (a === 'place') { if (G.place) G.place('v' + x.i, b); }
415
454
  else if (a === 'discuss') discuss();
416
455
  });
417
- holdable(el);
418
- el.addEventListener('submit', (e) => { if (e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); saveRename(); } });
419
- el.addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); e.stopPropagation(); endRename(); } });
420
- el.addEventListener('input', (e) => { if (e.target.id === 'czVwTitle' && V.cur && V.cur.renaming) V.cur.renValue = e.target.value; });
421
- el.addEventListener('change', (e) => { if (e.target.matches('[data-cz-vw-jira]') && V.cur) V.cur.renJira = e.target.checked; });
456
+ el.addEventListener('focusin', () => use(x));
457
+ holdable(el, x);
458
+ el.addEventListener('submit', (e) => { use(x); if (e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); saveRename(); } });
459
+ el.addEventListener('keydown', (e) => { use(x); if (e.key === 'Escape' && e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); e.stopPropagation(); endRename(); } });
460
+ el.addEventListener('input', (e) => { use(x); if (e.target.id === 'czVwTitle' && V.cur && V.cur.renaming) V.cur.renValue = e.target.value; });
461
+ el.addEventListener('change', (e) => { use(x); if (e.target.matches('[data-cz-vw-jira]') && V.cur) V.cur.renJira = e.target.checked; });
422
462
  place(el);
423
463
  V.el = el;
424
- if (typeof ResizeObserver !== 'undefined') new ResizeObserver(() => {
464
+ if (typeof ResizeObserver !== 'undefined') new ResizeObserver(() => on(x, () => {
425
465
  // crossing the phone width redraws the header too (← and no grip on a phone, × on a desk) without reopening the item
426
466
  if (isOpen() && !document.body.classList.contains('cz-vw-drag')) { const was = V.w, ph = V.ph; V.ph = isPhone(); apply(V.wide ? room().wideMax : V.w); if (V.w !== was || V.ph !== ph) redraw(); }
427
- }).observe(document.documentElement);
467
+ })).observe(document.documentElement);
428
468
  return el;
429
469
  }
430
470
  /** In the page's own place for it when there is one (data-cz-viewer-host), else at the end of the body, floating. */
@@ -433,10 +473,14 @@ function place(el) {
433
473
  if (host) { if (el.parentNode !== host) host.appendChild(el); el.classList.remove('cz-vw-float'); }
434
474
  else { if (el.parentNode !== document.body) document.body.appendChild(el); el.classList.add('cz-vw-float'); }
435
475
  }
436
- function emit() {
437
- const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null, via: V.cur ? '' : V.via || '' }; // via 'history': the browser's Back closed it
476
+ /** x: the instance that changed. The detail speaks of the Viewer used last (V): open is false only when no Viewer is open; panel names the
477
+ * one that changed and shut says it closed, for cozy-panels.js. */
478
+ function emit(x) {
479
+ x = x || V;
480
+ const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null, via: V.cur ? '' : x.via || '', // via 'history': the browser's Back closed it
481
+ panel: 'v' + x.i, shut: !shown(x) };
438
482
  document.body.classList.toggle('cz-vw-on', d.open);
439
- V.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
483
+ G.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
440
484
  document.dispatchEvent(new CustomEvent('cz-viewer', { detail: d }));
441
485
  }
442
486
  /** Runs go now, or after the item's guard says so (it holds unsaved changes and asks Save or Discard first). */
@@ -454,7 +498,7 @@ function redraw() {
454
498
  V.ph = isPhone();
455
499
  const hd = V.el.querySelector('.cz-vw-hd');
456
500
  const bk = V.stack[V.stack.length - 1], fw = V.fwd[V.fwd.length - 1];
457
- hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide || V.rail, phone: V.ph, home: onHome() });
501
+ hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide || G.rail, phone: V.ph, home: onHome(), place: !!G.place });
458
502
  hd.classList.toggle('cz-vw-renon', !!V.cur.renaming);
459
503
  }
460
504
 
@@ -485,26 +529,33 @@ async function saveRename() {
485
529
  endRename(); emit();
486
530
  }
487
531
  /** The item's own presses change while it is shown (the charter's Save shows only after a change). */
488
- export function setChip(id, chip) {
532
+ function setChip0(id, chip) {
489
533
  if (!V.cur || V.cur.id !== String(id)) return;
490
534
  const was = V.cur.chip, on = !!(chip && (chip.n > 0 || chip.looking)), n = on ? chip.n || 0 : -1;
491
535
  V.cur.chip = on ? chip : null;
492
536
  if (V.cur.args) V.cur.args = { ...V.cur.args, chip: V.cur.chip };
493
537
  if ((was ? was.n || 0 : -1) !== n || (was && chip && (was.label !== chip.label || !!was.looking !== !!chip.looking))) { if (!V.cur.renaming) redraw(); }
494
538
  }
495
- export function setPresses(id, list) { if (V.cur && V.cur.id === String(id)) { V.cur.presses = list || null; if (V.cur.args) V.cur.args = { ...V.cur.args, presses: list || null }; if (!V.cur.renaming) redraw(); } }
539
+ function setPresses0(id, list) { if (V.cur && V.cur.id === String(id)) { V.cur.presses = list || null; if (V.cur.args) V.cur.args = { ...V.cur.args, presses: list || null }; if (!V.cur.renaming) redraw(); } }
496
540
  /** A task's check box changes while it is shown (a status move from the card, canvas XetX1Done). */
497
- export function setCheck(id, check) { if (V.cur && V.cur.id === String(id)) { V.cur.check = check || null; if (V.cur.args) V.cur.args = { ...V.cur.args, check: check || null }; if (!V.cur.renaming) redraw(); } }
541
+ function setCheck0(id, check) { if (V.cur && V.cur.id === String(id)) { V.cur.check = check || null; if (V.cur.args) V.cur.args = { ...V.cur.args, check: check || null }; if (!V.cur.renaming) redraw(); } }
542
+ /** The item may be shown in any Viewer, not only the one used last: each one that shows it changes. */
543
+ const each = (id, fn) => ALL.filter((x) => x.cur && x.cur.id === String(id)).forEach((x) => on(x, fn));
544
+ export function setChip(id, chip) { each(id, () => setChip0(id, chip)); }
545
+ export function setPresses(id, list) { each(id, () => setPresses0(id, list)); }
546
+ export function setCheck(id, check) { each(id, () => setCheck0(id, check)); }
547
+ export function retitle(id, title) { each(id, () => retitle0(id, title)); }
498
548
  /** The caller's own rename landed elsewhere (Undo, or a reload): the header shows the name. */
499
- export function retitle(id, title) { if (V.cur && V.cur.id === String(id) && title) { V.cur.title = title; if (V.cur.args) V.cur.args = { ...V.cur.args, title }; if (!V.cur.renaming) redraw(); emit(); } }
549
+ function retitle0(id, title) { if (V.cur && V.cur.id === String(id) && title) { V.cur.title = title; if (V.cur.args) V.cur.args = { ...V.cur.args, title }; if (!V.cur.renaming) redraw(); emit(); } }
500
550
 
501
551
  /** Show one item in the Viewer, in place of the one shown. Returns the body element the content is in. */
502
552
  export function open(it) {
503
553
  const o = it || {};
554
+ use(o._inst || pick(o));
504
555
  // an item with unsaved changes asks first; the open goes on when it says so (and keeps a drill-in asked for before it)
505
556
  if (!o._asked && V.cur && typeof V.cur.guard === 'function') {
506
557
  const dr = V.drill; let now = true, ran = false;
507
- guarded(() => { ran = true; if (!now) { V.drill = dr; open({ ...o, _asked: true }); } });
558
+ const x = V; guarded(() => { ran = true; if (!now) { x.drill = dr; open({ ...o, _asked: true, _inst: x }); } });
508
559
  now = false;
509
560
  if (!ran) return null;
510
561
  }
@@ -513,6 +564,7 @@ export function open(it) {
513
564
  const was = isOpen(), pos = V.stack.length, how = stepOf(o);
514
565
  if (how === 'nav') { V.stack = o._trail.stack; V.fwd = o._trail.fwd; }
515
566
  else if (how === 'drill') { V.stack.push(V.cur.args); V.fwd = []; hq({ push: 1, s: H.s, i: V.stack.length }); }
567
+ else if (how === 'new' && V.i) { V.stack = []; V.fwd = []; } // a second Viewer keeps its trail without the browser history
516
568
  else if (how === 'new') {
517
569
  // a press starts a trail on its own entry; an open no press led to (the page drew it, or Back from another page restored it) takes the
518
570
  // page's entry, so Back from it leaves the page as before. A new trail from a press takes the place of a pressed one.
@@ -533,8 +585,8 @@ export function open(it) {
533
585
  body.className = 'cz-vw-body'; body.onclick = null; body.oninput = null; body.onchange = null; body.onkeydown = null; // what one item's render added to the body does not reach the next
534
586
  const wasHidden = el.hidden;
535
587
  el.hidden = false;
536
- const hold = V.hold > Date.now() && !wasHidden && (V.wide || V.rail); V.hold = 0;
537
- if (!hold && !(sameKind && !wasHidden && (V.wide || V.rail))) { const k = widthOf(o.kind); V.wide = false; apply(k || room().def); redraw(); }
588
+ const hold = G.hold > Date.now() && !wasHidden && (V.wide || G.rail); G.hold = 0;
589
+ if (!hold && !(sameKind && !wasHidden && (V.wide || G.rail))) { const k = widthOf(o.kind); V.wide = false; apply(k || room().def); redraw(); }
538
590
  if (typeof o.render === 'function') o.render(body); else if (o.html) body.innerHTML = o.html;
539
591
  emit();
540
592
  if (isPhone()) el.focus();
@@ -555,26 +607,29 @@ export function trail() {
555
607
  * already left the trail (its Back at the first item), so the history is not moved again. */
556
608
  export function close(o = {}) {
557
609
  if (!V.el || V.el.hidden) return;
558
- const pos = V.stack.length;
610
+ const pos = V.stack.length, x = V;
559
611
  leave();
560
612
  // the trail's entries come off, so Back never lands on a closed item; a trail on the page's own entry gives that entry back
561
- if (!o.quiet && H.s) { if (H.auto) { if (pos) hq({ go: -pos }); hq({ clear: 1 }); } else hq({ go: -(pos + 1) }); }
562
- H.s = ''; H.auto = false;
613
+ if (!V.i) {
614
+ if (!o.quiet && H.s) { if (H.auto) { if (pos) hq({ go: -pos }); hq({ clear: 1 }); } else hq({ go: -(pos + 1) }); }
615
+ H.s = ''; H.auto = false;
616
+ }
563
617
  V.via = o.quiet ? 'history' : '';
564
618
  V.stack = []; V.fwd = []; V.wide = false; V.drill = false;
565
619
  if (V.over) { V.over = false; document.body.classList.remove('cz-vw-over'); }
566
620
  V.el.hidden = true;
567
621
  V.el.querySelector('.cz-vw-body').innerHTML = '';
568
622
  V.el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
569
- setRail(false);
570
- emit();
571
- const b = V.back; V.back = null;
572
- if (b && b.isConnected) { try { b.focus(); } catch { /* gone */ } }
623
+ const nx = mru(); // another Viewer is still open: it is the one in use now, and the list stays as it is
624
+ if (nx) V = nx; else setRail(false);
625
+ emit(x);
626
+ const b = x.back; x.back = null;
627
+ if (b && b.isConnected && !nx) { try { b.focus(); } catch { /* gone */ } }
573
628
  }
574
629
  export const isOpen = () => !!(V.el && !V.el.hidden && V.cur);
575
630
  export const current = () => (V.cur ? { id: V.cur.id, kind: V.cur.kind, title: V.cur.title, url: V.cur.url } : null);
576
631
  export const body = () => (isOpen() ? V.el.querySelector('.cz-vw-body') : null);
577
- export function onChange(fn) { if (typeof fn === 'function') V.subs.push(fn); }
632
+ export function onChange(fn) { if (typeof fn === 'function') G.subs.push(fn); }
578
633
  /** Open the Viewer on a feature the design does not draw yet. */
579
634
  export function placeholder(featureName, o = {}) {
580
635
  return open({ id: 'placeholder:' + featureName, kind: o.kind || featureName, title: featureName, icon: o.icon || 'info', render: (el) => czPlaceholder(el, featureName) });
@@ -590,12 +645,12 @@ function stepOf(o) {
590
645
  const p = H.press && Date.now() - H.press.t < 10000 ? H.press : null; // the press that led here: an open often waits for a module or a read
591
646
  if (o.keep && V.cur) return 'keep';
592
647
  if (V.cur && V.cur.args && !o.fresh && (o.back || V.drill)) return 'drill'; // asked for: a view of the same item drills in too (Stage, Documents)
593
- if (V.cur && o.id != null && V.cur.id === String(o.id) && !(p && !p.inside) && !o.fresh) return 'keep';
594
- if (V.cur && V.cur.args && !o.fresh && p && p.inside) return 'drill';
648
+ if (V.cur && o.id != null && V.cur.id === String(o.id) && !(p && p.inst !== V) && !o.fresh) return 'keep';
649
+ if (V.cur && V.cur.args && !o.fresh && p && p.inst === V) return 'drill';
595
650
  return 'new';
596
651
  }
597
652
  /** The history follows the trail. A go() waits for its popstate before the next push or replace, so the order holds. */
598
- function hq(op) { if (!canHist()) return; H.q.push(op); hRun(); }
653
+ function hq(op) { if (!canHist() || V.i) return; H.q.push(op); hRun(); }
599
654
  function hRun() {
600
655
  while (H.q.length && !H.wait) {
601
656
  const op = H.q.shift();
@@ -619,11 +674,12 @@ function step(n, o = {}) {
619
674
  if (at >= seq.length) return null;
620
675
  const to = seq[at];
621
676
  if (!o.quiet) hq({ go: n });
622
- return open({ ...to, back: false, keep: false, _asked: true, _nav: true, _trail: { stack: seq.slice(0, at), fwd: seq.slice(at + 1).reverse() } });
677
+ return open({ ...to, back: false, keep: false, _asked: true, _nav: true, _inst: V, _trail: { stack: seq.slice(0, at), fwd: seq.slice(at + 1).reverse() } });
623
678
  }
624
679
  /** The browser moved (Back, Forward, a swipe, a long press on its own ←). An item with unsaved changes asks first: the browser goes back to
625
680
  * where it was, and the move runs on Save or Discard. */
626
- function popped(e) {
681
+ function popped(e) { use(ALL[0]); popped0(e); }
682
+ function popped0(e) {
627
683
  if (H.wait) { H.wait = 0; hRun(); return; } // the history moving after ← → or a close: the Viewer is already there
628
684
  const st = e && e.state && e.state.czvw;
629
685
  if (!st) { if (isOpen()) follow(-(V.stack.length + 1)); return; } // before the trail: the page as it was
@@ -638,20 +694,20 @@ function follow(n) {
638
694
  if (!ran) hq({ go: -n });
639
695
  }
640
696
  /* where a press was: inside the Viewer it drills in, outside it starts a new trail */
641
- function pressAt(e) { const t = e.target; H.press = { t: Date.now(), inside: !!(V.el && t && t.nodeType === 1 && V.el.contains(t) && !t.closest('.cz-vw-trail')) }; }
697
+ function pressAt(e) { const t = e.target; const inst = t && t.nodeType === 1 && !t.closest('.cz-vw-trail') ? ALL.find((x) => x.el && x.el.contains(t)) || null : null; H.press = { t: Date.now(), inst }; }
642
698
  /* the trail list: hover ← or → for a moment (a mouse), or hold it (a touch). It names every step, newest first, and the page it started on. */
643
699
  let HOLD = { t: 0, fired: 0 };
644
- function holdable(el) {
645
- el.addEventListener('pointerover', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b || e.pointerType === 'touch' || !V.stack.length && !V.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => trailMenu(b), 500); });
700
+ function holdable(el, x) {
701
+ el.addEventListener('pointerover', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b || e.pointerType === 'touch' || !x.stack.length && !x.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => on(x, () => trailMenu(b, x)), 500); });
646
702
  el.addEventListener('pointerout', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) clearTimeout(HOLD.t); });
647
- el.addEventListener('pointerdown', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b) return; HOLD.fired = 0; if (e.pointerType === 'mouse' || !V.stack.length && !V.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => { HOLD.fired = Date.now(); trailMenu(b); }, 500); });
703
+ el.addEventListener('pointerdown', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b) return; HOLD.fired = 0; if (e.pointerType === 'mouse' || !x.stack.length && !x.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => { HOLD.fired = Date.now(); on(x, () => trailMenu(b, x)); }, 500); });
648
704
  ['pointerup', 'pointercancel'].forEach((k) => el.addEventListener(k, () => clearTimeout(HOLD.t)));
649
705
  el.addEventListener('contextmenu', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) e.preventDefault(); });
650
706
  }
651
707
  /** A hold that opened the trail list is not also a press. */
652
708
  function held() { if (HOLD.fired && Date.now() - HOLD.fired < 800) { HOLD.fired = 0; return true; } return false; }
653
709
  const PAGES = { '/premium.html': 'Home', '/premium-board.html': 'Board', '/premium-intelligence.html': 'Intelligence', '/premium-insights.html': 'Intelligence' };
654
- function trailMenu(b) {
710
+ function trailMenu(b, x) {
655
711
  if (!V.cur || !V.el) return;
656
712
  const old = V.el.querySelector('.cz-vw-trail'); if (old) old.remove();
657
713
  const seq = [...V.stack, V.cur.args, ...V.fwd.slice().reverse()], here = V.stack.length;
@@ -663,7 +719,7 @@ function trailMenu(b) {
663
719
  + `<button type="button" role="menuitem" class="pg" data-cz-vw-go="${-(here + 1)}"><span class="t">${svg(P.home, 15)}</span><span>${esc(PAGES[location.pathname] || document.title || 'The page')}</span></button>`;
664
720
  const off = () => { m.remove(); document.removeEventListener('pointerdown', away, true); };
665
721
  const away = (e) => { if (!m.contains(e.target)) off(); };
666
- m.addEventListener('click', (e) => { const x = e.target.closest('[data-cz-vw-go]'); if (!x) return; const n = +x.dataset.czVwGo; off(); if (n) guarded(() => step(n), b); });
722
+ m.addEventListener('click', (e) => { const g = e.target.closest('[data-cz-vw-go]'); if (!g) return; const n = +g.dataset.czVwGo; off(); if (x) use(x); if (n) guarded(() => step(n), b); });
667
723
  m.addEventListener('keydown', (e) => {
668
724
  const bs = [...m.querySelectorAll('button')], at = bs.indexOf(document.activeElement);
669
725
  if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); off(); b.focus(); }
@@ -681,13 +737,33 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
681
737
  // Escape closes the Viewer first, unless a layer over it (a menu, a confirm) is open: that layer closes first. The listener is on
682
738
  // window in the capture phase and is added before premium-shell.js adds its own, so the old dialog does not also close on the same key.
683
739
  window.addEventListener('keydown', (e) => {
684
- if (e.key !== 'Escape' || !isOpen() || e.defaultPrevented) return;
740
+ const x = mru();
741
+ if (e.key !== 'Escape' || !x || e.defaultPrevented) return;
685
742
  if (document.querySelector('[data-esc-layer]')) return;
686
- e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
743
+ use(x); e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
687
744
  }, true);
688
745
  window.addEventListener('click', pressAt, true);
689
746
  window.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') pressAt(e); }, true);
690
747
  window.addEventListener('popstate', popped);
691
748
  try { H.adopt = !!(history.state && history.state.czvw); } catch { H.adopt = false; } // back here from another page, or a reload: the first open takes this entry
692
749
  }
750
+ /* ── for cozy-panels.js (batch 18 item 15): the instances behind one object. A panel id is 'v' + the instance's number (v0 is #czViewer). ── */
751
+ const byP = (id) => ALL.find((x) => 'v' + x.i === id) || null;
752
+ export const panels = {
753
+ list: () => ALL.map((x) => ({ id: 'v' + x.i, open: shown(x), used: x.used, el: x.el, item: x.cur ? { id: x.cur.id, kind: x.cur.kind, title: x.cur.title } : null })),
754
+ /** limit: how many Viewers may be open at once · place(id, button): ⧉ was pressed · managed(id) → true: the panels engine sizes it */
755
+ config(c = {}) { if (c.limit) G.limit = c.limit; if ('place' in c) G.place = c.place; if ('managed' in c) G.managed = c.managed; ALL.filter(shown).forEach((x) => on(x, redraw)); },
756
+ /** The next open() goes into a Viewer of its own (a drop beside, TbT5DragRow). */
757
+ beside() { G.beside = { t: Date.now() }; }, unbeside() { G.beside = null; },
758
+ close(id) { const x = byP(id); if (shown(x)) { use(x); guarded(close); } },
759
+ use(id) { const x = byP(id); if (x) use(x); },
760
+ /** The width of a Viewer beside the chat (the first divider drives it): px; keep: remembered for its kind. */
761
+ size(id, px, keep) { const x = byP(id); if (shown(x)) on(x, () => { V.wide = false; setWidth(px, keep); redraw(); }); },
762
+ reset(id) { const x = byP(id); if (shown(x)) on(x, resetW); },
763
+ /** Lay each open Viewer out again (the engine changed what it manages). */
764
+ relayout() { ALL.filter(shown).forEach((x) => on(x, () => { apply(V.wide ? room().wideMax : V.w || room().def); redraw(); })); },
765
+ /** Back beside the chat after the engine laid it out: the width its kind keeps, else the default. */
766
+ rest() { ALL.filter(shown).forEach((x) => on(x, () => { const k = widthOf(V.cur.kind); V.wide = false; apply(k || room().def); redraw(); })); },
767
+ rail(v) { setRail(!!v); }, railOn: () => G.rail,
768
+ };
693
769
  if (typeof window !== 'undefined') window.czViewer = { open, close, back, forward, trail, replaceUrl, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, railCard, railSync, keepWide, ICONS };
@@ -6,6 +6,7 @@
6
6
  * keptSay(rows) the "Kept" toast: "Kept. I read it every Monday 07:00." with the goal's own rhythm (never "every morning")
7
7
  * tableHtml(rows, o) GcJ1aTable: the drafts table. Proposed metric · How it is counted · Now (read hh:mm) · Target · From, how often · ✕ ✓
8
8
  * checkHtml(r, st) GcJ1Drafts: the check panel of one drafted metric; GcS3Differs once the PM typed a number that differs
9
+ * needOf(x) "it needs a full week": why a weekly (or monthly) goal is not read more often, said after How often
9
10
  * firstOf(g) { n, first, next } while a goal has fewer than 3 readings (GcJ2FirstMonday): no pace, no trend yet
10
11
  * firstMeta(g) the row's second line then: "39.4k · Looker, Mon 2 Nov 07:02 · pace known after 3 readings"
11
12
  * firstChart(g) the dashed box where the chart will be: "The line starts with the 2nd reading, Mon 9 Nov"
@@ -52,6 +53,12 @@ export function rhythmOf(x) {
52
53
  if (c === 'monthly') return { short: 'Every month', long: 'every month, the 1st' + (at ? ' ' + at : '') };
53
54
  return { short: String(c), long: String(c) };
54
55
  }
56
+ /** Why a goal is read no more often than this (GcJ1Drafts): a weekly count needs the whole week in it, a monthly one the whole month. */
57
+ export function needOf(x) {
58
+ const R = (x && x.rhythm) || (x && x.raw && x.raw.rhythm), rc = (x && x.recipe) || (x && x.raw && x.raw.recipe) || null;
59
+ const c = (R && typeof R === 'object' && R.cadence) || (rc && rc.cadence) || '';
60
+ return c === 'weekly' ? 'it needs a full week' : c === 'monthly' ? 'it needs a full month' : '';
61
+ }
55
62
  /** The "Kept" toast (AdM3Intel, now with the goal's own rhythm). rows: the drafts kept by this press. One rhythm for all: it says it; several:
56
63
  * "each on its own rhythm". A server's said line (r.said) wins. */
57
64
  export function keptSay(rows, said) {
@@ -147,8 +154,8 @@ export function checkHtml(r, st = {}) {
147
154
  + `<div class="gc-sec"><b class="gc-k">My checks</b><ul class="gc-checks">${list.map(checkRow).join('')}</ul></div>`
148
155
  + `<form class="gc-cmp" data-gc-cmp><input name="v" inputmode="decimal" maxlength="24" autocomplete="off" placeholder="${esc('Your number for ' + (L && L.period ? L.period.replace(/^week of .*/, 'last week') : 'last week') + (value ? ', e.g. ' + value : ''))}" aria-label="Your number, to compare with mine" value="${esc(st.compare || '')}">`
149
156
  + `<button type="submit" class="cz-ib sm solid" aria-label="Compare with my number" title="Compare"${st.busy ? ' disabled' : ''}>${icon(I.chk, 18)}</button></form>`
150
- + (R ? `<p class="gc-line"><b>How often</b> ${esc(R.long)}</p>` : '')
151
- + queryHtml(rc, false)
157
+ + (R ? `<p class="gc-line"><b>How often</b> ${esc([R.long, needOf(r)].filter(Boolean).join(' · '))}</p>` : '')
158
+ + queryHtml(rc, true)
152
159
  + `<div class="gc-foot">${rc && rc.url ? `<a class="cz-ib sm" href="${esc(rc.url)}" target="_blank" rel="noopener noreferrer" aria-label="Open in ${esc(rc.connector || 'the source')}" title="Open in ${esc(rc.connector || 'the source')}">${icon(I.open)}</a>` : ''}`
153
160
  + ib({ act: 'edit', row: r.id, icon: I.pen, label: 'Edit how it is counted, the target or the source', title: 'Edit', busy: st.busy })
154
161
  + ib({ act: 'test', row: r.id, icon: I.redo, label: 'Read it now', title: 'Read now', busy: st.busy })
@@ -16,6 +16,7 @@
16
16
  * press (pmPost). Nothing here opens the old dialog or links to the console. */
17
17
  import { mountNav } from './cozy-nav.js';
18
18
  import { mountLivePill } from './cozy-live-pill.js';
19
+ import { mountPanels } from './cozy-panels.js';
19
20
  import { ownTab, bring, tabUrl } from './rec-tab-core.js';
20
21
  import * as VW from './cozy-viewer.js';
21
22
  import * as SV from './small-vw.js'; // the small Viewers: a stakeholder, its form, a routine (batch 18 item 2-C)
@@ -469,7 +470,7 @@ function iniViewOf(id) {
469
470
  const need = H.needsOf(S.D).find((r) => r.ini === id);
470
471
  const p = programOf(S.D.programs || [], row.ws || (B.board || {}).ws || '', id);
471
472
  return iniView(rowFor({ ...row, trail: t || row.trail || null }), { steps: B.steps || STEPS, today: B.today, usual: WFM.usualOf(S.D.trail, row),
472
- ask: need ? { title: need.name, n: H.needsOf(S.D).filter((r) => r.ini === id).length } : null, program: p ? { id: p.id, title: p.title } : null,
473
+ ask: need ? { title: need.name, n: H.needsOf(S.D).filter((r) => r.ini === id).length } : null, program: p ? { id: p.id, title: p.title } : null, jiraReadAt: ((B.jira || {}).readAt) || '',
473
474
  // the card (batch 18 item 1): Claude's line while a session works on it, the stakeholders
474
475
  claude: (() => { const w = S.D.sessions.find((s) => H.iniOfSession(s) === id && s.shown === 'working'); return w ? 'I’m working on “' + H.nameOf(w) + '”. I’ll say here when it is ready.' : ''; })(),
475
476
  people: (((S.D.desk && S.D.desk.stakeholders) || {})[id] || []) });
@@ -1023,6 +1024,7 @@ async function goIni(id, o = {}) {
1023
1024
  openTarget(iniTarget(id));
1024
1025
  if (o.page !== false) { pushPage(); iniPage(); }
1025
1026
  syncUrl();
1027
+ if (window.czPanels) window.czPanels.scope(id); // the initiative reopens with its last panels and shares (batch 18 item 15)
1026
1028
  await loadIni();
1027
1029
  if (S.ini !== id) return;
1028
1030
  drawList(); openTarget(iniTarget(id));
@@ -1062,7 +1064,7 @@ function goProgram(id) {
1062
1064
  pushPage();
1063
1065
  programPanel().then(() => { if (S.head === 'g:' + id) document.dispatchEvent(new CustomEvent('bd:program', { detail: { id } })); }).catch(() => toast('The program could not open.'));
1064
1066
  }
1065
- function goHome() { S.ini = null; S.sel = null; S.IM = null; S.head = null; S.phoneChat = false; syncUrl(); drawList(); openTarget(homeTarget()); }
1067
+ function goHome() { S.ini = null; S.sel = null; S.IM = null; S.head = null; S.phoneChat = false; syncUrl(); drawList(); openTarget(homeTarget()); if (window.czPanels) window.czPanels.scope(null); }
1066
1068
  /* The browser's Back closes the page a name opened (HbC). The Viewer keeps the one trail and its history entries (batch 14 item 7): Back
1067
1069
  * at the trail's first item closes it, and Home is then as it was. Close (×, Escape) takes the entries off and keeps the initiative's chat. */
1068
1070
  let paged = false;
@@ -1754,7 +1756,9 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1754
1756
  if (d.hmGroup) { if (S.shut.has(d.hmGroup)) S.shut.delete(d.hmGroup); else S.shut.add(d.hmGroup); store.set('pmos.home.shut', JSON.stringify([...S.shut])); drawList(); return; }
1755
1757
  if ('hmAllneeds' in d) { S.allNeeds = !S.allNeeds; drawList(); return; }
1756
1758
  if ('hmNew' in d) { menu(b, newItems(), 'New'); return; }
1757
- if ('hmFold' in d) { S.folded = true; store.set('pmos.home.fold', '1'); drawList(); return; }
1759
+ // the list header's fold (batch 18 item 15): with a Viewer open the list folds to the rail and the Viewer takes the room; with none, the
1760
+ // list folds away and the button at the top left brings it back
1761
+ if ('hmFold' in d) { if (VW.isOpen()) { VW.wide(true); return; } S.folded = true; store.set('pmos.home.fold', '1'); drawList(); return; }
1758
1762
  if ('hmMeet' in d) { const m = H.meetLineOf(S.D.today); if (m) openMeeting(m.meeting); return; }
1759
1763
  if ('hmCal' in d) { openCalendar(); return; }
1760
1764
  if ('hmRec' in d) { MORE.openRecorder().then(() => drawList()); return; }
@@ -1873,14 +1877,21 @@ PO.mount({ programs: () => S.D.programs || [], stateOf: (p) => (((S.M && S.M.gro
1873
1877
  SO.mount({ redraw: () => { S.D.order = SO.layout(); drawList(); }, say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) });
1874
1878
  mountNav('home', document, { here: () => { if (VW.isOpen()) VW.close(); goHome(); } });
1875
1879
  // the Live pill (batch 6 item 2): on Home a row opens in place, the session's chat (with its Viewer page) or the meeting; the open one is tinted
1876
- mountLivePill(document, {
1877
- open: () => (S.cur && S.cur.ses) || null,
1878
- go: (x) => {
1879
- if (x.kind === 'rec') { const id = /[?&]meeting=([^&]+)/.exec(x.href || ''); if (!id) return false; openMeeting({ note: decodeURIComponent(id[1]) }); return true; }
1880
- const s = x.sid && S.D.sessions.find((y) => y.id === x.sid); if (!s) return false;
1881
- if (VW.isOpen() && isPhone()) VW.close();
1882
- S.sel = 's:' + s.id; S.phoneChat = isPhone(); openTarget(sessionTarget(s)); followViewer(s); drawList(); syncUrl();
1883
- return true;
1880
+ const liveGo = (x) => {
1881
+ if (x.kind === 'rec') { const id = /[?&]meeting=([^&]+)/.exec(x.href || ''); if (!id) return false; openMeeting({ note: decodeURIComponent(id[1]) }); return true; }
1882
+ const s = x.sid && S.D.sessions.find((y) => y.id === x.sid); if (!s) return false;
1883
+ if (VW.isOpen() && isPhone()) VW.close();
1884
+ S.sel = 's:' + s.id; S.phoneChat = isPhone(); openTarget(sessionTarget(s)); followViewer(s); drawList(); syncUrl();
1885
+ return true;
1886
+ };
1887
+ mountLivePill(document, { open: () => (S.cur && S.cur.ses) || null, go: liveGo });
1888
+ /* The panels (batch 18 item 15, canvas TbT1Split…TbT9Divider): the chat and up to 3 Viewers side by side, the divider, open beside, ⧉, slide
1889
+ * over. A Live pill row opens in the chat (liveGo); a remembered Viewer of an initiative opens again here when Home has a view for it. */
1890
+ mountPanels({
1891
+ go: liveGo,
1892
+ reopen: (it) => {
1893
+ if (/^file:[\w./-]+\.\w+$/.test(it.id || '')) { openFile({ path: it.id.slice(5), name: it.title || '' }); return true; }
1894
+ return false;
1884
1895
  },
1885
1896
  });
1886
1897
  PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m), skip: ['meeting'] }); drawList();