@pipelex/mthds-ui 0.59.0 → 0.60.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.
Files changed (50) hide show
  1. package/dist/{chunk-S4UMMHLE.js → chunk-43NAVRQK.js} +17 -2
  2. package/dist/chunk-43NAVRQK.js.map +1 -0
  3. package/dist/{chunk-6KWNAU4F.js → chunk-BQZ3BPJM.js} +13 -1
  4. package/dist/chunk-BQZ3BPJM.js.map +1 -0
  5. package/dist/{chunk-XMTXWXFO.js → chunk-KKT6OVO6.js} +3 -3
  6. package/dist/{chunk-5N3MP5TD.js → chunk-PWKNMKFA.js} +106 -35
  7. package/dist/chunk-PWKNMKFA.js.map +1 -0
  8. package/dist/{chunk-ZRSFFUHA.js → chunk-S36KN6CG.js} +3 -3
  9. package/dist/chunk-UVEGKTBU.js +600 -0
  10. package/dist/chunk-UVEGKTBU.js.map +1 -0
  11. package/dist/{chunk-7QUQJW6Q.js → chunk-YQJNKQWO.js} +91 -285
  12. package/dist/chunk-YQJNKQWO.js.map +1 -0
  13. package/dist/form/react/index.d.ts +1 -1
  14. package/dist/form/react/index.js +2 -2
  15. package/dist/graph/index.d.ts +48 -21
  16. package/dist/graph/index.js +61 -21
  17. package/dist/graph/react/detail/DetailPanel.css +49 -0
  18. package/dist/graph/react/graph-core.css +20 -0
  19. package/dist/graph/react/index.d.ts +2 -2
  20. package/dist/graph/react/index.js +92 -29
  21. package/dist/graph/react/index.js.map +1 -1
  22. package/dist/graph/react/styles/simple/SimpleDetailPanel.css +20 -0
  23. package/dist/graph/react/styles/simple/SimpleStyle.css +13 -0
  24. package/dist/index.d.ts +3 -2
  25. package/dist/index.js +61 -21
  26. package/dist/methodWords-DIEg1PVT.d.ts +180 -0
  27. package/dist/{registryJoin-CMfBspIs.d.ts → registryJoin-Cj1mIkqe.d.ts} +18 -10
  28. package/dist/standalone/graph-standalone.html +232 -130
  29. package/dist/standalone/graph-viewer.css +102 -0
  30. package/dist/standalone/graph-viewer.js +130 -130
  31. package/dist/static-graph/index.d.ts +1 -1
  32. package/dist/static-graph/index.js +33 -12
  33. package/dist/static-graph/index.js.map +1 -1
  34. package/dist/timeline/index.d.ts +42 -7
  35. package/dist/timeline/index.js +8 -3
  36. package/dist/timeline/react/RunTimeline.css +18 -0
  37. package/dist/timeline/react/index.d.ts +3 -2
  38. package/dist/timeline/react/index.js +20 -11
  39. package/dist/timeline/react/index.js.map +1 -1
  40. package/dist/timeline/react/styles/simple/SimpleProgress.css +25 -0
  41. package/dist/{types-CnDJyLYo.d.ts → types-BygAt1Si.d.ts} +51 -1
  42. package/package.json +2 -2
  43. package/dist/chunk-5N3MP5TD.js.map +0 -1
  44. package/dist/chunk-6KWNAU4F.js.map +0 -1
  45. package/dist/chunk-7QUQJW6Q.js.map +0 -1
  46. package/dist/chunk-P6IGZVWE.js +0 -155
  47. package/dist/chunk-P6IGZVWE.js.map +0 -1
  48. package/dist/chunk-S4UMMHLE.js.map +0 -1
  49. /package/dist/{chunk-XMTXWXFO.js.map → chunk-KKT6OVO6.js.map} +0 -0
  50. /package/dist/{chunk-ZRSFFUHA.js.map → chunk-S36KN6CG.js.map} +0 -0
