create-pmos 0.322.0 → 0.323.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.322.0",
3
+ "version": "0.323.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@de4bfa4
1
+ kernel-source: pmos@628f334
2
2
  assembled: 2026-10-19
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T16:09:21Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T16:09:21Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T16:09:21Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -119,6 +119,8 @@ Above the list, with today picked, a ring shows how many of the meetings still a
119
119
 
120
120
  With another day picked, the card lists that day's meetings from the calendar PMOS holds, and the items due that day. It reads the week once when the page opens. If the calendar cannot be read, the card says "Calendar not read" and gives the reason, and does not guess. A meeting in the past is shown dimmer. Picking a day changes only what the card shows and records nothing.
121
121
 
122
+ **The full calendar.** The button beside the filter in the card's title row opens the calendar in a dialog. **Day**, **Week** and **Month** each read the calendar PMOS holds for that range; the arrows move one day, week or month, and **Today** comes back. Week is a timeline from Monday to Friday, with Saturday and Sunday only when they hold something; meetings at the same time sit side by side, and the all-day row shows the dated marks the Calendar reads (a promised date, a plan item, a release, a report, your own due items). In a narrow dialog, such as on a phone, Day and Week are a list of days. In Month, press a day to open it. Press a meeting to open its meeting dialog; the calendar stays as a **Calendar** tab beside it, at the same view. An empty range says "No meetings in this week" (or day, or month), and a calendar that cannot be read says "Calendar not read" with the reason.
123
+
122
124
  Press a meeting, from today or from another day, to open the meeting dialog. It shows the time, the people, and what the meeting is about. It also shows the notes (decisions, next steps and open questions), the material, and, when a recording was kept, its length and the key points. Each part appears only when a record holds it.
123
125
 
