@sjunepark/fs 0.1.0 → 0.2.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/README.md CHANGED
@@ -20,13 +20,13 @@ reference does not attest to current npm publication availability.
20
20
  Run without a global installation:
21
21
 
22
22
  ```sh
23
- npx -y @sjunepark/fs@0.1.0 --help
23
+ npx -y @sjunepark/fs@0.2.0 --help
24
24
  ```
25
25
 
26
26
  Or install the `fs` executable globally:
27
27
 
28
28
  ```sh
29
- npm install --global @sjunepark/fs@0.1.0
29
+ npm install --global @sjunepark/fs@0.2.0
30
30
  fs --help
31
31
  ```
32
32
 
@@ -34,17 +34,17 @@ Common workflows:
34
34
 
35
35
  ```sh
36
36
  # Read the bundled authoring guide.
37
- npx -y @sjunepark/fs@0.1.0 guide authoring
37
+ npx -y @sjunepark/fs@0.2.0 guide authoring
38
38
 
39
39
  # Write the document schema or a bundled example to stdout.
40
- npx -y @sjunepark/fs@0.1.0 schema document
41
- npx -y @sjunepark/fs@0.1.0 example minimal
40
+ npx -y @sjunepark/fs@0.2.0 schema document
41
+ npx -y @sjunepark/fs@0.2.0 example minimal
42
42
 
43
43
  # Validate a document and calculate its results.
44
- npx -y @sjunepark/fs@0.1.0 validate statement.fs.json
44
+ npx -y @sjunepark/fs@0.2.0 validate statement.fs.json
45
45
 
46
46
  # Render a deterministic standalone HTML table.
47
- npx -y @sjunepark/fs@0.1.0 render --output statement.html statement.fs.json
47
+ npx -y @sjunepark/fs@0.2.0 render --output statement.html statement.fs.json
48
48
  ```
49
49
 
50
50
  The package bundles its schemas, guide, and examples. Validation does not
@@ -56,9 +56,19 @@ In a source checkout, `docs/development.md` owns repository setup, local CLI
56
56
  execution, validation, generated content, and package checks. That
57
57
  repository-only guide is not part of the npm package.
58
58
 
