@umriss-ui/calculation 0.42.0 → 0.44.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/CHANGELOG.md +28 -0
- package/README.md +2 -0
- package/dist/calculation.client.js +311 -279
- package/dist/calculation.css +1 -1
- package/dist/calculation.js +2 -2
- package/dist/calculation.model-CZuohgrp.js +176 -0
- package/dist/index.d.ts +7 -4
- package/docs/llms-full.md +28 -27
- package/package.json +3 -3
- package/dist/calculation.model-DU6T1D09.js +0 -168
|
@@ -1,101 +1,116 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./calculation.css";
|
|
3
|
-
import { jsx as l, jsxs as
|
|
4
|
-
import { useId as
|
|
5
|
-
import { assess as
|
|
6
|
-
import { p as
|
|
7
|
-
function
|
|
8
|
-
|
|
3
|
+
import { jsx as l, jsxs as O } from "react/jsx-runtime";
|
|
4
|
+
import { useId as ye, useState as ae, useRef as ke, useCallback as me, useLayoutEffect as Ae, useEffect as Ee } from "react";
|
|
5
|
+
import { assess as Me, verdictWeight as X, useDensityFor as Te, useFormats as be, useWording as Ne, VisuallyHidden as Be, AngleGlyph as De, Badge as se, useFreshness as Le, Tooltip as Re } from "@umriss-ui/core";
|
|
6
|
+
import { p as We } from "./calculation.model-CZuohgrp.js";
|
|
7
|
+
function we(e, t) {
|
|
8
|
+
if (e.decimals !== void 0) return e.decimals;
|
|
9
|
+
const m = e.format === "percent" ? 1 : e.given ? void 0 : 2;
|
|
10
|
+
if (m === void 0) return;
|
|
11
|
+
const i = e.format === "percent" ? t * 100 : t;
|
|
12
|
+
return i !== 0 && $e(i, m) === 0 ? void 0 : m;
|
|
9
13
|
}
|
|
10
|
-
function
|
|
11
|
-
const [
|
|
12
|
-
return +`${
|
|
14
|
+
function pe(e, t) {
|
|
15
|
+
const [m, i = "0"] = String(e).split("e");
|
|
16
|
+
return +`${m}e${Number(i) + t}`;
|
|
13
17
|
}
|
|
14
|
-
function
|
|
15
|
-
return t === void 0 ?
|
|
18
|
+
function $e(e, t) {
|
|
19
|
+
return t === void 0 ? e : Math.sign(e) * pe(Math.round(pe(Math.abs(e), t)), -t) || 0;
|
|
16
20
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
21
|
+
function J(e, t, m = we(e, t)) {
|
|
22
|
+
return $e(e.format === "percent" ? t * 100 : t, m);
|
|
19
23
|
}
|
|
20
|
-
const
|
|
21
|
-
function
|
|
22
|
-
const [
|
|
23
|
-
switch (
|
|
24
|
+
const Fe = (e, t) => e.format === "percent" ? t / 100 : t;
|
|
25
|
+
function fe(e, t, m) {
|
|
26
|
+
const [i, ...d] = t;
|
|
27
|
+
switch (e) {
|
|
24
28
|
case "sum":
|
|
25
|
-
return t.reduce((
|
|
29
|
+
return t.reduce((n, r, g) => m[g] ? n - r : n + r, 0);
|
|
26
30
|
case "difference":
|
|
27
|
-
return
|
|
31
|
+
return d.reduce((n, r) => n - r, i);
|
|
28
32
|
case "product":
|
|
29
|
-
return
|
|
33
|
+
return d.reduce((n, r) => n * r, i);
|
|
30
34
|
case "quotient":
|
|
31
|
-
return
|
|
35
|
+
return i / d[0];
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
|
-
const
|
|
35
|
-
function
|
|
36
|
-
const t = /* @__PURE__ */ new Map(),
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
typeof
|
|
38
|
+
const he = (e, t) => t === void 0 || e !== void 0 && X(e) >= X(t) ? e : t;
|
|
39
|
+
function qe(e) {
|
|
40
|
+
const t = /* @__PURE__ */ new Map(), m = (i) => {
|
|
41
|
+
const d = t.get(i);
|
|
42
|
+
if (d) return d;
|
|
43
|
+
const n = e.quantities.get(i);
|
|
44
|
+
let r = null, g, p = !1, s;
|
|
45
|
+
if (n.given) {
|
|
46
|
+
const N = n.given.value;
|
|
47
|
+
typeof N == "number" && Number.isFinite(N) ? r = N : g = { kind: "missing", label: n.label };
|
|
44
48
|
} else {
|
|
45
|
-
const
|
|
46
|
-
for (const { operand: w, verdict:
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
const N = n.operands.map((w) => ({ operand: w, ...m(w.key) }));
|
|
50
|
+
for (const { operand: w, verdict: S, worst: C } of N) {
|
|
51
|
+
const $ = w.reference ? S : he(S, C);
|
|
52
|
+
s = he(s, $);
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
53
|
-
const w =
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
g = N.find((w) => w.absence)?.absence;
|
|
55
|
+
const I = N[1];
|
|
56
|
+
if (!g && n.operator === "quotient" && I.value === 0 && (g = { kind: "zero", label: e.quantities.get(I.operand.key).label }), !g) {
|
|
57
|
+
const w = n.operands.map(($) => $.negated === !0);
|
|
58
|
+
r = fe(n.operator, N.map(($) => $.value), w);
|
|
59
|
+
const S = fe(
|
|
60
|
+
n.operator,
|
|
61
|
+
N.map(($) => Fe(e.quantities.get($.operand.key), $.shown)),
|
|
58
62
|
w
|
|
59
|
-
);
|
|
60
|
-
|
|
63
|
+
), C = we(n, r);
|
|
64
|
+
p = J(n, S, C) !== J(n, r, C);
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
|
-
const
|
|
64
|
-
value:
|
|
65
|
-
absence:
|
|
66
|
-
shown:
|
|
67
|
-
approximate:
|
|
68
|
-
assessment:
|
|
69
|
-
verdict:
|
|
70
|
-
worst:
|
|
67
|
+
const M = { target: n.target, limits: n.limits }, T = n.target !== void 0 || (n.limits?.length ?? 0) > 0 ? Me(r, M) : void 0, h = (n.limits?.length ?? 0) > 0 ? T.verdict : r === null ? "unknown" : void 0, q = {
|
|
68
|
+
value: r,
|
|
69
|
+
absence: g,
|
|
70
|
+
shown: r === null ? null : J(n, r),
|
|
71
|
+
approximate: p,
|
|
72
|
+
assessment: T,
|
|
73
|
+
verdict: h,
|
|
74
|
+
worst: s
|
|
71
75
|
};
|
|
72
|
-
return t.set(
|
|
76
|
+
return t.set(i, q), q;
|
|
73
77
|
};
|
|
74
|
-
for (const
|
|
78
|
+
for (const i of e.quantities.keys()) m(i);
|
|
75
79
|
return t;
|
|
76
80
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
function je() {
|
|
82
|
+
try {
|
|
83
|
+
return process.env.NODE_ENV !== "production";
|
|
84
|
+
} catch {
|
|
85
|
+
return !1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const Pe = je(), ve = /* @__PURE__ */ new Set();
|
|
89
|
+
function Ue(e, t) {
|
|
90
|
+
!Pe || ve.has(e) || (ve.add(e), console.warn(`@umriss-ui/calculation: ${t}`));
|
|
85
91
|
}
|
|
86
|
-
const
|
|
92
|
+
const ge = 4;
|
|
93
|
+
function Ie(e, t, m) {
|
|
94
|
+
const i = e.operands[t];
|
|
95
|
+
if (i.previous) return;
|
|
96
|
+
const d = e.operator, n = t === 0;
|
|
97
|
+
if (d !== "sum" && d !== "difference") return n ? void 0 : { operator: d, negated: !1 };
|
|
98
|
+
const r = d === "difference" ? !n : i.negated === !0, g = new Set(m.filter((s) => s !== null && s !== 0).map(Math.sign)), p = g.size === 1 ? { operator: "sum", negated: r !== g.has(-1), unsigned: !0 } : { operator: "sum", negated: r };
|
|
99
|
+
return n && !p.negated ? void 0 : p;
|
|
100
|
+
}
|
|
101
|
+
const Ve = {
|
|
87
102
|
sum: "calculationSumSymbol",
|
|
88
103
|
difference: "calculationDifferenceSymbol",
|
|
89
104
|
product: "calculationProductSymbol",
|
|
90
105
|
quotient: "calculationQuotientSymbol"
|
|
91
|
-
},
|
|
106
|
+
}, ze = {
|
|
92
107
|
sum: "calculationSumWord",
|
|
93
108
|
difference: "calculationDifferenceWord",
|
|
94
109
|
product: "calculationProductWord",
|
|
95
110
|
quotient: "calculationQuotientWord"
|
|
96
111
|
};
|
|
97
|
-
function
|
|
98
|
-
switch (
|
|
112
|
+
function K(e, t) {
|
|
113
|
+
switch (e) {
|
|
99
114
|
case "alarm":
|
|
100
115
|
return t.verdictAlarm;
|
|
101
116
|
case "warning":
|
|
@@ -106,298 +121,315 @@ function Y(n, t) {
|
|
|
106
121
|
return t.verdictOk;
|
|
107
122
|
}
|
|
108
123
|
}
|
|
109
|
-
function
|
|
110
|
-
const
|
|
111
|
-
return
|
|
124
|
+
function ee(e, t, m) {
|
|
125
|
+
const i = e.negated ? "difference" : e.operator;
|
|
126
|
+
return m[(t ? ze : Ve)[i]];
|
|
112
127
|
}
|
|
113
|
-
function
|
|
114
|
-
return
|
|
128
|
+
function He(e, t) {
|
|
129
|
+
return e.kind === "missing" ? t.calculationMissing(e.label) : t.calculationDivisionByZero(e.label);
|
|
115
130
|
}
|
|
116
|
-
function
|
|
117
|
-
const
|
|
118
|
-
return
|
|
131
|
+
function _e(e, t, m, i) {
|
|
132
|
+
const d = e.format === "percent" ? i : e.unit, n = m.number(t, e.decimals);
|
|
133
|
+
return d ? `${n} ${d}` : n;
|
|
119
134
|
}
|
|
120
|
-
function
|
|
135
|
+
function Qe(e, t, m, i, d, n, r, g = () => {
|
|
121
136
|
}) {
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
return
|
|
125
|
-
},
|
|
126
|
-
if (
|
|
127
|
-
if (
|
|
128
|
-
if (!
|
|
129
|
-
return { names:
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
return
|
|
137
|
+
const p = e.quantities.get(m), s = t.get(m), M = (v, k) => v.shown !== null && k?.unsigned ? Math.abs(v.shown) : v.shown, T = (v, k, _, W) => {
|
|
138
|
+
const j = M(k, W);
|
|
139
|
+
return j === null ? _ ? n.verdictUnknown : n.statAbsentValue : _e(v, j, d, _ ? n.calculationPercent : "%");
|
|
140
|
+
}, h = (v) => {
|
|
141
|
+
if (i || !p.operator) return {};
|
|
142
|
+
if (p.operands.length === 0) return { names: n.calculationNoOperands };
|
|
143
|
+
if (!v && p.operands.length > ge)
|
|
144
|
+
return { names: n.calculationOperandCount(p.operands.length) };
|
|
145
|
+
const k = (_) => p.operands.map((W, j) => {
|
|
146
|
+
const Y = e.quantities.get(W.key), F = g(j);
|
|
147
|
+
return F ? `${ee(F, v, n)} ${_(Y, F)}` : _(Y);
|
|
133
148
|
}).join(" ");
|
|
134
149
|
return {
|
|
135
|
-
names:
|
|
136
|
-
numbers:
|
|
150
|
+
names: k((_) => _.label),
|
|
151
|
+
numbers: k((_, W) => T(_, t.get(_.key), v, W))
|
|
137
152
|
};
|
|
138
|
-
},
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
return
|
|
143
|
-
},
|
|
144
|
-
(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
].filter(Boolean).join(", "),
|
|
149
|
-
return { amount:
|
|
153
|
+
}, q = (v) => {
|
|
154
|
+
const k = s.assessment?.deviation;
|
|
155
|
+
if (k === void 0 || p.target === void 0) return;
|
|
156
|
+
const _ = _e(p, J(p, p.target), d, v ? n.calculationPercent : "%");
|
|
157
|
+
return k > 0 ? n.calculationAboveTarget(_) : k < 0 ? n.calculationBelowTarget(_) : n.calculationOnTarget(_);
|
|
158
|
+
}, N = h(!1).names, I = N === void 0 || p.operands.length === 0 || p.operands.length > ge ? N : `= ${N}`, w = h(!0), S = s.absence ? He(s.absence, n) : void 0, C = ` ${n.calculationEquals} `, $ = s.approximate ? `${n.calculationApproximately} ${T(p, s, !0, r)}` : T(p, s, !0, r), te = [
|
|
159
|
+
(r ? `${ee(r, !0, n)} ` : "") + p.label + C + [w.names, w.numbers, $].filter(Boolean).join(`,${C}`),
|
|
160
|
+
s.verdict !== void 0 && s.verdict !== "unknown" ? K(s.verdict, n) : void 0,
|
|
161
|
+
q(!0),
|
|
162
|
+
S
|
|
163
|
+
].filter(Boolean).join(", "), G = s.shown === null ? void 0 : p.format === "percent" ? "%" : p.unit, y = (v) => v === null ? n.statAbsentValue : d.number(v, p.decimals);
|
|
164
|
+
return { amount: y(M(s, r)), ownAmount: y(s.shown), unit: G, names: I, target: q(!1), reason: S, sentence: te, spokenNames: w.names, spokenNumber: $ };
|
|
150
165
|
}
|
|
151
|
-
function
|
|
152
|
-
const
|
|
153
|
-
(
|
|
166
|
+
function Ge(e, t, m, i, d) {
|
|
167
|
+
const n = d ? `${ee(d, !0, i)} ` : "", r = t[0].spokenNames, g = n + e + (r === void 0 ? "" : ` ${i.calculationEquals} ${r}`), p = m.map(
|
|
168
|
+
(s, M) => [`${s.label} ${t[M].spokenNumber}`, t[M].reason].filter(Boolean).join(", ")
|
|
154
169
|
);
|
|
155
|
-
return `${
|
|
170
|
+
return `${g}: ${p.join("; ")}`;
|
|
156
171
|
}
|
|
157
|
-
const
|
|
158
|
-
frame:
|
|
159
|
-
calculation:
|
|
160
|
-
line:
|
|
161
|
-
assessment:
|
|
162
|
-
disclosure:
|
|
163
|
-
amount:
|
|
164
|
-
list:
|
|
165
|
-
item:
|
|
166
|
-
derivation:
|
|
167
|
-
labelCell:
|
|
168
|
-
names:
|
|
169
|
-
operator:
|
|
170
|
-
unit:
|
|
171
|
-
label:
|
|
172
|
-
approximate:
|
|
173
|
-
target:
|
|
174
|
-
worst:
|
|
175
|
-
head:
|
|
176
|
-
headCell:
|
|
177
|
-
headUnit:
|
|
178
|
-
notes:
|
|
179
|
-
freshness:
|
|
180
|
-
headLabel:
|
|
181
|
-
},
|
|
182
|
-
function
|
|
183
|
-
const
|
|
184
|
-
return /* @__PURE__ */
|
|
185
|
-
|
|
186
|
-
|
|
172
|
+
const Ye = "_frame_10pic_24 _text_18806_22", Ze = "_calculation_10pic_51", Je = "_line_10pic_86", Ke = "_assessment_10pic_98", Xe = "_disclosure_10pic_107", et = "_amount_10pic_90", tt = "_list_10pic_128", nt = "_item_10pic_129", at = "_derivation_10pic_130", st = "_labelCell_10pic_90", ot = "_names_10pic_90", it = "_operator_10pic_90", rt = "_unit_10pic_90", ct = "_label_10pic_90", lt = "_approximate_10pic_360", dt = "_target_10pic_102", ut = "_worst_10pic_102", mt = "_head_10pic_512", pt = "_headCell_10pic_519", ft = "_headUnit_10pic_532", ht = "_notes_10pic_539", vt = "_freshness_10pic_553", gt = "_headLabel_10pic_583", o = {
|
|
173
|
+
frame: Ye,
|
|
174
|
+
calculation: Ze,
|
|
175
|
+
line: Je,
|
|
176
|
+
assessment: Ke,
|
|
177
|
+
disclosure: Xe,
|
|
178
|
+
amount: et,
|
|
179
|
+
list: tt,
|
|
180
|
+
item: nt,
|
|
181
|
+
derivation: at,
|
|
182
|
+
labelCell: st,
|
|
183
|
+
names: ot,
|
|
184
|
+
operator: it,
|
|
185
|
+
unit: rt,
|
|
186
|
+
label: ct,
|
|
187
|
+
approximate: lt,
|
|
188
|
+
target: dt,
|
|
189
|
+
worst: ut,
|
|
190
|
+
head: mt,
|
|
191
|
+
headCell: pt,
|
|
192
|
+
headUnit: ft,
|
|
193
|
+
notes: ht,
|
|
194
|
+
freshness: vt,
|
|
195
|
+
headLabel: gt
|
|
196
|
+
}, _t = 10, Q = (e) => 4 + 2 * e, bt = (e) => 5 + 2 * e, Nt = { ok: "success", unknown: "neutral", warning: "warning", alarm: "danger" }, wt = (...e) => e.filter(Boolean).join(" ");
|
|
197
|
+
function $t({ asOf: e, ages: t }) {
|
|
198
|
+
const m = be(), i = Ne(), d = Le(e, t), n = d.freshness === "lost" ? i.freshnessDisconnected : d.freshness === "stale" ? i.freshnessStale : i.freshnessFresh;
|
|
199
|
+
return /* @__PURE__ */ O("span", { className: o.freshness, "data-freshness": d.freshness, children: [
|
|
200
|
+
n,
|
|
201
|
+
d.age !== null && ` · ${m.relative(d.age)}`
|
|
187
202
|
] });
|
|
188
203
|
}
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
204
|
+
function yt({
|
|
205
|
+
model: e,
|
|
206
|
+
ref: t,
|
|
207
|
+
className: m,
|
|
208
|
+
style: i,
|
|
209
|
+
density: d,
|
|
210
|
+
"aria-label": n,
|
|
211
|
+
"aria-labelledby": r,
|
|
212
|
+
"aria-describedby": g,
|
|
213
|
+
...p
|
|
214
|
+
}) {
|
|
215
|
+
!n && !r && Ue("no-name", "A Calculation has no accessible name: give it aria-label or aria-labelledby.");
|
|
216
|
+
const s = e.metrics, M = Te(d, "regular") === "compact", T = be(), h = Ne(), q = ye(), N = We(e).map((a) => ({ view: a, results: qe(a) })), [I, w] = ae(() => /* @__PURE__ */ new Set()), [S, C] = ae(null), $ = ke(null), oe = me(
|
|
217
|
+
(a) => {
|
|
218
|
+
$.current = a, typeof t == "function" ? t(a) : t && (t.current = a);
|
|
219
|
+
},
|
|
220
|
+
[t]
|
|
221
|
+
), [te, G] = ae(!1), y = s?.length ?? 0, v = me(() => {
|
|
222
|
+
const a = $.current, u = a && y > 0 ? getComputedStyle(a.firstElementChild).gridTemplateColumns.split(" ").map(parseFloat) : [], f = Q(y) - 1;
|
|
223
|
+
if (!a || u.length <= f || u.some((x) => !Number.isFinite(x))) {
|
|
224
|
+
G(!1);
|
|
194
225
|
return;
|
|
195
226
|
}
|
|
196
|
-
const
|
|
197
|
-
let
|
|
198
|
-
const
|
|
199
|
-
for (const
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
const
|
|
204
|
-
|
|
227
|
+
const A = u.slice(2, f).reduce((x, E) => x + E, 0);
|
|
228
|
+
let c = 0;
|
|
229
|
+
const B = document.createRange();
|
|
230
|
+
for (const x of a.querySelectorAll(`.${o.label}`)) {
|
|
231
|
+
B.selectNodeContents(x);
|
|
232
|
+
const E = [...B.getClientRects()].reduce((L, R) => L + R.width, 0);
|
|
233
|
+
if (E === 0) continue;
|
|
234
|
+
const z = x.parentElement, V = x.getBoundingClientRect().left - z.getBoundingClientRect().left;
|
|
235
|
+
c = Math.max(c, V + E + parseFloat(getComputedStyle(z).paddingRight));
|
|
205
236
|
}
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
}, [
|
|
209
|
-
|
|
210
|
-
const a =
|
|
211
|
-
if (!a ||
|
|
212
|
-
const
|
|
213
|
-
return
|
|
214
|
-
}, [
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
return
|
|
218
|
-
}),
|
|
237
|
+
const D = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
238
|
+
G(a.clientWidth - A < Math.min(c, _t * D));
|
|
239
|
+
}, [y]);
|
|
240
|
+
Ae(() => v()), Ee(() => {
|
|
241
|
+
const a = $.current;
|
|
242
|
+
if (!a || y === 0) return;
|
|
243
|
+
const u = new ResizeObserver(() => v());
|
|
244
|
+
return u.observe(a), () => u.disconnect();
|
|
245
|
+
}, [v, y]);
|
|
246
|
+
const k = (a) => w((u) => {
|
|
247
|
+
const f = new Set(u);
|
|
248
|
+
return f.delete(a) || f.add(a), f;
|
|
249
|
+
}), _ = (a, u) => Ie(
|
|
219
250
|
a,
|
|
220
|
-
|
|
221
|
-
|
|
251
|
+
u,
|
|
252
|
+
N.map(({ results: f }) => f.get(a.operands[u].key).shown)
|
|
222
253
|
);
|
|
223
|
-
let
|
|
224
|
-
const
|
|
225
|
-
/* @__PURE__ */
|
|
254
|
+
let W = !1;
|
|
255
|
+
const j = (a, u) => a.map(({ own: f, text: A }, c) => [
|
|
256
|
+
/* @__PURE__ */ O(
|
|
226
257
|
"span",
|
|
227
258
|
{
|
|
228
|
-
className:
|
|
259
|
+
className: o.amount,
|
|
229
260
|
"aria-hidden": "true",
|
|
230
|
-
"data-verdict":
|
|
231
|
-
"data-later":
|
|
232
|
-
style:
|
|
261
|
+
"data-verdict": f.verdict,
|
|
262
|
+
"data-later": c > 0 ? "" : void 0,
|
|
263
|
+
style: s ? { "--_calculation-column": Q(c) } : void 0,
|
|
233
264
|
children: [
|
|
234
|
-
|
|
235
|
-
|
|
265
|
+
f.approximate && /* @__PURE__ */ l(Re, { content: h.calculationApproximateNote, children: /* @__PURE__ */ l("span", { className: o.approximate, children: "≈" }) }),
|
|
266
|
+
u ? A.ownAmount : A.amount
|
|
236
267
|
]
|
|
237
268
|
},
|
|
238
|
-
`amount-${
|
|
269
|
+
`amount-${c}`
|
|
239
270
|
),
|
|
240
271
|
/* @__PURE__ */ l(
|
|
241
272
|
"span",
|
|
242
273
|
{
|
|
243
|
-
className:
|
|
274
|
+
className: o.unit,
|
|
244
275
|
"aria-hidden": "true",
|
|
245
|
-
style:
|
|
246
|
-
"data-last":
|
|
247
|
-
children:
|
|
276
|
+
style: s ? { "--_calculation-column": bt(c) } : void 0,
|
|
277
|
+
"data-last": s && c === a.length - 1 ? "" : void 0,
|
|
278
|
+
children: s && !u ? void 0 : A.unit
|
|
248
279
|
},
|
|
249
|
-
`unit-${
|
|
280
|
+
`unit-${c}`
|
|
250
281
|
)
|
|
251
|
-
]),
|
|
252
|
-
const
|
|
253
|
-
own:
|
|
254
|
-
text:
|
|
255
|
-
})), { own:
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
(
|
|
259
|
-
) : [],
|
|
260
|
-
!
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
!
|
|
264
|
-
].filter(Boolean),
|
|
282
|
+
]), Y = (a, u) => S === null ? void 0 : a === S ? "use" : u === S ? "operand" : void 0, F = (a, u, f, A) => {
|
|
283
|
+
const c = e.quantities.get(a), B = N.map(({ view: b, results: U }) => ({
|
|
284
|
+
own: U.get(a),
|
|
285
|
+
text: Qe(b, U, a, u, T, h, f.position, (Ce) => _(c, Ce))
|
|
286
|
+
})), { own: D, text: x } = B[0], E = c.operator !== void 0 && !u, z = a === e.result && !u, V = E && c.operands.length > 0 && (c.interim ? f.flat : z), L = E && !V && c.operands.length > 0, R = L && I.has(a);
|
|
287
|
+
W ||= L;
|
|
288
|
+
const ie = `${q}-${a}`, ne = { depth: V ? f.depth : f.depth + 1, flat: !1, parent: a }, Z = E ? c.operands.find((b) => b.previous) : void 0, re = Z && f.flat ? F(Z.key, !1, { ...f, parent: a, position: void 0 }, `${A}-c`) : [], Oe = Z && !f.flat ? F(Z.key, !1, { ...ne, flat: !0 }, `${A}-c`) : [], ce = E ? c.operands.map(
|
|
289
|
+
(b, U) => b.previous ? null : F(b.key, b.reference, { ...ne, position: _(c, U) }, `${A}-${U}`)
|
|
290
|
+
) : [], H = L && !R && D.worst !== void 0 && X(D.worst) > X(D.verdict ?? "ok") ? D.worst : void 0, P = u ? void 0 : c.given, Se = f.position ? ee(f.position, !1, h) : void 0, le = [
|
|
291
|
+
!u && c.explanation !== void 0 && /* @__PURE__ */ l("span", { children: c.explanation }, "explanation"),
|
|
292
|
+
P?.source !== void 0 && /* @__PURE__ */ l("span", { children: h.calculationSource(P.source) }, "source"),
|
|
293
|
+
P?.asOf !== void 0 && (P.ages !== void 0 ? /* @__PURE__ */ l($t, { asOf: P.asOf, ages: P.ages }, "asOf") : /* @__PURE__ */ l("span", { children: h.asOfAgo(T.dateTime(new Date(P.asOf), !1)) }, "asOf")),
|
|
294
|
+
!u && c.aside !== void 0 && /* @__PURE__ */ l("span", { children: c.aside }, "aside")
|
|
295
|
+
].filter(Boolean), de = z ? "result" : c.interim && !u && f.flat ? "interim" : void 0, ue = /* @__PURE__ */ O(
|
|
265
296
|
"div",
|
|
266
297
|
{
|
|
267
|
-
className:
|
|
268
|
-
style: { "--_calculation-depth":
|
|
269
|
-
"data-inner":
|
|
270
|
-
"data-kind":
|
|
271
|
-
"data-foldable":
|
|
272
|
-
"data-reference":
|
|
273
|
-
"data-emphasis":
|
|
274
|
-
"data-rule": !
|
|
275
|
-
"data-mark":
|
|
276
|
-
onPointerEnter: () =>
|
|
277
|
-
onPointerLeave: () =>
|
|
278
|
-
onFocus: () =>
|
|
279
|
-
onBlur: () =>
|
|
280
|
-
onClick:
|
|
281
|
-
window.getSelection()?.toString() ||
|
|
298
|
+
className: o.line,
|
|
299
|
+
style: { "--_calculation-depth": f.depth },
|
|
300
|
+
"data-inner": f.depth > 0 ? "" : void 0,
|
|
301
|
+
"data-kind": de,
|
|
302
|
+
"data-foldable": L ? "" : void 0,
|
|
303
|
+
"data-reference": u ? "" : void 0,
|
|
304
|
+
"data-emphasis": u ? void 0 : c.emphasis,
|
|
305
|
+
"data-rule": !u && c.rule ? "" : void 0,
|
|
306
|
+
"data-mark": Y(a, f.parent),
|
|
307
|
+
onPointerEnter: () => C(a),
|
|
308
|
+
onPointerLeave: () => C(null),
|
|
309
|
+
onFocus: () => C(a),
|
|
310
|
+
onBlur: () => C(null),
|
|
311
|
+
onClick: L ? () => {
|
|
312
|
+
window.getSelection()?.toString() || k(a);
|
|
282
313
|
} : void 0,
|
|
283
314
|
children: [
|
|
284
|
-
/* @__PURE__ */ l(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
315
|
+
/* @__PURE__ */ l(Be, { children: [
|
|
316
|
+
s ? Ge(c.label, B.map((b) => b.text), s, h, f.position) : x.sentence,
|
|
317
|
+
B.some((b) => b.own.approximate) && h.calculationApproximateNote,
|
|
318
|
+
H !== void 0 && h.calculationWorstInside(K(H, h))
|
|
288
319
|
].filter(Boolean).join(". ") }),
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
|
|
320
|
+
/* @__PURE__ */ O("span", { className: o.labelCell, children: [
|
|
321
|
+
L ? /* @__PURE__ */ l(
|
|
291
322
|
"button",
|
|
292
323
|
{
|
|
293
324
|
type: "button",
|
|
294
|
-
className:
|
|
295
|
-
"aria-expanded":
|
|
296
|
-
"aria-controls":
|
|
297
|
-
"aria-label": (
|
|
298
|
-
children: /* @__PURE__ */ l(
|
|
325
|
+
className: o.disclosure,
|
|
326
|
+
"aria-expanded": R,
|
|
327
|
+
"aria-controls": ie,
|
|
328
|
+
"aria-label": (R ? h.calculationHideDerivation : h.calculationShowDerivation)(c.label),
|
|
329
|
+
children: /* @__PURE__ */ l(De, { "data-open": R ? "" : void 0 })
|
|
299
330
|
}
|
|
300
|
-
) : /* @__PURE__ */ l("span", { className:
|
|
301
|
-
/* @__PURE__ */ l("span", { className:
|
|
331
|
+
) : /* @__PURE__ */ l("span", { className: o.disclosure, "aria-hidden": "true" }),
|
|
332
|
+
/* @__PURE__ */ l("span", { className: o.label, "aria-hidden": "true", children: c.label })
|
|
302
333
|
] }),
|
|
303
|
-
/* @__PURE__ */ l("span", { className:
|
|
304
|
-
/* @__PURE__ */ l("span", { className:
|
|
305
|
-
|
|
306
|
-
/* @__PURE__ */
|
|
307
|
-
|
|
334
|
+
/* @__PURE__ */ l("span", { className: o.names, "aria-hidden": "true", children: E && !V && !R ? x.names : void 0 }),
|
|
335
|
+
/* @__PURE__ */ l("span", { className: o.operator, "aria-hidden": "true", children: Se }),
|
|
336
|
+
j(B, de !== void 0),
|
|
337
|
+
/* @__PURE__ */ O("span", { className: o.assessment, "aria-hidden": "true", children: [
|
|
338
|
+
s ? (
|
|
308
339
|
/* Short: which metric. The sentence carries the full reason. */
|
|
309
|
-
|
|
310
|
-
(
|
|
340
|
+
s.map(
|
|
341
|
+
(b, U) => B[U].own.absence && /* @__PURE__ */ l(se, { children: h.calculationMissing(b.unit ?? b.label) }, b.id)
|
|
311
342
|
)
|
|
312
|
-
) :
|
|
313
|
-
|
|
314
|
-
|
|
343
|
+
) : x.reason !== void 0 ? /* @__PURE__ */ l(se, { children: x.reason }) : D.verdict !== void 0 && /* @__PURE__ */ l(se, { tone: Nt[D.verdict], children: K(D.verdict, h) }),
|
|
344
|
+
x.target !== void 0 && /* @__PURE__ */ l("span", { className: o.target, children: x.target }),
|
|
345
|
+
H !== void 0 && /* @__PURE__ */ l("span", { className: o.worst, "data-verdict": H, children: h.calculationWorstInside(K(H, h)) })
|
|
315
346
|
] }),
|
|
316
|
-
|
|
347
|
+
le.length > 0 && /* A click here - on a link in the aside, on a sparkline - is the
|
|
317
348
|
caller's, not a fold. */
|
|
318
|
-
/* @__PURE__ */ l("span", { className:
|
|
349
|
+
/* @__PURE__ */ l("span", { className: o.notes, onClick: (b) => b.stopPropagation(), children: le })
|
|
319
350
|
]
|
|
320
351
|
}
|
|
321
352
|
);
|
|
322
|
-
return
|
|
323
|
-
...
|
|
324
|
-
/* @__PURE__ */
|
|
325
|
-
/* @__PURE__ */ l("ul", { className:
|
|
326
|
-
|
|
327
|
-
] },
|
|
353
|
+
return V ? [
|
|
354
|
+
...re,
|
|
355
|
+
/* @__PURE__ */ O("li", { className: o.item, children: [
|
|
356
|
+
/* @__PURE__ */ l("ul", { className: o.list, children: ce }),
|
|
357
|
+
ue
|
|
358
|
+
] }, A)
|
|
328
359
|
] : [
|
|
329
|
-
...
|
|
330
|
-
/* @__PURE__ */
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
/* @__PURE__ */ l("li", { className:
|
|
360
|
+
...re,
|
|
361
|
+
/* @__PURE__ */ O("li", { className: o.item, "data-open": R ? "" : void 0, style: { "--_calculation-depth": f.depth }, children: [
|
|
362
|
+
ue,
|
|
363
|
+
L && /* @__PURE__ */ O("ul", { id: ie, className: o.derivation, hidden: !R, children: [
|
|
364
|
+
Oe,
|
|
365
|
+
ce,
|
|
366
|
+
/* @__PURE__ */ l("li", { className: o.item, "aria-hidden": "true", children: /* @__PURE__ */ O(
|
|
336
367
|
"div",
|
|
337
368
|
{
|
|
338
|
-
className:
|
|
339
|
-
style: { "--_calculation-depth":
|
|
369
|
+
className: o.line,
|
|
370
|
+
style: { "--_calculation-depth": ne.depth },
|
|
340
371
|
"data-inner": "",
|
|
341
372
|
"data-closing": "",
|
|
342
|
-
"data-mark":
|
|
373
|
+
"data-mark": S === a ? "use" : void 0,
|
|
343
374
|
children: [
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */ l("span", { className:
|
|
346
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ O("span", { className: o.labelCell, children: [
|
|
376
|
+
/* @__PURE__ */ l("span", { className: o.disclosure }),
|
|
377
|
+
/* @__PURE__ */ O("span", { className: o.label, children: [
|
|
347
378
|
"= ",
|
|
348
|
-
|
|
379
|
+
c.label
|
|
349
380
|
] })
|
|
350
381
|
] }),
|
|
351
|
-
/* @__PURE__ */ l("span", { className:
|
|
352
|
-
/* @__PURE__ */ l("span", { className:
|
|
353
|
-
|
|
382
|
+
/* @__PURE__ */ l("span", { className: o.names }),
|
|
383
|
+
/* @__PURE__ */ l("span", { className: o.operator }),
|
|
384
|
+
j(B, !0)
|
|
354
385
|
]
|
|
355
386
|
}
|
|
356
387
|
) })
|
|
357
388
|
] })
|
|
358
|
-
] },
|
|
389
|
+
] }, A)
|
|
359
390
|
];
|
|
360
|
-
},
|
|
391
|
+
}, xe = F(e.result, !1, { depth: 0, flat: !0, parent: null }, "r");
|
|
361
392
|
return (
|
|
362
393
|
/* The frame is the surface and the container the layout measures itself
|
|
363
394
|
against; the list inside it is the statement. */
|
|
364
395
|
/* @__PURE__ */ l(
|
|
365
396
|
"div",
|
|
366
397
|
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
"--_calculation-
|
|
372
|
-
"--_calculation-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
"data-
|
|
377
|
-
"data-
|
|
378
|
-
"data-
|
|
379
|
-
|
|
380
|
-
|
|
398
|
+
...p,
|
|
399
|
+
ref: oe,
|
|
400
|
+
className: wt(o.frame, m),
|
|
401
|
+
style: s ? {
|
|
402
|
+
"--_calculation-figure-tracks": Array(y * 2).fill("auto").join(" "),
|
|
403
|
+
"--_calculation-figures-end": Q(y),
|
|
404
|
+
"--_calculation-assessment-column": Q(y),
|
|
405
|
+
...i
|
|
406
|
+
} : i,
|
|
407
|
+
"data-still": W ? void 0 : "",
|
|
408
|
+
"data-metrics": s ? y : void 0,
|
|
409
|
+
"data-two-lines": te ? "" : void 0,
|
|
410
|
+
"data-compact": M ? "" : void 0,
|
|
411
|
+
children: /* @__PURE__ */ O("ul", { className: o.calculation, "aria-label": n, "aria-labelledby": r, "aria-describedby": g, children: [
|
|
412
|
+
s && /* The head names each metric and its unit above its column. Every
|
|
381
413
|
row's sentence names them too, so the head is for the eye. */
|
|
382
|
-
/* @__PURE__ */ l("li", { className:
|
|
414
|
+
/* @__PURE__ */ l("li", { className: o.item, "aria-hidden": "true", children: /* @__PURE__ */ l("div", { className: o.head, children: s.map((a, u) => /* @__PURE__ */ O(
|
|
383
415
|
"span",
|
|
384
416
|
{
|
|
385
|
-
className:
|
|
417
|
+
className: o.headCell,
|
|
386
418
|
"data-unit": a.unit === void 0 ? void 0 : "",
|
|
387
|
-
style: { "--_calculation-column":
|
|
419
|
+
style: { "--_calculation-column": Q(u) },
|
|
388
420
|
children: [
|
|
389
|
-
/* @__PURE__ */ l("span", { className:
|
|
390
|
-
a.unit !== void 0 && /* @__PURE__ */ l("span", { className:
|
|
421
|
+
/* @__PURE__ */ l("span", { className: o.headLabel, children: a.label }),
|
|
422
|
+
a.unit !== void 0 && /* @__PURE__ */ l("span", { className: o.headUnit, children: a.unit })
|
|
391
423
|
]
|
|
392
424
|
},
|
|
393
425
|
a.id
|
|
394
426
|
)) }) }),
|
|
395
|
-
|
|
427
|
+
xe
|
|
396
428
|
] })
|
|
397
429
|
}
|
|
398
430
|
)
|
|
399
431
|
);
|
|
400
432
|
}
|
|
401
433
|
export {
|
|
402
|
-
|
|
434
|
+
yt as CalculationView
|
|
403
435
|
};
|