124
126
  When the meeting is not linked, the dialog has a **Link it** press. You choose the portfolio, a board, an initiative or none. The press writes one calendar link, through a check that only a real press from this page can pass, so an agent session is refused. After the write, the page reads the week again. The **Material** part has **Add material** and a **Remove** on each row. Add material opens a sheet in the dialog with three ways to pick: **Suggested** (the documents of the meeting's initiative and the newest report cycles), **Find in PMOS** (type two letters or more) and **Paste a link** (an https address). A **For** choice says whether the material belongs to this meeting or to every meeting in the series. Before you press Add, the sheet says what it records: one line in PMOS's own record of the meeting. The calendar invite is never changed. After a write, the list is read again from the record. Remove names its scope and says the document itself is not changed. A few seconds of **Undo** put a removed item back.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.322.0",
3
+ "version": "0.323.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.322.0",
9
+ "version": "0.323.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.322.0",
3
+ "version": "0.323.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -104,7 +104,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
104
104
  await page.click('.vcf [data-a="1"]');
105
105
  ok('R1 vwConfirm resolves true on the yes button and removes the card', (await yes) === true && !(await page.$('.vcf')));
106
106
  await page.evaluate(() => window.__premiumViewer.vwStyle('none-such'));
107
- ok('R1 vwStyle adds the view\'s stylesheet link once', await page.evaluate(() => { window.__premiumViewer.vwStyle('none-such'); window.__premiumViewer.vwStyle('../x'); return document.querySelectorAll('link[data-vw-css]').length === 1 && document.querySelector('link[data-vw-css]').getAttribute('href') === '/pm/premium-vw-none-such.css'; }));
107
+ ok('R1 vwStyle adds the view\'s stylesheet link once', await page.evaluate(() => { window.__premiumViewer.vwStyle('none-such'); window.__premiumViewer.vwStyle('../x'); const l = document.querySelectorAll('link[data-vw-css="none-such"]'); return l.length === 1 && l[0].getAttribute('href') === '/pm/premium-vw-none-such.css' && !document.querySelector('link[href*="/x.css"]'); }));
108
108
  await page.keyboard.press('Escape');
109
109
  await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')), 3000);
110
110
  await openDialog(page);
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-vw-cal-test.js — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8; planning/prd/premium-viewer-prd.md R6, R7).
4
+ * Serves the real Briefing page from the real server. The Briefing model and GET /api/calendar-views are answered by stand-ins; the stand-in
5
+ * buckets its meetings with the repo's own calendar model (scripts/calendar-model.js), so each view gets the cells the real route would send.
6
+ * R8 the card's button opens the grid · Day, Week, Month · previous, next, Today · a month day opens that day · a meeting opens its detail with the
7
+ * calendar as a tab · R6 an empty range and a failed answer say so · R7 390px day list, 44px targets, no sideways scroll, dark theme
8
+ * Every wait polls the page; no fixed sleep stands in for a state. */
9
+ const path = require('path');
10
+ const { spawn } = require('child_process');
11
+ const { findBrowser } = require('./lib/find-browser');
12
+ const T = require('./test-run').configure({ name: 'premium-vw-cal' });
13
+ const B = require('./lib/briefing-premium.js');
14
+ const F = require('./fixtures/briefing-premium-facts.js');
15
+ const model = require('../scripts/calendar-model.js');
16
+
17
+ const BASE = T.BASE;
18
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
20
+ const results = [];
21
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
22
+ let srv = null; let browser = null;
23
+ const finish = async (code) => {
24
+ if (browser) await browser.close().catch(() => {});
25
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
26
+ T.killTmux();
27
+ const bad = results.filter((x) => !x.cond).length;
28
+ console.log(`\n${results.length - bad}/${results.length} premium-vw-cal assertions passed`);
29
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
30
+ };
31
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
32
+
33
+ const pad = (n) => String(n).padStart(2, '0');
34
+ const key = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
35
+ const TODAY = key(new Date());
36
+ const plus = (k, n) => { const [y, m, d] = k.split('-').map(Number); return key(new Date(y, m - 1, d + n)); };
37
+ /* today's meetings: two that overlap and one later; one more in five days, so it falls in a later week of the same or the next month */
38
+ const EVENTS = [
39
+ { id: 'ev-sync', title: 'Onboarding weekly sync', at: `${TODAY}T10:00:00`, end: `${TODAY}T11:00:00`, attendees: ['Sam', 'Lee'] },
40
+ { id: 'ev-over', title: 'Billing meter review', at: `${TODAY}T10:30:00`, end: `${TODAY}T11:30:00`, attendees: ['Ana'] },
41
+ { id: 'ev-late', title: 'Customer call', at: `${TODAY}T15:00:00`, end: `${TODAY}T15:45:00` },
42
+ { id: 'ev-next', title: 'Sprint planning', at: `${plus(TODAY, 8)}T13:00:00`, end: `${plus(TODAY, 8)}T14:30:00` },
43
+ ];
44
+ const answer = (url, mode) => {
45
+ const q = new URL(url).searchParams, view = q.get('view') || 'week', date = q.get('date') || TODAY;
46
+ if (mode === 'fail') return { status: 500, body: { ok: false, error: 'the calendar reader stopped' } };
47
+ const b = model.bucketEvents(mode === 'empty' ? [] : EVENTS, view, date);
48
+ return { status: 200, body: { ok: true, view, range: b.range, unit: b.unit, cells: b.cells, gantt: [], events_source: 'calendar-memory', today: TODAY,
49
+ layers: mode === 'empty' ? [] : [{ id: 'ini:x', date: TODAY, kind: 'initiative', layer: 'initiatives', title: 'Self-serve v2 promised', tone: 'warn' }], context: {}, link_boards: [] } };
50
+ };
51
+
52
+ (async () => {
53
+ const exe = findBrowser();
54
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
55
+ let chromium;
56
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
57
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
58
+ await T.waitForServer(BASE);
59
+ browser = await chromium.launch({ executablePath: exe });
60
+
61
+ const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
62
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
63
+ const page = await ctx.newPage();
64
+ const S = { errors: [], mode: 'full', asks: [] };
65
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
66
+ await page.route('**/api/briefing-premium*', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }) }));
67
+ await page.route('**/api/calendar-views*', (r) => { S.asks.push(r.request().url()); const a = answer(r.request().url(), S.mode); r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
68
+ await page.goto(BASE + '/premium.html?theme=' + theme);
69
+ S.up = await until(() => page.evaluate(() => !!document.querySelector('#todayCard .vc-open') && !!window.__premiumViewer), 20000);
70
+ return { page, ctx, S };
71
+ };
72
+ const vis = (page, sel) => page.evaluate((s) => [...document.querySelectorAll(s)].filter((e) => e.getClientRects().length && getComputedStyle(e).visibility !== 'hidden').length, sel);
73
+ const ready = (page) => until(() => page.evaluate(() => !!document.querySelector('#vcMain .vc-w .vc-h') || !!document.querySelector('.obody.vw[data-vw="cal"] .vc-w .vc-h')));
74
+ const pressed = (page) => page.evaluate(() => { const b = document.querySelector('#dOut .vc-seg [aria-pressed="true"]:not([hidden])'); return b && b.dataset.cv; });
75
+ const title = (page) => page.evaluate(() => { const t = [...document.querySelectorAll('#dOut .vc-t')].find((x) => x.getClientRects().length); return t ? t.textContent : ''; });
76
+
77
+ /* R8 desktop */
78
+ {
79
+ const { page, ctx, S } = await open();
80
+ ok('R8 the Briefing\'s Calendar card has a button that opens the calendar', S.up);
81
+ await page.click('#todayCard .vc-open');
82
+ ok('R8 the button opens a dialog with the calendar as its detail', await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#dTitle').textContent === 'Calendar')) && await ready(page));
83
+ await until(() => vis(page, '#vcMain .vc-ev'));
84
+ ok('R8 it opens on this week, read from GET /api/calendar-views?view=week', (await pressed(page)) === 'week' && S.asks.some((u) => /view=week&date=/.test(u)), S.asks.join(' '));
85
+ ok('R8 the week draws today\'s three meetings as blocks', (await vis(page, '#vcMain .vc-ev')) === 3, String(await vis(page, '#vcMain .vc-ev')));
86
+ const lanes = await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-ev')].filter((b) => /sync|meter/.test(b.textContent)).map((b) => b.getBoundingClientRect()));
87
+ ok('R8 two meetings that overlap sit side by side', lanes.length === 2 && Math.abs(lanes[0].left - lanes[1].left) > 20 && lanes[0].width < 200, JSON.stringify(lanes.map((r) => [r.left, r.width])));
88
+ ok('R8 the all-day row carries the dated layer as a mark', await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-adc .vc-ad')].some((x) => /promised/.test(x.textContent) && x.tagName === 'SPAN')));
89
+ ok('R8 the now line is drawn on today', (await vis(page, '#vcMain .vc-now')) <= 1);
90
+ const wk = await title(page);
91
+ await page.click('#vcMain [data-cn="1"]');
92
+ await until(async () => (await title(page)) !== wk);
93
+ ok('R8 Next moves a week on', (await title(page)) !== wk && S.asks.some((u) => u.includes('date=' + plus(TODAY, 7))), S.asks.slice(-1)[0]);
94
+ await page.click('#vcMain [data-cn="0"]');
95
+ await until(async () => (await title(page)) === wk);
96
+ ok('R8 Today comes back to this week', (await title(page)) === wk);
97
+ await page.click('#vcMain [data-cv="month"]');
98
+ await until(async () => (await pressed(page)) === 'month' && (await vis(page, '#vcMain .vc-md')) >= 28);
99
+ ok('R8 Month draws whole weeks of days', (await vis(page, '#vcMain .vc-md')) % 7 === 0 && (await vis(page, '#vcMain .vc-md')) >= 28 && /\d{4}$/.test(await title(page)), await title(page));
100
+ ok('R8 today\'s cell lists its meetings', await page.evaluate(() => { const c = document.querySelector('#vcMain .vc-md.now'); return !!c && c.querySelectorAll('.vc-me').length === 3; }));
101
+ await page.click('#vcMain .vc-md.now .vc-dn');
102
+ await until(async () => (await pressed(page)) === 'day');
103
+ await until(() => vis(page, '#vcMain .vc-ev'));
104
+ ok('R8 a month day opens that day', (await pressed(page)) === 'day' && S.asks.some((u) => u.includes('view=day&date=' + TODAY)) && (await vis(page, '#vcMain .vc-dh')) === 1);
105
+ await page.click('#vcMain [data-cv="week"]');
106
+ await until(() => vis(page, '#vcMain .vc-ev'));
107
+ await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-ev')].find((b) => /weekly sync/.test(b.textContent)).click());
108
+ ok('R8 a meeting opens its detail, the meeting dialog', await until(() => page.evaluate(() => document.querySelector('#dTitle').textContent === 'Onboarding weekly sync')));
109
+ const tabs = await page.evaluate(() => ({ ...window.__premiumViewer.vwState(), main: !document.querySelector('#oMain').hidden }));
110
+ ok('R8 the calendar stays as a tab beside the meeting, the meeting shown', JSON.stringify(tabs.ids) === '["cal"]' && tabs.on === 'main' && tabs.main, JSON.stringify(tabs));
111
+ await page.click('#vTabs .vtab[data-vw="cal"]');
112
+ await until(() => vis(page, '.obody.vw[data-vw="cal"] .vc-ev'));
113
+ ok('R8 the Calendar tab shows the grid at the same view', (await vis(page, '.obody.vw[data-vw="cal"] .vc-ev')) === 3 && (await pressed(page)) === 'week');
114
+ await page.evaluate(() => [...document.querySelectorAll('.obody.vw[data-vw="cal"] .vc-ev')].find((b) => /Customer call/.test(b.textContent)).click());
115
+ ok('R8 a meeting from the tab opens that meeting, with the tab again', await until(() => page.evaluate(() => document.querySelector('#dTitle').textContent === 'Customer call' && JSON.stringify(window.__premiumViewer.vwState().ids) === '["cal"]')));
116
+
117
+ /* R6 honesty */
118
+ await page.keyboard.press('Escape');
119
+ await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')), 3000);
120
+ S.mode = 'empty';
121
+ await page.click('#todayCard .vc-open');
122
+ await until(() => page.evaluate(() => /No meetings in this week/.test((document.querySelector('#vcMain') || {}).textContent || '')));
123
+ ok('R6 a week with no meetings says so', await page.evaluate(() => /No meetings in this week\./.test(document.querySelector('#vcMain').textContent) && !document.querySelector('#vcMain .vc-ev')));
124
+ S.mode = 'fail';
125
+ await page.click('#vcMain [data-cv="month"]');
126
+ await until(() => page.evaluate(() => /Calendar not read/.test(document.querySelector('#vcMain').textContent)));
127
+ ok('R6 a calendar that did not answer says it was not read, and why', await page.evaluate(() => /Calendar not read\. the calendar reader stopped/.test(document.querySelector('#vcMain').textContent)));
128
+ ok('R8 no page error', S.errors.length === 0, S.errors.join(' | '));
129
+ await ctx.close();
130
+ }
131
+
132
+ /* R7 phone and dark theme */
133
+ {
134
+ const { page, ctx, S } = await open({ w: 390, h: 844, theme: 'dark' });
135
+ await page.click('#todayCard .vc-open');
136
+ await until(() => vis(page, '#vcMain .vc-ar'));
137
+ ok('R7 at 390px the week is a day list, not the timeline', (await vis(page, '#vcMain .vc-ar')) === 3 && (await vis(page, '#vcMain .vc-g')) === 0, String(await vis(page, '#vcMain .vc-ar')));
138
+ const m = async () => page.evaluate(() => {
139
+ const bs = [...document.querySelectorAll('#vcMain button')].filter((b) => b.getClientRects().length).map((b) => b.getBoundingClientRect());
140
+ return { minH: Math.min(...bs.map((r) => r.height)), minW: Math.min(...bs.map((r) => r.width)), over: document.documentElement.scrollWidth > window.innerWidth,
141
+ right: Math.max(...bs.map((r) => r.right)) <= window.innerWidth + 1, bg: getComputedStyle(document.querySelector('#vcMain .vc-w')).backgroundColor };
142
+ });
143
+ let x = await m();
144
+ ok('R7 every control of the week is at least 44px', x.minH >= 44 && x.minW >= 44, JSON.stringify(x));
145
+ ok('R7 the week fits the width, no sideways scroll', x.right && !x.over, JSON.stringify(x));
146
+ ok('R7 in the dark theme the calendar is not a light card', (() => { const c = (x.bg.match(/\d+/g) || []).slice(0, 3).map(Number); return c.length === 3 && c[0] + c[1] + c[2] < 3 * 160; })(), x.bg);
147
+ await page.click('#vcMain [data-cv="month"]');
148
+ await until(() => vis(page, '#vcMain .vc-md'));
149
+ x = await m();
150
+ ok('R7 the month at 390px: day buttons of 44px, no sideways scroll', x.minH >= 44 && x.minW >= 40 && x.right && !x.over && (await vis(page, '#vcMain .vc-me')) === 0, JSON.stringify(x));
151
+ ok('R7 no page error', S.errors.length === 0, S.errors.join(' | '));
152
+ await ctx.close();
153
+ }
154
+ finish();
155
+ })();
@@ -784,5 +784,5 @@ export function mountMeeting(d) {
784
784
  $('#tl').addEventListener('click', (e) => { const b = e.target.closest('.ev[data-w]'); if (!b) return; e.stopImmediatePropagation(); const r = rowOf(b.dataset.w); if (r) openRow(r, 'week'); }, true);
785
785
  readNotes().then(() => mark());
786
786
  { const want = new URLSearchParams(location.search).get('meeting'); if (want) { history.replaceState(null, '', location.pathname + location.search.replace(/[?&]meeting=[^&]*/, '').replace(/^&/, '?')); setTimeout(() => openNote(want), 600); } }
787
- return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote };
787
+ return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote, openRow: (row) => openRow(row, 'week') }; // openRow: the full calendar (premium-vw-cal.js)
788
788
  }