59
- ## Format contract
59
+ The source repository implements the breaking `0.2` artifact contract. The
60
+ [completed refactor plan](https://github.com/cpaikr/fs/blob/main/docs/plans/remove-user-defined-groupings.md)
61
+ records its delivery and release handoff.
60
62
 
61
- V0 documents use `formatVersion: "0.1"`. The normative
63
+ ## Format contracts
64
+
65
+ `@sjunepark/fs@0.2.0` uses `formatVersion: "0.2"`. The
66
+ [FS 0.2 semantic specification](https://cpaikr.github.io/fs/spec/0.2/) and
67
+ [versioned document schema](https://cpaikr.github.io/fs/schema/0.2/fs-document.schema.json)
68
+ define that contract.
69
+
70
+ The earlier `@sjunepark/fs@0.1.0` release uses `formatVersion: "0.1"`. Its
71
+ immutable
62
72
  [FS V0 semantic specification](https://cpaikr.github.io/fs/spec/0.1/) and
63
73
  [versioned document schema](https://cpaikr.github.io/fs/schema/0.1/fs-document.schema.json)
64
74
  define the public contract.
@@ -15,10 +15,8 @@ For a new document, confirm all of these inputs before encoding:
15
15
  - periods with `id`, `kind`, and either `date` for an instant or inclusive
16
16
  `start` and `end` for a duration;
17
17
  - statements with `id`, `label`, ordered period identifiers, and ordered
18
- items; each item has `id`, `label`, `unit`, `values`, and `groupings`, plus
19
- any optional `description` or `rollupTo`;
20
- - grouping-column identifiers and, for every item, a nonempty string or JSON
21
- `null` assignment for each column;
18
+ items; each item has `id`, `label`, `unit`, and `values`, plus any optional
19
+ `description` or `rollupTo`;
22
20
  - one deliberate value state for every item-period: an exact decimal, zero,
23
21
  missing, or unavailable; and
24
22
  - confirmed rollups whose child and parent are in the same statement, use the
@@ -26,7 +24,7 @@ For a new document, confirm all of these inputs before encoding:
26
24
  acyclic graph.
27
25
 
28
26
  For a repair, treat the candidate's financial meanings, values, units,
29
- periods, groupings, and rollups as authoritative. Repair syntax, shape, and
27
+ periods, item meanings, and rollups as authoritative. Repair syntax, shape, and
30
28
  reference encoding. Ask for author input only when a diagnostic exposes a
31
29
  missing or contradictory financial decision.
32
30
 
@@ -44,7 +42,7 @@ fs example minimal
44
42
  ```
45
43
 
46
44
  Continue only when all three commands succeed and their artifacts are
47
- available. The [FS V0 semantic specification](https://cpaikr.github.io/fs/spec/0.1/)
45
+ available. The [FS 0.2 semantic specification](https://cpaikr.github.io/fs/spec/0.2/)
48
46
  defines meaning beyond JSON shape. Consult it when an invariant or repair is
49
47
  uncertain.
50
48
 
@@ -62,27 +60,24 @@ Choose one branch:
62
60
 
63
61
  For either branch, apply these encoding constraints:
64
62
 
65
- - Set `"formatVersion": "0.1"`. The only allowed optional discovery pointer
66
- is `"$schema": "https://cpaikr.github.io/fs/schema/0.1/fs-document.schema.json"`.
67
- - Define entity, scope, units, periods, and any grouping columns before
68
- statements reference them. Keep objects closed and every identifier and
69
- reference exact.
63
+ - Set `"formatVersion": "0.2"`. The only allowed optional discovery pointer
64
+ is `"$schema": "https://cpaikr.github.io/fs/schema/0.2/fs-document.schema.json"`.
65
+ - Define entity, scope, units, and periods before statements reference them.
66
+ Keep objects closed and every identifier and reference exact. Keep
67
+ project-specific classification and mapping data outside FS.
70
68
  - Give each statement an ordered, nonempty period list and ordered, nonempty
71
- item list. Each item's `values` keys exactly match its statement periods;
72
- its `groupings` keys exactly match the document's `groupingColumns`.
69
+ item list. Each item's `values` keys exactly match its statement periods.
73
70
  - Encode values as canonical decimal strings: no exponent or leading `+`, no
74
71
  unnecessary leading integer zeros or trailing fractional zeros, and no
75
72
  negative zero. Use `"0"` for zero, JSON `null` for missing, and
76
73
  `{ "unavailable": true }` for explicit unavailability.
77
- - Use a nonempty string for a grouping assignment and JSON `null` for no
78
- assignment. With no grouping columns, every item's `groupings` is `{}`.
79
74
  - Set `rollupTo` only on a confirmed child. Every relationship is
80
75
  same-statement, same-unit, coefficient-one, stored-sign, and acyclic. The
81
76
  parent remains explicit; validation compares direct children and never
82
77
  derives a subtotal.
83
78
 
84
79
  Create preparation is complete when every required member, selected-period
85
- cell, grouping assignment, identifier, reference, and confirmed rollup is
80
+ cell, identifier, reference, and confirmed rollup is
86
81
  present without inventing a financial choice. Repair preparation is complete
87
82
  when the original candidate is staged unchanged and its author-resolved
88
83
  financial choices are fixed as invariants.
@@ -111,7 +106,7 @@ reported values and do not force calculation consistency.
111
106
  Validation is complete only with a conforming status and the unabridged
112
107
  structured output retained.
113
108
 
114
- ### 4. Create and Deliver
109
+ ### 4. Create, Optionally Render, and Deliver
115
110
 
116
111
  ```sh
117
112
  fs create --output statement.fs.json candidate.json
@@ -120,6 +115,26 @@ fs create --output statement.fs.json candidate.json
120
115
  Use a new output path whose parent directory already exists. `create` copies
121
116
  the candidate's exact bytes atomically and never overwrites a path.
122
117
 
123
- Finish only when `output.status` is `"created"`. Deliver the created FS JSON
124
- and the complete structured validation output, including `validation` and
125
- `snapshotDiff`.
118
+ Finish document creation only when `output.status` is `"created"`.
119
+
120
+ When the user requests an HTML view, render the created document:
121
+
122
+ ```sh
123
+ fs render --output statement.html statement.fs.json
124
+ ```
125
+
126
+ Use another new output path whose parent directory already exists. `render`
127
+ validates the input again and atomically creates a deterministic standalone
128
+ HTML document with embedded CSS, renderer-owned fixed inline behavior, and no
129
+ external resources. Treat the HTML as a derived presentation, not a
130
+ replacement for the FS JSON: it provides statement review, presentation-only
131
+ rollup hierarchy and fresh rollup-check summaries, and per-statement
132
+ copy-for-Excel controls. Rendering calculates rollup checks but does not derive,
133
+ rescale, round, aggregate, or change the displayed statement values. Embedded
134
+ validation snapshots are not displayed. Finish rendering only when its
135
+ `output.status` is `"created"`.
136
+
137
+ Deliver the created FS JSON and the complete structured validation output,
138
+ including `validation` and `snapshotDiff`, which remain in the JSON command
139
+ output. When requested and successfully created, deliver the HTML alongside
140
+ them.
package/dist/pathless.js CHANGED
@@ -15,7 +15,7 @@ const discovery = {
15
15
  package: "@sjunepark/fs",
16
16
  input: null,
17
17
  artifact: {
18
- versions: ["0.1"],
18
+ versions: ["0.2"],
19
19
  serializations: ["json"]
20
20
  },
21
21
  commands: [
@@ -0,0 +1,84 @@
1
+ const templateParts = Symbol("HtmlTemplate.parts");
2
+ const literal = (text) => ({ text, escaped: false });
3
+ const authorText = (text) => ({ text, escaped: true });
4
+ export const html = (strings, ...values) => {
5
+ const parts = [];
6
+ for (const [index, string] of strings.entries()) {
7
+ if (string.length > 0)
8
+ parts.push(literal(string));
9
+ const value = values[index];
10
+ if (value === undefined)
11
+ continue;
12
+ if (typeof value === "string") {
13
+ parts.push(authorText(value));
14
+ }
15
+ else if (typeof value === "number") {
16
+ parts.push(literal(String(value)));
17
+ }
18
+ else {
19
+ parts.push(...value[templateParts]);
20
+ }
21
+ }
22
+ return { [templateParts]: parts };
23
+ };
24
+ const escapeReplacements = {
25
+ "&": { escaped: "&", byteDelta: 4 },
26
+ "<": { escaped: "&lt;", byteDelta: 3 },
27
+ ">": { escaped: "&gt;", byteDelta: 3 },
28
+ '"': { escaped: "&quot;", byteDelta: 5 },
29
+ "'": { escaped: "&#39;", byteDelta: 4 }
30
+ };
31
+ const escapePattern = /[&<>"']/gu;
32
+ const escapeHtml = (text) => text.replace(escapePattern, (character) => escapeReplacements[character].escaped);
33
+ const escapedByteLength = (text) => {
34
+ let bytes = Buffer.byteLength(text, "utf8");
35
+ for (const [character] of text.matchAll(escapePattern)) {
36
+ bytes += escapeReplacements[character].byteDelta;
37
+ }
38
+ return bytes;
39
+ };
40
+ export class HtmlSink {
41
+ byteLimit;
42
+ chunks;
43
+ byteCount = 0;
44
+ exceeded = false;
45
+ constructor(collect, byteLimit) {
46
+ this.byteLimit = byteLimit;
47
+ this.chunks = collect ? [] : null;
48
+ }
49
+ write(template) {
50
+ this.writeTemplate(template, false);
51
+ }
52
+ writeLine(template) {
53
+ this.writeTemplate(template, true);
54
+ }
55
+ writeTemplate(template, lineBreak) {
56
+ if (this.exceeded)
57
+ return;
58
+ let remaining = this.byteLimit - this.byteCount - (lineBreak ? 1 : 0);
59
+ if (remaining < 0) {
60
+ this.exceeded = true;
61
+ return;
62
+ }
63
+ const renderedParts = this.chunks === null ? null : [];
64
+ for (const part of template[templateParts]) {
65
+ const length = part.escaped ? escapedByteLength(part.text) : Buffer.byteLength(part.text, "utf8");
66
+ if (length > remaining) {
67
+ this.exceeded = true;
68
+ return;
69
+ }
70
+ remaining -= length;
71
+ renderedParts?.push(part.escaped ? escapeHtml(part.text) : part.text);
72
+ }
73
+ this.byteCount = this.byteLimit - remaining;
74
+ if (renderedParts !== null) {
75
+ this.chunks?.push(`${renderedParts.join("")}${lineBreak ? "\n" : ""}`);
76
+ }
77
+ }
78
+ bytes() {
79
+ if (this.chunks === null || this.exceeded)
80
+ throw new Error("HTML sink has no complete output");
81
+ return Buffer.from(this.chunks.join(""), "utf8");
82
+ }
83
+ }
84
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/render/html.ts"],"names":[],"mappings":"AAKA,MAAM,aAAa,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAA;AAQjE,MAAM,OAAO,GAAG,CAAC,IAAY,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;AACtE,MAAM,UAAU,GAAG,CAAC,IAAY,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AAExE,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,OAA6B,EAC7B,GAAG,MAAwC,EAC7B,EAAE;IAChB,MAAM,KAAK,GAAoB,EAAE,CAAA;IACjC,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAChD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3B,IAAI,KAAK,KAAK,SAAS;YAAE,SAAQ;QACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;QAC/B,CAAC;aAAM,IAAI,OAAO,KAA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;gBACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;gBACpB,OAAM;YACR,CAAC;YACD,SAAS,IAAI,MAAM,CAAA;YACnB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvE,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC3C,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QAC9F,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;IAClD,CAAC;CACF"}
@@ -0,0 +1,212 @@
1
+ import { calculate } from "../validation/calculate.js";
2
+ const commonUnitId = (statement) => {
3
+ const first = statement.items[0];
4
+ if (first === undefined)
5
+ throw new Error("Validated statement lost its first item");
6
+ return statement.items.every(({ unit }) => unit === first.unit) ? first.unit : undefined;
7
+ };
8
+ export const statementFixedColumnCount = (statement) => 1 + (commonUnitId(statement) === undefined ? 1 : 0);
9
+ const rollupDepths = (statement) => {
10
+ const parentOf = new Map();
11
+ const ids = new Set(statement.items.map(({ id }) => id));
12
+ for (const item of statement.items) {
13
+ if (item.rollupTo !== undefined && ids.has(item.rollupTo)) {
14
+ parentOf.set(item.id, item.rollupTo);
15
+ }
16
+ }
17
+ const depths = new Map();
18
+ for (const item of statement.items) {
19
+ if (depths.has(item.id))
20
+ continue;
21
+ const path = [];
22
+ const visiting = new Set();
23
+ let current = item.id;
24
+ let resolvedDepth;
25
+ while (true) {
26
+ const known = depths.get(current);
27
+ if (known !== undefined) {
28
+ resolvedDepth = known;
29
+ break;
30
+ }
31
+ if (visiting.has(current))
32
+ throw new Error("Validated statement lost its acyclic rollups");
33
+ visiting.add(current);
34
+ path.push(current);
35
+ const parent = parentOf.get(current);
36
+ if (parent === undefined) {
37
+ resolvedDepth = -1;
38
+ break;
39
+ }
40
+ current = parent;
41
+ }
42
+ for (let index = path.length - 1; index >= 0; index -= 1) {
43
+ const id = path[index];
44
+ if (id === undefined)
45
+ throw new Error("Validated rollup path lost an item");
46
+ resolvedDepth += 1;
47
+ depths.set(id, resolvedDepth);
48
+ }
49
+ }
50
+ return depths;
51
+ };
52
+ const presentItems = (statement, units) => {
53
+ const depths = rollupDepths(statement);
54
+ const indexOf = new Map(statement.items.map((item, index) => [item.id, index]));
55
+ const parentIndices = statement.items.map(({ rollupTo }) => rollupTo === undefined ? undefined : indexOf.get(rollupTo));
56
+ const descendantCounts = statement.items.map(() => 0);
57
+ const indicesByDepth = new Map();
58
+ let maximumDepth = 0;
59
+ for (const [index, item] of statement.items.entries()) {
60
+ const depth = depths.get(item.id);
61
+ if (depth === undefined)
62
+ throw new Error("Validated item lost its rollup depth");
63
+ maximumDepth = Math.max(maximumDepth, depth);
64
+ const indices = indicesByDepth.get(depth) ?? [];
65
+ indices.push(index);
66
+ indicesByDepth.set(depth, indices);
67
+ }
68
+ for (let depth = maximumDepth; depth > 0; depth -= 1) {
69
+ for (const index of indicesByDepth.get(depth) ?? []) {
70
+ const parentIndex = parentIndices[index];
71
+ if (parentIndex === undefined)
72
+ throw new Error("Validated rollup item lost its parent");
73
+ descendantCounts[parentIndex] =
74
+ (descendantCounts[parentIndex] ?? 0) + (descendantCounts[index] ?? 0) + 1;
75
+ }
76
+ }
77
+ return statement.items.map((item, index) => {
78
+ const unit = units.get(item.unit);
79
+ if (unit === undefined)
80
+ throw new Error("Validated item lost its unit");
81
+ const depth = depths.get(item.id);
82
+ if (depth === undefined)
83
+ throw new Error("Validated item lost its rollup depth");
84
+ const descendantCount = descendantCounts[index];
85
+ if (descendantCount === undefined)
86
+ throw new Error("Validated item lost its descendant count");
87
+ return {
88
+ item,
89
+ unit,
90
+ depth,
91
+ descendantCount,
92
+ isParent: descendantCount > 0,
93
+ parentIndex: parentIndices[index]
94
+ };
95
+ });
96
+ };
97
+ const presentHeadings = (items) => {
98
+ const subtreeStarts = items.map((_, index) => index);
99
+ const subtreeEnds = items.map((_, index) => index);
100
+ const subtreeSizes = items.map(() => 1);
101
+ const indicesByDepth = new Map();
102
+ let maximumDepth = 0;
103
+ for (const [index, { depth }] of items.entries()) {
104
+ maximumDepth = Math.max(maximumDepth, depth);
105
+ const indices = indicesByDepth.get(depth) ?? [];
106
+ indices.push(index);
107
+ indicesByDepth.set(depth, indices);
108
+ }
109
+ for (let depth = maximumDepth; depth > 0; depth -= 1) {
110
+ for (const index of indicesByDepth.get(depth) ?? []) {
111
+ const parentIndex = items[index]?.parentIndex;
112
+ if (parentIndex === undefined)
113
+ throw new Error("Validated rollup item lost its parent");
114
+ subtreeStarts[parentIndex] = Math.min(subtreeStarts[parentIndex] ?? parentIndex, subtreeStarts[index] ?? index);
115
+ subtreeEnds[parentIndex] = Math.max(subtreeEnds[parentIndex] ?? parentIndex, subtreeEnds[index] ?? index);
116
+ subtreeSizes[parentIndex] =
117
+ (subtreeSizes[parentIndex] ?? 1) + (subtreeSizes[index] ?? 1);
118
+ }
119
+ }
120
+ const headings = new Map();
121
+ for (const [parentIndex, { isParent }] of items.entries()) {
122
+ if (!isParent)
123
+ continue;
124
+ const start = subtreeStarts[parentIndex];
125
+ const end = subtreeEnds[parentIndex];
126
+ const size = subtreeSizes[parentIndex];
127
+ if (start === undefined || end === undefined || size === undefined) {
128
+ throw new Error("Validated rollup item lost its subtree bounds");
129
+ }
130
+ if (start === parentIndex || end !== parentIndex || end - start + 1 !== size)
131
+ continue;
132
+ const stack = headings.get(start) ?? [];
133
+ stack.push(parentIndex);
134
+ headings.set(start, stack);
135
+ }
136
+ for (const stack of headings.values()) {
137
+ stack.sort((a, b) => {
138
+ const depthA = items[a]?.depth ?? 0;
139
+ const depthB = items[b]?.depth ?? 0;
140
+ return depthA - depthB;
141
+ });
142
+ }
143
+ return headings;
144
+ };
145
+ const presentChecks = (statement, applications, periods) => {
146
+ const itemsById = new Map(statement.items.map((item) => [item.id, item]));
147
+ const childrenByParent = new Map();
148
+ for (const item of statement.items) {
149
+ if (item.rollupTo === undefined)
150
+ continue;
151
+ const children = childrenByParent.get(item.rollupTo) ?? [];
152
+ children.push(item);
153
+ childrenByParent.set(item.rollupTo, children);
154
+ }
155
+ const checks = [];
156
+ for (const application of applications) {
157
+ const parent = itemsById.get(application.key.parent);
158
+ if (parent === undefined)
159
+ throw new Error("Validated application lost its parent item");
160
+ const period = periods.get(application.key.period);
161
+ if (period === undefined)
162
+ throw new Error("Validated application lost its period");
163
+ const children = childrenByParent.get(parent.id);
164
+ if (children === undefined)
165
+ throw new Error("Validated application lost its child items");
166
+ checks.push({ application, parent, children, period });
167
+ }
168
+ return checks;
169
+ };
170
+ export const createRenderPresentation = (document) => {
171
+ const units = new Map(document.units.map((unit) => [unit.id, unit]));
172
+ const periods = new Map(document.periods.map((period) => [period.id, period]));
173
+ const calculations = calculate(document);
174
+ const applicationsByStatement = new Map();
175
+ for (const application of calculations.applications) {
176
+ const applications = applicationsByStatement.get(application.key.statement) ?? [];
177
+ applications.push(application);
178
+ applicationsByStatement.set(application.key.statement, applications);
179
+ }
180
+ const statements = document.statements.map((statement, index) => {
181
+ const unitId = commonUnitId(statement);
182
+ const commonUnit = unitId === undefined ? undefined : units.get(unitId);
183
+ if (unitId !== undefined && commonUnit === undefined) {
184
+ throw new Error("Validated statement lost its unit");
185
+ }
186
+ const ordinal = index + 1;
187
+ const items = presentItems(statement, units);
188
+ const headings = presentHeadings(items);
189
+ let headingCount = 0;
190
+ for (const stack of headings.values())
191
+ headingCount += stack.length;
192
+ const checks = presentChecks(statement, applicationsByStatement.get(statement.id) ?? [], periods);
193
+ return {
194
+ statement,
195
+ items,
196
+ headings,
197
+ headingCount,
198
+ checks,
199
+ commonUnit,
200
+ fixedColumnCount: statementFixedColumnCount(statement),
201
+ ordinal,
202
+ anchorId: `statement-${ordinal}`,
203
+ tableId: `statement-table-${ordinal}`,
204
+ copySourceId: `copy-source-${ordinal}`,
205
+ copyStatusId: `copy-status-${ordinal}`,
206
+ copyHelpId: `copy-help-${ordinal}`,
207
+ checksId: `statement-checks-${ordinal}`
208
+ };
209
+ });
210
+ return { document, units, periods, calculations, statements };
211
+ };
212
+ //# sourceMappingURL=presentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentation.js","sourceRoot":"","sources":["../../src/render/presentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0B,MAAM,4BAA4B,CAAA;AA2D9E,MAAM,YAAY,GAAG,CAAC,SAAoB,EAAsB,EAAE;IAChE,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAChC,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IACnF,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1F,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,SAAoB,EAAU,EAAE,CACxE,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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