@@ -0,0 +1,600 @@
1
+ import {
2
+ makePipeRef,
3
+ parsePipeRef
4
+ } from "./chunk-2N65P32H.js";
5
+ import {
6
+ BINDING_STEP_TYPE,
7
+ OUTCOME_TONE,
8
+ isBindingNode,
9
+ isOutcomeTone
10
+ } from "./chunk-BQZ3BPJM.js";
11
+
12
+ // src/graph/graphAnalysis.ts
13
+ function buildDataflowAnalysis(graphspec) {
14
+ if (!graphspec) return null;
15
+ const stuffRegistry = {};
16
+ const stuffProducers = {};
17
+ const stuffConsumers = {};
18
+ const containmentTree = {};
19
+ const childNodeIds = /* @__PURE__ */ new Set();
20
+ for (const edge of graphspec.edges) {
21
+ if (edge.kind === "contains") {
22
+ if (!containmentTree[edge.source]) containmentTree[edge.source] = [];
23
+ containmentTree[edge.source].push(edge.target);
24
+ childNodeIds.add(edge.target);
25
+ }
26
+ }
27
+ const controllerNodeIds = new Set(Object.keys(containmentTree));
28
+ for (const node of graphspec.nodes) {
29
+ const nodeIo = node.io;
30
+ const isController = controllerNodeIds.has(node.id);
31
+ for (const output of nodeIo.outputs) {
32
+ if (output.digest && !stuffRegistry[output.digest]) {
33
+ stuffRegistry[output.digest] = {
34
+ name: output.name,
35
+ concept: output.concept,
36
+ multiplicity: output.multiplicity,
37
+ contentType: output.content_type
38
+ };
39
+ }
40
+ if (output.digest && !isController) {
41
+ if (!stuffProducers[output.digest]) stuffProducers[output.digest] = [];
42
+ stuffProducers[output.digest].push(node.id);
43
+ }
44
+ }
45
+ for (const input of nodeIo.inputs) {
46
+ if (input.digest && !stuffRegistry[input.digest]) {
47
+ stuffRegistry[input.digest] = {
48
+ name: input.name,
49
+ concept: input.concept,
50
+ multiplicity: input.multiplicity,
51
+ contentType: input.content_type
52
+ };
53
+ }
54
+ if (input.digest && !isController) {
55
+ if (!stuffConsumers[input.digest]) stuffConsumers[input.digest] = [];
56
+ stuffConsumers[input.digest].push(node.id);
57
+ }
58
+ }
59
+ }
60
+ return {
61
+ stuffRegistry,
62
+ stuffProducers,
63
+ stuffConsumers,
64
+ controllerNodeIds,
65
+ childNodeIds,
66
+ containmentTree
67
+ };
68
+ }
69
+ function buildChildToControllerMap(graphspec, analysis) {
70
+ const childToController = {};
71
+ for (const [ctrlId, children] of Object.entries(analysis.containmentTree)) {
72
+ for (const childId of children) {
73
+ childToController[childId] = ctrlId;
74
+ }
75
+ }
76
+ for (const [digest, producerIds] of Object.entries(analysis.stuffProducers)) {
77
+ const stuffId = "stuff_" + digest;
78
+ const ctrlId = commonController(producerIds, childToController);
79
+ if (ctrlId) {
80
+ childToController[stuffId] = ctrlId;
81
+ }
82
+ }
83
+ for (const node of graphspec.nodes) {
84
+ if (!analysis.controllerNodeIds.has(node.id)) continue;
85
+ const parentCtrlId = childToController[node.id];
86
+ if (!parentCtrlId) continue;
87
+ for (const output of node.io.outputs) {
88
+ if (!output.digest) continue;
89
+ const stuffId = "stuff_" + output.digest;
90
+ if (!childToController[stuffId]) {
91
+ childToController[stuffId] = parentCtrlId;
92
+ }
93
+ }
94
+ }
95
+ for (const edge of graphspec.edges) {
96
+ if (edge.kind === "batch_item" && edge.target_stuff_digest) {
97
+ const stuffId = "stuff_" + edge.target_stuff_digest;
98
+ if (analysis.controllerNodeIds.has(edge.source)) {
99
+ childToController[stuffId] = edge.source;
100
+ }
101
+ }
102
+ }
103
+ const stuffInStuffEdges = /* @__PURE__ */ new Set();
104
+ for (const edge of graphspec.edges) {
105
+ if (edge.kind === "batch_item" || edge.kind === "batch_aggregate" || edge.kind === "parallel_combine") {
106
+ if (edge.source_stuff_digest) stuffInStuffEdges.add(edge.source_stuff_digest);
107
+ if (edge.target_stuff_digest) stuffInStuffEdges.add(edge.target_stuff_digest);
108
+ }
109
+ }
110
+ const stuffPrefix = "stuff_";
111
+ const stuffEntries = Object.keys(childToController).filter((id) => id.startsWith(stuffPrefix));
112
+ for (const stuffId of stuffEntries) {
113
+ const digest = stuffId.slice(stuffPrefix.length);
114
+ let assignedCtrl = childToController[stuffId];
115
+ if (!assignedCtrl) continue;
116
+ const consumers = analysis.stuffConsumers[digest] || [];
117
+ if (consumers.length === 0) {
118
+ if (!stuffInStuffEdges.has(digest)) {
119
+ delete childToController[stuffId];
120
+ }
121
+ continue;
122
+ }
123
+ while (assignedCtrl) {
124
+ const ctrl = assignedCtrl;
125
+ const hasConsumerInside = consumers.some(
126
+ (consumerId) => isDescendantOf(consumerId, ctrl, childToController)
127
+ );
128
+ if (hasConsumerInside) break;
129
+ const parentCtrl = childToController[assignedCtrl];
130
+ if (parentCtrl) {
131
+ childToController[stuffId] = parentCtrl;
132
+ assignedCtrl = parentCtrl;
133
+ } else {
134
+ delete childToController[stuffId];
135
+ assignedCtrl = void 0;
136
+ }
137
+ }
138
+ }
139
+ return childToController;
140
+ }
141
+ function commonController(nodeIds, childToController) {
142
+ if (nodeIds.length === 0) return void 0;
143
+ let candidate = childToController[nodeIds[0]];
144
+ while (candidate) {
145
+ const ctrl = candidate;
146
+ if (nodeIds.every((id) => isDescendantOf(id, ctrl, childToController))) return ctrl;
147
+ candidate = childToController[ctrl];
148
+ }
149
+ return void 0;
150
+ }
151
+ function isDescendantOf(nodeId, ancestorCtrlId, childToController) {
152
+ let current = childToController[nodeId];
153
+ while (current) {
154
+ if (current === ancestorCtrlId) return true;
155
+ current = childToController[current];
156
+ }
157
+ return false;
158
+ }
159
+ function getPipeBlueprint(spec, pipeRef) {
160
+ var _a;
161
+ return (_a = spec.pipe_registry) == null ? void 0 : _a[pipeRef];
162
+ }
163
+ function resolveNodeBlueprint(spec, node) {
164
+ var _a;
165
+ const registry = spec.pipe_registry;
166
+ if (!registry || isBindingNode(node) || !node.pipe_code) return void 0;
167
+ if (node.domain_code) return registry[makePipeRef(node.domain_code, node.pipe_code)];
168
+ const pipelineDomain = (_a = spec.pipeline_ref) == null ? void 0 : _a.domain;
169
+ if (pipelineDomain) {
170
+ const inPipelineDomain = registry[makePipeRef(pipelineDomain, node.pipe_code)];
171
+ if (inPipelineDomain) return inPipelineDomain;
172
+ }
173
+ const suffix = `.${node.pipe_code}`;
174
+ const matches = Object.keys(registry).filter((ref) => ref.endsWith(suffix));
175
+ return matches.length === 1 ? registry[matches[0]] : void 0;
176
+ }
177
+ function getConceptInfo(spec, conceptRef) {
178
+ var _a;
179
+ return (_a = spec.concept_registry) == null ? void 0 : _a[conceptRef];
180
+ }
181
+ function resolveConceptRef(spec, codeOrRef) {
182
+ if (!spec.concept_registry) return void 0;
183
+ const direct = spec.concept_registry[codeOrRef];
184
+ if (direct) return direct;
185
+ for (const info of Object.values(spec.concept_registry)) {
186
+ if (info.code === codeOrRef) return info;
187
+ }
188
+ return void 0;
189
+ }
190
+
191
+ // src/graph/styles/humanize.ts
192
+ var VOWELED_ACRONYMS = /* @__PURE__ */ new Set([
193
+ "ai",
194
+ "api",
195
+ "faq",
196
+ "iban",
197
+ "id",
198
+ "io",
199
+ "ip",
200
+ "json",
201
+ "kpi",
202
+ "ocr",
203
+ "roi",
204
+ "seo",
205
+ "ui",
206
+ "uri",
207
+ "url",
208
+ "uuid",
209
+ "ux"
210
+ ]);
211
+ var VOWELS = /[aeiouy]/;
212
+ var VOWELLESS_WORDS = /* @__PURE__ */ new Set([
213
+ "cfg",
214
+ "cm",
215
+ "cnt",
216
+ "ctx",
217
+ "dr",
218
+ "dst",
219
+ "fn",
220
+ "ft",
221
+ "hmm",
222
+ "hr",
223
+ "kg",
224
+ "km",
225
+ "lb",
226
+ "mg",
227
+ "ml",
228
+ "mm",
229
+ "mr",
230
+ "mrs",
231
+ "ms",
232
+ "msg",
233
+ "nd",
234
+ "nth",
235
+ "pkg",
236
+ "pt",
237
+ "rd",
238
+ "src",
239
+ "st",
240
+ "th",
241
+ "tmp",
242
+ "vs"
243
+ ]);
244
+ var SINGULAR_S_ACRONYMS = /* @__PURE__ */ new Set([
245
+ "cms",
246
+ "css",
247
+ "dns",
248
+ "gps",
249
+ "rss",
250
+ "sms"
251
+ ]);
252
+ var NATIVE_PLAIN_NAMES = {
253
+ Html: "HTML",
254
+ JSON: "JSON",
255
+ TextAndImages: "Text and images",
256
+ YesNo: "Yes or no",
257
+ SearchResult: "Search result",
258
+ Composite: "Combined results",
259
+ Dynamic: "Data"
260
+ };
261
+ var GENERIC_NATIVES = /* @__PURE__ */ new Set(["Anything", "Dynamic", "Composite"]);
262
+ function isAcronymWord(lower) {
263
+ if (lower.length < 2 || !/^[a-z]+$/.test(lower)) return false;
264
+ if (VOWELLESS_WORDS.has(lower)) return false;
265
+ if (lower.endsWith("s") && VOWELLESS_WORDS.has(lower.slice(0, -1))) return false;
266
+ return !VOWELS.test(lower) || VOWELED_ACRONYMS.has(lower);
267
+ }
268
+ function spellWord(lower, wasAllCaps) {
269
+ if (/^\d+$/.test(lower)) return lower;
270
+ if (wasAllCaps && lower.length >= 2) return lower.toUpperCase();
271
+ if (lower.endsWith("s") && !SINGULAR_S_ACRONYMS.has(lower) && isAcronymWord(lower.slice(0, -1))) {
272
+ return lower.slice(0, -1).toUpperCase() + "s";
273
+ }
274
+ if (isAcronymWord(lower)) return lower.toUpperCase();
275
+ return lower;
276
+ }
277
+ function splitIdentifier(identifier) {
278
+ const parts = identifier.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/([A-Za-z])(\d)/g, "$1 $2").split(/[\s_\-.]+/).filter((p) => p.length > 0);
279
+ return parts.map((p) => ({
280
+ word: p.toLowerCase(),
281
+ wasAllCaps: p.length >= 2 && p === p.toUpperCase() && /[A-Z]/.test(p)
282
+ }));
283
+ }
284
+ function capitalizeFirst(text) {
285
+ return text.length === 0 ? text : text.charAt(0).toUpperCase() + text.slice(1);
286
+ }
287
+ function stripDomain(ref) {
288
+ const dot = ref.lastIndexOf(".");
289
+ return dot === -1 ? ref : ref.slice(dot + 1);
290
+ }
291
+ function humanizeIdentifier(identifier) {
292
+ const words = splitIdentifier(stripDomain(identifier.trim()));
293
+ if (words.length === 0) return "";
294
+ return capitalizeFirst(words.map((w) => spellWord(w.word, w.wasAllCaps)).join(" "));
295
+ }
296
+ function conceptPlainName(conceptRef) {
297
+ var _a;
298
+ const code = stripDomain(conceptRef.trim());
299
+ return (_a = NATIVE_PLAIN_NAMES[code]) != null ? _a : humanizeIdentifier(code);
300
+ }
301
+ function isGenericConcept(conceptRef) {
302
+ return GENERIC_NATIVES.has(stripDomain(conceptRef.trim()));
303
+ }
304
+ function sentenceCase(text) {
305
+ const collapsed = text.replace(/\s+/g, " ").trim();
306
+ const trimmed = collapsed.endsWith(".") && !collapsed.endsWith("..") ? collapsed.slice(0, -1) : collapsed;
307
+ return capitalizeFirst(trimmed);
308
+ }
309
+ function humanizeInSentence(identifier) {
310
+ return wordsInSentence(humanizeIdentifier(identifier));
311
+ }
312
+ function wordsInSentence(words) {
313
+ var _a;
314
+ const first = (_a = words.split(" ")[0]) != null ? _a : "";
315
+ return first.length >= 2 && first === first.toUpperCase() ? words : words.charAt(0).toLowerCase() + words.slice(1);
316
+ }
317
+ var OUTCOME_KEY_WORDS = {
318
+ true: "Yes",
319
+ false: "No"
320
+ };
321
+ function outcomeKeyLabel(key) {
322
+ var _a;
323
+ return (_a = OUTCOME_KEY_WORDS[key.toLowerCase()]) != null ? _a : humanizeIdentifier(key);
324
+ }
325
+
326
+ // src/graph/styles/nativeConcepts.ts
327
+ var NATIVE_DOMAIN = "native";
328
+ var STORED_VALUE_NATIVES = /* @__PURE__ */ new Set(["Text", "Markdown", "Html", "JSON"]);
329
+ var STORED_VALUE_REFERENCE_MEMBERS = /* @__PURE__ */ new Set([
330
+ "url",
331
+ "size",
332
+ "mime_type",
333
+ "preview"
334
+ ]);
335
+ function isStoredValueConcept(graphspec, concept) {
336
+ const seen = /* @__PURE__ */ new Set();
337
+ let current = concept;
338
+ while (current && !seen.has(current)) {
339
+ seen.add(current);
340
+ if (current.domain_code === NATIVE_DOMAIN) return STORED_VALUE_NATIVES.has(current.code);
341
+ const parent = current.refines;
342
+ if (!parent) return false;
343
+ const resolved = resolveConceptRef(graphspec, parent);
344
+ if (!resolved) {
345
+ return parent.startsWith(`${NATIVE_DOMAIN}.`) && STORED_VALUE_NATIVES.has(stripDomain(parent));
346
+ }
347
+ current = resolved;
348
+ }
349
+ return false;
350
+ }
351
+
352
+ // src/graph/styles/methodWords.ts
353
+ var WORDING_SOURCE = {
354
+ ACTIVITY: "activity",
355
+ DESCRIPTION: "description",
356
+ CODE: "code"
357
+ };
358
+ function stepWording(pipe, pipeCode) {
359
+ var _a, _b;
360
+ const activity = sentenceCase((_a = pipe == null ? void 0 : pipe.activity) != null ? _a : "");
361
+ if (activity) return { title: activity, source: WORDING_SOURCE.ACTIVITY };
362
+ const described = sentenceCase((_b = pipe == null ? void 0 : pipe.description) != null ? _b : "");
363
+ if (described) return { title: described, source: WORDING_SOURCE.DESCRIPTION };
364
+ return { title: humanizeIdentifier(pipeCode), source: WORDING_SOURCE.CODE };
365
+ }
366
+ function activityTitle(pipe) {
367
+ var _a;
368
+ return sentenceCase((_a = pipe == null ? void 0 : pipe.activity) != null ? _a : "") || null;
369
+ }
370
+ function nonEmpty(value) {
371
+ if (typeof value !== "string") return null;
372
+ const trimmed = value.replace(/\s+/g, " ").trim();
373
+ return trimmed.length > 0 ? trimmed : null;
374
+ }
375
+ function readWords(words) {
376
+ if (!words || typeof words !== "object") return null;
377
+ const read = {
378
+ label: nonEmpty(words.label),
379
+ description: nonEmpty(words.description),
380
+ tone: isOutcomeTone(words.tone) ? words.tone : null
381
+ };
382
+ return read.label !== null || read.description !== null || read.tone !== null ? read : null;
383
+ }
384
+ function outcomeWordsOf(condition, key) {
385
+ if ((condition == null ? void 0 : condition.type) !== "PipeCondition") return null;
386
+ if (key === null) return readWords(condition.default_outcome_words);
387
+ const words = condition.outcome_words;
388
+ if (!words || !Object.hasOwn(words, key)) return null;
389
+ return readWords(words[key]);
390
+ }
391
+ function outcomeTone(words) {
392
+ if (!words) return null;
393
+ if (words.tone) return words.tone;
394
+ return words.label !== null ? OUTCOME_TONE.NEUTRAL : null;
395
+ }
396
+ function sharedOutcomeTone(words) {
397
+ const tones = words.map(outcomeTone);
398
+ if (tones.length === 0 || tones.some((tone) => tone === null)) return null;
399
+ return new Set(tones).size === 1 ? tones[0] : null;
400
+ }
401
+ function branchOutcomeWords(condition, outcomes) {
402
+ const read = outcomes.map((key) => outcomeWordsOf(condition, key));
403
+ const descriptions = read.flatMap((words) => (words == null ? void 0 : words.description) ? [words.description] : []);
404
+ return {
405
+ description: descriptions.length === 1 ? descriptions[0] : null,
406
+ tone: sharedOutcomeTone(read)
407
+ };
408
+ }
409
+ var SELECTED_OUTCOME_WORDS_KEY = {
410
+ LABEL: "selected_outcome_label",
411
+ DESCRIPTION: "selected_outcome_description",
412
+ TONE: "selected_outcome_tone"
413
+ };
414
+ function selectedOutcomeWords(executionData) {
415
+ if (!executionData) return null;
416
+ return readWords({
417
+ label: executionData[SELECTED_OUTCOME_WORDS_KEY.LABEL],
418
+ description: executionData[SELECTED_OUTCOME_WORDS_KEY.DESCRIPTION],
419
+ tone: executionData[SELECTED_OUTCOME_WORDS_KEY.TONE]
420
+ });
421
+ }
422
+ function takenOutcomeKey(condition, executionData) {
423
+ const selected = executionData == null ? void 0 : executionData.selected_outcome;
424
+ if (typeof selected !== "string") return void 0;
425
+ const map = condition.outcome_map;
426
+ const evaluated = executionData == null ? void 0 : executionData.evaluated_expression;
427
+ if (typeof evaluated === "string") {
428
+ if (Object.hasOwn(map, evaluated)) return map[evaluated] === selected ? evaluated : void 0;
429
+ return condition.default_outcome === selected ? null : void 0;
430
+ }
431
+ const key = Object.keys(map).find((each) => map[each] === selected);
432
+ if (key !== void 0) return key;
433
+ return condition.default_outcome === selected ? null : void 0;
434
+ }
435
+ var DEFAULT_OUTCOME_TAG = "default";
436
+ function outcomeKeysFromTag(tag) {
437
+ return tag.split("|").map((key) => key.trim()).filter((key) => key.length > 0).map((key) => key === DEFAULT_OUTCOME_TAG ? null : key);
438
+ }
439
+ function sameOutcomes(a, b) {
440
+ if (a.length !== b.length) return false;
441
+ const keys = new Set(a);
442
+ return keys.size === new Set(b).size && b.every((key) => keys.has(key));
443
+ }
444
+ function outcomeArrowLabel(outcomes, condition) {
445
+ const labels = outcomes.map((key, index) => {
446
+ const words = outcomeWordsOf(condition, key);
447
+ if (words == null ? void 0 : words.label) return words.label;
448
+ const label = key === null ? DEFAULT_OUTCOME_WORDS : outcomeKeyLabel(key);
449
+ return index === 0 ? label : wordsInSentence(label);
450
+ });
451
+ return labels.join(" or ");
452
+ }
453
+ var DEFAULT_OUTCOME_WORDS = "Otherwise";
454
+ function conditionBranches(condition) {
455
+ var _a, _b;
456
+ const fullRef = (pipeRef) => {
457
+ var _a2;
458
+ if (pipeRef === "fail" || pipeRef === "continue") return pipeRef;
459
+ const parsed = parsePipeRef(pipeRef);
460
+ return parsed ? makePipeRef((_a2 = parsed.domainPath) != null ? _a2 : condition.domain_code, parsed.pipeCode) : pipeRef;
461
+ };
462
+ const byTarget = /* @__PURE__ */ new Map();
463
+ const named = Object.entries(condition.outcome_map);
464
+ named.push([null, condition.default_outcome]);
465
+ for (const [key, pipeRef] of named) {
466
+ if (!pipeRef) continue;
467
+ const target = fullRef(pipeRef);
468
+ const outcomes = byTarget.get(target);
469
+ if (outcomes) outcomes.push(key);
470
+ else byTarget.set(target, [key]);
471
+ }
472
+ const branches = [...byTarget.entries()].map(([target, outcomes]) => ({
473
+ target,
474
+ outcomes,
475
+ label: outcomeArrowLabel(outcomes, condition)
476
+ }));
477
+ const counts = /* @__PURE__ */ new Map();
478
+ const spoken = (label) => label.toLowerCase();
479
+ for (const { label } of branches) counts.set(spoken(label), ((_a = counts.get(spoken(label))) != null ? _a : 0) + 1);
480
+ for (const branch of branches) {
481
+ if (((_b = counts.get(spoken(branch.label))) != null ? _b : 0) < 2) continue;
482
+ const keys = branch.outcomes.map((key) => key != null ? key : DEFAULT_OUTCOME_WORDS.toLowerCase());
483
+ branch.label = `${branch.label} (${keys.join(", ")})`;
484
+ }
485
+ return branches;
486
+ }
487
+ var FILE_NATIVE_CODES = /* @__PURE__ */ new Set(["Image", "Document"]);
488
+ function isFileValuedOutput(output, lookupConcept) {
489
+ let concept = output == null ? void 0 : output.concept;
490
+ if (!concept) return null;
491
+ const seen = /* @__PURE__ */ new Set();
492
+ while (concept) {
493
+ if (concept.domain_code === NATIVE_DOMAIN) return FILE_NATIVE_CODES.has(concept.code);
494
+ concept = fullerConcept(concept, lookupConcept == null ? void 0 : lookupConcept(`${concept.domain_code}.${concept.code}`));
495
+ const refines = concept.refines;
496
+ if (refines === void 0) return null;
497
+ if (!refines) return false;
498
+ const qualified = refines.includes(".");
499
+ if (qualified && refines.slice(0, refines.lastIndexOf(".")) === NATIVE_DOMAIN) {
500
+ return FILE_NATIVE_CODES.has(stripDomain(refines));
501
+ }
502
+ const ref = qualified ? refines : `${concept.domain_code}.${refines}`;
503
+ if (seen.has(ref)) return null;
504
+ seen.add(ref);
505
+ const found = lookupConcept == null ? void 0 : lookupConcept(ref);
506
+ if (found) {
507
+ concept = found;
508
+ continue;
509
+ }
510
+ if (qualified) return null;
511
+ return FILE_NATIVE_CODES.has(refines) ? true : null;
512
+ }
513
+ return null;
514
+ }
515
+ function refinementWeight(concept) {
516
+ if (typeof concept.refines === "string" && concept.refines !== "") return 2;
517
+ return concept.refines === void 0 ? 0 : 1;
518
+ }
519
+ function fullerConcept(current, other) {
520
+ return other && refinementWeight(other) > refinementWeight(current) ? other : current;
521
+ }
522
+ var RUN_VIEW_ROLE = {
523
+ PipeLLM: "step",
524
+ PipeExtract: "step",
525
+ PipeCompose: "plumbing",
526
+ PipeImgGen: "step",
527
+ PipeSearch: "step",
528
+ PipeFunc: "plumbing-unless-file",
529
+ PipeStructure: "step",
530
+ PipeJudge: "step",
531
+ PipeDocGen: "step",
532
+ PipeSignature: "step",
533
+ PipeSequence: "step",
534
+ PipeParallel: "step",
535
+ PipeCondition: "step",
536
+ PipeBatch: "step",
537
+ [BINDING_STEP_TYPE]: "plumbing"
538
+ };
539
+ function isPlumbingStep(pipeType, pipe, lookupConcept) {
540
+ if (!Object.hasOwn(RUN_VIEW_ROLE, pipeType)) return false;
541
+ const role = RUN_VIEW_ROLE[pipeType];
542
+ if (role !== "plumbing-unless-file") return role === "plumbing";
543
+ if (!pipe) return false;
544
+ return isFileValuedOutput(pipe.output, lookupConcept) === false;
545
+ }
546
+ function registryConceptLookup(pipes, concepts) {
547
+ var _a, _b;
548
+ const known = /* @__PURE__ */ new Map();
549
+ const add = (concept) => {
550
+ if ((concept == null ? void 0 : concept.domain_code) && concept.code) {
551
+ const ref = `${concept.domain_code}.${concept.code}`;
552
+ const held = known.get(ref);
553
+ known.set(ref, held ? fullerConcept(held, concept) : concept);
554
+ }
555
+ };
556
+ for (const pipe of Object.values(pipes != null ? pipes : {})) {
557
+ add((_a = pipe.output) == null ? void 0 : _a.concept);
558
+ for (const input of Object.values((_b = pipe.inputs) != null ? _b : {})) add(input == null ? void 0 : input.concept);
559
+ }
560
+ for (const concept of Object.values(concepts != null ? concepts : {})) add(concept);
561
+ return (conceptRef) => known.get(conceptRef);
562
+ }
563
+
564
+ export {
565
+ buildDataflowAnalysis,
566
+ buildChildToControllerMap,
567
+ getPipeBlueprint,
568
+ resolveNodeBlueprint,
569
+ getConceptInfo,
570
+ resolveConceptRef,
571
+ stripDomain,
572
+ humanizeIdentifier,
573
+ conceptPlainName,
574
+ isGenericConcept,
575
+ sentenceCase,
576
+ humanizeInSentence,
577
+ wordsInSentence,
578
+ outcomeKeyLabel,
579
+ NATIVE_DOMAIN,
580
+ STORED_VALUE_REFERENCE_MEMBERS,
581
+ isStoredValueConcept,
582
+ WORDING_SOURCE,
583
+ stepWording,
584
+ activityTitle,
585
+ outcomeWordsOf,
586
+ outcomeTone,
587
+ sharedOutcomeTone,
588
+ branchOutcomeWords,
589
+ SELECTED_OUTCOME_WORDS_KEY,
590
+ selectedOutcomeWords,
591
+ takenOutcomeKey,
592
+ outcomeKeysFromTag,
593
+ sameOutcomes,
594
+ outcomeArrowLabel,
595
+ conditionBranches,
596
+ isFileValuedOutput,
597
+ isPlumbingStep,
598
+ registryConceptLookup
599
+ };
600
+ //# sourceMappingURL=chunk-UVEGKTBU.js.map