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