@@ -0,0 +1,96 @@
1
+ @font-face{font-family:"Space Grotesk";src:url(/vendor/space-grotesk-var.woff2) format("woff2");font-weight:300 700;font-display:swap}
2
+ @font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-400.woff2) format("woff2");font-weight:400;font-display:swap}
3
+ @font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-500.woff2) format("woff2");font-weight:500;font-display:swap}
4
+ @font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-700.woff2) format("woff2");font-weight:600 700;font-display:swap}
5
+ :root{--fs-1:11px;--fs-2:12px;--fs-3:14px;--fs-4:16px;--fs-5:20px;--fs-6:28px}
6
+ /* pm/premium-vw-cal.css — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8; premium-vw-cal.js).
7
+ * Loaded once by vwStyle('cal'). Sizes are only var(--fs-1..6), weights 400/500/600 (premium-console-type.test.js).
8
+ * The pane's own width picks the layout: the timeline from 560px, the day list below it (the mockup's Week and Agenda). */
9
+ .vc-open{width:36px;height:36px;border-radius:6px;display:grid;place-items:center;background:var(--well);color:var(--ink-2);flex:none}
10
+ .vc-open .i{width:16px;height:16px}
11
+ .vc{container-type:inline-size}
12
+ .vc .vc-w{background:var(--card-solid);border:1px solid var(--hair);border-radius:8px;box-shadow:var(--card-shadow);overflow:hidden}
13
+ .vc .vc-h{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--hair);flex-wrap:wrap}
14
+ .vc .vc-t{font-size:var(--fs-3);font-weight:600;color:var(--ink)}
15
+ .vc .vc-cap{flex:1;min-width:0;font:400 var(--fs-2) var(--mono);color:var(--ink-3)}
16
+ .vc .vc-ib{width:36px;height:36px;border-radius:6px;display:grid;place-items:center;background:var(--well);color:var(--ink)}
17
+ .vc .vc-ib .i{width:16px;height:16px}
18
+ .vc .vc-tdy{min-height:36px;padding:0 12px;border-radius:6px;border:1px solid var(--hair);font-size:var(--fs-2);font-weight:500;color:var(--ink)}
19
+ .vc .vc-seg{display:flex;gap:2px;padding:3px;border-radius:8px;background:var(--well)}
20
+ .vc .vc-seg button{min-height:32px;padding:0 12px;border-radius:6px;font-size:var(--fs-2);font-weight:500;color:var(--ink-2)}
21
+ .vc .vc-seg button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
22
+ .vc button:focus-visible{outline:2px solid var(--ember);outline-offset:2px}
23
+ .vc .vc-empty{margin:0;padding:12px 14px;font-size:var(--fs-2);color:var(--ink-3);border-bottom:1px solid var(--hair)}
24
+ .vc .vc-w>.vc-empty:last-child{border-bottom:0}
25
+ /* the timeline (Day and Week) */
26
+ .vc .vc-g{display:grid;grid-template-columns:48px repeat(var(--tl-n),minmax(0,1fr))}
27
+ .vc .vc-dh{padding:8px 6px 6px;font-size:var(--fs-2);color:var(--ink-3);border-left:1px solid var(--hair);text-align:center}
28
+ .vc .vc-dh b{display:grid;place-items:center;margin:2px auto 0;width:30px;height:30px;border-radius:6px;font-size:var(--fs-4);font-weight:600;color:var(--ink)}
29
+ .vc .vc-dh.now b{background:var(--solid);color:var(--on-solid)}
30
+ .vc .vc-adl{border-top:1px solid var(--hair);font:400 var(--fs-1) var(--mono);color:var(--ink-3);padding:6px 4px 0;text-align:right}
31
+ .vc .vc-adc{min-height:28px;border-left:1px solid var(--hair);border-top:1px solid var(--hair);padding:3px;display:grid;gap:2px;align-content:start}
32
+ .vc .vc-ad{display:block;min-width:0;border-radius:6px;padding:1px 6px;font-size:var(--fs-1);font-weight:500;line-height:1.5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;
33
+ border-left:3px solid var(--ec,var(--ember));background:color-mix(in oklab,var(--ec,var(--ember)) 12%,transparent);color:var(--ink)}
34
+ .vc .vc-ad.meet{--ec:var(--sky)}
35
+ .vc .vc-ad.t-warn{--ec:var(--ember)}.vc .vc-ad.t-bad{--ec:var(--bad)}.vc .vc-ad.t-ok{--ec:var(--ok)}
36
+ .vc .vc-gut{border-top:1px solid var(--hair);font:400 var(--fs-1) var(--mono);color:var(--ink-3)}
37
+ .vc .vc-gut i{display:block;height:44px;font-style:normal;text-align:right;padding-right:6px;transform:translateY(-7px)}
38
+ .vc .vc-gut i:first-child{visibility:hidden}
39
+ .vc .vc-day{position:relative;height:var(--tl-hh);border-left:1px solid var(--hair);border-top:1px solid var(--hair);background:repeating-linear-gradient(to bottom,transparent 0 43px,var(--hair) 43px 44px)}
40
+ .vc .vc-day.past{background-color:color-mix(in oklab,var(--well) 40%,transparent)}
41
+ .vc .vc-ev{position:absolute;top:var(--tl-t);height:var(--tl-h);left:calc(var(--tl-l) + 3px);width:calc(var(--tl-w) - 6px);border-radius:6px;padding:3px 7px;font-size:var(--fs-1);line-height:1.3;overflow:hidden;text-align:left;
42
+ border-left:3px solid var(--sky);background:color-mix(in oklab,var(--sky) 14%,var(--card-solid));color:var(--ink);z-index:1}
43
+ .vc .vc-ev b{display:block;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
44
+ .vc .vc-ev small{display:block;font-size:var(--fs-1);color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
45
+ .vc .vc-ev.sh{padding:0 7px;display:flex;align-items:center}.vc .vc-ev.sh small{display:none}
46
+ .vc .vc-ev.past{opacity:.7}
47
+ .vc .vc-now{position:absolute;top:var(--tl-t);left:0;right:0;height:2px;background:var(--bad);z-index:2;pointer-events:none}
48
+ .vc .vc-now::before{content:"";position:absolute;left:-4px;top:-3px;width:8px;height:8px;border-radius:6px;background:var(--bad)}
49
+ /* the day list (Day and Week in a narrow pane) */
50
+ .vc .vc-ag{display:none}
51
+ .vc .vc-ag h4{margin:0;padding:10px 14px 4px;font-size:var(--fs-2);font-weight:600;color:var(--ink-3);border-top:1px solid var(--hair)}
52
+ .vc .vc-ag h4:first-child{border-top:0}
53
+ .vc .vc-ag h4.now{color:var(--ember-ink)}
54
+ .vc .vc-ag>.vc-ad{margin:2px 10px}
55
+ .vc .vc-ar{display:flex;gap:10px;align-items:baseline;width:calc(100% - 20px);min-height:44px;margin:3px 10px;padding:8px 10px;border-radius:8px;text-align:left;
56
+ border-left:3px solid var(--sky);background:color-mix(in oklab,var(--sky) 12%,transparent);color:var(--ink);font-size:var(--fs-3)}
57
+ .vc .vc-ar time{width:48px;flex:none;font:400 var(--fs-2) var(--mono);color:var(--ink-2)}
58
+ .vc .vc-ar span{min-width:0}
59
+ .vc .vc-ar b{display:block;font-weight:500}
60
+ .vc .vc-ar small{display:block;font-size:var(--fs-2);color:var(--ink-3)}
61
+ .vc .vc-ar.past{opacity:.7}
62
+ .vc .vc-none{margin:0;padding:4px 14px 10px;font-size:var(--fs-2);color:var(--ink-3)}
63
+ @container (max-width:559px){.vc .vc-g{display:none}.vc .vc-ag{display:block;padding-bottom:8px}}
64
+ /* the month */
65
+ .vc .vc-mh{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));border-bottom:1px solid var(--hair)}
66
+ .vc .vc-mh span{padding:6px 8px;font:400 var(--fs-1) var(--mono);text-transform:uppercase;letter-spacing:.06em;color:var(--ink-3)}
67
+ .vc .vc-mb{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}
68
+ .vc .vc-md{min-width:0;min-height:96px;padding:4px;border-left:1px solid var(--hair);border-top:1px solid var(--hair);display:flex;flex-direction:column;gap:2px}
69
+ .vc .vc-md:nth-child(7n+1){border-left:0}
70
+ .vc .vc-md:nth-child(-n+7){border-top:0}
71
+ .vc .vc-md.out{background:color-mix(in oklab,var(--well) 50%,transparent)}
72
+ .vc .vc-md.out .vc-dn b{color:var(--ink-3)}
73
+ .vc .vc-dn{display:flex;align-items:center;gap:6px;min-height:28px;padding:0 4px;border-radius:6px;text-align:left}
74
+ .vc .vc-dn b{display:grid;place-items:center;min-width:24px;height:24px;border-radius:6px;font-size:var(--fs-2);font-weight:600;color:var(--ink)}
75
+ .vc .vc-md.now .vc-dn b{background:var(--solid);color:var(--on-solid)}
76
+ .vc .vc-dn i{display:none;font-style:normal;font:500 var(--fs-1) var(--mono);color:var(--ink-3)}
77
+ .vc .vc-me{display:block;min-width:0;border-radius:6px;padding:2px 6px;font-size:var(--fs-1);line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;color:var(--ink);
78
+ background:color-mix(in oklab,var(--sky) 12%,transparent)}
79
+ .vc .vc-me time{font:400 var(--fs-1) var(--mono);color:var(--ink-2);margin-right:4px}
80
+ .vc .vc-md>.vc-ad{font-size:var(--fs-1)}
81
+ .vc .vc-more{align-self:flex-start;padding:1px 6px;border-radius:6px;font-size:var(--fs-1);font-weight:500;color:var(--ink-3)}
82
+ @container (max-width:559px){
83
+ .vc .vc-md{min-height:48px;padding:2px}
84
+ .vc .vc-md>.vc-me,.vc .vc-md>.vc-more,.vc .vc-md>.vc-ad{display:none}
85
+ .vc .vc-dn{flex:1;flex-direction:column;justify-content:center;gap:2px;min-height:44px;padding:0}
86
+ .vc .vc-dn i{display:block}
87
+ .vc .vc-mh span{padding:6px 2px;text-align:center}
88
+ }
89
+ @media (max-width:640px){.vc-open,.vc .vc-ib{width:44px;height:44px}.vc .vc-tdy,.vc .vc-seg button{min-height:44px}}
90
+ @media (hover:hover){
91
+ .vc-open:hover{color:var(--ink)}
92
+ .vc .vc-ev:hover{background:color-mix(in oklab,var(--sky) 24%,var(--card-solid))}
93
+ .vc .vc-dn:hover{background:var(--well)}
94
+ .vc .vc-me:hover{background:color-mix(in oklab,var(--sky) 22%,transparent)}
95
+ .vc .vc-more:hover{color:var(--ink);background:var(--well)}
96
+ }
@@ -0,0 +1,197 @@
1
+ /* pm/premium-vw-cal.js — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8).
2
+ * Reads GET /api/calendar-views?view=day|week|month&date=YYYY-MM-DD only, the same answer the console's Calendar draws (pm/calendar-views.js).
3
+ * Meetings come from the answer's cells; the all-day row also carries the answer's dated layers (an initiative's promised date, a plan item,
4
+ * a release, a report, your own due items). Nothing is invented: a range with no meeting says so, and a calendar that did not answer says why.
5
+ * Pressing a meeting opens its detail (premium-meeting.js openRow, the meeting dialog of slice S3) with the calendar as a tab beside it.
6
+ * The mockup is the iteration-3 calendar of prototype/premium-conversation-shell/index.html (.calw, .cg, .ev, .agd).
7
+ * calModel(r, view, date, today) pure · calHtml(M, esc) pure · mountCal(el, st, d) · openCalendar(d, st?) */
8
+ import { weekView } from './premium-meeting.js';
9
+ import { vwOpen, vwShow, vwStyle } from './premium-viewer.js';
10
+
11
+ export const VIEWS = [['day', 'Day'], ['week', 'Week'], ['month', 'Month']];
12
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
13
+ const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
14
+ const DOW = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
15
+ const pad = (n) => String(n).padStart(2, '0');
16
+ const parts = (k) => k.split('-').map(Number);
17
+ const keyOf = (t) => `${t.getUTCFullYear()}-${pad(t.getUTCMonth() + 1)}-${pad(t.getUTCDate())}`;
18
+ const addDays = (k, n) => { const [y, m, d] = parts(k); return keyOf(new Date(Date.UTC(y, m - 1, d + n))); };
19
+ const wd = (k) => { const [y, m, d] = parts(k); return (new Date(Date.UTC(y, m - 1, d)).getUTCDay() + 6) % 7; }; // Monday is 0
20
+ const hasTime = (s) => /T\d{2}:\d{2}/.test(String(s || ''));
21
+ const minOf = (s) => Number(String(s).slice(11, 13)) * 60 + Number(String(s).slice(14, 16)); // the wall clock as written, like premium-meeting.js hhmm
22
+ const hh = (m) => `${pad(Math.floor(m / 60))}:${pad(m % 60)}`;
23
+ export const todayKey = () => { const t = new Date(); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
24
+
25
+ /** The date one step before (-1) or after (1) `date` in `view`. */
26
+ export function shift(view, date, dir) {
27
+ const [y, m, d] = parts(date);
28
+ if (view === 'day') return addDays(date, dir);
29
+ if (view === 'week') return addDays(date, 7 * dir);
30
+ return keyOf(new Date(Date.UTC(y, m - 1 + dir, 1)));
31
+ }
32
+
33
+ /** The range's name: "Mon 19 Oct 2026", "19 – 25 Oct 2026" (or "28 Sep – 4 Oct 2026"), "October 2026". */
34
+ export function titleOf(view, range) {
35
+ const [y1, m1, d1] = parts(range.start), [y2, m2, d2] = parts(range.end);
36
+ if (view === 'month') return `${MONTH[m1 - 1]} ${y1}`;
37
+ if (view === 'day') return `${DOW[wd(range.start)]} ${d1} ${MON[m1 - 1]} ${y1}`;
38
+ if (y1 !== y2) return `${d1} ${MON[m1 - 1]} ${y1} – ${d2} ${MON[m2 - 1]} ${y2}`;
39
+ return m1 === m2 ? `${d1} – ${d2} ${MON[m2 - 1]} ${y2}` : `${d1} ${MON[m1 - 1]} – ${d2} ${MON[m2 - 1]} ${y2}`;
40
+ }
41
+
42
+ /** Side by side lanes for meetings that overlap on one day. Mutates each block with lane and lanes. */
43
+ function lanes(blocks) {
44
+ blocks.sort((a, b) => a.s - b.s || b.e - a.e);
45
+ let group = [], end = -1;
46
+ const close = () => { const n = Math.max(1, ...group.map((b) => b.lane + 1)); group.forEach((b) => { b.lanes = n; }); group = []; };
47
+ for (const b of blocks) {
48
+ if (b.s >= end && group.length) close();
49
+ const taken = new Set(group.filter((g) => g.e > b.s).map((g) => g.lane));
50
+ let l = 0; while (taken.has(l)) l++;
51
+ b.lane = l; group.push(b); end = Math.max(end, b.e);
52
+ }
53
+ if (group.length) close();
54
+ return blocks;
55
+ }
56
+
57
+ /** The grid as drawn. `r` is the answer of GET /api/calendar-views for `view`, or { ok:false, error }. Every block is a meeting row of
58
+ * weekView (premium-meeting.js), so pressing it opens the same meeting dialog the Briefing's card opens. */
59
+ export function calModel(r, view, date, today) {
60
+ const W = weekView(r, today);
61
+ const range = (r && r.range) || { start: date, end: date };
62
+ const base = { view, date, today, title: r && r.range ? titleOf(view, r.range) : '' };
63
+ if (W.state !== 'ok') return { ...base, state: 'error', reason: W.reason, days: [], total: 0, caption: 'Calendar not read' };
64
+ const layers = Array.isArray(r.layers) ? r.layers.filter((x) => x && x.title && /^\d{4}-\d{2}-\d{2}/.test(String(x.date))) : [];
65
+ const byKey = new Map(W.days.map((x) => [x.key, x]));
66
+ let from = 8 * 60, to = 18 * 60;
67
+ const dayOf = (key) => {
68
+ const src = byKey.get(key), rows = src ? src.rows : [];
69
+ const timed = [], allday = [];
70
+ rows.forEach((row, i) => {
71
+ const ref = key + '|' + i;
72
+ if (hasTime(row.at) && String(row.at).slice(0, 10) === key) {
73
+ const s = minOf(row.at), endSame = row.end && hasTime(row.end) && String(row.end).slice(0, 10) === key;
74
+ const e = Math.max(s + 15, endSame ? minOf(row.end) : row.end ? 24 * 60 : s + 30);
75
+ from = Math.min(from, Math.floor(s / 60) * 60); to = Math.max(to, Math.min(24 * 60, Math.ceil(e / 60) * 60));
76
+ timed.push({ ref, s, e, title: row.title, time: `${hh(s)}–${hh(e)}`, sub: row.sub, about: row.about, past: row.past, row });
77
+ } else allday.push({ ref, title: row.title, sub: row.sub, kind: 'meet', row });
78
+ });
79
+ for (const x of layers) {
80
+ const a = String(x.date).slice(0, 10), b = x.end && /^\d{4}-\d{2}-\d{2}/.test(String(x.end)) ? String(x.end).slice(0, 10) : a;
81
+ if (a <= key && key <= b) allday.push({ title: x.title, kind: x.kind || x.layer || 'mark', tone: x.tone || null });
82
+ }
83
+ const [, m, d] = parts(key);
84
+ return { key, dow: DOW[wd(key)], n: d, mon: MON[m - 1], label: `${DOW[wd(key)]} ${d} ${MON[m - 1]}`, today: key === today, past: key < today,
85
+ inRange: key >= range.start && key <= range.end, timed: lanes(timed), allday, meetings: rows.length };
86
+ };
87
+ let keys = [];
88
+ if (view === 'month') {
89
+ const first = addDays(range.start, -wd(range.start)), last = addDays(range.end, 6 - wd(range.end));
90
+ for (let k = first; k <= last; k = addDays(k, 1)) keys.push(k);
91
+ } else for (let k = range.start; k <= range.end; k = addDays(k, 1)) keys.push(k);
92
+ let days = keys.map(dayOf);
93
+ // the week shows Saturday and Sunday only when they hold something, or one is today
94
+ if (view === 'week') days = days.filter((x) => wd(x.key) < 5 || x.today || x.meetings || x.allday.length);
95
+ const total = days.filter((x) => x.inRange).reduce((s, x) => s + x.meetings, 0);
96
+ const none = r.events_source === 'none' ? 'PMOS holds no calendar to read.' : `No meetings ${view === 'day' ? 'on this day' : 'in this ' + view}.`;
97
+ return { ...base, state: 'ok', days, from, to, total, caption: total ? `${total} ${total === 1 ? 'meeting' : 'meetings'}` : 'No meetings', empty: total ? '' : none };
98
+ }
99
+
100
+ const ICON = {
101
+ back: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6',
102
+ };
103
+ const ic = (k) => `<svg class="i" viewBox="0 0 24 24"><path d="${ICON[k]}"/></svg>`;
104
+
105
+ /** The grid's markup. Both the timeline and the list are drawn for Day and Week; the pane's width picks one (premium-vw-cal.css). */
106
+ export function calHtml(M, esc, nowMin = null) {
107
+ const H = 44, top = (m) => ((m - M.from) / 60) * H;
108
+ const seg = `<div class="vc-seg" role="group" aria-label="Calendar view">${VIEWS.map(([k, l]) => `<button type="button" data-cv="${k}" aria-pressed="${M.view === k}">${l}</button>`).join('')}</div>`;
109
+ const step = M.view === 'day' ? 'day' : M.view === 'week' ? 'week' : 'month';
110
+ const head = `<div class="vc-h"><button type="button" class="vc-ib" data-cn="-1" aria-label="Previous ${step}">${ic('back')}</button><button type="button" class="vc-ib" data-cn="1" aria-label="Next ${step}">${ic('next')}</button><button type="button" class="vc-tdy" data-cn="0">Today</button><b class="vc-t">${esc(M.title)}</b><small class="vc-cap">${esc(M.caption)}</small>${seg}</div>`;
111
+ if (M.state !== 'ok') return `<div class="vc-w">${head}<p class="vc-empty" role="status">Calendar not read. ${esc(M.reason)}</p></div>`;
112
+ const chip = (a) => a.row ? `<button type="button" class="vc-ad meet" data-ev="${esc(a.ref)}" title="${esc(a.title)}">${esc(a.title)}</button>` : `<span class="vc-ad ${esc(a.kind)}${a.tone ? ' t-' + esc(a.tone) : ''}" title="${esc(a.title)}">${esc(a.title)}</span>`;
113
+ const empty = M.empty ? `<p class="vc-empty" role="status">${esc(M.empty)}</p>` : '';
114
+ if (M.view === 'month') {
115
+ const cells = M.days.map((x) => {
116
+ const ev = [...x.allday.filter((a) => a.row), ...x.timed].sort((a, b) => (a.s || 0) - (b.s || 0));
117
+ const say = `${x.label}${x.today ? ', today' : ''}: ${x.meetings ? x.meetings + (x.meetings === 1 ? ' meeting' : ' meetings') : 'no meetings'}`;
118
+ return `<div class="vc-md${x.inRange ? '' : ' out'}${x.today ? ' now' : ''}${x.past ? ' past' : ''}"><button type="button" class="vc-dn" data-day="${x.key}" aria-label="${esc(say)}"><b>${x.n}</b>${x.meetings ? `<i>${x.meetings}</i>` : ''}</button>${x.allday.filter((a) => !a.row).slice(0, 1).map(chip).join('')}${ev.slice(0, 3).map((e) => `<button type="button" class="vc-me" data-ev="${esc(e.ref)}" title="${esc(e.title)}">${e.s != null ? `<time>${hh(e.s)}</time>` : ''}${esc(e.title)}</button>`).join('')}${ev.length > 3 ? `<button type="button" class="vc-more" data-day="${x.key}">${ev.length - 3} more</button>` : ''}</div>`;
119
+ }).join('');
120
+ return `<div class="vc-w">${head}<div class="vc-mg"><div class="vc-mh">${DOW.map((d) => `<span>${d}</span>`).join('')}</div><div class="vc-mb">${cells}</div></div>${empty}</div>`;
121
+ }
122
+ const n = M.days.length, hours = [];
123
+ for (let m = M.from; m < M.to; m += 60) hours.push(m);
124
+ const blk = (e) => `<button type="button" class="vc-ev${e.past ? ' past' : ''}${e.e - e.s < 30 ? ' sh' : ''}" data-ev="${esc(e.ref)}" data-tl="${top(e.s) + 1}px ${Math.max(14, ((e.e - e.s) / 60) * H - 3)}px ${(e.lane / e.lanes) * 100}% ${100 / e.lanes}%" title="${esc(e.title + ' · ' + e.time)}"><b>${esc(e.title)}</b><small>${e.time}</small></button>`;
125
+ const grid = `<div class="vc-g" data-tl="${n}"><div class="vc-c"></div>${M.days.map((x) => `<div class="vc-dh${x.today ? ' now' : ''}">${x.dow}<b>${x.n}</b></div>`).join('')}<div class="vc-adl">all day</div>${M.days.map((x) => `<div class="vc-adc">${x.allday.map(chip).join('')}</div>`).join('')}<div class="vc-gut">${hours.map((m) => `<i>${hh(m)}</i>`).join('')}</div>${M.days.map((x) => `<div class="vc-day${x.past ? ' past' : ''}" data-tl="${hours.length * H}px">${x.today && nowMin != null && nowMin >= M.from && nowMin <= M.to ? `<span class="vc-now" data-tl="${top(nowMin)}px" aria-hidden="true"></span>` : ''}${x.timed.map(blk).join('')}</div>`).join('')}</div>`;
126
+ const list = `<div class="vc-ag">${M.days.map((x) => { const rows = [...x.allday.filter((a) => a.row), ...x.timed]; return `<h4${x.today ? ' class="now"' : ''}>${x.label}${x.today ? ' · today' : ''}</h4>${x.allday.filter((a) => !a.row).map(chip).join('')}${rows.length ? rows.map((e) => `<button type="button" class="vc-ar${e.past ? ' past' : ''}" data-ev="${esc(e.ref)}"><time>${e.s != null ? hh(e.s) : 'All day'}</time><span><b>${esc(e.title)}</b>${e.sub || e.about ? `<small>${esc([e.sub, e.about].filter(Boolean).join(' · '))}</small>` : ''}</span></button>`).join('') : '<p class="vc-none">No meetings</p>'}`; }).join('')}</div>`;
127
+ return `<div class="vc-w">${head}${empty}${grid}${list}</div>`;
128
+ }
129
+
130
+ /** The run-time geometry of the timeline: data-tl on a block is "top height left width", on the grid its column count, on a day its height. */
131
+ export function placeAll(el) {
132
+ el.querySelectorAll('[data-tl]').forEach((n) => {
133
+ const v = n.dataset.tl.split(' ');
134
+ if (n.classList.contains('vc-ev')) ['--tl-t', '--tl-h', '--tl-l', '--tl-w'].forEach((k, i) => n.style.setProperty(k, v[i]));
135
+ else if (n.classList.contains('vc-g')) n.style.setProperty('--tl-n', v[0]);
136
+ else if (n.classList.contains('vc-day')) n.style.setProperty('--tl-hh', v[0]);
137
+ else n.style.setProperty('--tl-t', v[0]);
138
+ });
139
+ }
140
+
141
+ const S = new WeakMap(); // host -> { st, M, seq }
142
+
143
+ /** Draws the grid in `el` and keeps it live. st = { view, date }. d = { pmGet, esc, ws(), openRow(row) } */
144
+ export function mountCal(el, st, d) {
145
+ vwStyle('cal');
146
+ const me = { st: { view: (st && st.view) || 'week', date: (st && st.date) || todayKey() }, M: null, seq: 0 };
147
+ S.set(el, me); el.classList.add('vc');
148
+ const nowMin = () => { const t = new Date(); return t.getHours() * 60 + t.getMinutes(); };
149
+ const paint = () => { el.innerHTML = me.M ? calHtml(me.M, d.esc, nowMin()) : `<div class="vc-w"><p class="vc-empty" role="status">Reading the calendar PMOS holds.</p></div>`; placeAll(el); };
150
+ const read = async () => {
151
+ const n = ++me.seq, { view, date } = me.st, w = d.ws && d.ws();
152
+ const res = await d.pmGet(`/api/calendar-views?view=${view}&date=${date}${w ? '&ws=' + encodeURIComponent(w) : ''}`);
153
+ if (n !== me.seq || !el.isConnected) return;
154
+ me.M = calModel(res, view, date, todayKey()); paint();
155
+ };
156
+ const go = (view, date, focus) => { me.st = { view, date }; read().then(() => { if (!focus) return; const b = el.querySelector(focus); if (b) b.focus(); }); };
157
+ el.onclick = (e) => { // delegated: every control of the grid is a button inside el
158
+ const b = e.target.closest('button'); if (!b || !el.contains(b)) return;
159
+ if (b.dataset.cv) return go(b.dataset.cv, me.st.date, `[data-cv="${b.dataset.cv}"]`);
160
+ if (b.dataset.cn != null) { const dir = +b.dataset.cn; return go(me.st.view, dir ? shift(me.st.view, me.st.date, dir) : todayKey(), `[data-cn="${b.dataset.cn}"]`); }
161
+ if (b.dataset.day) return go('day', b.dataset.day, '[data-cv="day"]');
162
+ if (b.dataset.ev) {
163
+ const [k, i] = b.dataset.ev.split('|'), x = me.M && me.M.days.find((y) => y.key === k);
164
+ const hit = x && [...x.timed, ...x.allday].find((y) => y.ref === k + '|' + i);
165
+ if (hit && hit.row && d.openRow) d.openRow(hit.row, { ...me.st });
166
+ }
167
+ };
168
+ paint(); read();
169
+ return { state: () => ({ ...me.st }), reload: read };
170
+ }
171
+
172
+ /** The calendar on its own: a dialog whose detail is the grid. d = { openDlg, turnA, ptx, $, pmGet, esc, ws(), openRow(row) } where openRow
173
+ * opens the meeting dialog. After a meeting opens, the grid comes back as a tab beside it at the same view and date. */
174
+ export function openCalendar(d, st) {
175
+ const open = (row, at) => {
176
+ d.openRow(row); // openDlg runs at once inside, so the tab below belongs to the meeting's dialog
177
+ vwOpen({ id: 'cal', title: 'Calendar', icon: 'cal', render: (el) => { el.classList.add('vc'); mountCal(el, at, { ...d, openRow: open }); } });
178
+ vwShow('main');
179
+ };
180
+ d.openDlg({ eye: 'Calendar · real data', title: 'Calendar', stream: d.turnA(d.ptx('This is the calendar PMOS holds. Press a meeting to open its detail; the calendar stays as a tab beside it.')),
181
+ pane: '<div class="vc" id="vcMain"></div>', label: 'Calendar' });
182
+ const f = d.$('#askF'); if (f) f.hidden = true;
183
+ return mountCal(d.$('#vcMain'), st || { view: 'week', date: todayKey() }, { ...d, openRow: open });
184
+ }
185
+
186
+ /** The Briefing's Calendar card gets a button that opens the full calendar. */
187
+ export function mountCalEntry(card, d) {
188
+ if (!card || card.querySelector('.vc-open')) return;
189
+ vwStyle('cal');
190
+ const b = document.createElement('button'); b.type = 'button'; b.className = 'vc-open'; b.setAttribute('aria-label', 'Open the calendar'); b.title = 'Open the calendar';
191
+ b.innerHTML = '<svg class="i" viewBox="0 0 24 24"><path d="M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7"/></svg>';
192
+ const h = card.querySelector('.ch'), fold = h && h.querySelector('.foldb');
193
+ if (fold) fold.before(b); else if (h) h.append(b);
194
+ b.onclick = () => openCalendar(d);
195
+ }
196
+
197
+ if (typeof window !== 'undefined') window.__premiumCal = { calModel, openCalendar };
@@ -5,6 +5,7 @@
5
5
  import { pmPost, pmGet } from './http.js';
6
6
  import { startAgent } from './page-agent.js';
7
7
  import { mountMeeting } from './premium-meeting.js';
8
+ import { mountCalEntry } from './premium-vw-cal.js';
8
9
  import { mountFirst } from './premium-first.js';
9
10
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
10
11
  import { consoleReads, briefOf, needsListOf } from './premium-brief.js';
@@ -23,6 +24,7 @@ const pinned = new Set();
23
24
 
24
25
  wireRail('brief');
25
26
  const week = mountMeeting({ $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, ws: () => new URLSearchParams(location.search).get('ws'), redraw: () => { if (M) drawTl(); } });
27
+ mountCalEntry($('#todayCard'), { $, esc, openDlg, turnA, ptx, pmGet, ws: () => new URLSearchParams(location.search).get('ws'), openRow: week.openRow }); // the full calendar: Day, Week and Month in the viewer
26
28
 
27
29
  /* ── a day's baseline, kept on this device, so "N of M done" counts rows that cleared since the page first read today ────── */
28
30
  const dayKey = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
@@ -0,0 +1,13 @@
1
+ {
2
+ "_comment": "Initiative premium-viewer, R8: the calendar grid (Day, Week, Month) in the premium viewer, opened from the Briefing's Calendar card.",
3
+ "modules": [
4
+ "premium-vw-cal.test.js"
5
+ ],
6
+ "panels": [
7
+ "premium-vw-cal-test.js"
8
+ ],
9
+ "seconds": {
10
+ "premium-vw-cal.test.js": 2,
11
+ "premium-vw-cal-test.js": 60
12
+ }
13
+ }