@graphty/graphty-element 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -3
- package/dist/ai.js +115 -222
- package/dist/catalog.js +46 -44
- package/dist/chunks/{AiManager-Bd_r1Hei.js → AiManager-BD9XK30e.js} +793 -654
- package/dist/chunks/{DataSource-bt0DhBjG.js → DataSource-B8vf2uhW.js} +3 -3
- package/dist/chunks/{GraphSession-iNyKm7Ds.js → GraphSession-dcwOjGJh.js} +3028 -2918
- package/dist/chunks/{GraphStyle-D0PXnZKu.js → GraphStyle-Cwr55SAE.js} +5 -2
- package/dist/chunks/{GraphtyError-BwcnblTH.js → GraphtyError-B93WRH3e.js} +8 -6
- package/dist/chunks/{GraphtyLogger-5KEttFUo.js → GraphtyLogger-CqOVV13Y.js} +2 -2
- package/dist/chunks/{NodeStyle-DKj7HjMJ.js → NodeStyle-CtmA7dXi.js} +16 -14
- package/dist/chunks/{VoiceInputAdapter-DszYl6Ha.js → VoiceInputAdapter-D0tHHi9G.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-XtxbbZ-D.js → XRPivotCameraController-DTfhvhHz.js} +2 -2
- package/dist/chunks/algorithms-BF0X6RPw.js +3627 -0
- package/dist/chunks/{capability-check-BqIEXcun.js → capability-check-BJzlK4oL.js} +1 -1
- package/dist/chunks/{detect-DM29BEaB.js → detect-vJxK7n0D.js} +2 -2
- package/dist/chunks/{format-detection-BEdmtvsy.js → format-detection-C80TLQ2e.js} +1 -1
- package/dist/chunks/{index-CD0_RJv-.js → index-2xkq7wyD.js} +11482 -10971
- package/dist/chunks/optionsFromZod-BuTOFgVM.js +2572 -0
- package/dist/chunks/paletteRegistry-A63C71Gn.js +1155 -0
- package/dist/chunks/{registry-CSba5QGJ.js → registry-jB46Gmeb.js} +1 -1
- package/dist/chunks/scales-B2d-7Bf0.js +3220 -0
- package/dist/chunks/{types-B7bX5c0K.js → types-C_c53VgR.js} +31 -26
- package/dist/commands.d.ts +4 -0
- package/dist/custom-elements.json +1 -1
- package/dist/extend.js +45 -45
- package/dist/graphty-catalog.json +245 -12
- package/dist/graphty.bundle.js +40762 -39403
- package/dist/graphty.js +33 -33
- package/dist/logging.js +2 -2
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +42 -40
- package/dist/session.d.ts +1 -1
- package/dist/session.js +29 -30
- package/dist/src/Graph.d.ts +112 -10
- package/dist/src/acceleration/AccelerationController.d.ts +14 -3
- package/dist/src/acceleration/types.d.ts +78 -0
- package/dist/src/algorithms/KCoreAlgorithm.d.ts +26 -0
- package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +41 -0
- package/dist/src/camera/builtins.d.ts +14 -1
- package/dist/src/camera/types.d.ts +7 -0
- package/dist/src/cameras/CameraManager.d.ts +13 -0
- package/dist/src/cameras/OrbitCameraController.d.ts +9 -0
- package/dist/src/catalog/algorithms.d.ts +5 -5
- package/dist/src/catalog/index.d.ts +2 -2
- package/dist/src/catalog/layouts.d.ts +7 -6
- package/dist/src/catalog/types.d.ts +87 -6
- package/dist/src/config/EdgeStyle.d.ts +35 -0
- package/dist/src/config/GraphStyle.d.ts +5 -1
- package/dist/src/config/StyleTemplate.d.ts +2 -2
- package/dist/src/config/index.d.ts +1 -1
- package/dist/src/data/GEXFDataSource.d.ts +23 -0
- package/dist/src/errors/codes.d.ts +14 -0
- package/dist/src/events.d.ts +30 -0
- package/dist/src/graphty-element.d.ts +77 -32
- package/dist/src/layout/GridLayoutEngine.d.ts +37 -0
- package/dist/src/layout/LayoutEngine.d.ts +7 -7
- package/dist/src/layout/NGraphLayoutEngine.d.ts +2 -0
- package/dist/src/layout/RadialLayoutEngine.d.ts +37 -0
- package/dist/src/layout/SimulationLayoutEngine.d.ts +12 -0
- package/dist/src/managers/DataManager.d.ts +69 -2
- package/dist/src/managers/EventManager.d.ts +10 -4
- package/dist/src/managers/GraphContext.d.ts +2 -1
- package/dist/src/managers/LayoutManager.d.ts +30 -3
- package/dist/src/managers/StylePainter.d.ts +9 -0
- package/dist/src/managers/UpdateManager.d.ts +5 -0
- package/dist/src/meshes/MeshCache.d.ts +18 -0
- package/dist/src/meshes/NodeEffects.d.ts +16 -11
- package/dist/src/meshes/NodeMesh.d.ts +2 -2
- package/dist/src/meshes/RichTextParser.d.ts +26 -0
- package/dist/src/meshes/RichTextRenderer.d.ts +0 -1
- package/dist/src/session/cost/estimate.d.ts +1 -1
- package/dist/src/session/layout.d.ts +3 -3
- package/dist/src/session/results/index.d.ts +1 -1
- package/dist/src/session/results/statistics.d.ts +8 -1
- package/dist/src/session/results/types.d.ts +33 -0
- package/dist/src/session/runs/RunsApi.d.ts +1 -1
- package/dist/src/session/selection/targets.d.ts +4 -1
- package/dist/src/session/styles/StylesApi.d.ts +6 -0
- package/dist/src/session/styles/intern.d.ts +26 -5
- package/dist/src/session/styles/predicate.d.ts +26 -1
- package/dist/src/session/styles/repaint.d.ts +13 -1
- package/dist/src/session/styles/selector.d.ts +13 -1
- package/dist/src/session/styles/sources.d.ts +9 -0
- package/dist/src/session/types.d.ts +6 -6
- package/dist/webgpu.js +2 -2
- package/package.json +6 -6
- package/dist/chunks/Algorithm-RQ629NLb.js +0 -494
- package/dist/chunks/cameras-ii4vngYY.js +0 -435
- package/dist/chunks/paletteRegistry-DnWHQsAD.js +0 -3166
- package/dist/chunks/scales-DyuwlJKI.js +0 -6087
|
@@ -0,0 +1,2572 @@
|
|
|
1
|
+
import { q as he, b as Ie } from "./GraphtyLogger-CqOVV13Y.js";
|
|
2
|
+
import { K as Te, f as Me } from "./types-C_c53VgR.js";
|
|
3
|
+
import { G as y } from "./GraphtyError-B93WRH3e.js";
|
|
4
|
+
import { Graph as _e, accelerated as X } from "@graphty/algorithms";
|
|
5
|
+
import { INVALID_INDEX as L } from "@graphty/graph-format";
|
|
6
|
+
import { z as me } from "zod/v4";
|
|
7
|
+
const _ = he({
|
|
8
|
+
kind: "camera",
|
|
9
|
+
idOf: (e) => e.descriptor.id,
|
|
10
|
+
descriptorOf: (e) => e.descriptor,
|
|
11
|
+
implementationOf: (e) => e.compute,
|
|
12
|
+
builtInIds: () => Te
|
|
13
|
+
});
|
|
14
|
+
function yn(e, t) {
|
|
15
|
+
const n = e.descriptor;
|
|
16
|
+
if (n === void 0 || typeof n != "object")
|
|
17
|
+
throw new y({
|
|
18
|
+
code: "E_BAD_COMMAND",
|
|
19
|
+
message: "registerCameraView takes a camera view with a descriptor",
|
|
20
|
+
source: "registry",
|
|
21
|
+
details: { kind: "camera", field: "descriptor" }
|
|
22
|
+
});
|
|
23
|
+
if (!Array.isArray(n.modes) || n.modes.length === 0)
|
|
24
|
+
throw new y({
|
|
25
|
+
code: "E_BAD_COMMAND",
|
|
26
|
+
message: `the camera view "${String(n.id)}" declares no drawing modes, so nothing could ever offer it: a view says where it works with \`modes\`, and the element refuses the rest`,
|
|
27
|
+
source: "registry",
|
|
28
|
+
details: { kind: "camera", name: String(n.id), field: "modes" }
|
|
29
|
+
});
|
|
30
|
+
if (!Array.isArray(n.options))
|
|
31
|
+
throw new y({
|
|
32
|
+
code: "E_BAD_COMMAND",
|
|
33
|
+
message: `the camera view "${String(n.id)}" declares no options list. A view that takes no configuration declares an empty one, so a form has something to render and the element has something to check a caller's values against`,
|
|
34
|
+
source: "registry",
|
|
35
|
+
details: { kind: "camera", name: String(n.id), field: "options" }
|
|
36
|
+
});
|
|
37
|
+
if (typeof e.compute != "function")
|
|
38
|
+
throw new y({
|
|
39
|
+
code: "E_BAD_COMMAND",
|
|
40
|
+
message: `the camera view "${String(n.id)}" was registered without a compute function`,
|
|
41
|
+
source: "registry",
|
|
42
|
+
details: { kind: "camera", name: String(n.id), field: "compute" }
|
|
43
|
+
});
|
|
44
|
+
_.register(e, t);
|
|
45
|
+
}
|
|
46
|
+
function bn() {
|
|
47
|
+
return _.descriptors();
|
|
48
|
+
}
|
|
49
|
+
function wn(e) {
|
|
50
|
+
return _.byId(e);
|
|
51
|
+
}
|
|
52
|
+
function vn() {
|
|
53
|
+
_.clearForTesting();
|
|
54
|
+
}
|
|
55
|
+
const ze = ["forceAtlas2", "fruchtermanReingold", "springElectrical", "release"], Ce = [
|
|
56
|
+
"pageRank",
|
|
57
|
+
"sssp",
|
|
58
|
+
"breadthFirstSearch",
|
|
59
|
+
"connectedComponents",
|
|
60
|
+
"weaklyConnectedComponents",
|
|
61
|
+
"minimumSpanningTree"
|
|
62
|
+
];
|
|
63
|
+
function On(e) {
|
|
64
|
+
const t = {
|
|
65
|
+
kind: e.backend
|
|
66
|
+
};
|
|
67
|
+
for (const n of ze) {
|
|
68
|
+
const r = e[n];
|
|
69
|
+
typeof r == "function" && (t[n] = r.bind(e));
|
|
70
|
+
}
|
|
71
|
+
return t;
|
|
72
|
+
}
|
|
73
|
+
function xe(e) {
|
|
74
|
+
const t = {
|
|
75
|
+
kind: e.backend
|
|
76
|
+
};
|
|
77
|
+
for (const n of Ce) {
|
|
78
|
+
const r = e[n];
|
|
79
|
+
typeof r == "function" && (t[n] = r.bind(e));
|
|
80
|
+
}
|
|
81
|
+
return t;
|
|
82
|
+
}
|
|
83
|
+
const je = ["auto", "off", "required"], kn = "auto";
|
|
84
|
+
function Nn(e) {
|
|
85
|
+
return typeof e == "string" && je.includes(e);
|
|
86
|
+
}
|
|
87
|
+
const Pe = "f64", Sn = "f32", An = "acceleration.minNodes", $n = 0, Rn = "RTX 4070 SUPER, headless Chromium, 2026-09-25", En = Object.freeze({
|
|
88
|
+
breadthFirstSearch: 3e5,
|
|
89
|
+
sssp: 3e5,
|
|
90
|
+
pageRank: 5e3,
|
|
91
|
+
connectedComponents: 5e4
|
|
92
|
+
}), z = he({
|
|
93
|
+
kind: "algorithm",
|
|
94
|
+
idOf: (e) => e.descriptor.key,
|
|
95
|
+
descriptorOf: (e) => e.descriptor,
|
|
96
|
+
implementationOf: (e) => e.descriptor,
|
|
97
|
+
builtInIds: () => Me
|
|
98
|
+
});
|
|
99
|
+
function Le(e, t) {
|
|
100
|
+
if (e.descriptor.key !== e.type)
|
|
101
|
+
throw new y({
|
|
102
|
+
code: "E_BAD_COMMAND",
|
|
103
|
+
message: `the algorithm registered as "${e.namespace}:${e.type}" publishes the catalogue key "${e.descriptor.key}". An algorithm has one name: make "descriptor.key" equal "static type".`,
|
|
104
|
+
source: "registry",
|
|
105
|
+
details: {
|
|
106
|
+
kind: "algorithm",
|
|
107
|
+
field: "descriptor.key",
|
|
108
|
+
key: e.descriptor.key,
|
|
109
|
+
type: e.type,
|
|
110
|
+
namespace: e.namespace
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
z.register(e, t);
|
|
114
|
+
}
|
|
115
|
+
function Fn() {
|
|
116
|
+
return z.descriptors();
|
|
117
|
+
}
|
|
118
|
+
function In(e) {
|
|
119
|
+
return z.byId(e);
|
|
120
|
+
}
|
|
121
|
+
function Tn() {
|
|
122
|
+
z.clearForTesting();
|
|
123
|
+
}
|
|
124
|
+
class b extends Error {
|
|
125
|
+
/**
|
|
126
|
+
* Creates an option validation error
|
|
127
|
+
* @param optionKey - The key of the option that failed validation
|
|
128
|
+
* @param message - The validation error message
|
|
129
|
+
*/
|
|
130
|
+
constructor(t, n) {
|
|
131
|
+
super(`Option '${t}': ${n}`), this.optionKey = t, this.name = "OptionValidationError";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function De(e, t, n) {
|
|
135
|
+
if (t == null) {
|
|
136
|
+
if (n.required)
|
|
137
|
+
throw new b(e, "is required but was not provided");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
switch (n.type) {
|
|
141
|
+
case "number":
|
|
142
|
+
Q(e, t, n, !1);
|
|
143
|
+
break;
|
|
144
|
+
case "integer":
|
|
145
|
+
Q(e, t, n, !0);
|
|
146
|
+
break;
|
|
147
|
+
case "boolean":
|
|
148
|
+
if (typeof t != "boolean")
|
|
149
|
+
throw new b(e, `must be a boolean, got ${typeof t}`);
|
|
150
|
+
break;
|
|
151
|
+
case "string":
|
|
152
|
+
if (typeof t != "string")
|
|
153
|
+
throw new b(e, `must be a string, got ${typeof t}`);
|
|
154
|
+
break;
|
|
155
|
+
case "select":
|
|
156
|
+
Ge(e, t, n);
|
|
157
|
+
break;
|
|
158
|
+
case "nodeId":
|
|
159
|
+
if (typeof t != "string" && typeof t != "number")
|
|
160
|
+
throw new b(e, `must be a string or number (node ID), got ${typeof t}`);
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
throw new b(e, `has unknown type '${n.type}'`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function Q(e, t, n, r) {
|
|
167
|
+
if (typeof t != "number")
|
|
168
|
+
throw new b(e, `must be a number, got ${typeof t}`);
|
|
169
|
+
if (Number.isNaN(t))
|
|
170
|
+
throw new b(e, "must not be NaN");
|
|
171
|
+
if (!Number.isFinite(t))
|
|
172
|
+
throw new b(e, "must be finite");
|
|
173
|
+
if (r && !Number.isInteger(t))
|
|
174
|
+
throw new b(e, `must be an integer, got ${t}`);
|
|
175
|
+
if (n.min !== void 0 && t < n.min)
|
|
176
|
+
throw new b(e, `must be >= ${n.min}, got ${t}`);
|
|
177
|
+
if (n.max !== void 0 && t > n.max)
|
|
178
|
+
throw new b(e, `must be <= ${n.max}, got ${t}`);
|
|
179
|
+
}
|
|
180
|
+
function Ge(e, t, n) {
|
|
181
|
+
if (!n.options || n.options.length === 0)
|
|
182
|
+
throw new b(e, "is a select type but has no options defined");
|
|
183
|
+
if (!n.options.map((i) => i.value).includes(t)) {
|
|
184
|
+
const i = n.options.map((s) => `'${String(s.value)}'`).join(", ");
|
|
185
|
+
throw new b(e, `must be one of [${i}], got '${String(t)}'`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function Ue(e, t) {
|
|
189
|
+
const n = {};
|
|
190
|
+
for (const [r, i] of Object.entries(e)) {
|
|
191
|
+
const o = t?.[r] ?? i.default;
|
|
192
|
+
De(r, o, i), n[r] = o;
|
|
193
|
+
}
|
|
194
|
+
return n;
|
|
195
|
+
}
|
|
196
|
+
function Mn(e) {
|
|
197
|
+
return e;
|
|
198
|
+
}
|
|
199
|
+
function He(e, t) {
|
|
200
|
+
const n = e.getSnapshot(), r = t === "directed" ? n : e.undirected(n).snapshot, i = r.flags.multigraph ? r.simplified({ weights: "sum" }).snapshot : r;
|
|
201
|
+
return Be(i, t);
|
|
202
|
+
}
|
|
203
|
+
function _n(e) {
|
|
204
|
+
const t = e.getSnapshot();
|
|
205
|
+
return t.flags.multigraph ? t.edgeCount - t.simplified({ weights: "sum" }).snapshot.edgeCount : 0;
|
|
206
|
+
}
|
|
207
|
+
function Be(e, t) {
|
|
208
|
+
const n = new _e({
|
|
209
|
+
directed: t !== "undirected"
|
|
210
|
+
}), { ids: r } = e;
|
|
211
|
+
for (let a = 0; a < e.nodeCount; a++)
|
|
212
|
+
n.addNode(r.idOf(a));
|
|
213
|
+
const { src: i, dst: s, weights: o } = e.edgeList();
|
|
214
|
+
for (let a = 0; a < e.edgeCount; a++) {
|
|
215
|
+
const u = r.idOf(i[a]), c = r.idOf(s[a]), h = o === null ? 1 : o[a];
|
|
216
|
+
n.addEdge(u, c, h);
|
|
217
|
+
}
|
|
218
|
+
return n;
|
|
219
|
+
}
|
|
220
|
+
const E = /* @__PURE__ */ new Map();
|
|
221
|
+
function Ve(e, t) {
|
|
222
|
+
if (t === null)
|
|
223
|
+
return e;
|
|
224
|
+
if (e === null)
|
|
225
|
+
return t;
|
|
226
|
+
const n = new Uint32Array(e.length);
|
|
227
|
+
for (let r = 0; r < e.length; r++) {
|
|
228
|
+
const i = e[r];
|
|
229
|
+
n[r] = i === L ? L : t[i];
|
|
230
|
+
}
|
|
231
|
+
return n;
|
|
232
|
+
}
|
|
233
|
+
const Z = class Z {
|
|
234
|
+
/**
|
|
235
|
+
* Getter for schema options
|
|
236
|
+
*
|
|
237
|
+
* Algorithms that use the new schema-based options should access
|
|
238
|
+
* options via this getter.
|
|
239
|
+
* @returns The resolved schema options
|
|
240
|
+
*/
|
|
241
|
+
get schemaOptions() {
|
|
242
|
+
return this._schemaOptions;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Creates a new algorithm instance
|
|
246
|
+
* @param g - The graph to run the algorithm on
|
|
247
|
+
* @param options - Optional configuration options (uses schema defaults if not provided)
|
|
248
|
+
*/
|
|
249
|
+
constructor(t, n) {
|
|
250
|
+
this.graph = t, this._schemaOptions = this.resolveOptions(n);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The `@graphty/algorithms` Graph this run reads, built from the element's graph snapshot.
|
|
254
|
+
*
|
|
255
|
+
* This is the ONLY way an algorithm should obtain its input. The `Node` and `Edge` objects the
|
|
256
|
+
* data manager also holds are render objects -- each `Node` builds a Babylon mesh in its
|
|
257
|
+
* constructor -- and reading the graph out of them ties every algorithm to a renderer and to
|
|
258
|
+
* whatever part of a data load the scene has caught up with.
|
|
259
|
+
* @param mode - the shape this algorithm needs; see {@link AlgorithmGraphMode}
|
|
260
|
+
* @returns a freshly built Graph for the algorithm package
|
|
261
|
+
*/
|
|
262
|
+
algorithmGraph(t) {
|
|
263
|
+
return He(this.graph.getDataManager(), t);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The route an algorithm with an accelerated implementation takes.
|
|
267
|
+
*
|
|
268
|
+
* It is the counterpart of {@link algorithmGraph} for the algorithms `@graphty/algorithms`
|
|
269
|
+
* can dispatch: instead of copying the snapshot into an object graph, the work runs over the
|
|
270
|
+
* snapshot itself, on the attached accelerator or on the index-based CPU port, and the adapter
|
|
271
|
+
* writes one loop over an index-aligned result either way.
|
|
272
|
+
*
|
|
273
|
+
* THE DECISION IS TAKEN ONCE, HERE, BEFORE ANY WORK STARTS. The controller answers "the policy
|
|
274
|
+
* is off", "no accelerator", "below `acceleration.minNodes`" or "this accelerator does not
|
|
275
|
+
* implement that" up front, and under `acceleration="required"` it throws `E_NO_ACCELERATOR`
|
|
276
|
+
* rather than answering quietly. After the work has started there is no second decision: a
|
|
277
|
+
* failure from the accelerator propagates with its code and fails the run, because a number
|
|
278
|
+
* that silently came from somewhere else is worse than no number.
|
|
279
|
+
* @param capability - The accelerator member this work would use, such as `"pageRank"`.
|
|
280
|
+
* @param mode - The shape this algorithm needs; see {@link AlgorithmGraphMode}. `"undirected"`
|
|
281
|
+
* takes the snapshot's undirected view, which is what collapses a reciprocal pair into one
|
|
282
|
+
* edge.
|
|
283
|
+
* @returns The snapshot, the edge map onto it, and the runner.
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* const { snapshot, run } = this.accelerated("connectedComponents", "undirected");
|
|
287
|
+
* const { value, precision } = await run((dispatch, s) => dispatch.connectedComponents(s));
|
|
288
|
+
* const group = value.labels[snapshot.ids.indexOf(nodeId)];
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
accelerated(t, n) {
|
|
292
|
+
const r = this.graph.getDataManager(), i = r.getSnapshot(), s = n === "undirected" ? r.undirected(i) : null, o = s === null ? i : s.snapshot, a = o.flags.multigraph ? o.simplified({ weights: "sum" }) : null, u = a === null ? o : a.snapshot, c = this.graph.acceleration, h = { capability: t, nodeCount: u.nodeCount };
|
|
293
|
+
return {
|
|
294
|
+
snapshot: u,
|
|
295
|
+
edgeRemap: Ve(s?.edgeRemap ?? null, a?.edgeRemap ?? null),
|
|
296
|
+
run: async (p) => {
|
|
297
|
+
const l = await c.run(
|
|
298
|
+
h,
|
|
299
|
+
(d) => p(X(xe(d)), u)
|
|
300
|
+
);
|
|
301
|
+
return l.accelerated ? { value: l.value, precision: l.precision } : { value: await p(X(null), u), precision: Pe };
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The dense row of a node the reader named in an option.
|
|
307
|
+
*
|
|
308
|
+
* A search takes its source as an id and the snapshot answers in indices, so this is where the
|
|
309
|
+
* two meet -- and where an id that names no node in the graph is reported as what it is: an
|
|
310
|
+
* option whose value is outside the permitted range, carrying the option's name and what was
|
|
311
|
+
* passed, rather than a silent empty result or a search from row zero.
|
|
312
|
+
* @param snapshot - The graph the work runs over.
|
|
313
|
+
* @param option - The option the id came from, named in the error.
|
|
314
|
+
* @param id - The node id the reader gave.
|
|
315
|
+
* @returns The node's dense row.
|
|
316
|
+
* @throws A `GraphtyError` with `E_OPTION_RANGE` when the graph has no such node.
|
|
317
|
+
*/
|
|
318
|
+
nodeIndex(t, n, r) {
|
|
319
|
+
const i = t.ids.indexOf(r);
|
|
320
|
+
if (i === L)
|
|
321
|
+
throw new y({
|
|
322
|
+
code: "E_OPTION_RANGE",
|
|
323
|
+
message: `the graph has no node "${String(r)}", so "${n}" names nothing to run from`,
|
|
324
|
+
source: "run",
|
|
325
|
+
details: { option: n, value: r }
|
|
326
|
+
});
|
|
327
|
+
return i;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Resolves and validates options against the schema
|
|
331
|
+
* @param options - User-provided options (partial)
|
|
332
|
+
* @returns Fully resolved options with defaults applied
|
|
333
|
+
*/
|
|
334
|
+
resolveOptions(t) {
|
|
335
|
+
const n = this.constructor.optionsSchema;
|
|
336
|
+
return Object.keys(n).length === 0 ? {} : Ue(n, t);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Gets the algorithm type
|
|
340
|
+
* @returns The algorithm type identifier
|
|
341
|
+
*/
|
|
342
|
+
get type() {
|
|
343
|
+
return this.constructor.type;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Gets the algorithm namespace
|
|
347
|
+
* @returns The algorithm namespace identifier
|
|
348
|
+
*/
|
|
349
|
+
get namespace() {
|
|
350
|
+
return this.constructor.namespace;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Compute this algorithm and publish what it produced as a result object.
|
|
354
|
+
*
|
|
355
|
+
* This is the entry point the run machinery calls, and it is the one that makes an algorithm
|
|
356
|
+
* startable as a `Run`: it takes a signal it must throw from, a progress channel, a yield, and
|
|
357
|
+
* the run id the result is published under -- and it RETURNS the result rather than writing it
|
|
358
|
+
* somewhere a caller has to go looking for. `run()` is the 1.10 entry point beside it, which
|
|
359
|
+
* returns nothing and can be neither watched nor stopped.
|
|
360
|
+
*
|
|
361
|
+
* The default refuses, because an algorithm that has not been migrated genuinely cannot answer
|
|
362
|
+
* a run: it publishes through side effects under its own names and has no result object to
|
|
363
|
+
* hand back. Both shipped families -- a metric and a declared algorithm -- override it.
|
|
364
|
+
* @param _context - A signal, a progress channel and a yield.
|
|
365
|
+
* @param runId - The id the result is published under.
|
|
366
|
+
* @param _fields - The catalogue's descriptors for this algorithm's fields, when the caller
|
|
367
|
+
* holds them.
|
|
368
|
+
* @returns The result, or undefined when there was nothing to compute.
|
|
369
|
+
* @throws A `GraphtyError` with code `E_UNSUPPORTED` when this algorithm has no result to
|
|
370
|
+
* publish.
|
|
371
|
+
*/
|
|
372
|
+
publishResult(t, n, r) {
|
|
373
|
+
return Promise.reject(
|
|
374
|
+
new y({
|
|
375
|
+
code: "E_UNSUPPORTED",
|
|
376
|
+
message: `The "${this.namespace}:${this.type}" algorithm writes its result through side effects and cannot be started as a run.`,
|
|
377
|
+
source: "run",
|
|
378
|
+
target: { kind: "run", id: n },
|
|
379
|
+
details: { algorithm: `${this.namespace}:${this.type}` }
|
|
380
|
+
})
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Registers an algorithm class in the global registry
|
|
385
|
+
* @param cls - The algorithm class to register
|
|
386
|
+
* @returns The registered algorithm class
|
|
387
|
+
*/
|
|
388
|
+
static register(t) {
|
|
389
|
+
const n = t, r = String(n.type), i = String(n.namespace), { descriptor: s, cost: o, version: a } = n;
|
|
390
|
+
return s !== void 0 && Le({
|
|
391
|
+
descriptor: s,
|
|
392
|
+
namespace: i,
|
|
393
|
+
type: r,
|
|
394
|
+
...o === void 0 ? {} : { cost: o },
|
|
395
|
+
...a === void 0 ? {} : { version: a }
|
|
396
|
+
}), E.set(`${i}:${r}`, t), t;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Gets an algorithm instance from the registry
|
|
400
|
+
* @param g - The graph to run the algorithm on
|
|
401
|
+
* @param namespace - The algorithm namespace
|
|
402
|
+
* @param type - The algorithm type
|
|
403
|
+
* @param options - Optional algorithm-specific options to pass to constructor
|
|
404
|
+
* @returns A new instance of the algorithm, or null if not found
|
|
405
|
+
*/
|
|
406
|
+
static get(t, n, r, i) {
|
|
407
|
+
const s = E.get(`${n}:${r}`);
|
|
408
|
+
return s ? new s(t, i) : null;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Gets an algorithm class from the registry
|
|
412
|
+
* @param namespace - The algorithm namespace
|
|
413
|
+
* @param type - The algorithm type
|
|
414
|
+
* @returns The algorithm class, or null if not found
|
|
415
|
+
*/
|
|
416
|
+
static getClass(t, n) {
|
|
417
|
+
return E.get(`${t}:${n}`) ?? null;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Get the options schema for this algorithm
|
|
421
|
+
* @returns The options schema, or an empty object if no options defined
|
|
422
|
+
* @deprecated Use getZodOptionsSchema() instead
|
|
423
|
+
*/
|
|
424
|
+
static getOptionsSchema() {
|
|
425
|
+
return this.optionsSchema;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Check if this algorithm has configurable options
|
|
429
|
+
* @returns true if the algorithm has at least one option defined
|
|
430
|
+
* @deprecated Use hasZodOptions() instead
|
|
431
|
+
*/
|
|
432
|
+
static hasOptions() {
|
|
433
|
+
return Object.keys(this.optionsSchema).length > 0;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Get the Zod-based options schema for this algorithm.
|
|
437
|
+
* @returns The Zod options schema, or an empty object if no schema defined
|
|
438
|
+
*/
|
|
439
|
+
static getZodOptionsSchema() {
|
|
440
|
+
return this.zodOptionsSchema ?? {};
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Check if this algorithm has a Zod-based options schema.
|
|
444
|
+
* @returns true if the algorithm has a Zod options schema defined
|
|
445
|
+
*/
|
|
446
|
+
static hasZodOptions() {
|
|
447
|
+
return this.zodOptionsSchema !== void 0 && Object.keys(this.zodOptionsSchema).length > 0;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Get all registered algorithm names.
|
|
451
|
+
* @param namespace - Optional namespace to filter by
|
|
452
|
+
* @returns Array of algorithm names in "namespace:type" format
|
|
453
|
+
*/
|
|
454
|
+
static getRegisteredAlgorithms(t) {
|
|
455
|
+
const n = [];
|
|
456
|
+
for (const r of E.keys())
|
|
457
|
+
(!t || r.startsWith(`${t}:`)) && n.push(r);
|
|
458
|
+
return n.sort();
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Get all registered algorithm types.
|
|
462
|
+
* This method is provided for API consistency with DataSource.
|
|
463
|
+
* @returns Array of algorithm keys in "namespace:type" format
|
|
464
|
+
* @since 1.5.0
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const types = Algorithm.getRegisteredTypes();
|
|
468
|
+
* console.log('Available algorithms:', types);
|
|
469
|
+
* // ['graphty:betweenness', 'graphty:closeness', 'graphty:degree', ...]
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
static getRegisteredTypes() {
|
|
473
|
+
return this.getRegisteredAlgorithms();
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
Z.optionsSchema = {};
|
|
477
|
+
let D = Z;
|
|
478
|
+
const ee = 3, qe = 0.1;
|
|
479
|
+
function m(e, t) {
|
|
480
|
+
return Number.isInteger(e) ? e.toLocaleString(t) : Number(e.toFixed(ee)).toLocaleString(t, { maximumFractionDigits: ee });
|
|
481
|
+
}
|
|
482
|
+
function Je(e, t, n) {
|
|
483
|
+
const r = e.fields.find((i) => i.name === t);
|
|
484
|
+
return r === void 0 ? t : n === "technical" ? r.technicalName : r.plainName.toLowerCase();
|
|
485
|
+
}
|
|
486
|
+
function C(e, t, n) {
|
|
487
|
+
const r = e.fields.find((i) => i.name === t)?.unit;
|
|
488
|
+
return r === void 0 ? "" : n === 1 && r.endsWith("s") ? ` ${r.slice(0, -1)}` : ` ${r}`;
|
|
489
|
+
}
|
|
490
|
+
function R(e, t) {
|
|
491
|
+
const n = e.graph[t];
|
|
492
|
+
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
493
|
+
}
|
|
494
|
+
function Ye(e) {
|
|
495
|
+
return e[0];
|
|
496
|
+
}
|
|
497
|
+
function We(e, t, n) {
|
|
498
|
+
const { locale: r, audience: i } = n, s = Je(e, "value", i), o = Ye(t.top);
|
|
499
|
+
if (o === void 0 || t.median === null)
|
|
500
|
+
return `Nothing was measured, so there is no ${s} to report.`;
|
|
501
|
+
const a = [
|
|
502
|
+
`${o.label} has the highest ${s}, at ${m(o.value, r)}${C(e, "value", o.value)}.`,
|
|
503
|
+
`The typical element sits at ${m(t.median, r)}${C(e, "value", t.median)}.`
|
|
504
|
+
];
|
|
505
|
+
return t.measured > 0 && t.tiedAtMin / t.measured >= qe && t.min !== null && a.push(
|
|
506
|
+
`${m(t.tiedAtMin, r)} of ${m(t.measured, r)} sit at the lowest value, ${m(t.min, r)}${C(e, "value", t.min)}.`
|
|
507
|
+
), t.count > t.measured && a.push(`${m(t.count - t.measured, r)} were not measured.`), a.join(" ");
|
|
508
|
+
}
|
|
509
|
+
function Ke(e, t, n) {
|
|
510
|
+
const { locale: r } = n, i = t.groups ?? [];
|
|
511
|
+
if (i.length === 0)
|
|
512
|
+
return "Nothing was grouped, so there are no groups to report.";
|
|
513
|
+
const s = i[0], o = [
|
|
514
|
+
`${m(i.length, r)} ${i.length === 1 ? "group" : "groups"} were found,`,
|
|
515
|
+
`the largest holding ${m(s.size, r)} of ${m(t.measured, r)}.`
|
|
516
|
+
], a = R(e, "modularity");
|
|
517
|
+
return a !== void 0 && o.push(`Modularity is ${m(a, r)}.`), o.join(" ");
|
|
518
|
+
}
|
|
519
|
+
function Ze(e, t) {
|
|
520
|
+
const { locale: n } = t, r = R(e, "hops"), i = R(e, "cost");
|
|
521
|
+
if (r === void 0 && i === void 0)
|
|
522
|
+
return "No route was found.";
|
|
523
|
+
const s = [];
|
|
524
|
+
return r !== void 0 && s.push(`The route runs ${m(r, n)} ${r === 1 ? "hop" : "hops"}.`), i !== void 0 && s.push(`Its total cost is ${m(i, n)}.`), s.join(" ");
|
|
525
|
+
}
|
|
526
|
+
function Xe(e, t, n) {
|
|
527
|
+
const { locale: r } = n, i = R(e, "count") ?? t.measured, s = e.shape === "edge-set" ? "edge" : "node";
|
|
528
|
+
return i === 0 ? `No ${s}s were selected.` : `${m(i, r)} ${i === 1 ? s : `${s}s`} were selected.`;
|
|
529
|
+
}
|
|
530
|
+
function Qe(e, t) {
|
|
531
|
+
const { pairs: n } = e.graph, r = Array.isArray(n) ? n.length : 0;
|
|
532
|
+
return r === 0 ? "No pairs were found." : `${m(r, t.locale)} ${r === 1 ? "pair was" : "pairs were"} found.`;
|
|
533
|
+
}
|
|
534
|
+
function et(e, t) {
|
|
535
|
+
const n = R(e, "steps");
|
|
536
|
+
return n === void 0 || n === 0 ? "The series is empty." : `The series covers ${m(n, t.locale)} ${n === 1 ? "step" : "steps"}.`;
|
|
537
|
+
}
|
|
538
|
+
function te(e, t) {
|
|
539
|
+
return e.measured === 0 ? "The run produced no values." : `The run covered ${m(e.measured, t.locale)} of ${m(e.count, t.locale)}.`;
|
|
540
|
+
}
|
|
541
|
+
function tt(e, t) {
|
|
542
|
+
const n = e.summary(), { shape: r } = e;
|
|
543
|
+
switch (r) {
|
|
544
|
+
case "node-metric":
|
|
545
|
+
case "edge-metric":
|
|
546
|
+
return We(e, n, t);
|
|
547
|
+
case "community":
|
|
548
|
+
case "layered-grouping":
|
|
549
|
+
case "category-table":
|
|
550
|
+
return Ke(e, n, t);
|
|
551
|
+
case "path":
|
|
552
|
+
return Ze(e, t);
|
|
553
|
+
case "node-set":
|
|
554
|
+
case "edge-set":
|
|
555
|
+
return Xe(e, n, t);
|
|
556
|
+
case "pair-list":
|
|
557
|
+
return Qe(e, t);
|
|
558
|
+
case "temporal":
|
|
559
|
+
return et(e, t);
|
|
560
|
+
case "fact":
|
|
561
|
+
return te(n, t);
|
|
562
|
+
default:
|
|
563
|
+
return te(n, t);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function zn(e, t) {
|
|
567
|
+
const n = t === "node", r = n ? e.nodeValue : e.edgeValue, i = n ? e.nodeHas : e.edgeHas, s = n ? e.nodeIdOf : e.edgeIdOf;
|
|
568
|
+
return {
|
|
569
|
+
value: r,
|
|
570
|
+
has: i ?? ((o, a) => nt(r(o, a))),
|
|
571
|
+
idOf: s ?? null
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function nt(e) {
|
|
575
|
+
return e != null;
|
|
576
|
+
}
|
|
577
|
+
function I(e) {
|
|
578
|
+
return e == null || e === !1 || e === "" ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "object" ? Object.keys(e).length > 0 : !0;
|
|
579
|
+
}
|
|
580
|
+
function G(e, t) {
|
|
581
|
+
if (e === t)
|
|
582
|
+
return !0;
|
|
583
|
+
if (Array.isArray(e) && Array.isArray(t))
|
|
584
|
+
return e.length === t.length && e.every((n, r) => G(n, t[r]));
|
|
585
|
+
if (ne(e) && ne(t)) {
|
|
586
|
+
const n = Object.keys(e);
|
|
587
|
+
return n.length === Object.keys(t).length && n.every((r) => G(e[r], t[r]));
|
|
588
|
+
}
|
|
589
|
+
return !1;
|
|
590
|
+
}
|
|
591
|
+
function ne(e) {
|
|
592
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
593
|
+
}
|
|
594
|
+
function f(e, t, n, r = {}) {
|
|
595
|
+
return new y({
|
|
596
|
+
code: "E_BAD_SELECTOR",
|
|
597
|
+
message: `${e} (at character ${String(n)} of ${JSON.stringify(t)})`,
|
|
598
|
+
source: "style",
|
|
599
|
+
details: { ...r, position: n, where: t }
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
const rt = Object.freeze({
|
|
603
|
+
"[": "index, slice, wildcard and filter expressions",
|
|
604
|
+
"]": "index, slice, wildcard and filter expressions",
|
|
605
|
+
"{": "multi-select hashes",
|
|
606
|
+
"}": "multi-select hashes",
|
|
607
|
+
",": "multi-select lists",
|
|
608
|
+
"*": "wildcards",
|
|
609
|
+
"@": "the current-node reference",
|
|
610
|
+
":": "slices"
|
|
611
|
+
}), it = ["&&", "||", "==", "!=", "<=", ">=", "!", "<", ">", ".", "(", ")"];
|
|
612
|
+
function fe(e) {
|
|
613
|
+
return /[A-Za-z_]/.test(e);
|
|
614
|
+
}
|
|
615
|
+
function ge(e) {
|
|
616
|
+
return /[A-Za-z0-9_]/.test(e);
|
|
617
|
+
}
|
|
618
|
+
function x(e, t, n) {
|
|
619
|
+
for (let r = t + 1; r < e.length; r++) {
|
|
620
|
+
if (e[r] === "\\") {
|
|
621
|
+
r++;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
if (e[r] === n)
|
|
625
|
+
return r;
|
|
626
|
+
}
|
|
627
|
+
throw f(`A ${n} is opened and never closed`, e, t, { delimiter: n });
|
|
628
|
+
}
|
|
629
|
+
function st(e) {
|
|
630
|
+
let t = "";
|
|
631
|
+
for (let n = 0; n < e.length; n++) {
|
|
632
|
+
if (e[n] === "\\" && (e[n + 1] === "'" || e[n + 1] === "\\")) {
|
|
633
|
+
t += e[n + 1], n++;
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
t += e[n];
|
|
637
|
+
}
|
|
638
|
+
return t;
|
|
639
|
+
}
|
|
640
|
+
function ot(e, t, n) {
|
|
641
|
+
const r = n.replace(/\\`/g, "`");
|
|
642
|
+
try {
|
|
643
|
+
return JSON.parse(r);
|
|
644
|
+
} catch {
|
|
645
|
+
throw f(
|
|
646
|
+
`A literal between backticks must be JSON, so a bare word needs quotes: write \`"${r}"\` rather than \`${r}\``,
|
|
647
|
+
e,
|
|
648
|
+
t,
|
|
649
|
+
{ literal: r }
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function at(e, t, n) {
|
|
654
|
+
try {
|
|
655
|
+
const r = JSON.parse(n);
|
|
656
|
+
if (typeof r == "string")
|
|
657
|
+
return r;
|
|
658
|
+
} catch {
|
|
659
|
+
}
|
|
660
|
+
throw f(
|
|
661
|
+
`A quoted attribute name follows JSON's rules for a string, and ${n} does not`,
|
|
662
|
+
e,
|
|
663
|
+
t,
|
|
664
|
+
{ name: n }
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
function ct(e) {
|
|
668
|
+
const t = [];
|
|
669
|
+
let n = 0;
|
|
670
|
+
for (; n < e.length; ) {
|
|
671
|
+
const r = e.charAt(n);
|
|
672
|
+
if (/\s/.test(r)) {
|
|
673
|
+
n++;
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
const i = rt[r];
|
|
677
|
+
if (i !== void 0)
|
|
678
|
+
throw f(`A selector does not support ${i}`, e, n, { construct: i });
|
|
679
|
+
if (r === "|" && e.charAt(n + 1) !== "|")
|
|
680
|
+
throw f("A selector does not support pipe expressions", e, n, { construct: "pipe expressions" });
|
|
681
|
+
if (r === "&" && e.charAt(n + 1) !== "&")
|
|
682
|
+
throw f("A selector does not support expression references", e, n, {
|
|
683
|
+
construct: "expression references"
|
|
684
|
+
});
|
|
685
|
+
const s = it.find((o) => e.startsWith(o, n));
|
|
686
|
+
if (s !== void 0) {
|
|
687
|
+
t.push({ kind: "operator", text: s, at: n }), n += s.length;
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (r === "`") {
|
|
691
|
+
const o = x(e, n, "`");
|
|
692
|
+
t.push({ kind: "literal", text: "", value: ot(e, n, e.slice(n + 1, o)), at: n }), n = o + 1;
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
if (r === "'") {
|
|
696
|
+
const o = x(e, n, "'");
|
|
697
|
+
t.push({ kind: "literal", text: "", value: st(e.slice(n + 1, o)), at: n }), n = o + 1;
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (r === '"') {
|
|
701
|
+
const o = x(e, n, '"');
|
|
702
|
+
t.push({ kind: "identifier", text: at(e, n, e.slice(n, o + 1)), at: n }), n = o + 1;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (fe(r)) {
|
|
706
|
+
let o = n + 1;
|
|
707
|
+
for (; o < e.length && ge(e.charAt(o)); )
|
|
708
|
+
o++;
|
|
709
|
+
t.push({ kind: "identifier", text: e.slice(n, o), at: n }), n = o;
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
throw /[0-9-]/.test(r) ? f(
|
|
713
|
+
"A number in a selector goes between backticks, so write `5` rather than 5",
|
|
714
|
+
e,
|
|
715
|
+
n,
|
|
716
|
+
{ character: r }
|
|
717
|
+
) : f(`${JSON.stringify(r)} is not something a selector can contain`, e, n, {
|
|
718
|
+
character: r
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
return t.push({ kind: "end", text: "", at: e.length }), t;
|
|
722
|
+
}
|
|
723
|
+
const ut = Object.freeze({
|
|
724
|
+
"!=": "!=",
|
|
725
|
+
"<": "<",
|
|
726
|
+
"<=": "<=",
|
|
727
|
+
"==": "==",
|
|
728
|
+
">": ">",
|
|
729
|
+
">=": ">="
|
|
730
|
+
});
|
|
731
|
+
function N(e) {
|
|
732
|
+
return e.tokens[e.index];
|
|
733
|
+
}
|
|
734
|
+
function S(e, t) {
|
|
735
|
+
const n = N(e);
|
|
736
|
+
return n.kind === "operator" && n.text === t;
|
|
737
|
+
}
|
|
738
|
+
function lt(e) {
|
|
739
|
+
const t = N(e), n = [];
|
|
740
|
+
for (; ; ) {
|
|
741
|
+
const r = N(e);
|
|
742
|
+
if (r.kind !== "identifier")
|
|
743
|
+
throw f("A `.` must be followed by an attribute name", e.where, r.at);
|
|
744
|
+
if (r.text.includes("."))
|
|
745
|
+
throw f(
|
|
746
|
+
`A quoted attribute name may not contain a dot: ${JSON.stringify(r.text)} would be indistinguishable from two names`,
|
|
747
|
+
e.where,
|
|
748
|
+
r.at,
|
|
749
|
+
{ segment: r.text }
|
|
750
|
+
);
|
|
751
|
+
if (e.index++, S(e, "("))
|
|
752
|
+
throw f(
|
|
753
|
+
`A selector does not support functions, so ${r.text}(...) cannot be called here`,
|
|
754
|
+
e.where,
|
|
755
|
+
r.at,
|
|
756
|
+
{ construct: "functions", function: r.text }
|
|
757
|
+
);
|
|
758
|
+
if (n.push(r.text), !S(e, "."))
|
|
759
|
+
return { kind: "path", path: n.join("."), at: t.at };
|
|
760
|
+
e.index++;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
function dt(e) {
|
|
764
|
+
const t = N(e);
|
|
765
|
+
if (t.kind === "literal")
|
|
766
|
+
return e.index++, { kind: "literal", value: t.value };
|
|
767
|
+
if (t.kind === "identifier")
|
|
768
|
+
return lt(e);
|
|
769
|
+
if (S(e, "(")) {
|
|
770
|
+
e.index++;
|
|
771
|
+
const n = ye(e);
|
|
772
|
+
if (!S(e, ")"))
|
|
773
|
+
throw f("A `(` is opened and never closed", e.where, t.at);
|
|
774
|
+
return e.index++, { kind: "group", inner: n };
|
|
775
|
+
}
|
|
776
|
+
throw f(
|
|
777
|
+
t.kind === "end" ? "The selector ends where an attribute name, a literal or a `(` should be" : `${JSON.stringify(t.text)} is where an attribute name, a literal or a \`(\` should be`,
|
|
778
|
+
e.where,
|
|
779
|
+
t.at
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
function U(e) {
|
|
783
|
+
if (!S(e, "!"))
|
|
784
|
+
return dt(e);
|
|
785
|
+
const t = N(e);
|
|
786
|
+
e.index++;
|
|
787
|
+
const n = U(e);
|
|
788
|
+
if (n.kind === "path" && n.path.includes("."))
|
|
789
|
+
throw f(
|
|
790
|
+
`In JMESPath \`!\` binds tighter than \`.\`, so !${n.path} means (!${n.path.split(".")[0]})${n.path.slice(n.path.indexOf("."))} rather than the opposite of ${n.path}. Write !(${n.path}) for that`,
|
|
791
|
+
e.where,
|
|
792
|
+
t.at,
|
|
793
|
+
{ path: n.path }
|
|
794
|
+
);
|
|
795
|
+
return { kind: "not", operand: n };
|
|
796
|
+
}
|
|
797
|
+
function re(e) {
|
|
798
|
+
const t = U(e), n = N(e), r = n.kind === "operator" ? ut[n.text] : void 0;
|
|
799
|
+
return r === void 0 ? t : (e.index++, { kind: "compare", operator: r, left: t, right: U(e) });
|
|
800
|
+
}
|
|
801
|
+
function ie(e) {
|
|
802
|
+
let t = re(e);
|
|
803
|
+
for (; S(e, "&&"); )
|
|
804
|
+
e.index++, t = { kind: "and", left: t, right: re(e) };
|
|
805
|
+
return t;
|
|
806
|
+
}
|
|
807
|
+
function ye(e) {
|
|
808
|
+
let t = ie(e);
|
|
809
|
+
for (; S(e, "||"); )
|
|
810
|
+
e.index++, t = { kind: "or", left: t, right: ie(e) };
|
|
811
|
+
return t;
|
|
812
|
+
}
|
|
813
|
+
function pt(e) {
|
|
814
|
+
const t = { where: e, tokens: ct(e), index: 0 }, n = ye(t), r = N(t);
|
|
815
|
+
if (r.kind !== "end")
|
|
816
|
+
throw f(
|
|
817
|
+
`${JSON.stringify(r.text)} is left over at the end of the selector`,
|
|
818
|
+
e,
|
|
819
|
+
r.at
|
|
820
|
+
);
|
|
821
|
+
return n;
|
|
822
|
+
}
|
|
823
|
+
function $(e, t) {
|
|
824
|
+
switch (e.kind) {
|
|
825
|
+
case "path":
|
|
826
|
+
t.includes(e.path) || t.push(e.path);
|
|
827
|
+
return;
|
|
828
|
+
case "group":
|
|
829
|
+
$(e.inner, t);
|
|
830
|
+
return;
|
|
831
|
+
case "not":
|
|
832
|
+
$(e.operand, t);
|
|
833
|
+
return;
|
|
834
|
+
case "and":
|
|
835
|
+
case "or":
|
|
836
|
+
case "compare":
|
|
837
|
+
$(e.left, t), $(e.right, t);
|
|
838
|
+
return;
|
|
839
|
+
default:
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
function w(e, t) {
|
|
844
|
+
switch (e.kind) {
|
|
845
|
+
case "path": {
|
|
846
|
+
const { path: n } = e, { value: r } = t;
|
|
847
|
+
return (i) => {
|
|
848
|
+
const s = r(i, n);
|
|
849
|
+
return s === void 0 ? null : s;
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
case "literal": {
|
|
853
|
+
const { value: n } = e;
|
|
854
|
+
return () => n;
|
|
855
|
+
}
|
|
856
|
+
case "group":
|
|
857
|
+
return w(e.inner, t);
|
|
858
|
+
case "not": {
|
|
859
|
+
const n = w(e.operand, t);
|
|
860
|
+
return (r) => !I(n(r));
|
|
861
|
+
}
|
|
862
|
+
case "and": {
|
|
863
|
+
const n = w(e.left, t), r = w(e.right, t);
|
|
864
|
+
return (i) => {
|
|
865
|
+
const s = n(i);
|
|
866
|
+
return I(s) ? r(i) : s;
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
case "or": {
|
|
870
|
+
const n = w(e.left, t), r = w(e.right, t);
|
|
871
|
+
return (i) => {
|
|
872
|
+
const s = n(i);
|
|
873
|
+
return I(s) ? s : r(i);
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
default:
|
|
877
|
+
return ft(e.operator, e.left, e.right, t);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
const ht = Object.freeze({
|
|
881
|
+
"<": (e, t) => e < t,
|
|
882
|
+
"<=": (e, t) => e <= t,
|
|
883
|
+
">": (e, t) => e > t,
|
|
884
|
+
">=": (e, t) => e >= t
|
|
885
|
+
});
|
|
886
|
+
function mt(e, t) {
|
|
887
|
+
return e.kind === "literal" ? e : t.kind === "literal" ? t : null;
|
|
888
|
+
}
|
|
889
|
+
function ft(e, t, n, r) {
|
|
890
|
+
if (e === "==" || e === "!=") {
|
|
891
|
+
const a = e === "==", u = t.kind === "literal", c = mt(t, n), h = u ? n : t;
|
|
892
|
+
if (c !== null && c.value === null && h.kind === "path") {
|
|
893
|
+
const { path: d } = h, { has: v } = r;
|
|
894
|
+
return (k) => v(k, d) !== a;
|
|
895
|
+
}
|
|
896
|
+
const p = w(t, r), l = w(n, r);
|
|
897
|
+
if (c !== null && c.value !== null && typeof c.value != "object") {
|
|
898
|
+
const { value: d } = c, v = u ? l : p;
|
|
899
|
+
return (k) => v(k) === d === a;
|
|
900
|
+
}
|
|
901
|
+
return (d) => G(p(d), l(d)) === a;
|
|
902
|
+
}
|
|
903
|
+
const i = w(t, r), s = w(n, r), o = ht[e];
|
|
904
|
+
return (a) => {
|
|
905
|
+
const u = i(a), c = s(a);
|
|
906
|
+
return typeof u == "number" && typeof c == "number" ? o(u, c) : null;
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
function A(e, t) {
|
|
910
|
+
switch (e.kind) {
|
|
911
|
+
case "compare":
|
|
912
|
+
case "not": {
|
|
913
|
+
const n = w(e, t);
|
|
914
|
+
return (r) => n(r) === !0;
|
|
915
|
+
}
|
|
916
|
+
case "group":
|
|
917
|
+
return A(e.inner, t);
|
|
918
|
+
case "and": {
|
|
919
|
+
const n = A(e.left, t), r = A(e.right, t);
|
|
920
|
+
return (i) => n(i) && r(i);
|
|
921
|
+
}
|
|
922
|
+
case "or": {
|
|
923
|
+
const n = A(e.left, t), r = A(e.right, t);
|
|
924
|
+
return (i) => n(i) || r(i);
|
|
925
|
+
}
|
|
926
|
+
default: {
|
|
927
|
+
const n = w(e, t);
|
|
928
|
+
return (r) => I(n(r));
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
function gt(e) {
|
|
933
|
+
return e.split(".").map((t) => yt(t) ? t : JSON.stringify(t)).join(".");
|
|
934
|
+
}
|
|
935
|
+
function yt(e) {
|
|
936
|
+
if (e === "" || !fe(e[0]))
|
|
937
|
+
return !1;
|
|
938
|
+
for (let t = 1; t < e.length; t++)
|
|
939
|
+
if (!ge(e[t]))
|
|
940
|
+
return !1;
|
|
941
|
+
return !0;
|
|
942
|
+
}
|
|
943
|
+
function Cn(e, t) {
|
|
944
|
+
const { has: n } = e;
|
|
945
|
+
return (r) => n(r, t);
|
|
946
|
+
}
|
|
947
|
+
function xn(e, t) {
|
|
948
|
+
const { idOf: n } = e;
|
|
949
|
+
if (n === null)
|
|
950
|
+
throw new y({
|
|
951
|
+
code: "E_UNSUPPORTED",
|
|
952
|
+
message: 'This session cannot evaluate an "ids" selector, because it cannot say which id sits at which row. Painting the layer anyway would colour elements it never named.',
|
|
953
|
+
source: "style",
|
|
954
|
+
details: { match: "ids" }
|
|
955
|
+
});
|
|
956
|
+
return (r) => t.has(n(r));
|
|
957
|
+
}
|
|
958
|
+
function jn(e, t, n) {
|
|
959
|
+
const { value: r } = e;
|
|
960
|
+
return (i) => {
|
|
961
|
+
const s = n();
|
|
962
|
+
if (s === void 0)
|
|
963
|
+
return !1;
|
|
964
|
+
const o = r(i, t);
|
|
965
|
+
return typeof o == "number" && Number.isFinite(o) && o >= s;
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
function Pn(e, t) {
|
|
969
|
+
const n = pt(e), r = [];
|
|
970
|
+
if ($(n, r), r.length === 0) {
|
|
971
|
+
let i = n;
|
|
972
|
+
for (; i.kind === "group"; )
|
|
973
|
+
i = i.inner;
|
|
974
|
+
const s = i.kind === "literal" && typeof i.value == "string";
|
|
975
|
+
throw f(
|
|
976
|
+
s ? "The selector is a quoted string literal, which is always true, so it would match every element. Remove the outer quotes so it is read as an expression" : 'The selector reads no attribute of the element, so it answers the same for every element. Write { match: "everything" } for a layer that really is meant to paint the whole graph',
|
|
977
|
+
e,
|
|
978
|
+
0,
|
|
979
|
+
{ constant: !0 }
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
return { paths: Object.freeze(r), test: A(n, t) };
|
|
983
|
+
}
|
|
984
|
+
const H = "results", bt = "$";
|
|
985
|
+
function T(e, t) {
|
|
986
|
+
return t === void 0 ? `${H}.${e}` : `${H}.${e}.${t}`;
|
|
987
|
+
}
|
|
988
|
+
const be = {
|
|
989
|
+
// -- per element ---------------------------------------------------------------------
|
|
990
|
+
value: {
|
|
991
|
+
meaning: "The number this metric measured for this element.",
|
|
992
|
+
scope: "element",
|
|
993
|
+
types: ["number", "integer"]
|
|
994
|
+
},
|
|
995
|
+
rank: {
|
|
996
|
+
meaning: "Where this element sits when every measured element is ordered best first, starting at 1.",
|
|
997
|
+
scope: "element",
|
|
998
|
+
types: ["integer"]
|
|
999
|
+
},
|
|
1000
|
+
percentile: {
|
|
1001
|
+
meaning: "The share of measured elements this one ranks at or above, from 0 to 1.",
|
|
1002
|
+
scope: "element",
|
|
1003
|
+
types: ["number"]
|
|
1004
|
+
},
|
|
1005
|
+
group: {
|
|
1006
|
+
meaning: "Which group this node was placed in.",
|
|
1007
|
+
scope: "element",
|
|
1008
|
+
types: ["integer", "string"]
|
|
1009
|
+
},
|
|
1010
|
+
groupSize: {
|
|
1011
|
+
meaning: "How many nodes share this node's group.",
|
|
1012
|
+
scope: "element",
|
|
1013
|
+
types: ["integer"]
|
|
1014
|
+
},
|
|
1015
|
+
level: {
|
|
1016
|
+
meaning: "How many levels out from the start this node sits, counting the start as 0.",
|
|
1017
|
+
scope: "element",
|
|
1018
|
+
types: ["integer"]
|
|
1019
|
+
},
|
|
1020
|
+
levelSize: {
|
|
1021
|
+
meaning: "How many nodes share this node's level.",
|
|
1022
|
+
scope: "element",
|
|
1023
|
+
types: ["integer"]
|
|
1024
|
+
},
|
|
1025
|
+
category: {
|
|
1026
|
+
meaning: "The category this node was sorted into.",
|
|
1027
|
+
scope: "element",
|
|
1028
|
+
types: ["string"]
|
|
1029
|
+
},
|
|
1030
|
+
score: {
|
|
1031
|
+
meaning: "How strongly this node belongs to its category.",
|
|
1032
|
+
scope: "element",
|
|
1033
|
+
types: ["number"]
|
|
1034
|
+
},
|
|
1035
|
+
onPath: {
|
|
1036
|
+
meaning: "Whether this element is on the route the run found.",
|
|
1037
|
+
scope: "element",
|
|
1038
|
+
types: ["boolean"]
|
|
1039
|
+
},
|
|
1040
|
+
order: {
|
|
1041
|
+
meaning: "This node's position along the route, counting the source as 0.",
|
|
1042
|
+
scope: "element",
|
|
1043
|
+
types: ["integer"]
|
|
1044
|
+
},
|
|
1045
|
+
in: {
|
|
1046
|
+
meaning: "Whether this element is in the set the run selected.",
|
|
1047
|
+
scope: "element",
|
|
1048
|
+
types: ["boolean"]
|
|
1049
|
+
},
|
|
1050
|
+
// -- per graph -----------------------------------------------------------------------
|
|
1051
|
+
min: {
|
|
1052
|
+
meaning: "The lowest value any measured element carries.",
|
|
1053
|
+
scope: "graph",
|
|
1054
|
+
types: ["number"]
|
|
1055
|
+
},
|
|
1056
|
+
max: {
|
|
1057
|
+
meaning: "The highest value any measured element carries.",
|
|
1058
|
+
scope: "graph",
|
|
1059
|
+
types: ["number"]
|
|
1060
|
+
},
|
|
1061
|
+
median: {
|
|
1062
|
+
meaning: "The middle value once the measured elements are ordered.",
|
|
1063
|
+
scope: "graph",
|
|
1064
|
+
types: ["number"]
|
|
1065
|
+
},
|
|
1066
|
+
mean: {
|
|
1067
|
+
meaning: "The average value across the measured elements.",
|
|
1068
|
+
scope: "graph",
|
|
1069
|
+
types: ["number"]
|
|
1070
|
+
},
|
|
1071
|
+
measured: {
|
|
1072
|
+
meaning: "How many elements the run produced a value for. Smaller than the scope when some elements have nothing to measure. Distinct from RunResult.measured, which counts the nodes and edges the run looked at.",
|
|
1073
|
+
scope: "graph",
|
|
1074
|
+
types: ["integer"]
|
|
1075
|
+
},
|
|
1076
|
+
normalization: {
|
|
1077
|
+
meaning: 'How the values were scaled before publication: "max", "min-max" or "none".',
|
|
1078
|
+
scope: "graph",
|
|
1079
|
+
types: ["string"]
|
|
1080
|
+
},
|
|
1081
|
+
tiedAtMin: {
|
|
1082
|
+
meaning: "How many measured elements sit at the lowest value, which is what says whether a colour ramp is about to paint most of the graph one colour.",
|
|
1083
|
+
scope: "graph",
|
|
1084
|
+
types: ["integer"]
|
|
1085
|
+
},
|
|
1086
|
+
groupCount: {
|
|
1087
|
+
meaning: "How many groups the partition has.",
|
|
1088
|
+
scope: "graph",
|
|
1089
|
+
types: ["integer"]
|
|
1090
|
+
},
|
|
1091
|
+
modularity: {
|
|
1092
|
+
meaning: "How much better this partition is than a random one, from -0.5 to 1.",
|
|
1093
|
+
scope: "graph",
|
|
1094
|
+
types: ["number"]
|
|
1095
|
+
},
|
|
1096
|
+
sizes: {
|
|
1097
|
+
meaning: "The size of each group or level, largest first.",
|
|
1098
|
+
scope: "graph",
|
|
1099
|
+
types: ["table"]
|
|
1100
|
+
},
|
|
1101
|
+
levelCount: {
|
|
1102
|
+
meaning: "How many levels the walk reached.",
|
|
1103
|
+
scope: "graph",
|
|
1104
|
+
types: ["integer"]
|
|
1105
|
+
},
|
|
1106
|
+
categories: {
|
|
1107
|
+
meaning: "One row per category, with its name and how many elements fell into it.",
|
|
1108
|
+
scope: "graph",
|
|
1109
|
+
types: ["table"]
|
|
1110
|
+
},
|
|
1111
|
+
length: {
|
|
1112
|
+
meaning: "How many nodes are on the route.",
|
|
1113
|
+
scope: "graph",
|
|
1114
|
+
types: ["integer"]
|
|
1115
|
+
},
|
|
1116
|
+
cost: {
|
|
1117
|
+
meaning: "What the route costs in total, summing the weight of every edge on it.",
|
|
1118
|
+
scope: "graph",
|
|
1119
|
+
types: ["number"]
|
|
1120
|
+
},
|
|
1121
|
+
hops: {
|
|
1122
|
+
meaning: "How many edges are on the route.",
|
|
1123
|
+
scope: "graph",
|
|
1124
|
+
types: ["integer"]
|
|
1125
|
+
},
|
|
1126
|
+
count: {
|
|
1127
|
+
meaning: "How many elements are in the set.",
|
|
1128
|
+
scope: "graph",
|
|
1129
|
+
types: ["integer"]
|
|
1130
|
+
},
|
|
1131
|
+
pairs: {
|
|
1132
|
+
meaning: "One row per scored pair of elements, best first.",
|
|
1133
|
+
scope: "graph",
|
|
1134
|
+
types: ["table"]
|
|
1135
|
+
},
|
|
1136
|
+
steps: {
|
|
1137
|
+
meaning: "One row per time step, with the step's window and what was visible in it.",
|
|
1138
|
+
scope: "graph",
|
|
1139
|
+
types: ["table"]
|
|
1140
|
+
},
|
|
1141
|
+
series: {
|
|
1142
|
+
meaning: "One row per tracked quantity, carrying its value at every step.",
|
|
1143
|
+
scope: "graph",
|
|
1144
|
+
types: ["table"]
|
|
1145
|
+
},
|
|
1146
|
+
rates: {
|
|
1147
|
+
meaning: "One row per tracked quantity, carrying how fast it changed between steps.",
|
|
1148
|
+
scope: "graph",
|
|
1149
|
+
types: ["table"]
|
|
1150
|
+
},
|
|
1151
|
+
changeThreshold: {
|
|
1152
|
+
meaning: "The rate of change above which a step counts as a change rather than drift.",
|
|
1153
|
+
scope: "graph",
|
|
1154
|
+
types: ["number"]
|
|
1155
|
+
}
|
|
1156
|
+
}, Ln = Object.keys(be), q = {
|
|
1157
|
+
"node-metric": {
|
|
1158
|
+
shape: "node-metric",
|
|
1159
|
+
primaryField: "value",
|
|
1160
|
+
nodeFields: ["value", "rank", "percentile"],
|
|
1161
|
+
edgeFields: [],
|
|
1162
|
+
graphFields: ["min", "max", "median", "mean", "measured", "normalization", "tiedAtMin"],
|
|
1163
|
+
optionalGraphFields: [],
|
|
1164
|
+
headlineScalar: !1,
|
|
1165
|
+
layer: "encoding"
|
|
1166
|
+
},
|
|
1167
|
+
"edge-metric": {
|
|
1168
|
+
shape: "edge-metric",
|
|
1169
|
+
primaryField: "value",
|
|
1170
|
+
nodeFields: [],
|
|
1171
|
+
edgeFields: ["value", "rank", "percentile"],
|
|
1172
|
+
graphFields: ["min", "max", "median", "mean", "measured", "normalization", "tiedAtMin"],
|
|
1173
|
+
optionalGraphFields: [],
|
|
1174
|
+
headlineScalar: !1,
|
|
1175
|
+
layer: "encoding"
|
|
1176
|
+
},
|
|
1177
|
+
community: {
|
|
1178
|
+
shape: "community",
|
|
1179
|
+
primaryField: "group",
|
|
1180
|
+
nodeFields: ["group", "groupSize"],
|
|
1181
|
+
edgeFields: [],
|
|
1182
|
+
graphFields: ["groupCount", "sizes"],
|
|
1183
|
+
// Only an algorithm that scores its own partition can publish modularity. Label
|
|
1184
|
+
// propagation and connected components do not, and a required field they cannot fill
|
|
1185
|
+
// would be a number invented to satisfy a table.
|
|
1186
|
+
optionalGraphFields: ["modularity"],
|
|
1187
|
+
headlineScalar: !1,
|
|
1188
|
+
layer: "encoding"
|
|
1189
|
+
},
|
|
1190
|
+
"layered-grouping": {
|
|
1191
|
+
shape: "layered-grouping",
|
|
1192
|
+
primaryField: "level",
|
|
1193
|
+
nodeFields: ["level", "levelSize"],
|
|
1194
|
+
edgeFields: [],
|
|
1195
|
+
graphFields: ["levelCount", "sizes"],
|
|
1196
|
+
optionalGraphFields: [],
|
|
1197
|
+
headlineScalar: !1,
|
|
1198
|
+
layer: "encoding"
|
|
1199
|
+
},
|
|
1200
|
+
"category-table": {
|
|
1201
|
+
shape: "category-table",
|
|
1202
|
+
primaryField: "category",
|
|
1203
|
+
nodeFields: ["category", "score", "rank"],
|
|
1204
|
+
edgeFields: [],
|
|
1205
|
+
graphFields: ["categories"],
|
|
1206
|
+
optionalGraphFields: [],
|
|
1207
|
+
headlineScalar: !1,
|
|
1208
|
+
layer: "encoding"
|
|
1209
|
+
},
|
|
1210
|
+
path: {
|
|
1211
|
+
shape: "path",
|
|
1212
|
+
primaryField: "onPath",
|
|
1213
|
+
nodeFields: ["onPath", "order"],
|
|
1214
|
+
// The edges of the route carry membership but not a position: an edge's place in the
|
|
1215
|
+
// route is the order of the node it leaves.
|
|
1216
|
+
edgeFields: ["onPath"],
|
|
1217
|
+
graphFields: ["length", "cost", "hops"],
|
|
1218
|
+
optionalGraphFields: [],
|
|
1219
|
+
headlineScalar: !1,
|
|
1220
|
+
layer: "highlight"
|
|
1221
|
+
},
|
|
1222
|
+
"node-set": {
|
|
1223
|
+
shape: "node-set",
|
|
1224
|
+
primaryField: "in",
|
|
1225
|
+
nodeFields: ["in"],
|
|
1226
|
+
edgeFields: [],
|
|
1227
|
+
graphFields: ["count"],
|
|
1228
|
+
optionalGraphFields: [],
|
|
1229
|
+
headlineScalar: !0,
|
|
1230
|
+
layer: "highlight"
|
|
1231
|
+
},
|
|
1232
|
+
"edge-set": {
|
|
1233
|
+
shape: "edge-set",
|
|
1234
|
+
primaryField: "in",
|
|
1235
|
+
nodeFields: [],
|
|
1236
|
+
edgeFields: ["in"],
|
|
1237
|
+
graphFields: ["count"],
|
|
1238
|
+
optionalGraphFields: [],
|
|
1239
|
+
headlineScalar: !0,
|
|
1240
|
+
layer: "highlight"
|
|
1241
|
+
},
|
|
1242
|
+
"pair-list": {
|
|
1243
|
+
shape: "pair-list",
|
|
1244
|
+
primaryField: "pairs",
|
|
1245
|
+
nodeFields: [],
|
|
1246
|
+
edgeFields: [],
|
|
1247
|
+
graphFields: ["pairs"],
|
|
1248
|
+
optionalGraphFields: [],
|
|
1249
|
+
headlineScalar: !1,
|
|
1250
|
+
layer: "none"
|
|
1251
|
+
},
|
|
1252
|
+
temporal: {
|
|
1253
|
+
shape: "temporal",
|
|
1254
|
+
primaryField: "series",
|
|
1255
|
+
nodeFields: [],
|
|
1256
|
+
edgeFields: [],
|
|
1257
|
+
graphFields: ["steps", "series", "rates", "changeThreshold"],
|
|
1258
|
+
optionalGraphFields: [],
|
|
1259
|
+
headlineScalar: !1,
|
|
1260
|
+
layer: "none"
|
|
1261
|
+
},
|
|
1262
|
+
fact: {
|
|
1263
|
+
shape: "fact",
|
|
1264
|
+
primaryField: null,
|
|
1265
|
+
nodeFields: [],
|
|
1266
|
+
edgeFields: [],
|
|
1267
|
+
graphFields: [],
|
|
1268
|
+
optionalGraphFields: [],
|
|
1269
|
+
headlineScalar: !1,
|
|
1270
|
+
layer: "none"
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
function B(e) {
|
|
1274
|
+
return q[e];
|
|
1275
|
+
}
|
|
1276
|
+
function Dn(e) {
|
|
1277
|
+
return q[e].layer === "highlight";
|
|
1278
|
+
}
|
|
1279
|
+
function Gn(e, t) {
|
|
1280
|
+
const n = q[e], r = [], i = [
|
|
1281
|
+
{ names: n.nodeFields, kind: "node" },
|
|
1282
|
+
{ names: n.edgeFields, kind: "edge" },
|
|
1283
|
+
{ names: n.graphFields, kind: "graph" }
|
|
1284
|
+
];
|
|
1285
|
+
for (const { names: s, kind: o } of i)
|
|
1286
|
+
for (const a of s) {
|
|
1287
|
+
const u = t.find((h) => h.name === a && h.kind === o);
|
|
1288
|
+
if (u === void 0) {
|
|
1289
|
+
r.push({
|
|
1290
|
+
field: a,
|
|
1291
|
+
kind: o,
|
|
1292
|
+
reason: `shape "${e}" requires a ${o} field named "${a}"`
|
|
1293
|
+
});
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
const c = be[a].types;
|
|
1297
|
+
c.includes(u.type) || r.push({
|
|
1298
|
+
field: a,
|
|
1299
|
+
kind: o,
|
|
1300
|
+
reason: `${o} field "${a}" is typed "${u.type}", not ${c.map((h) => `"${h}"`).join(" or ")}`
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
return n.headlineScalar && !wt(n, t) && r.push({
|
|
1304
|
+
field: null,
|
|
1305
|
+
kind: "graph",
|
|
1306
|
+
reason: `shape "${e}" requires one graph-level scalar of its own beside "count"`
|
|
1307
|
+
}), r;
|
|
1308
|
+
}
|
|
1309
|
+
function wt(e, t) {
|
|
1310
|
+
const n = [...e.graphFields, ...e.optionalGraphFields];
|
|
1311
|
+
return t.some((r) => r.kind === "graph" && !n.includes(r.name));
|
|
1312
|
+
}
|
|
1313
|
+
const vt = 3;
|
|
1314
|
+
function Ot(e, t) {
|
|
1315
|
+
if (e === t)
|
|
1316
|
+
return 0;
|
|
1317
|
+
const n = new Uint32Array(t.length + 1), r = new Uint32Array(t.length + 1);
|
|
1318
|
+
for (let i = 0; i <= t.length; i++)
|
|
1319
|
+
n[i] = i;
|
|
1320
|
+
for (let i = 1; i <= e.length; i++) {
|
|
1321
|
+
r[0] = i;
|
|
1322
|
+
for (let s = 1; s <= t.length; s++) {
|
|
1323
|
+
const o = n[s - 1] + (e[i - 1] === t[s - 1] ? 0 : 1);
|
|
1324
|
+
r[s] = Math.min(r[s - 1] + 1, n[s] + 1, o);
|
|
1325
|
+
}
|
|
1326
|
+
n.set(r);
|
|
1327
|
+
}
|
|
1328
|
+
return n[t.length];
|
|
1329
|
+
}
|
|
1330
|
+
function kt(e, t, n = vt) {
|
|
1331
|
+
const r = e.toLowerCase(), i = t.map((s) => ({
|
|
1332
|
+
candidate: s,
|
|
1333
|
+
distance: Ot(r, s.toLowerCase())
|
|
1334
|
+
}));
|
|
1335
|
+
return i.sort((s, o) => s.distance - o.distance || s.candidate.localeCompare(o.candidate)), Object.freeze(i.slice(0, Math.max(n, 0)).map((s) => s.candidate));
|
|
1336
|
+
}
|
|
1337
|
+
function se(e) {
|
|
1338
|
+
return typeof e == "string" ? e : "runId" in e ? e.runId : e.id;
|
|
1339
|
+
}
|
|
1340
|
+
function Nt(e) {
|
|
1341
|
+
return typeof e == "string" ? void 0 : e.shape;
|
|
1342
|
+
}
|
|
1343
|
+
function St(e, t) {
|
|
1344
|
+
return e.fields.some((n) => n.name === t) || t in e.graph;
|
|
1345
|
+
}
|
|
1346
|
+
class At {
|
|
1347
|
+
#e;
|
|
1348
|
+
/**
|
|
1349
|
+
* Build the API over a registry.
|
|
1350
|
+
* @param registry - Where runs are looked up.
|
|
1351
|
+
*/
|
|
1352
|
+
constructor(t) {
|
|
1353
|
+
this.#e = t;
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* The published path of a run's field.
|
|
1357
|
+
*
|
|
1358
|
+
* With no field the path names the run's primary field -- `value` for a metric, `group` for a
|
|
1359
|
+
* partition, `onPath` for a route -- so a caller binds an encoding to a run without knowing
|
|
1360
|
+
* what that algorithm calls its number. A `fact` result has no primary field and addresses
|
|
1361
|
+
* its whole result object instead.
|
|
1362
|
+
* @param run - The run, its result, or its id.
|
|
1363
|
+
* @param field - The field name; the shape's primary field when absent.
|
|
1364
|
+
* @returns The path.
|
|
1365
|
+
*/
|
|
1366
|
+
path(t, n) {
|
|
1367
|
+
const r = se(t);
|
|
1368
|
+
if (n !== void 0)
|
|
1369
|
+
return T(r, n);
|
|
1370
|
+
const i = Nt(t) ?? this.#e.entry(r)?.shape, s = i === void 0 ? null : B(i).primaryField;
|
|
1371
|
+
return s === null ? T(r) : T(r, s);
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* The same field, written so a selector expression can read it.
|
|
1375
|
+
*
|
|
1376
|
+
* The quoting is the whole point: a run id carries its algorithm's name, and a hyphenated
|
|
1377
|
+
* name lexes its hyphen as subtraction, so a path pasted into an expression unquoted is a
|
|
1378
|
+
* refused selector rather than a comparison. Nothing here decides WHICH field -- that is
|
|
1379
|
+
* {@link ResultsApi.path}'s job and this defers to it -- so the two can never name different
|
|
1380
|
+
* columns.
|
|
1381
|
+
* @param run - The run, its result, or its id.
|
|
1382
|
+
* @param field - The field name; the shape's primary field when absent.
|
|
1383
|
+
* @returns The path with every segment quoted that needs it.
|
|
1384
|
+
*/
|
|
1385
|
+
term(t, n) {
|
|
1386
|
+
return gt(n === void 0 ? this.path(t) : this.path(t, n));
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* One run's result.
|
|
1390
|
+
*
|
|
1391
|
+
* The answer always comes from the registry, even when the caller passed a result object: the
|
|
1392
|
+
* question is what this session holds, and a result the session never registered is not it.
|
|
1393
|
+
* @param run - The run, its result, or its id.
|
|
1394
|
+
* @returns The result, or undefined when the session holds no such run or it has not
|
|
1395
|
+
* finished.
|
|
1396
|
+
*/
|
|
1397
|
+
get(t) {
|
|
1398
|
+
return this.#e.entry(se(t))?.result;
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Whether a run, or one of its fields, is available to read.
|
|
1402
|
+
* @param run - The run, its result, or its id.
|
|
1403
|
+
* @param field - The field name; asks only about the run itself when absent.
|
|
1404
|
+
* @returns True when the path would resolve.
|
|
1405
|
+
*/
|
|
1406
|
+
has(t, n) {
|
|
1407
|
+
const r = this.get(t);
|
|
1408
|
+
return r === void 0 ? !1 : n === void 0 || St(r, n);
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Every run that has published a result, as an expression editor reads them.
|
|
1412
|
+
* @returns One root per finished run, in the order the runs were started.
|
|
1413
|
+
*/
|
|
1414
|
+
get roots() {
|
|
1415
|
+
const t = [];
|
|
1416
|
+
for (const n of this.#e.entries())
|
|
1417
|
+
n.result !== void 0 && t.push(Object.freeze({ runId: n.id, label: n.label, fields: n.result.fields }));
|
|
1418
|
+
return Object.freeze(t);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
function Un(e) {
|
|
1422
|
+
return new At(e);
|
|
1423
|
+
}
|
|
1424
|
+
const $t = 20, j = 100, Rt = 100, Et = Object.freeze([]), Ft = Object.freeze(["max", "min-max", "none"]);
|
|
1425
|
+
function we(e) {
|
|
1426
|
+
return typeof e == "string" && Ft.includes(e);
|
|
1427
|
+
}
|
|
1428
|
+
function Hn(e) {
|
|
1429
|
+
return {
|
|
1430
|
+
length: e.length,
|
|
1431
|
+
get: (t) => e[t]
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
const It = Object.freeze({
|
|
1435
|
+
measured: 0,
|
|
1436
|
+
min: Number.NaN,
|
|
1437
|
+
max: Number.NaN,
|
|
1438
|
+
mean: Number.NaN,
|
|
1439
|
+
median: Number.NaN,
|
|
1440
|
+
tiedAtMin: 0,
|
|
1441
|
+
smallestPositive: null
|
|
1442
|
+
});
|
|
1443
|
+
function ve(e) {
|
|
1444
|
+
const { length: t } = e, n = new Float64Array(t);
|
|
1445
|
+
let r = 0;
|
|
1446
|
+
for (let l = 0; l < t; l++) {
|
|
1447
|
+
const d = e.get(l);
|
|
1448
|
+
Number.isFinite(d) && (n[r] = d, r++);
|
|
1449
|
+
}
|
|
1450
|
+
if (r === 0)
|
|
1451
|
+
return { length: t, ...It };
|
|
1452
|
+
let i = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY, a = 0, u = 0;
|
|
1453
|
+
for (let l = 0; l < r; l++) {
|
|
1454
|
+
const d = n[l];
|
|
1455
|
+
d < i && (i = d), d > s && (s = d), d > 0 && d < o && (o = d);
|
|
1456
|
+
const v = d - u, k = a + v;
|
|
1457
|
+
u = k - a - v, a = k;
|
|
1458
|
+
}
|
|
1459
|
+
const c = n.slice(0, r).sort(), h = c[Math.floor((r - 1) / 2)];
|
|
1460
|
+
let p = 0;
|
|
1461
|
+
for (; p < r && c[p] === i; )
|
|
1462
|
+
p++;
|
|
1463
|
+
return {
|
|
1464
|
+
length: t,
|
|
1465
|
+
measured: r,
|
|
1466
|
+
min: i,
|
|
1467
|
+
max: s,
|
|
1468
|
+
mean: a / r,
|
|
1469
|
+
median: h,
|
|
1470
|
+
tiedAtMin: p,
|
|
1471
|
+
smallestPositive: Number.isFinite(o) ? o : null
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
function Oe(e) {
|
|
1475
|
+
const t = ve(e);
|
|
1476
|
+
return { view: Object.freeze({
|
|
1477
|
+
length: e.length,
|
|
1478
|
+
get: (r) => e.get(r),
|
|
1479
|
+
min: t.min,
|
|
1480
|
+
max: t.max,
|
|
1481
|
+
mean: t.mean,
|
|
1482
|
+
median: t.median
|
|
1483
|
+
}), statistics: t };
|
|
1484
|
+
}
|
|
1485
|
+
function J(e) {
|
|
1486
|
+
const t = e.filter((o) => Number.isFinite(o.value)).map((o) => ({ entry: o, label: String(o.id) }));
|
|
1487
|
+
t.sort((o, a) => o.entry.value !== a.entry.value ? a.entry.value - o.entry.value : o.label === a.label ? 0 : o.label < a.label ? -1 : 1);
|
|
1488
|
+
const n = t.length, r = [];
|
|
1489
|
+
let i = 0, s = Number.NaN;
|
|
1490
|
+
for (let o = 0; o < n; o++) {
|
|
1491
|
+
const { entry: a } = t[o];
|
|
1492
|
+
a.value !== s && (i = o + 1, s = a.value), r.push(
|
|
1493
|
+
Object.freeze({
|
|
1494
|
+
id: a.id,
|
|
1495
|
+
value: a.value,
|
|
1496
|
+
rank: i,
|
|
1497
|
+
percentile: (n - i + 1) / n
|
|
1498
|
+
})
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1501
|
+
return Object.freeze(r);
|
|
1502
|
+
}
|
|
1503
|
+
function Tt(e, t) {
|
|
1504
|
+
let n = Math.min(t, e.length);
|
|
1505
|
+
for (; n > 0 && n < e.length && e[n].rank === e[n - 1].rank; )
|
|
1506
|
+
n--;
|
|
1507
|
+
if (n === e.length || n === t)
|
|
1508
|
+
return Object.freeze({ entries: e.slice(0, n), leftOut: null, reason: null });
|
|
1509
|
+
const { value: r } = e[n];
|
|
1510
|
+
let i = n;
|
|
1511
|
+
for (; i < e.length && e[i].value === r; )
|
|
1512
|
+
i++;
|
|
1513
|
+
const s = i - n, o = `${String(s)} tie at ${String(r)}, and taking them would make ${String(n + s)}, more than the ${String(t)} asked for, so ${n === 0 ? "none are" : `only the top ${String(n)} are`} taken.`;
|
|
1514
|
+
return Object.freeze({
|
|
1515
|
+
entries: e.slice(0, n),
|
|
1516
|
+
leftOut: Object.freeze({ value: r, count: s }),
|
|
1517
|
+
reason: o
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
function Mt(e) {
|
|
1521
|
+
const { smallestPositive: t } = e;
|
|
1522
|
+
if (e.measured === 0 || !(e.max > 0) || t === null)
|
|
1523
|
+
return !1;
|
|
1524
|
+
const n = e.min > 0 ? e.min : t;
|
|
1525
|
+
return Math.log10(e.max) > Math.log10(n);
|
|
1526
|
+
}
|
|
1527
|
+
function _t(e) {
|
|
1528
|
+
return e.measured === 0 || !(e.median > 0) || e.max / e.median <= Rt ? "linear" : Mt(e) ? "log" : "linear";
|
|
1529
|
+
}
|
|
1530
|
+
function zt(e, t, n, r) {
|
|
1531
|
+
if (!(t > e))
|
|
1532
|
+
return { binCount: 1, indexOf: () => 0, rangeOf: () => [e, t] };
|
|
1533
|
+
if (r) {
|
|
1534
|
+
const s = t - e + 1, o = Math.ceil(s / Math.min(s, n)), a = Math.ceil(s / o);
|
|
1535
|
+
return {
|
|
1536
|
+
binCount: a,
|
|
1537
|
+
indexOf: (u) => Math.min(Math.floor((u - e) / o), a - 1),
|
|
1538
|
+
rangeOf: (u) => {
|
|
1539
|
+
const c = e + u * o;
|
|
1540
|
+
return [c, Math.min(c + o - 1, t)];
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
const i = (t - e) / n;
|
|
1545
|
+
return {
|
|
1546
|
+
binCount: n,
|
|
1547
|
+
indexOf: (s) => Math.min(Math.floor((s - e) / i), n - 1),
|
|
1548
|
+
rangeOf: (s) => [
|
|
1549
|
+
e + s * i,
|
|
1550
|
+
s === n - 1 ? t : e + (s + 1) * i
|
|
1551
|
+
]
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
function Ct(e, t, n, r, i) {
|
|
1555
|
+
const s = e > 0 ? 0 : 1, o = s === 0 ? e : n;
|
|
1556
|
+
if (!(t > 0) || o === null || !(o > 0))
|
|
1557
|
+
return null;
|
|
1558
|
+
const a = Math.log10(o), u = Math.log10(t);
|
|
1559
|
+
if (!(u > a))
|
|
1560
|
+
return null;
|
|
1561
|
+
const c = r - s;
|
|
1562
|
+
if (c < 1)
|
|
1563
|
+
return null;
|
|
1564
|
+
const h = (u - a) / c;
|
|
1565
|
+
return {
|
|
1566
|
+
binCount: r,
|
|
1567
|
+
indexOf: (p) => {
|
|
1568
|
+
if (!(p > 0))
|
|
1569
|
+
return 0;
|
|
1570
|
+
const l = Math.floor((Math.log10(p) - a) / h);
|
|
1571
|
+
return s + Math.min(Math.max(l, 0), c - 1);
|
|
1572
|
+
},
|
|
1573
|
+
rangeOf: (p) => {
|
|
1574
|
+
if (p < s)
|
|
1575
|
+
return [e, 0];
|
|
1576
|
+
const l = p - s, d = l === 0 ? o : 10 ** (a + l * h), v = l === c - 1 ? t : 10 ** (a + (l + 1) * h);
|
|
1577
|
+
if (!i)
|
|
1578
|
+
return [d, v];
|
|
1579
|
+
const k = l === 0 ? o : Math.ceil(d);
|
|
1580
|
+
return [k, l === c - 1 ? t : Math.max(k, Math.ceil(v) - 1)];
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
function xt(e) {
|
|
1585
|
+
if (e === void 0)
|
|
1586
|
+
return $t;
|
|
1587
|
+
if (!Number.isInteger(e) || e < 1 || e > j)
|
|
1588
|
+
throw new y({
|
|
1589
|
+
code: "E_OPTION_RANGE",
|
|
1590
|
+
source: "run",
|
|
1591
|
+
message: `A histogram takes between 1 and ${j} bins; ${String(e)} was asked for.`,
|
|
1592
|
+
details: { option: "bins", value: e, min: 1, max: j }
|
|
1593
|
+
});
|
|
1594
|
+
return e;
|
|
1595
|
+
}
|
|
1596
|
+
function jt(e, t) {
|
|
1597
|
+
const n = /* @__PURE__ */ new Map();
|
|
1598
|
+
for (let r = 0; r < e.length; r++) {
|
|
1599
|
+
const i = e.get(r);
|
|
1600
|
+
if (!Number.isFinite(i))
|
|
1601
|
+
continue;
|
|
1602
|
+
const s = n.get(i);
|
|
1603
|
+
if (s === void 0) {
|
|
1604
|
+
if (n.size >= t)
|
|
1605
|
+
return null;
|
|
1606
|
+
n.set(i, 1);
|
|
1607
|
+
continue;
|
|
1608
|
+
}
|
|
1609
|
+
n.set(i, s + 1);
|
|
1610
|
+
}
|
|
1611
|
+
return n;
|
|
1612
|
+
}
|
|
1613
|
+
function Pt(e, t) {
|
|
1614
|
+
const n = xt(t?.bins), r = t?.integerValued ?? !1, i = ve(e), s = _t(i), o = jt(e, n);
|
|
1615
|
+
if (o !== null) {
|
|
1616
|
+
if (o.size === 0)
|
|
1617
|
+
return Object.freeze({
|
|
1618
|
+
bins: Et,
|
|
1619
|
+
// Nothing was measured, so nothing is on any axis. Reported as linear rather
|
|
1620
|
+
// than as the request, because "log scale" over an empty chart is the same false
|
|
1621
|
+
// caption this whole return type exists to prevent.
|
|
1622
|
+
scale: "linear",
|
|
1623
|
+
suggestedScale: "linear",
|
|
1624
|
+
binning: "empty"
|
|
1625
|
+
});
|
|
1626
|
+
const p = [...o.entries()].sort((l, d) => l[0] - d[0]).map(([l, d]) => Object.freeze({ from: l, to: l, count: d }));
|
|
1627
|
+
return Object.freeze({
|
|
1628
|
+
bins: Object.freeze(p),
|
|
1629
|
+
// One bar per distinct value has no bands to space, so neither axis was applied to
|
|
1630
|
+
// it. Saying "linear" here is what stops a caption claiming a logarithmic layout of
|
|
1631
|
+
// a chart that has none.
|
|
1632
|
+
scale: "linear",
|
|
1633
|
+
suggestedScale: s,
|
|
1634
|
+
binning: "per-value"
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
const u = t?.scale === "log" || t?.scale === "auto" && s === "log" ? Ct(i.min, i.max, i.smallestPositive, n, r) : null, c = u ?? zt(i.min, i.max, n, r), h = new Array(c.binCount).fill(0);
|
|
1638
|
+
for (let p = 0; p < e.length; p++) {
|
|
1639
|
+
const l = e.get(p);
|
|
1640
|
+
Number.isFinite(l) && (h[c.indexOf(l)] += 1);
|
|
1641
|
+
}
|
|
1642
|
+
return Object.freeze({
|
|
1643
|
+
bins: Object.freeze(
|
|
1644
|
+
h.map((p, l) => {
|
|
1645
|
+
const [d, v] = c.rangeOf(l);
|
|
1646
|
+
return Object.freeze({ from: d, to: v, count: p });
|
|
1647
|
+
})
|
|
1648
|
+
),
|
|
1649
|
+
// `plan` is null exactly when a logarithmic layout was asked for and could not be built,
|
|
1650
|
+
// which is the case a caption must not get wrong.
|
|
1651
|
+
scale: u === null ? "linear" : "log",
|
|
1652
|
+
suggestedScale: s,
|
|
1653
|
+
binning: "banded"
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
const Lt = 10, Dt = 10;
|
|
1657
|
+
function oe(e) {
|
|
1658
|
+
const t = { ids: [], records: [], index: /* @__PURE__ */ new Map() };
|
|
1659
|
+
if (e === void 0)
|
|
1660
|
+
return t;
|
|
1661
|
+
for (const n of e) {
|
|
1662
|
+
const r = t.index.get(n.id);
|
|
1663
|
+
if (r === void 0) {
|
|
1664
|
+
t.index.set(n.id, t.ids.length), t.ids.push(n.id), t.records.push({ ...n.values });
|
|
1665
|
+
continue;
|
|
1666
|
+
}
|
|
1667
|
+
Object.assign(t.records[r], n.values);
|
|
1668
|
+
}
|
|
1669
|
+
return t;
|
|
1670
|
+
}
|
|
1671
|
+
function V(e, t) {
|
|
1672
|
+
const { records: n } = e;
|
|
1673
|
+
return {
|
|
1674
|
+
length: n.length,
|
|
1675
|
+
get: (r) => ke(n[r][t])
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
function Y(e, t) {
|
|
1679
|
+
return e.ids.map((n, r) => ({ id: n, value: ke(e.records[r][t]) }));
|
|
1680
|
+
}
|
|
1681
|
+
function ke(e) {
|
|
1682
|
+
return typeof e == "number" ? e : Number.NaN;
|
|
1683
|
+
}
|
|
1684
|
+
function W(e) {
|
|
1685
|
+
return typeof e == "string" || typeof e == "number";
|
|
1686
|
+
}
|
|
1687
|
+
function P(e) {
|
|
1688
|
+
return e.type === "number" || e.type === "integer";
|
|
1689
|
+
}
|
|
1690
|
+
function g(e, t, n) {
|
|
1691
|
+
e[t] === void 0 && (e[t] = n);
|
|
1692
|
+
}
|
|
1693
|
+
function M(e, t, n) {
|
|
1694
|
+
e[t] === void 0 && (e[t] = n);
|
|
1695
|
+
}
|
|
1696
|
+
function Ne(e, t) {
|
|
1697
|
+
const n = /* @__PURE__ */ new Map();
|
|
1698
|
+
for (const r of e.records) {
|
|
1699
|
+
const i = r[t];
|
|
1700
|
+
W(i) && n.set(i, (n.get(i) ?? 0) + 1);
|
|
1701
|
+
}
|
|
1702
|
+
return n;
|
|
1703
|
+
}
|
|
1704
|
+
function Se(e, t) {
|
|
1705
|
+
const n = String(e), r = String(t);
|
|
1706
|
+
return n === r ? 0 : n < r ? -1 : 1;
|
|
1707
|
+
}
|
|
1708
|
+
function Gt(e) {
|
|
1709
|
+
const t = [...e.entries()].map(([n, r]) => ({ group: n, size: r }));
|
|
1710
|
+
return t.sort((n, r) => r.size - n.size || Se(n.group, r.group)), Object.freeze(t.map((n) => Object.freeze(n)));
|
|
1711
|
+
}
|
|
1712
|
+
function Ae(e, t) {
|
|
1713
|
+
const n = e.find((r) => r.name === t)?.normalization;
|
|
1714
|
+
return we(n) ? n : "none";
|
|
1715
|
+
}
|
|
1716
|
+
function ae(e, t, n) {
|
|
1717
|
+
const { statistics: r } = Oe(V(e, "value"));
|
|
1718
|
+
for (const i of J(Y(e, "value"))) {
|
|
1719
|
+
const s = e.index.get(i.id);
|
|
1720
|
+
s !== void 0 && (M(e.records[s], "rank", i.rank), M(e.records[s], "percentile", i.percentile));
|
|
1721
|
+
}
|
|
1722
|
+
r.measured > 0 && (g(t, "min", r.min), g(t, "max", r.max), g(t, "median", r.median), g(t, "mean", r.mean)), g(t, "measured", r.measured), g(t, "tiedAtMin", r.tiedAtMin), g(t, "normalization", Ae(n, "value"));
|
|
1723
|
+
}
|
|
1724
|
+
function ce(e, t, n, r, i) {
|
|
1725
|
+
const s = Ne(e, n);
|
|
1726
|
+
for (const o of e.records) {
|
|
1727
|
+
const a = o[n];
|
|
1728
|
+
W(a) && M(o, r, s.get(a));
|
|
1729
|
+
}
|
|
1730
|
+
g(t, i, s.size), g(t, "sizes", Gt(s));
|
|
1731
|
+
}
|
|
1732
|
+
function Ut(e, t) {
|
|
1733
|
+
for (const r of J(Y(e, "score"))) {
|
|
1734
|
+
const i = e.index.get(r.id);
|
|
1735
|
+
i !== void 0 && M(e.records[i], "rank", r.rank);
|
|
1736
|
+
}
|
|
1737
|
+
const n = [...Ne(e, "category").entries()].map(([r, i]) => ({
|
|
1738
|
+
category: String(r),
|
|
1739
|
+
count: i
|
|
1740
|
+
}));
|
|
1741
|
+
n.sort((r, i) => i.count - r.count || Se(r.category, i.category)), g(t, "categories", Object.freeze(n.map((r) => Object.freeze(r))));
|
|
1742
|
+
}
|
|
1743
|
+
function F(e, t) {
|
|
1744
|
+
let n = 0;
|
|
1745
|
+
for (const r of e.records)
|
|
1746
|
+
r[t] === !0 && n++;
|
|
1747
|
+
return n;
|
|
1748
|
+
}
|
|
1749
|
+
function ue(e, t) {
|
|
1750
|
+
let n = 0;
|
|
1751
|
+
for (const r of e.records)
|
|
1752
|
+
r[t] !== void 0 && n++;
|
|
1753
|
+
return n;
|
|
1754
|
+
}
|
|
1755
|
+
function Ht(e, t, n, r, i) {
|
|
1756
|
+
switch (e) {
|
|
1757
|
+
case "node-metric":
|
|
1758
|
+
ae(t, r, i);
|
|
1759
|
+
break;
|
|
1760
|
+
case "edge-metric":
|
|
1761
|
+
ae(n, r, i);
|
|
1762
|
+
break;
|
|
1763
|
+
case "community":
|
|
1764
|
+
ce(t, r, "group", "groupSize", "groupCount");
|
|
1765
|
+
break;
|
|
1766
|
+
case "layered-grouping":
|
|
1767
|
+
ce(t, r, "level", "levelSize", "levelCount");
|
|
1768
|
+
break;
|
|
1769
|
+
case "category-table":
|
|
1770
|
+
Ut(t, r);
|
|
1771
|
+
break;
|
|
1772
|
+
case "path":
|
|
1773
|
+
g(r, "length", F(t, "onPath")), g(r, "hops", F(n, "onPath"));
|
|
1774
|
+
break;
|
|
1775
|
+
case "node-set":
|
|
1776
|
+
g(r, "count", F(t, "in"));
|
|
1777
|
+
break;
|
|
1778
|
+
case "edge-set":
|
|
1779
|
+
g(r, "count", F(n, "in"));
|
|
1780
|
+
break;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
function Bt(e) {
|
|
1784
|
+
switch (e) {
|
|
1785
|
+
case "node-metric":
|
|
1786
|
+
case "edge-metric":
|
|
1787
|
+
return "value";
|
|
1788
|
+
case "category-table":
|
|
1789
|
+
return "score";
|
|
1790
|
+
case "layered-grouping":
|
|
1791
|
+
return "level";
|
|
1792
|
+
default:
|
|
1793
|
+
return null;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
function Vt(e, t) {
|
|
1797
|
+
if (!Array.isArray(e))
|
|
1798
|
+
return;
|
|
1799
|
+
const n = [];
|
|
1800
|
+
for (const r of e) {
|
|
1801
|
+
if (typeof r != "object" || r === null)
|
|
1802
|
+
continue;
|
|
1803
|
+
const i = r, s = i.group ?? i.category, o = i.size ?? i.count;
|
|
1804
|
+
if (W(s) && typeof o == "number" && n.push(Object.freeze({ group: s, size: o })), n.length === t)
|
|
1805
|
+
break;
|
|
1806
|
+
}
|
|
1807
|
+
return Object.freeze(n);
|
|
1808
|
+
}
|
|
1809
|
+
class qt {
|
|
1810
|
+
#e;
|
|
1811
|
+
#t;
|
|
1812
|
+
#n;
|
|
1813
|
+
#r;
|
|
1814
|
+
#i;
|
|
1815
|
+
#s;
|
|
1816
|
+
#o = /* @__PURE__ */ new Map();
|
|
1817
|
+
#a = /* @__PURE__ */ new Map();
|
|
1818
|
+
#c = /* @__PURE__ */ new Map();
|
|
1819
|
+
#u;
|
|
1820
|
+
/**
|
|
1821
|
+
* Build a result around storage that has already been filled and frozen.
|
|
1822
|
+
* @param init - What the run published.
|
|
1823
|
+
* @param nodes - The published nodes.
|
|
1824
|
+
* @param edges - The published edges.
|
|
1825
|
+
* @param graph - The graph half, frozen.
|
|
1826
|
+
*/
|
|
1827
|
+
constructor(t, n, r, i) {
|
|
1828
|
+
this.runId = t.runId, this.shape = t.shape, this.fields = Object.freeze([...t.fields]), this.measured = Object.freeze({ nodes: t.measured.nodes, edges: t.measured.edges }), this.graph = i, this.#e = n, this.#t = r, this.#n = t.caveats, this.#r = t.durationMs, this.#i = t.labelOf ?? (() => {
|
|
1829
|
+
}), this.#s = t.reading ?? tt;
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* One node's fields.
|
|
1833
|
+
* @param id - The node id.
|
|
1834
|
+
* @returns The fields, or undefined when the run produced nothing for that node.
|
|
1835
|
+
*/
|
|
1836
|
+
node(t) {
|
|
1837
|
+
const n = this.#e.index.get(t);
|
|
1838
|
+
return n === void 0 ? void 0 : this.#e.records[n];
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* One edge's fields.
|
|
1842
|
+
* @param id - The edge id.
|
|
1843
|
+
* @returns The fields, or undefined when the run produced nothing for that edge.
|
|
1844
|
+
*/
|
|
1845
|
+
edge(t) {
|
|
1846
|
+
const n = this.#t.index.get(t);
|
|
1847
|
+
return n === void 0 ? void 0 : this.#t.records[n];
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* One numeric field as a column.
|
|
1851
|
+
*
|
|
1852
|
+
* The view reads straight through to the result's own storage and its four figures were
|
|
1853
|
+
* computed on the first call, so a histogram, a colour ramp's domain and a summary all walk
|
|
1854
|
+
* one column rather than three copies of it.
|
|
1855
|
+
* @param field - The field name.
|
|
1856
|
+
* @returns A view over the values, without an object per element.
|
|
1857
|
+
* @throws A GraphtyError coded E_UNKNOWN_ATTRIBUTE when the run published no such field, or
|
|
1858
|
+
* E_BAD_COMMAND when the field is not a number published per element.
|
|
1859
|
+
*/
|
|
1860
|
+
column(t) {
|
|
1861
|
+
return this.#h(t).view;
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* The highest-ranked elements on one field.
|
|
1865
|
+
*
|
|
1866
|
+
* Elements with equal values share a rank and come back in printed-id order, so the top of a
|
|
1867
|
+
* ranking does not reshuffle between two runs that measured the same thing.
|
|
1868
|
+
* @param field - The field to rank on.
|
|
1869
|
+
* @param limit - How many entries to return; the whole ranking when absent.
|
|
1870
|
+
* @returns The entries, best first.
|
|
1871
|
+
* @throws A GraphtyError coded E_OPTION_RANGE when the limit is not a whole number of
|
|
1872
|
+
* entries, E_UNKNOWN_ATTRIBUTE when the run published no such field, or E_BAD_COMMAND when
|
|
1873
|
+
* the field is not a number published per element.
|
|
1874
|
+
*/
|
|
1875
|
+
ranking(t, n) {
|
|
1876
|
+
n !== void 0 && this.#l(n, "limit");
|
|
1877
|
+
const r = this.#a.get(t) ?? this.#f(t);
|
|
1878
|
+
return n === void 0 ? r : Object.freeze(r.slice(0, n));
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* The top `n` elements on one field, cut only between tie groups: a group of equal values is
|
|
1882
|
+
* taken whole, and only when all of it fits inside `n`. Kept per field and `n`, because a
|
|
1883
|
+
* top selector asks once per element it paints.
|
|
1884
|
+
* @param field - The field to rank on.
|
|
1885
|
+
* @param n - The most elements the top may hold.
|
|
1886
|
+
* @returns The elements taken, and the tie group left out when there was one.
|
|
1887
|
+
* @throws A GraphtyError coded E_OPTION_RANGE when n is not a whole number of entries,
|
|
1888
|
+
* E_UNKNOWN_ATTRIBUTE when the run published no such field, or E_BAD_COMMAND when the
|
|
1889
|
+
* field is not a number published per element.
|
|
1890
|
+
*/
|
|
1891
|
+
top(t, n) {
|
|
1892
|
+
const r = `${String(n)}:${t}`, i = this.#c.get(r);
|
|
1893
|
+
if (i !== void 0)
|
|
1894
|
+
return i;
|
|
1895
|
+
const s = Tt(this.ranking(t), this.#l(n, "n"));
|
|
1896
|
+
return this.#c.set(r, s), s;
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Refuse a count of entries that is not a whole number.
|
|
1900
|
+
* @param limit - The count.
|
|
1901
|
+
* @param option - What the caller called it, for the refusal.
|
|
1902
|
+
* @returns The count.
|
|
1903
|
+
* @throws A GraphtyError coded E_OPTION_RANGE when it is not a whole number of entries.
|
|
1904
|
+
*/
|
|
1905
|
+
#l(t, n) {
|
|
1906
|
+
if (!Number.isInteger(t) || t < 0)
|
|
1907
|
+
throw new y({
|
|
1908
|
+
code: "E_OPTION_RANGE",
|
|
1909
|
+
source: "run",
|
|
1910
|
+
message: `A ranking limit is a whole number of entries, not ${String(t)}.`,
|
|
1911
|
+
details: { option: n, value: t, min: 0 },
|
|
1912
|
+
target: { kind: "run", id: this.runId }
|
|
1913
|
+
});
|
|
1914
|
+
return t;
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* The distribution of one numeric field.
|
|
1918
|
+
*
|
|
1919
|
+
* Whether the field counts things is read off its own descriptor rather than passed in, so a
|
|
1920
|
+
* count metric gets whole-number band edges without the caller knowing that it should.
|
|
1921
|
+
* @param field - The field to bin.
|
|
1922
|
+
* @param options - How to cut the bins.
|
|
1923
|
+
* @returns The distribution, carrying the scale that was applied as well as the bars.
|
|
1924
|
+
* @throws A GraphtyError coded E_OPTION_RANGE when the bin count is outside the permitted
|
|
1925
|
+
* range, E_UNKNOWN_ATTRIBUTE when the run published no such field, or E_BAD_COMMAND when
|
|
1926
|
+
* the field is not a number published per element.
|
|
1927
|
+
*/
|
|
1928
|
+
histogram(t, n) {
|
|
1929
|
+
const r = this.#d(t), i = r.kind === "edge" ? this.#t : this.#e;
|
|
1930
|
+
return Pt(V(i, t), {
|
|
1931
|
+
...n,
|
|
1932
|
+
integerValued: r.type === "integer"
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* The bounded form of this result.
|
|
1937
|
+
*
|
|
1938
|
+
* Everything on it is either a single figure or a list the element cut to a fixed length, so
|
|
1939
|
+
* the object is the same size for a graph of a hundred nodes and a graph of a million.
|
|
1940
|
+
* @returns The summary.
|
|
1941
|
+
*/
|
|
1942
|
+
summary() {
|
|
1943
|
+
return this.#u ??= this.#g(), this.#u;
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* What this result means, in one sentence of plain language.
|
|
1947
|
+
* @param options - The locale and how technical to be.
|
|
1948
|
+
* @returns The sentence.
|
|
1949
|
+
*/
|
|
1950
|
+
reading(t) {
|
|
1951
|
+
return this.#s(this, t ?? {});
|
|
1952
|
+
}
|
|
1953
|
+
/**
|
|
1954
|
+
* The descriptor of one numeric per-element field, without complaining when there is none.
|
|
1955
|
+
*
|
|
1956
|
+
* A summary asks this rather than {@link Result.#descriptorFor} because a summary must not
|
|
1957
|
+
* throw: a run whose field list does not declare the field its shape calls primary is a
|
|
1958
|
+
* defect in that run, and the summary's job is to say what it can about the result rather
|
|
1959
|
+
* than to refuse to describe it at all.
|
|
1960
|
+
* @param field - The field name.
|
|
1961
|
+
* @returns Its descriptor, or null when the run published no numeric field under that name.
|
|
1962
|
+
*/
|
|
1963
|
+
#m(t) {
|
|
1964
|
+
const n = this.fields.find((r) => r.name === t && r.kind !== "graph");
|
|
1965
|
+
return n !== void 0 && P(n) ? n : null;
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* The descriptor of one numeric field the run published per element.
|
|
1969
|
+
* @param field - The field name.
|
|
1970
|
+
* @returns Its descriptor.
|
|
1971
|
+
* @throws A GraphtyError naming what went wrong, with the readable fields in its details.
|
|
1972
|
+
*/
|
|
1973
|
+
#d(t) {
|
|
1974
|
+
const n = this.fields.filter((s) => s.name === t), r = n.find((s) => s.kind !== "graph"), i = this.fields.filter((s) => s.kind !== "graph" && P(s)).map((s) => s.name);
|
|
1975
|
+
if (r === void 0)
|
|
1976
|
+
throw n.length > 0 ? new y({
|
|
1977
|
+
code: "E_BAD_COMMAND",
|
|
1978
|
+
source: "run",
|
|
1979
|
+
message: `"${t}" is a graph-level field of run "${this.runId}"; read it from result.graph.`,
|
|
1980
|
+
details: { field: t, kind: "graph", available: i },
|
|
1981
|
+
target: { kind: "run", id: this.runId }
|
|
1982
|
+
}) : new y({
|
|
1983
|
+
code: "E_UNKNOWN_ATTRIBUTE",
|
|
1984
|
+
source: "run",
|
|
1985
|
+
message: `Run "${this.runId}" published no field named "${t}".`,
|
|
1986
|
+
details: { field: t, available: i, candidates: kt(t, i) },
|
|
1987
|
+
target: { kind: "run", id: this.runId }
|
|
1988
|
+
});
|
|
1989
|
+
if (!P(r))
|
|
1990
|
+
throw new y({
|
|
1991
|
+
code: "E_BAD_COMMAND",
|
|
1992
|
+
source: "run",
|
|
1993
|
+
message: `"${t}" is typed "${r.type}", which is not a column of numbers.`,
|
|
1994
|
+
details: { field: t, type: r.type, available: i },
|
|
1995
|
+
target: { kind: "run", id: this.runId }
|
|
1996
|
+
});
|
|
1997
|
+
return r;
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* The half of the result a per-element field belongs to.
|
|
2001
|
+
* @param field - The field name.
|
|
2002
|
+
* @returns The nodes or the edges.
|
|
2003
|
+
* @throws A GraphtyError naming what went wrong.
|
|
2004
|
+
*/
|
|
2005
|
+
#p(t) {
|
|
2006
|
+
return this.#d(t).kind === "edge" ? this.#t : this.#e;
|
|
2007
|
+
}
|
|
2008
|
+
/**
|
|
2009
|
+
* One field's column and statistics, computed on the first ask and kept.
|
|
2010
|
+
* @param field - The field name.
|
|
2011
|
+
* @returns The view and the statistics behind it.
|
|
2012
|
+
* @throws A GraphtyError naming what went wrong.
|
|
2013
|
+
*/
|
|
2014
|
+
#h(t) {
|
|
2015
|
+
const n = this.#o.get(t);
|
|
2016
|
+
if (n !== void 0)
|
|
2017
|
+
return n;
|
|
2018
|
+
const r = Oe(V(this.#p(t), t));
|
|
2019
|
+
return this.#o.set(t, r), r;
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Rank one field for the first time and keep the answer.
|
|
2023
|
+
* @param field - The field to rank on.
|
|
2024
|
+
* @returns The whole ranking, best first.
|
|
2025
|
+
* @throws A GraphtyError naming what went wrong.
|
|
2026
|
+
*/
|
|
2027
|
+
#f(t) {
|
|
2028
|
+
const n = J(Y(this.#p(t), t));
|
|
2029
|
+
return this.#a.set(t, n), n;
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Build the bounded form of this result.
|
|
2033
|
+
* @returns The summary.
|
|
2034
|
+
*/
|
|
2035
|
+
#g() {
|
|
2036
|
+
const t = Bt(this.shape), n = t === null || this.#m(t) === null ? null : t, r = n === null ? null : this.#h(n).statistics, i = r !== null && r.measured > 0 ? r : null, s = n === null ? [] : this.ranking(n, Lt).map(
|
|
2037
|
+
(c) => Object.freeze({
|
|
2038
|
+
id: c.id,
|
|
2039
|
+
label: this.#i(c.id) ?? String(c.id),
|
|
2040
|
+
value: c.value,
|
|
2041
|
+
rank: c.rank,
|
|
2042
|
+
percentile: c.percentile
|
|
2043
|
+
})
|
|
2044
|
+
), o = {
|
|
2045
|
+
count: this.#y(),
|
|
2046
|
+
measured: r === null ? this.#b() : r.measured,
|
|
2047
|
+
min: i === null ? null : i.min,
|
|
2048
|
+
max: i === null ? null : i.max,
|
|
2049
|
+
median: i === null ? null : i.median,
|
|
2050
|
+
mean: i === null ? null : i.mean,
|
|
2051
|
+
tiedAtMin: r === null ? 0 : r.tiedAtMin,
|
|
2052
|
+
normalization: this.#w(n),
|
|
2053
|
+
top: Object.freeze(s),
|
|
2054
|
+
caveats: this.#n,
|
|
2055
|
+
durationMs: this.#r
|
|
2056
|
+
}, a = this.graph.sizes ?? this.graph.categories, u = Vt(a, Dt);
|
|
2057
|
+
return Object.freeze(u === void 0 ? o : { ...o, groups: u });
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* How many elements this result was computed over.
|
|
2061
|
+
*
|
|
2062
|
+
* A shape publishes per-element fields for nodes, for edges or for neither, and the scope a
|
|
2063
|
+
* summary reports is the half or halves it actually measures. A shape that publishes nothing
|
|
2064
|
+
* per element reports none, rather than borrowing the graph's size to look busy.
|
|
2065
|
+
* @returns The count.
|
|
2066
|
+
*/
|
|
2067
|
+
#y() {
|
|
2068
|
+
const t = B(this.shape), n = t.nodeFields.length > 0 ? this.measured.nodes : 0, r = t.edgeFields.length > 0 ? this.measured.edges : 0;
|
|
2069
|
+
return n + r;
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* How many elements carry the shape's primary field, for a shape that measures no number.
|
|
2073
|
+
* @returns The count.
|
|
2074
|
+
*/
|
|
2075
|
+
#b() {
|
|
2076
|
+
const t = B(this.shape), { primaryField: n } = t;
|
|
2077
|
+
if (n === null)
|
|
2078
|
+
return 0;
|
|
2079
|
+
const r = t.nodeFields.includes(n) ? ue(this.#e, n) : 0, i = t.edgeFields.includes(n) ? ue(this.#t, n) : 0;
|
|
2080
|
+
return r + i;
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* How this result's values were scaled.
|
|
2084
|
+
* @param valueField - The field a summary describes, or null when the shape measures no
|
|
2085
|
+
* number.
|
|
2086
|
+
* @returns The normalisation the run published, the one its field declares, or "none".
|
|
2087
|
+
*/
|
|
2088
|
+
#w(t) {
|
|
2089
|
+
const n = this.graph.normalization;
|
|
2090
|
+
return we(n) ? n : t === null ? "none" : Ae(this.fields, t);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
function Jt(e) {
|
|
2094
|
+
const t = oe(e.nodes), n = oe(e.edges), r = { ...e.graph };
|
|
2095
|
+
Ht(e.shape, t, n, r, e.fields);
|
|
2096
|
+
for (const i of t.records)
|
|
2097
|
+
Object.freeze(i);
|
|
2098
|
+
for (const i of n.records)
|
|
2099
|
+
Object.freeze(i);
|
|
2100
|
+
return new qt(e, t, n, Object.freeze(r));
|
|
2101
|
+
}
|
|
2102
|
+
function Yt(e) {
|
|
2103
|
+
const t = e.styles?.config.data.knownFields.nodeLabelPath ?? null;
|
|
2104
|
+
if (t === null)
|
|
2105
|
+
return;
|
|
2106
|
+
const n = e.getDataManager();
|
|
2107
|
+
return (r) => {
|
|
2108
|
+
const i = n.getNode(r)?.data[t];
|
|
2109
|
+
return typeof i == "string" || typeof i == "number" ? String(i) : void 0;
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
function Bn(e) {
|
|
2113
|
+
return { exact: !0, precision: "f64", notes: [], ...e };
|
|
2114
|
+
}
|
|
2115
|
+
const Wt = 1024, Kt = 16;
|
|
2116
|
+
function Zt() {
|
|
2117
|
+
return {
|
|
2118
|
+
signal: new AbortController().signal,
|
|
2119
|
+
report: () => {
|
|
2120
|
+
},
|
|
2121
|
+
yieldNow: () => new Promise((e) => {
|
|
2122
|
+
setTimeout(e, 0);
|
|
2123
|
+
})
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
async function Vn(e, t, n, r) {
|
|
2127
|
+
const i = n.length;
|
|
2128
|
+
e.report({ phase: t, completed: 0, total: i });
|
|
2129
|
+
let s = performance.now();
|
|
2130
|
+
for (let o = 0; o < i; o++)
|
|
2131
|
+
o > 0 && o % Wt === 0 && (e.signal.throwIfAborted(), e.report({ phase: t, completed: o, total: i }), performance.now() - s >= Kt && (await e.yieldNow(), s = performance.now())), r(n[o], o);
|
|
2132
|
+
e.signal.throwIfAborted(), e.report({ phase: t, completed: i, total: i });
|
|
2133
|
+
}
|
|
2134
|
+
function Xt(e, t, n) {
|
|
2135
|
+
const r = n?.find((s) => s.name === e.name && s.kind === e.kind), i = {
|
|
2136
|
+
name: e.name,
|
|
2137
|
+
plainName: r?.plainName ?? e.name,
|
|
2138
|
+
technicalName: r?.technicalName ?? e.name,
|
|
2139
|
+
kind: e.kind,
|
|
2140
|
+
type: e.type,
|
|
2141
|
+
path: T(t, e.name),
|
|
2142
|
+
...r?.unit === void 0 ? {} : { unit: r.unit }
|
|
2143
|
+
};
|
|
2144
|
+
return e.normalization === void 0 ? i : { ...i, normalization: e.normalization };
|
|
2145
|
+
}
|
|
2146
|
+
class qn extends D {
|
|
2147
|
+
/** What the last run published, kept so a caller holding the algorithm can read the result. */
|
|
2148
|
+
#e;
|
|
2149
|
+
/**
|
|
2150
|
+
* Fill in what the caller did not pass, and refuse what this algorithm does not declare.
|
|
2151
|
+
*
|
|
2152
|
+
* ONE DECLARATION, NOT TWO. `descriptor.options` is the only list a declared algorithm
|
|
2153
|
+
* writes, and this is what makes that true at the point the values reach the running code:
|
|
2154
|
+
* the same descriptors the catalogue hands a picker are what the caller's values are checked
|
|
2155
|
+
* against. The older `static optionsSchema` remains the answer for a class that declares no
|
|
2156
|
+
* descriptor, which is every algorithm the element itself ships.
|
|
2157
|
+
*
|
|
2158
|
+
* It also fixes the failure vocabulary on the way in. The older schema throws an uncoded
|
|
2159
|
+
* `Error` for a bad value and SILENTLY DROPS a name it does not know, where the run path
|
|
2160
|
+
* refuses the same name with `E_UNKNOWN_OPTION` -- so the same mistake produced three
|
|
2161
|
+
* different outcomes depending on which door the caller came through.
|
|
2162
|
+
* @param options - What the caller asked for.
|
|
2163
|
+
* @returns Every declared option, with the caller's values where they were given and the
|
|
2164
|
+
* declared defaults everywhere else.
|
|
2165
|
+
* @throws A `GraphtyError` with `E_UNKNOWN_OPTION` for a name this algorithm does not
|
|
2166
|
+
* declare, or `E_OPTION_RANGE` for a value it would not accept.
|
|
2167
|
+
*/
|
|
2168
|
+
resolveOptions(t) {
|
|
2169
|
+
const { descriptor: n } = this.constructor;
|
|
2170
|
+
return n === void 0 ? super.resolveOptions(t) : Ie(n.options, t ?? {}, {
|
|
2171
|
+
kind: "algorithm",
|
|
2172
|
+
id: n.key
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* What the last run published.
|
|
2177
|
+
*
|
|
2178
|
+
* THE REPLACEMENT FOR `algorithmResults`. The 1.x entry point used to scatter its numbers onto
|
|
2179
|
+
* the render objects under names it chose for itself, and the only way back to them was to
|
|
2180
|
+
* walk the graph. It returns a result object now, and this is where the 1.x `run()` leaves it,
|
|
2181
|
+
* so the old call shape still has somewhere to read from.
|
|
2182
|
+
* @returns The result, or undefined when nothing has run or there was nothing to compute.
|
|
2183
|
+
*/
|
|
2184
|
+
get result() {
|
|
2185
|
+
return this.#e;
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Run the algorithm and publish what it produced on the 1.x result paths.
|
|
2189
|
+
*
|
|
2190
|
+
* The 1.x entry point: it returns nothing, and it publishes under the algorithm's own type
|
|
2191
|
+
* rather than under a run id, because there is no run behind it. Whoever wants the result
|
|
2192
|
+
* calls {@link DeclaredAlgorithm.computeRun}, which is the same work with a run in front of
|
|
2193
|
+
* it.
|
|
2194
|
+
* @returns A promise that settles when the result has been published.
|
|
2195
|
+
*/
|
|
2196
|
+
async run() {
|
|
2197
|
+
await this.computeRun(Zt(), this.type);
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Compute on behalf of a run, and hand the result back.
|
|
2201
|
+
*
|
|
2202
|
+
* The run machinery's entry point, which is {@link DeclaredAlgorithm.computeRun} under the
|
|
2203
|
+
* name every algorithm answers to.
|
|
2204
|
+
* @param context - A signal, a progress channel and a yield.
|
|
2205
|
+
* @param runId - The id the result is published under.
|
|
2206
|
+
* @param fields - The catalogue's descriptors for this algorithm's fields.
|
|
2207
|
+
* @returns The result, or undefined when there was nothing to compute.
|
|
2208
|
+
* @throws Whatever the context's signal throws once the run has been cancelled.
|
|
2209
|
+
*/
|
|
2210
|
+
publishResult(t, n, r) {
|
|
2211
|
+
return this.computeRun(t, n, r);
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Compute this algorithm's result, publish it under a run id, and project the 1.x view of it.
|
|
2215
|
+
*
|
|
2216
|
+
* This is what the run executor calls. The catalogue's own field descriptors are passed in
|
|
2217
|
+
* because the catalogue states what a reader sees a field called and cannot be imported here
|
|
2218
|
+
* without a cycle -- it reads these classes to publish their options.
|
|
2219
|
+
* @param context - What the element gave the run: a signal, a progress channel and a yield.
|
|
2220
|
+
* @param runId - The id the result is published under, which is the `<runId>` in
|
|
2221
|
+
* `results.<runId>`.
|
|
2222
|
+
* @param declared - The catalogue's descriptors for this algorithm's fields, when the caller
|
|
2223
|
+
* holds them.
|
|
2224
|
+
* @returns The result, or undefined when there was nothing to compute.
|
|
2225
|
+
* @throws Whatever the context's signal throws once the run has been cancelled, which is a
|
|
2226
|
+
* `DOMException` named `AbortError`.
|
|
2227
|
+
*/
|
|
2228
|
+
async computeRun(t, n, r) {
|
|
2229
|
+
const i = Date.now(), s = await this.compute(t);
|
|
2230
|
+
if (s === null)
|
|
2231
|
+
return;
|
|
2232
|
+
const o = this.graph.getDataManager(), a = Yt(this.graph), u = Jt({
|
|
2233
|
+
...a === void 0 ? {} : { labelOf: a },
|
|
2234
|
+
runId: n,
|
|
2235
|
+
shape: s.shape,
|
|
2236
|
+
fields: s.fields.map((c) => Xt(c, n, r)),
|
|
2237
|
+
measured: { nodes: o.nodes.size, edges: o.edges.size },
|
|
2238
|
+
graph: s.graph,
|
|
2239
|
+
nodes: s.nodes,
|
|
2240
|
+
edges: s.edges,
|
|
2241
|
+
caveats: s.caveats,
|
|
2242
|
+
durationMs: Date.now() - i
|
|
2243
|
+
});
|
|
2244
|
+
return this.#e = u, u;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
function Jn(e, t = "number") {
|
|
2248
|
+
return [
|
|
2249
|
+
{ name: "value", kind: e, type: t },
|
|
2250
|
+
{ name: "rank", kind: e, type: "integer" },
|
|
2251
|
+
{ name: "percentile", kind: e, type: "number" },
|
|
2252
|
+
{ name: "min", kind: "graph", type: "number" },
|
|
2253
|
+
{ name: "max", kind: "graph", type: "number" },
|
|
2254
|
+
{ name: "median", kind: "graph", type: "number" },
|
|
2255
|
+
{ name: "mean", kind: "graph", type: "number" },
|
|
2256
|
+
{ name: "measured", kind: "graph", type: "integer" },
|
|
2257
|
+
{ name: "normalization", kind: "graph", type: "string" },
|
|
2258
|
+
{ name: "tiedAtMin", kind: "graph", type: "integer" }
|
|
2259
|
+
];
|
|
2260
|
+
}
|
|
2261
|
+
const le = [
|
|
2262
|
+
{ name: "group", kind: "node", type: "integer" },
|
|
2263
|
+
{ name: "groupSize", kind: "node", type: "integer" },
|
|
2264
|
+
{ name: "groupCount", kind: "graph", type: "integer" },
|
|
2265
|
+
{ name: "sizes", kind: "graph", type: "table" }
|
|
2266
|
+
];
|
|
2267
|
+
function Yn(e) {
|
|
2268
|
+
return e ? [...le, { name: "modularity", kind: "graph", type: "number" }] : le;
|
|
2269
|
+
}
|
|
2270
|
+
const Wn = [
|
|
2271
|
+
{ name: "level", kind: "node", type: "integer" },
|
|
2272
|
+
{ name: "levelSize", kind: "node", type: "integer" },
|
|
2273
|
+
{ name: "levelCount", kind: "graph", type: "integer" },
|
|
2274
|
+
{ name: "sizes", kind: "graph", type: "table" }
|
|
2275
|
+
], Kn = [
|
|
2276
|
+
{ name: "onPath", kind: "node", type: "boolean" },
|
|
2277
|
+
{ name: "order", kind: "node", type: "integer" },
|
|
2278
|
+
{ name: "onPath", kind: "edge", type: "boolean" },
|
|
2279
|
+
{ name: "length", kind: "graph", type: "integer" },
|
|
2280
|
+
{ name: "cost", kind: "graph", type: "number" },
|
|
2281
|
+
{ name: "hops", kind: "graph", type: "integer" }
|
|
2282
|
+
];
|
|
2283
|
+
function Zn(e, t) {
|
|
2284
|
+
return [
|
|
2285
|
+
{ name: "in", kind: e, type: "boolean" },
|
|
2286
|
+
{ name: "count", kind: "graph", type: "integer" },
|
|
2287
|
+
{ ...t, kind: "graph" }
|
|
2288
|
+
];
|
|
2289
|
+
}
|
|
2290
|
+
const Qt = `${H}.${bt}`;
|
|
2291
|
+
function O(e) {
|
|
2292
|
+
return { ...e, path: `${Qt}.${e.name}` };
|
|
2293
|
+
}
|
|
2294
|
+
function Xn(e) {
|
|
2295
|
+
return [
|
|
2296
|
+
O({
|
|
2297
|
+
name: "value",
|
|
2298
|
+
plainName: e.plainName,
|
|
2299
|
+
technicalName: e.technicalName,
|
|
2300
|
+
kind: "node",
|
|
2301
|
+
type: e.type ?? "number",
|
|
2302
|
+
...e.unit === void 0 ? {} : { unit: e.unit }
|
|
2303
|
+
}),
|
|
2304
|
+
O({ name: "rank", plainName: "Rank", technicalName: "rank", kind: "node", type: "integer" }),
|
|
2305
|
+
O({
|
|
2306
|
+
name: "percentile",
|
|
2307
|
+
plainName: "Percentile",
|
|
2308
|
+
technicalName: "percentile",
|
|
2309
|
+
kind: "node",
|
|
2310
|
+
type: "number"
|
|
2311
|
+
}),
|
|
2312
|
+
O({ name: "min", plainName: "Lowest", technicalName: "min", kind: "graph", type: "number" }),
|
|
2313
|
+
O({ name: "max", plainName: "Highest", technicalName: "max", kind: "graph", type: "number" }),
|
|
2314
|
+
O({ name: "median", plainName: "Middle", technicalName: "median", kind: "graph", type: "number" }),
|
|
2315
|
+
O({ name: "mean", plainName: "Average", technicalName: "mean", kind: "graph", type: "number" }),
|
|
2316
|
+
O({
|
|
2317
|
+
name: "measured",
|
|
2318
|
+
plainName: "Measured",
|
|
2319
|
+
technicalName: "measured",
|
|
2320
|
+
kind: "graph",
|
|
2321
|
+
type: "integer"
|
|
2322
|
+
}),
|
|
2323
|
+
O({
|
|
2324
|
+
name: "normalization",
|
|
2325
|
+
plainName: "Normalization",
|
|
2326
|
+
technicalName: "normalization",
|
|
2327
|
+
kind: "graph",
|
|
2328
|
+
type: "string"
|
|
2329
|
+
}),
|
|
2330
|
+
O({
|
|
2331
|
+
name: "tiedAtMin",
|
|
2332
|
+
plainName: "Tied at the lowest value",
|
|
2333
|
+
technicalName: "tiedAtMin",
|
|
2334
|
+
kind: "graph",
|
|
2335
|
+
type: "integer"
|
|
2336
|
+
})
|
|
2337
|
+
];
|
|
2338
|
+
}
|
|
2339
|
+
const en = 12;
|
|
2340
|
+
function Qn(e, t = {}) {
|
|
2341
|
+
return (tn(e) ? nn(e) : rn(e)).map((r) => {
|
|
2342
|
+
const i = { ...r.meta, ...t.meta?.[r.name] }, s = r.node === null ? an(r.name, i, r.failure ?? "the schema could not be converted") : on(r.name, r.node, i), o = t.overrides?.[r.name];
|
|
2343
|
+
return o === void 0 ? s : { ...s, ...o };
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
function tn(e) {
|
|
2347
|
+
return typeof e != "object" || e === null ? !1 : "_zod" in e || "_def" in e;
|
|
2348
|
+
}
|
|
2349
|
+
function nn(e) {
|
|
2350
|
+
const t = $e(e);
|
|
2351
|
+
if (t === null)
|
|
2352
|
+
return [];
|
|
2353
|
+
const { properties: n } = t;
|
|
2354
|
+
return n === void 0 ? [] : Object.entries(n).map(([r, i]) => ({ name: r, node: Re(i, t) }));
|
|
2355
|
+
}
|
|
2356
|
+
function rn(e) {
|
|
2357
|
+
const t = Object.entries(e), n = {};
|
|
2358
|
+
for (const [s, o] of t)
|
|
2359
|
+
n[s] = o.schema;
|
|
2360
|
+
const r = sn(n), i = r?.properties;
|
|
2361
|
+
return t.map(([s, o]) => {
|
|
2362
|
+
const a = i?.[s];
|
|
2363
|
+
return r === null || a === void 0 ? {
|
|
2364
|
+
name: s,
|
|
2365
|
+
node: null,
|
|
2366
|
+
failure: "the schema could not be converted to JSON Schema",
|
|
2367
|
+
meta: o.meta
|
|
2368
|
+
} : { name: s, node: Re(a, r), meta: o.meta };
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
function $e(e) {
|
|
2372
|
+
try {
|
|
2373
|
+
return me.toJSONSchema(e, { io: "input", unrepresentable: "any" });
|
|
2374
|
+
} catch {
|
|
2375
|
+
return null;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
function sn(e) {
|
|
2379
|
+
try {
|
|
2380
|
+
return $e(me.object(e));
|
|
2381
|
+
} catch {
|
|
2382
|
+
return null;
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
const de = "#/$defs/";
|
|
2386
|
+
function Re(e, t) {
|
|
2387
|
+
const n = e.$ref;
|
|
2388
|
+
if (n === void 0 || !n.startsWith(de))
|
|
2389
|
+
return e;
|
|
2390
|
+
const r = n.slice(de.length).replaceAll("~1", "/").replaceAll("~0", "~");
|
|
2391
|
+
return t.$defs?.[r] ?? e;
|
|
2392
|
+
}
|
|
2393
|
+
function on(e, t, n) {
|
|
2394
|
+
const r = Ee(t, 0), i = cn(r), s = {
|
|
2395
|
+
name: e,
|
|
2396
|
+
plainName: n.label ?? K(e),
|
|
2397
|
+
technicalName: e,
|
|
2398
|
+
type: i.type
|
|
2399
|
+
}, o = n.description ?? t.description ?? i.node?.description;
|
|
2400
|
+
o !== void 0 && (s.description = o), "default" in t && (s.default = t.default);
|
|
2401
|
+
const a = i.node;
|
|
2402
|
+
if (a !== void 0 && (i.type === "number" || i.type === "integer")) {
|
|
2403
|
+
const c = pe(a.minimum ?? a.exclusiveMinimum), h = pe(a.maximum ?? a.exclusiveMaximum);
|
|
2404
|
+
c !== void 0 && (s.min = c), h !== void 0 && (s.max = h);
|
|
2405
|
+
}
|
|
2406
|
+
const u = n.step ?? a?.multipleOf;
|
|
2407
|
+
return u !== void 0 && (s.step = u), i.values !== void 0 && (s.values = i.values), n.group !== void 0 && (s.group = n.group), n.advanced !== void 0 && (s.advanced = n.advanced), i.unsupportedReason !== void 0 && (s.unsupportedReason = i.unsupportedReason), s;
|
|
2408
|
+
}
|
|
2409
|
+
function an(e, t, n) {
|
|
2410
|
+
const r = {
|
|
2411
|
+
name: e,
|
|
2412
|
+
plainName: t.label ?? K(e),
|
|
2413
|
+
technicalName: e,
|
|
2414
|
+
type: "unknown",
|
|
2415
|
+
unsupportedReason: n
|
|
2416
|
+
};
|
|
2417
|
+
return t.description !== void 0 && (r.description = t.description), t.step !== void 0 && (r.step = t.step), t.group !== void 0 && (r.group = t.group), t.advanced !== void 0 && (r.advanced = t.advanced), r;
|
|
2418
|
+
}
|
|
2419
|
+
function Ee(e, t) {
|
|
2420
|
+
if (t >= en)
|
|
2421
|
+
return { arms: [], nullable: !1, unresolvedRef: !0 };
|
|
2422
|
+
if (e.$ref !== void 0)
|
|
2423
|
+
return { arms: [], nullable: !1, unresolvedRef: !0 };
|
|
2424
|
+
const n = e.anyOf ?? e.oneOf;
|
|
2425
|
+
if (n === void 0)
|
|
2426
|
+
return e.type === "null" ? { arms: [], nullable: !0, unresolvedRef: !1 } : { arms: [e], nullable: !1, unresolvedRef: !1 };
|
|
2427
|
+
const r = { arms: [], nullable: !1, unresolvedRef: !1 };
|
|
2428
|
+
for (const i of n) {
|
|
2429
|
+
const s = Ee(i, t + 1);
|
|
2430
|
+
r.arms.push(...s.arms), r.nullable = r.nullable || s.nullable, r.unresolvedRef = r.unresolvedRef || s.unresolvedRef;
|
|
2431
|
+
}
|
|
2432
|
+
return r;
|
|
2433
|
+
}
|
|
2434
|
+
function cn(e) {
|
|
2435
|
+
if (e.arms.length === 0)
|
|
2436
|
+
return e.unresolvedRef ? {
|
|
2437
|
+
type: "unknown",
|
|
2438
|
+
unsupportedReason: "the schema is recursive, so it has no single value type"
|
|
2439
|
+
} : {
|
|
2440
|
+
type: "unknown",
|
|
2441
|
+
unsupportedReason: e.nullable ? "the only value the schema accepts is null" : "the schema declares no value type"
|
|
2442
|
+
};
|
|
2443
|
+
const t = ln(e.arms);
|
|
2444
|
+
if (t !== void 0)
|
|
2445
|
+
return { type: "enum", node: e.arms[0], values: t };
|
|
2446
|
+
if (e.arms.length === 1)
|
|
2447
|
+
return un(e.arms[0]);
|
|
2448
|
+
const n = e.arms.map((r) => Fe(r));
|
|
2449
|
+
return n.length === 2 && n.includes("string") && n.includes("number") ? { type: "node-id" } : {
|
|
2450
|
+
type: "unknown",
|
|
2451
|
+
unsupportedReason: `the schema is a union of ${n.join(" and ")}, which has no single control`
|
|
2452
|
+
};
|
|
2453
|
+
}
|
|
2454
|
+
function un(e) {
|
|
2455
|
+
switch (Fe(e)) {
|
|
2456
|
+
case "integer":
|
|
2457
|
+
return { type: "integer", node: e };
|
|
2458
|
+
case "number":
|
|
2459
|
+
return { type: "number", node: e };
|
|
2460
|
+
case "boolean":
|
|
2461
|
+
return { type: "boolean", node: e };
|
|
2462
|
+
case "string":
|
|
2463
|
+
return { type: "string", node: e };
|
|
2464
|
+
case "array":
|
|
2465
|
+
return {
|
|
2466
|
+
type: "unknown",
|
|
2467
|
+
node: e,
|
|
2468
|
+
unsupportedReason: "an array option has no descriptor type; give it one with an override"
|
|
2469
|
+
};
|
|
2470
|
+
case "object":
|
|
2471
|
+
return {
|
|
2472
|
+
type: "unknown",
|
|
2473
|
+
node: e,
|
|
2474
|
+
unsupportedReason: "an object or record option has no descriptor type; give it one with an override"
|
|
2475
|
+
};
|
|
2476
|
+
default:
|
|
2477
|
+
return {
|
|
2478
|
+
type: "unknown",
|
|
2479
|
+
node: e,
|
|
2480
|
+
unsupportedReason: "the Zod construct has no JSON Schema type, so its values cannot be classified"
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
function ln(e) {
|
|
2485
|
+
const t = [];
|
|
2486
|
+
for (const r of e)
|
|
2487
|
+
if (r.enum !== void 0)
|
|
2488
|
+
t.push(...r.enum);
|
|
2489
|
+
else if ("const" in r)
|
|
2490
|
+
t.push(r.const);
|
|
2491
|
+
else
|
|
2492
|
+
return;
|
|
2493
|
+
if (t.length === 0)
|
|
2494
|
+
return;
|
|
2495
|
+
const n = [];
|
|
2496
|
+
for (const r of t) {
|
|
2497
|
+
if (typeof r != "string" && typeof r != "number" && typeof r != "boolean")
|
|
2498
|
+
return;
|
|
2499
|
+
const i = String(r);
|
|
2500
|
+
n.push({ value: i, label: K(i) });
|
|
2501
|
+
}
|
|
2502
|
+
return n;
|
|
2503
|
+
}
|
|
2504
|
+
function Fe(e) {
|
|
2505
|
+
const { type: t } = e;
|
|
2506
|
+
return typeof t == "string" ? t : Array.isArray(t) && t.length > 0 ? t[0] : "none";
|
|
2507
|
+
}
|
|
2508
|
+
function pe(e) {
|
|
2509
|
+
if (!(e === Number.MAX_SAFE_INTEGER || e === -Number.MAX_SAFE_INTEGER))
|
|
2510
|
+
return e;
|
|
2511
|
+
}
|
|
2512
|
+
function K(e) {
|
|
2513
|
+
const t = e.replace(/([a-z0-9])([A-Z])/gu, "$1 $2").replace(/[_-]+/gu, " ").trim();
|
|
2514
|
+
return t === "" ? e : t.split(/\s+/u).map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
|
|
2515
|
+
}
|
|
2516
|
+
export {
|
|
2517
|
+
Un as $,
|
|
2518
|
+
D as A,
|
|
2519
|
+
In as B,
|
|
2520
|
+
Pe as C,
|
|
2521
|
+
Sn as D,
|
|
2522
|
+
On as E,
|
|
2523
|
+
wn as F,
|
|
2524
|
+
Yt as G,
|
|
2525
|
+
Jt as H,
|
|
2526
|
+
$n as I,
|
|
2527
|
+
An as J,
|
|
2528
|
+
En as K,
|
|
2529
|
+
Wn as L,
|
|
2530
|
+
Rn as M,
|
|
2531
|
+
ve as N,
|
|
2532
|
+
b as O,
|
|
2533
|
+
Kn as P,
|
|
2534
|
+
Hn as Q,
|
|
2535
|
+
Ln as R,
|
|
2536
|
+
Pn as S,
|
|
2537
|
+
zn as T,
|
|
2538
|
+
B as U,
|
|
2539
|
+
kt as V,
|
|
2540
|
+
jn as W,
|
|
2541
|
+
xn as X,
|
|
2542
|
+
Kt as Y,
|
|
2543
|
+
Cn as Z,
|
|
2544
|
+
Dn as _,
|
|
2545
|
+
qn as a,
|
|
2546
|
+
_n as a0,
|
|
2547
|
+
Tn as b,
|
|
2548
|
+
Gn as c,
|
|
2549
|
+
vn as d,
|
|
2550
|
+
Yn as e,
|
|
2551
|
+
Bn as f,
|
|
2552
|
+
Mn as g,
|
|
2553
|
+
Vn as h,
|
|
2554
|
+
Jn as i,
|
|
2555
|
+
Fn as j,
|
|
2556
|
+
bn as k,
|
|
2557
|
+
Ue as l,
|
|
2558
|
+
O as m,
|
|
2559
|
+
Xn as n,
|
|
2560
|
+
Qn as o,
|
|
2561
|
+
je as p,
|
|
2562
|
+
kn as q,
|
|
2563
|
+
yn as r,
|
|
2564
|
+
Zn as s,
|
|
2565
|
+
H as t,
|
|
2566
|
+
q as u,
|
|
2567
|
+
De as v,
|
|
2568
|
+
tt as w,
|
|
2569
|
+
Nn as x,
|
|
2570
|
+
gt as y,
|
|
2571
|
+
T as z
|
|
2572
|
+
};
|