@action-state-group/capsule-viewer 0.13.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,979 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * The History view (docs/design/history-view.md, capsule-viewer#247): one
4
+ * History page for Muse's private History, the mesh-llm console's saved
5
+ * History page and the Goose History card, on the actionstate-muse#203
6
+ * anatomy.
7
+ *
8
+ * The view draws; it never fetches and never verifies. Its caller passes a
9
+ * `history-view/v0` object built from what the caller itself checked, and
10
+ * the view decides the layout, the words and which slots may fill. Unknown
11
+ * members are refused, so a caller cannot pass words or a "filled" flag.
12
+ *
13
+ * The page is built once as an element tree and written two ways: as HTML
14
+ * text (`historyViewHtml`, for static pages) and as DOM (`renderHistoryView`,
15
+ * for scripted pages), so both are the same page. Caller text is only ever
16
+ * text: it never goes in an attribute and is never parsed as HTML.
17
+ */
18
+ import PACK from "./wording/history-view.en.json" with { type: "json" };
19
+ export const HISTORY_VIEW = "history-view/v0";
20
+ /** The view's check ids (design note §3). Words for each are `check.<id>`. */
21
+ export const HISTORY_CHECK_IDS = [
22
+ "readable",
23
+ "refusal",
24
+ "artifact_digest",
25
+ "card_digest",
26
+ "checkpoint_signatures",
27
+ "checkpoint_chain",
28
+ "consistency",
29
+ "anchor",
30
+ "period_counts",
31
+ "envelope_signature",
32
+ "key_is_node",
33
+ "reply_bound",
34
+ "witness",
35
+ "second_signature",
36
+ "deal_report",
37
+ ];
38
+ /** Checks whose failure is drawn in its chip or row slot, never as the page's verdict. */
39
+ const SLOT_CHECKS = new Set([
40
+ "witness",
41
+ "second_signature",
42
+ ]);
43
+ const BASE = PACK.entries;
44
+ /** The view's wording pack, as shipped (neutral words only). */
45
+ export const HISTORY_VIEW_WORDING = PACK;
46
+ /** A refused input: every reason the view found. */
47
+ export class HistoryViewRefused extends Error {
48
+ reasons;
49
+ constructor(reasons) {
50
+ super(`history-view refused: ${reasons.join("; ")}`);
51
+ this.name = "HistoryViewRefused";
52
+ this.reasons = reasons;
53
+ }
54
+ }
55
+ const TOKEN = /^[a-z0-9 _.-]*$/u;
56
+ function el(tag, attrs, ...children) {
57
+ const pairs = Object.entries(attrs ?? {});
58
+ for (const [name, value] of pairs)
59
+ if (!TOKEN.test(name) || !TOKEN.test(value))
60
+ throw new Error(`history-view: attribute ${name}=${value} is not a view token`);
61
+ return {
62
+ tag,
63
+ attrs: pairs,
64
+ children: children.filter((c) => c !== null && c !== false),
65
+ };
66
+ }
67
+ function escapeText(text) {
68
+ return text.replace(/[&<> ]/gu, (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : c === ">" ? "&gt;" : "&nbsp;");
69
+ }
70
+ /** The tree as HTML, by the HTML fragment serialization rules. */
71
+ export function serializeHistoryElement(node) {
72
+ if (typeof node === "string")
73
+ return escapeText(node);
74
+ const attrs = node.attrs.map(([n, v]) => ` ${n}="${v}"`).join("");
75
+ return `<${node.tag}${attrs}>${node.children.map(serializeHistoryElement).join("")}</${node.tag}>`;
76
+ }
77
+ /** The tree as DOM, text set as text nodes only. */
78
+ export function historyElementToDom(node, doc) {
79
+ if (typeof node === "string")
80
+ return doc.createTextNode(node);
81
+ const out = doc.createElement(node.tag);
82
+ for (const [n, v] of node.attrs)
83
+ out.setAttribute(n, v);
84
+ for (const child of node.children)
85
+ out.appendChild(historyElementToDom(child, doc));
86
+ return out;
87
+ }
88
+ class Reader {
89
+ reasons = [];
90
+ refuse(path, why) {
91
+ this.reasons.push(`${path}: ${why}`);
92
+ }
93
+ object(v, path, allowed, required) {
94
+ if (typeof v !== "object" || v === null || Array.isArray(v)) {
95
+ this.refuse(path, "is not an object");
96
+ return null;
97
+ }
98
+ const o = v;
99
+ for (const k of Object.keys(o))
100
+ if (!allowed.includes(k))
101
+ this.refuse(`${path}.${k}`, "is not a member of history-view/v0");
102
+ for (const k of required)
103
+ if (!(k in o))
104
+ this.refuse(`${path}.${k}`, "is missing");
105
+ return o;
106
+ }
107
+ string(v, path, max = 2000) {
108
+ if (typeof v !== "string" || v.length === 0 || v.length > max) {
109
+ this.refuse(path, `is not a string of 1 to ${max} characters`);
110
+ return undefined;
111
+ }
112
+ return v;
113
+ }
114
+ oneOf(v, path, values) {
115
+ if (typeof v !== "string" || !values.includes(v)) {
116
+ this.refuse(path, `is not one of ${values.join(", ")}`);
117
+ return undefined;
118
+ }
119
+ return v;
120
+ }
121
+ bool(v, path) {
122
+ if (typeof v !== "boolean") {
123
+ this.refuse(path, "is not true or false");
124
+ return undefined;
125
+ }
126
+ return v;
127
+ }
128
+ count(v, path) {
129
+ if (typeof v !== "number" || !Number.isSafeInteger(v) || v < 0) {
130
+ this.refuse(path, "is not a whole number of 0 or more");
131
+ return undefined;
132
+ }
133
+ return v;
134
+ }
135
+ time(v, path) {
136
+ const s = this.string(v, path, 64);
137
+ if (s === undefined)
138
+ return undefined;
139
+ const t = parseInstant(s);
140
+ if (t === undefined)
141
+ this.refuse(path, "is not an RFC 3339 time");
142
+ return t;
143
+ }
144
+ date(v, path) {
145
+ const s = this.string(v, path, 64);
146
+ if (s === undefined)
147
+ return undefined;
148
+ const t = /^\d{4}-\d{2}-\d{2}$/u.test(s)
149
+ ? parseInstant(`${s}T00:00:00Z`)
150
+ : parseInstant(s);
151
+ if (t === undefined)
152
+ this.refuse(path, "is not a date (YYYY-MM-DD) or an RFC 3339 time");
153
+ return t;
154
+ }
155
+ }
156
+ function parseInstant(s) {
157
+ const m = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?([Zz]|[+-]\d{2}:\d{2})$/u.exec(s);
158
+ if (!m)
159
+ return undefined;
160
+ const [, y, mo, d, h, mi, se, frac = "", zone = "Z"] = m;
161
+ const month = Number(mo);
162
+ const day = Number(d);
163
+ if (month < 1 ||
164
+ month > 12 ||
165
+ day < 1 ||
166
+ day > 31 ||
167
+ Number(h) > 23 ||
168
+ Number(mi) > 59 ||
169
+ Number(se) > 59)
170
+ return undefined;
171
+ let ms = Date.UTC(Number(y), month - 1, day, Number(h), Number(mi), Number(se));
172
+ if (new Date(ms).getUTCDate() !== day)
173
+ return undefined;
174
+ if (zone !== "Z" && zone !== "z") {
175
+ const sign = zone.startsWith("-") ? -1 : 1;
176
+ ms -=
177
+ sign *
178
+ (Number(zone.slice(1, 3)) * 60 + Number(zone.slice(4, 6))) *
179
+ 60_000;
180
+ }
181
+ return { ms, fraction: frac };
182
+ }
183
+ const MONTHS = [
184
+ "Jan",
185
+ "Feb",
186
+ "Mar",
187
+ "Apr",
188
+ "May",
189
+ "Jun",
190
+ "Jul",
191
+ "Aug",
192
+ "Sep",
193
+ "Oct",
194
+ "Nov",
195
+ "Dec",
196
+ ];
197
+ const two = (n) => String(n).padStart(2, "0");
198
+ function dateOf(t) {
199
+ const d = new Date(t.ms);
200
+ return `${MONTHS[d.getUTCMonth()]} ${d.getUTCDate()}, ${d.getUTCFullYear()}`;
201
+ }
202
+ function minuteOf(t) {
203
+ const d = new Date(t.ms);
204
+ return `${dateOf(t)}, ${two(d.getUTCHours())}:${two(d.getUTCMinutes())} UTC`;
205
+ }
206
+ function shortMinuteOf(t) {
207
+ const d = new Date(t.ms);
208
+ return `${MONTHS[d.getUTCMonth()]} ${d.getUTCDate()}, ${two(d.getUTCHours())}:${two(d.getUTCMinutes())} UTC`;
209
+ }
210
+ function secondOf(t, withFraction) {
211
+ const d = new Date(t.ms);
212
+ const frac = withFraction && t.fraction ? `.${t.fraction}` : "";
213
+ return `${dateOf(t)}, ${two(d.getUTCHours())}:${two(d.getUTCMinutes())}:${two(d.getUTCSeconds())}${frac} UTC`;
214
+ }
215
+ const PLACEHOLDER = /\{([a-z_]+)\}/gu;
216
+ function placeholders(text) {
217
+ return [...text.matchAll(PLACEHOLDER)].map((m) => m[1] ?? "").sort();
218
+ }
219
+ function readOverlay(r, v) {
220
+ const o = r.object(v, "overlay", ["id", "entries"], ["id", "entries"]);
221
+ if (!o)
222
+ return {};
223
+ r.string(o["id"], "overlay.id", 200);
224
+ const e = r.object(o["entries"], "overlay.entries", Object.keys(BASE), []);
225
+ const out = {};
226
+ if (!e)
227
+ return out;
228
+ for (const [k, text] of Object.entries(e)) {
229
+ const base = Object.hasOwn(BASE, k) ? BASE[k] : undefined;
230
+ const s = r.string(text, `overlay.entries.${k}`);
231
+ if (base === undefined || s === undefined)
232
+ continue;
233
+ if (placeholders(base).join(",") !== placeholders(s).join(","))
234
+ r.refuse(`overlay.entries.${k}`, `must use the placeholders ${JSON.stringify(placeholders(base))}`);
235
+ else
236
+ out[k] = s;
237
+ }
238
+ return out;
239
+ }
240
+ function readSlot(r, v, path, needBy) {
241
+ const o = r.object(v, path, ["state", "by", "at", "through"], ["state"]);
242
+ const state = o
243
+ ? (r.oneOf(o["state"], `${path}.state`, [
244
+ "passed",
245
+ "failed",
246
+ "none",
247
+ "not_checked",
248
+ ]) ?? "not_checked")
249
+ : "not_checked";
250
+ const by = o && "by" in o ? r.string(o["by"], `${path}.by`, 200) : undefined;
251
+ const at = o && "at" in o ? r.time(o["at"], `${path}.at`) : undefined;
252
+ let through;
253
+ if (o && "through" in o) {
254
+ const t = r.object(o["through"], `${path}.through`, ["k", "n"], ["k", "n"]);
255
+ const k = t ? r.count(t["k"], `${path}.through.k`) : undefined;
256
+ const n = t ? r.count(t["n"], `${path}.through.n`) : undefined;
257
+ if (k !== undefined && n !== undefined) {
258
+ if (k > n || n === 0)
259
+ r.refuse(`${path}.through`, "k must be at most n, and n more than 0");
260
+ else
261
+ through = { k, n };
262
+ }
263
+ }
264
+ if (state === "passed") {
265
+ if (!o || !("at" in o))
266
+ r.refuse(path, "a passed slot needs at");
267
+ if (needBy && !(o && "by" in o))
268
+ r.refuse(path, "a passed second-signature slot needs by");
269
+ }
270
+ return { state, by, at, through };
271
+ }
272
+ const EPOCH = { ms: 0, fraction: "" };
273
+ function readRow(r, v, path, kind) {
274
+ if (kind === "checkpoint") {
275
+ const o = r.object(v, path, [
276
+ "kind",
277
+ "cut_at",
278
+ "log_size",
279
+ "anchor",
280
+ "signature",
281
+ "witness",
282
+ "second_signature",
283
+ ], [
284
+ "kind",
285
+ "cut_at",
286
+ "log_size",
287
+ "anchor",
288
+ "signature",
289
+ "witness",
290
+ "second_signature",
291
+ ]);
292
+ if (!o)
293
+ return undefined;
294
+ if (o["kind"] !== "checkpoint")
295
+ r.refuse(`${path}.kind`, "must be the page's kind, checkpoint");
296
+ return {
297
+ kind,
298
+ cut: r.time(o["cut_at"], `${path}.cut_at`) ?? EPOCH,
299
+ logSize: r.count(o["log_size"], `${path}.log_size`) ?? 0,
300
+ anchor: r.string(o["anchor"], `${path}.anchor`, 200) ?? "",
301
+ signature: r.oneOf(o["signature"], `${path}.signature`, [
302
+ "pass",
303
+ "fail",
304
+ "not_run",
305
+ ]) ?? "not_run",
306
+ witness: readSlot(r, o["witness"], `${path}.witness`, false),
307
+ second: readSlot(r, o["second_signature"], `${path}.second_signature`, true),
308
+ };
309
+ }
310
+ const o = r.object(v, path, [
311
+ "kind",
312
+ "asked",
313
+ "outcome",
314
+ "money",
315
+ "opened_at",
316
+ "last_at",
317
+ "record",
318
+ "witness",
319
+ "second_signature",
320
+ ], [
321
+ "kind",
322
+ "asked",
323
+ "outcome",
324
+ "opened_at",
325
+ "last_at",
326
+ "record",
327
+ "witness",
328
+ "second_signature",
329
+ ]);
330
+ if (!o)
331
+ return undefined;
332
+ if (o["kind"] !== "deal")
333
+ r.refuse(`${path}.kind`, "must be the page's kind, deal");
334
+ return {
335
+ kind,
336
+ asked: r.string(o["asked"], `${path}.asked`) ?? "",
337
+ outcome: r.string(o["outcome"], `${path}.outcome`, 200) ?? "",
338
+ money: "money" in o ? r.string(o["money"], `${path}.money`, 200) : undefined,
339
+ opened: r.time(o["opened_at"], `${path}.opened_at`) ?? EPOCH,
340
+ last: r.time(o["last_at"], `${path}.last_at`) ?? EPOCH,
341
+ record: r.string(o["record"], `${path}.record`, 200) ?? "",
342
+ witness: readSlot(r, o["witness"], `${path}.witness`, false),
343
+ second: readSlot(r, o["second_signature"], `${path}.second_signature`, true),
344
+ };
345
+ }
346
+ // --- the page --------------------------------------------------------------
347
+ const TOP = [
348
+ "view",
349
+ "kind",
350
+ "surface",
351
+ "reader",
352
+ "holder",
353
+ "audience",
354
+ "built_at",
355
+ "checked",
356
+ "outcome",
357
+ "picked",
358
+ "rows",
359
+ "checks",
360
+ "periods",
361
+ "sharing",
362
+ "signer_directory",
363
+ "period",
364
+ ];
365
+ /**
366
+ * The History view's element tree for `input`, or every reason it is
367
+ * refused. `overlay` is a product caller's words (surface `product` only).
368
+ */
369
+ export function buildHistoryView(input, overlay) {
370
+ const r = new Reader();
371
+ const o = r.object(input, "input", TOP, [
372
+ "view",
373
+ "kind",
374
+ "surface",
375
+ "reader",
376
+ "holder",
377
+ "audience",
378
+ "built_at",
379
+ "checked",
380
+ "rows",
381
+ "checks",
382
+ ]);
383
+ if (!o)
384
+ return { ok: false, reasons: r.reasons };
385
+ if (o["view"] !== HISTORY_VIEW)
386
+ r.refuse("input.view", `is not ${HISTORY_VIEW}`);
387
+ const kind = r.oneOf(o["kind"], "input.kind", ["checkpoint", "deal"]) ??
388
+ "checkpoint";
389
+ const surface = r.oneOf(o["surface"], "input.surface", ["neutral", "product"]) ??
390
+ "neutral";
391
+ const reader = r.oneOf(o["reader"], "input.reader", ["owner", "recipient"]) ??
392
+ "recipient";
393
+ let words = {};
394
+ if (overlay !== undefined) {
395
+ if (surface !== "product")
396
+ r.refuse("overlay", "a neutral page takes no overlay");
397
+ else
398
+ words = readOverlay(r, overlay);
399
+ }
400
+ const ho = r.object(o["holder"], "input.holder", ["node", "name", "stream"], []);
401
+ const node = ho && "node" in ho
402
+ ? r.string(ho["node"], "input.holder.node", 200)
403
+ : undefined;
404
+ const name = ho && "name" in ho
405
+ ? r.string(ho["name"], "input.holder.name", 200)
406
+ : undefined;
407
+ const stream = ho && "stream" in ho
408
+ ? r.string(ho["stream"], "input.holder.stream", 200)
409
+ : undefined;
410
+ if (kind === "checkpoint" && node === undefined && ho)
411
+ r.refuse("input.holder.node", "is missing (a checkpoint page names its node)");
412
+ const au = r.object(o["audience"], "input.audience", ["kind", "for"], ["kind"]);
413
+ const audienceKind = au
414
+ ? (r.oneOf(au["kind"], "input.audience.kind", [
415
+ "private",
416
+ "shared",
417
+ "anyone",
418
+ ]) ?? "anyone")
419
+ : "anyone";
420
+ const audienceFor = audienceKind === "shared" && au
421
+ ? r.string(au["for"], "input.audience.for", 200)
422
+ : undefined;
423
+ if (audienceKind !== "shared" && au && "for" in au)
424
+ r.refuse("input.audience.for", "is only for a shared audience");
425
+ const built = r.time(o["built_at"], "input.built_at") ?? EPOCH;
426
+ const ck = r.object(o["checked"], "input.checked", ["where", "by"], ["where", "by"]);
427
+ const where = ck
428
+ ? (r.oneOf(ck["where"], "input.checked.where", [
429
+ "page",
430
+ "builder",
431
+ ]) ?? "builder")
432
+ : "builder";
433
+ const checkedBy = ck
434
+ ? (r.string(ck["by"], "input.checked.by", 200) ?? "")
435
+ : "";
436
+ let outcome = "answered";
437
+ let refusedReason;
438
+ if ("outcome" in o) {
439
+ if (kind !== "checkpoint")
440
+ r.refuse("input.outcome", "is only for a checkpoint page");
441
+ const oc = r.object(o["outcome"], "input.outcome", ["kind", "reason"], ["kind"]);
442
+ if (oc) {
443
+ outcome =
444
+ r.oneOf(oc["kind"], "input.outcome.kind", [
445
+ "answered",
446
+ "refused",
447
+ "unreadable",
448
+ ]) ?? "answered";
449
+ if (outcome === "refused")
450
+ refusedReason = r.string(oc["reason"], "input.outcome.reason", 200);
451
+ else if ("reason" in oc)
452
+ r.refuse("input.outcome.reason", "is only for a refused answer");
453
+ }
454
+ }
455
+ const picked = "picked" in o ? r.bool(o["picked"], "input.picked") === true : false;
456
+ if (picked && kind !== "deal")
457
+ r.refuse("input.picked", "is only for a deal page");
458
+ if (kind === "deal" && reader === "recipient" && name === undefined)
459
+ r.refuse("input.holder.name", "is missing (a deal page shown to someone else names whose it is)");
460
+ else if (picked && name === undefined)
461
+ r.refuse("input.holder.name", "is missing (a picked selection names who picked it)");
462
+ const rows = [];
463
+ if (Array.isArray(o["rows"])) {
464
+ if (o["rows"].length > 10_000)
465
+ r.refuse("input.rows", "has more than 10000 rows");
466
+ o["rows"].forEach((row, i) => {
467
+ const read = readRow(r, row, `input.rows[${i}]`, kind);
468
+ if (read)
469
+ rows.push(read);
470
+ });
471
+ if (outcome !== "answered" && o["rows"].length > 0)
472
+ r.refuse("input.rows", "must be empty unless the node answered");
473
+ }
474
+ else
475
+ r.refuse("input.rows", "is not a list");
476
+ const checks = [];
477
+ if (Array.isArray(o["checks"])) {
478
+ o["checks"].forEach((c, i) => {
479
+ const path = `input.checks[${i}]`;
480
+ const co = r.object(c, path, ["id", "status", "values"], ["id", "status"]);
481
+ if (!co)
482
+ return;
483
+ const id = r.oneOf(co["id"], `${path}.id`, HISTORY_CHECK_IDS);
484
+ const status = r.oneOf(co["status"], `${path}.status`, [
485
+ "pass",
486
+ "fail",
487
+ "not_run",
488
+ ]);
489
+ if ("values" in co) {
490
+ const vo = r.object(co["values"], `${path}.values`, [], []);
491
+ if (vo && Object.keys(vo).length > 0)
492
+ r.refuse(`${path}.values`, "names a placeholder the check's words do not have");
493
+ }
494
+ if (id && checks.some((x) => x.id === id))
495
+ r.refuse(`${path}.id`, "is listed twice");
496
+ if (id && status)
497
+ checks.push({ id, status });
498
+ });
499
+ }
500
+ else
501
+ r.refuse("input.checks", "is not a list");
502
+ const periods = [];
503
+ if ("periods" in o) {
504
+ if (kind !== "checkpoint")
505
+ r.refuse("input.periods", "is only for a checkpoint page");
506
+ if (Array.isArray(o["periods"]))
507
+ o["periods"].forEach((p, i) => {
508
+ const path = `input.periods[${i}]`;
509
+ const po = r.object(p, path, ["from", "to", "cells"], ["from", "to", "cells"]);
510
+ if (!po)
511
+ return;
512
+ const from = r.date(po["from"], `${path}.from`);
513
+ const to = r.date(po["to"], `${path}.to`);
514
+ const cells = [];
515
+ if (Array.isArray(po["cells"]))
516
+ po["cells"].forEach((c, j) => {
517
+ const co = r.object(c, `${path}.cells[${j}]`, ["what", "value", "withheld"], ["what"]);
518
+ const what = co
519
+ ? r.string(co["what"], `${path}.cells[${j}].what`, 200)
520
+ : undefined;
521
+ const withheld = co !== null && "withheld" in co;
522
+ if (withheld && co["withheld"] !== true)
523
+ r.refuse(`${path}.cells[${j}].withheld`, "is not true");
524
+ if (co && withheld === "value" in co)
525
+ r.refuse(`${path}.cells[${j}]`, "carries either a value or withheld: true");
526
+ const value = co && "value" in co
527
+ ? r.string(co["value"], `${path}.cells[${j}].value`, 40)
528
+ : undefined;
529
+ if (what !== undefined)
530
+ cells.push({ what, value });
531
+ });
532
+ else
533
+ r.refuse(`${path}.cells`, "is not a list");
534
+ if (from && to)
535
+ periods.push({ from, to, cells });
536
+ });
537
+ else
538
+ r.refuse("input.periods", "is not a list");
539
+ }
540
+ let sharing;
541
+ if (kind === "checkpoint" && !("sharing" in o))
542
+ r.refuse("input.sharing", "is missing (a checkpoint page says what its node shares)");
543
+ if ("sharing" in o) {
544
+ if (kind !== "checkpoint")
545
+ r.refuse("input.sharing", "is only for a checkpoint page");
546
+ const keys = [
547
+ "standard_history",
548
+ "history_segments",
549
+ "record_at_completion",
550
+ "adjudications",
551
+ "exchange_corroboration",
552
+ "adjudicate_differing_twins",
553
+ "witnesses",
554
+ ];
555
+ const so = r.object(o["sharing"], "input.sharing", keys, []);
556
+ if (so) {
557
+ let witnesses;
558
+ if ("witnesses" in so) {
559
+ witnesses = [];
560
+ if (Array.isArray(so["witnesses"]))
561
+ for (const [i, w] of so["witnesses"].entries()) {
562
+ const s = r.string(w, `input.sharing.witnesses[${i}]`, 300);
563
+ if (s !== undefined)
564
+ witnesses.push(s);
565
+ }
566
+ else
567
+ r.refuse("input.sharing.witnesses", "is not a list");
568
+ }
569
+ // Every member is optional: one the node does not state stays absent
570
+ // and is drawn as "this node's settings don't say".
571
+ const stated = {};
572
+ let wrong = false;
573
+ const take = (k, parse) => {
574
+ if (!(k in so))
575
+ return;
576
+ const v = parse();
577
+ if (v === undefined)
578
+ wrong = true;
579
+ else
580
+ stated[k] = v;
581
+ };
582
+ const on = (k) => take(k, () => r.bool(so[k], `input.sharing.${k}`));
583
+ const one = (k, values) => take(k, () => r.oneOf(so[k], `input.sharing.${k}`, values));
584
+ on("standard_history");
585
+ one("history_segments", ["off", "counterparties", "peers"]);
586
+ one("record_at_completion", ["counterparty", "off"]);
587
+ one("adjudications", ["deliver_to_subjects", "off"]);
588
+ on("exchange_corroboration");
589
+ on("adjudicate_differing_twins");
590
+ if (!wrong)
591
+ sharing = {
592
+ ...stated,
593
+ ...(witnesses !== undefined ? { witnesses } : {}),
594
+ };
595
+ }
596
+ }
597
+ let directory;
598
+ if ("signer_directory" in o) {
599
+ if (kind !== "deal")
600
+ r.refuse("input.signer_directory", "is only for a deal page");
601
+ directory = r.string(o["signer_directory"], "input.signer_directory", 300);
602
+ if (directory !== undefined && !directory.startsWith("https://"))
603
+ r.refuse("input.signer_directory", "is not an https:// address");
604
+ }
605
+ let period;
606
+ if ("period" in o) {
607
+ const po = r.object(o["period"], "input.period", ["from", "to"], ["from", "to"]);
608
+ const from = po ? r.date(po["from"], "input.period.from") : undefined;
609
+ const to = po ? r.date(po["to"], "input.period.to") : undefined;
610
+ if (from && to)
611
+ period = { from, to };
612
+ }
613
+ if (r.reasons.length > 0)
614
+ return { ok: false, reasons: r.reasons };
615
+ const say = (key, values = {}) => {
616
+ const text = words[key] ?? BASE[key];
617
+ if (text === undefined)
618
+ throw new Error(`history-view: no words for ${key}`);
619
+ return text.replace(PLACEHOLDER, (_, p) => {
620
+ const v = values[p];
621
+ if (v === undefined)
622
+ throw new Error(`history-view: ${key} needs {${p}}`);
623
+ return v;
624
+ });
625
+ };
626
+ const plural = (key, n, values = {}) => say(`${key}.${n === 1 ? "one" : "other"}`, { n: String(n), ...values });
627
+ const short = (id) => (id.length > 12 ? id.slice(0, 12) : id);
628
+ // One verdict for the page (design note §4).
629
+ const failedCheck = checks.some((c) => c.status === "fail" && !SLOT_CHECKS.has(c.id));
630
+ const failedRow = rows.some((x) => x.kind === "checkpoint" && x.signature === "fail");
631
+ const failed = failedCheck || failedRow;
632
+ const allPass = rows.length > 0 &&
633
+ rows.every((x) => x.kind !== "checkpoint" || x.signature === "pass") &&
634
+ checks
635
+ .filter((c) => !SLOT_CHECKS.has(c.id) && c.status !== "not_run")
636
+ .every((c) => c.status === "pass") &&
637
+ (kind === "deal" ||
638
+ checks.some((c) => c.id === "checkpoint_signatures" && c.status === "pass"));
639
+ // "Every signature" only when the answer's own signature and the node's key
640
+ // were checked too; otherwise the verdict names only what passed.
641
+ const passed = (id) => checks.some((c) => c.id === id && c.status === "pass");
642
+ const everySignature = allPass && passed("envelope_signature") && passed("key_is_node");
643
+ const verdictKey = everySignature ? "verdict.pass.all" : "verdict.pass";
644
+ const chipKey = everySignature
645
+ ? "chip.signatures.pass.all"
646
+ : "chip.signatures.pass";
647
+ const statusOf = (id) => checks.find((c) => c.id === id)?.status;
648
+ const dealRecorded = statusOf("deal_report") === "pass";
649
+ const witnessFailed = statusOf("witness") === "fail";
650
+ const secondFailed = statusOf("second_signature") === "fail";
651
+ // The seal's first lines say how the records are locked; only checks that
652
+ // passed may say it.
653
+ const lockChecked = kind === "checkpoint"
654
+ ? statusOf("checkpoint_signatures") === "pass" &&
655
+ statusOf("checkpoint_chain") === "pass" &&
656
+ statusOf("consistency") === "pass"
657
+ : dealRecorded;
658
+ // Header.
659
+ let title;
660
+ if (kind === "checkpoint")
661
+ title =
662
+ stream !== undefined
663
+ ? say("header.title.stream", { node: short(node ?? ""), stream })
664
+ : say("header.title.node", { node: short(node ?? "") });
665
+ else if (reader === "owner")
666
+ title = say("header.title.owner");
667
+ else
668
+ title =
669
+ audienceKind === "shared"
670
+ ? say("header.title.shared", { name: name ?? "" })
671
+ : say("header.title.person", { name: name ?? "" });
672
+ const badge = audienceKind === "private"
673
+ ? say("badge.private")
674
+ : audienceKind === "shared"
675
+ ? say("badge.shared", { who: audienceFor ?? "" })
676
+ : say("badge.anyone");
677
+ const header = el("header", { class: "cvh-header", "data-history": "header" }, el("h1", { class: "cvh-title" }, title), node !== undefined
678
+ ? el("details", { class: "cvh-proof" }, el("summary", null, say("proof.node", { id: short(node) })), el("code", null, node))
679
+ : null, period
680
+ ? el("p", { class: "cvh-scope" }, say("scope.period", {
681
+ from: dateOf(period.from),
682
+ to: dateOf(period.to),
683
+ }))
684
+ : null, el("p", { class: "cvh-badge", "data-audience": audienceKind }, badge), el("p", { class: "cvh-built" }, say(reader === "owner" ? "built.owner" : "built.recipient", {
685
+ at: minuteOf(built),
686
+ })));
687
+ // Hero.
688
+ const heroLines = [];
689
+ let drawRows = false;
690
+ if (outcome === "refused") {
691
+ heroLines.push(say("hero.refused"));
692
+ if (refusedReason !== undefined)
693
+ heroLines.push(say("hero.refused.reason", { reason: refusedReason }));
694
+ }
695
+ else if (outcome === "unreadable")
696
+ heroLines.push(say("hero.unreadable"));
697
+ else if (failed)
698
+ heroLines.push(say("hero.failed"));
699
+ else if (rows.length === 0)
700
+ heroLines.push(say(kind === "checkpoint" ? "hero.none.checkpoints" : "hero.none.deals"));
701
+ else {
702
+ drawRows = true;
703
+ if (kind === "checkpoint") {
704
+ const cps = rows;
705
+ const last = cps.reduce((a, b) => (b.cut.ms > a.cut.ms ? b : a));
706
+ const entries = Math.max(...cps.map((c) => c.logSize));
707
+ heroLines.push(plural("hero.checkpoints", cps.length, {
708
+ entries: plural("hero.entries", entries),
709
+ at: shortMinuteOf(last.cut),
710
+ verdict: say(allPass ? verdictKey : "verdict.unchecked"),
711
+ }));
712
+ }
713
+ else
714
+ heroLines.push(picked
715
+ ? plural("hero.deals.picked", rows.length, { name: name ?? "" })
716
+ : plural("hero.deals", rows.length));
717
+ }
718
+ const hero = el("section", { class: "cvh-hero", "data-history": "hero" }, ...heroLines.map((line, i) => el("p", { class: i === 0 ? "cvh-hero-line" : "cvh-hero-note" }, line)));
719
+ // Chips.
720
+ let chips = null;
721
+ if (drawRows) {
722
+ const stamped = rows.filter((x) => x.witness.state === "passed").length;
723
+ const stampChip = witnessFailed
724
+ ? say("chip.timestamped.failed")
725
+ : stamped === 0 && rows.some((x) => x.witness.state === "not_checked")
726
+ ? say("chip.timestamped.unchecked")
727
+ : stamped === 0
728
+ ? say("chip.timestamped.none")
729
+ : stamped === rows.length
730
+ ? say("chip.timestamped.all", { n: String(rows.length) })
731
+ : say("chip.timestamped.some", {
732
+ k: String(stamped),
733
+ n: String(rows.length),
734
+ });
735
+ const items = [];
736
+ if (kind === "checkpoint") {
737
+ items.push(say(allPass ? chipKey : "chip.signatures.unchecked"), stampChip);
738
+ const first = rows.reduce((a, b) => b.cut.ms < a.cut.ms ? b : a);
739
+ items.push(say("chip.started", { date: dateOf(first.cut) }));
740
+ }
741
+ else {
742
+ if (dealRecorded)
743
+ items.push(say("chip.recorded"));
744
+ items.push(stampChip);
745
+ }
746
+ chips = el("ul", { class: "cvh-chips", "data-history": "chips" }, ...items.map((t) => el("li", { class: "cvh-chip" }, t)));
747
+ }
748
+ // Rows.
749
+ const slotLine = (s, second) => {
750
+ if (s.state === "passed") {
751
+ const at = s.at ? minuteOf(s.at) : "";
752
+ let line = second
753
+ ? say("slot.second.by", { by: s.by ?? "", at })
754
+ : s.by !== undefined
755
+ ? say("slot.timestamped.by", { at, by: s.by })
756
+ : say("slot.timestamped.at", { at });
757
+ if (s.through && s.through.k < s.through.n)
758
+ line += ` · ${say("slot.part", { k: String(s.through.k), n: String(s.through.n) })}`;
759
+ return line;
760
+ }
761
+ if (s.state === "failed")
762
+ return say("slot.failed");
763
+ if (s.state === "none")
764
+ return say(second ? "slot.second.none" : "slot.timestamped.none");
765
+ return say("slot.unchecked");
766
+ };
767
+ const stamp = (nameKey, filled, state, line) => el("li", {
768
+ class: "cvh-stamp",
769
+ "data-filled": filled ? "yes" : "no",
770
+ "data-state": state,
771
+ }, el("span", { class: "cvh-stamp-name" }, say(nameKey)), line !== null ? el("span", { class: "cvh-stamp-line" }, line) : null);
772
+ const slotStamps = (row) => [
773
+ stamp("stamp.timestamped", row.witness.state === "passed", row.witness.state, slotLine(row.witness, false)),
774
+ stamp("stamp.second", row.second.state === "passed", row.second.state, slotLine(row.second, true)),
775
+ ];
776
+ const proof = (key, id) => el("details", { class: "cvh-proof" }, el("summary", null, say(key, { id: short(id) })), el("code", null, id));
777
+ let rowList = null;
778
+ if (drawRows) {
779
+ const seconds = new Map();
780
+ if (kind === "checkpoint")
781
+ for (const x of rows)
782
+ seconds.set(Math.floor(x.cut.ms / 1000), (seconds.get(Math.floor(x.cut.ms / 1000)) ?? 0) + 1);
783
+ const items = rows.map((x) => {
784
+ if (x.kind === "checkpoint") {
785
+ const tie = (seconds.get(Math.floor(x.cut.ms / 1000)) ?? 0) > 1;
786
+ return el("li", { class: "cvh-row", "data-history": "row" }, el("p", { class: "cvh-row-title" }, say("row.cut", { at: secondOf(x.cut, tie) })), el("p", { class: "cvh-row-detail" }, plural("row.entries", x.logSize)), proof("proof.checkpoint", x.anchor), el("ul", { class: "cvh-stamps" }, stamp("stamp.recorded", x.signature === "pass", x.signature, x.signature === "pass" ? null : say("stamp.signature.unchecked")), ...slotStamps(x)));
787
+ }
788
+ const detail = [
789
+ x.outcome,
790
+ ...(x.money !== undefined ? [x.money] : []),
791
+ say("row.opened", { at: minuteOf(x.opened) }),
792
+ say("row.last", { at: minuteOf(x.last) }),
793
+ ].join(" · ");
794
+ return el("li", { class: "cvh-row", "data-history": "row" }, el("p", { class: "cvh-row-title" }, x.asked), el("p", { class: "cvh-row-detail" }, detail), proof("proof.record", x.record), el("ul", { class: "cvh-stamps" }, dealRecorded
795
+ ? stamp("stamp.recorded", true, "passed", null)
796
+ : stamp("stamp.recorded", false, "not_checked", say("slot.unchecked")), ...slotStamps(x)));
797
+ });
798
+ rowList = el("section", { class: "cvh-rows-block" }, el("h2", null, say(kind === "checkpoint"
799
+ ? "rows.heading.checkpoints"
800
+ : "rows.heading.deals")), el("ol", { class: "cvh-rows", "data-history": "rows" }, ...items));
801
+ }
802
+ const periodBlock = drawRows && periods.length > 0
803
+ ? el("section", { class: "cvh-periods", "data-history": "periods" }, el("h2", null, say("periods.heading")), el("ul", null, ...periods.map((p) => el("li", null, el("p", null, say("periods.row", {
804
+ from: dateOf(p.from),
805
+ to: dateOf(p.to),
806
+ })), el("ul", null, ...p.cells.map((c) => el("li", null, c.value === undefined
807
+ ? say("periods.cell.withheld", { what: c.what })
808
+ : say("periods.cell", { what: c.what, value: c.value }))))))))
809
+ : null;
810
+ const callout = outcome === "answered" && !failed
811
+ ? el("aside", { class: "cvh-callout", "data-history": "does-not-show" }, el("h2", null, say("callout.heading")), el("p", null, kind === "checkpoint"
812
+ ? say("callout.checkpoints")
813
+ : picked
814
+ ? say("callout.deals.picked", { name: name ?? "" })
815
+ : say("callout.deals")))
816
+ : null;
817
+ let shares = null;
818
+ if (sharing) {
819
+ const lines = [say("shares.summary")];
820
+ if (sharing.standard_history === undefined)
821
+ lines.push(say("shares.standard.unstated"));
822
+ else
823
+ lines.push(say(sharing.standard_history
824
+ ? "shares.standard.on"
825
+ : "shares.standard.off"));
826
+ if (sharing.history_segments === "counterparties")
827
+ lines.push(say("shares.segments.counterparties"));
828
+ else if (sharing.history_segments === "peers")
829
+ lines.push(say("shares.segments.peers"));
830
+ else if (sharing.history_segments === "off")
831
+ lines.push(sharing.record_at_completion === "counterparty"
832
+ ? `${say("shares.segments.off")} ${say("shares.segments.off.sealed")}`
833
+ : say("shares.segments.off"));
834
+ else
835
+ lines.push(say("shares.segments.unstated"));
836
+ if (sharing.exchange_corroboration === undefined)
837
+ lines.push(say("shares.corroboration.unstated"));
838
+ else if (sharing.exchange_corroboration)
839
+ lines.push(say("shares.corroboration.on"));
840
+ if (sharing.record_at_completion === undefined)
841
+ lines.push(say("shares.completion.unstated"));
842
+ else
843
+ lines.push(say(sharing.record_at_completion === "counterparty"
844
+ ? "shares.completion.on"
845
+ : "shares.completion.off"));
846
+ if (sharing.adjudications === undefined)
847
+ lines.push(say("shares.adjudications.unstated"));
848
+ else
849
+ lines.push(say(sharing.adjudications === "deliver_to_subjects"
850
+ ? "shares.adjudications.on"
851
+ : "shares.adjudications.off"));
852
+ if (sharing.adjudicate_differing_twins === undefined)
853
+ lines.push(say("shares.twins.unstated"));
854
+ else if (sharing.adjudicate_differing_twins)
855
+ lines.push(say("shares.twins.on"));
856
+ if (sharing.witnesses === undefined)
857
+ lines.push(say("shares.witnesses.unstated"));
858
+ else
859
+ lines.push(sharing.witnesses.length > 0
860
+ ? say("shares.witnesses", { witnesses: sharing.witnesses.join(", ") })
861
+ : say("shares.witnesses.none"));
862
+ // The signed-request rule is the mesh plugin's, carried by its policy; a
863
+ // policy that states no segments setting does not vouch for it.
864
+ lines.push(say(sharing.history_segments === undefined
865
+ ? "shares.never.unstated"
866
+ : "shares.never"));
867
+ shares = el("section", { class: "cvh-shares", "data-history": "shares" }, el("h2", null, say("shares.heading")), el("ul", null, ...lines.map((l) => el("li", null, l))), el("p", { class: "cvh-note" }, say("shares.as_of", { at: minuteOf(built) })));
868
+ }
869
+ let seal = null;
870
+ {
871
+ const states = drawRows ? rows.map((x) => x.second.state) : [];
872
+ const sealState = secondFailed || states.some((s) => s === "failed")
873
+ ? "failed"
874
+ : states.length === 0 || states.some((s) => s === "not_checked")
875
+ ? "not_checked"
876
+ : states.every((s) => s === "none")
877
+ ? "none"
878
+ : "mixed";
879
+ // A failed row must not read as if the whole deal failed: when only some
880
+ // of the countersigned rows failed, the slot gives its scope and points to
881
+ // the rows. Rows nobody countersigned are not part of the count.
882
+ const failedRows = states.filter((s) => s === "failed").length;
883
+ const signedRows = states.filter((s) => s === "failed" || s === "passed").length;
884
+ const sealLine = sealState === "failed"
885
+ ? failedRows > 0 && failedRows < signedRows
886
+ ? say("seal.second.some_failed", {
887
+ k: String(failedRows),
888
+ n: String(signedRows),
889
+ })
890
+ : say("slot.failed")
891
+ : sealState === "none"
892
+ ? say("slot.second.none")
893
+ : sealState === "not_checked"
894
+ ? say("slot.unchecked")
895
+ : say("seal.second.rows");
896
+ seal = el("section", { class: "cvh-seal", "data-history": "seal" }, drawRows && lockChecked
897
+ ? el("p", { class: "cvh-seal-title" }, say("seal.title"))
898
+ : null, drawRows && lockChecked
899
+ ? el("p", null, say(kind === "checkpoint" ? "seal.checkpoints" : "seal.deals"))
900
+ : drawRows
901
+ ? el("p", null, say("seal.unchecked"))
902
+ : null, el("p", {
903
+ class: "cvh-seal-slot",
904
+ "data-filled": "no",
905
+ "data-state": sealState,
906
+ }, el("span", { class: "cvh-stamp-name" }, say("seal.second.label")), el("span", { class: "cvh-stamp-line" }, sealLine)), directory !== undefined
907
+ ? el("p", { class: "cvh-note", "data-history": "directory" }, say("seal.directory", { directory }))
908
+ : null);
909
+ }
910
+ const checkedAttrs = {
911
+ class: "cvh-checked",
912
+ "data-history": "checked",
913
+ };
914
+ if (failed || outcome !== "answered")
915
+ checkedAttrs["open"] = "";
916
+ const panel = el("details", checkedAttrs, el("summary", null, say("checked.heading")), el("ul", null, ...checks.map((c) => el("li", { class: "cvh-check", "data-status": c.status }, say("check.line", {
917
+ status: say(`status.${c.status}`),
918
+ name: say(`check.${c.id}`),
919
+ })))), el("p", { class: "cvh-note" }, where === "page"
920
+ ? say("checked.where.page", { by: checkedBy })
921
+ : say("checked.where.builder", { at: minuteOf(built), by: checkedBy })));
922
+ const tree = el("section", {
923
+ class: "cv-history",
924
+ "data-history": "view",
925
+ "data-kind": kind,
926
+ "data-surface": surface,
927
+ "data-verdict": failed ? "failed" : allPass ? "pass" : "unchecked",
928
+ }, header, el("div", { class: "cvh-main" }, hero, chips, rowList, periodBlock), el("div", { class: "cvh-side" }, callout, shares, seal, panel));
929
+ return { ok: true, tree };
930
+ }
931
+ /** The History view as HTML text; throws HistoryViewRefused on a refused input. */
932
+ export function historyViewHtml(input, overlay) {
933
+ const built = buildHistoryView(input, overlay);
934
+ if (!built.ok)
935
+ throw new HistoryViewRefused(built.reasons);
936
+ return serializeHistoryElement(built.tree);
937
+ }
938
+ /**
939
+ * Draws the History view into `container`, replacing what it holds. A
940
+ * refused input draws one visible refusal line and returns false.
941
+ */
942
+ export function renderHistoryView(input, container, overlay) {
943
+ const doc = container.ownerDocument;
944
+ const built = buildHistoryView(input, overlay);
945
+ const node = built.ok
946
+ ? historyElementToDom(built.tree, doc)
947
+ : historyElementToDom(el("p", { class: "cvh-refused", "data-history": "refused" }, (BASE["refused"] ?? "").replace("{reasons}", () => built.reasons.join("; "))), doc);
948
+ container.replaceChildren(node);
949
+ return built.ok;
950
+ }
951
+ /** The view's stylesheet: one column under 900px, two above, and print. */
952
+ export const historyViewStyles = `.cv-history{--cvh-ink:#1f2733;--cvh-slate:#6b7482;--cvh-line:#e3ded3;--cvh-cream:#f6f2ea;--cvh-navy:#232f42;--cvh-ok:#2e7d5b;--cvh-bad:#b5462f;font:16px/1.45 system-ui,sans-serif;color:var(--cvh-ink);max-width:1120px;margin:0 auto;padding:16px;display:grid;gap:16px}
953
+ .cv-history h1{font-size:22px;margin:0}.cv-history h2{font-size:15px;margin:0 0 8px;color:var(--cvh-navy)}
954
+ .cvh-header p{margin:4px 0}.cvh-badge{display:inline-block;border:1px solid var(--cvh-line);border-radius:6px;padding:2px 8px;font-size:12px;font-weight:700;letter-spacing:.02em}
955
+ .cvh-badge[data-audience=private]{background:#fbefd9;border-color:#e8a33d}.cvh-built,.cvh-note{color:var(--cvh-slate);font-size:13px}
956
+ .cvh-hero-line{font-size:20px;font-weight:700;margin:0}.cvh-hero-note{margin:6px 0 0;color:var(--cvh-slate)}
957
+ .cvh-chips{list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:8px}.cvh-chip{background:var(--cvh-cream);border-radius:999px;padding:3px 10px;font-size:13px}
958
+ .cvh-rows{list-style:none;padding:0;margin:0}.cvh-row{border:1px solid var(--cvh-line);border-radius:10px;padding:10px 12px;margin:0 0 10px}
959
+ .cvh-row p{margin:0 0 4px}.cvh-row-title{font-weight:700}.cvh-row-detail{color:var(--cvh-slate);font-size:14px}
960
+ .cvh-proof summary{cursor:pointer;font-size:13px;color:var(--cvh-slate)}.cvh-proof code{font-size:12px;word-break:break-all}
961
+ .cvh-stamps{list-style:none;padding:0;margin:8px 0 0;display:flex;flex-wrap:wrap;gap:8px}
962
+ .cvh-stamp,.cvh-seal-slot{border:2px solid var(--cvh-navy);border-radius:999px;padding:2px 10px;font-size:12px;color:var(--cvh-navy)}
963
+ .cvh-stamp[data-filled=no],.cvh-seal-slot[data-filled=no]{border-style:dotted;border-color:#9aa1ab;color:var(--cvh-slate)}
964
+ .cvh-stamp[data-state=failed]{border-color:var(--cvh-bad);color:var(--cvh-bad)}
965
+ .cvh-stamp-name{font-weight:800}.cvh-stamp-line{margin-left:6px}
966
+ .cvh-callout,.cvh-shares,.cvh-seal,.cvh-periods{border:1px solid var(--cvh-line);border-radius:10px;padding:12px}
967
+ .cvh-callout{background:var(--cvh-cream)}.cvh-callout p,.cvh-seal p{margin:0 0 6px}.cvh-shares ul,.cvh-periods ul{margin:0;padding-left:18px}
968
+ .cvh-seal-title{font-weight:700}.cvh-checked summary{cursor:pointer;font-weight:700;color:var(--cvh-navy)}
969
+ .cvh-check[data-status=fail]{color:var(--cvh-bad)}.cvh-check[data-status=pass]{color:var(--cvh-ok)}
970
+ .cvh-main,.cvh-side{display:grid;gap:16px;align-content:start}.cvh-refused{border:1px solid var(--cvh-bad);color:var(--cvh-bad);padding:8px 12px;border-radius:8px}
971
+ @media (min-width:900px){.cv-history{grid-template-columns:minmax(0,3fr) minmax(0,2fr)}.cvh-header{grid-column:1/-1}}
972
+ @media print{.cv-history{max-width:none;grid-template-columns:1fr}.cvh-proof code{display:block}}
973
+ `;
974
+ /** A whole static page (no script) holding the History view; throws HistoryViewRefused. */
975
+ export function historyViewDocument(input, overlay, title = "History") {
976
+ const body = historyViewHtml(input, overlay);
977
+ return `<!doctype html>\n<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeText(title)}</title><style>${historyViewStyles}</style></head><body>${body}</body></html>\n`;
978
+ }
979
+ //# sourceMappingURL=history-view.js.map