@umriss-ui/calculation 0.3.6 → 0.4.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.
@@ -1,409 +1,537 @@
1
1
  import "./calculation.css";
2
- import { jsx as f, jsxs as k } from "react/jsx-runtime";
3
- import { Children as ve, isValidElement as j, Fragment as ge, useId as we, useState as oe } from "react";
4
- import { assess as ye, verdictWeight as K, useFormats as me, useWording as fe, VisuallyHidden as _e, AngleGlyph as be, Tooltip as re, Badge as ie, useFreshness as $e } from "@umriss-ui/core";
5
- function Ne(t) {
2
+ import { jsx as g, jsxs as R } from "react/jsx-runtime";
3
+ import { Children as Ce, isValidElement as V, Fragment as Oe, useId as qe, useState as ie, useRef as ke, useCallback as Me, useLayoutEffect as Te, useEffect as Ee } from "react";
4
+ import { assess as Re, verdictWeight as ae, useFormats as we, useWording as Se, VisuallyHidden as Ae, AngleGlyph as Ie, Badge as re, useFreshness as Pe, Tooltip as je } from "@umriss-ui/core";
5
+ function De(t) {
6
6
  return t.decimals !== void 0 ? t.decimals : t.format === "percent" ? 1 : t.given ? void 0 : 2;
7
7
  }
8
- function xe(t, n) {
9
- return n === void 0 ? t : Math.sign(t) * Number(Math.abs(t).toFixed(n));
8
+ function Be(t, e) {
9
+ return e === void 0 ? t : Math.sign(t) * Number(Math.abs(t).toFixed(e));
10
10
  }
11
- function G(t, n) {
12
- return xe(t.format === "percent" ? n * 100 : n, Ne(t));
11
+ function te(t, e) {
12
+ return Be(t.format === "percent" ? e * 100 : e, De(t));
13
13
  }
14
- const Oe = (t, n) => t.format === "percent" ? n / 100 : n;
15
- function ce(t, n, v) {
16
- const [m, ...i] = n;
14
+ const Le = (t, e) => t.format === "percent" ? e / 100 : e;
15
+ function ve(t, e, h) {
16
+ const [o, ...c] = e;
17
17
  switch (t) {
18
18
  case "sum":
19
- return i.reduce((e, h, o) => v[o + 1] ? e - h : e + h, m);
19
+ return c.reduce((n, i, d) => h[d + 1] ? n - i : n + i, o);
20
20
  case "difference":
21
- return i.reduce((e, h) => e - h, m);
21
+ return c.reduce((n, i) => n - i, o);
22
22
  case "product":
23
- return i.reduce((e, h) => e * h, m);
23
+ return c.reduce((n, i) => n * i, o);
24
24
  case "quotient":
25
- return m / i[0];
25
+ return o / c[0];
26
26
  }
27
27
  }
28
- const le = (t, n) => n === void 0 || t !== void 0 && K(t) >= K(n) ? t : n;
29
- function Se(t) {
30
- const n = /* @__PURE__ */ new Map(), v = (m) => {
31
- var _, x, T;
32
- const i = n.get(m);
33
- if (i) return i;
34
- const e = t.quantities.get(m);
35
- let h = null, o, N = !1, C;
36
- if (e.given) {
37
- const b = e.given.value;
38
- typeof b == "number" && Number.isFinite(b) ? h = b : o = { kind: "missing", label: e.label };
28
+ const ge = (t, e) => e === void 0 || t !== void 0 && ae(t) >= ae(e) ? t : e;
29
+ function We(t) {
30
+ const e = /* @__PURE__ */ new Map(), h = (o) => {
31
+ var u, $, s;
32
+ const c = e.get(o);
33
+ if (c) return c;
34
+ const n = t.quantities.get(o);
35
+ let i = null, d, b = !1, M;
36
+ if (n.given) {
37
+ const l = n.given.value;
38
+ typeof l == "number" && Number.isFinite(l) ? i = l : d = { kind: "missing", label: n.label };
39
39
  } else {
40
- const b = e.operands.map((a) => ({ operand: a, ...v(a.key) }));
41
- for (const { operand: a, verdict: l, worst: r } of b) {
42
- const w = a.reference ? l : le(l, r);
43
- C = le(C, w);
40
+ const l = n.operands.map((S) => ({ operand: S, ...h(S.key) }));
41
+ for (const { operand: S, verdict: T, worst: N } of l) {
42
+ const C = S.reference ? T : ge(T, N);
43
+ M = ge(M, C);
44
44
  }
45
- o = (_ = b.find((a) => a.absence)) == null ? void 0 : _.absence;
46
- const O = b[1];
47
- if (!o && e.operator === "quotient" && O.value === 0 && (o = { kind: "zero", label: t.quantities.get(O.operand.key).label }), !o) {
48
- const a = e.operands.map((r) => r.negated === !0);
49
- h = ce(e.operator, b.map((r) => r.value), a);
50
- const l = ce(
51
- e.operator,
52
- b.map((r) => Oe(t.quantities.get(r.operand.key), r.shown)),
53
- a
45
+ d = (u = l.find((S) => S.absence)) == null ? void 0 : u.absence;
46
+ const O = l[1];
47
+ if (!d && n.operator === "quotient" && O.value === 0 && (d = { kind: "zero", label: t.quantities.get(O.operand.key).label }), !d) {
48
+ const S = n.operands.map((N) => N.negated === !0);
49
+ i = ve(n.operator, l.map((N) => N.value), S);
50
+ const T = ve(
51
+ n.operator,
52
+ l.map((N) => Le(t.quantities.get(N.operand.key), N.shown)),
53
+ S
54
54
  );
55
- N = G(e, l) !== G(e, h);
55
+ b = te(n, T) !== te(n, i);
56
56
  }
57
57
  }
58
- const d = { target: e.target, limits: e.limits }, g = e.target !== void 0 || (((x = e.limits) == null ? void 0 : x.length) ?? 0) > 0 ? ye(h, d) : void 0, y = (((T = e.limits) == null ? void 0 : T.length) ?? 0) > 0 ? g.verdict : h === null ? "unknown" : void 0, c = {
59
- value: h,
60
- absence: o,
61
- shown: h === null ? null : G(e, h),
62
- approximate: N,
63
- assessment: g,
64
- verdict: y,
65
- worst: C
58
+ const A = { target: n.target, limits: n.limits }, U = n.target !== void 0 || ((($ = n.limits) == null ? void 0 : $.length) ?? 0) > 0 ? Re(i, A) : void 0, I = (((s = n.limits) == null ? void 0 : s.length) ?? 0) > 0 ? U.verdict : i === null ? "unknown" : void 0, r = {
59
+ value: i,
60
+ absence: d,
61
+ shown: i === null ? null : te(n, i),
62
+ approximate: b,
63
+ assessment: U,
64
+ verdict: I,
65
+ worst: M
66
66
  };
67
- return n.set(m, c), c;
67
+ return e.set(o, r), r;
68
68
  };
69
- for (const m of t.quantities.keys()) v(m);
70
- return n;
69
+ for (const o of t.quantities.keys()) h(o);
70
+ return e;
71
71
  }
72
- const qe = () => null, Te = () => null, ke = () => null, Ce = () => null, Ae = () => null, ue = () => null, Ie = () => null, Me = () => null, Pe = () => null, De = () => null, Ee = () => null, Y = () => null, Be = /* @__PURE__ */ new Map([
73
- [Te, "sum"],
74
- [ke, "difference"],
75
- [Ce, "product"],
76
- [Ae, "quotient"]
77
- ]), We = {
72
+ const Fe = () => null, Ue = () => null, Qe = () => null, Ve = () => null, ze = () => null, be = () => null, Ge = () => null, He = () => null, Ke = () => null, Ye = () => null, Je = () => null, ce = () => null, Ze = /* @__PURE__ */ new Map([
73
+ [Ue, "sum"],
74
+ [Qe, "difference"],
75
+ [Ve, "product"],
76
+ [ze, "quotient"]
77
+ ]), $e = {
78
78
  sum: "Sum",
79
79
  difference: "Difference",
80
80
  product: "Product",
81
81
  quotient: "Quotient"
82
- }, Z = /* @__PURE__ */ new Map([
83
- [Me, { name: "Plus", operator: "sum" }],
84
- [Pe, { name: "Minus", operator: "sum", negated: !0 }],
85
- [De, { name: "Times", operator: "product" }],
86
- [Ee, { name: "DividedBy", operator: "quotient" }]
87
- ]), X = "<Given>, <Sum>, <Difference>, <Product>, <Quotient> or <Chain>";
88
- function q(t) {
82
+ }, le = /* @__PURE__ */ new Map([
83
+ [He, { name: "Plus", operator: "sum" }],
84
+ [Ke, { name: "Minus", operator: "sum", negated: !0 }],
85
+ [Ye, { name: "Times", operator: "product" }],
86
+ [Je, { name: "DividedBy", operator: "quotient" }]
87
+ ]), ue = "<Given>, <Sum>, <Difference>, <Product>, <Quotient> or <Chain>", _e = "a calculation with metrics only adds and subtracts - <Sum>, <Difference>, <Plus>, <Minus>.", Xe = ["unit", "format", "decimals"];
88
+ function w(t) {
89
89
  throw new Error(`@umriss-ui/calculation: ${t}`);
90
90
  }
91
- function Q(t) {
92
- return ve.toArray(t).flatMap(
93
- (n) => j(n) && n.type === ge ? Q(n.props.children) : [n]
91
+ function Z(t) {
92
+ return Ce.toArray(t).flatMap(
93
+ (e) => V(e) && e.type === Oe ? Z(e.props.children) : [e]
94
94
  );
95
95
  }
96
- function V(t) {
97
- if (!j(t)) return JSON.stringify(t);
98
- const n = t.type;
99
- return typeof n == "string" ? `<${n}>` : `<${n.displayName ?? n.name ?? "anonymous"}>`;
96
+ function ee(t) {
97
+ if (!V(t)) return JSON.stringify(t);
98
+ const e = t.type;
99
+ return typeof e == "string" ? `<${e}>` : `<${e.displayName ?? e.name ?? "anonymous"}>`;
100
100
  }
101
- const ee = (t, n, v) => `${t}/${j(n) && n.key || v}`;
102
- function je(t) {
103
- const n = Q(t);
104
- n.length !== 1 && q(`<Calculation> takes exactly one child, the result; it was given ${n.length}.`);
105
- const v = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), i = [], e = (d, g, y) => {
106
- const { id: c, ..._ } = g;
107
- c !== void 0 && (m.has(c) && q(`${y}: the id "${c}" is used twice.`), m.set(c, d));
108
- const x = { ..._, key: d, id: c, operands: [] };
109
- return v.set(d, x), x;
110
- }, h = (d, g, y) => {
111
- if (j(d) && d.type === ue) {
112
- const c = { key: "", reference: !0 };
113
- return i.push({ operand: c, to: d.props.to, where: y }), c;
101
+ const de = (t, e, h) => `${t}/${V(e) && e.key || h}`;
102
+ function et(t, e) {
103
+ const h = Z(t);
104
+ if (h.length !== 1 && w(`<Calculation> takes exactly one child, the result; it was given ${h.length}.`), e !== void 0) {
105
+ e.length === 0 && w("<Calculation>: metrics is empty; leave it out for a calculation with one number per quantity.");
106
+ const r = /* @__PURE__ */ new Set();
107
+ for (const { id: u } of e)
108
+ r.has(u) && w(`<Calculation>: the metric id "${u}" is used twice.`), r.add(u);
109
+ }
110
+ const o = e == null ? void 0 : e.map((r) => `"${r.id}"`).join(", "), c = (r, u) => {
111
+ const $ = typeof r == "object" && r !== null;
112
+ if (e === void 0) {
113
+ $ && w(`${u}: value is an object by metric, but the calculation has no metrics.`);
114
+ return;
115
+ }
116
+ $ || w(`${u}: with metrics, value is an object with a number for each metric - ${o}.`);
117
+ for (const { id: s } of e)
118
+ s in r || w(`${u}: value has no number for the metric "${s}"; write null where it is absent. The metrics: ${o}.`);
119
+ for (const s of Object.keys(r))
120
+ e.some((l) => l.id === s) || w(`${u}: value has a number for "${s}", which is no metric. The metrics: ${o}.`);
121
+ }, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), d = [], b = (r, u, $) => {
122
+ const { id: s, ...l } = u;
123
+ if (e !== void 0) {
124
+ for (const S of Xe)
125
+ u[S] !== void 0 && w(`${$}: ${S} belongs to the metric once the calculation has metrics, not to a quantity.`);
126
+ (u.target !== void 0 || u.limits !== void 0) && w(`${$}: target and limits are not assessed in a calculation with metrics.`);
127
+ }
128
+ s !== void 0 && (i.has(s) && w(`${$}: the id "${s}" is used twice.`), i.set(s, r));
129
+ const O = { ...l, key: r, id: s, operands: [] };
130
+ return n.set(r, O), O;
131
+ }, M = (r, u, $) => {
132
+ if (V(r) && r.type === be) {
133
+ const s = { key: "", reference: !0 };
134
+ return d.push({ operand: s, to: r.props.to, where: $ }), s;
114
135
  }
115
- return { key: o(d, g, y), reference: !1 };
116
- }, o = (d, g, y) => {
117
- if ((!j(d) || d.type === ue || Z.has(d.type) || d.type === Y) && q(`${y}: ${V(d)} cannot stand here; a quantity must be ${X}.`), d.type === Ie) return N(d.props.children, g, y);
118
- const c = Be.get(d.type);
119
- d.type !== qe && c === void 0 && q(
120
- `${y}: ${V(d)} is not an element of the calculation. A calculation reads its children's props and cannot look inside a component of your own; write ${X} or <Ref> directly, or return them from .map.`
136
+ return { key: A(r, u, $), reference: !1 };
137
+ }, A = (r, u, $) => {
138
+ if ((!V(r) || r.type === be || le.has(r.type) || r.type === ce) && w(`${$}: ${ee(r)} cannot stand here; a quantity must be ${ue}.`), r.type === Ge) return U(r.props.children, u, $);
139
+ const s = Ze.get(r.type);
140
+ r.type !== Fe && s === void 0 && w(
141
+ `${$}: ${ee(r)} is not an element of the calculation. A calculation reads its children's props and cannot look inside a component of your own; write ${ue} or <Ref> directly, or return them from .map.`
121
142
  );
122
- const { children: _, value: x, source: T, asOf: b, ages: O, ...a } = d.props, l = `${y} › ${a.label}`, r = e(g, a, l);
123
- if (c === void 0)
124
- return r.given = { value: x, source: T, asOf: b, ages: O }, g;
125
- r.operator = c;
126
- const w = Q(_), s = w.length;
127
- return (c === "quotient" ? s !== 2 : s < 2) && q(
128
- `${l}: <${We[c]}> takes ${c === "quotient" ? "exactly two operands" : "two or more operands"}; it was given ${s}.`
129
- ), r.operands = w.map((u, $) => h(u, ee(g, u, $), l)), g;
130
- }, N = (d, g, y) => {
131
- const c = `${y} › <Chain>`, [_, ...x] = Q(d);
132
- (_ === void 0 || j(_) && (Z.has(_.type) || _.type === Y)) && q(`${c}: a chain starts with a quantity that has no operator - ${X} or <Ref>.`);
133
- let T = h(_, ee(g, _, 0), c), b = V(_), O = [], a;
134
- return x.forEach((l, r) => {
135
- const w = ee(g, l, r + 1);
136
- if (j(l) && l.type === Y) {
137
- const M = l.props, D = `${c} › ${M.label}`;
138
- O.length === 0 && q(`${D}: an <Interim> needs an operand since the named value before it, ${b}.`);
139
- const S = e(w, M, D);
140
- S.interim = !0, S.operator = O[0].line.operator, S.operands = [T, ...O.map((J) => J.operand)], T = { key: w, reference: !1, previous: !0 }, b = `<Interim label="${M.label}">`, O = [], a = w;
143
+ const { children: l, value: O, source: S, asOf: T, ages: N, ...C } = r.props, _ = `${$} › ${C.label}`;
144
+ e !== void 0 && (s === "product" || s === "quotient") && w(`${_}: <${$e[s]}> - ${_e}`);
145
+ const y = b(u, C, _);
146
+ if (s === void 0)
147
+ return c(O, _), y.given = { value: O, source: S, asOf: T, ages: N }, u;
148
+ y.operator = s;
149
+ const q = Z(l), a = q.length;
150
+ return (s === "quotient" ? a !== 2 : a < 2) && w(
151
+ `${_}: <${$e[s]}> takes ${s === "quotient" ? "exactly two operands" : "two or more operands"}; it was given ${a}.`
152
+ ), y.operands = q.map((f, m) => M(f, de(u, f, m), _)), u;
153
+ }, U = (r, u, $) => {
154
+ const s = `${$} › <Chain>`, [l, ...O] = Z(r);
155
+ (l === void 0 || V(l) && (le.has(l.type) || l.type === ce)) && w(`${s}: a chain starts with a quantity that has no operator - ${ue} or <Ref>.`);
156
+ let S = M(l, de(u, l, 0), s), T = ee(l), N = [], C;
157
+ return O.forEach((_, y) => {
158
+ const q = de(u, _, y + 1);
159
+ if (V(_) && _.type === ce) {
160
+ const L = _.props, Q = `${s} › ${L.label}`;
161
+ N.length === 0 && w(`${Q}: an <Interim> needs an operand since the named value before it, ${T}.`);
162
+ const K = b(q, L, Q);
163
+ K.interim = !0, K.operator = N[0].line.operator, K.operands = [S, ...N.map((se) => se.operand)], S = { key: q, reference: !1, previous: !0 }, T = `<Interim label="${L.label}">`, N = [], C = q;
141
164
  return;
142
165
  }
143
- const s = j(l) ? Z.get(l.type) : void 0;
144
- s === void 0 && q(`${c}: ${V(l)} needs an operator in a chain - <Plus>, <Minus>, <Times> or <DividedBy> - or is an <Interim>.`);
145
- const u = s.operator !== "sum", $ = O.find((M) => M.line.operator !== "sum");
146
- (u && O.length > 0 || $) && q(
147
- `${c}: <${($ ?? { line: s }).line.name}> stands alone between two named values - directly after the first quantity or an <Interim>, and directly before an <Interim>.`
166
+ const a = V(_) ? le.get(_.type) : void 0;
167
+ a === void 0 && w(`${s}: ${ee(_)} needs an operator in a chain - <Plus>, <Minus>, <Times> or <DividedBy> - or is an <Interim>.`), e !== void 0 && a.operator !== "sum" && w(`${s}: <${a.name}> - ${_e}`);
168
+ const f = a.operator !== "sum", m = N.find((L) => L.line.operator !== "sum");
169
+ (f && N.length > 0 || m) && w(
170
+ `${s}: <${(m ?? { line: a }).line.name}> stands alone between two named values - directly after the first quantity or an <Interim>, and directly before an <Interim>.`
148
171
  );
149
- const { children: B, ...A } = l.props, W = Q(B), I = () => q(`${c}: <${s.name}> takes either a label and a value, or exactly one quantity as its child.`);
150
- if (W.length > 0) {
151
- (W.length > 1 || Object.values(A).some((D) => D !== void 0)) && I();
152
- const M = h(W[0], w, c);
153
- M.negated = s.negated, O.push({ operand: M, line: s });
172
+ const { children: P, ...v } = _.props, E = Z(P), j = () => w(`${s}: <${a.name}> takes either a label and a value, or exactly one quantity as its child.`);
173
+ if (E.length > 0) {
174
+ (E.length > 1 || Object.values(v).some((Q) => Q !== void 0)) && j();
175
+ const L = M(E[0], q, s);
176
+ L.negated = a.negated, N.push({ operand: L, line: a });
154
177
  return;
155
178
  }
156
- A.label === void 0 && I();
157
- const { value: E, source: U, asOf: F, ages: R, ...L } = A, z = e(w, { ...L, label: A.label }, `${c} › ${A.label}`);
158
- z.given = { value: E, source: U, asOf: F, ages: R }, O.push({ operand: { key: w, reference: !1, negated: s.negated }, line: s });
159
- }), (O.length > 0 || a === void 0) && q(`${c}: a chain ends with an <Interim>, which names its value.`), a;
160
- }, C = o(n[0], "0", "<Calculation>");
161
- for (const { operand: d, to: g, where: y } of i) {
162
- const c = m.get(g);
163
- if (c === void 0) {
164
- const _ = [...m.keys()].map((x) => `"${x}"`).join(", ");
165
- q(`${y}: <Ref to="${g}"> names no quantity. ${_ ? `The ids that exist: ${_}.` : "No quantity has an id."}`);
179
+ v.label === void 0 && j();
180
+ const { value: k, source: W, asOf: z, ages: G, ...D } = v, B = `${s} › ${v.label}`, X = b(q, { ...D, label: v.label }, B);
181
+ c(k, B), X.given = { value: k, source: W, asOf: z, ages: G }, N.push({ operand: { key: q, reference: !1, negated: a.negated }, line: a });
182
+ }), (N.length > 0 || C === void 0) && w(`${s}: a chain ends with an <Interim>, which names its value.`), C;
183
+ }, I = A(h[0], "0", "<Calculation>");
184
+ for (const { operand: r, to: u, where: $ } of d) {
185
+ const s = i.get(u);
186
+ if (s === void 0) {
187
+ const l = [...i.keys()].map((O) => `"${O}"`).join(", ");
188
+ w(`${$}: <Ref to="${u}"> names no quantity. ${l ? `The ids that exist: ${l}.` : "No quantity has an id."}`);
166
189
  }
167
- d.key = c;
190
+ r.key = s;
168
191
  }
169
- return Re(v), { result: C, quantities: v };
192
+ return nt(n), { result: I, quantities: n, metrics: e };
170
193
  }
171
- function Re(t) {
172
- const n = /* @__PURE__ */ new Set(), v = [], m = (i) => {
173
- if (n.has(i)) return;
174
- const e = v.indexOf(i);
175
- if (e !== -1) {
176
- const h = [...v.slice(e), i].map((o) => t.get(o).label);
177
- q(`the calculation goes round in a circle through references: ${h.join(" → ")}.`);
194
+ function tt(t) {
195
+ return t.metrics ? t.metrics.map((e) => {
196
+ const h = /* @__PURE__ */ new Map();
197
+ for (const [o, c] of t.quantities) {
198
+ const n = c.given && { ...c.given, value: c.given.value[e.id] };
199
+ h.set(o, { ...c, unit: e.unit, decimals: e.decimals, given: n });
178
200
  }
179
- v.push(i);
180
- for (const h of t.get(i).operands) m(h.key);
181
- v.pop(), n.add(i);
201
+ return { result: t.result, quantities: h };
202
+ }) : [t];
203
+ }
204
+ function nt(t) {
205
+ const e = /* @__PURE__ */ new Set(), h = [], o = (c) => {
206
+ if (e.has(c)) return;
207
+ const n = h.indexOf(c);
208
+ if (n !== -1) {
209
+ const i = [...h.slice(n), c].map((d) => t.get(d).label);
210
+ w(`the calculation goes round in a circle through references: ${i.join(" → ")}.`);
211
+ }
212
+ h.push(c);
213
+ for (const i of t.get(c).operands) o(i.key);
214
+ h.pop(), e.add(c);
182
215
  };
183
- for (const i of t.keys()) m(i);
216
+ for (const c of t.keys()) o(c);
184
217
  }
185
- const de = 4, Fe = {
218
+ const ye = 4, at = {
186
219
  sum: "calculationSumSymbol",
187
220
  difference: "calculationDifferenceSymbol",
188
221
  product: "calculationProductSymbol",
189
222
  quotient: "calculationQuotientSymbol"
190
- }, Qe = {
223
+ }, ot = {
191
224
  sum: "calculationSumWord",
192
225
  difference: "calculationDifferenceWord",
193
226
  product: "calculationProductWord",
194
227
  quotient: "calculationQuotientWord"
195
228
  };
196
- function H(t, n) {
229
+ function ne(t, e) {
197
230
  switch (t) {
198
231
  case "alarm":
199
- return n.verdictAlarm;
232
+ return e.verdictAlarm;
200
233
  case "warning":
201
- return n.verdictWarning;
234
+ return e.verdictWarning;
202
235
  case "unknown":
203
- return n.verdictUnknown;
236
+ return e.verdictUnknown;
204
237
  default:
205
- return n.verdictOk;
238
+ return e.verdictOk;
206
239
  }
207
240
  }
208
- function te(t, n, v) {
209
- const m = t.negated ? "difference" : t.operator;
210
- return v[(n ? Qe : Fe)[m]];
241
+ function oe(t, e, h) {
242
+ const o = t.negated ? "difference" : t.operator;
243
+ return h[(e ? ot : at)[o]];
211
244
  }
212
- function Ue(t, n) {
213
- return t.kind === "missing" ? n.calculationMissing(t.label) : n.calculationDivisionByZero(t.label);
245
+ function st(t, e) {
246
+ return t.kind === "missing" ? e.calculationMissing(t.label) : e.calculationDivisionByZero(t.label);
214
247
  }
215
- function pe(t, n, v, m) {
216
- const i = t.format === "percent" ? m : t.unit, e = v.number(n, t.decimals);
217
- return i ? `${e} ${i}` : e;
248
+ function Ne(t, e, h, o) {
249
+ const c = t.format === "percent" ? o : t.unit, n = h.number(e, t.decimals);
250
+ return c ? `${n} ${c}` : n;
218
251
  }
219
- function Le(t, n, v, m, i, e, h) {
220
- const o = t.quantities.get(v), N = n.get(v), C = (w, s, u) => s.shown === null ? u ? e.verdictUnknown : e.statAbsentValue : pe(w, s.shown, i, u ? e.calculationPercent : "%"), d = (w) => {
221
- if (m || !o.operator) return {};
222
- if (!w && o.operands.length > de)
223
- return { names: e.calculationOperandCount(o.operands.length) };
224
- const s = (u) => o.operands.map(($, B) => {
225
- const A = t.quantities.get($.key);
226
- return B === 0 ? u(A) : `${te({ operator: o.operator, negated: $.negated === !0 }, w, e)} ${u(A)}`;
252
+ function it(t, e, h, o, c, n, i) {
253
+ const d = t.quantities.get(h), b = e.get(h), M = (C, _, y) => _.shown === null ? y ? n.verdictUnknown : n.statAbsentValue : Ne(C, _.shown, c, y ? n.calculationPercent : "%"), A = (C) => {
254
+ if (o || !d.operator) return {};
255
+ if (!C && d.operands.length > ye)
256
+ return { names: n.calculationOperandCount(d.operands.length) };
257
+ const _ = (y) => d.operands.map((q, a) => {
258
+ const f = t.quantities.get(q.key);
259
+ return a === 0 ? y(f) : `${oe({ operator: d.operator, negated: q.negated === !0 }, C, n)} ${y(f)}`;
227
260
  }).join(" ");
228
261
  return {
229
- names: s((u) => u.label),
230
- numbers: s((u) => C(u, n.get(u.key), w))
262
+ names: _((y) => y.label),
263
+ numbers: _((y) => M(y, e.get(y.key), C))
231
264
  };
232
- }, g = (w) => {
233
- var $;
234
- const s = ($ = N.assessment) == null ? void 0 : $.deviation;
235
- if (s === void 0 || o.target === void 0) return;
236
- const u = pe(o, G(o, o.target), i, w ? e.calculationPercent : "%");
237
- return s > 0 ? e.calculationAboveTarget(u) : s < 0 ? e.calculationBelowTarget(u) : e.calculationOnTarget(u);
238
- }, y = d(!1).names, c = y === void 0 || o.operands.length > de ? y : `= ${y}`, _ = d(!0), x = N.absence ? Ue(N.absence, e) : void 0, T = ` ${e.calculationEquals} `, b = N.approximate ? `${e.calculationApproximately} ${C(o, N, !0)}` : C(o, N, !0), a = [
239
- (h ? `${te(h, !0, e)} ` : "") + o.label + T + [_.names, _.numbers, b].filter(Boolean).join(`,${T}`),
240
- N.verdict !== void 0 && N.verdict !== "unknown" ? H(N.verdict, e) : void 0,
241
- g(!0),
242
- x
243
- ].filter(Boolean).join(", "), l = N.shown === null ? void 0 : o.format === "percent" ? "%" : o.unit;
244
- return { amount: N.shown === null ? e.statAbsentValue : i.number(N.shown, o.decimals), unit: l, names: c, target: g(!1), reason: x, sentence: a };
265
+ }, U = (C) => {
266
+ var q;
267
+ const _ = (q = b.assessment) == null ? void 0 : q.deviation;
268
+ if (_ === void 0 || d.target === void 0) return;
269
+ const y = Ne(d, te(d, d.target), c, C ? n.calculationPercent : "%");
270
+ return _ > 0 ? n.calculationAboveTarget(y) : _ < 0 ? n.calculationBelowTarget(y) : n.calculationOnTarget(y);
271
+ }, I = A(!1).names, r = I === void 0 || d.operands.length > ye ? I : `= ${I}`, u = A(!0), $ = b.absence ? st(b.absence, n) : void 0, s = ` ${n.calculationEquals} `, l = b.approximate ? `${n.calculationApproximately} ${M(d, b, !0)}` : M(d, b, !0), S = [
272
+ (i ? `${oe(i, !0, n)} ` : "") + d.label + s + [u.names, u.numbers, l].filter(Boolean).join(`,${s}`),
273
+ b.verdict !== void 0 && b.verdict !== "unknown" ? ne(b.verdict, n) : void 0,
274
+ U(!0),
275
+ $
276
+ ].filter(Boolean).join(", "), T = b.shown === null ? void 0 : d.format === "percent" ? "%" : d.unit;
277
+ return { amount: b.shown === null ? n.statAbsentValue : c.number(b.shown, d.decimals), unit: T, names: r, target: U(!1), reason: $, sentence: S, spokenNames: u.names, spokenNumber: l };
245
278
  }
246
- const Ve = "_frame_1ydwt_21 _text_ocaqi_23", Ge = "_calculation_1ydwt_40", He = "_disclosure_1ydwt_54", Ke = "_list_1ydwt_58", ze = "_item_1ydwt_59", Je = "_derivation_1ydwt_60", Ye = "_line_1ydwt_110", Ze = "_labelCell_1ydwt_152", Xe = "_names_1ydwt_153", et = "_operator_1ydwt_154", tt = "_amount_1ydwt_155", nt = "_unit_1ydwt_156", at = "_assessment_1ydwt_157", st = "_label_1ydwt_152", ot = "_approximate_1ydwt_275", rt = "_target_1ydwt_303", it = "_worst_1ydwt_304", ct = "_notes_1ydwt_396", lt = "_freshness_1ydwt_410", p = {
247
- frame: Ve,
248
- calculation: Ge,
249
- disclosure: He,
250
- list: Ke,
251
- item: ze,
252
- derivation: Je,
253
- line: Ye,
254
- labelCell: Ze,
255
- names: Xe,
256
- operator: et,
257
- amount: tt,
258
- unit: nt,
259
- assessment: at,
260
- label: st,
261
- approximate: ot,
262
- target: rt,
263
- worst: it,
264
- notes: ct,
265
- freshness: lt
266
- }, ut = { ok: "success", unknown: "neutral", warning: "warning", alarm: "danger" }, dt = (...t) => t.filter(Boolean).join(" ");
267
- function pt({ asOf: t, ages: n }) {
268
- const v = me(), m = fe(), i = $e(t, n), e = i.freshness === "lost" ? m.freshnessDisconnected : i.freshness === "stale" ? m.freshnessStale : m.freshnessFresh;
269
- return /* @__PURE__ */ k("span", { className: p.freshness, "data-freshness": i.freshness, children: [
270
- e,
271
- i.age !== null && ` · ${v.relative(i.age)}`
279
+ function rt(t, e, h, o, c) {
280
+ const n = c ? `${oe(c, !0, o)} ` : "", i = e[0].spokenNames, d = n + t + (i === void 0 ? "" : ` ${o.calculationEquals} ${i}`), b = h.map(
281
+ (M, A) => [`${M.label} ${e[A].spokenNumber}`, e[A].reason].filter(Boolean).join(", ")
282
+ );
283
+ return `${d}: ${b.join("; ")}`;
284
+ }
285
+ const ct = "_frame_c4ne1_24 _text_ocaqi_23", lt = "_calculation_c4ne1_46", ut = "_disclosure_c4ne1_60", dt = "_list_c4ne1_64", ft = "_item_c4ne1_65", pt = "_derivation_c4ne1_66", mt = "_line_c4ne1_116", ht = "_labelCell_c4ne1_158", vt = "_names_c4ne1_159", gt = "_operator_c4ne1_160", bt = "_amount_c4ne1_161", $t = "_unit_c4ne1_162", _t = "_assessment_c4ne1_163", yt = "_label_c4ne1_158", Nt = "_approximate_c4ne1_281", wt = "_target_c4ne1_309", St = "_worst_c4ne1_310", xt = "_head_c4ne1_407", Ct = "_headCell_c4ne1_414", Ot = "_headUnit_c4ne1_427", qt = "_notes_c4ne1_434", kt = "_freshness_c4ne1_448", Mt = "_headLabel_c4ne1_478", p = {
286
+ frame: ct,
287
+ calculation: lt,
288
+ disclosure: ut,
289
+ list: dt,
290
+ item: ft,
291
+ derivation: pt,
292
+ line: mt,
293
+ labelCell: ht,
294
+ names: vt,
295
+ operator: gt,
296
+ amount: bt,
297
+ unit: $t,
298
+ assessment: _t,
299
+ label: yt,
300
+ approximate: Nt,
301
+ target: wt,
302
+ worst: St,
303
+ head: xt,
304
+ headCell: Ct,
305
+ headUnit: Ot,
306
+ notes: qt,
307
+ freshness: kt,
308
+ headLabel: Mt
309
+ }, Tt = 10, J = (t) => 4 + 2 * t, Et = (t) => 5 + 2 * t, Rt = { ok: "success", unknown: "neutral", warning: "warning", alarm: "danger" }, At = (...t) => t.filter(Boolean).join(" ");
310
+ function It({ asOf: t, ages: e }) {
311
+ const h = we(), o = Se(), c = Pe(t, e), n = c.freshness === "lost" ? o.freshnessDisconnected : c.freshness === "stale" ? o.freshnessStale : o.freshnessFresh;
312
+ return /* @__PURE__ */ R("span", { className: p.freshness, "data-freshness": c.freshness, children: [
313
+ n,
314
+ c.age !== null && ` · ${h.relative(c.age)}`
272
315
  ] });
273
316
  }
274
- function vt({ children: t, className: n, style: v, ...m }) {
275
- const i = me(), e = fe(), h = we(), o = je(t), N = Se(o), [C, d] = oe(() => /* @__PURE__ */ new Set()), [g, y] = oe(null), c = (a) => d((l) => {
276
- const r = new Set(l);
277
- return r.delete(a) || r.add(a), r;
278
- }), _ = (a, l, r) => r === 0 || l.previous ? void 0 : { operator: a.operator, negated: l.negated === !0 };
279
- let x = !1;
280
- const T = (a, l) => g === null ? void 0 : a === g ? "use" : l === g ? "operand" : void 0, b = (a, l, r, w) => {
281
- const s = o.quantities.get(a), u = N.get(a), $ = Le(o, N, a, l, i, e, r.position), B = s.operator !== void 0 && !l, A = a === o.result && !l, W = B && (s.interim ? r.flat : A), I = B && !W, E = I && C.has(a);
282
- x || (x = I);
283
- const U = `${h}-${a}`, F = { depth: W ? r.depth : r.depth + 1, flat: !1, parent: a }, R = B ? s.operands.find((P) => P.previous) : void 0, L = R && r.flat ? b(R.key, !1, { ...r, parent: a, position: void 0 }, `${w}-c`) : [], z = R && !r.flat ? b(R.key, !1, { ...F, flat: !0 }, `${w}-c`) : [], M = B ? s.operands.map(
284
- (P, se) => P.previous ? null : b(P.key, P.reference, { ...F, position: _(s, P, se) }, `${w}-${se}`)
285
- ) : [], D = I && !E && u.worst !== void 0 && K(u.worst) > K(u.verdict ?? "ok") ? u.worst : void 0, S = l ? void 0 : s.given, J = r.position ? te(r.position, !1, e) : void 0, ne = [
286
- !l && s.explanation !== void 0 && /* @__PURE__ */ f("span", { children: s.explanation }, "explanation"),
287
- (S == null ? void 0 : S.source) !== void 0 && /* @__PURE__ */ f("span", { children: e.calculationSource(S.source) }, "source"),
288
- (S == null ? void 0 : S.asOf) !== void 0 && (S.ages !== void 0 ? /* @__PURE__ */ f(pt, { asOf: S.asOf, ages: S.ages }, "asOf") : /* @__PURE__ */ f("span", { children: e.asOfAgo(i.dateTime(new Date(S.asOf), !1)) }, "asOf")),
289
- !l && s.aside !== void 0 && /* @__PURE__ */ f("span", { children: s.aside }, "aside")
290
- ].filter(Boolean), he = A ? "result" : s.interim && !l && r.flat ? "interim" : void 0, ae = /* @__PURE__ */ k(
317
+ function Bt({ children: t, className: e, style: h, metrics: o, ...c }) {
318
+ const n = we(), i = Se(), d = qe(), b = et(t, o), M = tt(b).map((a) => ({ view: a, results: We(a) })), [A, U] = ie(() => /* @__PURE__ */ new Set()), [I, r] = ie(null), u = ke(null), [$, s] = ie(!1), l = (o == null ? void 0 : o.length) ?? 0, O = Me(() => {
319
+ const a = u.current, f = a && l > 0 ? getComputedStyle(a.firstElementChild).gridTemplateColumns.split(" ").map(parseFloat) : [], m = J(l) - 1;
320
+ if (!a || f.length <= m || f.some((k) => !Number.isFinite(k))) {
321
+ s(!1);
322
+ return;
323
+ }
324
+ const P = f.slice(2, m).reduce((k, W) => k + W, 0);
325
+ let v = 0;
326
+ const E = document.createRange();
327
+ for (const k of a.querySelectorAll(`.${p.label}`)) {
328
+ E.selectNodeContents(k);
329
+ const W = [...E.getClientRects()].reduce((D, B) => D + B.width, 0);
330
+ if (W === 0) continue;
331
+ const z = k.parentElement, G = k.getBoundingClientRect().left - z.getBoundingClientRect().left;
332
+ v = Math.max(v, G + W + parseFloat(getComputedStyle(z).paddingRight));
333
+ }
334
+ const j = parseFloat(getComputedStyle(document.documentElement).fontSize);
335
+ s(a.clientWidth - P < Math.min(v, Tt * j));
336
+ }, [l]);
337
+ Te(() => O()), Ee(() => {
338
+ const a = u.current;
339
+ if (!a || l === 0) return;
340
+ const f = new ResizeObserver(() => O());
341
+ return f.observe(a), () => f.disconnect();
342
+ }, [O, l]);
343
+ const S = (a) => U((f) => {
344
+ const m = new Set(f);
345
+ return m.delete(a) || m.add(a), m;
346
+ }), T = (a, f, m) => m === 0 || f.previous ? void 0 : { operator: a.operator, negated: f.negated === !0 };
347
+ let N = !1;
348
+ const C = (a, f) => a.map(({ own: m, text: P }, v) => [
349
+ /* @__PURE__ */ R(
350
+ "span",
351
+ {
352
+ className: p.amount,
353
+ "aria-hidden": "true",
354
+ "data-verdict": m.verdict,
355
+ "data-later": v > 0 ? "" : void 0,
356
+ style: o ? { "--column": J(v) } : void 0,
357
+ children: [
358
+ m.approximate && /* @__PURE__ */ g(je, { content: i.calculationApproximateNote, children: /* @__PURE__ */ g("span", { className: p.approximate, children: "≈" }) }),
359
+ P.amount
360
+ ]
361
+ },
362
+ `amount-${v}`
363
+ ),
364
+ /* @__PURE__ */ g(
365
+ "span",
366
+ {
367
+ className: p.unit,
368
+ "aria-hidden": "true",
369
+ style: o ? { "--column": Et(v) } : void 0,
370
+ "data-last": o && v === a.length - 1 ? "" : void 0,
371
+ children: o && !f ? void 0 : P.unit
372
+ },
373
+ `unit-${v}`
374
+ )
375
+ ]), _ = (a, f) => I === null ? void 0 : a === I ? "use" : f === I ? "operand" : void 0, y = (a, f, m, P) => {
376
+ const v = b.quantities.get(a), E = M.map(({ view: x, results: H }) => ({
377
+ own: H.get(a),
378
+ text: it(x, H, a, f, n, i, m.position)
379
+ })), { own: j, text: k } = E[0], W = v.operator !== void 0 && !f, z = a === b.result && !f, G = W && (v.interim ? m.flat : z), D = W && !G, B = D && A.has(a);
380
+ N || (N = D);
381
+ const X = `${d}-${a}`, L = { depth: G ? m.depth : m.depth + 1, flat: !1, parent: a }, Q = W ? v.operands.find((x) => x.previous) : void 0, K = Q && m.flat ? y(Q.key, !1, { ...m, parent: a, position: void 0 }, `${P}-c`) : [], se = Q && !m.flat ? y(Q.key, !1, { ...L, flat: !0 }, `${P}-c`) : [], fe = W ? v.operands.map(
382
+ (x, H) => x.previous ? null : y(x.key, x.reference, { ...L, position: T(v, x, H) }, `${P}-${H}`)
383
+ ) : [], Y = D && !B && j.worst !== void 0 && ae(j.worst) > ae(j.verdict ?? "ok") ? j.worst : void 0, F = f ? void 0 : v.given, xe = m.position ? oe(m.position, !1, i) : void 0, pe = [
384
+ !f && v.explanation !== void 0 && /* @__PURE__ */ g("span", { children: v.explanation }, "explanation"),
385
+ (F == null ? void 0 : F.source) !== void 0 && /* @__PURE__ */ g("span", { children: i.calculationSource(F.source) }, "source"),
386
+ (F == null ? void 0 : F.asOf) !== void 0 && (F.ages !== void 0 ? /* @__PURE__ */ g(It, { asOf: F.asOf, ages: F.ages }, "asOf") : /* @__PURE__ */ g("span", { children: i.asOfAgo(n.dateTime(new Date(F.asOf), !1)) }, "asOf")),
387
+ !f && v.aside !== void 0 && /* @__PURE__ */ g("span", { children: v.aside }, "aside")
388
+ ].filter(Boolean), me = z ? "result" : v.interim && !f && m.flat ? "interim" : void 0, he = /* @__PURE__ */ R(
291
389
  "div",
292
390
  {
293
391
  className: p.line,
294
- style: { "--depth": r.depth },
295
- "data-inner": r.depth > 0 ? "" : void 0,
296
- "data-kind": he,
297
- "data-foldable": I ? "" : void 0,
298
- "data-reference": l ? "" : void 0,
299
- "data-mark": T(a, r.parent),
300
- onPointerEnter: () => y(a),
301
- onPointerLeave: () => y(null),
302
- onFocus: () => y(a),
303
- onBlur: () => y(null),
304
- onClick: I ? () => {
305
- var P;
306
- (P = window.getSelection()) != null && P.toString() || c(a);
392
+ style: { "--depth": m.depth },
393
+ "data-inner": m.depth > 0 ? "" : void 0,
394
+ "data-kind": me,
395
+ "data-foldable": D ? "" : void 0,
396
+ "data-reference": f ? "" : void 0,
397
+ "data-mark": _(a, m.parent),
398
+ onPointerEnter: () => r(a),
399
+ onPointerLeave: () => r(null),
400
+ onFocus: () => r(a),
401
+ onBlur: () => r(null),
402
+ onClick: D ? () => {
403
+ var x;
404
+ (x = window.getSelection()) != null && x.toString() || S(a);
307
405
  } : void 0,
308
406
  children: [
309
- /* @__PURE__ */ f(_e, { children: [
310
- $.sentence,
311
- u.approximate && e.calculationApproximateNote,
312
- D !== void 0 && e.calculationWorstInside(H(D, e))
407
+ /* @__PURE__ */ g(Ae, { children: [
408
+ o ? rt(v.label, E.map((x) => x.text), o, i, m.position) : k.sentence,
409
+ E.some((x) => x.own.approximate) && i.calculationApproximateNote,
410
+ Y !== void 0 && i.calculationWorstInside(ne(Y, i))
313
411
  ].filter(Boolean).join(". ") }),
314
- /* @__PURE__ */ k("span", { className: p.labelCell, children: [
315
- I ? /* @__PURE__ */ f(
412
+ /* @__PURE__ */ R("span", { className: p.labelCell, children: [
413
+ D ? /* @__PURE__ */ g(
316
414
  "button",
317
415
  {
318
416
  type: "button",
319
417
  className: p.disclosure,
320
- "aria-expanded": E,
321
- "aria-controls": U,
322
- "aria-label": (E ? e.calculationHideDerivation : e.calculationShowDerivation)(s.label),
323
- children: /* @__PURE__ */ f(be, { "data-open": E ? "" : void 0 })
418
+ "aria-expanded": B,
419
+ "aria-controls": X,
420
+ "aria-label": (B ? i.calculationHideDerivation : i.calculationShowDerivation)(v.label),
421
+ children: /* @__PURE__ */ g(Ie, { "data-open": B ? "" : void 0 })
324
422
  }
325
- ) : /* @__PURE__ */ f("span", { className: p.disclosure, "aria-hidden": "true" }),
326
- /* @__PURE__ */ f("span", { className: p.label, "aria-hidden": "true", children: s.label })
327
- ] }),
328
- /* @__PURE__ */ f("span", { className: p.names, "aria-hidden": "true", children: I && !E ? $.names : void 0 }),
329
- /* @__PURE__ */ f("span", { className: p.operator, "aria-hidden": "true", children: J }),
330
- /* @__PURE__ */ k("span", { className: p.amount, "aria-hidden": "true", "data-verdict": u.verdict, children: [
331
- u.approximate && /* @__PURE__ */ f(re, { content: e.calculationApproximateNote, children: /* @__PURE__ */ f("span", { className: p.approximate, children: "≈" }) }),
332
- $.amount
423
+ ) : /* @__PURE__ */ g("span", { className: p.disclosure, "aria-hidden": "true" }),
424
+ /* @__PURE__ */ g("span", { className: p.label, "aria-hidden": "true", children: v.label })
333
425
  ] }),
334
- /* @__PURE__ */ f("span", { className: p.unit, "aria-hidden": "true", children: $.unit }),
335
- /* @__PURE__ */ k("span", { className: p.assessment, "aria-hidden": "true", children: [
336
- $.reason !== void 0 ? /* @__PURE__ */ f(ie, { children: $.reason }) : u.verdict !== void 0 && /* @__PURE__ */ f(ie, { tone: ut[u.verdict], children: H(u.verdict, e) }),
337
- $.target !== void 0 && /* @__PURE__ */ f("span", { className: p.target, children: $.target }),
338
- D !== void 0 && /* @__PURE__ */ f("span", { className: p.worst, "data-verdict": D, children: e.calculationWorstInside(H(D, e)) })
426
+ /* @__PURE__ */ g("span", { className: p.names, "aria-hidden": "true", children: D && !B ? k.names : void 0 }),
427
+ /* @__PURE__ */ g("span", { className: p.operator, "aria-hidden": "true", children: xe }),
428
+ C(E, me !== void 0),
429
+ /* @__PURE__ */ R("span", { className: p.assessment, "aria-hidden": "true", children: [
430
+ o ? (
431
+ /* Short: which metric. The sentence carries the full reason. */
432
+ o.map(
433
+ (x, H) => E[H].own.absence && /* @__PURE__ */ g(re, { children: i.calculationMissing(x.unit ?? x.label) }, x.id)
434
+ )
435
+ ) : k.reason !== void 0 ? /* @__PURE__ */ g(re, { children: k.reason }) : j.verdict !== void 0 && /* @__PURE__ */ g(re, { tone: Rt[j.verdict], children: ne(j.verdict, i) }),
436
+ k.target !== void 0 && /* @__PURE__ */ g("span", { className: p.target, children: k.target }),
437
+ Y !== void 0 && /* @__PURE__ */ g("span", { className: p.worst, "data-verdict": Y, children: i.calculationWorstInside(ne(Y, i)) })
339
438
  ] }),
340
- ne.length > 0 && /* A click here - on a link in the aside, on a sparkline - is the
439
+ pe.length > 0 && /* A click here - on a link in the aside, on a sparkline - is the
341
440
  caller's, not a fold. */
342
- /* @__PURE__ */ f("span", { className: p.notes, onClick: (P) => P.stopPropagation(), children: ne })
441
+ /* @__PURE__ */ g("span", { className: p.notes, onClick: (x) => x.stopPropagation(), children: pe })
343
442
  ]
344
443
  }
345
444
  );
346
- return W ? [
347
- ...L,
348
- /* @__PURE__ */ k("li", { className: p.item, children: [
349
- /* @__PURE__ */ f("ul", { className: p.list, children: M }),
350
- ae
351
- ] }, w)
445
+ return G ? [
446
+ ...K,
447
+ /* @__PURE__ */ R("li", { className: p.item, children: [
448
+ /* @__PURE__ */ g("ul", { className: p.list, children: fe }),
449
+ he
450
+ ] }, P)
352
451
  ] : [
353
- ...L,
354
- /* @__PURE__ */ k("li", { className: p.item, "data-open": E ? "" : void 0, style: { "--depth": r.depth }, children: [
355
- ae,
356
- I && /* @__PURE__ */ k("ul", { id: U, className: p.derivation, hidden: !E, children: [
357
- z,
358
- M,
359
- /* @__PURE__ */ f("li", { className: p.item, "aria-hidden": "true", children: /* @__PURE__ */ k(
452
+ ...K,
453
+ /* @__PURE__ */ R("li", { className: p.item, "data-open": B ? "" : void 0, style: { "--depth": m.depth }, children: [
454
+ he,
455
+ D && /* @__PURE__ */ R("ul", { id: X, className: p.derivation, hidden: !B, children: [
456
+ se,
457
+ fe,
458
+ /* @__PURE__ */ g("li", { className: p.item, "aria-hidden": "true", children: /* @__PURE__ */ R(
360
459
  "div",
361
460
  {
362
461
  className: p.line,
363
- style: { "--depth": F.depth },
462
+ style: { "--depth": L.depth },
364
463
  "data-inner": "",
365
464
  "data-closing": "",
366
- "data-mark": g === a ? "use" : void 0,
465
+ "data-mark": I === a ? "use" : void 0,
367
466
  children: [
368
- /* @__PURE__ */ k("span", { className: p.labelCell, children: [
369
- /* @__PURE__ */ f("span", { className: p.disclosure }),
370
- /* @__PURE__ */ k("span", { className: p.label, children: [
467
+ /* @__PURE__ */ R("span", { className: p.labelCell, children: [
468
+ /* @__PURE__ */ g("span", { className: p.disclosure }),
469
+ /* @__PURE__ */ R("span", { className: p.label, children: [
371
470
  "= ",
372
- s.label
471
+ v.label
373
472
  ] })
374
473
  ] }),
375
- /* @__PURE__ */ f("span", { className: p.names }),
376
- /* @__PURE__ */ f("span", { className: p.operator }),
377
- /* @__PURE__ */ k("span", { className: p.amount, "data-verdict": u.verdict, children: [
378
- u.approximate && /* @__PURE__ */ f(re, { content: e.calculationApproximateNote, children: /* @__PURE__ */ f("span", { className: p.approximate, children: "≈" }) }),
379
- $.amount
380
- ] }),
381
- /* @__PURE__ */ f("span", { className: p.unit, children: $.unit })
474
+ /* @__PURE__ */ g("span", { className: p.names }),
475
+ /* @__PURE__ */ g("span", { className: p.operator }),
476
+ C(E, !0)
382
477
  ]
383
478
  }
384
479
  ) })
385
480
  ] })
386
- ] }, w)
481
+ ] }, P)
387
482
  ];
388
- }, O = b(o.result, !1, { depth: 0, flat: !0, parent: null }, "r");
483
+ }, q = y(b.result, !1, { depth: 0, flat: !0, parent: null }, "r");
389
484
  return (
390
485
  /* The frame is the surface and the container the layout measures itself
391
486
  against; the list inside it is the statement. */
392
- /* @__PURE__ */ f("div", { className: dt(p.frame, n), style: v, "data-still": x ? void 0 : "", children: /* @__PURE__ */ f("ul", { className: p.calculation, ...m, children: O }) })
487
+ /* @__PURE__ */ g(
488
+ "div",
489
+ {
490
+ ref: u,
491
+ className: At(p.frame, e),
492
+ style: o ? {
493
+ "--figure-tracks": Array(l * 2).fill("auto").join(" "),
494
+ "--figures-end": J(l),
495
+ "--assessment-column": J(l),
496
+ ...h
497
+ } : h,
498
+ "data-still": N ? void 0 : "",
499
+ "data-metrics": o ? l : void 0,
500
+ "data-two-lines": $ ? "" : void 0,
501
+ children: /* @__PURE__ */ R("ul", { className: p.calculation, ...c, children: [
502
+ o && /* The head names each metric and its unit above its column. Every
503
+ row's sentence names them too, so the head is for the eye. */
504
+ /* @__PURE__ */ g("li", { className: p.item, "aria-hidden": "true", children: /* @__PURE__ */ g("div", { className: p.head, children: o.map((a, f) => /* @__PURE__ */ R(
505
+ "span",
506
+ {
507
+ className: p.headCell,
508
+ "data-unit": a.unit === void 0 ? void 0 : "",
509
+ style: { "--column": J(f) },
510
+ children: [
511
+ /* @__PURE__ */ g("span", { className: p.headLabel, children: a.label }),
512
+ a.unit !== void 0 && /* @__PURE__ */ g("span", { className: p.headUnit, children: a.unit })
513
+ ]
514
+ },
515
+ a.id
516
+ )) }) }),
517
+ q
518
+ ] })
519
+ }
520
+ )
393
521
  );
394
522
  }
395
523
  export {
396
- vt as Calculation,
397
- Ie as Chain,
398
- ke as Difference,
399
- Ee as DividedBy,
400
- qe as Given,
401
- Y as Interim,
402
- Pe as Minus,
403
- Me as Plus,
404
- Ce as Product,
405
- Ae as Quotient,
406
- ue as Ref,
407
- Te as Sum,
408
- De as Times
524
+ Bt as Calculation,
525
+ Ge as Chain,
526
+ Qe as Difference,
527
+ Je as DividedBy,
528
+ Fe as Given,
529
+ ce as Interim,
530
+ Ke as Minus,
531
+ He as Plus,
532
+ Ve as Product,
533
+ ze as Quotient,
534
+ be as Ref,
535
+ Ue as Sum,
536
+ Ye as Times
409
537
  };