vizmatic 0.1.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/LICENSE +21 -0
- package/PROMPT.md +500 -0
- package/README.md +530 -0
- package/dist/chunk-ADU7JROD.js +627 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +303 -0
- package/dist/index.d.ts +1433 -0
- package/dist/index.js +4702 -0
- package/docs/PROMPT.md +500 -0
- package/docs/assets/examples/.gitkeep +1 -0
- package/docs/assets/examples/agent-pipeline_dark.png +0 -0
- package/docs/assets/examples/agent-pipeline_light.png +0 -0
- package/docs/assets/examples/animated-pipeline_dark.gif +0 -0
- package/docs/assets/examples/animated-pipeline_dark.png +0 -0
- package/docs/assets/examples/animated-pipeline_light.gif +0 -0
- package/docs/assets/examples/animated-pipeline_light.png +0 -0
- package/docs/assets/examples/attention-head_dark.png +0 -0
- package/docs/assets/examples/attention-head_light.png +0 -0
- package/docs/assets/examples/embedding-map_dark.png +0 -0
- package/docs/assets/examples/embedding-map_light.png +0 -0
- package/docs/assets/examples/eval-dashboard_dark.png +0 -0
- package/docs/assets/examples/eval-dashboard_light.png +0 -0
- package/docs/assets/examples/gif-manifest.json +12 -0
- package/docs/assets/examples/manifest.json +108 -0
- package/docs/assets/examples/model-router_dark.png +0 -0
- package/docs/assets/examples/model-router_light.png +0 -0
- package/docs/assets/examples/presentation-frame_dark.png +0 -0
- package/docs/assets/examples/presentation-frame_light.png +0 -0
- package/docs/assets/examples/rag-graph_dark.png +0 -0
- package/docs/assets/examples/rag-graph_light.png +0 -0
- package/docs/assets/examples/release-card_dark.png +0 -0
- package/docs/assets/examples/release-card_light.png +0 -0
- package/docs/assets/examples/research-landscape_dark.png +0 -0
- package/docs/assets/examples/research-landscape_light.png +0 -0
- package/docs/assets/examples/sources.json +93 -0
- package/docs/assets/examples/spec-anatomy_dark.png +0 -0
- package/docs/assets/examples/spec-anatomy_light.png +0 -0
- package/docs/assets/examples/theme-system_dark.png +0 -0
- package/docs/assets/examples/theme-system_light.png +0 -0
- package/docs/assets/examples/token-matrix_dark.png +0 -0
- package/docs/assets/examples/token-matrix_light.png +0 -0
- package/docs/assets/icon.svg +16 -0
- package/docs/assets/logo.svg +30 -0
- package/examples/agent-pipeline.tsx +27 -0
- package/examples/animated-pipeline.tsx +72 -0
- package/examples/attention-head.tsx +27 -0
- package/examples/embedding-map.tsx +34 -0
- package/examples/eval-dashboard.tsx +44 -0
- package/examples/model-router.tsx +35 -0
- package/examples/presentation-frame.tsx +32 -0
- package/examples/rag-graph.tsx +36 -0
- package/examples/release-card.tsx +39 -0
- package/examples/research-landscape.tsx +34 -0
- package/examples/spec-anatomy.tsx +44 -0
- package/examples/theme-system.tsx +30 -0
- package/examples/token-matrix.tsx +49 -0
- package/package.json +84 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4702 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cropPixels,
|
|
3
|
+
detectBackgroundColor,
|
|
4
|
+
detectContentBounds,
|
|
5
|
+
detectOverflow,
|
|
6
|
+
getFonts,
|
|
7
|
+
loadAdditionalAsset,
|
|
8
|
+
normalizeWatermark,
|
|
9
|
+
renderAnimatedGif,
|
|
10
|
+
renderToBuffer,
|
|
11
|
+
renderToPng,
|
|
12
|
+
renderToSvg,
|
|
13
|
+
wrapWithBrand,
|
|
14
|
+
wrapWithWatermark
|
|
15
|
+
} from "./chunk-ADU7JROD.js";
|
|
16
|
+
|
|
17
|
+
// src/theme.ts
|
|
18
|
+
var darkColors = {
|
|
19
|
+
// Canvas backgrounds
|
|
20
|
+
bg: "#151620",
|
|
21
|
+
bgCard: "#1a1b26",
|
|
22
|
+
bgCardAlt: "#1e2030",
|
|
23
|
+
bgHover: "#24253a",
|
|
24
|
+
bgSubtle: "#151620",
|
|
25
|
+
// Brand / semantic colors (matches Mermaid palette)
|
|
26
|
+
primary: "#7c3aed",
|
|
27
|
+
// Purple — key/highlighted components
|
|
28
|
+
primaryLight: "#a78bfa",
|
|
29
|
+
primaryDark: "#6d28d9",
|
|
30
|
+
secondary: "#2563eb",
|
|
31
|
+
// Blue — supporting elements
|
|
32
|
+
secondaryLight: "#60a5fa",
|
|
33
|
+
secondaryDark: "#1d4ed8",
|
|
34
|
+
positive: "#059669",
|
|
35
|
+
// Green — output/success
|
|
36
|
+
positiveLight: "#34d399",
|
|
37
|
+
positiveDark: "#047857",
|
|
38
|
+
warning: "#d97706",
|
|
39
|
+
// Amber — warnings
|
|
40
|
+
warningLight: "#fbbf24",
|
|
41
|
+
warningDark: "#b45309",
|
|
42
|
+
critical: "#dc2626",
|
|
43
|
+
// Red — errors/bottlenecks
|
|
44
|
+
criticalLight: "#f87171",
|
|
45
|
+
criticalDark: "#b91c1c",
|
|
46
|
+
info: "#06b6d4",
|
|
47
|
+
// Cyan — informational
|
|
48
|
+
infoLight: "#22d3ee",
|
|
49
|
+
infoDark: "#0891b2",
|
|
50
|
+
accent: "#f472b6",
|
|
51
|
+
// Pink — accents
|
|
52
|
+
accentLight: "#f9a8d4",
|
|
53
|
+
neutral: "#334155",
|
|
54
|
+
// Slate — infrastructure/background
|
|
55
|
+
neutralLight: "#475569",
|
|
56
|
+
neutralDark: "#1e293b",
|
|
57
|
+
// Text
|
|
58
|
+
textPrimary: "#f1f5f9",
|
|
59
|
+
textSecondary: "#94a3b8",
|
|
60
|
+
textMuted: "#64748b",
|
|
61
|
+
textOnColor: "#ffffff",
|
|
62
|
+
// Borders
|
|
63
|
+
border: "#334155",
|
|
64
|
+
borderSubtle: "#1e293b",
|
|
65
|
+
borderLight: "#475569",
|
|
66
|
+
shadow: "rgba(0, 0, 0, 0.24)"
|
|
67
|
+
};
|
|
68
|
+
var lightColors = {
|
|
69
|
+
// Canvas backgrounds
|
|
70
|
+
bg: "#f5f7fa",
|
|
71
|
+
bgCard: "#f8fafc",
|
|
72
|
+
bgCardAlt: "#f1f5f9",
|
|
73
|
+
bgHover: "#e2e8f0",
|
|
74
|
+
bgSubtle: "#f5f7fa",
|
|
75
|
+
// Brand / semantic colors (same hues, adjusted for light bg)
|
|
76
|
+
primary: "#7c3aed",
|
|
77
|
+
primaryLight: "#8b5cf6",
|
|
78
|
+
primaryDark: "#6d28d9",
|
|
79
|
+
secondary: "#2563eb",
|
|
80
|
+
secondaryLight: "#3b82f6",
|
|
81
|
+
secondaryDark: "#1d4ed8",
|
|
82
|
+
positive: "#059669",
|
|
83
|
+
positiveLight: "#10b981",
|
|
84
|
+
positiveDark: "#047857",
|
|
85
|
+
warning: "#d97706",
|
|
86
|
+
warningLight: "#f59e0b",
|
|
87
|
+
warningDark: "#b45309",
|
|
88
|
+
critical: "#dc2626",
|
|
89
|
+
criticalLight: "#ef4444",
|
|
90
|
+
criticalDark: "#b91c1c",
|
|
91
|
+
info: "#0891b2",
|
|
92
|
+
infoLight: "#06b6d4",
|
|
93
|
+
infoDark: "#0e7490",
|
|
94
|
+
accent: "#ec4899",
|
|
95
|
+
accentLight: "#f472b6",
|
|
96
|
+
neutral: "#cbd5e1",
|
|
97
|
+
neutralLight: "#94a3b8",
|
|
98
|
+
neutralDark: "#e2e8f0",
|
|
99
|
+
// Text
|
|
100
|
+
textPrimary: "#0f172a",
|
|
101
|
+
textSecondary: "#475569",
|
|
102
|
+
textMuted: "#94a3b8",
|
|
103
|
+
textOnColor: "#ffffff",
|
|
104
|
+
// Borders
|
|
105
|
+
border: "#e2e8f0",
|
|
106
|
+
borderSubtle: "#e2e8f0",
|
|
107
|
+
borderLight: "#cbd5e1",
|
|
108
|
+
shadow: "rgba(15, 23, 42, 0.12)"
|
|
109
|
+
};
|
|
110
|
+
function getThemeColors(mode) {
|
|
111
|
+
return mode === "light" ? lightColors : darkColors;
|
|
112
|
+
}
|
|
113
|
+
var colors = darkColors;
|
|
114
|
+
var gradients = {
|
|
115
|
+
purple: "linear-gradient(135deg, #7c3aed, #a855f7)",
|
|
116
|
+
blue: "linear-gradient(135deg, #2563eb, #60a5fa)",
|
|
117
|
+
green: "linear-gradient(135deg, #059669, #34d399)",
|
|
118
|
+
warm: "linear-gradient(135deg, #f59e0b, #ef4444)",
|
|
119
|
+
cyan: "linear-gradient(135deg, #06b6d4, #22d3ee)",
|
|
120
|
+
pink: "linear-gradient(135deg, #ec4899, #f472b6)",
|
|
121
|
+
sunset: "linear-gradient(135deg, #f97316, #db2777)",
|
|
122
|
+
ocean: "linear-gradient(135deg, #0284c7, #7c3aed)",
|
|
123
|
+
dark: "linear-gradient(180deg, #0f1117, #1a1b26)"
|
|
124
|
+
};
|
|
125
|
+
var toneGradients = {
|
|
126
|
+
blue: gradients.blue,
|
|
127
|
+
purple: gradients.purple,
|
|
128
|
+
green: gradients.green,
|
|
129
|
+
warm: gradients.warm,
|
|
130
|
+
cyan: gradients.cyan,
|
|
131
|
+
pink: gradients.pink,
|
|
132
|
+
red: gradients.warm,
|
|
133
|
+
critical: gradients.warm,
|
|
134
|
+
neutral: gradients.dark,
|
|
135
|
+
sunset: gradients.sunset,
|
|
136
|
+
ocean: gradients.ocean,
|
|
137
|
+
dark: gradients.dark
|
|
138
|
+
};
|
|
139
|
+
function getToneGradient(tone) {
|
|
140
|
+
return toneGradients[tone];
|
|
141
|
+
}
|
|
142
|
+
function getToneColor(tone, c) {
|
|
143
|
+
return {
|
|
144
|
+
blue: c.secondaryLight,
|
|
145
|
+
purple: c.primaryLight,
|
|
146
|
+
green: c.positiveLight,
|
|
147
|
+
warm: c.warningLight,
|
|
148
|
+
cyan: c.infoLight,
|
|
149
|
+
pink: c.accentLight,
|
|
150
|
+
red: c.criticalLight,
|
|
151
|
+
critical: c.criticalLight,
|
|
152
|
+
neutral: c.textSecondary,
|
|
153
|
+
sunset: c.warningLight,
|
|
154
|
+
ocean: c.infoLight,
|
|
155
|
+
dark: c.textSecondary
|
|
156
|
+
}[tone];
|
|
157
|
+
}
|
|
158
|
+
var typography = {
|
|
159
|
+
title: { fontSize: 28, fontWeight: 700, fontFamily: "Inter" },
|
|
160
|
+
subtitle: { fontSize: 20, fontWeight: 600, fontFamily: "Inter" },
|
|
161
|
+
label: { fontSize: 16, fontWeight: 600, fontFamily: "Inter" },
|
|
162
|
+
body: { fontSize: 14, fontWeight: 400, fontFamily: "Inter" },
|
|
163
|
+
small: { fontSize: 12, fontWeight: 500, fontFamily: "Inter" },
|
|
164
|
+
tiny: { fontSize: 10, fontWeight: 500, fontFamily: "Inter" },
|
|
165
|
+
code: { fontSize: 13, fontWeight: 400, fontFamily: "JetBrains Mono" },
|
|
166
|
+
annotation: { fontSize: 12, fontWeight: 500, fontFamily: "Inter", fontStyle: "italic" }
|
|
167
|
+
};
|
|
168
|
+
var canvas = {
|
|
169
|
+
standard: { width: 800, height: 500 },
|
|
170
|
+
wide: { width: 1e3, height: 400 },
|
|
171
|
+
square: { width: 600, height: 600 },
|
|
172
|
+
tall: { width: 600, height: 800 }
|
|
173
|
+
};
|
|
174
|
+
function getStyles(c) {
|
|
175
|
+
return {
|
|
176
|
+
canvas: {
|
|
177
|
+
width: "100%",
|
|
178
|
+
height: "100%",
|
|
179
|
+
display: "flex",
|
|
180
|
+
flexDirection: "column",
|
|
181
|
+
backgroundColor: c.bg,
|
|
182
|
+
fontFamily: "Inter",
|
|
183
|
+
padding: 40
|
|
184
|
+
},
|
|
185
|
+
card: {
|
|
186
|
+
display: "flex",
|
|
187
|
+
flexDirection: "column",
|
|
188
|
+
backgroundColor: c.bgCard,
|
|
189
|
+
borderRadius: 8,
|
|
190
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
191
|
+
padding: 20
|
|
192
|
+
},
|
|
193
|
+
pill: {
|
|
194
|
+
display: "flex",
|
|
195
|
+
alignItems: "center",
|
|
196
|
+
justifyContent: "center",
|
|
197
|
+
borderRadius: 999,
|
|
198
|
+
padding: "6px 16px",
|
|
199
|
+
fontSize: 13,
|
|
200
|
+
fontWeight: 600,
|
|
201
|
+
fontFamily: "Inter"
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
var styles = {
|
|
206
|
+
canvas: {
|
|
207
|
+
width: "100%",
|
|
208
|
+
height: "100%",
|
|
209
|
+
display: "flex",
|
|
210
|
+
flexDirection: "column",
|
|
211
|
+
backgroundColor: colors.bg,
|
|
212
|
+
fontFamily: "Inter",
|
|
213
|
+
padding: 40
|
|
214
|
+
},
|
|
215
|
+
card: {
|
|
216
|
+
display: "flex",
|
|
217
|
+
flexDirection: "column",
|
|
218
|
+
backgroundColor: colors.bgCard,
|
|
219
|
+
borderRadius: 8,
|
|
220
|
+
border: `1px solid ${colors.borderSubtle}`,
|
|
221
|
+
padding: 20
|
|
222
|
+
},
|
|
223
|
+
pill: {
|
|
224
|
+
display: "flex",
|
|
225
|
+
alignItems: "center",
|
|
226
|
+
justifyContent: "center",
|
|
227
|
+
borderRadius: 999,
|
|
228
|
+
padding: "6px 16px",
|
|
229
|
+
fontSize: 13,
|
|
230
|
+
fontWeight: 600,
|
|
231
|
+
fontFamily: "Inter"
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function getColor(name, c) {
|
|
235
|
+
if (c) return c[name];
|
|
236
|
+
return colors[name];
|
|
237
|
+
}
|
|
238
|
+
function getGradient(name) {
|
|
239
|
+
const map = {
|
|
240
|
+
primary: gradients.purple,
|
|
241
|
+
secondary: gradients.blue,
|
|
242
|
+
positive: gradients.green,
|
|
243
|
+
warning: gradients.warm,
|
|
244
|
+
critical: gradients.warm,
|
|
245
|
+
info: gradients.cyan,
|
|
246
|
+
accent: gradients.pink,
|
|
247
|
+
neutral: gradients.dark
|
|
248
|
+
};
|
|
249
|
+
return map[name];
|
|
250
|
+
}
|
|
251
|
+
function heatColor(value) {
|
|
252
|
+
const v = Math.max(0, Math.min(1, value));
|
|
253
|
+
if (v < 0.25) {
|
|
254
|
+
const t = v / 0.25;
|
|
255
|
+
return lerpColor("#1e293b", "#0891b2", t);
|
|
256
|
+
} else if (v < 0.5) {
|
|
257
|
+
const t = (v - 0.25) / 0.25;
|
|
258
|
+
return lerpColor("#0891b2", "#059669", t);
|
|
259
|
+
} else if (v < 0.75) {
|
|
260
|
+
const t = (v - 0.5) / 0.25;
|
|
261
|
+
return lerpColor("#059669", "#d97706", t);
|
|
262
|
+
} else {
|
|
263
|
+
const t = (v - 0.75) / 0.25;
|
|
264
|
+
return lerpColor("#d97706", "#dc2626", t);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function lerpColor(a, b, t) {
|
|
268
|
+
const ah = parseInt(a.slice(1), 16);
|
|
269
|
+
const bh = parseInt(b.slice(1), 16);
|
|
270
|
+
const ar = ah >> 16 & 255, ag = ah >> 8 & 255, ab = ah & 255;
|
|
271
|
+
const br = bh >> 16 & 255, bg = bh >> 8 & 255, bb = bh & 255;
|
|
272
|
+
const rr = Math.round(ar + (br - ar) * t);
|
|
273
|
+
const rg = Math.round(ag + (bg - ag) * t);
|
|
274
|
+
const rb = Math.round(ab + (bb - ab) * t);
|
|
275
|
+
return `#${(rr << 16 | rg << 8 | rb).toString(16).padStart(6, "0")}`;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// src/primitives.ts
|
|
279
|
+
import React from "react";
|
|
280
|
+
function defineIllustration(build, defaultTheme = "dark") {
|
|
281
|
+
return {
|
|
282
|
+
create(theme) {
|
|
283
|
+
return build(getThemeColors(theme));
|
|
284
|
+
},
|
|
285
|
+
default: build(getThemeColors(defaultTheme))
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function Canvas({ children, c, padding = 40, justify = "center", background }) {
|
|
289
|
+
return React.createElement("div", {
|
|
290
|
+
style: {
|
|
291
|
+
width: "100%",
|
|
292
|
+
height: "100%",
|
|
293
|
+
boxSizing: "border-box",
|
|
294
|
+
display: "flex",
|
|
295
|
+
flexDirection: "column",
|
|
296
|
+
alignItems: "center",
|
|
297
|
+
justifyContent: justify,
|
|
298
|
+
backgroundColor: background ?? c.bg,
|
|
299
|
+
fontFamily: "Inter",
|
|
300
|
+
padding
|
|
301
|
+
}
|
|
302
|
+
}, children);
|
|
303
|
+
}
|
|
304
|
+
function TitleBar({ title, subtitle, c }) {
|
|
305
|
+
return React.createElement(
|
|
306
|
+
"div",
|
|
307
|
+
{
|
|
308
|
+
style: {
|
|
309
|
+
display: "flex",
|
|
310
|
+
flexDirection: "column",
|
|
311
|
+
alignItems: "center",
|
|
312
|
+
gap: 6,
|
|
313
|
+
marginBottom: 24
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
React.createElement("div", {
|
|
317
|
+
style: {
|
|
318
|
+
...typography.title,
|
|
319
|
+
color: c.textPrimary
|
|
320
|
+
}
|
|
321
|
+
}, title),
|
|
322
|
+
subtitle && React.createElement("div", {
|
|
323
|
+
style: {
|
|
324
|
+
...typography.body,
|
|
325
|
+
color: c.textSecondary,
|
|
326
|
+
fontFamily: "JetBrains Mono"
|
|
327
|
+
}
|
|
328
|
+
}, subtitle)
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
function flexAlign(align) {
|
|
332
|
+
return {
|
|
333
|
+
start: "flex-start",
|
|
334
|
+
center: "center",
|
|
335
|
+
end: "flex-end",
|
|
336
|
+
stretch: "stretch"
|
|
337
|
+
}[align];
|
|
338
|
+
}
|
|
339
|
+
function flexJustify(justify) {
|
|
340
|
+
return {
|
|
341
|
+
start: "flex-start",
|
|
342
|
+
center: "center",
|
|
343
|
+
end: "flex-end",
|
|
344
|
+
"space-between": "space-between",
|
|
345
|
+
"space-around": "space-around"
|
|
346
|
+
}[justify];
|
|
347
|
+
}
|
|
348
|
+
function textFitStyle(align = "left") {
|
|
349
|
+
return {
|
|
350
|
+
minWidth: 0,
|
|
351
|
+
maxWidth: "100%",
|
|
352
|
+
whiteSpace: "normal",
|
|
353
|
+
overflowWrap: "break-word",
|
|
354
|
+
textAlign: align
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function compactChildren(children) {
|
|
358
|
+
return children.filter((child) => child !== void 0 && child !== null && child !== false);
|
|
359
|
+
}
|
|
360
|
+
function Scene({
|
|
361
|
+
c,
|
|
362
|
+
children,
|
|
363
|
+
title,
|
|
364
|
+
subtitle,
|
|
365
|
+
padding = 40,
|
|
366
|
+
gap = 24,
|
|
367
|
+
justify = "flex-start",
|
|
368
|
+
align = "stretch",
|
|
369
|
+
contentWidth = "100%",
|
|
370
|
+
background,
|
|
371
|
+
contentStyle
|
|
372
|
+
}) {
|
|
373
|
+
return React.createElement(
|
|
374
|
+
Canvas,
|
|
375
|
+
{ c, padding, justify, background },
|
|
376
|
+
...compactChildren([
|
|
377
|
+
title && React.createElement(TitleBar, { c, title, subtitle }),
|
|
378
|
+
React.createElement("div", {
|
|
379
|
+
style: {
|
|
380
|
+
width: contentWidth,
|
|
381
|
+
display: "flex",
|
|
382
|
+
flexDirection: "column",
|
|
383
|
+
alignItems: flexAlign(align),
|
|
384
|
+
gap,
|
|
385
|
+
...contentStyle
|
|
386
|
+
}
|
|
387
|
+
}, children)
|
|
388
|
+
])
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
function flexBox(direction, {
|
|
392
|
+
children,
|
|
393
|
+
gap = 12,
|
|
394
|
+
align = "center",
|
|
395
|
+
justify = "center",
|
|
396
|
+
wrap = false,
|
|
397
|
+
width,
|
|
398
|
+
height,
|
|
399
|
+
style
|
|
400
|
+
}) {
|
|
401
|
+
return React.createElement("div", {
|
|
402
|
+
style: {
|
|
403
|
+
display: "flex",
|
|
404
|
+
flexDirection: direction,
|
|
405
|
+
alignItems: flexAlign(align),
|
|
406
|
+
justifyContent: flexJustify(justify),
|
|
407
|
+
gap,
|
|
408
|
+
...wrap ? { flexWrap: "wrap" } : {},
|
|
409
|
+
...width != null ? { width } : {},
|
|
410
|
+
...height != null ? { height } : {},
|
|
411
|
+
...style
|
|
412
|
+
}
|
|
413
|
+
}, children);
|
|
414
|
+
}
|
|
415
|
+
function Row(props) {
|
|
416
|
+
return flexBox("row", props);
|
|
417
|
+
}
|
|
418
|
+
function Column(props) {
|
|
419
|
+
return flexBox("column", props);
|
|
420
|
+
}
|
|
421
|
+
function ToneStrip({ tone, width = 34, height = 4 }) {
|
|
422
|
+
return React.createElement("span", {
|
|
423
|
+
style: {
|
|
424
|
+
display: "flex",
|
|
425
|
+
width,
|
|
426
|
+
height,
|
|
427
|
+
borderRadius: 999,
|
|
428
|
+
backgroundImage: getToneGradient(tone),
|
|
429
|
+
flexShrink: 0
|
|
430
|
+
}
|
|
431
|
+
}, "");
|
|
432
|
+
}
|
|
433
|
+
function Panel({
|
|
434
|
+
title,
|
|
435
|
+
c,
|
|
436
|
+
children,
|
|
437
|
+
subtitle,
|
|
438
|
+
tone = "blue",
|
|
439
|
+
footer,
|
|
440
|
+
width,
|
|
441
|
+
minWidth,
|
|
442
|
+
height,
|
|
443
|
+
minHeight,
|
|
444
|
+
padding = 14,
|
|
445
|
+
radius = 8,
|
|
446
|
+
gap = 10,
|
|
447
|
+
align = "stretch",
|
|
448
|
+
justify = "start",
|
|
449
|
+
shadow = true,
|
|
450
|
+
background,
|
|
451
|
+
borderColor,
|
|
452
|
+
titleFontSize,
|
|
453
|
+
accentWidth = 34,
|
|
454
|
+
accentHeight = 4,
|
|
455
|
+
bodyStyle
|
|
456
|
+
}) {
|
|
457
|
+
return React.createElement(
|
|
458
|
+
"div",
|
|
459
|
+
{
|
|
460
|
+
style: {
|
|
461
|
+
display: "flex",
|
|
462
|
+
flexDirection: "column",
|
|
463
|
+
alignItems: flexAlign(align),
|
|
464
|
+
justifyContent: flexJustify(justify),
|
|
465
|
+
gap,
|
|
466
|
+
...width != null ? { width } : {},
|
|
467
|
+
...minWidth != null ? { minWidth } : {},
|
|
468
|
+
...height != null ? { height } : {},
|
|
469
|
+
...minHeight != null ? { minHeight } : {},
|
|
470
|
+
padding,
|
|
471
|
+
borderRadius: radius,
|
|
472
|
+
border: `1px solid ${borderColor ?? c.borderSubtle}`,
|
|
473
|
+
backgroundColor: background ?? c.bgCard,
|
|
474
|
+
...shadow ? { boxShadow: `0 9px 24px ${c.shadow}` } : {}
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
...compactChildren([
|
|
478
|
+
React.createElement(
|
|
479
|
+
"div",
|
|
480
|
+
{
|
|
481
|
+
style: {
|
|
482
|
+
width: "100%",
|
|
483
|
+
display: "flex",
|
|
484
|
+
flexDirection: "column",
|
|
485
|
+
gap: subtitle ? 5 : 0
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
...compactChildren([
|
|
489
|
+
React.createElement(
|
|
490
|
+
"div",
|
|
491
|
+
{
|
|
492
|
+
style: {
|
|
493
|
+
display: "flex",
|
|
494
|
+
alignItems: "center",
|
|
495
|
+
gap: 8,
|
|
496
|
+
color: c.textPrimary,
|
|
497
|
+
...typography.small,
|
|
498
|
+
...textFitStyle(),
|
|
499
|
+
fontSize: titleFontSize ?? typography.small.fontSize,
|
|
500
|
+
fontWeight: 900,
|
|
501
|
+
lineHeight: 1.2
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
ToneStrip({ tone, width: accentWidth, height: accentHeight }),
|
|
505
|
+
title
|
|
506
|
+
),
|
|
507
|
+
subtitle && React.createElement("div", {
|
|
508
|
+
style: {
|
|
509
|
+
display: "flex",
|
|
510
|
+
color: c.textSecondary,
|
|
511
|
+
...typography.tiny,
|
|
512
|
+
...textFitStyle(),
|
|
513
|
+
lineHeight: 1.35
|
|
514
|
+
}
|
|
515
|
+
}, subtitle)
|
|
516
|
+
])
|
|
517
|
+
),
|
|
518
|
+
React.createElement("div", {
|
|
519
|
+
style: {
|
|
520
|
+
width: "100%",
|
|
521
|
+
display: "flex",
|
|
522
|
+
flexDirection: "column",
|
|
523
|
+
...bodyStyle
|
|
524
|
+
}
|
|
525
|
+
}, children),
|
|
526
|
+
footer && React.createElement("div", {
|
|
527
|
+
style: {
|
|
528
|
+
width: "100%",
|
|
529
|
+
display: "flex",
|
|
530
|
+
color: c.textMuted,
|
|
531
|
+
...typography.tiny,
|
|
532
|
+
...textFitStyle()
|
|
533
|
+
}
|
|
534
|
+
}, footer)
|
|
535
|
+
])
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
function readScriptValue(text, start) {
|
|
539
|
+
if (text[start] === "{") {
|
|
540
|
+
const end = text.indexOf("}", start + 1);
|
|
541
|
+
if (end !== -1) return { value: text.slice(start + 1, end), next: end + 1 };
|
|
542
|
+
}
|
|
543
|
+
let next = start;
|
|
544
|
+
while (next < text.length && /[A-Za-z0-9+\-]/.test(text[next])) next += 1;
|
|
545
|
+
if (next === start) next += 1;
|
|
546
|
+
return { value: text.slice(start, next), next };
|
|
547
|
+
}
|
|
548
|
+
function parseMathText(text) {
|
|
549
|
+
const parts = [];
|
|
550
|
+
let buffer = "";
|
|
551
|
+
let index = 0;
|
|
552
|
+
while (index < text.length) {
|
|
553
|
+
const char = text[index];
|
|
554
|
+
if ((char === "_" || char === "^") && index + 1 < text.length) {
|
|
555
|
+
if (buffer) {
|
|
556
|
+
parts.push({ kind: "text", value: buffer });
|
|
557
|
+
buffer = "";
|
|
558
|
+
}
|
|
559
|
+
const script = readScriptValue(text, index + 1);
|
|
560
|
+
parts.push({ kind: char === "_" ? "sub" : "sup", value: script.value });
|
|
561
|
+
index = script.next;
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
buffer += char;
|
|
565
|
+
index += 1;
|
|
566
|
+
}
|
|
567
|
+
if (buffer) parts.push({ kind: "text", value: buffer });
|
|
568
|
+
return parts;
|
|
569
|
+
}
|
|
570
|
+
var subscriptChars = {
|
|
571
|
+
"0": "\u2080",
|
|
572
|
+
"1": "\u2081",
|
|
573
|
+
"2": "\u2082",
|
|
574
|
+
"3": "\u2083",
|
|
575
|
+
"4": "\u2084",
|
|
576
|
+
"5": "\u2085",
|
|
577
|
+
"6": "\u2086",
|
|
578
|
+
"7": "\u2087",
|
|
579
|
+
"8": "\u2088",
|
|
580
|
+
"9": "\u2089",
|
|
581
|
+
"+": "\u208A",
|
|
582
|
+
"-": "\u208B",
|
|
583
|
+
"=": "\u208C",
|
|
584
|
+
"(": "\u208D",
|
|
585
|
+
")": "\u208E",
|
|
586
|
+
a: "\u2090",
|
|
587
|
+
e: "\u2091",
|
|
588
|
+
h: "\u2095",
|
|
589
|
+
i: "\u1D62",
|
|
590
|
+
j: "\u2C7C",
|
|
591
|
+
k: "\u2096",
|
|
592
|
+
l: "\u2097",
|
|
593
|
+
m: "\u2098",
|
|
594
|
+
n: "\u2099",
|
|
595
|
+
o: "\u2092",
|
|
596
|
+
p: "\u209A",
|
|
597
|
+
r: "\u1D63",
|
|
598
|
+
s: "\u209B",
|
|
599
|
+
t: "\u209C",
|
|
600
|
+
u: "\u1D64",
|
|
601
|
+
v: "\u1D65",
|
|
602
|
+
x: "\u2093"
|
|
603
|
+
};
|
|
604
|
+
var superscriptChars = {
|
|
605
|
+
"0": "\u2070",
|
|
606
|
+
"1": "\xB9",
|
|
607
|
+
"2": "\xB2",
|
|
608
|
+
"3": "\xB3",
|
|
609
|
+
"4": "\u2074",
|
|
610
|
+
"5": "\u2075",
|
|
611
|
+
"6": "\u2076",
|
|
612
|
+
"7": "\u2077",
|
|
613
|
+
"8": "\u2078",
|
|
614
|
+
"9": "\u2079",
|
|
615
|
+
"+": "\u207A",
|
|
616
|
+
"-": "\u207B",
|
|
617
|
+
"=": "\u207C",
|
|
618
|
+
"(": "\u207D",
|
|
619
|
+
")": "\u207E",
|
|
620
|
+
A: "\u1D2C",
|
|
621
|
+
B: "\u1D2E",
|
|
622
|
+
D: "\u1D30",
|
|
623
|
+
E: "\u1D31",
|
|
624
|
+
G: "\u1D33",
|
|
625
|
+
H: "\u1D34",
|
|
626
|
+
I: "\u1D35",
|
|
627
|
+
J: "\u1D36",
|
|
628
|
+
K: "\u1D37",
|
|
629
|
+
L: "\u1D38",
|
|
630
|
+
M: "\u1D39",
|
|
631
|
+
N: "\u1D3A",
|
|
632
|
+
O: "\u1D3C",
|
|
633
|
+
P: "\u1D3E",
|
|
634
|
+
R: "\u1D3F",
|
|
635
|
+
T: "\u1D40",
|
|
636
|
+
U: "\u1D41",
|
|
637
|
+
V: "\u2C7D",
|
|
638
|
+
W: "\u1D42",
|
|
639
|
+
a: "\u1D43",
|
|
640
|
+
b: "\u1D47",
|
|
641
|
+
c: "\u1D9C",
|
|
642
|
+
d: "\u1D48",
|
|
643
|
+
e: "\u1D49",
|
|
644
|
+
f: "\u1DA0",
|
|
645
|
+
g: "\u1D4D",
|
|
646
|
+
h: "\u02B0",
|
|
647
|
+
i: "\u2071",
|
|
648
|
+
j: "\u02B2",
|
|
649
|
+
k: "\u1D4F",
|
|
650
|
+
l: "\u02E1",
|
|
651
|
+
m: "\u1D50",
|
|
652
|
+
n: "\u207F",
|
|
653
|
+
o: "\u1D52",
|
|
654
|
+
p: "\u1D56",
|
|
655
|
+
r: "\u02B3",
|
|
656
|
+
s: "\u02E2",
|
|
657
|
+
t: "\u1D57",
|
|
658
|
+
u: "\u1D58",
|
|
659
|
+
v: "\u1D5B",
|
|
660
|
+
w: "\u02B7",
|
|
661
|
+
x: "\u02E3",
|
|
662
|
+
y: "\u02B8",
|
|
663
|
+
z: "\u1DBB"
|
|
664
|
+
};
|
|
665
|
+
var superscriptWords = {
|
|
666
|
+
alpha: "\u1D45",
|
|
667
|
+
beta: "\u1D5D",
|
|
668
|
+
gamma: "\u1D5E",
|
|
669
|
+
theta: "\u1DBF"
|
|
670
|
+
};
|
|
671
|
+
function scriptText(value, kind) {
|
|
672
|
+
const words = kind === "sup" ? superscriptWords : {};
|
|
673
|
+
const chars = kind === "sub" ? subscriptChars : superscriptChars;
|
|
674
|
+
if (words[value]) return words[value];
|
|
675
|
+
if ((value.startsWith("-") || value.startsWith("+")) && words[value.slice(1)]) {
|
|
676
|
+
return `${chars[value[0]]}${words[value.slice(1)]}`;
|
|
677
|
+
}
|
|
678
|
+
return Array.from(value).map((char) => chars[char] ?? char).join("");
|
|
679
|
+
}
|
|
680
|
+
function formatMathText(text) {
|
|
681
|
+
return parseMathText(text).map((part) => part.kind === "text" ? part.value : scriptText(part.value, part.kind)).join("");
|
|
682
|
+
}
|
|
683
|
+
function MathText({ text }) {
|
|
684
|
+
return formatMathText(text);
|
|
685
|
+
}
|
|
686
|
+
function TextLabel({
|
|
687
|
+
text,
|
|
688
|
+
c,
|
|
689
|
+
variant = "body",
|
|
690
|
+
color,
|
|
691
|
+
fontSize,
|
|
692
|
+
fontWeight,
|
|
693
|
+
width,
|
|
694
|
+
align = "left",
|
|
695
|
+
math = false,
|
|
696
|
+
mono = false
|
|
697
|
+
}) {
|
|
698
|
+
const base = typography[variant];
|
|
699
|
+
return React.createElement("div", {
|
|
700
|
+
style: {
|
|
701
|
+
display: "flex",
|
|
702
|
+
...width !== void 0 ? { width } : {},
|
|
703
|
+
...base,
|
|
704
|
+
...textFitStyle(align),
|
|
705
|
+
color: color ?? c.textSecondary,
|
|
706
|
+
fontSize: fontSize ?? base.fontSize,
|
|
707
|
+
fontWeight: fontWeight ?? base.fontWeight,
|
|
708
|
+
fontFamily: mono ? "JetBrains Mono" : base.fontFamily,
|
|
709
|
+
justifyContent: align === "right" ? "flex-end" : align === "center" ? "center" : "flex-start",
|
|
710
|
+
lineHeight: 1.35
|
|
711
|
+
}
|
|
712
|
+
}, math ? formatMathText(text) : text);
|
|
713
|
+
}
|
|
714
|
+
function SvgMathText({
|
|
715
|
+
text,
|
|
716
|
+
x,
|
|
717
|
+
y,
|
|
718
|
+
fill,
|
|
719
|
+
fontSize = 13,
|
|
720
|
+
fontFamily = "JetBrains Mono",
|
|
721
|
+
fontWeight = 800,
|
|
722
|
+
textAnchor = "middle",
|
|
723
|
+
dominantBaseline = "middle",
|
|
724
|
+
opacity = 1
|
|
725
|
+
}) {
|
|
726
|
+
return React.createElement(
|
|
727
|
+
"text",
|
|
728
|
+
{
|
|
729
|
+
x,
|
|
730
|
+
y,
|
|
731
|
+
fill,
|
|
732
|
+
fontSize,
|
|
733
|
+
fontFamily,
|
|
734
|
+
fontWeight,
|
|
735
|
+
textAnchor,
|
|
736
|
+
dominantBaseline,
|
|
737
|
+
opacity
|
|
738
|
+
},
|
|
739
|
+
...parseMathText(text).map((part, index) => {
|
|
740
|
+
if (part.kind === "text") return part.value;
|
|
741
|
+
return React.createElement("tspan", {
|
|
742
|
+
key: `${part.kind}-${index}-${part.value}`,
|
|
743
|
+
baselineShift: part.kind === "sub" ? "sub" : "super",
|
|
744
|
+
fontSize: Math.round(fontSize * 0.72)
|
|
745
|
+
}, part.value);
|
|
746
|
+
})
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
function Box({
|
|
750
|
+
label,
|
|
751
|
+
c,
|
|
752
|
+
color = "primary",
|
|
753
|
+
width,
|
|
754
|
+
height,
|
|
755
|
+
fontSize = 14,
|
|
756
|
+
gradient = false,
|
|
757
|
+
sublabel,
|
|
758
|
+
icon,
|
|
759
|
+
radius = 8,
|
|
760
|
+
outlined = false
|
|
761
|
+
}) {
|
|
762
|
+
const solidColor = getColor(color, c);
|
|
763
|
+
const gradientBg = getGradient(color);
|
|
764
|
+
const style = {
|
|
765
|
+
display: "flex",
|
|
766
|
+
flexDirection: "column",
|
|
767
|
+
alignItems: "center",
|
|
768
|
+
justifyContent: "center",
|
|
769
|
+
borderRadius: radius,
|
|
770
|
+
padding: "12px 20px",
|
|
771
|
+
gap: 4,
|
|
772
|
+
...width ? { width } : {},
|
|
773
|
+
...height ? { height } : {}
|
|
774
|
+
};
|
|
775
|
+
if (outlined) {
|
|
776
|
+
style.border = `2px solid ${solidColor}`;
|
|
777
|
+
style.backgroundColor = "transparent";
|
|
778
|
+
} else if (gradient) {
|
|
779
|
+
style.backgroundImage = gradientBg;
|
|
780
|
+
style.boxShadow = `0 4px 20px ${solidColor}30`;
|
|
781
|
+
} else {
|
|
782
|
+
style.backgroundImage = gradientBg;
|
|
783
|
+
style.boxShadow = `0 4px 20px ${solidColor}30`;
|
|
784
|
+
}
|
|
785
|
+
return React.createElement(
|
|
786
|
+
"div",
|
|
787
|
+
{ style },
|
|
788
|
+
icon && React.createElement("div", {
|
|
789
|
+
style: { fontSize: fontSize + 4 }
|
|
790
|
+
}, icon),
|
|
791
|
+
React.createElement("div", {
|
|
792
|
+
style: {
|
|
793
|
+
fontSize,
|
|
794
|
+
fontWeight: 700,
|
|
795
|
+
color: outlined ? solidColor : c.textOnColor,
|
|
796
|
+
fontFamily: "Inter",
|
|
797
|
+
textAlign: "center",
|
|
798
|
+
lineHeight: 1.3
|
|
799
|
+
}
|
|
800
|
+
}, label),
|
|
801
|
+
sublabel && React.createElement("div", {
|
|
802
|
+
style: {
|
|
803
|
+
fontSize: fontSize - 2,
|
|
804
|
+
fontWeight: 400,
|
|
805
|
+
color: outlined ? c.textMuted : `${c.textOnColor}b3`,
|
|
806
|
+
fontFamily: "JetBrains Mono",
|
|
807
|
+
textAlign: "center"
|
|
808
|
+
}
|
|
809
|
+
}, sublabel)
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
function Arrow({
|
|
813
|
+
direction = "down",
|
|
814
|
+
label,
|
|
815
|
+
length = 40,
|
|
816
|
+
c,
|
|
817
|
+
color
|
|
818
|
+
}) {
|
|
819
|
+
const arrowColor = color || c.textMuted;
|
|
820
|
+
const isVertical = direction === "down" || direction === "up";
|
|
821
|
+
const arrowHead = {
|
|
822
|
+
down: {
|
|
823
|
+
width: 14,
|
|
824
|
+
height: 10,
|
|
825
|
+
points: "0,0 14,0 7,10"
|
|
826
|
+
},
|
|
827
|
+
up: {
|
|
828
|
+
width: 14,
|
|
829
|
+
height: 10,
|
|
830
|
+
points: "0,10 14,10 7,0"
|
|
831
|
+
},
|
|
832
|
+
right: {
|
|
833
|
+
width: 10,
|
|
834
|
+
height: 14,
|
|
835
|
+
points: "0,0 10,7 0,14"
|
|
836
|
+
},
|
|
837
|
+
left: {
|
|
838
|
+
width: 10,
|
|
839
|
+
height: 14,
|
|
840
|
+
points: "10,0 0,7 10,14"
|
|
841
|
+
}
|
|
842
|
+
}[direction];
|
|
843
|
+
const line = React.createElement("div", {
|
|
844
|
+
style: {
|
|
845
|
+
...isVertical ? { width: 2, flexGrow: 1, minHeight: 1 } : { height: 2, flexGrow: 1, minWidth: 1 },
|
|
846
|
+
backgroundColor: arrowColor
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
const head = React.createElement(
|
|
850
|
+
"svg",
|
|
851
|
+
{
|
|
852
|
+
width: arrowHead.width,
|
|
853
|
+
height: arrowHead.height,
|
|
854
|
+
viewBox: `0 0 ${arrowHead.width} ${arrowHead.height}`,
|
|
855
|
+
style: {
|
|
856
|
+
flexShrink: 0
|
|
857
|
+
}
|
|
858
|
+
},
|
|
859
|
+
React.createElement("polygon", {
|
|
860
|
+
points: arrowHead.points,
|
|
861
|
+
fill: arrowColor
|
|
862
|
+
})
|
|
863
|
+
);
|
|
864
|
+
return React.createElement(
|
|
865
|
+
"div",
|
|
866
|
+
{
|
|
867
|
+
style: {
|
|
868
|
+
position: "relative",
|
|
869
|
+
display: "flex",
|
|
870
|
+
flexDirection: isVertical ? "column" : "row",
|
|
871
|
+
alignItems: "center",
|
|
872
|
+
justifyContent: "center",
|
|
873
|
+
gap: 0,
|
|
874
|
+
...isVertical ? { height: length } : { width: length }
|
|
875
|
+
}
|
|
876
|
+
},
|
|
877
|
+
...direction === "up" || direction === "left" ? [head, line] : [line, head],
|
|
878
|
+
// Optional label
|
|
879
|
+
label && React.createElement("div", {
|
|
880
|
+
style: {
|
|
881
|
+
fontSize: 10,
|
|
882
|
+
color: c.textMuted,
|
|
883
|
+
fontFamily: "Inter",
|
|
884
|
+
fontWeight: 500,
|
|
885
|
+
position: "absolute",
|
|
886
|
+
...isVertical ? { left: 8 } : { bottom: 12 }
|
|
887
|
+
}
|
|
888
|
+
}, label)
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
function FlowArrow({
|
|
892
|
+
direction = "right",
|
|
893
|
+
label,
|
|
894
|
+
length = 40,
|
|
895
|
+
c,
|
|
896
|
+
tone = "blue",
|
|
897
|
+
color
|
|
898
|
+
}) {
|
|
899
|
+
return Arrow({
|
|
900
|
+
direction,
|
|
901
|
+
label,
|
|
902
|
+
length,
|
|
903
|
+
c,
|
|
904
|
+
color: color ?? getToneColor(tone, c)
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
function Connector(props) {
|
|
908
|
+
return FlowArrow(props);
|
|
909
|
+
}
|
|
910
|
+
function VectorArrow({
|
|
911
|
+
key,
|
|
912
|
+
x1,
|
|
913
|
+
y1,
|
|
914
|
+
x2,
|
|
915
|
+
y2,
|
|
916
|
+
color,
|
|
917
|
+
strokeWidth = 2,
|
|
918
|
+
arrowSize = 2.2,
|
|
919
|
+
opacity = 1
|
|
920
|
+
}) {
|
|
921
|
+
const dx = x2 - x1;
|
|
922
|
+
const dy = y2 - y1;
|
|
923
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
924
|
+
if (len < 1e-3) {
|
|
925
|
+
return React.createElement("g", null);
|
|
926
|
+
}
|
|
927
|
+
const ux = dx / len;
|
|
928
|
+
const uy = dy / len;
|
|
929
|
+
const px = -uy;
|
|
930
|
+
const py = ux;
|
|
931
|
+
const headLen = strokeWidth * arrowSize;
|
|
932
|
+
const headWidth = headLen * 0.6;
|
|
933
|
+
const backX = x2 - ux * headLen;
|
|
934
|
+
const backY = y2 - uy * headLen;
|
|
935
|
+
const points = `${x2},${y2} ${backX + px * headWidth / 2},${backY + py * headWidth / 2} ${backX - px * headWidth / 2},${backY - py * headWidth / 2}`;
|
|
936
|
+
return React.createElement(
|
|
937
|
+
"g",
|
|
938
|
+
{ key, opacity },
|
|
939
|
+
React.createElement("line", {
|
|
940
|
+
x1,
|
|
941
|
+
y1,
|
|
942
|
+
x2: backX,
|
|
943
|
+
y2: backY,
|
|
944
|
+
stroke: color,
|
|
945
|
+
strokeWidth,
|
|
946
|
+
strokeLinecap: "round"
|
|
947
|
+
}),
|
|
948
|
+
React.createElement("polygon", {
|
|
949
|
+
points,
|
|
950
|
+
fill: color
|
|
951
|
+
})
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
function VectorSegment({
|
|
955
|
+
key,
|
|
956
|
+
x1,
|
|
957
|
+
y1,
|
|
958
|
+
x2,
|
|
959
|
+
y2,
|
|
960
|
+
color,
|
|
961
|
+
strokeWidth = 4,
|
|
962
|
+
opacity = 1,
|
|
963
|
+
showStartDot = false,
|
|
964
|
+
showEndDot = true,
|
|
965
|
+
dotRadius = 4.5
|
|
966
|
+
}) {
|
|
967
|
+
return React.createElement(
|
|
968
|
+
"g",
|
|
969
|
+
{ key, opacity },
|
|
970
|
+
React.createElement("line", {
|
|
971
|
+
x1,
|
|
972
|
+
y1,
|
|
973
|
+
x2,
|
|
974
|
+
y2,
|
|
975
|
+
stroke: color,
|
|
976
|
+
strokeWidth,
|
|
977
|
+
strokeLinecap: "round"
|
|
978
|
+
}),
|
|
979
|
+
showStartDot && React.createElement("circle", {
|
|
980
|
+
cx: x1,
|
|
981
|
+
cy: y1,
|
|
982
|
+
r: dotRadius,
|
|
983
|
+
fill: color
|
|
984
|
+
}),
|
|
985
|
+
showEndDot && React.createElement("circle", {
|
|
986
|
+
cx: x2,
|
|
987
|
+
cy: y2,
|
|
988
|
+
r: dotRadius,
|
|
989
|
+
fill: color
|
|
990
|
+
})
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
function SvgFrame({
|
|
994
|
+
key,
|
|
995
|
+
x = 0,
|
|
996
|
+
y = 0,
|
|
997
|
+
width,
|
|
998
|
+
height,
|
|
999
|
+
c,
|
|
1000
|
+
rx = 8,
|
|
1001
|
+
fill,
|
|
1002
|
+
stroke,
|
|
1003
|
+
strokeWidth = 1,
|
|
1004
|
+
opacity
|
|
1005
|
+
}) {
|
|
1006
|
+
return React.createElement("rect", {
|
|
1007
|
+
key,
|
|
1008
|
+
x,
|
|
1009
|
+
y,
|
|
1010
|
+
width,
|
|
1011
|
+
height,
|
|
1012
|
+
rx,
|
|
1013
|
+
fill: fill ?? c.bgSubtle,
|
|
1014
|
+
stroke: stroke ?? c.borderSubtle,
|
|
1015
|
+
strokeWidth,
|
|
1016
|
+
...opacity !== void 0 ? { opacity } : {}
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
function SvgPoint({
|
|
1020
|
+
key,
|
|
1021
|
+
cx,
|
|
1022
|
+
cy,
|
|
1023
|
+
r = 5,
|
|
1024
|
+
fill,
|
|
1025
|
+
stroke,
|
|
1026
|
+
strokeWidth,
|
|
1027
|
+
opacity
|
|
1028
|
+
}) {
|
|
1029
|
+
return React.createElement("circle", {
|
|
1030
|
+
key,
|
|
1031
|
+
cx,
|
|
1032
|
+
cy,
|
|
1033
|
+
r,
|
|
1034
|
+
fill,
|
|
1035
|
+
...stroke ? { stroke } : {},
|
|
1036
|
+
...strokeWidth ? { strokeWidth } : {},
|
|
1037
|
+
...opacity !== void 0 ? { opacity } : {}
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
function ArrowMarkerDef({ id, color, size = 5 }) {
|
|
1041
|
+
return React.createElement(
|
|
1042
|
+
"marker",
|
|
1043
|
+
{
|
|
1044
|
+
id,
|
|
1045
|
+
viewBox: "0 0 10 10",
|
|
1046
|
+
refX: 9.5,
|
|
1047
|
+
refY: 5,
|
|
1048
|
+
markerWidth: size,
|
|
1049
|
+
markerHeight: size,
|
|
1050
|
+
orient: "auto"
|
|
1051
|
+
},
|
|
1052
|
+
React.createElement("path", {
|
|
1053
|
+
d: "M 0 0 L 10 5 L 0 10 z",
|
|
1054
|
+
fill: color
|
|
1055
|
+
})
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
function Stack({
|
|
1059
|
+
direction = "vertical",
|
|
1060
|
+
gap = 12,
|
|
1061
|
+
align = "center",
|
|
1062
|
+
wrap = false,
|
|
1063
|
+
children
|
|
1064
|
+
}) {
|
|
1065
|
+
const alignMap = {
|
|
1066
|
+
start: "flex-start",
|
|
1067
|
+
center: "center",
|
|
1068
|
+
end: "flex-end",
|
|
1069
|
+
stretch: "stretch"
|
|
1070
|
+
};
|
|
1071
|
+
return React.createElement("div", {
|
|
1072
|
+
style: {
|
|
1073
|
+
display: "flex",
|
|
1074
|
+
flexDirection: direction === "vertical" ? "column" : "row",
|
|
1075
|
+
alignItems: alignMap[align],
|
|
1076
|
+
gap,
|
|
1077
|
+
...wrap ? { flexWrap: "wrap" } : {}
|
|
1078
|
+
}
|
|
1079
|
+
}, children);
|
|
1080
|
+
}
|
|
1081
|
+
function Card({
|
|
1082
|
+
children,
|
|
1083
|
+
c,
|
|
1084
|
+
title,
|
|
1085
|
+
subtitle,
|
|
1086
|
+
tone,
|
|
1087
|
+
footer,
|
|
1088
|
+
width,
|
|
1089
|
+
minWidth,
|
|
1090
|
+
height,
|
|
1091
|
+
minHeight,
|
|
1092
|
+
padding = 20,
|
|
1093
|
+
radius = 8,
|
|
1094
|
+
gap,
|
|
1095
|
+
align = "stretch",
|
|
1096
|
+
justify = "start",
|
|
1097
|
+
shadow = false,
|
|
1098
|
+
background,
|
|
1099
|
+
borderColor,
|
|
1100
|
+
bodyStyle
|
|
1101
|
+
}) {
|
|
1102
|
+
const hasHeader = title || subtitle || tone;
|
|
1103
|
+
return React.createElement(
|
|
1104
|
+
"div",
|
|
1105
|
+
{
|
|
1106
|
+
style: {
|
|
1107
|
+
display: "flex",
|
|
1108
|
+
flexDirection: "column",
|
|
1109
|
+
alignItems: flexAlign(align),
|
|
1110
|
+
justifyContent: flexJustify(justify),
|
|
1111
|
+
gap: gap ?? (hasHeader || footer ? 10 : 0),
|
|
1112
|
+
backgroundColor: background ?? c.bgCard,
|
|
1113
|
+
borderRadius: radius,
|
|
1114
|
+
border: `1px solid ${borderColor ?? c.borderSubtle}`,
|
|
1115
|
+
padding,
|
|
1116
|
+
...width !== void 0 ? { width } : {},
|
|
1117
|
+
...minWidth !== void 0 ? { minWidth } : {},
|
|
1118
|
+
...height !== void 0 ? { height } : {},
|
|
1119
|
+
...minHeight !== void 0 ? { minHeight } : {},
|
|
1120
|
+
...shadow ? { boxShadow: `0 9px 24px ${c.shadow}` } : {}
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
...compactChildren([
|
|
1124
|
+
hasHeader && React.createElement(
|
|
1125
|
+
"div",
|
|
1126
|
+
{
|
|
1127
|
+
style: {
|
|
1128
|
+
width: "100%",
|
|
1129
|
+
display: "flex",
|
|
1130
|
+
flexDirection: "column",
|
|
1131
|
+
gap: subtitle ? 5 : 0
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
...compactChildren([
|
|
1135
|
+
(title || tone) && React.createElement(
|
|
1136
|
+
"div",
|
|
1137
|
+
{
|
|
1138
|
+
style: {
|
|
1139
|
+
display: "flex",
|
|
1140
|
+
alignItems: "center",
|
|
1141
|
+
gap: 8,
|
|
1142
|
+
color: c.textPrimary,
|
|
1143
|
+
...typography.small,
|
|
1144
|
+
...textFitStyle(),
|
|
1145
|
+
fontWeight: 900,
|
|
1146
|
+
lineHeight: 1.2
|
|
1147
|
+
}
|
|
1148
|
+
},
|
|
1149
|
+
tone && ToneStrip({ tone, width: 30, height: 4 }),
|
|
1150
|
+
title
|
|
1151
|
+
),
|
|
1152
|
+
subtitle && React.createElement("div", {
|
|
1153
|
+
style: {
|
|
1154
|
+
display: "flex",
|
|
1155
|
+
color: c.textSecondary,
|
|
1156
|
+
...typography.tiny,
|
|
1157
|
+
...textFitStyle(),
|
|
1158
|
+
lineHeight: 1.35
|
|
1159
|
+
}
|
|
1160
|
+
}, subtitle)
|
|
1161
|
+
])
|
|
1162
|
+
),
|
|
1163
|
+
React.createElement("div", {
|
|
1164
|
+
style: {
|
|
1165
|
+
width: "100%",
|
|
1166
|
+
display: "flex",
|
|
1167
|
+
flexDirection: "column",
|
|
1168
|
+
...bodyStyle
|
|
1169
|
+
}
|
|
1170
|
+
}, children),
|
|
1171
|
+
footer && React.createElement("div", {
|
|
1172
|
+
style: {
|
|
1173
|
+
width: "100%",
|
|
1174
|
+
display: "flex",
|
|
1175
|
+
color: c.textMuted,
|
|
1176
|
+
...typography.tiny,
|
|
1177
|
+
...textFitStyle()
|
|
1178
|
+
}
|
|
1179
|
+
}, footer)
|
|
1180
|
+
])
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
function renderMaybeMath(node, math) {
|
|
1184
|
+
return math && typeof node === "string" ? formatMathText(node) : node;
|
|
1185
|
+
}
|
|
1186
|
+
function ValuePill({
|
|
1187
|
+
label,
|
|
1188
|
+
value,
|
|
1189
|
+
c,
|
|
1190
|
+
tone = "blue",
|
|
1191
|
+
detail,
|
|
1192
|
+
width = 112,
|
|
1193
|
+
math = false
|
|
1194
|
+
}) {
|
|
1195
|
+
const accent = getToneColor(tone, c);
|
|
1196
|
+
return Card({
|
|
1197
|
+
c,
|
|
1198
|
+
tone,
|
|
1199
|
+
width,
|
|
1200
|
+
padding: 12,
|
|
1201
|
+
radius: 10,
|
|
1202
|
+
shadow: true,
|
|
1203
|
+
title: React.createElement("span", {
|
|
1204
|
+
style: {
|
|
1205
|
+
textTransform: "uppercase",
|
|
1206
|
+
letterSpacing: "0.05em"
|
|
1207
|
+
}
|
|
1208
|
+
}, renderMaybeMath(label, math)),
|
|
1209
|
+
children: React.createElement(
|
|
1210
|
+
"div",
|
|
1211
|
+
{
|
|
1212
|
+
style: {
|
|
1213
|
+
display: "flex",
|
|
1214
|
+
flexDirection: "column",
|
|
1215
|
+
gap: 4
|
|
1216
|
+
}
|
|
1217
|
+
},
|
|
1218
|
+
React.createElement("div", {
|
|
1219
|
+
style: {
|
|
1220
|
+
color: accent,
|
|
1221
|
+
fontFamily: "JetBrains Mono",
|
|
1222
|
+
fontSize: 24,
|
|
1223
|
+
fontWeight: 900,
|
|
1224
|
+
lineHeight: 1
|
|
1225
|
+
}
|
|
1226
|
+
}, renderMaybeMath(value, math)),
|
|
1227
|
+
detail && React.createElement("div", {
|
|
1228
|
+
style: {
|
|
1229
|
+
color: c.textSecondary,
|
|
1230
|
+
...typography.tiny,
|
|
1231
|
+
lineHeight: 1.3
|
|
1232
|
+
}
|
|
1233
|
+
}, renderMaybeMath(detail, math))
|
|
1234
|
+
)
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
function EquationCard({
|
|
1238
|
+
title,
|
|
1239
|
+
formula,
|
|
1240
|
+
c,
|
|
1241
|
+
tone = "purple",
|
|
1242
|
+
result,
|
|
1243
|
+
detail,
|
|
1244
|
+
width = 190,
|
|
1245
|
+
height,
|
|
1246
|
+
math = false,
|
|
1247
|
+
align = "left"
|
|
1248
|
+
}) {
|
|
1249
|
+
const accent = getToneColor(tone, c);
|
|
1250
|
+
const textAlign = align;
|
|
1251
|
+
return Card({
|
|
1252
|
+
c,
|
|
1253
|
+
tone,
|
|
1254
|
+
width,
|
|
1255
|
+
height,
|
|
1256
|
+
padding: 16,
|
|
1257
|
+
radius: 10,
|
|
1258
|
+
shadow: true,
|
|
1259
|
+
title,
|
|
1260
|
+
children: React.createElement(
|
|
1261
|
+
"div",
|
|
1262
|
+
{
|
|
1263
|
+
style: {
|
|
1264
|
+
display: "flex",
|
|
1265
|
+
flexDirection: "column",
|
|
1266
|
+
gap: 8,
|
|
1267
|
+
alignItems: align === "center" ? "center" : "flex-start"
|
|
1268
|
+
}
|
|
1269
|
+
},
|
|
1270
|
+
React.createElement("div", {
|
|
1271
|
+
style: {
|
|
1272
|
+
color: c.textPrimary,
|
|
1273
|
+
fontFamily: "JetBrains Mono",
|
|
1274
|
+
fontSize: 15,
|
|
1275
|
+
fontWeight: 800,
|
|
1276
|
+
lineHeight: 1.3,
|
|
1277
|
+
textAlign
|
|
1278
|
+
}
|
|
1279
|
+
}, renderMaybeMath(formula, math)),
|
|
1280
|
+
result && React.createElement("div", {
|
|
1281
|
+
style: {
|
|
1282
|
+
color: accent,
|
|
1283
|
+
fontFamily: "JetBrains Mono",
|
|
1284
|
+
fontSize: 28,
|
|
1285
|
+
fontWeight: 900,
|
|
1286
|
+
lineHeight: 1,
|
|
1287
|
+
textAlign
|
|
1288
|
+
}
|
|
1289
|
+
}, renderMaybeMath(result, math)),
|
|
1290
|
+
detail && React.createElement("div", {
|
|
1291
|
+
style: {
|
|
1292
|
+
color: c.textSecondary,
|
|
1293
|
+
...typography.tiny,
|
|
1294
|
+
lineHeight: 1.35,
|
|
1295
|
+
textAlign
|
|
1296
|
+
}
|
|
1297
|
+
}, renderMaybeMath(detail, math))
|
|
1298
|
+
)
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
function BadgePill({
|
|
1302
|
+
text,
|
|
1303
|
+
c,
|
|
1304
|
+
tone = "blue",
|
|
1305
|
+
width,
|
|
1306
|
+
minWidth = 34,
|
|
1307
|
+
height = 20,
|
|
1308
|
+
padding = "0 8px",
|
|
1309
|
+
radius = 6,
|
|
1310
|
+
fontSize = 9,
|
|
1311
|
+
mono = true,
|
|
1312
|
+
filled = false,
|
|
1313
|
+
math = false
|
|
1314
|
+
}) {
|
|
1315
|
+
const accent = getToneColor(tone, c);
|
|
1316
|
+
return React.createElement("div", {
|
|
1317
|
+
style: {
|
|
1318
|
+
display: "flex",
|
|
1319
|
+
alignItems: "center",
|
|
1320
|
+
justifyContent: "center",
|
|
1321
|
+
...width != null ? { width } : {},
|
|
1322
|
+
...minWidth != null ? { minWidth } : {},
|
|
1323
|
+
...height != null ? { height } : {},
|
|
1324
|
+
padding,
|
|
1325
|
+
borderRadius: radius,
|
|
1326
|
+
...filled ? { backgroundImage: getToneGradient(tone) } : { backgroundColor: `${accent}18` },
|
|
1327
|
+
border: `1px solid ${filled ? `${accent}00` : `${accent}55`}`,
|
|
1328
|
+
color: filled ? c.textOnColor : accent,
|
|
1329
|
+
fontSize,
|
|
1330
|
+
fontWeight: 800,
|
|
1331
|
+
lineHeight: 1,
|
|
1332
|
+
fontFamily: mono ? "JetBrains Mono" : "Inter",
|
|
1333
|
+
boxSizing: "border-box",
|
|
1334
|
+
whiteSpace: "nowrap"
|
|
1335
|
+
}
|
|
1336
|
+
}, renderMaybeMath(text, math));
|
|
1337
|
+
}
|
|
1338
|
+
function GradientChip({
|
|
1339
|
+
title,
|
|
1340
|
+
c,
|
|
1341
|
+
subtitle,
|
|
1342
|
+
tone = "blue",
|
|
1343
|
+
gradient,
|
|
1344
|
+
width,
|
|
1345
|
+
minWidth,
|
|
1346
|
+
height,
|
|
1347
|
+
minHeight = 78,
|
|
1348
|
+
padding = "0 18px",
|
|
1349
|
+
radius = 8,
|
|
1350
|
+
shadow = true,
|
|
1351
|
+
align = "left",
|
|
1352
|
+
subtitleMono = true,
|
|
1353
|
+
math = false
|
|
1354
|
+
}) {
|
|
1355
|
+
const textAlign = align;
|
|
1356
|
+
return React.createElement(
|
|
1357
|
+
"div",
|
|
1358
|
+
{
|
|
1359
|
+
style: {
|
|
1360
|
+
...width != null ? { width } : {},
|
|
1361
|
+
...minWidth != null ? { minWidth } : {},
|
|
1362
|
+
...height != null ? { height } : {},
|
|
1363
|
+
...minHeight != null ? { minHeight } : {},
|
|
1364
|
+
boxSizing: "border-box",
|
|
1365
|
+
borderRadius: radius,
|
|
1366
|
+
...gradient != null ? { backgroundImage: gradient } : { backgroundImage: getToneGradient(tone) },
|
|
1367
|
+
color: c.textOnColor,
|
|
1368
|
+
display: "flex",
|
|
1369
|
+
flexDirection: "column",
|
|
1370
|
+
justifyContent: "center",
|
|
1371
|
+
alignItems: align === "center" ? "center" : "flex-start",
|
|
1372
|
+
gap: 5,
|
|
1373
|
+
padding,
|
|
1374
|
+
...shadow ? { boxShadow: `0 12px 30px ${c.shadow}` } : {}
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
React.createElement("div", {
|
|
1378
|
+
style: {
|
|
1379
|
+
...typography.label,
|
|
1380
|
+
color: c.textOnColor,
|
|
1381
|
+
fontWeight: 900,
|
|
1382
|
+
lineHeight: 1.1,
|
|
1383
|
+
textAlign
|
|
1384
|
+
}
|
|
1385
|
+
}, renderMaybeMath(title, math)),
|
|
1386
|
+
subtitle && React.createElement("div", {
|
|
1387
|
+
style: {
|
|
1388
|
+
fontSize: 11,
|
|
1389
|
+
color: "rgba(255,255,255,0.86)",
|
|
1390
|
+
lineHeight: 1.2,
|
|
1391
|
+
textAlign,
|
|
1392
|
+
fontFamily: subtitleMono ? "JetBrains Mono" : "Inter"
|
|
1393
|
+
}
|
|
1394
|
+
}, renderMaybeMath(subtitle, math))
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
function StepCard({
|
|
1398
|
+
title,
|
|
1399
|
+
c,
|
|
1400
|
+
subtitle,
|
|
1401
|
+
eyebrow,
|
|
1402
|
+
tone = "blue",
|
|
1403
|
+
width = 210,
|
|
1404
|
+
minWidth,
|
|
1405
|
+
minHeight = 74,
|
|
1406
|
+
padding = "12px 14px",
|
|
1407
|
+
radius = 8,
|
|
1408
|
+
shadow = true,
|
|
1409
|
+
align = "center",
|
|
1410
|
+
math = false
|
|
1411
|
+
}) {
|
|
1412
|
+
const accent = getToneColor(tone, c);
|
|
1413
|
+
const textAlign = align;
|
|
1414
|
+
return Card({
|
|
1415
|
+
c,
|
|
1416
|
+
width,
|
|
1417
|
+
minWidth,
|
|
1418
|
+
minHeight,
|
|
1419
|
+
padding,
|
|
1420
|
+
radius,
|
|
1421
|
+
shadow,
|
|
1422
|
+
borderColor: `${accent}88`,
|
|
1423
|
+
children: React.createElement(
|
|
1424
|
+
"div",
|
|
1425
|
+
{
|
|
1426
|
+
style: {
|
|
1427
|
+
width: "100%",
|
|
1428
|
+
display: "flex",
|
|
1429
|
+
flexDirection: "column",
|
|
1430
|
+
justifyContent: "center",
|
|
1431
|
+
alignItems: align === "center" ? "center" : "flex-start",
|
|
1432
|
+
gap: subtitle ? 5 : 2
|
|
1433
|
+
}
|
|
1434
|
+
},
|
|
1435
|
+
eyebrow && React.createElement("div", {
|
|
1436
|
+
style: {
|
|
1437
|
+
...typography.tiny,
|
|
1438
|
+
color: c.textMuted,
|
|
1439
|
+
fontWeight: 800,
|
|
1440
|
+
textTransform: "uppercase",
|
|
1441
|
+
letterSpacing: "0.05em",
|
|
1442
|
+
...textFitStyle(textAlign),
|
|
1443
|
+
lineHeight: 1.2
|
|
1444
|
+
}
|
|
1445
|
+
}, renderMaybeMath(eyebrow, math)),
|
|
1446
|
+
React.createElement("div", {
|
|
1447
|
+
style: {
|
|
1448
|
+
...typography.label,
|
|
1449
|
+
color: accent,
|
|
1450
|
+
fontWeight: 700,
|
|
1451
|
+
lineHeight: 1.15,
|
|
1452
|
+
...textFitStyle(textAlign)
|
|
1453
|
+
}
|
|
1454
|
+
}, renderMaybeMath(title, math)),
|
|
1455
|
+
subtitle && React.createElement("div", {
|
|
1456
|
+
style: {
|
|
1457
|
+
...typography.tiny,
|
|
1458
|
+
color: c.textMuted,
|
|
1459
|
+
lineHeight: 1.25,
|
|
1460
|
+
...textFitStyle(textAlign)
|
|
1461
|
+
}
|
|
1462
|
+
}, renderMaybeMath(subtitle, math))
|
|
1463
|
+
)
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
function MetricCard({
|
|
1467
|
+
label,
|
|
1468
|
+
value,
|
|
1469
|
+
c,
|
|
1470
|
+
tone = "blue",
|
|
1471
|
+
detail,
|
|
1472
|
+
width,
|
|
1473
|
+
minWidth,
|
|
1474
|
+
minHeight = 74,
|
|
1475
|
+
padding = "10px 12px",
|
|
1476
|
+
radius = 8,
|
|
1477
|
+
shadow = true,
|
|
1478
|
+
align = "center",
|
|
1479
|
+
math = false,
|
|
1480
|
+
valueMono = true,
|
|
1481
|
+
valueFontSize = 10,
|
|
1482
|
+
valueColor
|
|
1483
|
+
}) {
|
|
1484
|
+
const accent = getToneColor(tone, c);
|
|
1485
|
+
const textAlign = align;
|
|
1486
|
+
return Card({
|
|
1487
|
+
c,
|
|
1488
|
+
width,
|
|
1489
|
+
minWidth,
|
|
1490
|
+
minHeight,
|
|
1491
|
+
padding,
|
|
1492
|
+
radius,
|
|
1493
|
+
shadow,
|
|
1494
|
+
borderColor: `${accent}66`,
|
|
1495
|
+
children: React.createElement(
|
|
1496
|
+
"div",
|
|
1497
|
+
{
|
|
1498
|
+
style: {
|
|
1499
|
+
width: "100%",
|
|
1500
|
+
display: "flex",
|
|
1501
|
+
flexDirection: "column",
|
|
1502
|
+
justifyContent: "center",
|
|
1503
|
+
alignItems: align === "center" ? "center" : "flex-start",
|
|
1504
|
+
gap: 3
|
|
1505
|
+
}
|
|
1506
|
+
},
|
|
1507
|
+
...compactChildren([
|
|
1508
|
+
React.createElement("div", {
|
|
1509
|
+
style: {
|
|
1510
|
+
fontSize: 11,
|
|
1511
|
+
fontWeight: 800,
|
|
1512
|
+
color: accent,
|
|
1513
|
+
lineHeight: 1.1,
|
|
1514
|
+
...textFitStyle(textAlign)
|
|
1515
|
+
}
|
|
1516
|
+
}, renderMaybeMath(label, math)),
|
|
1517
|
+
React.createElement("div", {
|
|
1518
|
+
style: {
|
|
1519
|
+
fontSize: valueFontSize,
|
|
1520
|
+
fontWeight: 700,
|
|
1521
|
+
color: valueColor ?? c.textPrimary,
|
|
1522
|
+
lineHeight: 1.15,
|
|
1523
|
+
...textFitStyle(textAlign),
|
|
1524
|
+
fontFamily: valueMono ? "JetBrains Mono" : "Inter"
|
|
1525
|
+
}
|
|
1526
|
+
}, renderMaybeMath(value, math)),
|
|
1527
|
+
detail && React.createElement("div", {
|
|
1528
|
+
style: {
|
|
1529
|
+
...typography.tiny,
|
|
1530
|
+
color: c.textMuted,
|
|
1531
|
+
lineHeight: 1.2,
|
|
1532
|
+
...textFitStyle(textAlign)
|
|
1533
|
+
}
|
|
1534
|
+
}, renderMaybeMath(detail, math))
|
|
1535
|
+
])
|
|
1536
|
+
)
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
function ProgressRow({
|
|
1540
|
+
label,
|
|
1541
|
+
value,
|
|
1542
|
+
valueLabel,
|
|
1543
|
+
tone = "blue",
|
|
1544
|
+
muted = false,
|
|
1545
|
+
c,
|
|
1546
|
+
labelWidth = 42,
|
|
1547
|
+
valueWidth = 38,
|
|
1548
|
+
barHeight = 8,
|
|
1549
|
+
fontSize = 10
|
|
1550
|
+
}) {
|
|
1551
|
+
const accent = muted ? c.textMuted : getToneColor(tone, c);
|
|
1552
|
+
const pct = Math.round(Math.max(0, Math.min(1, value)) * 100);
|
|
1553
|
+
return React.createElement(
|
|
1554
|
+
"div",
|
|
1555
|
+
{
|
|
1556
|
+
style: {
|
|
1557
|
+
display: "flex",
|
|
1558
|
+
alignItems: "center",
|
|
1559
|
+
gap: 8,
|
|
1560
|
+
width: "100%"
|
|
1561
|
+
}
|
|
1562
|
+
},
|
|
1563
|
+
React.createElement("div", {
|
|
1564
|
+
style: {
|
|
1565
|
+
width: labelWidth,
|
|
1566
|
+
color: muted ? c.textMuted : c.textPrimary,
|
|
1567
|
+
fontSize,
|
|
1568
|
+
fontWeight: 800,
|
|
1569
|
+
lineHeight: 1
|
|
1570
|
+
}
|
|
1571
|
+
}, label),
|
|
1572
|
+
React.createElement(
|
|
1573
|
+
"div",
|
|
1574
|
+
{
|
|
1575
|
+
style: {
|
|
1576
|
+
display: "flex",
|
|
1577
|
+
flex: 1,
|
|
1578
|
+
height: barHeight,
|
|
1579
|
+
borderRadius: 999,
|
|
1580
|
+
backgroundColor: c.bgSubtle,
|
|
1581
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
1582
|
+
overflow: "hidden"
|
|
1583
|
+
}
|
|
1584
|
+
},
|
|
1585
|
+
React.createElement("div", {
|
|
1586
|
+
style: {
|
|
1587
|
+
width: `${pct}%`,
|
|
1588
|
+
height: "100%",
|
|
1589
|
+
borderRadius: 999,
|
|
1590
|
+
backgroundColor: accent,
|
|
1591
|
+
opacity: muted ? 0.62 : 1
|
|
1592
|
+
}
|
|
1593
|
+
})
|
|
1594
|
+
),
|
|
1595
|
+
React.createElement("div", {
|
|
1596
|
+
style: {
|
|
1597
|
+
width: valueWidth,
|
|
1598
|
+
color: accent,
|
|
1599
|
+
fontSize,
|
|
1600
|
+
fontWeight: 800,
|
|
1601
|
+
fontFamily: "JetBrains Mono",
|
|
1602
|
+
lineHeight: 1,
|
|
1603
|
+
textAlign: "right"
|
|
1604
|
+
}
|
|
1605
|
+
}, valueLabel ?? `${pct}%`)
|
|
1606
|
+
);
|
|
1607
|
+
}
|
|
1608
|
+
function ProgressList({
|
|
1609
|
+
rows,
|
|
1610
|
+
c,
|
|
1611
|
+
gap = 8,
|
|
1612
|
+
labelWidth,
|
|
1613
|
+
valueWidth,
|
|
1614
|
+
barHeight,
|
|
1615
|
+
fontSize
|
|
1616
|
+
}) {
|
|
1617
|
+
return Column({
|
|
1618
|
+
gap,
|
|
1619
|
+
align: "stretch",
|
|
1620
|
+
children: rows.map((row, index) => React.createElement(
|
|
1621
|
+
React.Fragment,
|
|
1622
|
+
{ key: `progress-${index}` },
|
|
1623
|
+
ProgressRow({
|
|
1624
|
+
...row,
|
|
1625
|
+
c,
|
|
1626
|
+
labelWidth,
|
|
1627
|
+
valueWidth,
|
|
1628
|
+
barHeight,
|
|
1629
|
+
fontSize
|
|
1630
|
+
})
|
|
1631
|
+
))
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
function MiniBarChart({
|
|
1635
|
+
data,
|
|
1636
|
+
c,
|
|
1637
|
+
max,
|
|
1638
|
+
minBarHeight = 8,
|
|
1639
|
+
height = 92,
|
|
1640
|
+
barWidth = 22,
|
|
1641
|
+
gap = 10,
|
|
1642
|
+
radius = 7,
|
|
1643
|
+
fontSize = 9,
|
|
1644
|
+
showValues = false
|
|
1645
|
+
}) {
|
|
1646
|
+
const safeMax = max ?? Math.max(1, ...data.map((item) => Math.max(0, item.value)));
|
|
1647
|
+
const barMaxHeight = Math.max(minBarHeight, height - (showValues ? 34 : 20));
|
|
1648
|
+
return React.createElement(
|
|
1649
|
+
"div",
|
|
1650
|
+
{
|
|
1651
|
+
style: {
|
|
1652
|
+
display: "flex",
|
|
1653
|
+
alignItems: "flex-end",
|
|
1654
|
+
justifyContent: "center",
|
|
1655
|
+
gap,
|
|
1656
|
+
height,
|
|
1657
|
+
width: "100%",
|
|
1658
|
+
padding: "0 4px",
|
|
1659
|
+
boxSizing: "border-box"
|
|
1660
|
+
}
|
|
1661
|
+
},
|
|
1662
|
+
...data.map((item, index) => {
|
|
1663
|
+
const tone = item.tone ?? "blue";
|
|
1664
|
+
const barHeight = Math.max(minBarHeight, Math.round(Math.max(0, item.value) / safeMax * barMaxHeight));
|
|
1665
|
+
const fill = item.color ?? getToneGradient(tone);
|
|
1666
|
+
return React.createElement(
|
|
1667
|
+
"div",
|
|
1668
|
+
{
|
|
1669
|
+
key: `mini-bar-${index}-${String(item.label)}`,
|
|
1670
|
+
style: {
|
|
1671
|
+
display: "flex",
|
|
1672
|
+
flexDirection: "column",
|
|
1673
|
+
alignItems: "center",
|
|
1674
|
+
justifyContent: "flex-end",
|
|
1675
|
+
gap: 5,
|
|
1676
|
+
height: "100%",
|
|
1677
|
+
minWidth: barWidth
|
|
1678
|
+
}
|
|
1679
|
+
},
|
|
1680
|
+
...compactChildren([
|
|
1681
|
+
showValues && React.createElement("div", {
|
|
1682
|
+
style: {
|
|
1683
|
+
color: getToneColor(tone, c),
|
|
1684
|
+
fontFamily: "JetBrains Mono",
|
|
1685
|
+
fontSize,
|
|
1686
|
+
fontWeight: 800,
|
|
1687
|
+
lineHeight: 1
|
|
1688
|
+
}
|
|
1689
|
+
}, item.valueLabel ?? item.value),
|
|
1690
|
+
React.createElement("div", {
|
|
1691
|
+
style: {
|
|
1692
|
+
display: "flex",
|
|
1693
|
+
width: barWidth,
|
|
1694
|
+
height: barHeight,
|
|
1695
|
+
borderRadius: `${radius}px ${radius}px 4px 4px`,
|
|
1696
|
+
...fill.startsWith("linear-gradient") ? { backgroundImage: fill } : { backgroundColor: fill },
|
|
1697
|
+
opacity: item.opacity ?? 0.92
|
|
1698
|
+
}
|
|
1699
|
+
}),
|
|
1700
|
+
React.createElement("div", {
|
|
1701
|
+
style: {
|
|
1702
|
+
color: c.textMuted,
|
|
1703
|
+
fontFamily: "JetBrains Mono",
|
|
1704
|
+
fontSize,
|
|
1705
|
+
fontWeight: 700,
|
|
1706
|
+
lineHeight: 1,
|
|
1707
|
+
minHeight: fontSize + 2
|
|
1708
|
+
}
|
|
1709
|
+
}, item.label)
|
|
1710
|
+
])
|
|
1711
|
+
);
|
|
1712
|
+
})
|
|
1713
|
+
);
|
|
1714
|
+
}
|
|
1715
|
+
function DetailList({
|
|
1716
|
+
items,
|
|
1717
|
+
c,
|
|
1718
|
+
tone,
|
|
1719
|
+
gap = 7,
|
|
1720
|
+
padding = "7px 8px",
|
|
1721
|
+
fontSize = 10,
|
|
1722
|
+
mono = false,
|
|
1723
|
+
math = false
|
|
1724
|
+
}) {
|
|
1725
|
+
const accent = tone ? getToneColor(tone, c) : c.borderSubtle;
|
|
1726
|
+
return Column({
|
|
1727
|
+
gap,
|
|
1728
|
+
align: "stretch",
|
|
1729
|
+
children: items.map((item, index) => React.createElement("div", {
|
|
1730
|
+
key: `detail-${index}`,
|
|
1731
|
+
style: {
|
|
1732
|
+
padding,
|
|
1733
|
+
borderRadius: 8,
|
|
1734
|
+
backgroundColor: c.bgSubtle,
|
|
1735
|
+
border: `1px solid ${tone ? `${accent}44` : c.borderSubtle}`,
|
|
1736
|
+
color: c.textSecondary,
|
|
1737
|
+
fontSize,
|
|
1738
|
+
lineHeight: 1.3,
|
|
1739
|
+
fontFamily: mono ? "JetBrains Mono" : "Inter"
|
|
1740
|
+
}
|
|
1741
|
+
}, renderMaybeMath(item, math)))
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
function Tile({
|
|
1745
|
+
title,
|
|
1746
|
+
subtitle,
|
|
1747
|
+
eyebrow,
|
|
1748
|
+
icon,
|
|
1749
|
+
tone = "blue",
|
|
1750
|
+
lines,
|
|
1751
|
+
children,
|
|
1752
|
+
width,
|
|
1753
|
+
minHeight = 84,
|
|
1754
|
+
c,
|
|
1755
|
+
align = "center",
|
|
1756
|
+
padding = "14px 16px",
|
|
1757
|
+
radius = 10,
|
|
1758
|
+
shadow = true,
|
|
1759
|
+
math = false
|
|
1760
|
+
}) {
|
|
1761
|
+
const accent = getToneColor(tone, c);
|
|
1762
|
+
const textAlign = align;
|
|
1763
|
+
const crossAlign = align === "center" ? "center" : "flex-start";
|
|
1764
|
+
const detailLines = (lines ?? []).map((line, index) => React.createElement(
|
|
1765
|
+
"div",
|
|
1766
|
+
{
|
|
1767
|
+
key: `tile-line-${index}`,
|
|
1768
|
+
style: {
|
|
1769
|
+
display: "flex",
|
|
1770
|
+
alignItems: "center",
|
|
1771
|
+
justifyContent: align === "center" ? "center" : "flex-start",
|
|
1772
|
+
gap: 6,
|
|
1773
|
+
...typography.tiny,
|
|
1774
|
+
color: c.textSecondary,
|
|
1775
|
+
lineHeight: 1.3,
|
|
1776
|
+
textAlign
|
|
1777
|
+
}
|
|
1778
|
+
},
|
|
1779
|
+
React.createElement("span", {
|
|
1780
|
+
style: {
|
|
1781
|
+
display: "flex",
|
|
1782
|
+
width: 4,
|
|
1783
|
+
height: 4,
|
|
1784
|
+
borderRadius: 999,
|
|
1785
|
+
backgroundColor: accent,
|
|
1786
|
+
flexShrink: 0
|
|
1787
|
+
}
|
|
1788
|
+
}),
|
|
1789
|
+
renderMaybeMath(line, math)
|
|
1790
|
+
));
|
|
1791
|
+
return Card({
|
|
1792
|
+
c,
|
|
1793
|
+
width,
|
|
1794
|
+
minHeight,
|
|
1795
|
+
padding,
|
|
1796
|
+
radius,
|
|
1797
|
+
shadow,
|
|
1798
|
+
borderColor: `${accent}88`,
|
|
1799
|
+
children: React.createElement(
|
|
1800
|
+
"div",
|
|
1801
|
+
{
|
|
1802
|
+
style: {
|
|
1803
|
+
width: "100%",
|
|
1804
|
+
display: "flex",
|
|
1805
|
+
flexDirection: "column",
|
|
1806
|
+
justifyContent: "center",
|
|
1807
|
+
alignItems: crossAlign,
|
|
1808
|
+
gap: 5
|
|
1809
|
+
}
|
|
1810
|
+
},
|
|
1811
|
+
...compactChildren([
|
|
1812
|
+
icon != null && React.createElement("div", {
|
|
1813
|
+
style: { display: "flex", fontSize: 22, lineHeight: 1 }
|
|
1814
|
+
}, icon),
|
|
1815
|
+
eyebrow != null && React.createElement("div", {
|
|
1816
|
+
style: {
|
|
1817
|
+
...typography.tiny,
|
|
1818
|
+
color: c.textMuted,
|
|
1819
|
+
fontWeight: 800,
|
|
1820
|
+
textTransform: "uppercase",
|
|
1821
|
+
letterSpacing: "0.05em",
|
|
1822
|
+
lineHeight: 1.2,
|
|
1823
|
+
textAlign
|
|
1824
|
+
}
|
|
1825
|
+
}, renderMaybeMath(eyebrow, math)),
|
|
1826
|
+
React.createElement("div", {
|
|
1827
|
+
style: {
|
|
1828
|
+
...typography.label,
|
|
1829
|
+
color: accent,
|
|
1830
|
+
fontWeight: 800,
|
|
1831
|
+
lineHeight: 1.15,
|
|
1832
|
+
textAlign
|
|
1833
|
+
}
|
|
1834
|
+
}, renderMaybeMath(title, math)),
|
|
1835
|
+
subtitle != null && React.createElement("div", {
|
|
1836
|
+
style: {
|
|
1837
|
+
...typography.tiny,
|
|
1838
|
+
color: c.textSecondary,
|
|
1839
|
+
lineHeight: 1.3,
|
|
1840
|
+
textAlign
|
|
1841
|
+
}
|
|
1842
|
+
}, renderMaybeMath(subtitle, math)),
|
|
1843
|
+
detailLines.length > 0 && React.createElement("div", {
|
|
1844
|
+
style: {
|
|
1845
|
+
width: "100%",
|
|
1846
|
+
display: "flex",
|
|
1847
|
+
flexDirection: "column",
|
|
1848
|
+
gap: 4,
|
|
1849
|
+
marginTop: 2
|
|
1850
|
+
}
|
|
1851
|
+
}, ...detailLines),
|
|
1852
|
+
children
|
|
1853
|
+
])
|
|
1854
|
+
)
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
function TileGrid({
|
|
1858
|
+
tiles,
|
|
1859
|
+
c,
|
|
1860
|
+
columns,
|
|
1861
|
+
gap = 12,
|
|
1862
|
+
tileWidth,
|
|
1863
|
+
minHeight,
|
|
1864
|
+
align = "center",
|
|
1865
|
+
math = false
|
|
1866
|
+
}) {
|
|
1867
|
+
const renderTile = (tile, index) => React.createElement(
|
|
1868
|
+
React.Fragment,
|
|
1869
|
+
{ key: `tile-${index}` },
|
|
1870
|
+
Tile({
|
|
1871
|
+
...tile,
|
|
1872
|
+
c,
|
|
1873
|
+
align,
|
|
1874
|
+
math,
|
|
1875
|
+
width: tile.width ?? tileWidth,
|
|
1876
|
+
minHeight: tile.minHeight ?? minHeight
|
|
1877
|
+
})
|
|
1878
|
+
);
|
|
1879
|
+
if (!columns || columns >= tiles.length) {
|
|
1880
|
+
return Row({ gap, align: "stretch", justify: "center", wrap: true, children: tiles.map(renderTile) });
|
|
1881
|
+
}
|
|
1882
|
+
const rows = [];
|
|
1883
|
+
for (let i = 0; i < tiles.length; i += columns) {
|
|
1884
|
+
rows.push(tiles.slice(i, i + columns));
|
|
1885
|
+
}
|
|
1886
|
+
return Column({
|
|
1887
|
+
gap,
|
|
1888
|
+
align: "stretch",
|
|
1889
|
+
children: rows.map((rowTiles, rowIndex) => React.createElement(
|
|
1890
|
+
React.Fragment,
|
|
1891
|
+
{ key: `tile-row-${rowIndex}` },
|
|
1892
|
+
Row({ gap, align: "stretch", justify: "center", children: rowTiles.map((tile, colIndex) => renderTile(tile, rowIndex * columns + colIndex)) })
|
|
1893
|
+
))
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
function isCodeLineSpec(line) {
|
|
1897
|
+
return typeof line === "object" && line !== null && !React.isValidElement(line) && "text" in line;
|
|
1898
|
+
}
|
|
1899
|
+
function CodeBlock({
|
|
1900
|
+
lines,
|
|
1901
|
+
c,
|
|
1902
|
+
title,
|
|
1903
|
+
tone,
|
|
1904
|
+
width,
|
|
1905
|
+
minWidth,
|
|
1906
|
+
fontSize = 12,
|
|
1907
|
+
showLineNumbers = false,
|
|
1908
|
+
padding = 14,
|
|
1909
|
+
radius = 10,
|
|
1910
|
+
background,
|
|
1911
|
+
shadow = false,
|
|
1912
|
+
math = false
|
|
1913
|
+
}) {
|
|
1914
|
+
const headerAccent = tone ? getToneColor(tone, c) : c.textMuted;
|
|
1915
|
+
const numberWidth = String(lines.length).length * (fontSize * 0.62) + 8;
|
|
1916
|
+
const lineElements = lines.map((line, index) => {
|
|
1917
|
+
const spec = isCodeLineSpec(line) ? line : { text: line };
|
|
1918
|
+
const accent = spec.tone ? getToneColor(spec.tone, c) : void 0;
|
|
1919
|
+
const textColor = spec.dim ? c.textMuted : accent ?? c.textSecondary;
|
|
1920
|
+
return React.createElement(
|
|
1921
|
+
"div",
|
|
1922
|
+
{
|
|
1923
|
+
key: `code-line-${index}`,
|
|
1924
|
+
style: {
|
|
1925
|
+
display: "flex",
|
|
1926
|
+
alignItems: "flex-start",
|
|
1927
|
+
gap: 8,
|
|
1928
|
+
width: "100%",
|
|
1929
|
+
padding: accent ? "3px 7px" : "1px 0",
|
|
1930
|
+
borderRadius: accent ? 5 : 0,
|
|
1931
|
+
...accent ? { backgroundColor: `${accent}1f` } : {},
|
|
1932
|
+
boxSizing: "border-box"
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
...compactChildren([
|
|
1936
|
+
showLineNumbers && React.createElement("div", {
|
|
1937
|
+
style: {
|
|
1938
|
+
display: "flex",
|
|
1939
|
+
width: numberWidth,
|
|
1940
|
+
flexShrink: 0,
|
|
1941
|
+
justifyContent: "flex-end",
|
|
1942
|
+
color: c.textMuted,
|
|
1943
|
+
fontFamily: "JetBrains Mono",
|
|
1944
|
+
fontSize: fontSize - 1,
|
|
1945
|
+
lineHeight: 1.5,
|
|
1946
|
+
opacity: 0.7
|
|
1947
|
+
}
|
|
1948
|
+
}, String(index + 1)),
|
|
1949
|
+
spec.prefix != null && React.createElement("div", {
|
|
1950
|
+
style: {
|
|
1951
|
+
display: "flex",
|
|
1952
|
+
flexShrink: 0,
|
|
1953
|
+
color: accent ?? c.textMuted,
|
|
1954
|
+
fontFamily: "JetBrains Mono",
|
|
1955
|
+
fontWeight: 800,
|
|
1956
|
+
fontSize,
|
|
1957
|
+
lineHeight: 1.5
|
|
1958
|
+
}
|
|
1959
|
+
}, spec.prefix),
|
|
1960
|
+
React.createElement("div", {
|
|
1961
|
+
style: {
|
|
1962
|
+
display: "flex",
|
|
1963
|
+
flex: 1,
|
|
1964
|
+
color: textColor,
|
|
1965
|
+
fontFamily: "JetBrains Mono",
|
|
1966
|
+
fontWeight: accent ? 700 : 500,
|
|
1967
|
+
fontSize,
|
|
1968
|
+
lineHeight: 1.5,
|
|
1969
|
+
whiteSpace: "pre-wrap"
|
|
1970
|
+
}
|
|
1971
|
+
}, math && typeof spec.text === "string" ? formatMathText(spec.text) : spec.text)
|
|
1972
|
+
])
|
|
1973
|
+
);
|
|
1974
|
+
});
|
|
1975
|
+
return React.createElement(
|
|
1976
|
+
"div",
|
|
1977
|
+
{
|
|
1978
|
+
style: {
|
|
1979
|
+
display: "flex",
|
|
1980
|
+
flexDirection: "column",
|
|
1981
|
+
gap: 8,
|
|
1982
|
+
...width != null ? { width } : {},
|
|
1983
|
+
...minWidth != null ? { minWidth } : {},
|
|
1984
|
+
padding,
|
|
1985
|
+
borderRadius: radius,
|
|
1986
|
+
backgroundColor: background ?? c.bgSubtle,
|
|
1987
|
+
border: `1px solid ${tone ? `${headerAccent}44` : c.borderSubtle}`,
|
|
1988
|
+
boxSizing: "border-box",
|
|
1989
|
+
...shadow ? { boxShadow: `0 9px 24px ${c.shadow}` } : {}
|
|
1990
|
+
}
|
|
1991
|
+
},
|
|
1992
|
+
...compactChildren([
|
|
1993
|
+
title != null && React.createElement(
|
|
1994
|
+
"div",
|
|
1995
|
+
{
|
|
1996
|
+
style: {
|
|
1997
|
+
display: "flex",
|
|
1998
|
+
alignItems: "center",
|
|
1999
|
+
gap: 8,
|
|
2000
|
+
paddingBottom: 8,
|
|
2001
|
+
borderBottom: `1px solid ${c.borderSubtle}`,
|
|
2002
|
+
color: c.textSecondary,
|
|
2003
|
+
fontFamily: "JetBrains Mono",
|
|
2004
|
+
fontSize: fontSize - 1,
|
|
2005
|
+
fontWeight: 800,
|
|
2006
|
+
letterSpacing: "0.02em"
|
|
2007
|
+
}
|
|
2008
|
+
},
|
|
2009
|
+
React.createElement("span", {
|
|
2010
|
+
style: {
|
|
2011
|
+
display: "flex",
|
|
2012
|
+
width: 8,
|
|
2013
|
+
height: 8,
|
|
2014
|
+
borderRadius: 999,
|
|
2015
|
+
backgroundColor: headerAccent,
|
|
2016
|
+
flexShrink: 0
|
|
2017
|
+
}
|
|
2018
|
+
}),
|
|
2019
|
+
renderMaybeMath(title, math)
|
|
2020
|
+
),
|
|
2021
|
+
React.createElement("div", {
|
|
2022
|
+
style: {
|
|
2023
|
+
display: "flex",
|
|
2024
|
+
flexDirection: "column",
|
|
2025
|
+
gap: 2,
|
|
2026
|
+
width: "100%"
|
|
2027
|
+
}
|
|
2028
|
+
}, ...lineElements)
|
|
2029
|
+
])
|
|
2030
|
+
);
|
|
2031
|
+
}
|
|
2032
|
+
function renderComparisonDivider(divider, c, key) {
|
|
2033
|
+
const label = divider === true ? "vs" : divider;
|
|
2034
|
+
return React.createElement(
|
|
2035
|
+
"div",
|
|
2036
|
+
{
|
|
2037
|
+
key,
|
|
2038
|
+
style: {
|
|
2039
|
+
display: "flex",
|
|
2040
|
+
flexDirection: "column",
|
|
2041
|
+
alignItems: "center",
|
|
2042
|
+
justifyContent: "center",
|
|
2043
|
+
alignSelf: "stretch",
|
|
2044
|
+
flexShrink: 0
|
|
2045
|
+
}
|
|
2046
|
+
},
|
|
2047
|
+
React.createElement("div", {
|
|
2048
|
+
style: {
|
|
2049
|
+
display: "flex",
|
|
2050
|
+
alignItems: "center",
|
|
2051
|
+
justifyContent: "center",
|
|
2052
|
+
minWidth: 30,
|
|
2053
|
+
height: 30,
|
|
2054
|
+
padding: "0 8px",
|
|
2055
|
+
borderRadius: 999,
|
|
2056
|
+
backgroundColor: c.bgCard,
|
|
2057
|
+
border: `1px solid ${c.borderLight}`,
|
|
2058
|
+
color: c.textMuted,
|
|
2059
|
+
fontFamily: "Inter",
|
|
2060
|
+
fontSize: 11,
|
|
2061
|
+
fontWeight: 900,
|
|
2062
|
+
textTransform: "uppercase",
|
|
2063
|
+
letterSpacing: "0.06em",
|
|
2064
|
+
boxShadow: `0 4px 12px ${c.shadow}`
|
|
2065
|
+
}
|
|
2066
|
+
}, label)
|
|
2067
|
+
);
|
|
2068
|
+
}
|
|
2069
|
+
function Comparison({
|
|
2070
|
+
sides,
|
|
2071
|
+
c,
|
|
2072
|
+
divider = false,
|
|
2073
|
+
gap = 14,
|
|
2074
|
+
sideWidth,
|
|
2075
|
+
minHeight,
|
|
2076
|
+
align = "stretch",
|
|
2077
|
+
math = false
|
|
2078
|
+
}) {
|
|
2079
|
+
const children = sides.flatMap((side, index) => {
|
|
2080
|
+
const tone = side.tone ?? "blue";
|
|
2081
|
+
const panel = React.createElement(
|
|
2082
|
+
React.Fragment,
|
|
2083
|
+
{ key: `comparison-side-${index}` },
|
|
2084
|
+
Panel({
|
|
2085
|
+
c,
|
|
2086
|
+
tone,
|
|
2087
|
+
title: side.title,
|
|
2088
|
+
subtitle: side.subtitle,
|
|
2089
|
+
footer: side.footer,
|
|
2090
|
+
width: side.width ?? sideWidth,
|
|
2091
|
+
minHeight,
|
|
2092
|
+
bodyStyle: { gap: 8 },
|
|
2093
|
+
children: side.eyebrow != null ? React.createElement(
|
|
2094
|
+
"div",
|
|
2095
|
+
{ style: { display: "flex", flexDirection: "column", gap: 8 } },
|
|
2096
|
+
React.createElement("div", {
|
|
2097
|
+
style: {
|
|
2098
|
+
...typography.tiny,
|
|
2099
|
+
color: c.textMuted,
|
|
2100
|
+
fontWeight: 800,
|
|
2101
|
+
textTransform: "uppercase",
|
|
2102
|
+
letterSpacing: "0.05em"
|
|
2103
|
+
}
|
|
2104
|
+
}, renderMaybeMath(side.eyebrow, math)),
|
|
2105
|
+
side.children ?? DetailList({ items: side.lines ?? [], c, tone, math })
|
|
2106
|
+
) : side.children ?? DetailList({ items: side.lines ?? [], c, tone, math })
|
|
2107
|
+
})
|
|
2108
|
+
);
|
|
2109
|
+
if (divider && index < sides.length - 1) {
|
|
2110
|
+
return [panel, renderComparisonDivider(divider, c, `comparison-divider-${index}`)];
|
|
2111
|
+
}
|
|
2112
|
+
return [panel];
|
|
2113
|
+
});
|
|
2114
|
+
return Row({ gap, align, justify: "center", children });
|
|
2115
|
+
}
|
|
2116
|
+
function KeyValueList({
|
|
2117
|
+
rows,
|
|
2118
|
+
c,
|
|
2119
|
+
title,
|
|
2120
|
+
width,
|
|
2121
|
+
minWidth,
|
|
2122
|
+
keyWidth,
|
|
2123
|
+
gap = 0,
|
|
2124
|
+
fontSize = 11,
|
|
2125
|
+
divider = true,
|
|
2126
|
+
keyMono = false,
|
|
2127
|
+
math = false
|
|
2128
|
+
}) {
|
|
2129
|
+
const rowElements = rows.map((row, index) => {
|
|
2130
|
+
const accent = row.tone ? getToneColor(row.tone, c) : void 0;
|
|
2131
|
+
const isLast = index === rows.length - 1;
|
|
2132
|
+
const valueMono = row.valueMono ?? true;
|
|
2133
|
+
return React.createElement(
|
|
2134
|
+
"div",
|
|
2135
|
+
{
|
|
2136
|
+
key: `kv-row-${index}`,
|
|
2137
|
+
style: {
|
|
2138
|
+
display: "flex",
|
|
2139
|
+
alignItems: "center",
|
|
2140
|
+
justifyContent: "space-between",
|
|
2141
|
+
gap: 14,
|
|
2142
|
+
width: "100%",
|
|
2143
|
+
padding: divider ? "7px 0" : "4px 0",
|
|
2144
|
+
...divider && !isLast ? { borderBottom: `1px solid ${c.borderSubtle}` } : {},
|
|
2145
|
+
boxSizing: "border-box"
|
|
2146
|
+
}
|
|
2147
|
+
},
|
|
2148
|
+
React.createElement("div", {
|
|
2149
|
+
style: {
|
|
2150
|
+
display: "flex",
|
|
2151
|
+
...keyWidth != null ? { width: keyWidth, flexShrink: 0 } : {},
|
|
2152
|
+
color: c.textSecondary,
|
|
2153
|
+
fontFamily: keyMono ? "JetBrains Mono" : "Inter",
|
|
2154
|
+
fontSize,
|
|
2155
|
+
fontWeight: 600,
|
|
2156
|
+
lineHeight: 1.3
|
|
2157
|
+
}
|
|
2158
|
+
}, renderMaybeMath(row.key, math)),
|
|
2159
|
+
React.createElement("div", {
|
|
2160
|
+
style: {
|
|
2161
|
+
display: "flex",
|
|
2162
|
+
flex: 1,
|
|
2163
|
+
justifyContent: "flex-end",
|
|
2164
|
+
textAlign: "right",
|
|
2165
|
+
color: accent ?? c.textPrimary,
|
|
2166
|
+
fontFamily: valueMono ? "JetBrains Mono" : "Inter",
|
|
2167
|
+
fontSize,
|
|
2168
|
+
fontWeight: 800,
|
|
2169
|
+
lineHeight: 1.3
|
|
2170
|
+
}
|
|
2171
|
+
}, renderMaybeMath(row.value, math))
|
|
2172
|
+
);
|
|
2173
|
+
});
|
|
2174
|
+
return React.createElement(
|
|
2175
|
+
"div",
|
|
2176
|
+
{
|
|
2177
|
+
style: {
|
|
2178
|
+
display: "flex",
|
|
2179
|
+
flexDirection: "column",
|
|
2180
|
+
gap,
|
|
2181
|
+
...width != null ? { width } : {},
|
|
2182
|
+
...minWidth != null ? { minWidth } : {}
|
|
2183
|
+
}
|
|
2184
|
+
},
|
|
2185
|
+
...compactChildren([
|
|
2186
|
+
title != null && React.createElement("div", {
|
|
2187
|
+
style: {
|
|
2188
|
+
display: "flex",
|
|
2189
|
+
...typography.tiny,
|
|
2190
|
+
color: c.textMuted,
|
|
2191
|
+
fontWeight: 800,
|
|
2192
|
+
textTransform: "uppercase",
|
|
2193
|
+
letterSpacing: "0.05em",
|
|
2194
|
+
paddingBottom: 4
|
|
2195
|
+
}
|
|
2196
|
+
}, renderMaybeMath(title, math)),
|
|
2197
|
+
...rowElements
|
|
2198
|
+
])
|
|
2199
|
+
);
|
|
2200
|
+
}
|
|
2201
|
+
function WindowFrame({
|
|
2202
|
+
c,
|
|
2203
|
+
children,
|
|
2204
|
+
title,
|
|
2205
|
+
variant = "window",
|
|
2206
|
+
tone = "blue",
|
|
2207
|
+
dots = true,
|
|
2208
|
+
width,
|
|
2209
|
+
minWidth,
|
|
2210
|
+
height,
|
|
2211
|
+
minHeight,
|
|
2212
|
+
padding = 16,
|
|
2213
|
+
radius = 10,
|
|
2214
|
+
shadow = true,
|
|
2215
|
+
background,
|
|
2216
|
+
bodyStyle
|
|
2217
|
+
}) {
|
|
2218
|
+
const isTerminal = variant === "terminal";
|
|
2219
|
+
const surface = background ?? (isTerminal ? c.bgSubtle : c.bgCard);
|
|
2220
|
+
const accent = getToneColor(tone, c);
|
|
2221
|
+
const trafficDot = (color, key) => React.createElement("span", {
|
|
2222
|
+
key,
|
|
2223
|
+
style: { display: "flex", width: 10, height: 10, borderRadius: 999, backgroundColor: color }
|
|
2224
|
+
});
|
|
2225
|
+
const titleBar = React.createElement(
|
|
2226
|
+
"div",
|
|
2227
|
+
{
|
|
2228
|
+
style: {
|
|
2229
|
+
display: "flex",
|
|
2230
|
+
alignItems: "center",
|
|
2231
|
+
gap: 10,
|
|
2232
|
+
width: "100%",
|
|
2233
|
+
padding: "8px 12px",
|
|
2234
|
+
backgroundColor: isTerminal ? c.bg === "transparent" ? c.bgHover : c.bgHover : c.bgSubtle,
|
|
2235
|
+
borderBottom: `1px solid ${c.borderSubtle}`,
|
|
2236
|
+
boxSizing: "border-box"
|
|
2237
|
+
}
|
|
2238
|
+
},
|
|
2239
|
+
...compactChildren([
|
|
2240
|
+
dots && React.createElement(
|
|
2241
|
+
"div",
|
|
2242
|
+
{
|
|
2243
|
+
style: { display: "flex", alignItems: "center", gap: 6, flexShrink: 0 }
|
|
2244
|
+
},
|
|
2245
|
+
trafficDot(c.criticalLight, "dot-r"),
|
|
2246
|
+
trafficDot(c.warningLight, "dot-y"),
|
|
2247
|
+
trafficDot(c.positiveLight, "dot-g")
|
|
2248
|
+
),
|
|
2249
|
+
title != null && (variant === "browser" ? React.createElement("div", {
|
|
2250
|
+
style: {
|
|
2251
|
+
display: "flex",
|
|
2252
|
+
flex: 1,
|
|
2253
|
+
alignItems: "center",
|
|
2254
|
+
height: 22,
|
|
2255
|
+
padding: "0 12px",
|
|
2256
|
+
borderRadius: 999,
|
|
2257
|
+
backgroundColor: c.bgCard,
|
|
2258
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
2259
|
+
color: c.textSecondary,
|
|
2260
|
+
fontFamily: "JetBrains Mono",
|
|
2261
|
+
fontSize: 11,
|
|
2262
|
+
fontWeight: 600,
|
|
2263
|
+
lineHeight: 1
|
|
2264
|
+
}
|
|
2265
|
+
}, title) : React.createElement("div", {
|
|
2266
|
+
style: {
|
|
2267
|
+
display: "flex",
|
|
2268
|
+
flex: 1,
|
|
2269
|
+
justifyContent: dots ? "center" : "flex-start",
|
|
2270
|
+
color: isTerminal ? accent : c.textSecondary,
|
|
2271
|
+
fontFamily: isTerminal ? "JetBrains Mono" : "Inter",
|
|
2272
|
+
fontSize: 12,
|
|
2273
|
+
fontWeight: 700,
|
|
2274
|
+
lineHeight: 1
|
|
2275
|
+
}
|
|
2276
|
+
}, title)),
|
|
2277
|
+
dots && title != null && variant !== "browser" && React.createElement("div", {
|
|
2278
|
+
style: { display: "flex", width: 52, flexShrink: 0 }
|
|
2279
|
+
}, "")
|
|
2280
|
+
])
|
|
2281
|
+
);
|
|
2282
|
+
return React.createElement(
|
|
2283
|
+
"div",
|
|
2284
|
+
{
|
|
2285
|
+
style: {
|
|
2286
|
+
display: "flex",
|
|
2287
|
+
flexDirection: "column",
|
|
2288
|
+
...width != null ? { width } : {},
|
|
2289
|
+
...minWidth != null ? { minWidth } : {},
|
|
2290
|
+
...height != null ? { height } : {},
|
|
2291
|
+
...minHeight != null ? { minHeight } : {},
|
|
2292
|
+
borderRadius: radius,
|
|
2293
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
2294
|
+
backgroundColor: surface,
|
|
2295
|
+
overflow: "hidden",
|
|
2296
|
+
boxSizing: "border-box",
|
|
2297
|
+
...shadow ? { boxShadow: `0 12px 30px ${c.shadow}` } : {}
|
|
2298
|
+
}
|
|
2299
|
+
},
|
|
2300
|
+
titleBar,
|
|
2301
|
+
React.createElement("div", {
|
|
2302
|
+
style: {
|
|
2303
|
+
display: "flex",
|
|
2304
|
+
flexDirection: "column",
|
|
2305
|
+
width: "100%",
|
|
2306
|
+
padding,
|
|
2307
|
+
boxSizing: "border-box",
|
|
2308
|
+
...isTerminal ? { fontFamily: "JetBrains Mono", color: c.textSecondary } : {},
|
|
2309
|
+
...bodyStyle
|
|
2310
|
+
}
|
|
2311
|
+
}, children)
|
|
2312
|
+
);
|
|
2313
|
+
}
|
|
2314
|
+
var statusGlyphs = {
|
|
2315
|
+
check: "\u2713",
|
|
2316
|
+
cross: "\u2717",
|
|
2317
|
+
warn: "!",
|
|
2318
|
+
info: "i",
|
|
2319
|
+
pending: "\u2013",
|
|
2320
|
+
dot: ""
|
|
2321
|
+
};
|
|
2322
|
+
var statusTones = {
|
|
2323
|
+
check: "green",
|
|
2324
|
+
cross: "red",
|
|
2325
|
+
warn: "warm",
|
|
2326
|
+
info: "blue",
|
|
2327
|
+
pending: "neutral",
|
|
2328
|
+
dot: "blue"
|
|
2329
|
+
};
|
|
2330
|
+
function StatusRow({
|
|
2331
|
+
label,
|
|
2332
|
+
detail,
|
|
2333
|
+
status = "check",
|
|
2334
|
+
tone,
|
|
2335
|
+
c,
|
|
2336
|
+
boxed = true,
|
|
2337
|
+
fontSize = 11,
|
|
2338
|
+
width,
|
|
2339
|
+
math = false
|
|
2340
|
+
}) {
|
|
2341
|
+
const accent = getToneColor(tone ?? statusTones[status], c);
|
|
2342
|
+
const glyph = statusGlyphs[status];
|
|
2343
|
+
const marker = React.createElement("div", {
|
|
2344
|
+
style: {
|
|
2345
|
+
display: "flex",
|
|
2346
|
+
alignItems: "center",
|
|
2347
|
+
justifyContent: "center",
|
|
2348
|
+
width: 18,
|
|
2349
|
+
height: 18,
|
|
2350
|
+
flexShrink: 0,
|
|
2351
|
+
borderRadius: 999,
|
|
2352
|
+
backgroundColor: status === "dot" ? accent : `${accent}26`,
|
|
2353
|
+
border: `1px solid ${accent}`,
|
|
2354
|
+
color: accent,
|
|
2355
|
+
fontFamily: "Inter",
|
|
2356
|
+
fontSize: status === "warn" || status === "info" ? 12 : 11,
|
|
2357
|
+
fontWeight: 900,
|
|
2358
|
+
lineHeight: 1
|
|
2359
|
+
}
|
|
2360
|
+
}, glyph);
|
|
2361
|
+
return React.createElement(
|
|
2362
|
+
"div",
|
|
2363
|
+
{
|
|
2364
|
+
style: {
|
|
2365
|
+
display: "flex",
|
|
2366
|
+
alignItems: "center",
|
|
2367
|
+
gap: 9,
|
|
2368
|
+
width: width ?? "100%",
|
|
2369
|
+
boxSizing: "border-box",
|
|
2370
|
+
...boxed ? {
|
|
2371
|
+
padding: "7px 10px",
|
|
2372
|
+
borderRadius: 8,
|
|
2373
|
+
backgroundColor: `${accent}12`,
|
|
2374
|
+
border: `1px solid ${accent}3a`
|
|
2375
|
+
} : { padding: "3px 0" }
|
|
2376
|
+
}
|
|
2377
|
+
},
|
|
2378
|
+
marker,
|
|
2379
|
+
React.createElement("div", {
|
|
2380
|
+
style: {
|
|
2381
|
+
display: "flex",
|
|
2382
|
+
flex: 1,
|
|
2383
|
+
color: c.textPrimary,
|
|
2384
|
+
fontFamily: "Inter",
|
|
2385
|
+
fontSize,
|
|
2386
|
+
fontWeight: 600,
|
|
2387
|
+
lineHeight: 1.3
|
|
2388
|
+
}
|
|
2389
|
+
}, renderMaybeMath(label, math)),
|
|
2390
|
+
detail != null && React.createElement("div", {
|
|
2391
|
+
style: {
|
|
2392
|
+
display: "flex",
|
|
2393
|
+
flexShrink: 0,
|
|
2394
|
+
color: c.textSecondary,
|
|
2395
|
+
fontFamily: "Inter",
|
|
2396
|
+
fontSize: fontSize - 1,
|
|
2397
|
+
lineHeight: 1.3,
|
|
2398
|
+
textAlign: "right"
|
|
2399
|
+
}
|
|
2400
|
+
}, renderMaybeMath(detail, math))
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2403
|
+
function StatusList({
|
|
2404
|
+
rows,
|
|
2405
|
+
c,
|
|
2406
|
+
gap = 7,
|
|
2407
|
+
boxed = true,
|
|
2408
|
+
fontSize,
|
|
2409
|
+
width,
|
|
2410
|
+
math = false
|
|
2411
|
+
}) {
|
|
2412
|
+
return Column({
|
|
2413
|
+
gap,
|
|
2414
|
+
align: "stretch",
|
|
2415
|
+
...width != null ? { width } : {},
|
|
2416
|
+
children: rows.map((row, index) => React.createElement(
|
|
2417
|
+
React.Fragment,
|
|
2418
|
+
{ key: `status-${index}` },
|
|
2419
|
+
StatusRow({ ...row, c, boxed, fontSize, math })
|
|
2420
|
+
))
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
function renderFlowStage(stage, c, math) {
|
|
2424
|
+
const tone = stage.tone ?? "blue";
|
|
2425
|
+
const hasDetails = Boolean(stage.children || stage.lines?.length);
|
|
2426
|
+
if (!hasDetails) {
|
|
2427
|
+
return StepCard({
|
|
2428
|
+
title: stage.title,
|
|
2429
|
+
subtitle: stage.subtitle,
|
|
2430
|
+
eyebrow: stage.eyebrow,
|
|
2431
|
+
tone,
|
|
2432
|
+
c,
|
|
2433
|
+
width: stage.width,
|
|
2434
|
+
minWidth: stage.minWidth,
|
|
2435
|
+
minHeight: stage.minHeight,
|
|
2436
|
+
padding: stage.padding,
|
|
2437
|
+
math
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
return Panel({
|
|
2441
|
+
title: stage.title,
|
|
2442
|
+
subtitle: stage.subtitle,
|
|
2443
|
+
tone,
|
|
2444
|
+
c,
|
|
2445
|
+
width: stage.width,
|
|
2446
|
+
minWidth: stage.minWidth,
|
|
2447
|
+
minHeight: stage.minHeight,
|
|
2448
|
+
padding: stage.padding ?? 12,
|
|
2449
|
+
bodyStyle: { gap: 8 },
|
|
2450
|
+
children: stage.children ?? DetailList({ items: stage.lines ?? [], c, tone, math })
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
function Flow({
|
|
2454
|
+
stages,
|
|
2455
|
+
c,
|
|
2456
|
+
direction = "horizontal",
|
|
2457
|
+
gap = 10,
|
|
2458
|
+
connectorLength = 28,
|
|
2459
|
+
connectorTone = "neutral",
|
|
2460
|
+
align = "center",
|
|
2461
|
+
math = false
|
|
2462
|
+
}) {
|
|
2463
|
+
const isHorizontal = direction === "horizontal";
|
|
2464
|
+
const children = stages.flatMap((stage, index) => {
|
|
2465
|
+
const elements = [
|
|
2466
|
+
React.createElement(React.Fragment, { key: `stage-${index}` }, renderFlowStage(stage, c, math))
|
|
2467
|
+
];
|
|
2468
|
+
if (index < stages.length - 1) {
|
|
2469
|
+
elements.push(React.createElement(
|
|
2470
|
+
React.Fragment,
|
|
2471
|
+
{ key: `connector-${index}` },
|
|
2472
|
+
FlowArrow({
|
|
2473
|
+
direction: isHorizontal ? "right" : "down",
|
|
2474
|
+
length: connectorLength,
|
|
2475
|
+
c,
|
|
2476
|
+
tone: connectorTone
|
|
2477
|
+
})
|
|
2478
|
+
));
|
|
2479
|
+
}
|
|
2480
|
+
return elements;
|
|
2481
|
+
});
|
|
2482
|
+
return (isHorizontal ? Row : Column)({
|
|
2483
|
+
gap,
|
|
2484
|
+
align,
|
|
2485
|
+
justify: "center",
|
|
2486
|
+
children
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
function distributeValues(count, start, end) {
|
|
2490
|
+
if (count <= 1) return [(start + end) / 2];
|
|
2491
|
+
const step = (end - start) / (count - 1);
|
|
2492
|
+
return Array.from({ length: count }, (_, index) => start + index * step);
|
|
2493
|
+
}
|
|
2494
|
+
function LayeredNetwork({
|
|
2495
|
+
c,
|
|
2496
|
+
layers,
|
|
2497
|
+
activePath = [],
|
|
2498
|
+
annotations = [],
|
|
2499
|
+
formula,
|
|
2500
|
+
legend = "highlighted path",
|
|
2501
|
+
width = 900,
|
|
2502
|
+
height = 400,
|
|
2503
|
+
nodeSize = 56,
|
|
2504
|
+
showFormula = true
|
|
2505
|
+
}) {
|
|
2506
|
+
const radius = nodeSize / 2;
|
|
2507
|
+
const top = 82;
|
|
2508
|
+
const bottom = showFormula || formula ? height - 118 : height - 42;
|
|
2509
|
+
const layerXs = distributeValues(layers.length, 82, width - 82);
|
|
2510
|
+
const nodeLayout = layers.map((layer, layerIndex) => ({
|
|
2511
|
+
...layer,
|
|
2512
|
+
x: layerXs[layerIndex],
|
|
2513
|
+
ys: distributeValues(layer.nodes.length, top, bottom),
|
|
2514
|
+
tone: layer.tone ?? "purple"
|
|
2515
|
+
}));
|
|
2516
|
+
const connectionElements = nodeLayout.slice(0, -1).flatMap((from, layerIndex) => {
|
|
2517
|
+
const to = nodeLayout[layerIndex + 1];
|
|
2518
|
+
return from.ys.flatMap(
|
|
2519
|
+
(fromY, fromIndex) => to.ys.map((toY, toIndex) => {
|
|
2520
|
+
const active = activePath[layerIndex] === fromIndex && activePath[layerIndex + 1] === toIndex;
|
|
2521
|
+
return React.createElement("line", {
|
|
2522
|
+
key: `connection-${layerIndex}-${fromIndex}-${toIndex}`,
|
|
2523
|
+
x1: from.x + radius + 4,
|
|
2524
|
+
y1: fromY,
|
|
2525
|
+
x2: to.x - radius - 4,
|
|
2526
|
+
y2: toY,
|
|
2527
|
+
stroke: active ? c.warningLight : c.borderLight,
|
|
2528
|
+
strokeWidth: active ? 3.6 : 1.2,
|
|
2529
|
+
strokeOpacity: active ? 0.98 : 0.42,
|
|
2530
|
+
strokeLinecap: "round"
|
|
2531
|
+
});
|
|
2532
|
+
})
|
|
2533
|
+
);
|
|
2534
|
+
});
|
|
2535
|
+
const label = (key, text, x, y, labelWidth, color, fontSize = 13, fontWeight = 800, fontFamily = "Inter") => React.createElement("div", {
|
|
2536
|
+
key,
|
|
2537
|
+
style: {
|
|
2538
|
+
position: "absolute",
|
|
2539
|
+
left: x - labelWidth / 2,
|
|
2540
|
+
top: y,
|
|
2541
|
+
width: labelWidth,
|
|
2542
|
+
display: "flex",
|
|
2543
|
+
justifyContent: "center",
|
|
2544
|
+
color,
|
|
2545
|
+
fontSize,
|
|
2546
|
+
fontWeight,
|
|
2547
|
+
fontFamily,
|
|
2548
|
+
lineHeight: 1.15,
|
|
2549
|
+
textAlign: "center"
|
|
2550
|
+
}
|
|
2551
|
+
}, formatMathText(text));
|
|
2552
|
+
const titleElements = nodeLayout.map(
|
|
2553
|
+
(layer) => label(`title-${layer.title}`, layer.title, layer.x, 20, 120, getToneColor(layer.tone, c), 16, 900)
|
|
2554
|
+
);
|
|
2555
|
+
const nodeElements = nodeLayout.flatMap(
|
|
2556
|
+
(layer, layerIndex) => layer.ys.flatMap((y, nodeIndex) => {
|
|
2557
|
+
const active = activePath[layerIndex] === nodeIndex;
|
|
2558
|
+
const color = getToneColor(layer.tone, c);
|
|
2559
|
+
return [
|
|
2560
|
+
active && React.createElement("div", {
|
|
2561
|
+
key: `halo-${layerIndex}-${nodeIndex}`,
|
|
2562
|
+
style: {
|
|
2563
|
+
position: "absolute",
|
|
2564
|
+
left: layer.x - radius - 14,
|
|
2565
|
+
top: y - radius - 14,
|
|
2566
|
+
width: nodeSize + 28,
|
|
2567
|
+
height: nodeSize + 28,
|
|
2568
|
+
borderRadius: 999,
|
|
2569
|
+
backgroundColor: `${c.warningLight}2e`,
|
|
2570
|
+
border: `4px solid ${c.warningLight}`,
|
|
2571
|
+
boxSizing: "border-box",
|
|
2572
|
+
boxShadow: `0 0 18px ${c.warningLight}66`
|
|
2573
|
+
}
|
|
2574
|
+
}),
|
|
2575
|
+
React.createElement("div", {
|
|
2576
|
+
key: `node-${layerIndex}-${nodeIndex}`,
|
|
2577
|
+
style: {
|
|
2578
|
+
position: "absolute",
|
|
2579
|
+
left: layer.x - radius,
|
|
2580
|
+
top: y - radius,
|
|
2581
|
+
width: nodeSize,
|
|
2582
|
+
height: nodeSize,
|
|
2583
|
+
borderRadius: 999,
|
|
2584
|
+
display: "flex",
|
|
2585
|
+
alignItems: "center",
|
|
2586
|
+
justifyContent: "center",
|
|
2587
|
+
backgroundColor: color,
|
|
2588
|
+
color: c.textOnColor,
|
|
2589
|
+
border: active ? `3px solid ${c.warningLight}` : `1.5px solid ${color}`,
|
|
2590
|
+
boxSizing: "border-box",
|
|
2591
|
+
boxShadow: active ? `0 0 16px ${c.warningLight}70` : `0 8px 14px ${c.shadow}`,
|
|
2592
|
+
fontFamily: "JetBrains Mono",
|
|
2593
|
+
fontSize: 16,
|
|
2594
|
+
fontWeight: 900,
|
|
2595
|
+
lineHeight: 1
|
|
2596
|
+
}
|
|
2597
|
+
}, formatMathText(layer.nodes[nodeIndex]))
|
|
2598
|
+
];
|
|
2599
|
+
}).filter(Boolean)
|
|
2600
|
+
);
|
|
2601
|
+
const annotationY = showFormula || formula ? height - 84 : height - 26;
|
|
2602
|
+
const annotationElements = annotations.map(
|
|
2603
|
+
(annotation, index) => label(
|
|
2604
|
+
`annotation-${index}`,
|
|
2605
|
+
annotation,
|
|
2606
|
+
(layerXs[index] + layerXs[index + 1]) / 2,
|
|
2607
|
+
annotationY,
|
|
2608
|
+
132,
|
|
2609
|
+
c.textMuted,
|
|
2610
|
+
13,
|
|
2611
|
+
800,
|
|
2612
|
+
"JetBrains Mono"
|
|
2613
|
+
)
|
|
2614
|
+
);
|
|
2615
|
+
const formulaElement = (showFormula || formula) && formula ? React.createElement("div", {
|
|
2616
|
+
key: "formula-wrap",
|
|
2617
|
+
style: {
|
|
2618
|
+
position: "absolute",
|
|
2619
|
+
left: width / 2 - 244,
|
|
2620
|
+
top: height - 52,
|
|
2621
|
+
width: 488,
|
|
2622
|
+
height: 44,
|
|
2623
|
+
borderRadius: 10,
|
|
2624
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
2625
|
+
backgroundColor: c.bgCard,
|
|
2626
|
+
display: "flex",
|
|
2627
|
+
alignItems: "center",
|
|
2628
|
+
justifyContent: "center",
|
|
2629
|
+
color: c.textPrimary,
|
|
2630
|
+
fontFamily: "Inter",
|
|
2631
|
+
fontSize: 15,
|
|
2632
|
+
fontWeight: 850,
|
|
2633
|
+
boxShadow: `0 8px 18px ${c.shadow}`
|
|
2634
|
+
}
|
|
2635
|
+
}, formatMathText(formula)) : null;
|
|
2636
|
+
const legendElement = (showFormula || formula) && formula ? React.createElement(
|
|
2637
|
+
"div",
|
|
2638
|
+
{
|
|
2639
|
+
key: "legend-wrap",
|
|
2640
|
+
style: {
|
|
2641
|
+
position: "absolute",
|
|
2642
|
+
left: width - 184,
|
|
2643
|
+
top: height - 43,
|
|
2644
|
+
width: 160,
|
|
2645
|
+
display: "flex",
|
|
2646
|
+
alignItems: "center",
|
|
2647
|
+
gap: 14,
|
|
2648
|
+
color: c.textSecondary,
|
|
2649
|
+
fontFamily: "Inter",
|
|
2650
|
+
fontSize: 12,
|
|
2651
|
+
fontWeight: 800
|
|
2652
|
+
}
|
|
2653
|
+
},
|
|
2654
|
+
React.createElement("div", {
|
|
2655
|
+
style: {
|
|
2656
|
+
width: 42,
|
|
2657
|
+
height: 5,
|
|
2658
|
+
borderRadius: 999,
|
|
2659
|
+
backgroundColor: c.warningLight
|
|
2660
|
+
}
|
|
2661
|
+
}),
|
|
2662
|
+
legend
|
|
2663
|
+
) : null;
|
|
2664
|
+
return React.createElement(
|
|
2665
|
+
"div",
|
|
2666
|
+
{
|
|
2667
|
+
role: "img",
|
|
2668
|
+
style: {
|
|
2669
|
+
width,
|
|
2670
|
+
height,
|
|
2671
|
+
maxWidth: "100%",
|
|
2672
|
+
position: "relative",
|
|
2673
|
+
display: "flex",
|
|
2674
|
+
alignSelf: "center",
|
|
2675
|
+
flexShrink: 0
|
|
2676
|
+
}
|
|
2677
|
+
},
|
|
2678
|
+
React.createElement("svg", {
|
|
2679
|
+
width,
|
|
2680
|
+
height,
|
|
2681
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
2682
|
+
style: {
|
|
2683
|
+
position: "absolute",
|
|
2684
|
+
inset: 0,
|
|
2685
|
+
overflow: "visible"
|
|
2686
|
+
}
|
|
2687
|
+
}, ...connectionElements),
|
|
2688
|
+
...titleElements,
|
|
2689
|
+
...nodeElements,
|
|
2690
|
+
...annotationElements,
|
|
2691
|
+
formulaElement,
|
|
2692
|
+
legendElement
|
|
2693
|
+
);
|
|
2694
|
+
}
|
|
2695
|
+
function GraphDiagram({
|
|
2696
|
+
nodes,
|
|
2697
|
+
edges,
|
|
2698
|
+
c,
|
|
2699
|
+
width = 520,
|
|
2700
|
+
height = 420,
|
|
2701
|
+
nodeWidth = 150,
|
|
2702
|
+
nodeHeight = 66,
|
|
2703
|
+
padding = 28
|
|
2704
|
+
}) {
|
|
2705
|
+
const layout = new Map(nodes.map((node) => {
|
|
2706
|
+
const resolvedWidth = node.width ?? nodeWidth;
|
|
2707
|
+
const resolvedHeight = node.height ?? nodeHeight;
|
|
2708
|
+
return [node.id, {
|
|
2709
|
+
...node,
|
|
2710
|
+
width: resolvedWidth,
|
|
2711
|
+
height: resolvedHeight,
|
|
2712
|
+
cx: padding + clamp(node.x, 0, 1) * (width - padding * 2),
|
|
2713
|
+
cy: padding + clamp(node.y, 0, 1) * (height - padding * 2)
|
|
2714
|
+
}];
|
|
2715
|
+
}));
|
|
2716
|
+
const edgeLayouts = edges.flatMap((edge, index) => {
|
|
2717
|
+
const from = layout.get(edge.from);
|
|
2718
|
+
const to = layout.get(edge.to);
|
|
2719
|
+
if (!from || !to || from.cx === to.cx && from.cy === to.cy) return [];
|
|
2720
|
+
const dx = to.cx - from.cx;
|
|
2721
|
+
const dy = to.cy - from.cy;
|
|
2722
|
+
const absDx = Math.abs(dx);
|
|
2723
|
+
const absDy = Math.abs(dy);
|
|
2724
|
+
const fromScale = Math.min(
|
|
2725
|
+
absDx > 0 ? from.width / 2 / absDx : Infinity,
|
|
2726
|
+
absDy > 0 ? from.height / 2 / absDy : Infinity
|
|
2727
|
+
);
|
|
2728
|
+
const toScale = Math.min(
|
|
2729
|
+
absDx > 0 ? to.width / 2 / absDx : Infinity,
|
|
2730
|
+
absDy > 0 ? to.height / 2 / absDy : Infinity
|
|
2731
|
+
);
|
|
2732
|
+
const color = edge.muted ? c.textMuted : getToneColor(edge.tone ?? "blue", c);
|
|
2733
|
+
const markerId = `graph-arrow-${edge.from}-${edge.to}-${index}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
2734
|
+
return [{
|
|
2735
|
+
...edge,
|
|
2736
|
+
index,
|
|
2737
|
+
color,
|
|
2738
|
+
markerId,
|
|
2739
|
+
x1: from.cx + dx * fromScale,
|
|
2740
|
+
y1: from.cy + dy * fromScale,
|
|
2741
|
+
x2: to.cx - dx * toScale,
|
|
2742
|
+
y2: to.cy - dy * toScale
|
|
2743
|
+
}];
|
|
2744
|
+
});
|
|
2745
|
+
return React.createElement(
|
|
2746
|
+
"div",
|
|
2747
|
+
{
|
|
2748
|
+
role: "img",
|
|
2749
|
+
style: {
|
|
2750
|
+
position: "relative",
|
|
2751
|
+
display: "flex",
|
|
2752
|
+
width,
|
|
2753
|
+
height,
|
|
2754
|
+
maxWidth: "100%",
|
|
2755
|
+
flexShrink: 0
|
|
2756
|
+
}
|
|
2757
|
+
},
|
|
2758
|
+
React.createElement(
|
|
2759
|
+
"svg",
|
|
2760
|
+
{
|
|
2761
|
+
width,
|
|
2762
|
+
height,
|
|
2763
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
2764
|
+
style: { position: "absolute", inset: 0, overflow: "visible" }
|
|
2765
|
+
},
|
|
2766
|
+
React.createElement(
|
|
2767
|
+
"defs",
|
|
2768
|
+
{},
|
|
2769
|
+
...edgeLayouts.map((edge) => ArrowMarkerDef({
|
|
2770
|
+
id: edge.markerId,
|
|
2771
|
+
color: edge.color,
|
|
2772
|
+
size: 5
|
|
2773
|
+
}))
|
|
2774
|
+
),
|
|
2775
|
+
...edgeLayouts.map((edge) => React.createElement("line", {
|
|
2776
|
+
key: `graph-edge-${edge.index}`,
|
|
2777
|
+
x1: edge.x1,
|
|
2778
|
+
y1: edge.y1,
|
|
2779
|
+
x2: edge.x2,
|
|
2780
|
+
y2: edge.y2,
|
|
2781
|
+
stroke: edge.color,
|
|
2782
|
+
strokeWidth: edge.muted ? 1.6 : 2.8,
|
|
2783
|
+
strokeDasharray: edge.dashed ? "7 6" : void 0,
|
|
2784
|
+
strokeLinecap: "round",
|
|
2785
|
+
opacity: edge.muted ? 0.48 : 0.9,
|
|
2786
|
+
markerEnd: `url(#${edge.markerId})`
|
|
2787
|
+
}))
|
|
2788
|
+
),
|
|
2789
|
+
...edgeLayouts.flatMap((edge) => edge.label ? [
|
|
2790
|
+
React.createElement("div", {
|
|
2791
|
+
key: `graph-edge-label-${edge.index}`,
|
|
2792
|
+
style: {
|
|
2793
|
+
position: "absolute",
|
|
2794
|
+
left: (edge.x1 + edge.x2) / 2,
|
|
2795
|
+
top: (edge.y1 + edge.y2) / 2,
|
|
2796
|
+
transform: "translate(-50%, -50%)",
|
|
2797
|
+
padding: "3px 7px",
|
|
2798
|
+
borderRadius: 999,
|
|
2799
|
+
backgroundColor: c.bgCard,
|
|
2800
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
2801
|
+
color: edge.muted ? c.textMuted : edge.color,
|
|
2802
|
+
fontFamily: "JetBrains Mono",
|
|
2803
|
+
fontSize: 9,
|
|
2804
|
+
fontWeight: 800,
|
|
2805
|
+
lineHeight: 1,
|
|
2806
|
+
whiteSpace: "nowrap"
|
|
2807
|
+
}
|
|
2808
|
+
}, edge.label)
|
|
2809
|
+
] : []),
|
|
2810
|
+
...Array.from(layout.values()).map((node) => {
|
|
2811
|
+
const accent = node.muted ? c.textMuted : getToneColor(node.tone ?? "blue", c);
|
|
2812
|
+
return React.createElement(
|
|
2813
|
+
"div",
|
|
2814
|
+
{
|
|
2815
|
+
key: `graph-node-${node.id}`,
|
|
2816
|
+
style: {
|
|
2817
|
+
position: "absolute",
|
|
2818
|
+
left: node.cx - node.width / 2,
|
|
2819
|
+
top: node.cy - node.height / 2,
|
|
2820
|
+
width: node.width,
|
|
2821
|
+
height: node.height,
|
|
2822
|
+
display: "flex",
|
|
2823
|
+
flexDirection: "column",
|
|
2824
|
+
alignItems: "center",
|
|
2825
|
+
justifyContent: "center",
|
|
2826
|
+
gap: node.detail ? 5 : 0,
|
|
2827
|
+
padding: "8px 10px",
|
|
2828
|
+
boxSizing: "border-box",
|
|
2829
|
+
borderRadius: 10,
|
|
2830
|
+
backgroundColor: node.muted ? c.bgSubtle : `${accent}16`,
|
|
2831
|
+
border: `1.5px solid ${node.muted ? c.borderLight : `${accent}88`}`,
|
|
2832
|
+
...!node.muted ? { boxShadow: `0 8px 18px ${c.shadow}` } : {},
|
|
2833
|
+
opacity: node.muted ? 0.62 : 1,
|
|
2834
|
+
color: accent,
|
|
2835
|
+
textAlign: "center"
|
|
2836
|
+
}
|
|
2837
|
+
},
|
|
2838
|
+
React.createElement("div", {
|
|
2839
|
+
style: {
|
|
2840
|
+
fontFamily: "Inter",
|
|
2841
|
+
fontSize: 14,
|
|
2842
|
+
fontWeight: 900,
|
|
2843
|
+
lineHeight: 1.15
|
|
2844
|
+
}
|
|
2845
|
+
}, node.label),
|
|
2846
|
+
node.detail && React.createElement("div", {
|
|
2847
|
+
style: {
|
|
2848
|
+
color: c.textMuted,
|
|
2849
|
+
fontFamily: "JetBrains Mono",
|
|
2850
|
+
fontSize: 9,
|
|
2851
|
+
fontWeight: 650,
|
|
2852
|
+
lineHeight: 1.2
|
|
2853
|
+
}
|
|
2854
|
+
}, node.detail)
|
|
2855
|
+
);
|
|
2856
|
+
})
|
|
2857
|
+
);
|
|
2858
|
+
}
|
|
2859
|
+
function CalloutCard({
|
|
2860
|
+
c,
|
|
2861
|
+
children,
|
|
2862
|
+
title,
|
|
2863
|
+
detail,
|
|
2864
|
+
tone = "blue",
|
|
2865
|
+
width,
|
|
2866
|
+
minHeight,
|
|
2867
|
+
padding = 12,
|
|
2868
|
+
filled = true,
|
|
2869
|
+
align = "center"
|
|
2870
|
+
}) {
|
|
2871
|
+
const accent = getToneColor(tone, c);
|
|
2872
|
+
const textAlign = align;
|
|
2873
|
+
return React.createElement(
|
|
2874
|
+
"div",
|
|
2875
|
+
{
|
|
2876
|
+
style: {
|
|
2877
|
+
...width != null ? { width } : {},
|
|
2878
|
+
...minHeight != null ? { minHeight } : {},
|
|
2879
|
+
padding,
|
|
2880
|
+
borderRadius: 10,
|
|
2881
|
+
boxSizing: "border-box",
|
|
2882
|
+
...filled ? { backgroundImage: getToneGradient(tone), color: c.textOnColor, border: `1px solid ${accent}00` } : { backgroundColor: c.bgCard, color: c.textPrimary, border: `1px solid ${accent}66` },
|
|
2883
|
+
display: "flex",
|
|
2884
|
+
flexDirection: "column",
|
|
2885
|
+
alignItems: align === "center" ? "center" : "flex-start",
|
|
2886
|
+
justifyContent: "center",
|
|
2887
|
+
gap: detail ? 5 : 0,
|
|
2888
|
+
boxShadow: `0 10px 24px ${c.shadow}`,
|
|
2889
|
+
textAlign
|
|
2890
|
+
}
|
|
2891
|
+
},
|
|
2892
|
+
...compactChildren([
|
|
2893
|
+
title && React.createElement("div", {
|
|
2894
|
+
style: {
|
|
2895
|
+
...typography.small,
|
|
2896
|
+
color: filled ? c.textOnColor : accent,
|
|
2897
|
+
fontWeight: 900,
|
|
2898
|
+
lineHeight: 1.2,
|
|
2899
|
+
textAlign
|
|
2900
|
+
}
|
|
2901
|
+
}, title),
|
|
2902
|
+
detail && React.createElement("div", {
|
|
2903
|
+
style: {
|
|
2904
|
+
...typography.tiny,
|
|
2905
|
+
color: filled ? "rgba(255,255,255,0.84)" : c.textSecondary,
|
|
2906
|
+
lineHeight: 1.3,
|
|
2907
|
+
textAlign
|
|
2908
|
+
}
|
|
2909
|
+
}, detail),
|
|
2910
|
+
children && React.createElement("div", {
|
|
2911
|
+
style: {
|
|
2912
|
+
display: "flex",
|
|
2913
|
+
flexDirection: "column",
|
|
2914
|
+
alignItems: align === "center" ? "center" : "flex-start",
|
|
2915
|
+
fontSize: 12,
|
|
2916
|
+
fontWeight: 700,
|
|
2917
|
+
lineHeight: 1.3,
|
|
2918
|
+
textAlign
|
|
2919
|
+
}
|
|
2920
|
+
}, children)
|
|
2921
|
+
])
|
|
2922
|
+
);
|
|
2923
|
+
}
|
|
2924
|
+
function Pipeline({ stages, c, title }) {
|
|
2925
|
+
return React.createElement(
|
|
2926
|
+
"div",
|
|
2927
|
+
{
|
|
2928
|
+
style: {
|
|
2929
|
+
display: "flex",
|
|
2930
|
+
flexDirection: "column",
|
|
2931
|
+
alignItems: "center",
|
|
2932
|
+
gap: 20
|
|
2933
|
+
}
|
|
2934
|
+
},
|
|
2935
|
+
title && React.createElement("div", {
|
|
2936
|
+
style: { ...typography.label, color: c.textPrimary }
|
|
2937
|
+
}, title),
|
|
2938
|
+
React.createElement(
|
|
2939
|
+
"div",
|
|
2940
|
+
{
|
|
2941
|
+
style: {
|
|
2942
|
+
display: "flex",
|
|
2943
|
+
alignItems: "center",
|
|
2944
|
+
gap: 0
|
|
2945
|
+
}
|
|
2946
|
+
},
|
|
2947
|
+
...stages.flatMap((stage, i) => {
|
|
2948
|
+
const elements = [];
|
|
2949
|
+
elements.push(
|
|
2950
|
+
Box({
|
|
2951
|
+
label: stage.label,
|
|
2952
|
+
sublabel: stage.sublabel,
|
|
2953
|
+
icon: stage.icon,
|
|
2954
|
+
color: stage.color || "primary",
|
|
2955
|
+
gradient: true,
|
|
2956
|
+
c,
|
|
2957
|
+
fontSize: 13
|
|
2958
|
+
})
|
|
2959
|
+
);
|
|
2960
|
+
if (i < stages.length - 1) {
|
|
2961
|
+
elements.push(
|
|
2962
|
+
Arrow({ direction: "right", length: 36, c })
|
|
2963
|
+
);
|
|
2964
|
+
}
|
|
2965
|
+
return elements;
|
|
2966
|
+
})
|
|
2967
|
+
)
|
|
2968
|
+
);
|
|
2969
|
+
}
|
|
2970
|
+
function Matrix({
|
|
2971
|
+
data,
|
|
2972
|
+
c,
|
|
2973
|
+
rowLabels,
|
|
2974
|
+
colLabels,
|
|
2975
|
+
labels,
|
|
2976
|
+
title,
|
|
2977
|
+
cellSize = 48,
|
|
2978
|
+
cellWidth,
|
|
2979
|
+
cellHeight,
|
|
2980
|
+
rowLabelWidth,
|
|
2981
|
+
format = "decimal",
|
|
2982
|
+
colorize = true,
|
|
2983
|
+
colorScale = "heat"
|
|
2984
|
+
}) {
|
|
2985
|
+
const resolvedCellWidth = cellWidth ?? cellSize;
|
|
2986
|
+
const resolvedCellHeight = cellHeight ?? cellSize;
|
|
2987
|
+
const resolvedRowLabelWidth = rowLabelWidth ?? cellSize;
|
|
2988
|
+
const formatValue = (v) => {
|
|
2989
|
+
if (format === "percent") return `${Math.round(v * 100)}%`;
|
|
2990
|
+
if (format === "integer") return `${Math.round(v)}`;
|
|
2991
|
+
return v.toFixed(2);
|
|
2992
|
+
};
|
|
2993
|
+
const cellColor = (value) => {
|
|
2994
|
+
if (colorScale === "heat") return heatColor(value);
|
|
2995
|
+
if (value < 0.34) return c.bgHover;
|
|
2996
|
+
if (value < 0.67) return c.infoDark;
|
|
2997
|
+
return c.positiveDark;
|
|
2998
|
+
};
|
|
2999
|
+
return React.createElement(
|
|
3000
|
+
"div",
|
|
3001
|
+
{
|
|
3002
|
+
style: {
|
|
3003
|
+
display: "flex",
|
|
3004
|
+
flexDirection: "column",
|
|
3005
|
+
alignItems: "center",
|
|
3006
|
+
gap: 12
|
|
3007
|
+
}
|
|
3008
|
+
},
|
|
3009
|
+
title && React.createElement("div", {
|
|
3010
|
+
style: { ...typography.label, color: c.textPrimary }
|
|
3011
|
+
}, title),
|
|
3012
|
+
React.createElement(
|
|
3013
|
+
"div",
|
|
3014
|
+
{
|
|
3015
|
+
style: {
|
|
3016
|
+
display: "flex",
|
|
3017
|
+
flexDirection: "column",
|
|
3018
|
+
gap: 2
|
|
3019
|
+
}
|
|
3020
|
+
},
|
|
3021
|
+
// Column labels
|
|
3022
|
+
colLabels && React.createElement(
|
|
3023
|
+
"div",
|
|
3024
|
+
{
|
|
3025
|
+
style: {
|
|
3026
|
+
display: "flex",
|
|
3027
|
+
gap: 2,
|
|
3028
|
+
marginLeft: rowLabels ? resolvedRowLabelWidth + 4 : 0
|
|
3029
|
+
}
|
|
3030
|
+
},
|
|
3031
|
+
...colLabels.map(
|
|
3032
|
+
(label, i) => React.createElement("div", {
|
|
3033
|
+
key: `col-${i}`,
|
|
3034
|
+
style: {
|
|
3035
|
+
width: resolvedCellWidth,
|
|
3036
|
+
textAlign: "center",
|
|
3037
|
+
fontSize: 11,
|
|
3038
|
+
fontWeight: 600,
|
|
3039
|
+
color: c.textSecondary,
|
|
3040
|
+
fontFamily: "JetBrains Mono"
|
|
3041
|
+
}
|
|
3042
|
+
}, label)
|
|
3043
|
+
)
|
|
3044
|
+
),
|
|
3045
|
+
...data.map(
|
|
3046
|
+
(row, ri) => React.createElement(
|
|
3047
|
+
"div",
|
|
3048
|
+
{
|
|
3049
|
+
key: `row-${ri}`,
|
|
3050
|
+
style: {
|
|
3051
|
+
display: "flex",
|
|
3052
|
+
gap: 2,
|
|
3053
|
+
alignItems: "center"
|
|
3054
|
+
}
|
|
3055
|
+
},
|
|
3056
|
+
rowLabels && React.createElement("div", {
|
|
3057
|
+
style: {
|
|
3058
|
+
width: resolvedRowLabelWidth,
|
|
3059
|
+
textAlign: "right",
|
|
3060
|
+
paddingRight: 4,
|
|
3061
|
+
fontSize: 11,
|
|
3062
|
+
fontWeight: 600,
|
|
3063
|
+
color: c.textSecondary,
|
|
3064
|
+
fontFamily: "JetBrains Mono"
|
|
3065
|
+
}
|
|
3066
|
+
}, rowLabels[ri]),
|
|
3067
|
+
...row.map(
|
|
3068
|
+
(value, ci) => React.createElement("div", {
|
|
3069
|
+
key: `cell-${ri}-${ci}`,
|
|
3070
|
+
style: {
|
|
3071
|
+
width: resolvedCellWidth,
|
|
3072
|
+
height: resolvedCellHeight,
|
|
3073
|
+
display: "flex",
|
|
3074
|
+
alignItems: "center",
|
|
3075
|
+
justifyContent: "center",
|
|
3076
|
+
backgroundColor: colorize ? cellColor(value) : c.bgCard,
|
|
3077
|
+
borderRadius: 6,
|
|
3078
|
+
fontSize: 11,
|
|
3079
|
+
fontWeight: 600,
|
|
3080
|
+
color: colorScale === "strength" && value < 0.34 ? c.textSecondary : c.textOnColor,
|
|
3081
|
+
fontFamily: "JetBrains Mono"
|
|
3082
|
+
}
|
|
3083
|
+
}, labels?.[ri]?.[ci] ?? formatValue(value))
|
|
3084
|
+
)
|
|
3085
|
+
)
|
|
3086
|
+
)
|
|
3087
|
+
)
|
|
3088
|
+
);
|
|
3089
|
+
}
|
|
3090
|
+
function Heatmap({
|
|
3091
|
+
data,
|
|
3092
|
+
xLabels,
|
|
3093
|
+
yLabels,
|
|
3094
|
+
c,
|
|
3095
|
+
labels,
|
|
3096
|
+
title,
|
|
3097
|
+
cellSize = 52,
|
|
3098
|
+
cellWidth,
|
|
3099
|
+
cellHeight,
|
|
3100
|
+
rowLabelWidth,
|
|
3101
|
+
colorScale
|
|
3102
|
+
}) {
|
|
3103
|
+
return Matrix({
|
|
3104
|
+
data,
|
|
3105
|
+
colLabels: xLabels,
|
|
3106
|
+
rowLabels: yLabels,
|
|
3107
|
+
c,
|
|
3108
|
+
labels,
|
|
3109
|
+
title,
|
|
3110
|
+
colorize: true,
|
|
3111
|
+
cellSize,
|
|
3112
|
+
cellWidth,
|
|
3113
|
+
cellHeight,
|
|
3114
|
+
rowLabelWidth,
|
|
3115
|
+
colorScale
|
|
3116
|
+
});
|
|
3117
|
+
}
|
|
3118
|
+
function TiledMatrix({
|
|
3119
|
+
rows,
|
|
3120
|
+
cols,
|
|
3121
|
+
c,
|
|
3122
|
+
regions = [],
|
|
3123
|
+
title,
|
|
3124
|
+
subtitle,
|
|
3125
|
+
cellSize = 24,
|
|
3126
|
+
gap = 3,
|
|
3127
|
+
tone = "blue",
|
|
3128
|
+
muted = false,
|
|
3129
|
+
crossedOut = false
|
|
3130
|
+
}) {
|
|
3131
|
+
const safeRows = Math.max(1, Math.floor(rows));
|
|
3132
|
+
const safeCols = Math.max(1, Math.floor(cols));
|
|
3133
|
+
const baseAccent = getToneColor(tone, c);
|
|
3134
|
+
const cellRows = Array.from(
|
|
3135
|
+
{ length: safeRows },
|
|
3136
|
+
(_, row) => React.createElement(
|
|
3137
|
+
"div",
|
|
3138
|
+
{
|
|
3139
|
+
key: `tiled-matrix-row-${row}`,
|
|
3140
|
+
style: {
|
|
3141
|
+
display: "flex",
|
|
3142
|
+
gap
|
|
3143
|
+
}
|
|
3144
|
+
},
|
|
3145
|
+
...Array.from({ length: safeCols }, (_2, col) => {
|
|
3146
|
+
const regionIndex = regions.findIndex(
|
|
3147
|
+
(region2) => row >= region2.rowStart && row < region2.rowEnd && col >= region2.colStart && col < region2.colEnd
|
|
3148
|
+
);
|
|
3149
|
+
const region = regionIndex >= 0 ? regions[regionIndex] : void 0;
|
|
3150
|
+
const accent = getToneColor(region?.tone ?? tone, c);
|
|
3151
|
+
return React.createElement("div", {
|
|
3152
|
+
key: `tiled-matrix-cell-${row}-${col}`,
|
|
3153
|
+
"data-region": regionIndex >= 0 ? regionIndex : void 0,
|
|
3154
|
+
style: {
|
|
3155
|
+
width: cellSize,
|
|
3156
|
+
height: cellSize,
|
|
3157
|
+
boxSizing: "border-box",
|
|
3158
|
+
borderRadius: Math.max(2, Math.min(6, Math.round(cellSize * 0.18))),
|
|
3159
|
+
backgroundColor: region ? `${accent}42` : muted ? c.bgSubtle : `${baseAccent}0f`,
|
|
3160
|
+
border: `1px solid ${region ? `${accent}aa` : c.borderSubtle}`,
|
|
3161
|
+
opacity: muted ? 0.55 : 1
|
|
3162
|
+
}
|
|
3163
|
+
});
|
|
3164
|
+
})
|
|
3165
|
+
)
|
|
3166
|
+
);
|
|
3167
|
+
const grid = React.createElement(
|
|
3168
|
+
"div",
|
|
3169
|
+
{
|
|
3170
|
+
"data-crossed-out": crossedOut ? "true" : void 0,
|
|
3171
|
+
style: {
|
|
3172
|
+
position: "relative",
|
|
3173
|
+
display: "flex",
|
|
3174
|
+
flexDirection: "column",
|
|
3175
|
+
gap,
|
|
3176
|
+
padding: gap,
|
|
3177
|
+
borderRadius: 10,
|
|
3178
|
+
backgroundColor: c.bgSubtle,
|
|
3179
|
+
border: `1px solid ${c.borderLight}`,
|
|
3180
|
+
boxShadow: `0 8px 18px ${c.shadow}`,
|
|
3181
|
+
overflow: "hidden"
|
|
3182
|
+
}
|
|
3183
|
+
},
|
|
3184
|
+
...cellRows,
|
|
3185
|
+
...crossedOut ? [
|
|
3186
|
+
React.createElement("div", {
|
|
3187
|
+
key: "cross-forward",
|
|
3188
|
+
style: {
|
|
3189
|
+
position: "absolute",
|
|
3190
|
+
left: "-12%",
|
|
3191
|
+
top: "50%",
|
|
3192
|
+
width: "124%",
|
|
3193
|
+
height: 4,
|
|
3194
|
+
borderRadius: 999,
|
|
3195
|
+
backgroundColor: c.criticalLight,
|
|
3196
|
+
transform: "rotate(36deg)",
|
|
3197
|
+
transformOrigin: "center",
|
|
3198
|
+
boxShadow: `0 0 0 1px ${c.bgCard}`
|
|
3199
|
+
}
|
|
3200
|
+
}),
|
|
3201
|
+
React.createElement("div", {
|
|
3202
|
+
key: "cross-backward",
|
|
3203
|
+
style: {
|
|
3204
|
+
position: "absolute",
|
|
3205
|
+
left: "-12%",
|
|
3206
|
+
top: "50%",
|
|
3207
|
+
width: "124%",
|
|
3208
|
+
height: 4,
|
|
3209
|
+
borderRadius: 999,
|
|
3210
|
+
backgroundColor: c.criticalLight,
|
|
3211
|
+
transform: "rotate(-36deg)",
|
|
3212
|
+
transformOrigin: "center",
|
|
3213
|
+
boxShadow: `0 0 0 1px ${c.bgCard}`
|
|
3214
|
+
}
|
|
3215
|
+
})
|
|
3216
|
+
] : []
|
|
3217
|
+
);
|
|
3218
|
+
return React.createElement(
|
|
3219
|
+
"div",
|
|
3220
|
+
{
|
|
3221
|
+
role: "img",
|
|
3222
|
+
style: {
|
|
3223
|
+
display: "flex",
|
|
3224
|
+
flexDirection: "column",
|
|
3225
|
+
alignItems: "center",
|
|
3226
|
+
gap: 7
|
|
3227
|
+
}
|
|
3228
|
+
},
|
|
3229
|
+
...compactChildren([
|
|
3230
|
+
title && React.createElement("div", {
|
|
3231
|
+
style: {
|
|
3232
|
+
color: muted ? c.textMuted : baseAccent,
|
|
3233
|
+
fontFamily: "Inter",
|
|
3234
|
+
fontSize: 13,
|
|
3235
|
+
fontWeight: 900,
|
|
3236
|
+
lineHeight: 1.1,
|
|
3237
|
+
textAlign: "center"
|
|
3238
|
+
}
|
|
3239
|
+
}, title),
|
|
3240
|
+
subtitle && React.createElement("div", {
|
|
3241
|
+
style: {
|
|
3242
|
+
color: c.textMuted,
|
|
3243
|
+
fontFamily: "JetBrains Mono",
|
|
3244
|
+
fontSize: 9,
|
|
3245
|
+
fontWeight: 700,
|
|
3246
|
+
lineHeight: 1.1,
|
|
3247
|
+
textAlign: "center"
|
|
3248
|
+
}
|
|
3249
|
+
}, subtitle),
|
|
3250
|
+
grid
|
|
3251
|
+
])
|
|
3252
|
+
);
|
|
3253
|
+
}
|
|
3254
|
+
function DataTable({
|
|
3255
|
+
rows,
|
|
3256
|
+
c,
|
|
3257
|
+
cellWidth = 54,
|
|
3258
|
+
firstColWidth = cellWidth,
|
|
3259
|
+
cellHeight = 28,
|
|
3260
|
+
gap = 5,
|
|
3261
|
+
headerRows = 1,
|
|
3262
|
+
headerCols = 1,
|
|
3263
|
+
fontSize = 10,
|
|
3264
|
+
math = false
|
|
3265
|
+
}) {
|
|
3266
|
+
const renderCell = (cell) => math && typeof cell === "string" ? formatMathText(cell) : cell;
|
|
3267
|
+
return React.createElement(
|
|
3268
|
+
"div",
|
|
3269
|
+
{
|
|
3270
|
+
style: {
|
|
3271
|
+
display: "flex",
|
|
3272
|
+
flexDirection: "column",
|
|
3273
|
+
gap,
|
|
3274
|
+
alignItems: "center"
|
|
3275
|
+
}
|
|
3276
|
+
},
|
|
3277
|
+
...rows.map((row, rowIndex) => React.createElement(
|
|
3278
|
+
"div",
|
|
3279
|
+
{
|
|
3280
|
+
key: `${rowIndex}-${row.map(String).join("|")}`,
|
|
3281
|
+
style: {
|
|
3282
|
+
display: "flex",
|
|
3283
|
+
gap
|
|
3284
|
+
}
|
|
3285
|
+
},
|
|
3286
|
+
...row.map((cell, colIndex) => {
|
|
3287
|
+
const isHeaderRow = rowIndex < headerRows;
|
|
3288
|
+
const isHeaderCol = colIndex < headerCols;
|
|
3289
|
+
return React.createElement("div", {
|
|
3290
|
+
key: `${rowIndex}-${colIndex}-${String(cell)}`,
|
|
3291
|
+
style: {
|
|
3292
|
+
width: colIndex === 0 ? firstColWidth : cellWidth,
|
|
3293
|
+
height: cellHeight,
|
|
3294
|
+
display: "flex",
|
|
3295
|
+
alignItems: "center",
|
|
3296
|
+
justifyContent: "center",
|
|
3297
|
+
borderRadius: 7,
|
|
3298
|
+
backgroundColor: isHeaderRow ? c.bgSubtle : c.bgHover,
|
|
3299
|
+
color: isHeaderCol ? c.textPrimary : c.textSecondary,
|
|
3300
|
+
fontFamily: "JetBrains Mono",
|
|
3301
|
+
fontSize,
|
|
3302
|
+
fontWeight: isHeaderCol ? 850 : 650,
|
|
3303
|
+
lineHeight: 1.15,
|
|
3304
|
+
...textFitStyle("center")
|
|
3305
|
+
}
|
|
3306
|
+
}, renderCell(cell));
|
|
3307
|
+
})
|
|
3308
|
+
))
|
|
3309
|
+
);
|
|
3310
|
+
}
|
|
3311
|
+
function isGridCell(cell) {
|
|
3312
|
+
return typeof cell === "object" && cell !== null && !React.isValidElement(cell) && ("label" in cell || "tone" in cell || "backgroundColor" in cell || "borderColor" in cell);
|
|
3313
|
+
}
|
|
3314
|
+
function Grid({
|
|
3315
|
+
rows,
|
|
3316
|
+
c,
|
|
3317
|
+
cellWidth = 34,
|
|
3318
|
+
cellHeight = 30,
|
|
3319
|
+
gap = 5,
|
|
3320
|
+
radius = 7,
|
|
3321
|
+
fontSize = 10,
|
|
3322
|
+
math = false,
|
|
3323
|
+
headerRows = 0,
|
|
3324
|
+
headerCols = 0
|
|
3325
|
+
}) {
|
|
3326
|
+
const renderCellLabel = (cell) => {
|
|
3327
|
+
const label = isGridCell(cell) ? cell.label : cell;
|
|
3328
|
+
return math && typeof label === "string" ? formatMathText(label) : label;
|
|
3329
|
+
};
|
|
3330
|
+
const cellStyle = (cell, rowIndex, colIndex) => {
|
|
3331
|
+
const config = isGridCell(cell) ? cell : {};
|
|
3332
|
+
const toneColor = config.tone ? getToneColor(config.tone, c) : void 0;
|
|
3333
|
+
const isHeader = rowIndex < headerRows || colIndex < headerCols;
|
|
3334
|
+
return {
|
|
3335
|
+
width: cellWidth,
|
|
3336
|
+
height: cellHeight,
|
|
3337
|
+
display: "flex",
|
|
3338
|
+
alignItems: "center",
|
|
3339
|
+
justifyContent: "center",
|
|
3340
|
+
borderRadius: radius,
|
|
3341
|
+
backgroundColor: config.backgroundColor ?? (toneColor ? `${toneColor}22` : isHeader ? c.bgSubtle : c.bgHover),
|
|
3342
|
+
border: `1px solid ${config.borderColor ?? (toneColor ? `${toneColor}55` : c.borderSubtle)}`,
|
|
3343
|
+
color: config.color ?? (toneColor ?? (isHeader ? c.textPrimary : c.textSecondary)),
|
|
3344
|
+
...config.opacity !== void 0 ? { opacity: config.opacity } : {},
|
|
3345
|
+
fontFamily: "JetBrains Mono",
|
|
3346
|
+
fontSize,
|
|
3347
|
+
fontWeight: isHeader || toneColor ? 850 : 650,
|
|
3348
|
+
lineHeight: 1.15,
|
|
3349
|
+
...textFitStyle("center")
|
|
3350
|
+
};
|
|
3351
|
+
};
|
|
3352
|
+
return React.createElement(
|
|
3353
|
+
"div",
|
|
3354
|
+
{
|
|
3355
|
+
style: {
|
|
3356
|
+
display: "flex",
|
|
3357
|
+
flexDirection: "column",
|
|
3358
|
+
gap,
|
|
3359
|
+
alignItems: "center"
|
|
3360
|
+
}
|
|
3361
|
+
},
|
|
3362
|
+
...rows.map((row, rowIndex) => React.createElement(
|
|
3363
|
+
"div",
|
|
3364
|
+
{
|
|
3365
|
+
key: `grid-row-${rowIndex}`,
|
|
3366
|
+
style: {
|
|
3367
|
+
display: "flex",
|
|
3368
|
+
gap
|
|
3369
|
+
}
|
|
3370
|
+
},
|
|
3371
|
+
...row.map((cell, colIndex) => React.createElement("div", {
|
|
3372
|
+
key: `grid-cell-${rowIndex}-${colIndex}`,
|
|
3373
|
+
style: cellStyle(cell, rowIndex, colIndex)
|
|
3374
|
+
}, renderCellLabel(cell)))
|
|
3375
|
+
))
|
|
3376
|
+
);
|
|
3377
|
+
}
|
|
3378
|
+
function AxisPlot({
|
|
3379
|
+
c,
|
|
3380
|
+
width,
|
|
3381
|
+
height,
|
|
3382
|
+
xMin = -1,
|
|
3383
|
+
xMax = 1,
|
|
3384
|
+
yMin = -1,
|
|
3385
|
+
yMax = 1,
|
|
3386
|
+
padding = 18,
|
|
3387
|
+
showFrame = true,
|
|
3388
|
+
showAxes = true,
|
|
3389
|
+
showGrid = false,
|
|
3390
|
+
gridCount = 5,
|
|
3391
|
+
frameRx = 8,
|
|
3392
|
+
frameFill,
|
|
3393
|
+
frameStroke,
|
|
3394
|
+
axisColor,
|
|
3395
|
+
points = [],
|
|
3396
|
+
vectors = [],
|
|
3397
|
+
paths = [],
|
|
3398
|
+
xAxisLabel,
|
|
3399
|
+
yAxisLabel,
|
|
3400
|
+
children
|
|
3401
|
+
}) {
|
|
3402
|
+
const innerWidth = Math.max(1, width - padding * 2);
|
|
3403
|
+
const innerHeight = Math.max(1, height - padding * 2);
|
|
3404
|
+
const xRange = xMax === xMin ? 1 : xMax - xMin;
|
|
3405
|
+
const yRange = yMax === yMin ? 1 : yMax - yMin;
|
|
3406
|
+
const sx = (x) => padding + (x - xMin) / xRange * innerWidth;
|
|
3407
|
+
const sy = (y) => padding + innerHeight - (y - yMin) / yRange * innerHeight;
|
|
3408
|
+
const xAxisY = yMin <= 0 && yMax >= 0 ? sy(0) : padding + innerHeight / 2;
|
|
3409
|
+
const yAxisX = xMin <= 0 && xMax >= 0 ? sx(0) : padding + innerWidth / 2;
|
|
3410
|
+
const axisStroke = axisColor ?? c.borderLight;
|
|
3411
|
+
const gridIndexes = Array.from({ length: Math.max(0, gridCount) }, (_, index) => index + 1);
|
|
3412
|
+
const elements = [];
|
|
3413
|
+
if (showFrame) {
|
|
3414
|
+
elements.push(SvgFrame({
|
|
3415
|
+
key: "axis-frame",
|
|
3416
|
+
x: padding / 2,
|
|
3417
|
+
y: padding / 2,
|
|
3418
|
+
width: width - padding,
|
|
3419
|
+
height: height - padding,
|
|
3420
|
+
rx: frameRx,
|
|
3421
|
+
c,
|
|
3422
|
+
fill: frameFill,
|
|
3423
|
+
stroke: frameStroke
|
|
3424
|
+
}));
|
|
3425
|
+
}
|
|
3426
|
+
if (showGrid && gridCount > 0) {
|
|
3427
|
+
elements.push(...gridIndexes.flatMap((index) => {
|
|
3428
|
+
const x = padding + innerWidth * index / (gridCount + 1);
|
|
3429
|
+
const y = padding + innerHeight * index / (gridCount + 1);
|
|
3430
|
+
return [
|
|
3431
|
+
React.createElement("line", {
|
|
3432
|
+
key: `axis-grid-x-${index}`,
|
|
3433
|
+
x1: x,
|
|
3434
|
+
y1: padding,
|
|
3435
|
+
x2: x,
|
|
3436
|
+
y2: padding + innerHeight,
|
|
3437
|
+
stroke: c.borderSubtle,
|
|
3438
|
+
strokeWidth: 1,
|
|
3439
|
+
opacity: 0.75
|
|
3440
|
+
}),
|
|
3441
|
+
React.createElement("line", {
|
|
3442
|
+
key: `axis-grid-y-${index}`,
|
|
3443
|
+
x1: padding,
|
|
3444
|
+
y1: y,
|
|
3445
|
+
x2: padding + innerWidth,
|
|
3446
|
+
y2: y,
|
|
3447
|
+
stroke: c.borderSubtle,
|
|
3448
|
+
strokeWidth: 1,
|
|
3449
|
+
opacity: 0.75
|
|
3450
|
+
})
|
|
3451
|
+
];
|
|
3452
|
+
}));
|
|
3453
|
+
}
|
|
3454
|
+
if (showAxes) {
|
|
3455
|
+
elements.push(
|
|
3456
|
+
React.createElement("line", {
|
|
3457
|
+
key: "axis-x",
|
|
3458
|
+
x1: padding,
|
|
3459
|
+
y1: xAxisY,
|
|
3460
|
+
x2: padding + innerWidth,
|
|
3461
|
+
y2: xAxisY,
|
|
3462
|
+
stroke: axisStroke,
|
|
3463
|
+
strokeWidth: 1.6,
|
|
3464
|
+
opacity: 0.85
|
|
3465
|
+
}),
|
|
3466
|
+
React.createElement("line", {
|
|
3467
|
+
key: "axis-y",
|
|
3468
|
+
x1: yAxisX,
|
|
3469
|
+
y1: padding,
|
|
3470
|
+
x2: yAxisX,
|
|
3471
|
+
y2: padding + innerHeight,
|
|
3472
|
+
stroke: axisStroke,
|
|
3473
|
+
strokeWidth: 1.6,
|
|
3474
|
+
opacity: 0.85
|
|
3475
|
+
})
|
|
3476
|
+
);
|
|
3477
|
+
}
|
|
3478
|
+
elements.push(...paths.flatMap((path, index) => {
|
|
3479
|
+
if (path.points.length < 2) return [];
|
|
3480
|
+
const [first, ...rest] = path.points;
|
|
3481
|
+
const commands = [`M ${sx(first.x)} ${sy(first.y)}`];
|
|
3482
|
+
for (const point of rest) {
|
|
3483
|
+
if (path.interpolation === "step-after") {
|
|
3484
|
+
commands.push(`H ${sx(point.x)} V ${sy(point.y)}`);
|
|
3485
|
+
} else {
|
|
3486
|
+
commands.push(`L ${sx(point.x)} ${sy(point.y)}`);
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
return [React.createElement("path", {
|
|
3490
|
+
key: `axis-path-${index}`,
|
|
3491
|
+
d: commands.join(" "),
|
|
3492
|
+
fill: "none",
|
|
3493
|
+
stroke: path.color ?? getToneColor(path.tone ?? "blue", c),
|
|
3494
|
+
strokeWidth: path.strokeWidth ?? 3,
|
|
3495
|
+
strokeLinecap: "round",
|
|
3496
|
+
strokeLinejoin: "round",
|
|
3497
|
+
strokeDasharray: path.dashed ? "8 7" : void 0,
|
|
3498
|
+
opacity: path.opacity ?? 1
|
|
3499
|
+
})];
|
|
3500
|
+
}));
|
|
3501
|
+
elements.push(...vectors.map((vector, index) => {
|
|
3502
|
+
const color = vector.color ?? getToneColor(vector.tone ?? "blue", c);
|
|
3503
|
+
const x1 = sx(vector.x1);
|
|
3504
|
+
const y1 = sy(vector.y1);
|
|
3505
|
+
const x2 = sx(vector.x2);
|
|
3506
|
+
const y2 = sy(vector.y2);
|
|
3507
|
+
if (vector.arrow) {
|
|
3508
|
+
return VectorArrow({
|
|
3509
|
+
key: `axis-vector-${index}`,
|
|
3510
|
+
x1,
|
|
3511
|
+
y1,
|
|
3512
|
+
x2,
|
|
3513
|
+
y2,
|
|
3514
|
+
color,
|
|
3515
|
+
strokeWidth: vector.strokeWidth,
|
|
3516
|
+
arrowSize: vector.arrowSize,
|
|
3517
|
+
opacity: vector.opacity
|
|
3518
|
+
});
|
|
3519
|
+
}
|
|
3520
|
+
return VectorSegment({
|
|
3521
|
+
key: `axis-vector-${index}`,
|
|
3522
|
+
x1,
|
|
3523
|
+
y1,
|
|
3524
|
+
x2,
|
|
3525
|
+
y2,
|
|
3526
|
+
color,
|
|
3527
|
+
strokeWidth: vector.strokeWidth,
|
|
3528
|
+
opacity: vector.opacity,
|
|
3529
|
+
showStartDot: vector.showStartDot,
|
|
3530
|
+
showEndDot: vector.showEndDot,
|
|
3531
|
+
dotRadius: vector.dotRadius
|
|
3532
|
+
});
|
|
3533
|
+
}));
|
|
3534
|
+
elements.push(...points.map((point, index) => SvgPoint({
|
|
3535
|
+
key: `axis-point-${index}`,
|
|
3536
|
+
cx: sx(point.x),
|
|
3537
|
+
cy: sy(point.y),
|
|
3538
|
+
r: point.r ?? 5,
|
|
3539
|
+
fill: point.fill ?? getToneColor(point.tone ?? "blue", c),
|
|
3540
|
+
stroke: point.stroke,
|
|
3541
|
+
strokeWidth: point.strokeWidth,
|
|
3542
|
+
opacity: point.opacity
|
|
3543
|
+
})));
|
|
3544
|
+
elements.push(...React.Children.toArray(children).filter(React.isValidElement));
|
|
3545
|
+
const svg = React.createElement("svg", {
|
|
3546
|
+
width,
|
|
3547
|
+
height,
|
|
3548
|
+
viewBox: `0 0 ${width} ${height}`
|
|
3549
|
+
}, ...elements);
|
|
3550
|
+
if (!xAxisLabel && !yAxisLabel) return svg;
|
|
3551
|
+
return React.createElement(
|
|
3552
|
+
"div",
|
|
3553
|
+
{
|
|
3554
|
+
style: {
|
|
3555
|
+
position: "relative",
|
|
3556
|
+
width,
|
|
3557
|
+
height,
|
|
3558
|
+
display: "flex"
|
|
3559
|
+
}
|
|
3560
|
+
},
|
|
3561
|
+
svg,
|
|
3562
|
+
xAxisLabel && React.createElement("div", {
|
|
3563
|
+
key: "axis-x-label",
|
|
3564
|
+
style: {
|
|
3565
|
+
position: "absolute",
|
|
3566
|
+
left: width / 2,
|
|
3567
|
+
bottom: 0,
|
|
3568
|
+
width: width - padding * 2,
|
|
3569
|
+
transform: "translateX(-50%)",
|
|
3570
|
+
textAlign: "center",
|
|
3571
|
+
color: c.textMuted,
|
|
3572
|
+
fontFamily: "Inter",
|
|
3573
|
+
fontSize: 11,
|
|
3574
|
+
fontWeight: 750
|
|
3575
|
+
}
|
|
3576
|
+
}, xAxisLabel),
|
|
3577
|
+
yAxisLabel && React.createElement("div", {
|
|
3578
|
+
key: "axis-y-label",
|
|
3579
|
+
style: {
|
|
3580
|
+
position: "absolute",
|
|
3581
|
+
left: 0,
|
|
3582
|
+
top: height / 2,
|
|
3583
|
+
width: height - padding * 2,
|
|
3584
|
+
transform: "translate(-50%, -50%) rotate(-90deg)",
|
|
3585
|
+
textAlign: "center",
|
|
3586
|
+
color: c.textMuted,
|
|
3587
|
+
fontFamily: "Inter",
|
|
3588
|
+
fontSize: 11,
|
|
3589
|
+
fontWeight: 750
|
|
3590
|
+
}
|
|
3591
|
+
}, yAxisLabel)
|
|
3592
|
+
);
|
|
3593
|
+
}
|
|
3594
|
+
var chartPalette = ["primary", "secondary", "positive", "warning", "info", "accent", "critical"];
|
|
3595
|
+
function isColorName(value) {
|
|
3596
|
+
return chartPalette.includes(value) || value === "neutral";
|
|
3597
|
+
}
|
|
3598
|
+
function chartColor(color, c, index = 0) {
|
|
3599
|
+
if (!color) return getColor(chartPalette[index % chartPalette.length], c);
|
|
3600
|
+
return isColorName(color) ? getColor(color, c) : color;
|
|
3601
|
+
}
|
|
3602
|
+
function formatChartValue(value, format = "decimal") {
|
|
3603
|
+
if (typeof format === "function") return format(value);
|
|
3604
|
+
if (format === "percent") return `${Math.round(value * 100)}%`;
|
|
3605
|
+
if (format === "integer") return `${Math.round(value)}`;
|
|
3606
|
+
if (format === "compact") {
|
|
3607
|
+
if (Math.abs(value) >= 1e6) return `${(value / 1e6).toFixed(1)}M`;
|
|
3608
|
+
if (Math.abs(value) >= 1e3) return `${(value / 1e3).toFixed(1)}k`;
|
|
3609
|
+
return `${Math.round(value)}`;
|
|
3610
|
+
}
|
|
3611
|
+
return Number.isInteger(value) ? `${value}` : value.toFixed(2);
|
|
3612
|
+
}
|
|
3613
|
+
function chartDomain(values, min, max) {
|
|
3614
|
+
const rawMin = min ?? Math.min(0, ...values);
|
|
3615
|
+
const rawMax = max ?? Math.max(...values, 1);
|
|
3616
|
+
const range = rawMax === rawMin ? 1 : rawMax - rawMin;
|
|
3617
|
+
return { min: rawMin, max: rawMax, range };
|
|
3618
|
+
}
|
|
3619
|
+
function chartTicks(min, max, count = 4) {
|
|
3620
|
+
if (count <= 1) return [min];
|
|
3621
|
+
const step = (max - min) / (count - 1);
|
|
3622
|
+
return Array.from({ length: count }, (_, index) => min + step * index);
|
|
3623
|
+
}
|
|
3624
|
+
function clamp(value, min, max) {
|
|
3625
|
+
return Math.min(max, Math.max(min, value));
|
|
3626
|
+
}
|
|
3627
|
+
function axisTextStyle(c) {
|
|
3628
|
+
return {
|
|
3629
|
+
fontFamily: "JetBrains Mono",
|
|
3630
|
+
fontSize: 10,
|
|
3631
|
+
fontWeight: 600,
|
|
3632
|
+
color: c.textMuted,
|
|
3633
|
+
lineHeight: 1
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3636
|
+
function createPlotArea(width, height, margin) {
|
|
3637
|
+
const innerWidth = Math.max(1, width - margin.left - margin.right);
|
|
3638
|
+
const innerHeight = Math.max(1, height - margin.top - margin.bottom);
|
|
3639
|
+
return {
|
|
3640
|
+
width,
|
|
3641
|
+
height,
|
|
3642
|
+
margin,
|
|
3643
|
+
x: margin.left,
|
|
3644
|
+
y: margin.top,
|
|
3645
|
+
right: width - margin.right,
|
|
3646
|
+
bottom: height - margin.bottom,
|
|
3647
|
+
innerWidth,
|
|
3648
|
+
innerHeight
|
|
3649
|
+
};
|
|
3650
|
+
}
|
|
3651
|
+
function scaleToRange(value, min, range, outputStart, outputLength) {
|
|
3652
|
+
return outputStart + (value - min) / range * outputLength;
|
|
3653
|
+
}
|
|
3654
|
+
function xInPlot(value, domain, plot) {
|
|
3655
|
+
return scaleToRange(value, domain.min, domain.range, plot.x, plot.innerWidth);
|
|
3656
|
+
}
|
|
3657
|
+
function yInPlot(value, domain, plot) {
|
|
3658
|
+
return plot.y + plot.innerHeight - (value - domain.min) / domain.range * plot.innerHeight;
|
|
3659
|
+
}
|
|
3660
|
+
function chartLabel(key, text, x, y, c, options = {}) {
|
|
3661
|
+
const align = options.align ?? "center";
|
|
3662
|
+
const width = options.width ?? 72;
|
|
3663
|
+
const fontSize = options.fontSize ?? 10;
|
|
3664
|
+
const labelHeight = options.height ?? Math.ceil(fontSize * 1.4);
|
|
3665
|
+
let left = x;
|
|
3666
|
+
let top = y;
|
|
3667
|
+
let transform = options.transform ?? (align === "center" ? "translate(-50%, -50%)" : align === "right" ? "translate(-100%, -50%)" : "translate(0, -50%)");
|
|
3668
|
+
if (options.bounds) {
|
|
3669
|
+
const padding = options.bounds.padding ?? 4;
|
|
3670
|
+
const idealLeft = align === "center" ? x - width / 2 : align === "right" ? x - width : x;
|
|
3671
|
+
const idealTop = y - labelHeight / 2;
|
|
3672
|
+
left = clamp(
|
|
3673
|
+
idealLeft,
|
|
3674
|
+
options.bounds.x + padding,
|
|
3675
|
+
options.bounds.x + options.bounds.width - width - padding
|
|
3676
|
+
);
|
|
3677
|
+
top = clamp(
|
|
3678
|
+
idealTop,
|
|
3679
|
+
options.bounds.y + padding,
|
|
3680
|
+
options.bounds.y + options.bounds.height - labelHeight - padding
|
|
3681
|
+
);
|
|
3682
|
+
transform = void 0;
|
|
3683
|
+
}
|
|
3684
|
+
return React.createElement("div", {
|
|
3685
|
+
key,
|
|
3686
|
+
style: {
|
|
3687
|
+
position: "absolute",
|
|
3688
|
+
left,
|
|
3689
|
+
top,
|
|
3690
|
+
width,
|
|
3691
|
+
...transform !== void 0 ? { transform } : {},
|
|
3692
|
+
display: "flex",
|
|
3693
|
+
justifyContent: align === "right" ? "flex-end" : align === "left" ? "flex-start" : "center",
|
|
3694
|
+
...textFitStyle(align),
|
|
3695
|
+
pointerEvents: "none",
|
|
3696
|
+
...axisTextStyle(c),
|
|
3697
|
+
color: options.color ?? c.textMuted,
|
|
3698
|
+
fontFamily: options.fontFamily ?? "JetBrains Mono",
|
|
3699
|
+
fontWeight: options.fontWeight ?? 600,
|
|
3700
|
+
fontSize,
|
|
3701
|
+
lineHeight: 1.15
|
|
3702
|
+
}
|
|
3703
|
+
}, text);
|
|
3704
|
+
}
|
|
3705
|
+
function pointLabelPlacement(x, y, plot, index, width = 70) {
|
|
3706
|
+
const nearTop = y < plot.y + 34;
|
|
3707
|
+
const nearBottom = y > plot.bottom - 34;
|
|
3708
|
+
const nearLeft = x < plot.x + 76;
|
|
3709
|
+
const nearRight = x > plot.right - 76;
|
|
3710
|
+
const align = nearLeft ? "left" : nearRight ? "right" : "center";
|
|
3711
|
+
const verticalOffset = nearTop ? 18 : nearBottom ? -18 : index % 2 === 0 ? -16 : 18;
|
|
3712
|
+
return {
|
|
3713
|
+
x,
|
|
3714
|
+
y: y + verticalOffset,
|
|
3715
|
+
align,
|
|
3716
|
+
width,
|
|
3717
|
+
bounds: {
|
|
3718
|
+
x: plot.x,
|
|
3719
|
+
y: plot.y,
|
|
3720
|
+
width: plot.innerWidth,
|
|
3721
|
+
height: plot.innerHeight,
|
|
3722
|
+
padding: 6
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
function ChartFrame({
|
|
3727
|
+
children,
|
|
3728
|
+
c,
|
|
3729
|
+
title,
|
|
3730
|
+
subtitle,
|
|
3731
|
+
legend,
|
|
3732
|
+
footer,
|
|
3733
|
+
width = "100%",
|
|
3734
|
+
height,
|
|
3735
|
+
padding = 16
|
|
3736
|
+
}) {
|
|
3737
|
+
return React.createElement(
|
|
3738
|
+
"div",
|
|
3739
|
+
{
|
|
3740
|
+
style: {
|
|
3741
|
+
width,
|
|
3742
|
+
...height ? { height } : {},
|
|
3743
|
+
display: "flex",
|
|
3744
|
+
flexDirection: "column",
|
|
3745
|
+
gap: 12,
|
|
3746
|
+
padding,
|
|
3747
|
+
borderRadius: 8,
|
|
3748
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
3749
|
+
backgroundColor: c.bgCard,
|
|
3750
|
+
boxShadow: `0 9px 24px ${c.shadow}`
|
|
3751
|
+
}
|
|
3752
|
+
},
|
|
3753
|
+
(title || subtitle) && React.createElement(
|
|
3754
|
+
"div",
|
|
3755
|
+
{
|
|
3756
|
+
style: { display: "flex", flexDirection: "column", gap: 4, minWidth: 0, maxWidth: "100%" }
|
|
3757
|
+
},
|
|
3758
|
+
title && React.createElement("div", {
|
|
3759
|
+
style: { ...typography.small, ...textFitStyle(), color: c.textPrimary, fontWeight: 900 }
|
|
3760
|
+
}, title),
|
|
3761
|
+
subtitle && React.createElement("div", {
|
|
3762
|
+
style: { ...typography.tiny, ...textFitStyle(), color: c.textSecondary, lineHeight: 1.35 }
|
|
3763
|
+
}, subtitle)
|
|
3764
|
+
),
|
|
3765
|
+
children,
|
|
3766
|
+
(legend || footer) && React.createElement(
|
|
3767
|
+
"div",
|
|
3768
|
+
{
|
|
3769
|
+
style: {
|
|
3770
|
+
display: "flex",
|
|
3771
|
+
alignItems: "center",
|
|
3772
|
+
justifyContent: legend ? "space-between" : "center",
|
|
3773
|
+
gap: 12,
|
|
3774
|
+
minHeight: 18
|
|
3775
|
+
}
|
|
3776
|
+
},
|
|
3777
|
+
legend && React.createElement(
|
|
3778
|
+
"div",
|
|
3779
|
+
{
|
|
3780
|
+
style: { display: "flex", alignItems: "center", gap: 12, flexWrap: "wrap", minWidth: 0 }
|
|
3781
|
+
},
|
|
3782
|
+
...legend.map((item, index) => React.createElement(
|
|
3783
|
+
"div",
|
|
3784
|
+
{
|
|
3785
|
+
key: `${item.label}-${index}`,
|
|
3786
|
+
style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 }
|
|
3787
|
+
},
|
|
3788
|
+
React.createElement("span", {
|
|
3789
|
+
style: {
|
|
3790
|
+
width: 14,
|
|
3791
|
+
height: 3,
|
|
3792
|
+
borderRadius: 999,
|
|
3793
|
+
backgroundColor: chartColor(item.color, c, index),
|
|
3794
|
+
display: "flex"
|
|
3795
|
+
}
|
|
3796
|
+
}),
|
|
3797
|
+
React.createElement("span", {
|
|
3798
|
+
style: { ...typography.tiny, ...textFitStyle(), color: c.textSecondary }
|
|
3799
|
+
}, item.label)
|
|
3800
|
+
))
|
|
3801
|
+
),
|
|
3802
|
+
footer && React.createElement("div", {
|
|
3803
|
+
style: { ...typography.tiny, ...textFitStyle("right"), color: c.textMuted }
|
|
3804
|
+
}, footer)
|
|
3805
|
+
)
|
|
3806
|
+
);
|
|
3807
|
+
}
|
|
3808
|
+
function StackedBar({
|
|
3809
|
+
segments,
|
|
3810
|
+
c,
|
|
3811
|
+
width = 480,
|
|
3812
|
+
height = 68,
|
|
3813
|
+
title,
|
|
3814
|
+
subtitle,
|
|
3815
|
+
showLegend = true
|
|
3816
|
+
}) {
|
|
3817
|
+
const positiveSegments = segments.filter((segment) => segment.value > 0);
|
|
3818
|
+
const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
|
|
3819
|
+
return React.createElement(
|
|
3820
|
+
"div",
|
|
3821
|
+
{
|
|
3822
|
+
style: {
|
|
3823
|
+
width,
|
|
3824
|
+
display: "flex",
|
|
3825
|
+
flexDirection: "column",
|
|
3826
|
+
gap: 10
|
|
3827
|
+
}
|
|
3828
|
+
},
|
|
3829
|
+
(title || subtitle) && React.createElement(
|
|
3830
|
+
"div",
|
|
3831
|
+
{
|
|
3832
|
+
style: {
|
|
3833
|
+
display: "flex",
|
|
3834
|
+
flexDirection: "column",
|
|
3835
|
+
gap: 3
|
|
3836
|
+
}
|
|
3837
|
+
},
|
|
3838
|
+
title && React.createElement("div", {
|
|
3839
|
+
style: { ...typography.label, color: c.textPrimary, fontWeight: 850 }
|
|
3840
|
+
}, title),
|
|
3841
|
+
subtitle && React.createElement("div", {
|
|
3842
|
+
style: { ...typography.tiny, color: c.textSecondary }
|
|
3843
|
+
}, subtitle)
|
|
3844
|
+
),
|
|
3845
|
+
React.createElement(
|
|
3846
|
+
"div",
|
|
3847
|
+
{
|
|
3848
|
+
style: {
|
|
3849
|
+
width,
|
|
3850
|
+
height,
|
|
3851
|
+
display: "flex",
|
|
3852
|
+
overflow: "hidden",
|
|
3853
|
+
borderRadius: 14,
|
|
3854
|
+
border: `1px solid ${c.borderLight}`,
|
|
3855
|
+
backgroundColor: c.bgCard,
|
|
3856
|
+
boxShadow: `0 8px 22px ${c.shadow}`
|
|
3857
|
+
}
|
|
3858
|
+
},
|
|
3859
|
+
...positiveSegments.map((segment, index) => {
|
|
3860
|
+
const share = total > 0 ? segment.value / total : 0;
|
|
3861
|
+
const segmentWidth = width * share;
|
|
3862
|
+
const color = chartColor(segment.color, c, index);
|
|
3863
|
+
return React.createElement(
|
|
3864
|
+
"div",
|
|
3865
|
+
{
|
|
3866
|
+
key: `${segment.label}-${index}`,
|
|
3867
|
+
style: {
|
|
3868
|
+
width: `${share * 100}%`,
|
|
3869
|
+
height: "100%",
|
|
3870
|
+
display: "flex",
|
|
3871
|
+
alignItems: "center",
|
|
3872
|
+
justifyContent: "center",
|
|
3873
|
+
backgroundColor: color,
|
|
3874
|
+
...index < positiveSegments.length - 1 ? { borderRight: `2px solid ${c.bgSubtle}` } : {}
|
|
3875
|
+
}
|
|
3876
|
+
},
|
|
3877
|
+
segmentWidth >= 64 && React.createElement("span", {
|
|
3878
|
+
style: {
|
|
3879
|
+
...typography.small,
|
|
3880
|
+
color: c.textOnColor,
|
|
3881
|
+
fontWeight: 900,
|
|
3882
|
+
whiteSpace: "nowrap"
|
|
3883
|
+
}
|
|
3884
|
+
}, segment.valueLabel ?? formatChartValue(share, "percent"))
|
|
3885
|
+
);
|
|
3886
|
+
})
|
|
3887
|
+
),
|
|
3888
|
+
showLegend && React.createElement(
|
|
3889
|
+
"div",
|
|
3890
|
+
{
|
|
3891
|
+
style: {
|
|
3892
|
+
display: "flex",
|
|
3893
|
+
alignItems: "center",
|
|
3894
|
+
gap: 16,
|
|
3895
|
+
flexWrap: "wrap"
|
|
3896
|
+
}
|
|
3897
|
+
},
|
|
3898
|
+
...positiveSegments.map((segment, index) => {
|
|
3899
|
+
const share = total > 0 ? segment.value / total : 0;
|
|
3900
|
+
return React.createElement(
|
|
3901
|
+
"div",
|
|
3902
|
+
{
|
|
3903
|
+
key: `legend-${segment.label}-${index}`,
|
|
3904
|
+
style: { display: "flex", alignItems: "center", gap: 7 }
|
|
3905
|
+
},
|
|
3906
|
+
React.createElement("span", {
|
|
3907
|
+
style: {
|
|
3908
|
+
width: 12,
|
|
3909
|
+
height: 12,
|
|
3910
|
+
borderRadius: 4,
|
|
3911
|
+
display: "flex",
|
|
3912
|
+
backgroundColor: chartColor(segment.color, c, index)
|
|
3913
|
+
}
|
|
3914
|
+
}),
|
|
3915
|
+
React.createElement("span", {
|
|
3916
|
+
style: { ...typography.tiny, color: c.textSecondary }
|
|
3917
|
+
}, `${segment.label} ${segment.valueLabel ?? formatChartValue(share, "percent")}`)
|
|
3918
|
+
);
|
|
3919
|
+
})
|
|
3920
|
+
)
|
|
3921
|
+
);
|
|
3922
|
+
}
|
|
3923
|
+
function BarChart({
|
|
3924
|
+
data,
|
|
3925
|
+
c,
|
|
3926
|
+
title,
|
|
3927
|
+
subtitle,
|
|
3928
|
+
width = 320,
|
|
3929
|
+
height = 220,
|
|
3930
|
+
min,
|
|
3931
|
+
max,
|
|
3932
|
+
format = "decimal",
|
|
3933
|
+
showGrid = true,
|
|
3934
|
+
showValues = true,
|
|
3935
|
+
yAxisLabel,
|
|
3936
|
+
footer
|
|
3937
|
+
}) {
|
|
3938
|
+
const margin = { top: 18, right: 18, bottom: 40, left: yAxisLabel ? 52 : 38 };
|
|
3939
|
+
const plot = createPlotArea(width, height, margin);
|
|
3940
|
+
const domain = chartDomain(data.map((item) => item.value), min, max);
|
|
3941
|
+
const ticks = chartTicks(domain.min, domain.max, 4);
|
|
3942
|
+
const barGap = Math.max(8, plot.innerWidth / Math.max(data.length, 1) * 0.18);
|
|
3943
|
+
const barWidth = Math.max(12, (plot.innerWidth - barGap * (data.length - 1)) / Math.max(data.length, 1));
|
|
3944
|
+
const zeroY = yInPlot(0, domain, plot);
|
|
3945
|
+
const baselineY = clamp(zeroY, plot.y, plot.bottom);
|
|
3946
|
+
const barGeometries = data.map((item, index) => {
|
|
3947
|
+
const x = plot.x + index * (barWidth + barGap);
|
|
3948
|
+
const valueY = yInPlot(item.value, domain, plot);
|
|
3949
|
+
const y = Math.min(valueY, baselineY);
|
|
3950
|
+
const barHeight = Math.max(4, Math.abs(baselineY - valueY));
|
|
3951
|
+
return { item, index, x, y, barHeight, valueY, color: chartColor(item.color, c, index) };
|
|
3952
|
+
});
|
|
3953
|
+
return ChartFrame({
|
|
3954
|
+
c,
|
|
3955
|
+
title,
|
|
3956
|
+
subtitle,
|
|
3957
|
+
width,
|
|
3958
|
+
footer,
|
|
3959
|
+
children: React.createElement(
|
|
3960
|
+
"div",
|
|
3961
|
+
{ style: { position: "relative", width, height, display: "flex" } },
|
|
3962
|
+
React.createElement(
|
|
3963
|
+
"svg",
|
|
3964
|
+
{ width, height, viewBox: `0 0 ${width} ${height}` },
|
|
3965
|
+
showGrid && React.createElement(
|
|
3966
|
+
"g",
|
|
3967
|
+
{},
|
|
3968
|
+
...ticks.map((tick) => {
|
|
3969
|
+
const y = yInPlot(tick, domain, plot);
|
|
3970
|
+
return React.createElement("line", {
|
|
3971
|
+
key: `tick-${tick}`,
|
|
3972
|
+
x1: plot.x,
|
|
3973
|
+
y1: y,
|
|
3974
|
+
x2: plot.right,
|
|
3975
|
+
y2: y,
|
|
3976
|
+
stroke: c.borderSubtle,
|
|
3977
|
+
strokeWidth: 1
|
|
3978
|
+
});
|
|
3979
|
+
})
|
|
3980
|
+
),
|
|
3981
|
+
React.createElement("line", { x1: plot.x, y1: plot.y, x2: plot.x, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
|
|
3982
|
+
React.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: 1.2 }),
|
|
3983
|
+
...barGeometries.map(
|
|
3984
|
+
({ item, index, x, y, barHeight, color }) => React.createElement("rect", {
|
|
3985
|
+
key: `${item.label}-${index}`,
|
|
3986
|
+
x,
|
|
3987
|
+
y,
|
|
3988
|
+
width: barWidth,
|
|
3989
|
+
height: barHeight,
|
|
3990
|
+
rx: 5,
|
|
3991
|
+
fill: color,
|
|
3992
|
+
opacity: 0.92
|
|
3993
|
+
})
|
|
3994
|
+
)
|
|
3995
|
+
),
|
|
3996
|
+
...ticks.map((tick) => {
|
|
3997
|
+
const y = yInPlot(tick, domain, plot);
|
|
3998
|
+
return chartLabel(`tick-label-${tick}`, formatChartValue(tick, format), plot.x - 8, y, c, { align: "right", width: 36 });
|
|
3999
|
+
}),
|
|
4000
|
+
yAxisLabel && chartLabel("y-axis-label", yAxisLabel, 12, plot.y + plot.innerHeight / 2, c, {
|
|
4001
|
+
width: plot.innerHeight,
|
|
4002
|
+
fontFamily: "Inter",
|
|
4003
|
+
fontWeight: 700,
|
|
4004
|
+
transform: "translate(-50%, -50%) rotate(-90deg)"
|
|
4005
|
+
}),
|
|
4006
|
+
...barGeometries.flatMap(({ item, index, x, y, barHeight, valueY }) => [
|
|
4007
|
+
...showValues ? [chartLabel(
|
|
4008
|
+
`bar-value-${index}`,
|
|
4009
|
+
item.valueLabel ?? formatChartValue(item.value, format),
|
|
4010
|
+
x + barWidth / 2,
|
|
4011
|
+
item.value < 0 ? y + barHeight + 12 : clamp(valueY - 8, 10, height - 28),
|
|
4012
|
+
c,
|
|
4013
|
+
{ color: c.textPrimary, fontWeight: 800, width: 54, bounds: { x: plot.x, y: 0, width: plot.innerWidth, height } }
|
|
4014
|
+
)] : [],
|
|
4015
|
+
chartLabel(`bar-label-${index}`, item.label, x + barWidth / 2, height - 16, c, { width: 54 })
|
|
4016
|
+
])
|
|
4017
|
+
)
|
|
4018
|
+
});
|
|
4019
|
+
}
|
|
4020
|
+
function LineChart({
|
|
4021
|
+
series,
|
|
4022
|
+
c,
|
|
4023
|
+
title,
|
|
4024
|
+
subtitle,
|
|
4025
|
+
width = 420,
|
|
4026
|
+
height = 240,
|
|
4027
|
+
labels,
|
|
4028
|
+
min,
|
|
4029
|
+
max,
|
|
4030
|
+
format = "decimal",
|
|
4031
|
+
showGrid = true,
|
|
4032
|
+
showPoints = true,
|
|
4033
|
+
yAxisLabel,
|
|
4034
|
+
footer
|
|
4035
|
+
}) {
|
|
4036
|
+
const margin = { top: 18, right: 20, bottom: labels ? 36 : 24, left: yAxisLabel ? 54 : 40 };
|
|
4037
|
+
const plot = createPlotArea(width, height, margin);
|
|
4038
|
+
const allValues = series.flatMap((item) => item.points);
|
|
4039
|
+
const domain = chartDomain(allValues, min, max);
|
|
4040
|
+
const maxPoints = Math.max(...series.map((item) => item.points.length), 1);
|
|
4041
|
+
const xStep = maxPoints <= 1 ? plot.innerWidth : plot.innerWidth / (maxPoints - 1);
|
|
4042
|
+
const ticks = chartTicks(domain.min, domain.max, 4);
|
|
4043
|
+
const pointFor = (value, index) => {
|
|
4044
|
+
const x = plot.x + index * xStep;
|
|
4045
|
+
const y = yInPlot(value, domain, plot);
|
|
4046
|
+
return { x, y };
|
|
4047
|
+
};
|
|
4048
|
+
const pathFor = (points) => points.map((value, index) => {
|
|
4049
|
+
const point = pointFor(value, index);
|
|
4050
|
+
return `${index === 0 ? "M" : "L"} ${point.x.toFixed(1)} ${point.y.toFixed(1)}`;
|
|
4051
|
+
}).join(" ");
|
|
4052
|
+
return ChartFrame({
|
|
4053
|
+
c,
|
|
4054
|
+
title,
|
|
4055
|
+
subtitle,
|
|
4056
|
+
width,
|
|
4057
|
+
footer,
|
|
4058
|
+
legend: series.map((item, index) => ({ label: item.name, color: item.color ?? chartPalette[index % chartPalette.length] })),
|
|
4059
|
+
children: React.createElement(
|
|
4060
|
+
"div",
|
|
4061
|
+
{ style: { position: "relative", width, height, display: "flex" } },
|
|
4062
|
+
React.createElement(
|
|
4063
|
+
"svg",
|
|
4064
|
+
{ width, height, viewBox: `0 0 ${width} ${height}` },
|
|
4065
|
+
showGrid && React.createElement(
|
|
4066
|
+
"g",
|
|
4067
|
+
{},
|
|
4068
|
+
...ticks.map((tick) => {
|
|
4069
|
+
const y = yInPlot(tick, domain, plot);
|
|
4070
|
+
return React.createElement("line", {
|
|
4071
|
+
key: `line-tick-${tick}`,
|
|
4072
|
+
x1: plot.x,
|
|
4073
|
+
y1: y,
|
|
4074
|
+
x2: plot.right,
|
|
4075
|
+
y2: y,
|
|
4076
|
+
stroke: c.borderSubtle,
|
|
4077
|
+
strokeWidth: 1
|
|
4078
|
+
});
|
|
4079
|
+
})
|
|
4080
|
+
),
|
|
4081
|
+
React.createElement("line", { x1: plot.x, y1: plot.y, x2: plot.x, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
|
|
4082
|
+
React.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
|
|
4083
|
+
...series.flatMap((item, seriesIndex) => {
|
|
4084
|
+
if (item.points.length === 0) return [];
|
|
4085
|
+
const color = chartColor(item.color, c, seriesIndex);
|
|
4086
|
+
const linePath = pathFor(item.points);
|
|
4087
|
+
const areaPath = item.area && item.points.length > 1 ? `${linePath} L ${plot.x + (item.points.length - 1) * xStep} ${plot.bottom} L ${plot.x} ${plot.bottom} Z` : "";
|
|
4088
|
+
const elements = [];
|
|
4089
|
+
if (areaPath) {
|
|
4090
|
+
elements.push(React.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.12 }));
|
|
4091
|
+
}
|
|
4092
|
+
elements.push(React.createElement("path", {
|
|
4093
|
+
key: `${item.name}-line`,
|
|
4094
|
+
d: linePath,
|
|
4095
|
+
fill: "none",
|
|
4096
|
+
stroke: color,
|
|
4097
|
+
strokeWidth: 4,
|
|
4098
|
+
strokeLinecap: "round",
|
|
4099
|
+
strokeLinejoin: "round"
|
|
4100
|
+
}));
|
|
4101
|
+
if (showPoints) {
|
|
4102
|
+
elements.push(...item.points.map((value, index) => {
|
|
4103
|
+
const point = pointFor(value, index);
|
|
4104
|
+
return React.createElement("circle", {
|
|
4105
|
+
key: `${item.name}-point-${index}`,
|
|
4106
|
+
cx: point.x,
|
|
4107
|
+
cy: point.y,
|
|
4108
|
+
r: 5,
|
|
4109
|
+
fill: c.bgCard,
|
|
4110
|
+
stroke: color,
|
|
4111
|
+
strokeWidth: 3
|
|
4112
|
+
});
|
|
4113
|
+
}));
|
|
4114
|
+
}
|
|
4115
|
+
return elements;
|
|
4116
|
+
})
|
|
4117
|
+
),
|
|
4118
|
+
...ticks.map((tick) => {
|
|
4119
|
+
const y = yInPlot(tick, domain, plot);
|
|
4120
|
+
return chartLabel(`line-tick-label-${tick}`, formatChartValue(tick, format), plot.x - 8, y, c, { align: "right", width: 36 });
|
|
4121
|
+
}),
|
|
4122
|
+
yAxisLabel && chartLabel("line-y-axis-label", yAxisLabel, 12, plot.y + plot.innerHeight / 2, c, {
|
|
4123
|
+
width: plot.innerHeight,
|
|
4124
|
+
fontFamily: "Inter",
|
|
4125
|
+
fontWeight: 700,
|
|
4126
|
+
transform: "translate(-50%, -50%) rotate(-90deg)"
|
|
4127
|
+
}),
|
|
4128
|
+
...(labels ?? []).map((label, index, allLabels) => {
|
|
4129
|
+
const x = plot.x + index * xStep;
|
|
4130
|
+
const align = index === 0 ? "left" : index === allLabels.length - 1 ? "right" : "center";
|
|
4131
|
+
return chartLabel(`line-x-${label}`, label, x, height - 14, c, { align, width: 72 });
|
|
4132
|
+
})
|
|
4133
|
+
)
|
|
4134
|
+
});
|
|
4135
|
+
}
|
|
4136
|
+
function ScatterPlot({
|
|
4137
|
+
points,
|
|
4138
|
+
c,
|
|
4139
|
+
title,
|
|
4140
|
+
subtitle,
|
|
4141
|
+
width = 380,
|
|
4142
|
+
height = 260,
|
|
4143
|
+
xMin,
|
|
4144
|
+
xMax,
|
|
4145
|
+
yMin,
|
|
4146
|
+
yMax,
|
|
4147
|
+
xAxisLabel,
|
|
4148
|
+
yAxisLabel,
|
|
4149
|
+
formatX = "decimal",
|
|
4150
|
+
formatY = "decimal",
|
|
4151
|
+
showGrid = true,
|
|
4152
|
+
footer
|
|
4153
|
+
}) {
|
|
4154
|
+
const margin = { top: 20, right: 24, bottom: xAxisLabel ? 46 : 34, left: yAxisLabel ? 54 : 42 };
|
|
4155
|
+
const plot = createPlotArea(width, height, margin);
|
|
4156
|
+
const xDomain = chartDomain(points.map((item) => item.x), xMin, xMax);
|
|
4157
|
+
const yDomain = chartDomain(points.map((item) => item.y), yMin, yMax);
|
|
4158
|
+
const xTicks = chartTicks(xDomain.min, xDomain.max, 4);
|
|
4159
|
+
const yTicks = chartTicks(yDomain.min, yDomain.max, 4);
|
|
4160
|
+
const pointFor = (xValue, yValue) => ({
|
|
4161
|
+
x: xInPlot(xValue, xDomain, plot),
|
|
4162
|
+
y: yInPlot(yValue, yDomain, plot)
|
|
4163
|
+
});
|
|
4164
|
+
const pointGeometries = points.map((item, index) => {
|
|
4165
|
+
const point = pointFor(item.x, item.y);
|
|
4166
|
+
return { item, index, point, color: chartColor(item.color, c, index) };
|
|
4167
|
+
});
|
|
4168
|
+
return ChartFrame({
|
|
4169
|
+
c,
|
|
4170
|
+
title,
|
|
4171
|
+
subtitle,
|
|
4172
|
+
width,
|
|
4173
|
+
footer,
|
|
4174
|
+
children: React.createElement(
|
|
4175
|
+
"div",
|
|
4176
|
+
{ style: { position: "relative", width, height, display: "flex" } },
|
|
4177
|
+
React.createElement(
|
|
4178
|
+
"svg",
|
|
4179
|
+
{ width, height, viewBox: `0 0 ${width} ${height}` },
|
|
4180
|
+
showGrid && React.createElement(
|
|
4181
|
+
"g",
|
|
4182
|
+
{},
|
|
4183
|
+
...xTicks.map((tick) => {
|
|
4184
|
+
const x = xInPlot(tick, xDomain, plot);
|
|
4185
|
+
return React.createElement("line", {
|
|
4186
|
+
key: `x-tick-${tick}`,
|
|
4187
|
+
x1: x,
|
|
4188
|
+
y1: plot.y,
|
|
4189
|
+
x2: x,
|
|
4190
|
+
y2: plot.bottom,
|
|
4191
|
+
stroke: c.borderSubtle,
|
|
4192
|
+
strokeWidth: 1
|
|
4193
|
+
});
|
|
4194
|
+
}),
|
|
4195
|
+
...yTicks.map((tick) => {
|
|
4196
|
+
const y = yInPlot(tick, yDomain, plot);
|
|
4197
|
+
return React.createElement("line", {
|
|
4198
|
+
key: `y-tick-${tick}`,
|
|
4199
|
+
x1: plot.x,
|
|
4200
|
+
y1: y,
|
|
4201
|
+
x2: plot.right,
|
|
4202
|
+
y2: y,
|
|
4203
|
+
stroke: c.borderSubtle,
|
|
4204
|
+
strokeWidth: 1
|
|
4205
|
+
});
|
|
4206
|
+
})
|
|
4207
|
+
),
|
|
4208
|
+
React.createElement("rect", { x: plot.x, y: plot.y, width: plot.innerWidth, height: plot.innerHeight, fill: "transparent", stroke: c.borderLight, strokeWidth: 1.2, rx: 6 }),
|
|
4209
|
+
...pointGeometries.map(
|
|
4210
|
+
({ item, index, point, color }) => React.createElement("circle", {
|
|
4211
|
+
key: `${item.label ?? "point"}-${index}`,
|
|
4212
|
+
cx: point.x,
|
|
4213
|
+
cy: point.y,
|
|
4214
|
+
r: item.size ?? 7,
|
|
4215
|
+
fill: color,
|
|
4216
|
+
opacity: 0.92,
|
|
4217
|
+
stroke: c.bgCard,
|
|
4218
|
+
strokeWidth: 2
|
|
4219
|
+
})
|
|
4220
|
+
)
|
|
4221
|
+
),
|
|
4222
|
+
...xTicks.map((tick) => {
|
|
4223
|
+
const x = xInPlot(tick, xDomain, plot);
|
|
4224
|
+
return chartLabel(`x-tick-label-${tick}`, formatChartValue(tick, formatX), x, plot.bottom + 18, c, { width: 44 });
|
|
4225
|
+
}),
|
|
4226
|
+
...yTicks.map((tick) => {
|
|
4227
|
+
const y = yInPlot(tick, yDomain, plot);
|
|
4228
|
+
return chartLabel(`y-tick-label-${tick}`, formatChartValue(tick, formatY), plot.x - 8, y, c, { align: "right", width: 36 });
|
|
4229
|
+
}),
|
|
4230
|
+
xAxisLabel && chartLabel("scatter-x-axis-label", xAxisLabel, plot.x + plot.innerWidth / 2, height - 8, c, {
|
|
4231
|
+
width: plot.innerWidth,
|
|
4232
|
+
fontFamily: "Inter",
|
|
4233
|
+
fontWeight: 700
|
|
4234
|
+
}),
|
|
4235
|
+
yAxisLabel && chartLabel("scatter-y-axis-label", yAxisLabel, 12, plot.y + plot.innerHeight / 2, c, {
|
|
4236
|
+
width: plot.innerHeight,
|
|
4237
|
+
fontFamily: "Inter",
|
|
4238
|
+
fontWeight: 700,
|
|
4239
|
+
transform: "translate(-50%, -50%) rotate(-90deg)"
|
|
4240
|
+
}),
|
|
4241
|
+
...pointGeometries.flatMap(({ item, index, point, color }) => {
|
|
4242
|
+
if (!item.label) return [];
|
|
4243
|
+
const placement = pointLabelPlacement(point.x, point.y, plot, index);
|
|
4244
|
+
return [chartLabel(`scatter-point-label-${index}`, item.label, placement.x, placement.y, c, {
|
|
4245
|
+
align: placement.align,
|
|
4246
|
+
width: placement.width,
|
|
4247
|
+
bounds: placement.bounds,
|
|
4248
|
+
color,
|
|
4249
|
+
fontWeight: 800
|
|
4250
|
+
})];
|
|
4251
|
+
})
|
|
4252
|
+
)
|
|
4253
|
+
});
|
|
4254
|
+
}
|
|
4255
|
+
function QuadrantChart({
|
|
4256
|
+
points,
|
|
4257
|
+
regions,
|
|
4258
|
+
c,
|
|
4259
|
+
title,
|
|
4260
|
+
subtitle,
|
|
4261
|
+
width = 700,
|
|
4262
|
+
height = 360,
|
|
4263
|
+
xAxisLabel,
|
|
4264
|
+
yAxisLabel,
|
|
4265
|
+
footer
|
|
4266
|
+
}) {
|
|
4267
|
+
const margin = { top: 18, right: 20, bottom: xAxisLabel ? 46 : 24, left: yAxisLabel ? 54 : 24 };
|
|
4268
|
+
const plot = createPlotArea(width, height, margin);
|
|
4269
|
+
const halfWidth = plot.innerWidth / 2;
|
|
4270
|
+
const halfHeight = plot.innerHeight / 2;
|
|
4271
|
+
const midX = plot.x + halfWidth;
|
|
4272
|
+
const midY = plot.y + halfHeight;
|
|
4273
|
+
const regionEntries = [
|
|
4274
|
+
{ key: "top-left", region: regions.topLeft, x: plot.x, y: plot.y },
|
|
4275
|
+
{ key: "top-right", region: regions.topRight, x: midX, y: plot.y },
|
|
4276
|
+
{ key: "bottom-left", region: regions.bottomLeft, x: plot.x, y: midY },
|
|
4277
|
+
{ key: "bottom-right", region: regions.bottomRight, x: midX, y: midY }
|
|
4278
|
+
];
|
|
4279
|
+
const pointGeometries = points.map((point, index) => ({
|
|
4280
|
+
point,
|
|
4281
|
+
index,
|
|
4282
|
+
x: plot.x + clamp(point.x, 0, 1) * plot.innerWidth,
|
|
4283
|
+
y: plot.y + plot.innerHeight - clamp(point.y, 0, 1) * plot.innerHeight,
|
|
4284
|
+
color: chartColor(point.color, c, index)
|
|
4285
|
+
}));
|
|
4286
|
+
return ChartFrame({
|
|
4287
|
+
c,
|
|
4288
|
+
title,
|
|
4289
|
+
subtitle,
|
|
4290
|
+
width,
|
|
4291
|
+
footer,
|
|
4292
|
+
children: React.createElement(
|
|
4293
|
+
"div",
|
|
4294
|
+
{
|
|
4295
|
+
style: { position: "relative", width, height, display: "flex" }
|
|
4296
|
+
},
|
|
4297
|
+
React.createElement(
|
|
4298
|
+
"svg",
|
|
4299
|
+
{ width, height, viewBox: `0 0 ${width} ${height}` },
|
|
4300
|
+
...regionEntries.map(({ key, region, x, y }, index) => React.createElement("rect", {
|
|
4301
|
+
key: `quadrant-${key}`,
|
|
4302
|
+
x,
|
|
4303
|
+
y,
|
|
4304
|
+
width: halfWidth,
|
|
4305
|
+
height: halfHeight,
|
|
4306
|
+
fill: chartColor(region.color, c, index),
|
|
4307
|
+
opacity: 0.1
|
|
4308
|
+
})),
|
|
4309
|
+
React.createElement("rect", {
|
|
4310
|
+
x: plot.x,
|
|
4311
|
+
y: plot.y,
|
|
4312
|
+
width: plot.innerWidth,
|
|
4313
|
+
height: plot.innerHeight,
|
|
4314
|
+
fill: "transparent",
|
|
4315
|
+
stroke: c.borderLight,
|
|
4316
|
+
strokeWidth: 1.2,
|
|
4317
|
+
rx: 8
|
|
4318
|
+
}),
|
|
4319
|
+
React.createElement("line", {
|
|
4320
|
+
x1: midX,
|
|
4321
|
+
y1: plot.y,
|
|
4322
|
+
x2: midX,
|
|
4323
|
+
y2: plot.bottom,
|
|
4324
|
+
stroke: c.borderLight,
|
|
4325
|
+
strokeWidth: 1.4
|
|
4326
|
+
}),
|
|
4327
|
+
React.createElement("line", {
|
|
4328
|
+
x1: plot.x,
|
|
4329
|
+
y1: midY,
|
|
4330
|
+
x2: plot.right,
|
|
4331
|
+
y2: midY,
|
|
4332
|
+
stroke: c.borderLight,
|
|
4333
|
+
strokeWidth: 1.4
|
|
4334
|
+
}),
|
|
4335
|
+
...pointGeometries.map(({ point, index, x, y, color }) => React.createElement("circle", {
|
|
4336
|
+
key: `quadrant-point-${point.label ?? index}`,
|
|
4337
|
+
cx: x,
|
|
4338
|
+
cy: y,
|
|
4339
|
+
r: point.size ?? 8,
|
|
4340
|
+
fill: color,
|
|
4341
|
+
stroke: c.bgCard,
|
|
4342
|
+
strokeWidth: 3
|
|
4343
|
+
}))
|
|
4344
|
+
),
|
|
4345
|
+
...regionEntries.flatMap(({ key, region, x, y }, index) => {
|
|
4346
|
+
const color = chartColor(region.color, c, index);
|
|
4347
|
+
return [
|
|
4348
|
+
chartLabel(`quadrant-label-${key}`, region.label, x + halfWidth / 2, y + 18, c, {
|
|
4349
|
+
width: halfWidth - 24,
|
|
4350
|
+
color,
|
|
4351
|
+
fontFamily: "Inter",
|
|
4352
|
+
fontWeight: 900,
|
|
4353
|
+
fontSize: 11
|
|
4354
|
+
}),
|
|
4355
|
+
...region.detail ? [chartLabel(`quadrant-detail-${key}`, region.detail, x + halfWidth / 2, y + 34, c, {
|
|
4356
|
+
width: halfWidth - 24,
|
|
4357
|
+
color: c.textMuted,
|
|
4358
|
+
fontSize: 9
|
|
4359
|
+
})] : []
|
|
4360
|
+
];
|
|
4361
|
+
}),
|
|
4362
|
+
...pointGeometries.flatMap(({ point, index, x, y, color }) => {
|
|
4363
|
+
if (!point.label) return [];
|
|
4364
|
+
const placement = pointLabelPlacement(x, y, plot, index, 110);
|
|
4365
|
+
return [chartLabel(`quadrant-point-label-${index}`, point.label, placement.x, placement.y, c, {
|
|
4366
|
+
align: placement.align,
|
|
4367
|
+
width: 110,
|
|
4368
|
+
bounds: placement.bounds,
|
|
4369
|
+
color,
|
|
4370
|
+
fontFamily: "Inter",
|
|
4371
|
+
fontWeight: 850,
|
|
4372
|
+
fontSize: 10
|
|
4373
|
+
})];
|
|
4374
|
+
}),
|
|
4375
|
+
xAxisLabel && chartLabel("quadrant-x-axis-label", xAxisLabel, plot.x + plot.innerWidth / 2, height - 8, c, {
|
|
4376
|
+
width: plot.innerWidth,
|
|
4377
|
+
fontFamily: "Inter",
|
|
4378
|
+
fontWeight: 700
|
|
4379
|
+
}),
|
|
4380
|
+
yAxisLabel && chartLabel("quadrant-y-axis-label", yAxisLabel, 12, plot.y + plot.innerHeight / 2, c, {
|
|
4381
|
+
width: plot.innerHeight,
|
|
4382
|
+
fontFamily: "Inter",
|
|
4383
|
+
fontWeight: 700,
|
|
4384
|
+
transform: "translate(-50%, -50%) rotate(-90deg)"
|
|
4385
|
+
})
|
|
4386
|
+
)
|
|
4387
|
+
});
|
|
4388
|
+
}
|
|
4389
|
+
function IntervalPlot({
|
|
4390
|
+
data,
|
|
4391
|
+
c,
|
|
4392
|
+
title,
|
|
4393
|
+
subtitle,
|
|
4394
|
+
width = 640,
|
|
4395
|
+
height = 220,
|
|
4396
|
+
min,
|
|
4397
|
+
max,
|
|
4398
|
+
format = "decimal",
|
|
4399
|
+
axisLabel,
|
|
4400
|
+
footer
|
|
4401
|
+
}) {
|
|
4402
|
+
const margin = { top: 22, right: 28, bottom: axisLabel ? 44 : 30, left: 96 };
|
|
4403
|
+
const plot = createPlotArea(width, height, margin);
|
|
4404
|
+
const rowGap = data.length <= 1 ? 0 : plot.innerHeight / data.length;
|
|
4405
|
+
const domain = chartDomain(data.flatMap((item) => [item.low, item.mid, item.high]), min, max);
|
|
4406
|
+
const ticks = chartTicks(domain.min, domain.max, 5);
|
|
4407
|
+
const scaleX = (value) => xInPlot(value, domain, plot);
|
|
4408
|
+
const rows = data.map((item, index) => {
|
|
4409
|
+
const y = data.length <= 1 ? plot.y + plot.innerHeight / 2 : plot.y + rowGap * index + rowGap / 2;
|
|
4410
|
+
return {
|
|
4411
|
+
item,
|
|
4412
|
+
index,
|
|
4413
|
+
y,
|
|
4414
|
+
color: chartColor(item.color, c, index),
|
|
4415
|
+
lowX: scaleX(item.low),
|
|
4416
|
+
midX: scaleX(item.mid),
|
|
4417
|
+
highX: scaleX(item.high)
|
|
4418
|
+
};
|
|
4419
|
+
});
|
|
4420
|
+
return ChartFrame({
|
|
4421
|
+
c,
|
|
4422
|
+
title,
|
|
4423
|
+
subtitle,
|
|
4424
|
+
width,
|
|
4425
|
+
footer,
|
|
4426
|
+
children: React.createElement(
|
|
4427
|
+
"div",
|
|
4428
|
+
{ style: { position: "relative", width, height, display: "flex" } },
|
|
4429
|
+
React.createElement(
|
|
4430
|
+
"svg",
|
|
4431
|
+
{ width, height, viewBox: `0 0 ${width} ${height}` },
|
|
4432
|
+
...ticks.map((tick) => {
|
|
4433
|
+
const x = scaleX(tick);
|
|
4434
|
+
return React.createElement("line", {
|
|
4435
|
+
key: `interval-tick-${tick}`,
|
|
4436
|
+
x1: x,
|
|
4437
|
+
y1: plot.y,
|
|
4438
|
+
x2: x,
|
|
4439
|
+
y2: plot.bottom,
|
|
4440
|
+
stroke: c.borderSubtle,
|
|
4441
|
+
strokeWidth: 1
|
|
4442
|
+
});
|
|
4443
|
+
}),
|
|
4444
|
+
React.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
|
|
4445
|
+
...rows.flatMap(({ item, index, y, color, lowX, midX, highX }) => [
|
|
4446
|
+
React.createElement("line", { key: `${item.label}-range-${index}`, x1: lowX, y1: y, x2: highX, y2: y, stroke: color, strokeWidth: 9, strokeLinecap: "round", opacity: 0.9 }),
|
|
4447
|
+
React.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
|
|
4448
|
+
])
|
|
4449
|
+
),
|
|
4450
|
+
...ticks.map((tick) => {
|
|
4451
|
+
const x = scaleX(tick);
|
|
4452
|
+
return chartLabel(`interval-tick-label-${tick}`, formatChartValue(tick, format), x, height - margin.bottom + 17, c, { width: 48 });
|
|
4453
|
+
}),
|
|
4454
|
+
axisLabel && chartLabel("interval-axis-label", axisLabel, plot.x + plot.innerWidth / 2, height - 8, c, {
|
|
4455
|
+
width: plot.innerWidth,
|
|
4456
|
+
fontFamily: "Inter",
|
|
4457
|
+
fontWeight: 700
|
|
4458
|
+
}),
|
|
4459
|
+
...rows.flatMap(({ item, index, y, lowX, midX, highX }) => [
|
|
4460
|
+
chartLabel(`interval-row-label-${index}`, item.label, plot.x - 12, y, c, {
|
|
4461
|
+
align: "right",
|
|
4462
|
+
width: 84,
|
|
4463
|
+
color: c.textPrimary,
|
|
4464
|
+
fontFamily: "Inter",
|
|
4465
|
+
fontWeight: 900
|
|
4466
|
+
}),
|
|
4467
|
+
chartLabel(`interval-low-${index}`, item.lowLabel ?? formatChartValue(item.low, format), lowX, y + 25, c, { width: 48, bounds: { x: plot.x, y: 0, width: plot.innerWidth, height } }),
|
|
4468
|
+
chartLabel(`interval-mid-${index}`, item.midLabel ?? formatChartValue(item.mid, format), midX, y - 16, c, {
|
|
4469
|
+
width: 48,
|
|
4470
|
+
bounds: { x: plot.x, y: 0, width: plot.innerWidth, height },
|
|
4471
|
+
color: c.textPrimary,
|
|
4472
|
+
fontWeight: 900
|
|
4473
|
+
}),
|
|
4474
|
+
chartLabel(`interval-high-${index}`, item.highLabel ?? formatChartValue(item.high, format), highX, y + 25, c, { width: 48, bounds: { x: plot.x, y: 0, width: plot.innerWidth, height } })
|
|
4475
|
+
])
|
|
4476
|
+
)
|
|
4477
|
+
});
|
|
4478
|
+
}
|
|
4479
|
+
function Badge({ label, c, color = "primary" }) {
|
|
4480
|
+
const solidColor = getColor(color, c);
|
|
4481
|
+
return React.createElement("div", {
|
|
4482
|
+
style: {
|
|
4483
|
+
display: "flex",
|
|
4484
|
+
alignItems: "center",
|
|
4485
|
+
justifyContent: "center",
|
|
4486
|
+
backgroundColor: `${solidColor}20`,
|
|
4487
|
+
color: solidColor,
|
|
4488
|
+
borderRadius: 999,
|
|
4489
|
+
padding: "4px 12px",
|
|
4490
|
+
fontSize: 11,
|
|
4491
|
+
fontWeight: 600,
|
|
4492
|
+
fontFamily: "Inter",
|
|
4493
|
+
border: `1px solid ${solidColor}40`
|
|
4494
|
+
}
|
|
4495
|
+
}, label);
|
|
4496
|
+
}
|
|
4497
|
+
function DotPoint({ x, y, label, color, size = 12, labelOffset }) {
|
|
4498
|
+
const offX = labelOffset?.x ?? 0;
|
|
4499
|
+
const offY = labelOffset?.y ?? -22;
|
|
4500
|
+
return [
|
|
4501
|
+
// Dot
|
|
4502
|
+
React.createElement("div", {
|
|
4503
|
+
key: `dot-${label}`,
|
|
4504
|
+
style: {
|
|
4505
|
+
position: "absolute",
|
|
4506
|
+
left: x - size / 2,
|
|
4507
|
+
top: y - size / 2,
|
|
4508
|
+
width: size,
|
|
4509
|
+
height: size,
|
|
4510
|
+
borderRadius: "50%",
|
|
4511
|
+
backgroundColor: color,
|
|
4512
|
+
boxShadow: `0 0 14px ${color}50`,
|
|
4513
|
+
display: "flex"
|
|
4514
|
+
}
|
|
4515
|
+
}),
|
|
4516
|
+
// Label
|
|
4517
|
+
React.createElement("div", {
|
|
4518
|
+
key: `label-${label}`,
|
|
4519
|
+
style: {
|
|
4520
|
+
position: "absolute",
|
|
4521
|
+
left: x + offX - 30,
|
|
4522
|
+
top: y + offY,
|
|
4523
|
+
fontSize: 13,
|
|
4524
|
+
fontWeight: 600,
|
|
4525
|
+
color,
|
|
4526
|
+
fontFamily: "JetBrains Mono",
|
|
4527
|
+
textAlign: "center",
|
|
4528
|
+
width: 60
|
|
4529
|
+
}
|
|
4530
|
+
}, label)
|
|
4531
|
+
];
|
|
4532
|
+
}
|
|
4533
|
+
function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
|
|
4534
|
+
const dx = x2 - x1;
|
|
4535
|
+
const dy = y2 - y1;
|
|
4536
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
4537
|
+
const numDots = Math.floor(length / dotSpacing);
|
|
4538
|
+
const dots = [];
|
|
4539
|
+
for (let i = 0; i < numDots; i++) {
|
|
4540
|
+
if (i % 2 === 1) continue;
|
|
4541
|
+
const t = i / numDots;
|
|
4542
|
+
dots.push(
|
|
4543
|
+
React.createElement("div", {
|
|
4544
|
+
key: `dash-${i}`,
|
|
4545
|
+
style: {
|
|
4546
|
+
position: "absolute",
|
|
4547
|
+
left: x1 + t * dx - dotSize / 2,
|
|
4548
|
+
top: y1 + t * dy - dotSize / 2,
|
|
4549
|
+
width: dotSize,
|
|
4550
|
+
height: dotSize,
|
|
4551
|
+
borderRadius: "50%",
|
|
4552
|
+
backgroundColor: color
|
|
4553
|
+
}
|
|
4554
|
+
})
|
|
4555
|
+
);
|
|
4556
|
+
}
|
|
4557
|
+
return dots;
|
|
4558
|
+
}
|
|
4559
|
+
function Legend({ items, c, title }) {
|
|
4560
|
+
return React.createElement(
|
|
4561
|
+
"div",
|
|
4562
|
+
{
|
|
4563
|
+
style: {
|
|
4564
|
+
display: "flex",
|
|
4565
|
+
flexDirection: "column",
|
|
4566
|
+
gap: 10,
|
|
4567
|
+
backgroundColor: c.bgCard,
|
|
4568
|
+
borderRadius: 8,
|
|
4569
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
4570
|
+
padding: "14px 16px"
|
|
4571
|
+
}
|
|
4572
|
+
},
|
|
4573
|
+
title && React.createElement("div", {
|
|
4574
|
+
style: {
|
|
4575
|
+
fontSize: 11,
|
|
4576
|
+
fontWeight: 700,
|
|
4577
|
+
color: c.textSecondary,
|
|
4578
|
+
textTransform: "uppercase",
|
|
4579
|
+
letterSpacing: 1,
|
|
4580
|
+
fontFamily: "Inter"
|
|
4581
|
+
}
|
|
4582
|
+
}, title),
|
|
4583
|
+
...items.map(
|
|
4584
|
+
(item, i) => React.createElement(
|
|
4585
|
+
"div",
|
|
4586
|
+
{
|
|
4587
|
+
key: `legend-${i}`,
|
|
4588
|
+
style: { display: "flex", alignItems: "center", gap: 8 }
|
|
4589
|
+
},
|
|
4590
|
+
React.createElement("div", {
|
|
4591
|
+
style: {
|
|
4592
|
+
width: 16,
|
|
4593
|
+
height: item.style === "dashed" ? 0 : 2,
|
|
4594
|
+
backgroundColor: item.color,
|
|
4595
|
+
...item.style === "dashed" ? {
|
|
4596
|
+
borderTop: `2px dashed ${item.color}`
|
|
4597
|
+
} : {}
|
|
4598
|
+
}
|
|
4599
|
+
}),
|
|
4600
|
+
React.createElement("div", {
|
|
4601
|
+
style: {
|
|
4602
|
+
fontSize: 11,
|
|
4603
|
+
color: c.textMuted,
|
|
4604
|
+
fontFamily: "Inter"
|
|
4605
|
+
}
|
|
4606
|
+
}, item.label)
|
|
4607
|
+
)
|
|
4608
|
+
)
|
|
4609
|
+
);
|
|
4610
|
+
}
|
|
4611
|
+
export {
|
|
4612
|
+
Arrow,
|
|
4613
|
+
ArrowMarkerDef,
|
|
4614
|
+
AxisPlot,
|
|
4615
|
+
Badge,
|
|
4616
|
+
BadgePill,
|
|
4617
|
+
BarChart,
|
|
4618
|
+
Box,
|
|
4619
|
+
CalloutCard,
|
|
4620
|
+
Canvas,
|
|
4621
|
+
Card,
|
|
4622
|
+
ChartFrame,
|
|
4623
|
+
CodeBlock,
|
|
4624
|
+
Column,
|
|
4625
|
+
Comparison,
|
|
4626
|
+
Connector,
|
|
4627
|
+
DashedLine,
|
|
4628
|
+
DataTable,
|
|
4629
|
+
DetailList,
|
|
4630
|
+
DotPoint,
|
|
4631
|
+
EquationCard,
|
|
4632
|
+
Flow,
|
|
4633
|
+
FlowArrow,
|
|
4634
|
+
GradientChip,
|
|
4635
|
+
GraphDiagram,
|
|
4636
|
+
Grid,
|
|
4637
|
+
Heatmap,
|
|
4638
|
+
IntervalPlot,
|
|
4639
|
+
KeyValueList,
|
|
4640
|
+
LayeredNetwork,
|
|
4641
|
+
Legend,
|
|
4642
|
+
LineChart,
|
|
4643
|
+
MathText,
|
|
4644
|
+
Matrix,
|
|
4645
|
+
MetricCard,
|
|
4646
|
+
MiniBarChart,
|
|
4647
|
+
Panel,
|
|
4648
|
+
Pipeline,
|
|
4649
|
+
ProgressList,
|
|
4650
|
+
ProgressRow,
|
|
4651
|
+
QuadrantChart,
|
|
4652
|
+
Row,
|
|
4653
|
+
ScatterPlot,
|
|
4654
|
+
Scene,
|
|
4655
|
+
Stack,
|
|
4656
|
+
StackedBar,
|
|
4657
|
+
StatusList,
|
|
4658
|
+
StatusRow,
|
|
4659
|
+
StepCard,
|
|
4660
|
+
SvgFrame,
|
|
4661
|
+
SvgMathText,
|
|
4662
|
+
SvgPoint,
|
|
4663
|
+
TextLabel,
|
|
4664
|
+
Tile,
|
|
4665
|
+
TileGrid,
|
|
4666
|
+
TiledMatrix,
|
|
4667
|
+
TitleBar,
|
|
4668
|
+
ToneStrip,
|
|
4669
|
+
ValuePill,
|
|
4670
|
+
VectorArrow,
|
|
4671
|
+
VectorSegment,
|
|
4672
|
+
WindowFrame,
|
|
4673
|
+
canvas,
|
|
4674
|
+
colors,
|
|
4675
|
+
createPlotArea,
|
|
4676
|
+
cropPixels,
|
|
4677
|
+
defineIllustration,
|
|
4678
|
+
detectBackgroundColor,
|
|
4679
|
+
detectContentBounds,
|
|
4680
|
+
detectOverflow,
|
|
4681
|
+
formatMathText,
|
|
4682
|
+
getColor,
|
|
4683
|
+
getFonts,
|
|
4684
|
+
getGradient,
|
|
4685
|
+
getStyles,
|
|
4686
|
+
getThemeColors,
|
|
4687
|
+
getToneColor,
|
|
4688
|
+
getToneGradient,
|
|
4689
|
+
gradients,
|
|
4690
|
+
heatColor,
|
|
4691
|
+
loadAdditionalAsset,
|
|
4692
|
+
normalizeWatermark,
|
|
4693
|
+
renderAnimatedGif,
|
|
4694
|
+
renderToBuffer,
|
|
4695
|
+
renderToPng,
|
|
4696
|
+
renderToSvg,
|
|
4697
|
+
styles,
|
|
4698
|
+
toneGradients,
|
|
4699
|
+
typography,
|
|
4700
|
+
wrapWithBrand,
|
|
4701
|
+
wrapWithWatermark
|
|
4702
|
+
};
|