@probelabs/probe 0.6.0-rc114 → 0.6.0-rc116
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/bin/probe +3 -3
- package/build/agent/index.js +3452 -27
- package/build/agent/schemaUtils.js +3 -1
- package/build/mcp/index.js +5 -5
- package/build/mcp/index.ts +5 -5
- package/cjs/agent/ProbeAgent.cjs +3450 -25
- package/cjs/index.cjs +3450 -25
- package/package.json +2 -2
- package/src/agent/index.js +2 -2
- package/src/agent/schemaUtils.js +3 -1
- package/src/mcp/index.ts +5 -5
package/build/agent/index.js
CHANGED
|
@@ -41765,13 +41765,14 @@ function tokenize(text) {
|
|
|
41765
41765
|
const lexResult = MermaidLexer.tokenize(text);
|
|
41766
41766
|
return lexResult;
|
|
41767
41767
|
}
|
|
41768
|
-
var Identifier, NumberLiteral, FlowchartKeyword, GraphKeyword, Direction, SubgraphKeyword, EndKeyword, ClassKeyword, StyleKeyword, ClassDefKeyword, Ampersand, Comma, Semicolon, Colon, TripleColon, BiDirectionalArrow, CircleEndLine, CrossEndLine, DottedArrowRight, DottedArrowLeft, ThickArrowRight, ThickArrowLeft, ArrowRight, ArrowLeft, DottedLine, ThickLine, Line, TwoDashes, InvalidArrow, DoubleSquareOpen, DoubleSquareClose, DoubleRoundOpen, DoubleRoundClose, HexagonOpen, HexagonClose, StadiumOpen, StadiumClose, CylinderOpen, CylinderClose, SquareOpen, SquareClose, RoundOpen, RoundClose, DiamondOpen, DiamondClose, AngleOpen, AngleLess, Pipe, QuotedString, MultilineText, Comment, ColorValue, Text, WhiteSpace, Newline, allTokens, MermaidLexer;
|
|
41768
|
+
var Identifier, NumberLiteral, FlowchartKeyword, GraphKeyword, Direction, SubgraphKeyword, EndKeyword, ClassKeyword, StyleKeyword, ClassDefKeyword, Ampersand, Comma, Semicolon, Colon, TripleColon, BiDirectionalArrow, CircleEndLine, CrossEndLine, DottedArrowRight, DottedArrowLeft, ThickArrowRight, ThickArrowLeft, ArrowRight, ArrowLeft, DottedLine, ThickLine, Line, TwoDashes, InvalidArrow, DoubleSquareOpen, DoubleSquareClose, DoubleRoundOpen, DoubleRoundClose, HexagonOpen, HexagonClose, StadiumOpen, StadiumClose, CylinderOpen, CylinderClose, SquareOpen, SquareClose, RoundOpen, RoundClose, DiamondOpen, DiamondClose, AngleOpen, AngleLess, Pipe, ForwardSlash, Backslash, QuotedString, MultilineText, Comment, ColorValue, Text, WhiteSpace, Newline, allTokens, MermaidLexer;
|
|
41769
41769
|
var init_lexer2 = __esm({
|
|
41770
41770
|
"node_modules/@probelabs/maid/out/diagrams/flowchart/lexer.js"() {
|
|
41771
41771
|
init_api5();
|
|
41772
41772
|
Identifier = createToken({
|
|
41773
41773
|
name: "Identifier",
|
|
41774
|
-
|
|
41774
|
+
// e.g., id-2, _id, A1, but not A-- (that belongs to an arrow token)
|
|
41775
|
+
pattern: /[a-zA-Z_][a-zA-Z0-9_]*(?:-[a-zA-Z0-9_]+)*/
|
|
41775
41776
|
});
|
|
41776
41777
|
NumberLiteral = createToken({
|
|
41777
41778
|
name: "NumberLiteral",
|
|
@@ -41912,6 +41913,8 @@ var init_lexer2 = __esm({
|
|
|
41912
41913
|
AngleOpen = createToken({ name: "AngleOpen", pattern: />/ });
|
|
41913
41914
|
AngleLess = createToken({ name: "AngleLess", pattern: /</ });
|
|
41914
41915
|
Pipe = createToken({ name: "Pipe", pattern: /\|/ });
|
|
41916
|
+
ForwardSlash = createToken({ name: "ForwardSlash", pattern: /\// });
|
|
41917
|
+
Backslash = createToken({ name: "Backslash", pattern: /\\/ });
|
|
41915
41918
|
QuotedString = createToken({
|
|
41916
41919
|
name: "QuotedString",
|
|
41917
41920
|
// Allow escaped characters within quotes (Mermaid accepts \" inside "...")
|
|
@@ -41995,6 +41998,8 @@ var init_lexer2 = __esm({
|
|
|
41995
41998
|
DiamondClose,
|
|
41996
41999
|
AngleOpen,
|
|
41997
42000
|
AngleLess,
|
|
42001
|
+
ForwardSlash,
|
|
42002
|
+
Backslash,
|
|
41998
42003
|
Pipe,
|
|
41999
42004
|
TripleColon,
|
|
42000
42005
|
Ampersand,
|
|
@@ -42187,6 +42192,8 @@ var init_parser2 = __esm({
|
|
|
42187
42192
|
// Allow HTML-like tags (e.g., <br/>) inside labels
|
|
42188
42193
|
{ ALT: () => this.CONSUME(AngleLess) },
|
|
42189
42194
|
{ ALT: () => this.CONSUME(AngleOpen) },
|
|
42195
|
+
{ ALT: () => this.CONSUME(ForwardSlash) },
|
|
42196
|
+
{ ALT: () => this.CONSUME(Backslash) },
|
|
42190
42197
|
{ ALT: () => this.CONSUME(Comma) },
|
|
42191
42198
|
{ ALT: () => this.CONSUME(Colon) },
|
|
42192
42199
|
// HTML entities and ampersands inside labels
|
|
@@ -43235,6 +43242,66 @@ ${br.example}`,
|
|
|
43235
43242
|
length: len
|
|
43236
43243
|
};
|
|
43237
43244
|
}
|
|
43245
|
+
if (inRule("boxBlock") && (err.name === "NoViableAltException" || err.name === "MismatchedTokenException")) {
|
|
43246
|
+
const isMessage = /->|-->>|-->/.test(ltxt);
|
|
43247
|
+
const isNote = /note\s+(left|right|over)/i.test(ltxt);
|
|
43248
|
+
const isActivate = /activate\s+/i.test(ltxt);
|
|
43249
|
+
const isDeactivate = /deactivate\s+/i.test(ltxt);
|
|
43250
|
+
if (isMessage || isNote || isActivate || isDeactivate || tokType === "NoteKeyword" || tokType === "ActivateKeyword" || tokType === "DeactivateKeyword") {
|
|
43251
|
+
const lines2 = text.split(/\r?\n/);
|
|
43252
|
+
const boxLine = Math.max(0, line - 1);
|
|
43253
|
+
let hasEnd = false;
|
|
43254
|
+
let openIdx = -1;
|
|
43255
|
+
for (let i3 = boxLine; i3 >= 0; i3--) {
|
|
43256
|
+
if (/^\s*box\b/.test(lines2[i3] || "")) {
|
|
43257
|
+
openIdx = i3;
|
|
43258
|
+
break;
|
|
43259
|
+
}
|
|
43260
|
+
}
|
|
43261
|
+
if (openIdx !== -1) {
|
|
43262
|
+
for (let i3 = boxLine; i3 < lines2.length; i3++) {
|
|
43263
|
+
if (/^\s*end\s*$/.test(lines2[i3] || "")) {
|
|
43264
|
+
hasEnd = true;
|
|
43265
|
+
break;
|
|
43266
|
+
}
|
|
43267
|
+
if (i3 > boxLine && /^\s*(sequenceDiagram|box|alt|opt|loop|par|rect|critical|break)\b/.test(lines2[i3] || ""))
|
|
43268
|
+
break;
|
|
43269
|
+
}
|
|
43270
|
+
}
|
|
43271
|
+
if (hasEnd) {
|
|
43272
|
+
let hasParticipants = false;
|
|
43273
|
+
for (let i3 = openIdx + 1; i3 < lines2.length; i3++) {
|
|
43274
|
+
const raw = lines2[i3] || "";
|
|
43275
|
+
if (/^\s*end\s*$/.test(raw))
|
|
43276
|
+
break;
|
|
43277
|
+
if (/^\s*(participant|actor)\b/i.test(raw)) {
|
|
43278
|
+
hasParticipants = true;
|
|
43279
|
+
break;
|
|
43280
|
+
}
|
|
43281
|
+
}
|
|
43282
|
+
if (!hasParticipants) {
|
|
43283
|
+
return {
|
|
43284
|
+
line: openIdx + 1,
|
|
43285
|
+
column: 1,
|
|
43286
|
+
severity: "error",
|
|
43287
|
+
code: "SE-BOX-EMPTY",
|
|
43288
|
+
message: "Box block has no participant/actor declarations. Use 'rect' to group messages visually.",
|
|
43289
|
+
hint: "Replace 'box' with 'rect' if you want to group messages:\nrect rgb(240, 240, 255)\n A->>B: Message\n Note over A: Info\nend",
|
|
43290
|
+
length: 3
|
|
43291
|
+
};
|
|
43292
|
+
}
|
|
43293
|
+
return {
|
|
43294
|
+
line,
|
|
43295
|
+
column,
|
|
43296
|
+
severity: "error",
|
|
43297
|
+
code: "SE-BOX-INVALID-CONTENT",
|
|
43298
|
+
message: "Box blocks can only contain participant/actor declarations.",
|
|
43299
|
+
hint: 'Move messages, notes, and other statements outside the box block.\nExample:\nbox "Group"\n participant A\n participant B\nend\nA->>B: Message',
|
|
43300
|
+
length: len
|
|
43301
|
+
};
|
|
43302
|
+
}
|
|
43303
|
+
}
|
|
43304
|
+
}
|
|
43238
43305
|
const blockRules = [
|
|
43239
43306
|
{ rule: "altBlock", label: "alt" },
|
|
43240
43307
|
{ rule: "optBlock", label: "opt" },
|
|
@@ -44134,9 +44201,15 @@ var init_parser4 = __esm({
|
|
|
44134
44201
|
this.CONSUME(BoxKeyword);
|
|
44135
44202
|
this.OPTION(() => this.SUBRULE(this.lineRemainder));
|
|
44136
44203
|
this.AT_LEAST_ONE(() => this.CONSUME(Newline3));
|
|
44137
|
-
this.MANY(() => this.
|
|
44204
|
+
this.MANY(() => this.OR([
|
|
44205
|
+
{ ALT: () => this.SUBRULE(this.participantDecl) },
|
|
44206
|
+
{ ALT: () => this.SUBRULE(this.blankLine) }
|
|
44207
|
+
]));
|
|
44138
44208
|
this.CONSUME(EndKeyword2);
|
|
44139
|
-
this.
|
|
44209
|
+
this.OR2([
|
|
44210
|
+
{ ALT: () => this.AT_LEAST_ONE2(() => this.CONSUME2(Newline3)) },
|
|
44211
|
+
{ ALT: () => this.CONSUME2(EOF) }
|
|
44212
|
+
]);
|
|
44140
44213
|
});
|
|
44141
44214
|
this.lineRemainder = this.RULE("lineRemainder", () => {
|
|
44142
44215
|
this.AT_LEAST_ONE(() => this.OR([
|
|
@@ -45687,6 +45760,69 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
45687
45760
|
edits.push(replaceRange(text, at(e3), e3.length ?? 4, "option"));
|
|
45688
45761
|
continue;
|
|
45689
45762
|
}
|
|
45763
|
+
if (is("SE-BOX-EMPTY", e3)) {
|
|
45764
|
+
const lines = text.split(/\r?\n/);
|
|
45765
|
+
const boxIdx = Math.max(0, e3.line - 1);
|
|
45766
|
+
const boxLine = lines[boxIdx] || "";
|
|
45767
|
+
const labelMatch = /^\s*box\s+(.+)$/.exec(boxLine);
|
|
45768
|
+
if (labelMatch) {
|
|
45769
|
+
const indent = boxLine.match(/^\s*/)?.[0] || "";
|
|
45770
|
+
const newLine = `${indent}rect rgb(240, 240, 255)`;
|
|
45771
|
+
edits.push({ start: { line: e3.line, column: 1 }, end: { line: e3.line, column: boxLine.length + 1 }, newText: newLine });
|
|
45772
|
+
}
|
|
45773
|
+
continue;
|
|
45774
|
+
}
|
|
45775
|
+
if (is("SE-BOX-INVALID-CONTENT", e3)) {
|
|
45776
|
+
const lines = text.split(/\r?\n/);
|
|
45777
|
+
const curIdx = Math.max(0, e3.line - 1);
|
|
45778
|
+
const boxRe = /^(\s*)box\b/;
|
|
45779
|
+
let openIdx = -1;
|
|
45780
|
+
let openIndent = "";
|
|
45781
|
+
for (let i3 = curIdx; i3 >= 0; i3--) {
|
|
45782
|
+
const m3 = boxRe.exec(lines[i3] || "");
|
|
45783
|
+
if (m3) {
|
|
45784
|
+
openIdx = i3;
|
|
45785
|
+
openIndent = m3[1] || "";
|
|
45786
|
+
break;
|
|
45787
|
+
}
|
|
45788
|
+
}
|
|
45789
|
+
if (openIdx !== -1) {
|
|
45790
|
+
let endIdx = -1;
|
|
45791
|
+
for (let i3 = openIdx + 1; i3 < lines.length; i3++) {
|
|
45792
|
+
const trimmed = (lines[i3] || "").trim();
|
|
45793
|
+
if (trimmed === "end") {
|
|
45794
|
+
endIdx = i3;
|
|
45795
|
+
break;
|
|
45796
|
+
}
|
|
45797
|
+
}
|
|
45798
|
+
if (endIdx !== -1) {
|
|
45799
|
+
const invalidLines = [];
|
|
45800
|
+
for (let i3 = openIdx + 1; i3 < endIdx; i3++) {
|
|
45801
|
+
const raw = lines[i3] || "";
|
|
45802
|
+
const trimmed = raw.trim();
|
|
45803
|
+
if (trimmed === "")
|
|
45804
|
+
continue;
|
|
45805
|
+
if (!/^\s*(participant|actor)\b/i.test(raw)) {
|
|
45806
|
+
invalidLines.push(i3);
|
|
45807
|
+
}
|
|
45808
|
+
}
|
|
45809
|
+
if (invalidLines.length > 0) {
|
|
45810
|
+
const endIndent = openIndent;
|
|
45811
|
+
const movedContent = invalidLines.map((i3) => {
|
|
45812
|
+
const line = lines[i3] || "";
|
|
45813
|
+
const trimmed = line.trimStart();
|
|
45814
|
+
return endIndent + trimmed;
|
|
45815
|
+
}).join("\n") + "\n";
|
|
45816
|
+
for (let i3 = invalidLines.length - 1; i3 >= 0; i3--) {
|
|
45817
|
+
const idx = invalidLines[i3];
|
|
45818
|
+
edits.push({ start: { line: idx + 1, column: 1 }, end: { line: idx + 2, column: 1 }, newText: "" });
|
|
45819
|
+
}
|
|
45820
|
+
edits.push(insertAt(text, { line: endIdx + 2, column: 1 }, movedContent));
|
|
45821
|
+
}
|
|
45822
|
+
}
|
|
45823
|
+
}
|
|
45824
|
+
continue;
|
|
45825
|
+
}
|
|
45690
45826
|
if (is("SE-BLOCK-MISSING-END", e3)) {
|
|
45691
45827
|
const lines = text.split(/\r?\n/);
|
|
45692
45828
|
const curIdx = Math.max(0, e3.line - 1);
|
|
@@ -45967,8 +46103,543 @@ var init_fixes = __esm({
|
|
|
45967
46103
|
});
|
|
45968
46104
|
|
|
45969
46105
|
// node_modules/@probelabs/maid/out/renderer/graph-builder.js
|
|
46106
|
+
var GraphBuilder;
|
|
45970
46107
|
var init_graph_builder = __esm({
|
|
45971
46108
|
"node_modules/@probelabs/maid/out/renderer/graph-builder.js"() {
|
|
46109
|
+
GraphBuilder = class {
|
|
46110
|
+
constructor() {
|
|
46111
|
+
this.nodes = /* @__PURE__ */ new Map();
|
|
46112
|
+
this.edges = [];
|
|
46113
|
+
this.nodeCounter = 0;
|
|
46114
|
+
this.edgeCounter = 0;
|
|
46115
|
+
this.subgraphs = [];
|
|
46116
|
+
this.currentSubgraphStack = [];
|
|
46117
|
+
this.classStyles = /* @__PURE__ */ new Map();
|
|
46118
|
+
this.nodeStyles = /* @__PURE__ */ new Map();
|
|
46119
|
+
this.nodeClasses = /* @__PURE__ */ new Map();
|
|
46120
|
+
}
|
|
46121
|
+
build(cst) {
|
|
46122
|
+
this.reset();
|
|
46123
|
+
if (!cst || !cst.children) {
|
|
46124
|
+
return {
|
|
46125
|
+
nodes: [],
|
|
46126
|
+
edges: [],
|
|
46127
|
+
direction: "TD",
|
|
46128
|
+
subgraphs: []
|
|
46129
|
+
};
|
|
46130
|
+
}
|
|
46131
|
+
const direction = this.extractDirection(cst);
|
|
46132
|
+
this.processStatements(cst);
|
|
46133
|
+
return {
|
|
46134
|
+
nodes: Array.from(this.nodes.values()),
|
|
46135
|
+
edges: this.edges,
|
|
46136
|
+
direction,
|
|
46137
|
+
subgraphs: this.subgraphs
|
|
46138
|
+
};
|
|
46139
|
+
}
|
|
46140
|
+
reset() {
|
|
46141
|
+
this.nodes.clear();
|
|
46142
|
+
this.edges = [];
|
|
46143
|
+
this.nodeCounter = 0;
|
|
46144
|
+
this.edgeCounter = 0;
|
|
46145
|
+
this.subgraphs = [];
|
|
46146
|
+
this.currentSubgraphStack = [];
|
|
46147
|
+
this.classStyles.clear();
|
|
46148
|
+
this.nodeStyles.clear();
|
|
46149
|
+
this.nodeClasses.clear();
|
|
46150
|
+
}
|
|
46151
|
+
extractDirection(cst) {
|
|
46152
|
+
const dirToken = cst.children?.Direction?.[0];
|
|
46153
|
+
const dir = dirToken?.image?.toUpperCase();
|
|
46154
|
+
switch (dir) {
|
|
46155
|
+
case "TB":
|
|
46156
|
+
case "TD":
|
|
46157
|
+
return "TD";
|
|
46158
|
+
case "BT":
|
|
46159
|
+
return "BT";
|
|
46160
|
+
case "LR":
|
|
46161
|
+
return "LR";
|
|
46162
|
+
case "RL":
|
|
46163
|
+
return "RL";
|
|
46164
|
+
default:
|
|
46165
|
+
return "TD";
|
|
46166
|
+
}
|
|
46167
|
+
}
|
|
46168
|
+
processStatements(cst) {
|
|
46169
|
+
const statements = cst.children?.statement;
|
|
46170
|
+
if (!statements)
|
|
46171
|
+
return;
|
|
46172
|
+
for (const stmt of statements) {
|
|
46173
|
+
if (stmt.children?.nodeStatement) {
|
|
46174
|
+
this.processNodeStatement(stmt.children.nodeStatement[0]);
|
|
46175
|
+
} else if (stmt.children?.subgraph) {
|
|
46176
|
+
this.processSubgraph(stmt.children.subgraph[0]);
|
|
46177
|
+
} else if (stmt.children?.classDefStatement) {
|
|
46178
|
+
this.processClassDef(stmt.children.classDefStatement[0]);
|
|
46179
|
+
} else if (stmt.children?.classStatement) {
|
|
46180
|
+
this.processClassAssign(stmt.children.classStatement[0]);
|
|
46181
|
+
} else if (stmt.children?.styleStatement) {
|
|
46182
|
+
this.processStyle(stmt.children.styleStatement[0]);
|
|
46183
|
+
}
|
|
46184
|
+
}
|
|
46185
|
+
}
|
|
46186
|
+
processNodeStatement(stmt) {
|
|
46187
|
+
const groups = stmt.children?.nodeOrParallelGroup;
|
|
46188
|
+
const links = stmt.children?.link;
|
|
46189
|
+
if (!groups || groups.length === 0)
|
|
46190
|
+
return;
|
|
46191
|
+
const sourceNodes = this.processNodeGroup(groups[0]);
|
|
46192
|
+
if (groups.length > 1 && links && links.length > 0) {
|
|
46193
|
+
const targetNodes = this.processNodeGroup(groups[1]);
|
|
46194
|
+
const linkInfo = this.extractLinkInfo(links[0]);
|
|
46195
|
+
for (const source of sourceNodes) {
|
|
46196
|
+
for (const target of targetNodes) {
|
|
46197
|
+
this.edges.push({
|
|
46198
|
+
id: `e${this.edgeCounter++}`,
|
|
46199
|
+
source,
|
|
46200
|
+
target,
|
|
46201
|
+
label: linkInfo.label,
|
|
46202
|
+
type: linkInfo.type,
|
|
46203
|
+
markerStart: linkInfo.markerStart,
|
|
46204
|
+
markerEnd: linkInfo.markerEnd
|
|
46205
|
+
});
|
|
46206
|
+
}
|
|
46207
|
+
}
|
|
46208
|
+
for (let i3 = 2; i3 < groups.length; i3++) {
|
|
46209
|
+
const nextNodes = this.processNodeGroup(groups[i3]);
|
|
46210
|
+
const nextLink = links[i3 - 1] ? this.extractLinkInfo(links[i3 - 1]) : linkInfo;
|
|
46211
|
+
for (const source of targetNodes) {
|
|
46212
|
+
for (const target of nextNodes) {
|
|
46213
|
+
this.edges.push({
|
|
46214
|
+
id: `e${this.edgeCounter++}`,
|
|
46215
|
+
source,
|
|
46216
|
+
target,
|
|
46217
|
+
label: nextLink.label,
|
|
46218
|
+
type: nextLink.type,
|
|
46219
|
+
markerStart: nextLink.markerStart,
|
|
46220
|
+
markerEnd: nextLink.markerEnd
|
|
46221
|
+
});
|
|
46222
|
+
}
|
|
46223
|
+
}
|
|
46224
|
+
targetNodes.length = 0;
|
|
46225
|
+
targetNodes.push(...nextNodes);
|
|
46226
|
+
}
|
|
46227
|
+
}
|
|
46228
|
+
}
|
|
46229
|
+
processNodeGroup(group) {
|
|
46230
|
+
const nodes = group.children?.node;
|
|
46231
|
+
if (!nodes)
|
|
46232
|
+
return [];
|
|
46233
|
+
const nodeIds = [];
|
|
46234
|
+
for (const node of nodes) {
|
|
46235
|
+
const nodeInfo = this.extractNodeInfo(node);
|
|
46236
|
+
if (nodeInfo) {
|
|
46237
|
+
const isSubgraph = this.subgraphs.some((sg) => sg.id === nodeInfo.id);
|
|
46238
|
+
if (!isSubgraph) {
|
|
46239
|
+
if (!this.nodes.has(nodeInfo.id)) {
|
|
46240
|
+
nodeInfo.style = this.computeNodeStyle(nodeInfo.id);
|
|
46241
|
+
this.nodes.set(nodeInfo.id, nodeInfo);
|
|
46242
|
+
} else {
|
|
46243
|
+
const existing = this.nodes.get(nodeInfo.id);
|
|
46244
|
+
if (nodeInfo.shape !== "rectangle" || nodeInfo.label !== nodeInfo.id) {
|
|
46245
|
+
if (nodeInfo.label !== nodeInfo.id) {
|
|
46246
|
+
existing.label = nodeInfo.label;
|
|
46247
|
+
}
|
|
46248
|
+
if (nodeInfo.shape !== "rectangle") {
|
|
46249
|
+
existing.shape = nodeInfo.shape;
|
|
46250
|
+
}
|
|
46251
|
+
}
|
|
46252
|
+
const merged = this.computeNodeStyle(nodeInfo.id);
|
|
46253
|
+
if (Object.keys(merged).length) {
|
|
46254
|
+
existing.style = { ...existing.style || {}, ...merged };
|
|
46255
|
+
}
|
|
46256
|
+
}
|
|
46257
|
+
if (this.currentSubgraphStack.length) {
|
|
46258
|
+
for (const sgId of this.currentSubgraphStack) {
|
|
46259
|
+
const subgraph = this.subgraphs.find((s3) => s3.id === sgId);
|
|
46260
|
+
if (subgraph && !subgraph.nodes.includes(nodeInfo.id)) {
|
|
46261
|
+
subgraph.nodes.push(nodeInfo.id);
|
|
46262
|
+
}
|
|
46263
|
+
}
|
|
46264
|
+
}
|
|
46265
|
+
}
|
|
46266
|
+
nodeIds.push(nodeInfo.id);
|
|
46267
|
+
}
|
|
46268
|
+
}
|
|
46269
|
+
return nodeIds;
|
|
46270
|
+
}
|
|
46271
|
+
extractNodeInfo(node) {
|
|
46272
|
+
const children = node.children;
|
|
46273
|
+
if (!children)
|
|
46274
|
+
return null;
|
|
46275
|
+
let id;
|
|
46276
|
+
if (children.nodeId) {
|
|
46277
|
+
id = children.nodeId[0].image;
|
|
46278
|
+
if (children.nodeIdSuffix) {
|
|
46279
|
+
id += children.nodeIdSuffix[0].image;
|
|
46280
|
+
}
|
|
46281
|
+
} else if (children.nodeIdNum) {
|
|
46282
|
+
id = children.nodeIdNum[0].image;
|
|
46283
|
+
} else if (children.Identifier) {
|
|
46284
|
+
id = children.Identifier[0].image;
|
|
46285
|
+
} else {
|
|
46286
|
+
return null;
|
|
46287
|
+
}
|
|
46288
|
+
let shape = "rectangle";
|
|
46289
|
+
let label = id;
|
|
46290
|
+
const shapeNode = children.nodeShape?.[0];
|
|
46291
|
+
if (shapeNode?.children) {
|
|
46292
|
+
const result = this.extractShapeAndLabel(shapeNode);
|
|
46293
|
+
shape = result.shape;
|
|
46294
|
+
if (result.label)
|
|
46295
|
+
label = result.label;
|
|
46296
|
+
}
|
|
46297
|
+
const clsTok = children.nodeClass?.[0];
|
|
46298
|
+
if (clsTok) {
|
|
46299
|
+
const set = this.nodeClasses.get(id) || /* @__PURE__ */ new Set();
|
|
46300
|
+
set.add(clsTok.image);
|
|
46301
|
+
this.nodeClasses.set(id, set);
|
|
46302
|
+
}
|
|
46303
|
+
return { id, label, shape };
|
|
46304
|
+
}
|
|
46305
|
+
extractShapeAndLabel(shapeNode) {
|
|
46306
|
+
const children = shapeNode.children;
|
|
46307
|
+
let shape = "rectangle";
|
|
46308
|
+
let label = "";
|
|
46309
|
+
const contentNodes = children?.nodeContent;
|
|
46310
|
+
if (contentNodes && contentNodes.length > 0) {
|
|
46311
|
+
label = this.extractTextContent(contentNodes[0]);
|
|
46312
|
+
}
|
|
46313
|
+
if (children?.SquareOpen) {
|
|
46314
|
+
shape = "rectangle";
|
|
46315
|
+
const contentNode = children.nodeContent?.[0];
|
|
46316
|
+
if (contentNode) {
|
|
46317
|
+
const c3 = contentNode.children;
|
|
46318
|
+
const tokTypes = ["ForwardSlash", "Backslash", "Identifier", "Text", "NumberLiteral", "RoundOpen", "RoundClose", "AngleLess", "AngleOpen", "Comma", "Colon", "Ampersand", "Semicolon", "TwoDashes", "Line", "ThickLine", "DottedLine"];
|
|
46319
|
+
const toks = [];
|
|
46320
|
+
for (const tt of tokTypes) {
|
|
46321
|
+
const arr = c3[tt];
|
|
46322
|
+
arr?.forEach((t3) => toks.push({ type: tt, t: t3, start: t3.startOffset ?? 0 }));
|
|
46323
|
+
}
|
|
46324
|
+
if (toks.length >= 2) {
|
|
46325
|
+
toks.sort((a3, b3) => a3.start - b3.start);
|
|
46326
|
+
const first2 = toks[0].type;
|
|
46327
|
+
const last2 = toks[toks.length - 1].type;
|
|
46328
|
+
if (first2 === "ForwardSlash" && last2 === "ForwardSlash" || first2 === "Backslash" && last2 === "Backslash") {
|
|
46329
|
+
shape = "parallelogram";
|
|
46330
|
+
} else if (first2 === "ForwardSlash" && last2 === "Backslash") {
|
|
46331
|
+
shape = "trapezoid";
|
|
46332
|
+
} else if (first2 === "Backslash" && last2 === "ForwardSlash") {
|
|
46333
|
+
shape = "trapezoidAlt";
|
|
46334
|
+
}
|
|
46335
|
+
}
|
|
46336
|
+
}
|
|
46337
|
+
} else if (children?.RoundOpen) {
|
|
46338
|
+
shape = "round";
|
|
46339
|
+
} else if (children?.DiamondOpen) {
|
|
46340
|
+
shape = "diamond";
|
|
46341
|
+
} else if (children?.DoubleRoundOpen) {
|
|
46342
|
+
shape = "circle";
|
|
46343
|
+
} else if (children?.StadiumOpen) {
|
|
46344
|
+
shape = "stadium";
|
|
46345
|
+
} else if (children?.HexagonOpen) {
|
|
46346
|
+
shape = "hexagon";
|
|
46347
|
+
} else if (children?.DoubleSquareOpen) {
|
|
46348
|
+
shape = "subroutine";
|
|
46349
|
+
} else if (children?.CylinderOpen) {
|
|
46350
|
+
shape = "cylinder";
|
|
46351
|
+
} else if (children?.TrapezoidOpen) {
|
|
46352
|
+
shape = "trapezoid";
|
|
46353
|
+
} else if (children?.ParallelogramOpen) {
|
|
46354
|
+
shape = "parallelogram";
|
|
46355
|
+
}
|
|
46356
|
+
return { shape, label };
|
|
46357
|
+
}
|
|
46358
|
+
extractTextContent(contentNode) {
|
|
46359
|
+
const children = contentNode.children;
|
|
46360
|
+
if (!children)
|
|
46361
|
+
return "";
|
|
46362
|
+
const tokenTypes = [
|
|
46363
|
+
"Text",
|
|
46364
|
+
"Identifier",
|
|
46365
|
+
"QuotedString",
|
|
46366
|
+
"NumberLiteral",
|
|
46367
|
+
"Ampersand",
|
|
46368
|
+
"Comma",
|
|
46369
|
+
"Colon",
|
|
46370
|
+
"Semicolon",
|
|
46371
|
+
"Dot",
|
|
46372
|
+
"Underscore",
|
|
46373
|
+
"Dash",
|
|
46374
|
+
"ForwardSlash",
|
|
46375
|
+
"Backslash",
|
|
46376
|
+
"AngleLess",
|
|
46377
|
+
"AngleOpen"
|
|
46378
|
+
];
|
|
46379
|
+
const tokenWithPositions = [];
|
|
46380
|
+
for (const type of tokenTypes) {
|
|
46381
|
+
const tokens = children[type];
|
|
46382
|
+
if (tokens) {
|
|
46383
|
+
for (const token of tokens) {
|
|
46384
|
+
let text = token.image;
|
|
46385
|
+
if (type === "QuotedString" && text.startsWith('"') && text.endsWith('"')) {
|
|
46386
|
+
text = text.slice(1, -1);
|
|
46387
|
+
}
|
|
46388
|
+
if ((type === "ForwardSlash" || type === "Backslash") && tokenWithPositions.length === 0) {
|
|
46389
|
+
continue;
|
|
46390
|
+
}
|
|
46391
|
+
tokenWithPositions.push({
|
|
46392
|
+
text,
|
|
46393
|
+
startOffset: token.startOffset ?? 0,
|
|
46394
|
+
type
|
|
46395
|
+
});
|
|
46396
|
+
}
|
|
46397
|
+
}
|
|
46398
|
+
}
|
|
46399
|
+
tokenWithPositions.sort((a3, b3) => a3.startOffset - b3.startOffset);
|
|
46400
|
+
if (tokenWithPositions.length) {
|
|
46401
|
+
const first2 = tokenWithPositions[0];
|
|
46402
|
+
if (first2.type === "ForwardSlash" || first2.type === "Backslash") {
|
|
46403
|
+
tokenWithPositions.shift();
|
|
46404
|
+
}
|
|
46405
|
+
const last2 = tokenWithPositions[tokenWithPositions.length - 1];
|
|
46406
|
+
if (last2.type === "ForwardSlash" || last2.type === "Backslash") {
|
|
46407
|
+
tokenWithPositions.pop();
|
|
46408
|
+
}
|
|
46409
|
+
}
|
|
46410
|
+
const parts = tokenWithPositions.map((t3) => t3.text);
|
|
46411
|
+
if (children.Space) {
|
|
46412
|
+
return parts.join("");
|
|
46413
|
+
}
|
|
46414
|
+
return parts.join(" ").trim();
|
|
46415
|
+
}
|
|
46416
|
+
extractLinkInfo(link) {
|
|
46417
|
+
const children = link.children;
|
|
46418
|
+
let type = "arrow";
|
|
46419
|
+
let label;
|
|
46420
|
+
let markerStart = "none";
|
|
46421
|
+
let markerEnd = "none";
|
|
46422
|
+
if (children.BiDirectionalArrow) {
|
|
46423
|
+
type = "arrow";
|
|
46424
|
+
markerStart = "arrow";
|
|
46425
|
+
markerEnd = "arrow";
|
|
46426
|
+
} else if (children.CircleEndLine) {
|
|
46427
|
+
type = "open";
|
|
46428
|
+
markerStart = "circle";
|
|
46429
|
+
markerEnd = "circle";
|
|
46430
|
+
} else if (children.CrossEndLine) {
|
|
46431
|
+
type = "open";
|
|
46432
|
+
markerStart = "cross";
|
|
46433
|
+
markerEnd = "cross";
|
|
46434
|
+
} else if (children?.ArrowRight) {
|
|
46435
|
+
type = "arrow";
|
|
46436
|
+
markerEnd = "arrow";
|
|
46437
|
+
} else if (children?.ArrowLeft) {
|
|
46438
|
+
type = "arrow";
|
|
46439
|
+
markerStart = "arrow";
|
|
46440
|
+
} else if (children?.DottedArrowRight) {
|
|
46441
|
+
type = "dotted";
|
|
46442
|
+
markerEnd = "arrow";
|
|
46443
|
+
} else if (children?.DottedArrowLeft) {
|
|
46444
|
+
type = "dotted";
|
|
46445
|
+
markerStart = "arrow";
|
|
46446
|
+
} else if (children?.ThickArrowRight) {
|
|
46447
|
+
type = "thick";
|
|
46448
|
+
markerEnd = "arrow";
|
|
46449
|
+
} else if (children?.ThickArrowLeft) {
|
|
46450
|
+
type = "thick";
|
|
46451
|
+
markerStart = "arrow";
|
|
46452
|
+
} else if (children?.LinkRight || children?.LinkLeft || children?.Line || children?.TwoDashes || children?.DottedLine || children?.ThickLine) {
|
|
46453
|
+
if (children?.DottedLine)
|
|
46454
|
+
type = "dotted";
|
|
46455
|
+
else if (children?.ThickLine)
|
|
46456
|
+
type = "thick";
|
|
46457
|
+
else
|
|
46458
|
+
type = "open";
|
|
46459
|
+
} else if (children?.InvisibleLink) {
|
|
46460
|
+
type = "invisible";
|
|
46461
|
+
}
|
|
46462
|
+
if (markerEnd === "none" && (children?.ArrowRight || children.ThickArrowRight || children.DottedArrowRight)) {
|
|
46463
|
+
markerEnd = "arrow";
|
|
46464
|
+
}
|
|
46465
|
+
if (markerStart === "none" && (children?.ArrowLeft || children.ThickArrowLeft || children.DottedArrowLeft)) {
|
|
46466
|
+
markerStart = "arrow";
|
|
46467
|
+
}
|
|
46468
|
+
const textNode = children?.linkText?.[0];
|
|
46469
|
+
if (textNode) {
|
|
46470
|
+
label = this.extractTextContent(textNode);
|
|
46471
|
+
} else if (children.linkTextInline?.[0]) {
|
|
46472
|
+
label = this.extractTextContent(children.linkTextInline[0]);
|
|
46473
|
+
} else if (children.inlineCarrier?.[0]) {
|
|
46474
|
+
const token = children.inlineCarrier[0];
|
|
46475
|
+
const raw = token.image.trim();
|
|
46476
|
+
if (raw.startsWith("-.") && raw.endsWith(".-")) {
|
|
46477
|
+
type = "dotted";
|
|
46478
|
+
} else if (raw.startsWith("==") && raw.endsWith("==")) {
|
|
46479
|
+
type = "thick";
|
|
46480
|
+
} else if (raw.startsWith("--") && raw.endsWith("--")) {
|
|
46481
|
+
}
|
|
46482
|
+
if (children.ArrowRight || children.DottedArrowRight || children.ThickArrowRight) {
|
|
46483
|
+
markerEnd = "arrow";
|
|
46484
|
+
}
|
|
46485
|
+
if (children.ArrowLeft || children.DottedArrowLeft || children.ThickArrowLeft) {
|
|
46486
|
+
markerStart = "arrow";
|
|
46487
|
+
}
|
|
46488
|
+
const strip = (str) => {
|
|
46489
|
+
if (str.startsWith("-.") && str.endsWith(".-") || str.startsWith("==") && str.endsWith("==") || str.startsWith("--") && str.endsWith("--")) {
|
|
46490
|
+
return str.slice(2, -2).trim();
|
|
46491
|
+
}
|
|
46492
|
+
return str;
|
|
46493
|
+
};
|
|
46494
|
+
label = strip(raw);
|
|
46495
|
+
}
|
|
46496
|
+
return { type, label, markerStart, markerEnd };
|
|
46497
|
+
}
|
|
46498
|
+
processSubgraph(subgraph) {
|
|
46499
|
+
const children = subgraph.children;
|
|
46500
|
+
let id = `subgraph_${this.subgraphs.length}`;
|
|
46501
|
+
let label;
|
|
46502
|
+
const idToken = children?.subgraphId?.[0] || children?.Identifier?.[0];
|
|
46503
|
+
if (idToken) {
|
|
46504
|
+
id = idToken.image;
|
|
46505
|
+
}
|
|
46506
|
+
if (children?.SquareOpen && children?.nodeContent) {
|
|
46507
|
+
label = this.extractTextContent(children.nodeContent[0]);
|
|
46508
|
+
} else if (children.subgraphTitleQ?.[0]) {
|
|
46509
|
+
const qt = children.subgraphTitleQ[0];
|
|
46510
|
+
const img = qt.image;
|
|
46511
|
+
label = img && img.length >= 2 && (img.startsWith('"') || img.startsWith("'")) ? img.slice(1, -1) : img;
|
|
46512
|
+
} else if (children?.subgraphLabel) {
|
|
46513
|
+
label = this.extractTextContent(children.subgraphLabel[0]);
|
|
46514
|
+
}
|
|
46515
|
+
if (!label && id !== `subgraph_${this.subgraphs.length}`) {
|
|
46516
|
+
label = id;
|
|
46517
|
+
}
|
|
46518
|
+
const parent = this.currentSubgraphStack.length ? this.currentSubgraphStack[this.currentSubgraphStack.length - 1] : void 0;
|
|
46519
|
+
const sg = { id, label, nodes: [], parent };
|
|
46520
|
+
this.subgraphs.push(sg);
|
|
46521
|
+
this.currentSubgraphStack.push(id);
|
|
46522
|
+
const statements = children?.subgraphStatement;
|
|
46523
|
+
if (statements) {
|
|
46524
|
+
for (const stmt of statements) {
|
|
46525
|
+
if (stmt.children?.nodeStatement) {
|
|
46526
|
+
this.processNodeStatement(stmt.children.nodeStatement[0]);
|
|
46527
|
+
} else if (stmt.children?.subgraph) {
|
|
46528
|
+
this.processSubgraph(stmt.children.subgraph[0]);
|
|
46529
|
+
}
|
|
46530
|
+
}
|
|
46531
|
+
}
|
|
46532
|
+
this.currentSubgraphStack.pop();
|
|
46533
|
+
}
|
|
46534
|
+
// ---- Styling helpers ----
|
|
46535
|
+
processClassDef(cst) {
|
|
46536
|
+
const idTok = cst.children?.Identifier?.[0];
|
|
46537
|
+
if (!idTok)
|
|
46538
|
+
return;
|
|
46539
|
+
const className = idTok.image;
|
|
46540
|
+
const props = this.collectStyleProps(cst, { skipFirstIdentifier: true });
|
|
46541
|
+
if (Object.keys(props).length) {
|
|
46542
|
+
this.classStyles.set(className, props);
|
|
46543
|
+
for (const [nodeId, classes] of this.nodeClasses.entries()) {
|
|
46544
|
+
if (classes.has(className)) {
|
|
46545
|
+
const node = this.nodes.get(nodeId);
|
|
46546
|
+
if (node) {
|
|
46547
|
+
node.style = { ...node.style || {}, ...this.computeNodeStyle(nodeId) };
|
|
46548
|
+
}
|
|
46549
|
+
}
|
|
46550
|
+
}
|
|
46551
|
+
}
|
|
46552
|
+
}
|
|
46553
|
+
processClassAssign(cst) {
|
|
46554
|
+
const ids = cst.children?.Identifier || [];
|
|
46555
|
+
if (!ids.length)
|
|
46556
|
+
return;
|
|
46557
|
+
const classNameTok = cst.children.className?.[0];
|
|
46558
|
+
const className = classNameTok?.image || ids[ids.length - 1].image;
|
|
46559
|
+
const nodeIds = classNameTok ? ids.slice(0, -1) : ids.slice(0, -1);
|
|
46560
|
+
for (const tok of nodeIds) {
|
|
46561
|
+
const id = tok.image;
|
|
46562
|
+
const set = this.nodeClasses.get(id) || /* @__PURE__ */ new Set();
|
|
46563
|
+
set.add(className);
|
|
46564
|
+
this.nodeClasses.set(id, set);
|
|
46565
|
+
const node = this.nodes.get(id);
|
|
46566
|
+
if (node) {
|
|
46567
|
+
node.style = { ...node.style || {}, ...this.computeNodeStyle(id) };
|
|
46568
|
+
}
|
|
46569
|
+
}
|
|
46570
|
+
}
|
|
46571
|
+
processStyle(cst) {
|
|
46572
|
+
const idTok = cst.children?.Identifier?.[0];
|
|
46573
|
+
if (!idTok)
|
|
46574
|
+
return;
|
|
46575
|
+
const nodeId = idTok.image;
|
|
46576
|
+
const props = this.collectStyleProps(cst, { skipFirstIdentifier: true });
|
|
46577
|
+
if (Object.keys(props).length) {
|
|
46578
|
+
this.nodeStyles.set(nodeId, props);
|
|
46579
|
+
const node = this.nodes.get(nodeId);
|
|
46580
|
+
if (node) {
|
|
46581
|
+
node.style = { ...node.style || {}, ...this.computeNodeStyle(nodeId) };
|
|
46582
|
+
}
|
|
46583
|
+
}
|
|
46584
|
+
}
|
|
46585
|
+
collectStyleProps(cst, opts = {}) {
|
|
46586
|
+
const tokens = [];
|
|
46587
|
+
const ch = cst.children || {};
|
|
46588
|
+
const push = (arr, type = "t") => arr?.forEach((t3) => tokens.push({ text: t3.image, startOffset: t3.startOffset ?? 0, type }));
|
|
46589
|
+
push(ch.Text, "Text");
|
|
46590
|
+
push(ch.Identifier, "Identifier");
|
|
46591
|
+
push(ch.ColorValue, "Color");
|
|
46592
|
+
push(ch.Colon, "Colon");
|
|
46593
|
+
push(ch.Comma, "Comma");
|
|
46594
|
+
push(ch.NumberLiteral, "Number");
|
|
46595
|
+
tokens.sort((a3, b3) => a3.startOffset - b3.startOffset);
|
|
46596
|
+
if (opts.skipFirstIdentifier) {
|
|
46597
|
+
const idx = tokens.findIndex((t3) => t3.type === "Identifier");
|
|
46598
|
+
if (idx >= 0)
|
|
46599
|
+
tokens.splice(idx, 1);
|
|
46600
|
+
}
|
|
46601
|
+
const joined = tokens.map((t3) => t3.text).join("");
|
|
46602
|
+
const props = {};
|
|
46603
|
+
for (const seg of joined.split(",").map((s3) => s3.trim()).filter(Boolean)) {
|
|
46604
|
+
const [k3, v3] = seg.split(":");
|
|
46605
|
+
if (k3 && v3)
|
|
46606
|
+
props[k3.trim()] = v3.trim();
|
|
46607
|
+
}
|
|
46608
|
+
return props;
|
|
46609
|
+
}
|
|
46610
|
+
computeNodeStyle(nodeId) {
|
|
46611
|
+
const out = {};
|
|
46612
|
+
const classes = this.nodeClasses.get(nodeId);
|
|
46613
|
+
if (classes) {
|
|
46614
|
+
for (const c3 of classes) {
|
|
46615
|
+
const s3 = this.classStyles.get(c3);
|
|
46616
|
+
if (s3)
|
|
46617
|
+
Object.assign(out, this.normalizeStyle(s3));
|
|
46618
|
+
}
|
|
46619
|
+
}
|
|
46620
|
+
const direct = this.nodeStyles.get(nodeId);
|
|
46621
|
+
if (direct)
|
|
46622
|
+
Object.assign(out, this.normalizeStyle(direct));
|
|
46623
|
+
return out;
|
|
46624
|
+
}
|
|
46625
|
+
normalizeStyle(s3) {
|
|
46626
|
+
const out = {};
|
|
46627
|
+
for (const [kRaw, vRaw] of Object.entries(s3)) {
|
|
46628
|
+
const k3 = kRaw.trim().toLowerCase();
|
|
46629
|
+
const v3 = vRaw.trim();
|
|
46630
|
+
if (k3 === "stroke-width") {
|
|
46631
|
+
const num = parseFloat(v3);
|
|
46632
|
+
if (!Number.isNaN(num))
|
|
46633
|
+
out.strokeWidth = num;
|
|
46634
|
+
} else if (k3 === "stroke") {
|
|
46635
|
+
out.stroke = v3;
|
|
46636
|
+
} else if (k3 === "fill") {
|
|
46637
|
+
out.fill = v3;
|
|
46638
|
+
}
|
|
46639
|
+
}
|
|
46640
|
+
return out;
|
|
46641
|
+
}
|
|
46642
|
+
};
|
|
45972
46643
|
}
|
|
45973
46644
|
});
|
|
45974
46645
|
|
|
@@ -53651,36 +54322,2786 @@ var require_dagre = __commonJS({
|
|
|
53651
54322
|
});
|
|
53652
54323
|
|
|
53653
54324
|
// node_modules/@probelabs/maid/out/renderer/layout.js
|
|
53654
|
-
var import_dagre;
|
|
54325
|
+
var import_dagre, DagreLayoutEngine;
|
|
53655
54326
|
var init_layout = __esm({
|
|
53656
54327
|
"node_modules/@probelabs/maid/out/renderer/layout.js"() {
|
|
53657
54328
|
import_dagre = __toESM(require_dagre(), 1);
|
|
54329
|
+
DagreLayoutEngine = class {
|
|
54330
|
+
constructor() {
|
|
54331
|
+
this.nodeWidth = 120;
|
|
54332
|
+
this.nodeHeight = 50;
|
|
54333
|
+
this.rankSep = 50;
|
|
54334
|
+
this.nodeSep = 50;
|
|
54335
|
+
this.edgeSep = 10;
|
|
54336
|
+
}
|
|
54337
|
+
layout(graph) {
|
|
54338
|
+
const g3 = new import_dagre.default.graphlib.Graph();
|
|
54339
|
+
const hasClusters = !!(graph.subgraphs && graph.subgraphs.length > 0);
|
|
54340
|
+
const dir = this.mapDirection(graph.direction);
|
|
54341
|
+
let ranksep = this.rankSep;
|
|
54342
|
+
let nodesep = this.nodeSep;
|
|
54343
|
+
if (hasClusters) {
|
|
54344
|
+
if (dir === "LR" || dir === "RL") {
|
|
54345
|
+
ranksep += 20;
|
|
54346
|
+
nodesep += 70;
|
|
54347
|
+
} else {
|
|
54348
|
+
ranksep += 70;
|
|
54349
|
+
nodesep += 20;
|
|
54350
|
+
}
|
|
54351
|
+
}
|
|
54352
|
+
const graphConfig = {
|
|
54353
|
+
rankdir: dir,
|
|
54354
|
+
ranksep,
|
|
54355
|
+
nodesep,
|
|
54356
|
+
edgesep: this.edgeSep,
|
|
54357
|
+
marginx: 20,
|
|
54358
|
+
marginy: 20
|
|
54359
|
+
};
|
|
54360
|
+
if (hasClusters && (dir === "LR" || dir === "RL")) {
|
|
54361
|
+
graphConfig.ranker = "longest-path";
|
|
54362
|
+
graphConfig.acyclicer = "greedy";
|
|
54363
|
+
}
|
|
54364
|
+
if (hasClusters) {
|
|
54365
|
+
graphConfig.compound = true;
|
|
54366
|
+
}
|
|
54367
|
+
g3.setGraph(graphConfig);
|
|
54368
|
+
g3.setDefaultEdgeLabel(() => ({}));
|
|
54369
|
+
if (graph.subgraphs && graph.subgraphs.length > 0) {
|
|
54370
|
+
for (const subgraph of graph.subgraphs) {
|
|
54371
|
+
g3.setNode(subgraph.id, { label: subgraph.label || subgraph.id, clusterLabelPos: "top" });
|
|
54372
|
+
}
|
|
54373
|
+
}
|
|
54374
|
+
for (const node of graph.nodes) {
|
|
54375
|
+
const dimensions = this.calculateNodeDimensions(node.label, node.shape);
|
|
54376
|
+
g3.setNode(node.id, {
|
|
54377
|
+
width: dimensions.width,
|
|
54378
|
+
height: dimensions.height,
|
|
54379
|
+
label: node.label,
|
|
54380
|
+
shape: node.shape
|
|
54381
|
+
});
|
|
54382
|
+
}
|
|
54383
|
+
if (graph.subgraphs && graph.subgraphs.length > 0) {
|
|
54384
|
+
for (const subgraph of graph.subgraphs) {
|
|
54385
|
+
for (const nodeId of subgraph.nodes) {
|
|
54386
|
+
if (g3.hasNode(nodeId)) {
|
|
54387
|
+
try {
|
|
54388
|
+
g3.setParent(nodeId, subgraph.id);
|
|
54389
|
+
} catch {
|
|
54390
|
+
}
|
|
54391
|
+
}
|
|
54392
|
+
}
|
|
54393
|
+
if (subgraph.parent && g3.hasNode(subgraph.parent)) {
|
|
54394
|
+
try {
|
|
54395
|
+
g3.setParent(subgraph.id, subgraph.parent);
|
|
54396
|
+
} catch {
|
|
54397
|
+
}
|
|
54398
|
+
}
|
|
54399
|
+
}
|
|
54400
|
+
}
|
|
54401
|
+
for (const edge of graph.edges) {
|
|
54402
|
+
g3.setEdge(edge.source, edge.target, {
|
|
54403
|
+
label: edge.label,
|
|
54404
|
+
width: edge.label ? edge.label.length * 8 : 0,
|
|
54405
|
+
height: edge.label ? 20 : 0
|
|
54406
|
+
});
|
|
54407
|
+
}
|
|
54408
|
+
import_dagre.default.layout(g3);
|
|
54409
|
+
const graphInfo = g3.graph();
|
|
54410
|
+
const layoutNodes = [];
|
|
54411
|
+
const layoutEdges = [];
|
|
54412
|
+
for (const node of graph.nodes) {
|
|
54413
|
+
const nodeLayout = g3.node(node.id);
|
|
54414
|
+
if (nodeLayout) {
|
|
54415
|
+
layoutNodes.push({
|
|
54416
|
+
...node,
|
|
54417
|
+
x: nodeLayout.x - nodeLayout.width / 2,
|
|
54418
|
+
y: nodeLayout.y - nodeLayout.height / 2,
|
|
54419
|
+
width: nodeLayout.width,
|
|
54420
|
+
height: nodeLayout.height
|
|
54421
|
+
});
|
|
54422
|
+
}
|
|
54423
|
+
}
|
|
54424
|
+
const layoutSubgraphs = [];
|
|
54425
|
+
if (graph.subgraphs && graph.subgraphs.length > 0) {
|
|
54426
|
+
for (const sg of graph.subgraphs) {
|
|
54427
|
+
const members = layoutNodes.filter((nd) => sg.nodes.includes(nd.id));
|
|
54428
|
+
if (members.length) {
|
|
54429
|
+
const minX = Math.min(...members.map((m3) => m3.x));
|
|
54430
|
+
const minY = Math.min(...members.map((m3) => m3.y));
|
|
54431
|
+
const maxX = Math.max(...members.map((m3) => m3.x + m3.width));
|
|
54432
|
+
const maxY = Math.max(...members.map((m3) => m3.y + m3.height));
|
|
54433
|
+
const pad = 30;
|
|
54434
|
+
layoutSubgraphs.push({
|
|
54435
|
+
id: sg.id,
|
|
54436
|
+
label: sg.label || sg.id,
|
|
54437
|
+
x: minX - pad,
|
|
54438
|
+
y: minY - pad - 18,
|
|
54439
|
+
// space for title
|
|
54440
|
+
width: maxX - minX + pad * 2,
|
|
54441
|
+
height: maxY - minY + pad * 2 + 18,
|
|
54442
|
+
parent: sg.parent
|
|
54443
|
+
});
|
|
54444
|
+
}
|
|
54445
|
+
}
|
|
54446
|
+
const byId = Object.fromEntries(layoutSubgraphs.map((s3) => [s3.id, s3]));
|
|
54447
|
+
for (const sg of layoutSubgraphs) {
|
|
54448
|
+
if (!sg.parent)
|
|
54449
|
+
continue;
|
|
54450
|
+
const p3 = byId[sg.parent];
|
|
54451
|
+
if (!p3)
|
|
54452
|
+
continue;
|
|
54453
|
+
const minX = Math.min(p3.x, sg.x);
|
|
54454
|
+
const minY = Math.min(p3.y, sg.y);
|
|
54455
|
+
const maxX = Math.max(p3.x + p3.width, sg.x + sg.width);
|
|
54456
|
+
const maxY = Math.max(p3.y + p3.height, sg.y + sg.height);
|
|
54457
|
+
p3.x = minX;
|
|
54458
|
+
p3.y = minY;
|
|
54459
|
+
p3.width = maxX - minX;
|
|
54460
|
+
p3.height = maxY - minY;
|
|
54461
|
+
}
|
|
54462
|
+
}
|
|
54463
|
+
const subgraphById = Object.fromEntries(layoutSubgraphs.map((sg) => [sg.id, sg]));
|
|
54464
|
+
for (const edge of graph.edges) {
|
|
54465
|
+
const edgeLayout = g3.edge(edge.source, edge.target);
|
|
54466
|
+
let pts = edgeLayout && Array.isArray(edgeLayout.points) ? edgeLayout.points.slice() : [];
|
|
54467
|
+
const hasNaN = pts.some((p3) => !Number.isFinite(p3.x) || !Number.isFinite(p3.y));
|
|
54468
|
+
const srcSg = subgraphById[edge.source];
|
|
54469
|
+
const dstSg = subgraphById[edge.target];
|
|
54470
|
+
let synthesized = false;
|
|
54471
|
+
if (!pts.length || hasNaN || srcSg || dstSg) {
|
|
54472
|
+
const rankdir = this.mapDirection(graph.direction);
|
|
54473
|
+
const getNode = (id) => {
|
|
54474
|
+
const n3 = g3.node(id);
|
|
54475
|
+
if (!n3)
|
|
54476
|
+
return void 0;
|
|
54477
|
+
return {
|
|
54478
|
+
id,
|
|
54479
|
+
label: n3.label || id,
|
|
54480
|
+
shape: n3.shape || "rectangle",
|
|
54481
|
+
x: n3.x - n3.width / 2,
|
|
54482
|
+
y: n3.y - n3.height / 2,
|
|
54483
|
+
width: n3.width,
|
|
54484
|
+
height: n3.height,
|
|
54485
|
+
style: {}
|
|
54486
|
+
};
|
|
54487
|
+
};
|
|
54488
|
+
const start = srcSg ? this.clusterAnchor(srcSg, rankdir, "out") : this.nodeAnchor(getNode(edge.source), rankdir, "out");
|
|
54489
|
+
const end = dstSg ? this.clusterAnchor(dstSg, rankdir, "in") : this.nodeAnchor(getNode(edge.target), rankdir, "in");
|
|
54490
|
+
if (start && end) {
|
|
54491
|
+
const PAD = 20;
|
|
54492
|
+
const horizontallyAdjacent = srcSg && dstSg && Math.abs(srcSg.x - dstSg.x) > Math.abs(srcSg.y - dstSg.y);
|
|
54493
|
+
const horizontalSubgraphs = horizontallyAdjacent;
|
|
54494
|
+
if (rankdir === "LR" || rankdir === "RL") {
|
|
54495
|
+
const outX = start.x + (rankdir === "LR" ? PAD : -PAD);
|
|
54496
|
+
const inX = end.x + (rankdir === "LR" ? -PAD : PAD);
|
|
54497
|
+
const startOut = { x: srcSg ? outX : start.x, y: start.y };
|
|
54498
|
+
const endPre = { x: dstSg ? inX : end.x, y: end.y };
|
|
54499
|
+
const alpha = 0.68;
|
|
54500
|
+
const midX = startOut.x + (endPre.x - startOut.x) * alpha;
|
|
54501
|
+
const m1 = { x: midX, y: startOut.y };
|
|
54502
|
+
const m22 = { x: midX, y: endPre.y };
|
|
54503
|
+
pts = dstSg ? [start, startOut, m1, m22, endPre] : [start, startOut, m1, m22, endPre, end];
|
|
54504
|
+
} else {
|
|
54505
|
+
if (horizontalSubgraphs && srcSg && dstSg) {
|
|
54506
|
+
const midY = (srcSg.y + srcSg.height / 2 + dstSg.y + dstSg.height / 2) / 2;
|
|
54507
|
+
if (srcSg.x < dstSg.x) {
|
|
54508
|
+
const startX = srcSg.x + srcSg.width;
|
|
54509
|
+
const endX = dstSg.x;
|
|
54510
|
+
pts = [{ x: startX, y: midY }, { x: endX, y: midY }];
|
|
54511
|
+
} else {
|
|
54512
|
+
const startX = srcSg.x;
|
|
54513
|
+
const endX = dstSg.x + dstSg.width;
|
|
54514
|
+
pts = [{ x: startX, y: midY }, { x: endX, y: midY }];
|
|
54515
|
+
}
|
|
54516
|
+
} else {
|
|
54517
|
+
const outY = start.y + (rankdir === "TD" ? PAD : -PAD);
|
|
54518
|
+
const inY = end.y + (rankdir === "TD" ? -PAD : PAD);
|
|
54519
|
+
const startOut = { x: start.x, y: srcSg ? outY : start.y };
|
|
54520
|
+
const endPre = { x: end.x, y: dstSg ? inY : end.y };
|
|
54521
|
+
const alpha = 0.68;
|
|
54522
|
+
const midY = startOut.y + (endPre.y - startOut.y) * alpha;
|
|
54523
|
+
const m1 = { x: startOut.x, y: midY };
|
|
54524
|
+
const m22 = { x: endPre.x, y: midY };
|
|
54525
|
+
pts = dstSg ? [start, startOut, m1, m22, endPre] : [start, startOut, m1, m22, endPre, end];
|
|
54526
|
+
}
|
|
54527
|
+
}
|
|
54528
|
+
synthesized = true;
|
|
54529
|
+
}
|
|
54530
|
+
}
|
|
54531
|
+
if (pts.length) {
|
|
54532
|
+
layoutEdges.push({ ...edge, points: pts, pathMode: synthesized ? "orthogonal" : "smooth" });
|
|
54533
|
+
}
|
|
54534
|
+
}
|
|
54535
|
+
const rawW = graphInfo.width;
|
|
54536
|
+
const rawH = graphInfo.height;
|
|
54537
|
+
const w3 = Number.isFinite(rawW) && rawW > 0 ? rawW : 800;
|
|
54538
|
+
const h3 = Number.isFinite(rawH) && rawH > 0 ? rawH : 600;
|
|
54539
|
+
return {
|
|
54540
|
+
nodes: layoutNodes,
|
|
54541
|
+
edges: layoutEdges,
|
|
54542
|
+
width: w3,
|
|
54543
|
+
height: h3,
|
|
54544
|
+
subgraphs: layoutSubgraphs
|
|
54545
|
+
};
|
|
54546
|
+
}
|
|
54547
|
+
mapDirection(direction) {
|
|
54548
|
+
switch (direction) {
|
|
54549
|
+
case "TB":
|
|
54550
|
+
case "TD":
|
|
54551
|
+
return "TB";
|
|
54552
|
+
case "BT":
|
|
54553
|
+
return "BT";
|
|
54554
|
+
case "LR":
|
|
54555
|
+
return "LR";
|
|
54556
|
+
case "RL":
|
|
54557
|
+
return "RL";
|
|
54558
|
+
default:
|
|
54559
|
+
return "TB";
|
|
54560
|
+
}
|
|
54561
|
+
}
|
|
54562
|
+
calculateNodeDimensions(label, shape) {
|
|
54563
|
+
const charWidth = 7;
|
|
54564
|
+
const padding = 20;
|
|
54565
|
+
const minWidth = 80;
|
|
54566
|
+
const minHeight = 40;
|
|
54567
|
+
const maxWidth = 240;
|
|
54568
|
+
const lineHeight = 18;
|
|
54569
|
+
const explicitLines = label.split(/<\s*br\s*\/?\s*>/i);
|
|
54570
|
+
const hasExplicitBreaks = explicitLines.length > 1;
|
|
54571
|
+
let width;
|
|
54572
|
+
let lines;
|
|
54573
|
+
if (hasExplicitBreaks) {
|
|
54574
|
+
const maxLineLength = Math.max(...explicitLines.map((line) => line.length));
|
|
54575
|
+
width = Math.min(Math.max(maxLineLength * charWidth + padding * 2, minWidth), maxWidth);
|
|
54576
|
+
lines = explicitLines.length;
|
|
54577
|
+
} else {
|
|
54578
|
+
width = Math.min(Math.max(label.length * charWidth + padding * 2, minWidth), maxWidth);
|
|
54579
|
+
const charsPerLine = Math.max(1, Math.floor((width - padding * 2) / charWidth));
|
|
54580
|
+
lines = Math.ceil(label.length / charsPerLine);
|
|
54581
|
+
}
|
|
54582
|
+
let height = Math.max(lines * lineHeight + padding, minHeight);
|
|
54583
|
+
switch (shape) {
|
|
54584
|
+
case "circle":
|
|
54585
|
+
const size = Math.max(width, height);
|
|
54586
|
+
width = size;
|
|
54587
|
+
height = size;
|
|
54588
|
+
break;
|
|
54589
|
+
case "diamond": {
|
|
54590
|
+
const size2 = Math.max(width, height) * 1.2;
|
|
54591
|
+
width = size2;
|
|
54592
|
+
height = size2;
|
|
54593
|
+
break;
|
|
54594
|
+
}
|
|
54595
|
+
case "hexagon":
|
|
54596
|
+
width *= 1.3;
|
|
54597
|
+
height *= 1.2;
|
|
54598
|
+
break;
|
|
54599
|
+
case "stadium":
|
|
54600
|
+
width *= 1.2;
|
|
54601
|
+
break;
|
|
54602
|
+
case "cylinder":
|
|
54603
|
+
height *= 1.5;
|
|
54604
|
+
break;
|
|
54605
|
+
case "subroutine":
|
|
54606
|
+
case "double":
|
|
54607
|
+
width += 10;
|
|
54608
|
+
height += 10;
|
|
54609
|
+
break;
|
|
54610
|
+
case "parallelogram":
|
|
54611
|
+
case "trapezoid":
|
|
54612
|
+
width *= 1.3;
|
|
54613
|
+
break;
|
|
54614
|
+
}
|
|
54615
|
+
return { width: Math.round(width), height: Math.round(height) };
|
|
54616
|
+
}
|
|
54617
|
+
clusterAnchor(sg, rankdir, mode) {
|
|
54618
|
+
switch (rankdir) {
|
|
54619
|
+
case "LR":
|
|
54620
|
+
return { x: mode === "out" ? sg.x + sg.width : sg.x, y: sg.y + sg.height / 2 };
|
|
54621
|
+
case "RL":
|
|
54622
|
+
return { x: mode === "out" ? sg.x : sg.x + sg.width, y: sg.y + sg.height / 2 };
|
|
54623
|
+
case "BT":
|
|
54624
|
+
return { x: sg.x + sg.width / 2, y: mode === "out" ? sg.y : sg.y + sg.height };
|
|
54625
|
+
case "TB":
|
|
54626
|
+
default:
|
|
54627
|
+
return { x: sg.x + sg.width / 2, y: mode === "out" ? sg.y + sg.height : sg.y };
|
|
54628
|
+
}
|
|
54629
|
+
}
|
|
54630
|
+
nodeAnchor(n3, rankdir, mode) {
|
|
54631
|
+
if (!n3)
|
|
54632
|
+
return { x: 0, y: 0 };
|
|
54633
|
+
switch (rankdir) {
|
|
54634
|
+
case "LR":
|
|
54635
|
+
return { x: mode === "in" ? n3.x : n3.x + n3.width, y: n3.y + n3.height / 2 };
|
|
54636
|
+
case "RL":
|
|
54637
|
+
return { x: mode === "in" ? n3.x + n3.width : n3.x, y: n3.y + n3.height / 2 };
|
|
54638
|
+
case "BT":
|
|
54639
|
+
return { x: n3.x + n3.width / 2, y: mode === "in" ? n3.y + n3.height : n3.y };
|
|
54640
|
+
case "TB":
|
|
54641
|
+
default:
|
|
54642
|
+
return { x: n3.x + n3.width / 2, y: mode === "in" ? n3.y : n3.y + n3.height };
|
|
54643
|
+
}
|
|
54644
|
+
}
|
|
54645
|
+
};
|
|
54646
|
+
}
|
|
54647
|
+
});
|
|
54648
|
+
|
|
54649
|
+
// node_modules/@probelabs/maid/out/renderer/arrow-utils.js
|
|
54650
|
+
function triangleAtEnd(start, end, color = "#333", length = 8, width = 6) {
|
|
54651
|
+
const vx = end.x - start.x;
|
|
54652
|
+
const vy = end.y - start.y;
|
|
54653
|
+
const len = Math.hypot(vx, vy) || 1;
|
|
54654
|
+
const ux = vx / len;
|
|
54655
|
+
const uy = vy / len;
|
|
54656
|
+
const nx = -uy;
|
|
54657
|
+
const ny = ux;
|
|
54658
|
+
const baseX = end.x - ux * length;
|
|
54659
|
+
const baseY = end.y - uy * length;
|
|
54660
|
+
const p2x = baseX + nx * (width / 2), p2y = baseY + ny * (width / 2);
|
|
54661
|
+
const p3x = baseX - nx * (width / 2), p3y = baseY - ny * (width / 2);
|
|
54662
|
+
return `<path d="M${end.x},${end.y} L${p2x},${p2y} L${p3x},${p3y} Z" fill="${color}" />`;
|
|
54663
|
+
}
|
|
54664
|
+
function triangleAtStart(first2, second, color = "#333", length = 8, width = 6) {
|
|
54665
|
+
const vx = second.x - first2.x;
|
|
54666
|
+
const vy = second.y - first2.y;
|
|
54667
|
+
const len = Math.hypot(vx, vy) || 1;
|
|
54668
|
+
const ux = vx / len;
|
|
54669
|
+
const uy = vy / len;
|
|
54670
|
+
const nx = -uy;
|
|
54671
|
+
const ny = ux;
|
|
54672
|
+
const tipX = first2.x - ux * length;
|
|
54673
|
+
const tipY = first2.y - uy * length;
|
|
54674
|
+
const p2x = first2.x + nx * (width / 2), p2y = first2.y + ny * (width / 2);
|
|
54675
|
+
const p3x = first2.x - nx * (width / 2), p3y = first2.y - ny * (width / 2);
|
|
54676
|
+
return `<path d="M${tipX},${tipY} L${p2x},${p2y} L${p3x},${p3y} Z" fill="${color}" />`;
|
|
54677
|
+
}
|
|
54678
|
+
var init_arrow_utils = __esm({
|
|
54679
|
+
"node_modules/@probelabs/maid/out/renderer/arrow-utils.js"() {
|
|
54680
|
+
}
|
|
54681
|
+
});
|
|
54682
|
+
|
|
54683
|
+
// node_modules/@probelabs/maid/out/renderer/styles.js
|
|
54684
|
+
function buildSharedCss(opts = {}) {
|
|
54685
|
+
const fontFamily = opts.fontFamily || "Arial, sans-serif";
|
|
54686
|
+
const fontSize = opts.fontSize ?? 14;
|
|
54687
|
+
const nodeFill = opts.nodeFill || "#eef0ff";
|
|
54688
|
+
const nodeStroke = opts.nodeStroke || "#3f3f3f";
|
|
54689
|
+
const edgeStroke = opts.edgeStroke || "#555555";
|
|
54690
|
+
return `
|
|
54691
|
+
.node-shape { fill: ${nodeFill}; stroke: ${nodeStroke}; stroke-width: 1px; }
|
|
54692
|
+
.node-label { fill: #333; font-family: ${fontFamily}; font-size: ${fontSize}px; }
|
|
54693
|
+
.edge-path { stroke: ${edgeStroke}; stroke-width: 2px; fill: none; }
|
|
54694
|
+
.edge-label-bg { fill: rgba(232,232,232, 0.8); opacity: 0.5; }
|
|
54695
|
+
.edge-label-text { fill: #333; font-family: ${fontFamily}; font-size: ${Math.max(10, fontSize - 2)}px; }
|
|
54696
|
+
|
|
54697
|
+
/* Cluster (flowchart + sequence blocks) */
|
|
54698
|
+
.cluster-bg { fill: #ffffde; }
|
|
54699
|
+
.cluster-border { fill: none; stroke: #aaaa33; stroke-width: 1px; }
|
|
54700
|
+
.cluster-title-bg { fill: rgba(255,255,255,0.8); }
|
|
54701
|
+
.cluster-label-text { fill: #333; font-family: ${fontFamily}; font-size: 12px; }
|
|
54702
|
+
|
|
54703
|
+
/* Notes */
|
|
54704
|
+
.note { fill: #fff5ad; stroke: #aaaa33; stroke-width: 1px; }
|
|
54705
|
+
.note-text { fill: #333; font-family: ${fontFamily}; font-size: 12px; }
|
|
54706
|
+
|
|
54707
|
+
/* Sequence-specific add-ons (safe for flowcharts too) */
|
|
54708
|
+
.actor-rect { fill: #eaeaea; stroke: #666; stroke-width: 1.5px; }
|
|
54709
|
+
.actor-label { fill: #111; font-family: ${fontFamily}; font-size: 16px; }
|
|
54710
|
+
.lifeline { stroke: #999; stroke-width: 0.5px; }
|
|
54711
|
+
.activation { fill: #f4f4f4; stroke: #666; stroke-width: 1px; }
|
|
54712
|
+
.msg-line { stroke: #333; stroke-width: 1.5px; fill: none; }
|
|
54713
|
+
.msg-line.dotted { stroke-dasharray: 2 2; }
|
|
54714
|
+
.msg-line.thick { stroke-width: 3px; }
|
|
54715
|
+
.msg-label { fill: #333; font-family: ${fontFamily}; font-size: 12px; dominant-baseline: middle; }
|
|
54716
|
+
.msg-label-bg { fill: #ffffff; stroke: #cccccc; stroke-width: 1px; rx: 3; }
|
|
54717
|
+
`;
|
|
54718
|
+
}
|
|
54719
|
+
var init_styles = __esm({
|
|
54720
|
+
"node_modules/@probelabs/maid/out/renderer/styles.js"() {
|
|
54721
|
+
}
|
|
54722
|
+
});
|
|
54723
|
+
|
|
54724
|
+
// node_modules/@probelabs/maid/out/renderer/utils.js
|
|
54725
|
+
function escapeXml(text) {
|
|
54726
|
+
return String(text).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """).replace(/'/g, "'");
|
|
54727
|
+
}
|
|
54728
|
+
function measureText(text, fontSize = 12) {
|
|
54729
|
+
const avg = 0.6 * fontSize;
|
|
54730
|
+
return Math.max(0, Math.round(text.length * avg));
|
|
54731
|
+
}
|
|
54732
|
+
function palette(index) {
|
|
54733
|
+
if (index < DEFAULT_PALETTE.length)
|
|
54734
|
+
return DEFAULT_PALETTE[index];
|
|
54735
|
+
const i3 = index - DEFAULT_PALETTE.length;
|
|
54736
|
+
const hue = i3 * 47 % 360;
|
|
54737
|
+
return `hsl(${hue} 60% 55%)`;
|
|
54738
|
+
}
|
|
54739
|
+
function formatNumber(n3) {
|
|
54740
|
+
if (Number.isInteger(n3))
|
|
54741
|
+
return String(n3);
|
|
54742
|
+
return (Math.round(n3 * 100) / 100).toString();
|
|
54743
|
+
}
|
|
54744
|
+
function formatPercent(value, total) {
|
|
54745
|
+
if (!(total > 0))
|
|
54746
|
+
return "0%";
|
|
54747
|
+
const p3 = value / total * 100;
|
|
54748
|
+
return `${Math.round(p3)}%`;
|
|
54749
|
+
}
|
|
54750
|
+
var DEFAULT_PALETTE;
|
|
54751
|
+
var init_utils4 = __esm({
|
|
54752
|
+
"node_modules/@probelabs/maid/out/renderer/utils.js"() {
|
|
54753
|
+
DEFAULT_PALETTE = [
|
|
54754
|
+
"#ECECFF",
|
|
54755
|
+
"#ffffde",
|
|
54756
|
+
"hsl(80, 100%, 56.2745098039%)",
|
|
54757
|
+
"hsl(240, 100%, 86.2745098039%)",
|
|
54758
|
+
"hsl(60, 100%, 63.5294117647%)",
|
|
54759
|
+
"hsl(80, 100%, 76.2745098039%)",
|
|
54760
|
+
"hsl(300, 100%, 76.2745098039%)",
|
|
54761
|
+
"hsl(180, 100%, 56.2745098039%)",
|
|
54762
|
+
"hsl(0, 100%, 56.2745098039%)",
|
|
54763
|
+
"hsl(300, 100%, 56.2745098039%)",
|
|
54764
|
+
"hsl(150, 100%, 56.2745098039%)",
|
|
54765
|
+
"hsl(0, 100%, 66.2745098039%)"
|
|
54766
|
+
];
|
|
53658
54767
|
}
|
|
53659
54768
|
});
|
|
53660
54769
|
|
|
53661
|
-
// node_modules/@probelabs/maid/out/renderer/
|
|
53662
|
-
|
|
53663
|
-
"
|
|
54770
|
+
// node_modules/@probelabs/maid/out/renderer/block-utils.js
|
|
54771
|
+
function blockBackground(x3, y2, width, height, radius = 0) {
|
|
54772
|
+
return `<g class="cluster-bg-layer" transform="translate(${x3},${y2})">
|
|
54773
|
+
<rect class="cluster-bg" x="0" y="0" width="${width}" height="${height}" rx="${radius}"/>
|
|
54774
|
+
</g>`;
|
|
54775
|
+
}
|
|
54776
|
+
function blockOverlay(x3, y2, width, height, title, branchYs = [], titleYOffset = 0, align = "center", branchAlign = "left", radius = 0) {
|
|
54777
|
+
const parts = [];
|
|
54778
|
+
parts.push(`<g class="cluster-overlay" transform="translate(${x3},${y2})">`);
|
|
54779
|
+
parts.push(`<rect class="cluster-border" x="0" y="0" width="${width}" height="${height}" rx="${radius}"/>`);
|
|
54780
|
+
const titleText = title ? escapeXml(title) : "";
|
|
54781
|
+
if (titleText) {
|
|
54782
|
+
const titleW = Math.max(24, measureText(titleText, 12) + 10);
|
|
54783
|
+
const yBg = -2 + titleYOffset;
|
|
54784
|
+
const yText = 11 + titleYOffset;
|
|
54785
|
+
if (align === "left") {
|
|
54786
|
+
const xBg = 6;
|
|
54787
|
+
parts.push(`<rect class="cluster-title-bg" x="${xBg}" y="${yBg}" width="${titleW}" height="18" rx="3"/>`);
|
|
54788
|
+
parts.push(`<text class="cluster-label-text" x="${xBg + 6}" y="${yText}" text-anchor="start">${titleText}</text>`);
|
|
54789
|
+
} else {
|
|
54790
|
+
const xBg = 6;
|
|
54791
|
+
parts.push(`<rect class="cluster-title-bg" x="${xBg}" y="${yBg}" width="${titleW}" height="18" rx="3"/>`);
|
|
54792
|
+
parts.push(`<text class="cluster-label-text" x="${xBg + titleW / 2}" y="${yText}" text-anchor="middle">${titleText}</text>`);
|
|
54793
|
+
}
|
|
54794
|
+
}
|
|
54795
|
+
for (const br of branchYs) {
|
|
54796
|
+
const yRel = br.y - y2;
|
|
54797
|
+
parts.push(`<line x1="0" y1="${yRel}" x2="${width}" y2="${yRel}" class="cluster-border" />`);
|
|
54798
|
+
if (br.title) {
|
|
54799
|
+
const text = escapeXml(br.title);
|
|
54800
|
+
const bw = Math.max(24, measureText(text, 12) + 10);
|
|
54801
|
+
const xBg = 6;
|
|
54802
|
+
parts.push(`<rect class="cluster-title-bg" x="${xBg}" y="${yRel - 10}" width="${bw}" height="18" rx="3"/>`);
|
|
54803
|
+
if (branchAlign === "left") {
|
|
54804
|
+
parts.push(`<text class="cluster-label-text" x="${xBg + 6}" y="${yRel + 1}" text-anchor="start">${text}</text>`);
|
|
54805
|
+
} else {
|
|
54806
|
+
parts.push(`<text class="cluster-label-text" x="${xBg + bw / 2}" y="${yRel + 1}" text-anchor="middle">${text}</text>`);
|
|
54807
|
+
}
|
|
54808
|
+
}
|
|
53664
54809
|
}
|
|
53665
|
-
|
|
53666
|
-
|
|
53667
|
-
|
|
53668
|
-
var
|
|
53669
|
-
"node_modules/@probelabs/maid/out/renderer/
|
|
54810
|
+
parts.push("</g>");
|
|
54811
|
+
return parts.join("\n");
|
|
54812
|
+
}
|
|
54813
|
+
var init_block_utils = __esm({
|
|
54814
|
+
"node_modules/@probelabs/maid/out/renderer/block-utils.js"() {
|
|
54815
|
+
init_utils4();
|
|
53670
54816
|
}
|
|
53671
54817
|
});
|
|
53672
54818
|
|
|
53673
|
-
// node_modules/@probelabs/maid/out/renderer/
|
|
53674
|
-
var
|
|
53675
|
-
|
|
53676
|
-
|
|
53677
|
-
|
|
53678
|
-
|
|
53679
|
-
|
|
53680
|
-
|
|
53681
|
-
|
|
53682
|
-
|
|
53683
|
-
|
|
54819
|
+
// node_modules/@probelabs/maid/out/renderer/svg-generator.js
|
|
54820
|
+
var SVGRenderer;
|
|
54821
|
+
var init_svg_generator = __esm({
|
|
54822
|
+
"node_modules/@probelabs/maid/out/renderer/svg-generator.js"() {
|
|
54823
|
+
init_arrow_utils();
|
|
54824
|
+
init_styles();
|
|
54825
|
+
init_block_utils();
|
|
54826
|
+
SVGRenderer = class {
|
|
54827
|
+
constructor() {
|
|
54828
|
+
this.padding = 20;
|
|
54829
|
+
this.fontSize = 14;
|
|
54830
|
+
this.fontFamily = "Arial, sans-serif";
|
|
54831
|
+
this.defaultStroke = "#3f3f3f";
|
|
54832
|
+
this.defaultFill = "#eef0ff";
|
|
54833
|
+
this.arrowStroke = "#555555";
|
|
54834
|
+
this.arrowMarkerSize = 9;
|
|
54835
|
+
}
|
|
54836
|
+
render(layout) {
|
|
54837
|
+
let minX = Infinity;
|
|
54838
|
+
let minY = Infinity;
|
|
54839
|
+
let maxX = -Infinity;
|
|
54840
|
+
let maxY = -Infinity;
|
|
54841
|
+
for (const n3 of layout.nodes) {
|
|
54842
|
+
minX = Math.min(minX, n3.x);
|
|
54843
|
+
minY = Math.min(minY, n3.y);
|
|
54844
|
+
maxX = Math.max(maxX, n3.x + n3.width);
|
|
54845
|
+
maxY = Math.max(maxY, n3.y + n3.height);
|
|
54846
|
+
}
|
|
54847
|
+
if (layout.subgraphs) {
|
|
54848
|
+
for (const sg of layout.subgraphs) {
|
|
54849
|
+
minX = Math.min(minX, sg.x);
|
|
54850
|
+
minY = Math.min(minY, sg.y);
|
|
54851
|
+
maxX = Math.max(maxX, sg.x + sg.width);
|
|
54852
|
+
maxY = Math.max(maxY, sg.y + sg.height);
|
|
54853
|
+
}
|
|
54854
|
+
}
|
|
54855
|
+
for (const e3 of layout.edges) {
|
|
54856
|
+
if (e3.points)
|
|
54857
|
+
for (const p3 of e3.points) {
|
|
54858
|
+
minX = Math.min(minX, p3.x);
|
|
54859
|
+
minY = Math.min(minY, p3.y);
|
|
54860
|
+
maxX = Math.max(maxX, p3.x);
|
|
54861
|
+
maxY = Math.max(maxY, p3.y);
|
|
54862
|
+
}
|
|
54863
|
+
}
|
|
54864
|
+
if (!isFinite(minX)) {
|
|
54865
|
+
minX = 0;
|
|
54866
|
+
}
|
|
54867
|
+
if (!isFinite(minY)) {
|
|
54868
|
+
minY = 0;
|
|
54869
|
+
}
|
|
54870
|
+
if (!isFinite(maxX)) {
|
|
54871
|
+
maxX = layout.width;
|
|
54872
|
+
}
|
|
54873
|
+
if (!isFinite(maxY)) {
|
|
54874
|
+
maxY = layout.height;
|
|
54875
|
+
}
|
|
54876
|
+
const extraPadX = Math.max(0, -Math.floor(minX) + 1);
|
|
54877
|
+
const extraPadY = Math.max(0, -Math.floor(minY) + 1);
|
|
54878
|
+
const padX = this.padding + extraPadX;
|
|
54879
|
+
const padY = this.padding + extraPadY;
|
|
54880
|
+
const bboxWidth = Math.ceil(maxX) - Math.min(0, Math.floor(minX));
|
|
54881
|
+
const bboxHeight = Math.ceil(maxY) - Math.min(0, Math.floor(minY));
|
|
54882
|
+
const width = bboxWidth + this.padding * 2 + extraPadX;
|
|
54883
|
+
const height = bboxHeight + this.padding * 2 + extraPadY;
|
|
54884
|
+
const elements = [];
|
|
54885
|
+
const overlays = [];
|
|
54886
|
+
elements.push(this.generateDefs());
|
|
54887
|
+
if (layout.subgraphs && layout.subgraphs.length) {
|
|
54888
|
+
const sgs = layout.subgraphs;
|
|
54889
|
+
const order = sgs.slice().sort((a3, b3) => (a3.parent ? 1 : 0) - (b3.parent ? 1 : 0));
|
|
54890
|
+
const map4 = new Map(order.map((o3) => [o3.id, o3]));
|
|
54891
|
+
const depthOf = (sg) => {
|
|
54892
|
+
let d3 = 0;
|
|
54893
|
+
let p3 = sg.parent;
|
|
54894
|
+
while (p3) {
|
|
54895
|
+
d3++;
|
|
54896
|
+
p3 = map4.get(p3)?.parent;
|
|
54897
|
+
}
|
|
54898
|
+
return d3;
|
|
54899
|
+
};
|
|
54900
|
+
const bgs = [];
|
|
54901
|
+
for (const sg of order) {
|
|
54902
|
+
const x3 = sg.x + padX;
|
|
54903
|
+
const y2 = sg.y + padY;
|
|
54904
|
+
bgs.push(blockBackground(x3, y2, sg.width, sg.height, 0));
|
|
54905
|
+
const depth = depthOf(sg);
|
|
54906
|
+
const title = sg.label ? this.escapeXml(sg.label) : void 0;
|
|
54907
|
+
const titleYOffset = 7 + depth * 12;
|
|
54908
|
+
overlays.push(blockOverlay(x3, y2, sg.width, sg.height, title, [], titleYOffset, "center", "left", 0));
|
|
54909
|
+
}
|
|
54910
|
+
elements.push(`<g class="subgraph-bg">${bgs.join("")}</g>`);
|
|
54911
|
+
}
|
|
54912
|
+
const nodeMap = {};
|
|
54913
|
+
for (const n3 of layout.nodes) {
|
|
54914
|
+
nodeMap[n3.id] = { x: n3.x + padX, y: n3.y + padY, width: n3.width, height: n3.height, shape: n3.shape };
|
|
54915
|
+
}
|
|
54916
|
+
if (layout.subgraphs && layout.subgraphs.length) {
|
|
54917
|
+
for (const sg of layout.subgraphs) {
|
|
54918
|
+
nodeMap[sg.id] = { x: sg.x + padX, y: sg.y + padY, width: sg.width, height: sg.height, shape: "rectangle" };
|
|
54919
|
+
}
|
|
54920
|
+
}
|
|
54921
|
+
for (const node of layout.nodes) {
|
|
54922
|
+
elements.push(this.generateNodeWithPad(node, padX, padY));
|
|
54923
|
+
}
|
|
54924
|
+
for (const edge of layout.edges) {
|
|
54925
|
+
const { path: path6, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
|
|
54926
|
+
elements.push(path6);
|
|
54927
|
+
if (overlay)
|
|
54928
|
+
overlays.push(overlay);
|
|
54929
|
+
}
|
|
54930
|
+
const bg = `<rect x="0" y="0" width="${width}" height="${height}" fill="#ffffff" />`;
|
|
54931
|
+
const sharedCss = buildSharedCss({
|
|
54932
|
+
fontFamily: this.fontFamily,
|
|
54933
|
+
fontSize: this.fontSize,
|
|
54934
|
+
nodeFill: this.defaultFill,
|
|
54935
|
+
nodeStroke: this.defaultStroke,
|
|
54936
|
+
edgeStroke: this.arrowStroke
|
|
54937
|
+
});
|
|
54938
|
+
const css = `<style>${sharedCss}</style>`;
|
|
54939
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
54940
|
+
${bg}
|
|
54941
|
+
${css}
|
|
54942
|
+
${elements.join("\n ")}
|
|
54943
|
+
${overlays.join("\n ")}
|
|
54944
|
+
</svg>`;
|
|
54945
|
+
}
|
|
54946
|
+
buildNodeStyleAttrs(style) {
|
|
54947
|
+
const decs = [];
|
|
54948
|
+
if (style.fill)
|
|
54949
|
+
decs.push(`fill:${style.fill}`);
|
|
54950
|
+
if (style.stroke)
|
|
54951
|
+
decs.push(`stroke:${style.stroke}`);
|
|
54952
|
+
if (style.strokeWidth != null)
|
|
54953
|
+
decs.push(`stroke-width:${style.strokeWidth}`);
|
|
54954
|
+
return decs.length ? `style="${decs.join(";")}"` : "";
|
|
54955
|
+
}
|
|
54956
|
+
buildNodeStrokeStyle(style) {
|
|
54957
|
+
const decs = [];
|
|
54958
|
+
if (style.stroke)
|
|
54959
|
+
decs.push(`stroke:${style.stroke}`);
|
|
54960
|
+
if (style.strokeWidth != null)
|
|
54961
|
+
decs.push(`stroke-width:${style.strokeWidth}`);
|
|
54962
|
+
return decs.length ? `style="${decs.join(";")}"` : "";
|
|
54963
|
+
}
|
|
54964
|
+
generateDefs() {
|
|
54965
|
+
const aw = Math.max(8, this.arrowMarkerSize + 2);
|
|
54966
|
+
const ah = Math.max(8, this.arrowMarkerSize + 2);
|
|
54967
|
+
const arefX = Math.max(6, aw);
|
|
54968
|
+
const arefY = Math.max(4, Math.round(ah / 2));
|
|
54969
|
+
return `<defs>
|
|
54970
|
+
<marker id="arrow" viewBox="0 0 ${aw} ${ah}" markerWidth="${aw}" markerHeight="${ah}" refX="${arefX}" refY="${arefY}" orient="auto" markerUnits="userSpaceOnUse">
|
|
54971
|
+
<path d="M0,0 L0,${ah} L${aw},${arefY} z" fill="${this.arrowStroke}" />
|
|
54972
|
+
</marker>
|
|
54973
|
+
<marker id="circle-marker" viewBox="0 0 9 9" markerWidth="9" markerHeight="9" refX="4.5" refY="4.5" orient="auto" markerUnits="userSpaceOnUse">
|
|
54974
|
+
<circle cx="4.5" cy="4.5" r="4.5" fill="${this.arrowStroke}" />
|
|
54975
|
+
</marker>
|
|
54976
|
+
<marker id="cross-marker" viewBox="0 0 12 12" markerWidth="12" markerHeight="12" refX="6" refY="6" orient="auto" markerUnits="userSpaceOnUse">
|
|
54977
|
+
<path d="M1.5,1.5 L10.5,10.5 M10.5,1.5 L1.5,10.5" stroke="${this.arrowStroke}" stroke-width="2.25" />
|
|
54978
|
+
</marker>
|
|
54979
|
+
</defs>`;
|
|
54980
|
+
}
|
|
54981
|
+
generateNodeWithPad(node, padX, padY) {
|
|
54982
|
+
const x3 = node.x + padX;
|
|
54983
|
+
const y2 = node.y + padY;
|
|
54984
|
+
const cx = x3 + node.width / 2;
|
|
54985
|
+
const cy = y2 + node.height / 2;
|
|
54986
|
+
let shape = "";
|
|
54987
|
+
let labelCenterY = cy;
|
|
54988
|
+
const strokeWidth = node.style?.strokeWidth ?? void 0;
|
|
54989
|
+
const stroke = node.style?.stroke ?? void 0;
|
|
54990
|
+
const fill = node.style?.fill ?? void 0;
|
|
54991
|
+
const styleAttr = this.buildNodeStyleAttrs({ stroke, strokeWidth, fill });
|
|
54992
|
+
switch (node.shape) {
|
|
54993
|
+
case "rectangle":
|
|
54994
|
+
shape = `<rect class="node-shape" ${styleAttr} x="${x3}" y="${y2}" width="${node.width}" height="${node.height}" rx="0" ry="0" />`;
|
|
54995
|
+
break;
|
|
54996
|
+
case "round":
|
|
54997
|
+
shape = `<rect class="node-shape" ${styleAttr} x="${x3}" y="${y2}" width="${node.width}" height="${node.height}" rx="5" ry="5" />`;
|
|
54998
|
+
break;
|
|
54999
|
+
case "stadium":
|
|
55000
|
+
const radius = node.height / 2;
|
|
55001
|
+
shape = `<rect class="node-shape" ${styleAttr} x="${x3}" y="${y2}" width="${node.width}" height="${node.height}" rx="${radius}" ry="${radius}" />`;
|
|
55002
|
+
break;
|
|
55003
|
+
case "circle":
|
|
55004
|
+
const r3 = Math.min(node.width, node.height) / 2;
|
|
55005
|
+
shape = `<circle class="node-shape" ${styleAttr} cx="${cx}" cy="${cy}" r="${r3}" />`;
|
|
55006
|
+
break;
|
|
55007
|
+
case "diamond": {
|
|
55008
|
+
const points = [
|
|
55009
|
+
`${cx},${y2}`,
|
|
55010
|
+
// top
|
|
55011
|
+
`${x3 + node.width},${cy}`,
|
|
55012
|
+
// right
|
|
55013
|
+
`${cx},${y2 + node.height}`,
|
|
55014
|
+
// bottom
|
|
55015
|
+
`${x3},${cy}`
|
|
55016
|
+
// left
|
|
55017
|
+
].join(" ");
|
|
55018
|
+
shape = `<polygon class="node-shape" ${styleAttr} points="${points}" />`;
|
|
55019
|
+
break;
|
|
55020
|
+
}
|
|
55021
|
+
case "hexagon": {
|
|
55022
|
+
const dx = node.width * 0.25;
|
|
55023
|
+
const points = [
|
|
55024
|
+
`${x3 + dx},${y2}`,
|
|
55025
|
+
// top-left
|
|
55026
|
+
`${x3 + node.width - dx},${y2}`,
|
|
55027
|
+
// top-right
|
|
55028
|
+
`${x3 + node.width},${cy}`,
|
|
55029
|
+
// right
|
|
55030
|
+
`${x3 + node.width - dx},${y2 + node.height}`,
|
|
55031
|
+
// bottom-right
|
|
55032
|
+
`${x3 + dx},${y2 + node.height}`,
|
|
55033
|
+
// bottom-left
|
|
55034
|
+
`${x3},${cy}`
|
|
55035
|
+
// left
|
|
55036
|
+
].join(" ");
|
|
55037
|
+
shape = `<polygon class="node-shape" ${styleAttr} points="${points}" />`;
|
|
55038
|
+
break;
|
|
55039
|
+
}
|
|
55040
|
+
case "parallelogram": {
|
|
55041
|
+
const skew = node.width * 0.15;
|
|
55042
|
+
const points = [
|
|
55043
|
+
`${x3 + skew},${y2}`,
|
|
55044
|
+
// top-left
|
|
55045
|
+
`${x3 + node.width},${y2}`,
|
|
55046
|
+
// top-right
|
|
55047
|
+
`${x3 + node.width - skew},${y2 + node.height}`,
|
|
55048
|
+
// bottom-right
|
|
55049
|
+
`${x3},${y2 + node.height}`
|
|
55050
|
+
// bottom-left
|
|
55051
|
+
].join(" ");
|
|
55052
|
+
shape = `<polygon class="node-shape" ${styleAttr} points="${points}" />`;
|
|
55053
|
+
break;
|
|
55054
|
+
}
|
|
55055
|
+
case "trapezoid": {
|
|
55056
|
+
const inset = node.width * 0.15;
|
|
55057
|
+
const points = [
|
|
55058
|
+
`${x3 + inset},${y2}`,
|
|
55059
|
+
// top-left
|
|
55060
|
+
`${x3 + node.width - inset},${y2}`,
|
|
55061
|
+
// top-right
|
|
55062
|
+
`${x3 + node.width},${y2 + node.height}`,
|
|
55063
|
+
// bottom-right
|
|
55064
|
+
`${x3},${y2 + node.height}`
|
|
55065
|
+
// bottom-left
|
|
55066
|
+
].join(" ");
|
|
55067
|
+
shape = `<polygon class="node-shape" ${styleAttr} points="${points}" />`;
|
|
55068
|
+
break;
|
|
55069
|
+
}
|
|
55070
|
+
case "trapezoidAlt": {
|
|
55071
|
+
const inset = node.width * 0.15;
|
|
55072
|
+
const points = [
|
|
55073
|
+
`${x3},${y2}`,
|
|
55074
|
+
// top-left (full width)
|
|
55075
|
+
`${x3 + node.width},${y2}`,
|
|
55076
|
+
// top-right
|
|
55077
|
+
`${x3 + node.width - inset},${y2 + node.height}`,
|
|
55078
|
+
// bottom-right (narrow)
|
|
55079
|
+
`${x3 + inset},${y2 + node.height}`
|
|
55080
|
+
// bottom-left (narrow)
|
|
55081
|
+
].join(" ");
|
|
55082
|
+
shape = `<polygon class="node-shape" ${styleAttr} points="${points}" />`;
|
|
55083
|
+
break;
|
|
55084
|
+
}
|
|
55085
|
+
case "cylinder": {
|
|
55086
|
+
const rx = Math.max(8, node.width / 2);
|
|
55087
|
+
const ry = Math.max(6, Math.min(node.height * 0.22, node.width * 0.25));
|
|
55088
|
+
const topCY = y2 + ry;
|
|
55089
|
+
const botCY = y2 + node.height - ry;
|
|
55090
|
+
const bodyH = Math.max(0, node.height - ry * 2);
|
|
55091
|
+
const strokeOnly = this.buildNodeStrokeStyle({ stroke, strokeWidth });
|
|
55092
|
+
shape = `<g>
|
|
55093
|
+
<rect class="node-shape" ${styleAttr} x="${x3}" y="${topCY}" width="${node.width}" height="${bodyH}" />
|
|
55094
|
+
<ellipse class="node-shape" ${styleAttr} cx="${cx}" cy="${topCY}" rx="${node.width / 2}" ry="${ry}" />
|
|
55095
|
+
<path class="node-shape" ${strokeOnly} d="M${x3},${topCY} L${x3},${botCY} A${node.width / 2},${ry} 0 0,0 ${x3 + node.width},${botCY} L${x3 + node.width},${topCY}" fill="none" />
|
|
55096
|
+
</g>`;
|
|
55097
|
+
labelCenterY = topCY + bodyH / 2;
|
|
55098
|
+
break;
|
|
55099
|
+
}
|
|
55100
|
+
case "subroutine":
|
|
55101
|
+
const insetX = 5;
|
|
55102
|
+
const strokeOnly2 = this.buildNodeStrokeStyle({ stroke, strokeWidth });
|
|
55103
|
+
shape = `<g>
|
|
55104
|
+
<rect class="node-shape" ${styleAttr} x="${x3}" y="${y2}" width="${node.width}" height="${node.height}" rx="0" ry="0" />
|
|
55105
|
+
<line class="node-shape" ${strokeOnly2} x1="${x3 + insetX}" y1="${y2}" x2="${x3 + insetX}" y2="${y2 + node.height}" />
|
|
55106
|
+
<line class="node-shape" ${strokeOnly2} x1="${x3 + node.width - insetX}" y1="${y2}" x2="${x3 + node.width - insetX}" y2="${y2 + node.height}" />
|
|
55107
|
+
</g>`;
|
|
55108
|
+
break;
|
|
55109
|
+
case "double":
|
|
55110
|
+
const gap = 4;
|
|
55111
|
+
const strokeOnly3 = this.buildNodeStrokeStyle({ stroke, strokeWidth });
|
|
55112
|
+
shape = `<g>
|
|
55113
|
+
<rect class="node-shape" ${styleAttr} x="${x3}" y="${y2}" width="${node.width}" height="${node.height}" rx="0" ry="0" />
|
|
55114
|
+
<rect class="node-shape" ${strokeOnly3} x="${x3 + gap}" y="${y2 + gap}" width="${node.width - gap * 2}" height="${node.height - gap * 2}" rx="0" ry="0" fill="none" />
|
|
55115
|
+
</g>`;
|
|
55116
|
+
break;
|
|
55117
|
+
default:
|
|
55118
|
+
const s3 = this.buildNodeStyleAttrs({ stroke, strokeWidth, fill });
|
|
55119
|
+
shape = `<rect ${s3} x="${x3}" y="${y2}" width="${node.width}" height="${node.height}" rx="0" ry="0" />`;
|
|
55120
|
+
}
|
|
55121
|
+
const text = this.generateWrappedText(node.label, cx, labelCenterY, node.width - 20);
|
|
55122
|
+
return `<g id="${node.id}">
|
|
55123
|
+
${shape}
|
|
55124
|
+
${text}
|
|
55125
|
+
</g>`;
|
|
55126
|
+
}
|
|
55127
|
+
generateWrappedText(text, x3, y2, maxWidth) {
|
|
55128
|
+
if (text.includes("<")) {
|
|
55129
|
+
return this.generateRichText(text, x3, y2, maxWidth);
|
|
55130
|
+
}
|
|
55131
|
+
const charWidth = 7;
|
|
55132
|
+
const maxCharsPerLine = Math.floor(maxWidth / charWidth);
|
|
55133
|
+
if (maxCharsPerLine <= 0 || text.length <= maxCharsPerLine) {
|
|
55134
|
+
const dyOffset = this.fontSize * 0.35;
|
|
55135
|
+
return `<text class="node-label" x="${x3}" y="${y2 + dyOffset}" text-anchor="middle">${this.escapeXml(text)}</text>`;
|
|
55136
|
+
}
|
|
55137
|
+
const words = text.split(" ");
|
|
55138
|
+
const lines = [];
|
|
55139
|
+
let currentLine = "";
|
|
55140
|
+
for (const word of words) {
|
|
55141
|
+
const testLine = currentLine ? `${currentLine} ${word}` : word;
|
|
55142
|
+
if (testLine.length > maxCharsPerLine && currentLine) {
|
|
55143
|
+
lines.push(currentLine);
|
|
55144
|
+
currentLine = word;
|
|
55145
|
+
} else {
|
|
55146
|
+
currentLine = testLine;
|
|
55147
|
+
}
|
|
55148
|
+
}
|
|
55149
|
+
if (currentLine) {
|
|
55150
|
+
lines.push(currentLine);
|
|
55151
|
+
}
|
|
55152
|
+
const lineHeight = 18;
|
|
55153
|
+
const totalHeight = (lines.length - 1) * lineHeight;
|
|
55154
|
+
const startY = y2 - totalHeight / 2 + this.fontSize * 0.35;
|
|
55155
|
+
const tspans = lines.map((line, i3) => {
|
|
55156
|
+
const lineY = startY + i3 * lineHeight;
|
|
55157
|
+
return `<tspan x="${x3}" y="${lineY}" text-anchor="middle">${this.escapeXml(line)}</tspan>`;
|
|
55158
|
+
}).join("\n ");
|
|
55159
|
+
return `<text class="node-label">
|
|
55160
|
+
${tspans}
|
|
55161
|
+
</text>`;
|
|
55162
|
+
}
|
|
55163
|
+
// Basic HTML-aware text renderer supporting <br>, <b>/<strong>, <i>/<em>, <u>
|
|
55164
|
+
generateRichText(html, x3, y2, maxWidth) {
|
|
55165
|
+
html = this.normalizeHtml(html);
|
|
55166
|
+
const segments = [];
|
|
55167
|
+
const re = /<\/?(br|b|strong|i|em|u)\s*\/?\s*>/gi;
|
|
55168
|
+
let lastIndex = 0;
|
|
55169
|
+
const state2 = { bold: false, italic: false, underline: false };
|
|
55170
|
+
const pushText = (t3) => {
|
|
55171
|
+
if (!t3)
|
|
55172
|
+
return;
|
|
55173
|
+
segments.push({ text: this.htmlDecode(t3), bold: state2.bold, italic: state2.italic, underline: state2.underline });
|
|
55174
|
+
};
|
|
55175
|
+
let m3;
|
|
55176
|
+
while (m3 = re.exec(html)) {
|
|
55177
|
+
pushText(html.slice(lastIndex, m3.index));
|
|
55178
|
+
const tag2 = m3[0].toLowerCase();
|
|
55179
|
+
const name14 = m3[1].toLowerCase();
|
|
55180
|
+
const isClose = tag2.startsWith("</");
|
|
55181
|
+
if (name14 === "br") {
|
|
55182
|
+
segments.push({ text: "", br: true });
|
|
55183
|
+
} else if (name14 === "b" || name14 === "strong") {
|
|
55184
|
+
state2.bold = !isClose ? true : false;
|
|
55185
|
+
} else if (name14 === "i" || name14 === "em") {
|
|
55186
|
+
state2.italic = !isClose ? true : false;
|
|
55187
|
+
} else if (name14 === "u") {
|
|
55188
|
+
state2.underline = !isClose ? true : false;
|
|
55189
|
+
}
|
|
55190
|
+
lastIndex = re.lastIndex;
|
|
55191
|
+
}
|
|
55192
|
+
pushText(html.slice(lastIndex));
|
|
55193
|
+
const lines = [];
|
|
55194
|
+
const charWidth = 7;
|
|
55195
|
+
const maxCharsPerLine = Math.max(1, Math.floor(maxWidth / charWidth));
|
|
55196
|
+
let current = [];
|
|
55197
|
+
let currentLen = 0;
|
|
55198
|
+
const flush = () => {
|
|
55199
|
+
if (current.length) {
|
|
55200
|
+
lines.push(current);
|
|
55201
|
+
current = [];
|
|
55202
|
+
currentLen = 0;
|
|
55203
|
+
}
|
|
55204
|
+
};
|
|
55205
|
+
const splitWords = (s3) => {
|
|
55206
|
+
if (!s3.text)
|
|
55207
|
+
return [s3];
|
|
55208
|
+
const words = s3.text.split(/(\s+)/);
|
|
55209
|
+
return words.map((w3) => ({ ...s3, text: w3 }));
|
|
55210
|
+
};
|
|
55211
|
+
for (const seg of segments) {
|
|
55212
|
+
if (seg.br) {
|
|
55213
|
+
flush();
|
|
55214
|
+
continue;
|
|
55215
|
+
}
|
|
55216
|
+
for (const w3 of splitWords(seg)) {
|
|
55217
|
+
const wlen = w3.text.length;
|
|
55218
|
+
if (currentLen + wlen > maxCharsPerLine && currentLen > 0) {
|
|
55219
|
+
flush();
|
|
55220
|
+
}
|
|
55221
|
+
current.push(w3);
|
|
55222
|
+
currentLen += wlen;
|
|
55223
|
+
}
|
|
55224
|
+
}
|
|
55225
|
+
flush();
|
|
55226
|
+
const lineHeight = 18;
|
|
55227
|
+
const totalHeight = (lines.length - 1) * lineHeight;
|
|
55228
|
+
const startY = y2 - totalHeight / 2 + this.fontSize * 0.35;
|
|
55229
|
+
const tspans = [];
|
|
55230
|
+
for (let i3 = 0; i3 < lines.length; i3++) {
|
|
55231
|
+
const lineY = startY + i3 * lineHeight;
|
|
55232
|
+
let acc = "";
|
|
55233
|
+
let cursorX = x3;
|
|
55234
|
+
const inner = [];
|
|
55235
|
+
let buffer = "";
|
|
55236
|
+
let style = { bold: false, italic: false, underline: false };
|
|
55237
|
+
const flushInline = () => {
|
|
55238
|
+
if (!buffer)
|
|
55239
|
+
return;
|
|
55240
|
+
const styleAttr = `${style.bold ? 'font-weight="bold" ' : ""}${style.italic ? 'font-style="italic" ' : ""}${style.underline ? 'text-decoration="underline" ' : ""}`;
|
|
55241
|
+
inner.push(`<tspan ${styleAttr}>${this.escapeXml(buffer)}</tspan>`);
|
|
55242
|
+
buffer = "";
|
|
55243
|
+
};
|
|
55244
|
+
for (const w3 of lines[i3]) {
|
|
55245
|
+
const wStyle = { bold: !!w3.bold, italic: !!w3.italic, underline: !!w3.underline };
|
|
55246
|
+
if (wStyle.bold !== style.bold || wStyle.italic !== style.italic || wStyle.underline !== style.underline) {
|
|
55247
|
+
flushInline();
|
|
55248
|
+
style = wStyle;
|
|
55249
|
+
}
|
|
55250
|
+
buffer += w3.text;
|
|
55251
|
+
}
|
|
55252
|
+
flushInline();
|
|
55253
|
+
tspans.push(`<tspan x="${x3}" y="${lineY}" text-anchor="middle">${inner.join("")}</tspan>`);
|
|
55254
|
+
}
|
|
55255
|
+
return `<text font-family="${this.fontFamily}" font-size="${this.fontSize}" fill="#333">${tspans.join("\n ")}</text>`;
|
|
55256
|
+
}
|
|
55257
|
+
normalizeHtml(s3) {
|
|
55258
|
+
let out = s3.replace(/<\s+/g, "<").replace(/\s+>/g, ">").replace(/<\s*\//g, "</").replace(/\s*\/\s*>/g, "/>").replace(/<\s*(br)\s*>/gi, "<$1/>");
|
|
55259
|
+
return out;
|
|
55260
|
+
}
|
|
55261
|
+
htmlDecode(s3) {
|
|
55262
|
+
return s3.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
55263
|
+
}
|
|
55264
|
+
generateEdge(edge, padX, padY, nodeMap) {
|
|
55265
|
+
if (!edge.points || edge.points.length < 2) {
|
|
55266
|
+
return { path: "" };
|
|
55267
|
+
}
|
|
55268
|
+
const points = edge.points.map((p3) => ({ x: p3.x + padX, y: p3.y + padY }));
|
|
55269
|
+
const segData = this.buildSmoothSegments(points);
|
|
55270
|
+
let strokeDasharray = "";
|
|
55271
|
+
let strokeWidth = 1.5;
|
|
55272
|
+
let markerEnd = "";
|
|
55273
|
+
let markerStart = "";
|
|
55274
|
+
switch (edge.type) {
|
|
55275
|
+
case "open":
|
|
55276
|
+
markerEnd = "";
|
|
55277
|
+
break;
|
|
55278
|
+
case "dotted":
|
|
55279
|
+
strokeDasharray = "3,3";
|
|
55280
|
+
break;
|
|
55281
|
+
case "thick":
|
|
55282
|
+
strokeWidth = 3;
|
|
55283
|
+
break;
|
|
55284
|
+
case "invisible":
|
|
55285
|
+
strokeDasharray = "0,100000";
|
|
55286
|
+
markerEnd = "";
|
|
55287
|
+
break;
|
|
55288
|
+
}
|
|
55289
|
+
const mStart = edge.markerStart;
|
|
55290
|
+
const mEnd = edge.markerEnd;
|
|
55291
|
+
const sourceNode = nodeMap[edge.source];
|
|
55292
|
+
const targetNode = nodeMap[edge.target];
|
|
55293
|
+
let boundaryStart = points[0];
|
|
55294
|
+
let boundaryEnd = points[points.length - 1];
|
|
55295
|
+
if (sourceNode && points.length >= 2) {
|
|
55296
|
+
const pseudo = { start: points[0], segs: [{ c1: points[1], c2: points[Math.max(0, points.length - 2)], to: points[points.length - 1] }] };
|
|
55297
|
+
boundaryStart = this.intersectSegmentsStart(pseudo, sourceNode).start;
|
|
55298
|
+
}
|
|
55299
|
+
if (targetNode && points.length >= 2) {
|
|
55300
|
+
const pseudo = { start: points[0], segs: [{ c1: points[1], c2: points[Math.max(0, points.length - 2)], to: points[points.length - 1] }] };
|
|
55301
|
+
const after = this.intersectSegmentsEnd(pseudo, targetNode);
|
|
55302
|
+
boundaryEnd = after.segs.length ? after.segs[after.segs.length - 1].to : boundaryEnd;
|
|
55303
|
+
}
|
|
55304
|
+
const pathParts = [];
|
|
55305
|
+
pathParts.push(`M${boundaryStart.x},${boundaryStart.y}`);
|
|
55306
|
+
let startFlat = points.length >= 2 ? points[1] : boundaryStart;
|
|
55307
|
+
if (points.length >= 2) {
|
|
55308
|
+
const svx = points[1].x - boundaryStart.x;
|
|
55309
|
+
const svy = points[1].y - boundaryStart.y;
|
|
55310
|
+
const slen = Math.hypot(svx, svy) || 1;
|
|
55311
|
+
const SFLAT = Math.min(22, Math.max(10, slen * 0.15));
|
|
55312
|
+
startFlat = { x: boundaryStart.x + svx / slen * SFLAT, y: boundaryStart.y + svy / slen * SFLAT };
|
|
55313
|
+
pathParts.push(`L${startFlat.x},${startFlat.y}`);
|
|
55314
|
+
}
|
|
55315
|
+
const orthogonal = edge.pathMode === "orthogonal";
|
|
55316
|
+
if (points.length >= 4 && !orthogonal) {
|
|
55317
|
+
const pts = [points[0], ...points, points[points.length - 1]];
|
|
55318
|
+
for (let i3 = 1; i3 < pts.length - 3; i3++) {
|
|
55319
|
+
const p0 = pts[i3 - 1];
|
|
55320
|
+
const p1 = pts[i3];
|
|
55321
|
+
const p22 = pts[i3 + 1];
|
|
55322
|
+
const p3 = pts[i3 + 2];
|
|
55323
|
+
const c1x = p1.x + (p22.x - p0.x) / 6;
|
|
55324
|
+
const c1y = p1.y + (p22.y - p0.y) / 6;
|
|
55325
|
+
const c2x = p22.x - (p3.x - p1.x) / 6;
|
|
55326
|
+
const c2y = p22.y - (p3.y - p1.y) / 6;
|
|
55327
|
+
pathParts.push(`C${c1x},${c1y} ${c2x},${c2y} ${p22.x},${p22.y}`);
|
|
55328
|
+
}
|
|
55329
|
+
pathParts.push(`L${boundaryEnd.x},${boundaryEnd.y}`);
|
|
55330
|
+
} else if (points.length === 3 && !orthogonal) {
|
|
55331
|
+
const p0 = boundaryStart, p1 = points[1], p22 = boundaryEnd;
|
|
55332
|
+
const ax = boundaryEnd.x - p1.x;
|
|
55333
|
+
const ay = boundaryEnd.y - p1.y;
|
|
55334
|
+
const alen = Math.hypot(ax, ay) || 1;
|
|
55335
|
+
const FLAT_IN = Math.min(20, Math.max(10, alen * 0.15));
|
|
55336
|
+
const preEnd = { x: boundaryEnd.x - ax / alen * FLAT_IN, y: boundaryEnd.y - ay / alen * FLAT_IN };
|
|
55337
|
+
const sdx = startFlat.x - boundaryStart.x;
|
|
55338
|
+
const sdy = startFlat.y - boundaryStart.y;
|
|
55339
|
+
const sdirx = sdx === 0 && sdy === 0 ? p1.x - p0.x : sdx;
|
|
55340
|
+
const sdiry = sdx === 0 && sdy === 0 ? p1.y - p0.y : sdy;
|
|
55341
|
+
const sdlen = Math.hypot(sdirx, sdiry) || 1;
|
|
55342
|
+
const c1len = Math.min(40, Math.max(12, sdlen * 1.2));
|
|
55343
|
+
const c1x = startFlat.x + sdirx / sdlen * c1len;
|
|
55344
|
+
const c1y = startFlat.y + sdiry / sdlen * c1len;
|
|
55345
|
+
const dirx = (boundaryEnd.x - p1.x) / alen;
|
|
55346
|
+
const diry = (boundaryEnd.y - p1.y) / alen;
|
|
55347
|
+
const c2x = preEnd.x - dirx * (FLAT_IN * 0.6);
|
|
55348
|
+
const c2y = preEnd.y - diry * (FLAT_IN * 0.6);
|
|
55349
|
+
pathParts.push(`C${c1x},${c1y} ${c2x},${c2y} ${preEnd.x},${preEnd.y}`);
|
|
55350
|
+
pathParts.push(`L${boundaryEnd.x},${boundaryEnd.y}`);
|
|
55351
|
+
} else {
|
|
55352
|
+
pathParts.push(`L${boundaryEnd.x},${boundaryEnd.y}`);
|
|
55353
|
+
}
|
|
55354
|
+
if (orthogonal) {
|
|
55355
|
+
pathParts.length = 0;
|
|
55356
|
+
pathParts.push(`M${boundaryStart.x},${boundaryStart.y}`);
|
|
55357
|
+
for (const p3 of points.slice(1, -1))
|
|
55358
|
+
pathParts.push(`L${p3.x},${p3.y}`);
|
|
55359
|
+
pathParts.push(`L${boundaryEnd.x},${boundaryEnd.y}`);
|
|
55360
|
+
}
|
|
55361
|
+
const pathData = pathParts.join(" ");
|
|
55362
|
+
let edgeElement = `<path class="edge-path" d="${pathData}" stroke-linecap="round" stroke-linejoin="round"`;
|
|
55363
|
+
if (strokeDasharray) {
|
|
55364
|
+
edgeElement += ` stroke-dasharray="${strokeDasharray}"`;
|
|
55365
|
+
}
|
|
55366
|
+
const startMarkUrl = mStart === "arrow" ? "url(#arrow)" : mStart === "circle" ? "url(#circle-marker)" : mStart === "cross" ? "url(#cross-marker)" : "";
|
|
55367
|
+
const endMarkUrl = mEnd === "arrow" ? "url(#arrow)" : mEnd === "circle" ? "url(#circle-marker)" : mEnd === "cross" ? "url(#cross-marker)" : markerEnd || "";
|
|
55368
|
+
if (startMarkUrl && mStart !== "arrow")
|
|
55369
|
+
edgeElement += ` marker-start="${startMarkUrl}"`;
|
|
55370
|
+
if (endMarkUrl && mEnd !== "arrow")
|
|
55371
|
+
edgeElement += ` marker-end="${endMarkUrl}"`;
|
|
55372
|
+
edgeElement += " />";
|
|
55373
|
+
if (edge.label) {
|
|
55374
|
+
const pos = this.pointAtRatio(points, 0.55);
|
|
55375
|
+
const text = this.escapeXml(edge.label);
|
|
55376
|
+
const padding = 4;
|
|
55377
|
+
const fontSize = this.fontSize - 3;
|
|
55378
|
+
const width = Math.max(18, Math.min(220, text.length * 6 + padding * 2));
|
|
55379
|
+
const height = 14;
|
|
55380
|
+
const x3 = pos.x - width / 2;
|
|
55381
|
+
const y2 = pos.y - height / 2;
|
|
55382
|
+
const labelBg = `<rect class="edge-label-bg" x="${x3}" y="${y2}" width="${width}" height="${height}" rx="3" />`;
|
|
55383
|
+
const labelText = `<text class="edge-label-text" x="${pos.x}" y="${pos.y}" text-anchor="middle" dominant-baseline="middle">${text}</text>`;
|
|
55384
|
+
let overlay2 = "";
|
|
55385
|
+
const prevEndL = points.length >= 2 ? points[points.length - 2] : boundaryEnd;
|
|
55386
|
+
const vxl = boundaryEnd.x - prevEndL.x;
|
|
55387
|
+
const vyl = boundaryEnd.y - prevEndL.y;
|
|
55388
|
+
const vlenl = Math.hypot(vxl, vyl) || 1;
|
|
55389
|
+
const uxl = vxl / vlenl;
|
|
55390
|
+
const uyl = vyl / vlenl;
|
|
55391
|
+
const nxl = -uyl;
|
|
55392
|
+
const nyl = uxl;
|
|
55393
|
+
const triLenL = 8;
|
|
55394
|
+
const triWL = 6;
|
|
55395
|
+
const p1xL = boundaryEnd.x, p1yL = boundaryEnd.y;
|
|
55396
|
+
const baseXL = boundaryEnd.x - uxl * triLenL;
|
|
55397
|
+
const baseYL = boundaryEnd.y - uyl * triLenL;
|
|
55398
|
+
const p2xL = baseXL + nxl * (triWL / 2), p2yL = baseYL + nyl * (triWL / 2);
|
|
55399
|
+
const p3xL = baseXL - nxl * (triWL / 2), p3yL = baseYL - nyl * (triWL / 2);
|
|
55400
|
+
overlay2 += triangleAtEnd(prevEndL, boundaryEnd, this.arrowStroke);
|
|
55401
|
+
if (mStart === "arrow" && points.length >= 2) {
|
|
55402
|
+
const firstLeg = points[1];
|
|
55403
|
+
const svx = boundaryStart.x - firstLeg.x;
|
|
55404
|
+
const svy = boundaryStart.y - firstLeg.y;
|
|
55405
|
+
const slen = Math.hypot(svx, svy) || 1;
|
|
55406
|
+
const sux = svx / slen;
|
|
55407
|
+
const suy = svy / slen;
|
|
55408
|
+
const snx = -suy;
|
|
55409
|
+
const sny = sux;
|
|
55410
|
+
const sbaseX = boundaryStart.x - sux * triLenL;
|
|
55411
|
+
const sbaseY = boundaryStart.y - suy * triLenL;
|
|
55412
|
+
overlay2 += triangleAtStart(boundaryStart, firstLeg, this.arrowStroke);
|
|
55413
|
+
}
|
|
55414
|
+
const pathGroup = `<g>
|
|
55415
|
+
${edgeElement}
|
|
55416
|
+
${labelBg}
|
|
55417
|
+
${labelText}
|
|
55418
|
+
${overlay2}
|
|
55419
|
+
</g>`;
|
|
55420
|
+
return { path: pathGroup };
|
|
55421
|
+
}
|
|
55422
|
+
let overlay = "";
|
|
55423
|
+
const prevEnd = points.length >= 2 ? points[points.length - 2] : boundaryEnd;
|
|
55424
|
+
const vx = boundaryEnd.x - prevEnd.x;
|
|
55425
|
+
const vy = boundaryEnd.y - prevEnd.y;
|
|
55426
|
+
const vlen = Math.hypot(vx, vy) || 1;
|
|
55427
|
+
const ux = vx / vlen;
|
|
55428
|
+
const uy = vy / vlen;
|
|
55429
|
+
const nx = -uy;
|
|
55430
|
+
const ny = ux;
|
|
55431
|
+
const triLen = 8;
|
|
55432
|
+
const triW = 6;
|
|
55433
|
+
const p1x = boundaryEnd.x, p1y = boundaryEnd.y;
|
|
55434
|
+
const baseX = boundaryEnd.x - ux * triLen;
|
|
55435
|
+
const baseY = boundaryEnd.y - uy * triLen;
|
|
55436
|
+
const p2x = baseX + nx * (triW / 2), p2y = baseY + ny * (triW / 2);
|
|
55437
|
+
const p3x = baseX - nx * (triW / 2), p3y = baseY - ny * (triW / 2);
|
|
55438
|
+
if (mEnd === "arrow")
|
|
55439
|
+
overlay += triangleAtEnd(prevEnd, boundaryEnd, this.arrowStroke);
|
|
55440
|
+
if (mStart === "arrow" && points.length >= 2) {
|
|
55441
|
+
const firstLeg = points[1];
|
|
55442
|
+
const svx = boundaryStart.x - firstLeg.x;
|
|
55443
|
+
const svy = boundaryStart.y - firstLeg.y;
|
|
55444
|
+
const slen = Math.hypot(svx, svy) || 1;
|
|
55445
|
+
const sux = svx / slen;
|
|
55446
|
+
const suy = svy / slen;
|
|
55447
|
+
const snx = -suy;
|
|
55448
|
+
const sny = sux;
|
|
55449
|
+
overlay += triangleAtStart(boundaryStart, firstLeg, this.arrowStroke);
|
|
55450
|
+
}
|
|
55451
|
+
if (overlay) {
|
|
55452
|
+
const grouped = `<g>${edgeElement}
|
|
55453
|
+
${overlay}</g>`;
|
|
55454
|
+
return { path: grouped };
|
|
55455
|
+
}
|
|
55456
|
+
return { path: edgeElement };
|
|
55457
|
+
}
|
|
55458
|
+
// --- helpers ---
|
|
55459
|
+
buildSmoothSegments(points) {
|
|
55460
|
+
if (points.length < 2) {
|
|
55461
|
+
const p3 = points[0] || { x: 0, y: 0 };
|
|
55462
|
+
return { start: p3, segs: [] };
|
|
55463
|
+
}
|
|
55464
|
+
if (points.length === 2) {
|
|
55465
|
+
const p0 = points[0];
|
|
55466
|
+
const p1 = points[1];
|
|
55467
|
+
const c1 = { x: p0.x + (p1.x - p0.x) / 3, y: p0.y + (p1.y - p0.y) / 3 };
|
|
55468
|
+
const c22 = { x: p0.x + 2 * (p1.x - p0.x) / 3, y: p0.y + 2 * (p1.y - p0.y) / 3 };
|
|
55469
|
+
return { start: p0, segs: [{ c1, c2: c22, to: p1 }] };
|
|
55470
|
+
}
|
|
55471
|
+
const pts = [points[0], ...points, points[points.length - 1]];
|
|
55472
|
+
const segs = [];
|
|
55473
|
+
const firstIdx = 1;
|
|
55474
|
+
const lastIdx = pts.length - 3;
|
|
55475
|
+
const midFactor = 1;
|
|
55476
|
+
const endFactor = 0.35;
|
|
55477
|
+
const FLAT_LEN = 28;
|
|
55478
|
+
for (let i3 = 1; i3 < pts.length - 2; i3++) {
|
|
55479
|
+
const p0 = pts[i3 - 1];
|
|
55480
|
+
const p1 = pts[i3];
|
|
55481
|
+
const p22 = pts[i3 + 1];
|
|
55482
|
+
const p3 = pts[i3 + 2];
|
|
55483
|
+
const f1 = i3 === firstIdx ? endFactor : midFactor;
|
|
55484
|
+
const f22 = i3 === lastIdx ? endFactor : midFactor;
|
|
55485
|
+
let c1 = { x: p1.x + (p22.x - p0.x) / 6 * f1, y: p1.y + (p22.y - p0.y) / 6 * f1 };
|
|
55486
|
+
let c22 = { x: p22.x - (p3.x - p1.x) / 6 * f22, y: p22.y - (p3.y - p1.y) / 6 * f22 };
|
|
55487
|
+
if (i3 === firstIdx) {
|
|
55488
|
+
const dx = p22.x - p1.x, dy = p22.y - p1.y;
|
|
55489
|
+
const len = Math.hypot(dx, dy) || 1;
|
|
55490
|
+
const t3 = Math.min(FLAT_LEN, len * 0.5);
|
|
55491
|
+
c1 = { x: p1.x + dx / len * t3, y: p1.y + dy / len * t3 };
|
|
55492
|
+
}
|
|
55493
|
+
if (i3 === lastIdx) {
|
|
55494
|
+
const dx = p22.x - p1.x, dy = p22.y - p1.y;
|
|
55495
|
+
const len = Math.hypot(dx, dy) || 1;
|
|
55496
|
+
const t3 = Math.min(FLAT_LEN, len * 0.5);
|
|
55497
|
+
c22 = { x: p22.x - dx / len * t3, y: p22.y - dy / len * t3 };
|
|
55498
|
+
}
|
|
55499
|
+
segs.push({ c1, c2: c22, to: { x: p22.x, y: p22.y } });
|
|
55500
|
+
}
|
|
55501
|
+
return { start: pts[1], segs };
|
|
55502
|
+
}
|
|
55503
|
+
pathFromSegments(data2) {
|
|
55504
|
+
let d3 = `M${data2.start.x},${data2.start.y}`;
|
|
55505
|
+
for (const s3 of data2.segs) {
|
|
55506
|
+
d3 += ` C${s3.c1.x},${s3.c1.y} ${s3.c2.x},${s3.c2.y} ${s3.to.x},${s3.to.y}`;
|
|
55507
|
+
}
|
|
55508
|
+
return d3;
|
|
55509
|
+
}
|
|
55510
|
+
trimSegmentsEnd(data2, cut) {
|
|
55511
|
+
const segs = data2.segs.slice();
|
|
55512
|
+
if (!segs.length)
|
|
55513
|
+
return data2;
|
|
55514
|
+
const last2 = { ...segs[segs.length - 1] };
|
|
55515
|
+
const vx = last2.to.x - last2.c2.x;
|
|
55516
|
+
const vy = last2.to.y - last2.c2.y;
|
|
55517
|
+
const len = Math.hypot(vx, vy) || 1;
|
|
55518
|
+
const eff = Math.max(0.1, Math.min(cut, Math.max(0, len - 0.2)));
|
|
55519
|
+
const nx = vx / len;
|
|
55520
|
+
const ny = vy / len;
|
|
55521
|
+
const newTo = { x: last2.to.x - nx * eff, y: last2.to.y - ny * eff };
|
|
55522
|
+
last2.to = newTo;
|
|
55523
|
+
segs[segs.length - 1] = last2;
|
|
55524
|
+
return { start: data2.start, segs };
|
|
55525
|
+
}
|
|
55526
|
+
trimSegmentsStart(data2, cut) {
|
|
55527
|
+
const segs = data2.segs.slice();
|
|
55528
|
+
if (!segs.length)
|
|
55529
|
+
return data2;
|
|
55530
|
+
const first2 = { ...segs[0] };
|
|
55531
|
+
const vx = first2.c1.x - data2.start.x;
|
|
55532
|
+
const vy = first2.c1.y - data2.start.y;
|
|
55533
|
+
const len = Math.hypot(vx, vy) || 1;
|
|
55534
|
+
const eff = Math.max(0.1, Math.min(cut, Math.max(0, len - 0.2)));
|
|
55535
|
+
const nx = vx / len;
|
|
55536
|
+
const ny = vy / len;
|
|
55537
|
+
const newStart = { x: data2.start.x + nx * eff, y: data2.start.y + ny * eff };
|
|
55538
|
+
return { start: newStart, segs };
|
|
55539
|
+
}
|
|
55540
|
+
// ---- shape intersections ----
|
|
55541
|
+
intersectSegmentsEnd(data2, node) {
|
|
55542
|
+
if (!data2.segs.length)
|
|
55543
|
+
return data2;
|
|
55544
|
+
const last2 = data2.segs[data2.segs.length - 1];
|
|
55545
|
+
const p1 = last2.c2;
|
|
55546
|
+
const p22 = last2.to;
|
|
55547
|
+
const hit = this.intersectLineWithNode(p1, p22, node);
|
|
55548
|
+
if (hit) {
|
|
55549
|
+
const segs = data2.segs.slice();
|
|
55550
|
+
segs[segs.length - 1] = { ...last2, to: hit };
|
|
55551
|
+
return { start: data2.start, segs };
|
|
55552
|
+
}
|
|
55553
|
+
return data2;
|
|
55554
|
+
}
|
|
55555
|
+
intersectSegmentsStart(data2, node) {
|
|
55556
|
+
if (!data2.segs.length)
|
|
55557
|
+
return data2;
|
|
55558
|
+
const first2 = data2.segs[0];
|
|
55559
|
+
const p1 = data2.start;
|
|
55560
|
+
const p22 = first2.c1;
|
|
55561
|
+
const hit = this.intersectLineWithNode(p1, p22, node);
|
|
55562
|
+
if (hit) {
|
|
55563
|
+
return { start: hit, segs: data2.segs };
|
|
55564
|
+
}
|
|
55565
|
+
return data2;
|
|
55566
|
+
}
|
|
55567
|
+
intersectLineWithNode(p1, p22, node) {
|
|
55568
|
+
const shape = node.shape;
|
|
55569
|
+
const rectPoly = () => [
|
|
55570
|
+
{ x: node.x, y: node.y },
|
|
55571
|
+
{ x: node.x + node.width, y: node.y },
|
|
55572
|
+
{ x: node.x + node.width, y: node.y + node.height },
|
|
55573
|
+
{ x: node.x, y: node.y + node.height }
|
|
55574
|
+
];
|
|
55575
|
+
switch (shape) {
|
|
55576
|
+
case "circle": {
|
|
55577
|
+
const cx = node.x + node.width / 2;
|
|
55578
|
+
const cy = node.y + node.height / 2;
|
|
55579
|
+
const r3 = Math.min(node.width, node.height) / 2;
|
|
55580
|
+
return this.lineCircleIntersection(p1, p22, { cx, cy, r: r3 });
|
|
55581
|
+
}
|
|
55582
|
+
case "diamond": {
|
|
55583
|
+
const cx = node.x + node.width / 2;
|
|
55584
|
+
const cy = node.y + node.height / 2;
|
|
55585
|
+
const poly = [{ x: cx, y: node.y }, { x: node.x + node.width, y: cy }, { x: cx, y: node.y + node.height }, { x: node.x, y: cy }];
|
|
55586
|
+
return this.linePolygonIntersection(p1, p22, poly);
|
|
55587
|
+
}
|
|
55588
|
+
case "hexagon": {
|
|
55589
|
+
const s3 = Math.max(10, node.width * 0.2);
|
|
55590
|
+
const poly = [
|
|
55591
|
+
{ x: node.x + s3, y: node.y },
|
|
55592
|
+
{ x: node.x + node.width - s3, y: node.y },
|
|
55593
|
+
{ x: node.x + node.width, y: node.y + node.height / 2 },
|
|
55594
|
+
{ x: node.x + node.width - s3, y: node.y + node.height },
|
|
55595
|
+
{ x: node.x + s3, y: node.y + node.height },
|
|
55596
|
+
{ x: node.x, y: node.y + node.height / 2 }
|
|
55597
|
+
];
|
|
55598
|
+
return this.linePolygonIntersection(p1, p22, poly);
|
|
55599
|
+
}
|
|
55600
|
+
case "parallelogram": {
|
|
55601
|
+
const o3 = Math.min(node.width * 0.25, node.height * 0.6);
|
|
55602
|
+
const poly = [
|
|
55603
|
+
{ x: node.x + o3, y: node.y },
|
|
55604
|
+
{ x: node.x + node.width, y: node.y },
|
|
55605
|
+
{ x: node.x + node.width - o3, y: node.y + node.height },
|
|
55606
|
+
{ x: node.x, y: node.y + node.height }
|
|
55607
|
+
];
|
|
55608
|
+
return this.linePolygonIntersection(p1, p22, poly);
|
|
55609
|
+
}
|
|
55610
|
+
case "trapezoid": {
|
|
55611
|
+
const o3 = Math.min(node.width * 0.2, node.height * 0.5);
|
|
55612
|
+
const poly = [
|
|
55613
|
+
{ x: node.x + o3, y: node.y },
|
|
55614
|
+
{ x: node.x + node.width - o3, y: node.y },
|
|
55615
|
+
{ x: node.x + node.width, y: node.y + node.height },
|
|
55616
|
+
{ x: node.x, y: node.y + node.height }
|
|
55617
|
+
];
|
|
55618
|
+
return this.linePolygonIntersection(p1, p22, poly);
|
|
55619
|
+
}
|
|
55620
|
+
case "trapezoidAlt": {
|
|
55621
|
+
const o3 = Math.min(node.width * 0.2, node.height * 0.5);
|
|
55622
|
+
const poly = [
|
|
55623
|
+
{ x: node.x, y: node.y },
|
|
55624
|
+
{ x: node.x + node.width, y: node.y },
|
|
55625
|
+
{ x: node.x + node.width - o3, y: node.y + node.height },
|
|
55626
|
+
{ x: node.x + o3, y: node.y + node.height }
|
|
55627
|
+
];
|
|
55628
|
+
return this.linePolygonIntersection(p1, p22, poly);
|
|
55629
|
+
}
|
|
55630
|
+
case "stadium": {
|
|
55631
|
+
const r3 = Math.min(node.height / 2, node.width / 2);
|
|
55632
|
+
const rect = [
|
|
55633
|
+
{ x: node.x + r3, y: node.y },
|
|
55634
|
+
{ x: node.x + node.width - r3, y: node.y },
|
|
55635
|
+
{ x: node.x + node.width - r3, y: node.y + node.height },
|
|
55636
|
+
{ x: node.x + r3, y: node.y + node.height }
|
|
55637
|
+
];
|
|
55638
|
+
const hitRect = this.linePolygonIntersection(p1, p22, rect);
|
|
55639
|
+
if (hitRect)
|
|
55640
|
+
return hitRect;
|
|
55641
|
+
const left = this.lineCircleIntersection(p1, p22, { cx: node.x + r3, cy: node.y + node.height / 2, r: r3 });
|
|
55642
|
+
const right = this.lineCircleIntersection(p1, p22, { cx: node.x + node.width - r3, cy: node.y + node.height / 2, r: r3 });
|
|
55643
|
+
const pick = (...pts) => {
|
|
55644
|
+
let best = null;
|
|
55645
|
+
let bestd = -Infinity;
|
|
55646
|
+
for (const pt of pts)
|
|
55647
|
+
if (pt) {
|
|
55648
|
+
const d3 = -((pt.x - p22.x) ** 2 + (pt.y - p22.y) ** 2);
|
|
55649
|
+
if (d3 > bestd) {
|
|
55650
|
+
bestd = d3;
|
|
55651
|
+
best = pt;
|
|
55652
|
+
}
|
|
55653
|
+
}
|
|
55654
|
+
return best;
|
|
55655
|
+
};
|
|
55656
|
+
return pick(left, right);
|
|
55657
|
+
}
|
|
55658
|
+
default: {
|
|
55659
|
+
return this.linePolygonIntersection(p1, p22, rectPoly());
|
|
55660
|
+
}
|
|
55661
|
+
}
|
|
55662
|
+
}
|
|
55663
|
+
lineCircleIntersection(p1, p22, c3) {
|
|
55664
|
+
const dx = p22.x - p1.x;
|
|
55665
|
+
const dy = p22.y - p1.y;
|
|
55666
|
+
const fx = p1.x - c3.cx;
|
|
55667
|
+
const fy = p1.y - c3.cy;
|
|
55668
|
+
const a3 = dx * dx + dy * dy;
|
|
55669
|
+
const b3 = 2 * (fx * dx + fy * dy);
|
|
55670
|
+
const cc2 = fx * fx + fy * fy - c3.r * c3.r;
|
|
55671
|
+
const disc = b3 * b3 - 4 * a3 * cc2;
|
|
55672
|
+
if (disc < 0)
|
|
55673
|
+
return null;
|
|
55674
|
+
const s3 = Math.sqrt(disc);
|
|
55675
|
+
const t1 = (-b3 - s3) / (2 * a3);
|
|
55676
|
+
const t22 = (-b3 + s3) / (2 * a3);
|
|
55677
|
+
const ts = [t1, t22].filter((t4) => t4 >= 0 && t4 <= 1);
|
|
55678
|
+
if (!ts.length)
|
|
55679
|
+
return null;
|
|
55680
|
+
const t3 = Math.max(...ts);
|
|
55681
|
+
return { x: p1.x + dx * t3, y: p1.y + dy * t3 };
|
|
55682
|
+
}
|
|
55683
|
+
linePolygonIntersection(p1, p22, poly) {
|
|
55684
|
+
let bestT = -Infinity;
|
|
55685
|
+
let best = null;
|
|
55686
|
+
for (let i3 = 0; i3 < poly.length; i3++) {
|
|
55687
|
+
const a3 = poly[i3];
|
|
55688
|
+
const b3 = poly[(i3 + 1) % poly.length];
|
|
55689
|
+
const hit = this.segmentIntersection(p1, p22, a3, b3);
|
|
55690
|
+
if (hit && hit.t >= 0 && hit.t <= 1 && hit.u >= 0 && hit.u <= 1) {
|
|
55691
|
+
if (hit.t > bestT) {
|
|
55692
|
+
bestT = hit.t;
|
|
55693
|
+
best = { x: hit.x, y: hit.y };
|
|
55694
|
+
}
|
|
55695
|
+
}
|
|
55696
|
+
}
|
|
55697
|
+
return best;
|
|
55698
|
+
}
|
|
55699
|
+
segmentIntersection(p3, p22, q3, q22) {
|
|
55700
|
+
const r3 = { x: p22.x - p3.x, y: p22.y - p3.y };
|
|
55701
|
+
const s3 = { x: q22.x - q3.x, y: q22.y - q3.y };
|
|
55702
|
+
const rxs = r3.x * s3.y - r3.y * s3.x;
|
|
55703
|
+
if (Math.abs(rxs) < 1e-6)
|
|
55704
|
+
return null;
|
|
55705
|
+
const q_p = { x: q3.x - p3.x, y: q3.y - p3.y };
|
|
55706
|
+
const t3 = (q_p.x * s3.y - q_p.y * s3.x) / rxs;
|
|
55707
|
+
const u3 = (q_p.x * r3.y - q_p.y * r3.x) / rxs;
|
|
55708
|
+
const x3 = p3.x + t3 * r3.x;
|
|
55709
|
+
const y2 = p3.y + t3 * r3.y;
|
|
55710
|
+
return { x: x3, y: y2, t: t3, u: u3 };
|
|
55711
|
+
}
|
|
55712
|
+
pointAtRatio(points, ratio) {
|
|
55713
|
+
const clampRatio = Math.max(0, Math.min(1, ratio));
|
|
55714
|
+
let total = 0;
|
|
55715
|
+
const segs = [];
|
|
55716
|
+
for (let i3 = 0; i3 < points.length - 1; i3++) {
|
|
55717
|
+
const dx = points[i3 + 1].x - points[i3].x;
|
|
55718
|
+
const dy = points[i3 + 1].y - points[i3].y;
|
|
55719
|
+
const len = Math.hypot(dx, dy);
|
|
55720
|
+
segs.push(len);
|
|
55721
|
+
total += len;
|
|
55722
|
+
}
|
|
55723
|
+
if (total === 0)
|
|
55724
|
+
return points[Math.floor(points.length / 2)];
|
|
55725
|
+
let target = total * clampRatio;
|
|
55726
|
+
for (let i3 = 0; i3 < segs.length; i3++) {
|
|
55727
|
+
if (target <= segs[i3]) {
|
|
55728
|
+
const t3 = segs[i3] === 0 ? 0 : target / segs[i3];
|
|
55729
|
+
return {
|
|
55730
|
+
x: points[i3].x + (points[i3 + 1].x - points[i3].x) * t3,
|
|
55731
|
+
y: points[i3].y + (points[i3 + 1].y - points[i3].y) * t3
|
|
55732
|
+
};
|
|
55733
|
+
}
|
|
55734
|
+
target -= segs[i3];
|
|
55735
|
+
}
|
|
55736
|
+
return points[points.length - 1];
|
|
55737
|
+
}
|
|
55738
|
+
escapeXml(text) {
|
|
55739
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
55740
|
+
}
|
|
55741
|
+
};
|
|
55742
|
+
}
|
|
55743
|
+
});
|
|
55744
|
+
|
|
55745
|
+
// node_modules/@probelabs/maid/out/renderer/pie-builder.js
|
|
55746
|
+
function unquote(s3) {
|
|
55747
|
+
if (!s3)
|
|
55748
|
+
return s3;
|
|
55749
|
+
const first2 = s3.charAt(0);
|
|
55750
|
+
const last2 = s3.charAt(s3.length - 1);
|
|
55751
|
+
if (first2 === '"' && last2 === '"' || first2 === "'" && last2 === "'") {
|
|
55752
|
+
const inner = s3.slice(1, -1);
|
|
55753
|
+
return inner.replace(/\\(["'])/g, "$1");
|
|
55754
|
+
}
|
|
55755
|
+
return s3;
|
|
55756
|
+
}
|
|
55757
|
+
function buildPieModel(text) {
|
|
55758
|
+
const errors = [];
|
|
55759
|
+
const lex = tokenize2(text);
|
|
55760
|
+
for (const e3 of lex.errors) {
|
|
55761
|
+
errors.push({
|
|
55762
|
+
line: e3.line ?? 1,
|
|
55763
|
+
column: e3.column ?? 1,
|
|
55764
|
+
message: e3.message,
|
|
55765
|
+
code: "PIE_LEX",
|
|
55766
|
+
severity: "error"
|
|
55767
|
+
});
|
|
55768
|
+
}
|
|
55769
|
+
parserInstance2.reset();
|
|
55770
|
+
parserInstance2.input = lex.tokens;
|
|
55771
|
+
const cst = parserInstance2.diagram();
|
|
55772
|
+
for (const e3 of parserInstance2.errors) {
|
|
55773
|
+
const t3 = e3.token;
|
|
55774
|
+
errors.push({
|
|
55775
|
+
line: t3?.startLine ?? 1,
|
|
55776
|
+
column: t3?.startColumn ?? 1,
|
|
55777
|
+
message: e3.message,
|
|
55778
|
+
code: "PIE_PARSE",
|
|
55779
|
+
severity: "error"
|
|
55780
|
+
});
|
|
55781
|
+
}
|
|
55782
|
+
const model = { title: void 0, showData: false, slices: [] };
|
|
55783
|
+
if (!cst || !cst.children)
|
|
55784
|
+
return { model, errors };
|
|
55785
|
+
if (cst.children.ShowDataKeyword && cst.children.ShowDataKeyword.length > 0) {
|
|
55786
|
+
model.showData = true;
|
|
55787
|
+
}
|
|
55788
|
+
const statements = cst.children.statement ?? [];
|
|
55789
|
+
for (const st of statements) {
|
|
55790
|
+
if (st.children?.titleStmt) {
|
|
55791
|
+
const tnode = st.children.titleStmt[0];
|
|
55792
|
+
const parts = [];
|
|
55793
|
+
const collect = (k3) => {
|
|
55794
|
+
const arr = tnode.children?.[k3] ?? [];
|
|
55795
|
+
for (const tok of arr)
|
|
55796
|
+
parts.push(unquote(tok.image));
|
|
55797
|
+
};
|
|
55798
|
+
collect("QuotedString");
|
|
55799
|
+
collect("Text");
|
|
55800
|
+
collect("NumberLiteral");
|
|
55801
|
+
const title = parts.join(" ").trim();
|
|
55802
|
+
if (title)
|
|
55803
|
+
model.title = title;
|
|
55804
|
+
} else if (st.children?.sliceStmt) {
|
|
55805
|
+
const snode = st.children.sliceStmt[0];
|
|
55806
|
+
const labelTok = snode.children?.sliceLabel?.[0]?.children?.QuotedString?.[0];
|
|
55807
|
+
const numTok = snode.children?.NumberLiteral?.[0];
|
|
55808
|
+
if (labelTok && numTok) {
|
|
55809
|
+
const label = unquote(labelTok.image).trim();
|
|
55810
|
+
const value = Number(numTok.image);
|
|
55811
|
+
if (!Number.isNaN(value)) {
|
|
55812
|
+
model.slices.push({ label, value });
|
|
55813
|
+
}
|
|
55814
|
+
}
|
|
55815
|
+
}
|
|
55816
|
+
}
|
|
55817
|
+
return { model, errors };
|
|
55818
|
+
}
|
|
55819
|
+
var init_pie_builder = __esm({
|
|
55820
|
+
"node_modules/@probelabs/maid/out/renderer/pie-builder.js"() {
|
|
55821
|
+
init_lexer3();
|
|
55822
|
+
init_parser3();
|
|
55823
|
+
}
|
|
55824
|
+
});
|
|
55825
|
+
|
|
55826
|
+
// node_modules/@probelabs/maid/out/renderer/pie-renderer.js
|
|
55827
|
+
function polarToCartesian(cx, cy, r3, angleRad) {
|
|
55828
|
+
return { x: cx + r3 * Math.cos(angleRad), y: cy + r3 * Math.sin(angleRad) };
|
|
55829
|
+
}
|
|
55830
|
+
function renderPie(model, opts = {}) {
|
|
55831
|
+
let width = Math.max(320, Math.floor(opts.width ?? 640));
|
|
55832
|
+
const height = Math.max(240, Math.floor(opts.height ?? 400));
|
|
55833
|
+
const pad = 24;
|
|
55834
|
+
const titleH = model.title ? 28 : 0;
|
|
55835
|
+
let cx = width / 2;
|
|
55836
|
+
const cy = (height + titleH) / 2 + (model.title ? 8 : 0);
|
|
55837
|
+
const baseRadius = Math.max(40, Math.min(width, height - titleH) / 2 - pad);
|
|
55838
|
+
const slices = model.slices.filter((s3) => Math.max(0, s3.value) > 0);
|
|
55839
|
+
const total = slices.reduce((a3, s3) => a3 + Math.max(0, s3.value), 0);
|
|
55840
|
+
const LEG_SW = 12;
|
|
55841
|
+
const LEG_GAP = 8;
|
|
55842
|
+
const LEG_VSPACE = 18;
|
|
55843
|
+
const legendItems = slices.map((s3) => `${s3.label}${model.showData ? ` ${formatNumber(Number(s3.value))}` : ""}`);
|
|
55844
|
+
const legendTextWidth = legendItems.length ? Math.max(...legendItems.map((t3) => measureText(t3, 12))) : 0;
|
|
55845
|
+
const legendBlockWidth = legendItems.length ? LEG_SW + LEG_GAP + legendTextWidth + pad : 0;
|
|
55846
|
+
if (legendItems.length) {
|
|
55847
|
+
const neededWidth = pad + baseRadius * 2 + legendBlockWidth + pad;
|
|
55848
|
+
if (neededWidth > width)
|
|
55849
|
+
width = Math.ceil(neededWidth);
|
|
55850
|
+
}
|
|
55851
|
+
let radius = baseRadius;
|
|
55852
|
+
if (legendItems.length) {
|
|
55853
|
+
const leftPad = Math.max(pad, (width - legendBlockWidth - radius * 2) / 2);
|
|
55854
|
+
cx = leftPad + radius;
|
|
55855
|
+
}
|
|
55856
|
+
let start = -Math.PI / 2;
|
|
55857
|
+
let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">`;
|
|
55858
|
+
svg += `
|
|
55859
|
+
<style>
|
|
55860
|
+
.pie-title { font-family: Arial, sans-serif; font-size: 16px; font-weight: 600; fill: #222; }
|
|
55861
|
+
.slice-label { font-family: Arial, sans-serif; font-size: 12px; fill: #222; dominant-baseline: middle; }
|
|
55862
|
+
.leader { stroke: #444; stroke-width: 1; fill: none; }
|
|
55863
|
+
.pieCircle { stroke: black; stroke-width: 2px; opacity: 0.7; }
|
|
55864
|
+
.pieOuterCircle { stroke: black; stroke-width: 2px; fill: none; }
|
|
55865
|
+
</style>`;
|
|
55866
|
+
if (model.title) {
|
|
55867
|
+
svg += `
|
|
55868
|
+
<text class="pie-title" x="${cx}" y="${pad + 8}" text-anchor="middle">${escapeXml(model.title)}</text>`;
|
|
55869
|
+
}
|
|
55870
|
+
svg += `
|
|
55871
|
+
<g class="pie" aria-label="pie">`;
|
|
55872
|
+
const minOutsideAngle = 0.35;
|
|
55873
|
+
slices.forEach((s3, i3) => {
|
|
55874
|
+
const pct = total > 0 ? Math.max(0, s3.value) / total : 0;
|
|
55875
|
+
const angle = 2 * Math.PI * pct;
|
|
55876
|
+
const end = start + angle;
|
|
55877
|
+
const large = angle > Math.PI ? 1 : 0;
|
|
55878
|
+
const c0 = polarToCartesian(cx, cy, radius, start);
|
|
55879
|
+
const c1 = polarToCartesian(cx, cy, radius, end);
|
|
55880
|
+
const d3 = [
|
|
55881
|
+
`M ${cx} ${cy}`,
|
|
55882
|
+
`L ${c0.x.toFixed(2)} ${c0.y.toFixed(2)}`,
|
|
55883
|
+
`A ${radius} ${radius} 0 ${large} 1 ${c1.x.toFixed(2)} ${c1.y.toFixed(2)}`,
|
|
55884
|
+
"Z"
|
|
55885
|
+
].join(" ");
|
|
55886
|
+
const fill = s3.color || palette(i3);
|
|
55887
|
+
svg += `
|
|
55888
|
+
<path d="${d3}" class="pieCircle" fill="${fill}" />`;
|
|
55889
|
+
const mid = (start + end) / 2;
|
|
55890
|
+
const cos = Math.cos(mid);
|
|
55891
|
+
const sin = Math.sin(mid);
|
|
55892
|
+
const percentLabel = escapeXml(formatPercent(s3.value, total));
|
|
55893
|
+
if (angle < minOutsideAngle) {
|
|
55894
|
+
const r1 = radius * 0.9;
|
|
55895
|
+
const r22 = radius * 1.06;
|
|
55896
|
+
const p1 = polarToCartesian(cx, cy, r1, mid);
|
|
55897
|
+
const p22 = polarToCartesian(cx, cy, r22, mid);
|
|
55898
|
+
const hlen = 12;
|
|
55899
|
+
const anchorLeft = cos < 0;
|
|
55900
|
+
const hx = anchorLeft ? p22.x - hlen : p22.x + hlen;
|
|
55901
|
+
const hy = p22.y;
|
|
55902
|
+
svg += `
|
|
55903
|
+
<path class="leader" d="M ${p1.x.toFixed(2)} ${p1.y.toFixed(2)} L ${p22.x.toFixed(2)} ${p22.y.toFixed(2)} L ${hx.toFixed(2)} ${hy.toFixed(2)}" />`;
|
|
55904
|
+
const tx = anchorLeft ? hx - 2 : hx + 2;
|
|
55905
|
+
const tAnchor = anchorLeft ? "end" : "start";
|
|
55906
|
+
svg += `
|
|
55907
|
+
<text class="slice-label" x="${tx.toFixed(2)}" y="${hy.toFixed(2)}" text-anchor="${tAnchor}">${percentLabel}</text>`;
|
|
55908
|
+
} else {
|
|
55909
|
+
const lr = radius * 0.62;
|
|
55910
|
+
const lp = { x: cx + lr * cos, y: cy + lr * sin };
|
|
55911
|
+
const tAnchor = Math.abs(cos) < 0.2 ? "middle" : cos > 0 ? "start" : "end";
|
|
55912
|
+
const avail = lr;
|
|
55913
|
+
const textW = measureText(percentLabel, 12);
|
|
55914
|
+
const anchor = textW > avail * 1.2 ? "middle" : tAnchor;
|
|
55915
|
+
svg += `
|
|
55916
|
+
<text class="slice-label" x="${lp.x.toFixed(2)}" y="${lp.y.toFixed(2)}" text-anchor="${anchor}">${percentLabel}</text>`;
|
|
55917
|
+
}
|
|
55918
|
+
start = end;
|
|
55919
|
+
});
|
|
55920
|
+
const rimStroke = opts.rimStroke || "black";
|
|
55921
|
+
const rimWidth = opts.rimStrokeWidth != null ? String(opts.rimStrokeWidth) : "2px";
|
|
55922
|
+
svg += `
|
|
55923
|
+
</g>
|
|
55924
|
+
<circle class="pie-rim pieOuterCircle" cx="${cx}" cy="${cy}" r="${radius}" stroke="${rimStroke}" stroke-width="${rimWidth}" fill="none" />`;
|
|
55925
|
+
if (legendItems.length) {
|
|
55926
|
+
const legendX = cx + radius + pad / 2;
|
|
55927
|
+
const totalH = legendItems.length * LEG_VSPACE;
|
|
55928
|
+
let legendY = cy - totalH / 2 + 10;
|
|
55929
|
+
svg += `
|
|
55930
|
+
<g class="legend">`;
|
|
55931
|
+
slices.forEach((s3, i3) => {
|
|
55932
|
+
const y2 = legendY + i3 * LEG_VSPACE;
|
|
55933
|
+
const fill = s3.color || palette(i3);
|
|
55934
|
+
const text = escapeXml(`${s3.label}${model.showData ? ` ${formatNumber(Number(s3.value))}` : ""}`);
|
|
55935
|
+
svg += `
|
|
55936
|
+
<rect x="${legendX}" y="${y2 - LEG_SW + 6}" width="${LEG_SW}" height="${LEG_SW}" fill="${fill}" stroke="${fill}" stroke-width="1" />`;
|
|
55937
|
+
svg += `
|
|
55938
|
+
<text class="slice-label legend-text" x="${legendX + LEG_SW + LEG_GAP}" y="${y2}" text-anchor="start">${text}</text>`;
|
|
55939
|
+
});
|
|
55940
|
+
svg += `
|
|
55941
|
+
</g>`;
|
|
55942
|
+
}
|
|
55943
|
+
svg += `
|
|
55944
|
+
</svg>`;
|
|
55945
|
+
return svg;
|
|
55946
|
+
}
|
|
55947
|
+
var init_pie_renderer = __esm({
|
|
55948
|
+
"node_modules/@probelabs/maid/out/renderer/pie-renderer.js"() {
|
|
55949
|
+
init_utils4();
|
|
55950
|
+
}
|
|
55951
|
+
});
|
|
55952
|
+
|
|
55953
|
+
// node_modules/@probelabs/maid/out/renderer/sequence-builder.js
|
|
55954
|
+
function textFromTokens(tokens) {
|
|
55955
|
+
if (!tokens || tokens.length === 0)
|
|
55956
|
+
return "";
|
|
55957
|
+
const parts = [];
|
|
55958
|
+
for (const t3 of tokens) {
|
|
55959
|
+
const img = t3.image;
|
|
55960
|
+
if (!img)
|
|
55961
|
+
continue;
|
|
55962
|
+
if (t3.tokenType && t3.tokenType.name === "QuotedString") {
|
|
55963
|
+
if (img.startsWith('"') && img.endsWith('"'))
|
|
55964
|
+
parts.push(img.slice(1, -1));
|
|
55965
|
+
else if (img.startsWith("'") && img.endsWith("'"))
|
|
55966
|
+
parts.push(img.slice(1, -1));
|
|
55967
|
+
else
|
|
55968
|
+
parts.push(img);
|
|
55969
|
+
} else {
|
|
55970
|
+
parts.push(img);
|
|
55971
|
+
}
|
|
55972
|
+
}
|
|
55973
|
+
return parts.join(" ").replace(/\s+/g, " ").trim();
|
|
55974
|
+
}
|
|
55975
|
+
function actorRefToText(refCst) {
|
|
55976
|
+
const ch = refCst.children || {};
|
|
55977
|
+
const toks = [];
|
|
55978
|
+
["Identifier", "QuotedString", "NumberLiteral", "Text"].forEach((k3) => {
|
|
55979
|
+
const a3 = ch[k3];
|
|
55980
|
+
a3?.forEach((t3) => toks.push(t3));
|
|
55981
|
+
});
|
|
55982
|
+
toks.sort((a3, b3) => (a3.startOffset ?? 0) - (b3.startOffset ?? 0));
|
|
55983
|
+
return textFromTokens(toks);
|
|
55984
|
+
}
|
|
55985
|
+
function lineRemainderToText(lineRem) {
|
|
55986
|
+
if (!lineRem)
|
|
55987
|
+
return void 0;
|
|
55988
|
+
const ch = lineRem.children || {};
|
|
55989
|
+
const toks = [];
|
|
55990
|
+
const order = [
|
|
55991
|
+
"Identifier",
|
|
55992
|
+
"NumberLiteral",
|
|
55993
|
+
"QuotedString",
|
|
55994
|
+
"Text",
|
|
55995
|
+
"Plus",
|
|
55996
|
+
"Minus",
|
|
55997
|
+
"Comma",
|
|
55998
|
+
"Colon",
|
|
55999
|
+
"LParen",
|
|
56000
|
+
"RParen",
|
|
56001
|
+
"AndKeyword",
|
|
56002
|
+
"ElseKeyword",
|
|
56003
|
+
"OptKeyword",
|
|
56004
|
+
"OptionKeyword",
|
|
56005
|
+
"LoopKeyword",
|
|
56006
|
+
"ParKeyword",
|
|
56007
|
+
"RectKeyword",
|
|
56008
|
+
"CriticalKeyword",
|
|
56009
|
+
"BreakKeyword",
|
|
56010
|
+
"BoxKeyword",
|
|
56011
|
+
"EndKeyword",
|
|
56012
|
+
"NoteKeyword",
|
|
56013
|
+
"LeftKeyword",
|
|
56014
|
+
"RightKeyword",
|
|
56015
|
+
"OverKeyword",
|
|
56016
|
+
"OfKeyword",
|
|
56017
|
+
"AutonumberKeyword",
|
|
56018
|
+
"OffKeyword",
|
|
56019
|
+
"LinkKeyword",
|
|
56020
|
+
"LinksKeyword",
|
|
56021
|
+
"CreateKeyword",
|
|
56022
|
+
"DestroyKeyword",
|
|
56023
|
+
"ParticipantKeyword",
|
|
56024
|
+
"ActorKeyword",
|
|
56025
|
+
"ActivateKeyword",
|
|
56026
|
+
"DeactivateKeyword"
|
|
56027
|
+
];
|
|
56028
|
+
for (const k3 of order)
|
|
56029
|
+
ch[k3]?.forEach((t3) => toks.push(t3));
|
|
56030
|
+
toks.sort((a3, b3) => (a3.startOffset ?? 0) - (b3.startOffset ?? 0));
|
|
56031
|
+
return textFromTokens(toks) || void 0;
|
|
56032
|
+
}
|
|
56033
|
+
function canonicalId(raw) {
|
|
56034
|
+
const t3 = raw.trim().replace(/\s+/g, "_");
|
|
56035
|
+
return t3;
|
|
56036
|
+
}
|
|
56037
|
+
function ensureParticipant(map4, byDisplay, idLike, display) {
|
|
56038
|
+
const idGuess = canonicalId(idLike);
|
|
56039
|
+
const existing = map4.get(idGuess) || (byDisplay.get(idLike) ? map4.get(byDisplay.get(idLike)) : void 0);
|
|
56040
|
+
if (existing)
|
|
56041
|
+
return existing;
|
|
56042
|
+
const p3 = { id: idGuess, display: display || idLike };
|
|
56043
|
+
map4.set(p3.id, p3);
|
|
56044
|
+
byDisplay.set(p3.display, p3.id);
|
|
56045
|
+
return p3;
|
|
56046
|
+
}
|
|
56047
|
+
function msgFromArrow(arrowCst) {
|
|
56048
|
+
const ch = arrowCst.children || {};
|
|
56049
|
+
if (ch.BidirAsyncDotted)
|
|
56050
|
+
return { line: "dotted", start: "arrow", end: "arrow", async: true };
|
|
56051
|
+
if (ch.BidirAsync)
|
|
56052
|
+
return { line: "solid", start: "arrow", end: "arrow", async: true };
|
|
56053
|
+
if (ch.DottedAsync)
|
|
56054
|
+
return { line: "dotted", start: "none", end: "arrow", async: true };
|
|
56055
|
+
if (ch.Async)
|
|
56056
|
+
return { line: "solid", start: "none", end: "arrow", async: true };
|
|
56057
|
+
if (ch.Dotted)
|
|
56058
|
+
return { line: "dotted", start: "none", end: "arrow" };
|
|
56059
|
+
if (ch.Solid)
|
|
56060
|
+
return { line: "solid", start: "none", end: "arrow" };
|
|
56061
|
+
if (ch.DottedCross)
|
|
56062
|
+
return { line: "dotted", start: "none", end: "cross" };
|
|
56063
|
+
if (ch.Cross)
|
|
56064
|
+
return { line: "solid", start: "none", end: "cross" };
|
|
56065
|
+
if (ch.DottedOpen)
|
|
56066
|
+
return { line: "dotted", start: "none", end: "open" };
|
|
56067
|
+
if (ch.Open)
|
|
56068
|
+
return { line: "solid", start: "none", end: "open" };
|
|
56069
|
+
return { line: "solid", start: "none", end: "arrow" };
|
|
56070
|
+
}
|
|
56071
|
+
function buildSequenceModel(text) {
|
|
56072
|
+
const { tokens } = tokenize3(text);
|
|
56073
|
+
parserInstance3.input = tokens;
|
|
56074
|
+
const cst = parserInstance3.diagram();
|
|
56075
|
+
const participantsMap = /* @__PURE__ */ new Map();
|
|
56076
|
+
const byDisplay = /* @__PURE__ */ new Map();
|
|
56077
|
+
const events = [];
|
|
56078
|
+
let autonumber = { on: false };
|
|
56079
|
+
const diagramChildren = cst.children || {};
|
|
56080
|
+
const lines = diagramChildren.line || [];
|
|
56081
|
+
const openBlocks = [];
|
|
56082
|
+
function processLineNode(ln) {
|
|
56083
|
+
const ch = ln.children || {};
|
|
56084
|
+
if (ch.participantDecl) {
|
|
56085
|
+
const decl = ch.participantDecl[0];
|
|
56086
|
+
const dch = decl.children || {};
|
|
56087
|
+
const ref1 = dch.actorRef?.[0];
|
|
56088
|
+
const ref2 = dch.actorRef?.[1];
|
|
56089
|
+
const idText = actorRefToText(ref1);
|
|
56090
|
+
const aliasText = ref2 ? actorRefToText(ref2) : void 0;
|
|
56091
|
+
const id = canonicalId(idText);
|
|
56092
|
+
const display = aliasText || idText;
|
|
56093
|
+
const p3 = ensureParticipant(participantsMap, byDisplay, id, display);
|
|
56094
|
+
events.push({ kind: "create", actor: p3.id, display: p3.display });
|
|
56095
|
+
return;
|
|
56096
|
+
}
|
|
56097
|
+
if (ch.autonumberStmt) {
|
|
56098
|
+
const stmt = ch.autonumberStmt[0];
|
|
56099
|
+
const sch = stmt.children || {};
|
|
56100
|
+
autonumber = { on: true };
|
|
56101
|
+
const nums = sch.NumberLiteral || [];
|
|
56102
|
+
if (nums.length >= 1)
|
|
56103
|
+
autonumber.start = Number(nums[0].image);
|
|
56104
|
+
if (nums.length >= 2)
|
|
56105
|
+
autonumber.step = Number(nums[1].image);
|
|
56106
|
+
if (sch.OffKeyword)
|
|
56107
|
+
autonumber = { on: false };
|
|
56108
|
+
return;
|
|
56109
|
+
}
|
|
56110
|
+
if (ch.activateStmt) {
|
|
56111
|
+
const st = ch.activateStmt[0];
|
|
56112
|
+
const sch = st.children || {};
|
|
56113
|
+
const idTxt = actorRefToText(sch.actorRef?.[0]);
|
|
56114
|
+
const p3 = ensureParticipant(participantsMap, byDisplay, idTxt);
|
|
56115
|
+
events.push({ kind: "activate", actor: p3.id });
|
|
56116
|
+
return;
|
|
56117
|
+
}
|
|
56118
|
+
if (ch.deactivateStmt) {
|
|
56119
|
+
const st = ch.deactivateStmt[0];
|
|
56120
|
+
const sch = st.children || {};
|
|
56121
|
+
const idTxt = actorRefToText(sch.actorRef?.[0]);
|
|
56122
|
+
const p3 = ensureParticipant(participantsMap, byDisplay, idTxt);
|
|
56123
|
+
events.push({ kind: "deactivate", actor: p3.id });
|
|
56124
|
+
return;
|
|
56125
|
+
}
|
|
56126
|
+
if (ch.createStmt) {
|
|
56127
|
+
const st = ch.createStmt[0];
|
|
56128
|
+
const sch = st.children || {};
|
|
56129
|
+
const idTxt = actorRefToText(sch.actorRef?.[0]);
|
|
56130
|
+
const alias = sch.lineRemainder ? lineRemainderToText(sch.lineRemainder[0]) : void 0;
|
|
56131
|
+
const p3 = ensureParticipant(participantsMap, byDisplay, idTxt, alias || idTxt);
|
|
56132
|
+
events.push({ kind: "create", actor: p3.id, display: p3.display });
|
|
56133
|
+
return;
|
|
56134
|
+
}
|
|
56135
|
+
if (ch.destroyStmt) {
|
|
56136
|
+
const st = ch.destroyStmt[0];
|
|
56137
|
+
const sch = st.children || {};
|
|
56138
|
+
const idTxt = actorRefToText(sch.actorRef?.[0]);
|
|
56139
|
+
const p3 = ensureParticipant(participantsMap, byDisplay, idTxt);
|
|
56140
|
+
events.push({ kind: "destroy", actor: p3.id });
|
|
56141
|
+
return;
|
|
56142
|
+
}
|
|
56143
|
+
if (ch.noteStmt) {
|
|
56144
|
+
const st = ch.noteStmt[0];
|
|
56145
|
+
const sch = st.children || {};
|
|
56146
|
+
const text2 = lineRemainderToText(sch.lineRemainder?.[0]) || "";
|
|
56147
|
+
if (sch.LeftKeyword || sch.RightKeyword) {
|
|
56148
|
+
const pos = sch.LeftKeyword ? "leftOf" : "rightOf";
|
|
56149
|
+
const actorTxt = actorRefToText(sch.actorRef?.[0]);
|
|
56150
|
+
const p3 = ensureParticipant(participantsMap, byDisplay, actorTxt);
|
|
56151
|
+
const note = { pos, actors: [p3.id], text: text2 };
|
|
56152
|
+
events.push({ kind: "note", note });
|
|
56153
|
+
} else if (sch.OverKeyword) {
|
|
56154
|
+
const a1 = actorRefToText(sch.actorRef?.[0]);
|
|
56155
|
+
const a22 = sch.actorRef?.[1] ? actorRefToText(sch.actorRef?.[1]) : void 0;
|
|
56156
|
+
const p1 = ensureParticipant(participantsMap, byDisplay, a1);
|
|
56157
|
+
const ids = [p1.id];
|
|
56158
|
+
if (a22) {
|
|
56159
|
+
const p22 = ensureParticipant(participantsMap, byDisplay, a22);
|
|
56160
|
+
ids.push(p22.id);
|
|
56161
|
+
}
|
|
56162
|
+
events.push({ kind: "note", note: { pos: "over", actors: ids, text: text2 } });
|
|
56163
|
+
}
|
|
56164
|
+
return;
|
|
56165
|
+
}
|
|
56166
|
+
const blockKinds = [
|
|
56167
|
+
{ key: "altBlock", type: "alt", branchKeys: [{ key: "ElseKeyword", kind: "else" }] },
|
|
56168
|
+
{ key: "optBlock", type: "opt" },
|
|
56169
|
+
{ key: "loopBlock", type: "loop" },
|
|
56170
|
+
{ key: "parBlock", type: "par", branchKeys: [{ key: "AndKeyword", kind: "and" }] },
|
|
56171
|
+
{ key: "criticalBlock", type: "critical", branchKeys: [{ key: "OptionKeyword", kind: "option" }] },
|
|
56172
|
+
{ key: "breakBlock", type: "break" },
|
|
56173
|
+
{ key: "rectBlock", type: "rect" },
|
|
56174
|
+
{ key: "boxBlock", type: "box" }
|
|
56175
|
+
];
|
|
56176
|
+
let handledBlock = false;
|
|
56177
|
+
for (const spec of blockKinds) {
|
|
56178
|
+
if (ch[spec.key]) {
|
|
56179
|
+
handledBlock = true;
|
|
56180
|
+
const bnode = ch[spec.key][0];
|
|
56181
|
+
const bch = bnode.children || {};
|
|
56182
|
+
const title = lineRemainderToText(bch.lineRemainder?.[0]);
|
|
56183
|
+
const block = { type: spec.type, title, branches: spec.branchKeys ? [] : void 0 };
|
|
56184
|
+
openBlocks.push(block);
|
|
56185
|
+
events.push({ kind: "block-start", block });
|
|
56186
|
+
if (spec.branchKeys) {
|
|
56187
|
+
const newlines = bch.Newline || [];
|
|
56188
|
+
const branchKey = spec.branchKeys[0].key;
|
|
56189
|
+
const branchTokArr = bch[branchKey];
|
|
56190
|
+
const lrArr = bch.lineRemainder;
|
|
56191
|
+
if (branchTokArr && branchTokArr.length) {
|
|
56192
|
+
const lr = (lrArr || []).slice(1);
|
|
56193
|
+
for (let i3 = 0; i3 < branchTokArr.length; i3++) {
|
|
56194
|
+
const title2 = lr[i3] ? lineRemainderToText(lr[i3]) : void 0;
|
|
56195
|
+
const br = { kind: spec.branchKeys[0].kind, title: title2 };
|
|
56196
|
+
block.branches.push(br);
|
|
56197
|
+
events.push({ kind: "block-branch", block, branch: br });
|
|
56198
|
+
}
|
|
56199
|
+
}
|
|
56200
|
+
}
|
|
56201
|
+
events.push({ kind: "block-end", block });
|
|
56202
|
+
openBlocks.pop();
|
|
56203
|
+
break;
|
|
56204
|
+
}
|
|
56205
|
+
}
|
|
56206
|
+
if (handledBlock)
|
|
56207
|
+
return;
|
|
56208
|
+
if (ch.messageStmt) {
|
|
56209
|
+
const st = ch.messageStmt[0];
|
|
56210
|
+
const sch = st.children || {};
|
|
56211
|
+
const fromTxt = actorRefToText(sch.actorRef?.[0]);
|
|
56212
|
+
const toTxt = actorRefToText(sch.actorRef?.[1]);
|
|
56213
|
+
const from = ensureParticipant(participantsMap, byDisplay, fromTxt).id;
|
|
56214
|
+
const to = ensureParticipant(participantsMap, byDisplay, toTxt).id;
|
|
56215
|
+
const arrow = msgFromArrow(sch.arrow?.[0]);
|
|
56216
|
+
const text2 = lineRemainderToText(sch.lineRemainder?.[0]);
|
|
56217
|
+
const activateTarget = !!sch.Plus;
|
|
56218
|
+
const deactivateTarget = !!sch.Minus;
|
|
56219
|
+
const msg = { from, to, text: text2, line: arrow.line, startMarker: arrow.start, endMarker: arrow.end, async: arrow.async, activateTarget, deactivateTarget };
|
|
56220
|
+
events.push({ kind: "message", msg });
|
|
56221
|
+
return;
|
|
56222
|
+
}
|
|
56223
|
+
if (ch.linkStmt) {
|
|
56224
|
+
events.push({ kind: "noop" });
|
|
56225
|
+
return;
|
|
56226
|
+
}
|
|
56227
|
+
events.push({ kind: "noop" });
|
|
56228
|
+
}
|
|
56229
|
+
function collectInnerLines(blockNode) {
|
|
56230
|
+
const out = [];
|
|
56231
|
+
const ch = blockNode.children || {};
|
|
56232
|
+
for (const key of Object.keys(ch)) {
|
|
56233
|
+
const arr = ch[key];
|
|
56234
|
+
if (Array.isArray(arr)) {
|
|
56235
|
+
for (const node of arr) {
|
|
56236
|
+
if (node && typeof node === "object" && node.name === "line")
|
|
56237
|
+
out.push(node);
|
|
56238
|
+
}
|
|
56239
|
+
}
|
|
56240
|
+
}
|
|
56241
|
+
return out;
|
|
56242
|
+
}
|
|
56243
|
+
for (const ln of lines) {
|
|
56244
|
+
processLineNode(ln);
|
|
56245
|
+
const ch = ln.children || {};
|
|
56246
|
+
const block = ch.altBlock?.[0] || ch.optBlock?.[0] || ch.loopBlock?.[0] || ch.parBlock?.[0] || ch.criticalBlock?.[0] || ch.breakBlock?.[0] || ch.rectBlock?.[0] || ch.boxBlock?.[0];
|
|
56247
|
+
if (block) {
|
|
56248
|
+
for (const inner of collectInnerLines(block))
|
|
56249
|
+
processLineNode(inner);
|
|
56250
|
+
}
|
|
56251
|
+
}
|
|
56252
|
+
return {
|
|
56253
|
+
participants: Array.from(participantsMap.values()),
|
|
56254
|
+
events,
|
|
56255
|
+
autonumber: autonumber.on === true || autonumber.on === false ? autonumber : { on: false }
|
|
56256
|
+
};
|
|
56257
|
+
}
|
|
56258
|
+
var init_sequence_builder = __esm({
|
|
56259
|
+
"node_modules/@probelabs/maid/out/renderer/sequence-builder.js"() {
|
|
56260
|
+
init_lexer4();
|
|
56261
|
+
init_parser4();
|
|
56262
|
+
}
|
|
56263
|
+
});
|
|
56264
|
+
|
|
56265
|
+
// node_modules/@probelabs/maid/out/renderer/sequence-layout.js
|
|
56266
|
+
function layoutSequence(model) {
|
|
56267
|
+
const order = [];
|
|
56268
|
+
const seen = /* @__PURE__ */ new Set();
|
|
56269
|
+
const partById = new Map(model.participants.map((p3) => [p3.id, p3]));
|
|
56270
|
+
function touch(id) {
|
|
56271
|
+
if (!seen.has(id)) {
|
|
56272
|
+
seen.add(id);
|
|
56273
|
+
order.push(id);
|
|
56274
|
+
}
|
|
56275
|
+
}
|
|
56276
|
+
for (const ev of model.events) {
|
|
56277
|
+
if (ev.kind === "message") {
|
|
56278
|
+
touch(ev.msg.from);
|
|
56279
|
+
touch(ev.msg.to);
|
|
56280
|
+
}
|
|
56281
|
+
if (ev.kind === "note") {
|
|
56282
|
+
ev.note.actors.forEach(touch);
|
|
56283
|
+
}
|
|
56284
|
+
if (ev.kind === "activate" || ev.kind === "deactivate" || ev.kind === "create" || ev.kind === "destroy")
|
|
56285
|
+
touch(ev.actor);
|
|
56286
|
+
}
|
|
56287
|
+
for (const p3 of model.participants)
|
|
56288
|
+
touch(p3.id);
|
|
56289
|
+
const participants = [];
|
|
56290
|
+
let x3 = MARGIN_X;
|
|
56291
|
+
for (const id of order) {
|
|
56292
|
+
const p3 = partById.get(id) || { id, display: id };
|
|
56293
|
+
const w3 = Math.max(COL_MIN, measureText(p3.display, ACTOR_FONT_SIZE) + ACTOR_PAD_X * 2);
|
|
56294
|
+
participants.push({ id, display: p3.display, x: x3, y: MARGIN_Y, width: w3, height: ACTOR_H });
|
|
56295
|
+
x3 += w3 + MARGIN_X;
|
|
56296
|
+
}
|
|
56297
|
+
const width = Math.max(320, x3);
|
|
56298
|
+
const rowIndexForEvent = /* @__PURE__ */ new Map();
|
|
56299
|
+
let row = 0;
|
|
56300
|
+
const openBlocks = [];
|
|
56301
|
+
function consumeRow(idx) {
|
|
56302
|
+
rowIndexForEvent.set(idx, row++);
|
|
56303
|
+
}
|
|
56304
|
+
model.events.forEach((ev, idx) => {
|
|
56305
|
+
switch (ev.kind) {
|
|
56306
|
+
case "message":
|
|
56307
|
+
consumeRow(idx);
|
|
56308
|
+
break;
|
|
56309
|
+
case "note":
|
|
56310
|
+
consumeRow(idx);
|
|
56311
|
+
break;
|
|
56312
|
+
case "block-start":
|
|
56313
|
+
openBlocks.push({ block: ev.block, startRow: row, branches: [] });
|
|
56314
|
+
consumeRow(idx);
|
|
56315
|
+
break;
|
|
56316
|
+
case "block-branch": {
|
|
56317
|
+
const top = openBlocks[openBlocks.length - 1];
|
|
56318
|
+
if (top)
|
|
56319
|
+
top.branches.push({ title: ev.branch.title, row });
|
|
56320
|
+
consumeRow(idx);
|
|
56321
|
+
break;
|
|
56322
|
+
}
|
|
56323
|
+
case "block-end":
|
|
56324
|
+
break;
|
|
56325
|
+
case "activate":
|
|
56326
|
+
case "deactivate":
|
|
56327
|
+
case "create":
|
|
56328
|
+
case "destroy":
|
|
56329
|
+
case "noop":
|
|
56330
|
+
break;
|
|
56331
|
+
}
|
|
56332
|
+
});
|
|
56333
|
+
const lifelineTop = MARGIN_Y + ACTOR_H + LIFELINE_GAP;
|
|
56334
|
+
const contentHeight = row * ROW_H;
|
|
56335
|
+
const height = lifelineTop + contentHeight + MARGIN_Y + ACTOR_H;
|
|
56336
|
+
const lifelines = participants.map((p3) => ({ x: p3.x + p3.width / 2, y1: lifelineTop, y2: height - MARGIN_Y - ACTOR_H }));
|
|
56337
|
+
function yForRow(r3) {
|
|
56338
|
+
return lifelineTop + r3 * ROW_H + ROW_H / 2;
|
|
56339
|
+
}
|
|
56340
|
+
const col = new Map(participants.map((p3) => [p3.id, p3]));
|
|
56341
|
+
const messages = [];
|
|
56342
|
+
const notes = [];
|
|
56343
|
+
const blocks = [];
|
|
56344
|
+
const activations = [];
|
|
56345
|
+
const actStack = /* @__PURE__ */ new Map();
|
|
56346
|
+
const startAct = (actor, r3) => {
|
|
56347
|
+
const arr = actStack.get(actor) || [];
|
|
56348
|
+
arr.push(r3);
|
|
56349
|
+
actStack.set(actor, arr);
|
|
56350
|
+
};
|
|
56351
|
+
const endAct = (actor, r3) => {
|
|
56352
|
+
const arr = actStack.get(actor) || [];
|
|
56353
|
+
const start = arr.pop();
|
|
56354
|
+
if (start != null) {
|
|
56355
|
+
const p3 = col.get(actor);
|
|
56356
|
+
if (p3) {
|
|
56357
|
+
activations.push({ actor, x: p3.x + p3.width / 2 - 4, y: yForRow(start) - ROW_H / 2, width: 8, height: yForRow(r3) - yForRow(start) });
|
|
56358
|
+
}
|
|
56359
|
+
}
|
|
56360
|
+
actStack.set(actor, arr);
|
|
56361
|
+
};
|
|
56362
|
+
const openForLayout = [];
|
|
56363
|
+
model.events.forEach((ev, idx) => {
|
|
56364
|
+
const r3 = rowIndexForEvent.has(idx) ? rowIndexForEvent.get(idx) : null;
|
|
56365
|
+
switch (ev.kind) {
|
|
56366
|
+
case "message": {
|
|
56367
|
+
const p1 = col.get(ev.msg.from), p22 = col.get(ev.msg.to);
|
|
56368
|
+
if (p1 && p22 && r3 != null) {
|
|
56369
|
+
const y2 = yForRow(r3);
|
|
56370
|
+
const x1 = p1.x + p1.width / 2;
|
|
56371
|
+
const x22 = p22.x + p22.width / 2;
|
|
56372
|
+
messages.push({ from: p1.id, to: p22.id, text: ev.msg.text, y: y2, x1, x2: x22, line: ev.msg.line, startMarker: ev.msg.startMarker, endMarker: ev.msg.endMarker, async: ev.msg.async });
|
|
56373
|
+
if (ev.msg.activateTarget)
|
|
56374
|
+
startAct(ev.msg.to, r3);
|
|
56375
|
+
if (ev.msg.deactivateTarget)
|
|
56376
|
+
endAct(ev.msg.to, r3);
|
|
56377
|
+
const top = openForLayout[openForLayout.length - 1];
|
|
56378
|
+
if (top)
|
|
56379
|
+
top.lastRow = r3;
|
|
56380
|
+
}
|
|
56381
|
+
break;
|
|
56382
|
+
}
|
|
56383
|
+
case "note": {
|
|
56384
|
+
if (r3 == null)
|
|
56385
|
+
break;
|
|
56386
|
+
const estLines = (text, width2) => {
|
|
56387
|
+
const charsPerLine = Math.max(8, Math.floor((width2 - NOTE_PAD * 2) / 7));
|
|
56388
|
+
const length = text ? text.length : 0;
|
|
56389
|
+
return Math.max(1, Math.ceil(length / charsPerLine));
|
|
56390
|
+
};
|
|
56391
|
+
const y2 = yForRow(r3) - NOTE_PAD;
|
|
56392
|
+
if (ev.note.pos === "over") {
|
|
56393
|
+
const [a3, b3] = ev.note.actors;
|
|
56394
|
+
const p1 = col.get(a3), p22 = b3 ? col.get(b3) : p1;
|
|
56395
|
+
if (p1 && p22) {
|
|
56396
|
+
const left = Math.min(p1.x + p1.width / 2, p22.x + p22.width / 2);
|
|
56397
|
+
const right = Math.max(p1.x + p1.width / 2, p22.x + p22.width / 2);
|
|
56398
|
+
const w3 = right - left + NOTE_PAD * 2;
|
|
56399
|
+
const lines = estLines(ev.note.text, w3);
|
|
56400
|
+
const h3 = Math.max(ROW_H - NOTE_PAD, lines * 16 + NOTE_PAD);
|
|
56401
|
+
notes.push({ x: left - NOTE_PAD, y: y2, width: w3, height: h3, text: ev.note.text, anchor: "over" });
|
|
56402
|
+
}
|
|
56403
|
+
} else {
|
|
56404
|
+
const actor = ev.note.actors[0];
|
|
56405
|
+
const p3 = col.get(actor);
|
|
56406
|
+
if (p3) {
|
|
56407
|
+
const leftSide = ev.note.pos === "leftOf";
|
|
56408
|
+
const x4 = leftSide ? p3.x - NOTE_W - 10 : p3.x + p3.width + 10;
|
|
56409
|
+
const lines = estLines(ev.note.text, NOTE_W);
|
|
56410
|
+
const h3 = Math.max(ROW_H - NOTE_PAD, lines * 16 + NOTE_PAD);
|
|
56411
|
+
notes.push({ x: x4, y: y2, width: NOTE_W, height: h3, text: ev.note.text, anchor: leftSide ? "left" : "right" });
|
|
56412
|
+
}
|
|
56413
|
+
}
|
|
56414
|
+
const top = openForLayout[openForLayout.length - 1];
|
|
56415
|
+
if (top && r3 != null)
|
|
56416
|
+
top.lastRow = r3;
|
|
56417
|
+
break;
|
|
56418
|
+
}
|
|
56419
|
+
case "activate":
|
|
56420
|
+
if (r3 != null)
|
|
56421
|
+
startAct(ev.actor, r3);
|
|
56422
|
+
break;
|
|
56423
|
+
case "deactivate":
|
|
56424
|
+
if (r3 != null)
|
|
56425
|
+
endAct(ev.actor, r3);
|
|
56426
|
+
break;
|
|
56427
|
+
case "block-start": {
|
|
56428
|
+
const startRow = r3 != null ? r3 : row;
|
|
56429
|
+
openForLayout.push({ block: ev.block, startRow, branches: [] });
|
|
56430
|
+
break;
|
|
56431
|
+
}
|
|
56432
|
+
case "block-branch": {
|
|
56433
|
+
const top = openForLayout[openForLayout.length - 1];
|
|
56434
|
+
if (top && r3 != null) {
|
|
56435
|
+
top.branches.push({ title: ev.branch.title, row: r3 });
|
|
56436
|
+
top.lastRow = r3;
|
|
56437
|
+
}
|
|
56438
|
+
break;
|
|
56439
|
+
}
|
|
56440
|
+
case "block-end": {
|
|
56441
|
+
const top = openForLayout.pop();
|
|
56442
|
+
if (top) {
|
|
56443
|
+
const first2 = participants.length > 0 ? participants[0] : void 0;
|
|
56444
|
+
const last2 = participants.length > 0 ? participants[participants.length - 1] : void 0;
|
|
56445
|
+
const left = first2 ? first2.x : MARGIN_X;
|
|
56446
|
+
const right = last2 ? last2.x + last2.width : left + 200;
|
|
56447
|
+
const yTop = yForRow(top.startRow) - ROW_H / 2 - (BLOCK_PAD + TITLE_EXTRA_TOP);
|
|
56448
|
+
const endRow = top.lastRow != null ? top.lastRow : top.startRow;
|
|
56449
|
+
const yBot = yForRow(endRow) + ROW_H / 2 + BLOCK_PAD;
|
|
56450
|
+
const layout = { type: top.block.type, title: top.block.title, x: left - BLOCK_PAD, y: yTop, width: right - left + BLOCK_PAD * 2, height: yBot - yTop };
|
|
56451
|
+
if (top.branches.length)
|
|
56452
|
+
layout.branches = top.branches.map((b3) => ({ title: b3.title, y: yForRow(b3.row) - ROW_H / 2 }));
|
|
56453
|
+
blocks.push(layout);
|
|
56454
|
+
}
|
|
56455
|
+
break;
|
|
56456
|
+
}
|
|
56457
|
+
default:
|
|
56458
|
+
break;
|
|
56459
|
+
}
|
|
56460
|
+
});
|
|
56461
|
+
const lastRow = row;
|
|
56462
|
+
for (const [actor, arr] of actStack.entries()) {
|
|
56463
|
+
while (arr.length) {
|
|
56464
|
+
const start = arr.pop();
|
|
56465
|
+
const p3 = col.get(actor);
|
|
56466
|
+
if (p3)
|
|
56467
|
+
activations.push({ actor, x: p3.x + p3.width / 2 - 4, y: yForRow(start) - ROW_H / 2, width: 8, height: yForRow(lastRow) - yForRow(start) });
|
|
56468
|
+
}
|
|
56469
|
+
}
|
|
56470
|
+
return { width, height, participants, lifelines, messages, notes, blocks, activations };
|
|
56471
|
+
}
|
|
56472
|
+
var MARGIN_X, MARGIN_Y, ACTOR_FONT_SIZE, ACTOR_H, LIFELINE_GAP, ACTOR_PAD_X, COL_MIN, ROW_H, NOTE_W, NOTE_PAD, BLOCK_PAD, TITLE_EXTRA_TOP;
|
|
56473
|
+
var init_sequence_layout = __esm({
|
|
56474
|
+
"node_modules/@probelabs/maid/out/renderer/sequence-layout.js"() {
|
|
56475
|
+
init_utils4();
|
|
56476
|
+
MARGIN_X = 24;
|
|
56477
|
+
MARGIN_Y = 24;
|
|
56478
|
+
ACTOR_FONT_SIZE = 16;
|
|
56479
|
+
ACTOR_H = 32;
|
|
56480
|
+
LIFELINE_GAP = 4;
|
|
56481
|
+
ACTOR_PAD_X = 12;
|
|
56482
|
+
COL_MIN = 110;
|
|
56483
|
+
ROW_H = 36;
|
|
56484
|
+
NOTE_W = 160;
|
|
56485
|
+
NOTE_PAD = 8;
|
|
56486
|
+
BLOCK_PAD = 8;
|
|
56487
|
+
TITLE_EXTRA_TOP = 12;
|
|
56488
|
+
}
|
|
56489
|
+
});
|
|
56490
|
+
|
|
56491
|
+
// node_modules/@probelabs/maid/out/renderer/sequence-renderer.js
|
|
56492
|
+
function renderSequence(model, opts = {}) {
|
|
56493
|
+
const layout = layoutSequence(model);
|
|
56494
|
+
const svgParts = [];
|
|
56495
|
+
const width = Math.ceil(layout.width);
|
|
56496
|
+
const height = Math.ceil(layout.height);
|
|
56497
|
+
svgParts.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${width + 50}" height="${height + 40}" viewBox="-50 -10 ${width + 50} ${height + 40}">`);
|
|
56498
|
+
const sharedCss = buildSharedCss({
|
|
56499
|
+
fontFamily: "Arial, sans-serif",
|
|
56500
|
+
fontSize: 14,
|
|
56501
|
+
nodeFill: "#eef0ff",
|
|
56502
|
+
nodeStroke: "#3f3f3f",
|
|
56503
|
+
edgeStroke: "#555555"
|
|
56504
|
+
});
|
|
56505
|
+
svgParts.push(` <style>${sharedCss}</style>`);
|
|
56506
|
+
for (const p3 of layout.participants)
|
|
56507
|
+
drawParticipant(svgParts, p3);
|
|
56508
|
+
for (const b3 of layout.blocks)
|
|
56509
|
+
svgParts.push(blockBackground(b3.x, b3.y, b3.width, b3.height, 0));
|
|
56510
|
+
for (const l3 of layout.lifelines)
|
|
56511
|
+
svgParts.push(` <line class="lifeline" x1="${l3.x}" y1="${l3.y1}" x2="${l3.x}" y2="${l3.y2}"/>`);
|
|
56512
|
+
for (const a3 of layout.activations)
|
|
56513
|
+
svgParts.push(` <rect class="activation" x="${a3.x}" y="${a3.y}" width="${a3.width}" height="${a3.height}" />`);
|
|
56514
|
+
let counter = model.autonumber?.on ? model.autonumber.start ?? 1 : void 0;
|
|
56515
|
+
const step = model.autonumber?.on ? model.autonumber.step ?? 1 : void 0;
|
|
56516
|
+
for (const m3 of layout.messages) {
|
|
56517
|
+
drawMessage(svgParts, m3);
|
|
56518
|
+
const label = formatMessageLabel(m3.text, counter);
|
|
56519
|
+
if (label)
|
|
56520
|
+
drawMessageLabel(svgParts, m3, label, counter);
|
|
56521
|
+
if (counter != null)
|
|
56522
|
+
counter += step;
|
|
56523
|
+
}
|
|
56524
|
+
for (const n3 of layout.notes)
|
|
56525
|
+
drawNote(svgParts, n3);
|
|
56526
|
+
for (const b3 of layout.blocks) {
|
|
56527
|
+
const title = b3.title ? `${b3.type}: ${b3.title}` : b3.type;
|
|
56528
|
+
const branches = (b3.branches || []).map((br) => ({ y: br.y, title: br.title }));
|
|
56529
|
+
svgParts.push(blockOverlay(b3.x, b3.y, b3.width, b3.height, title, branches, 0, "left", "left", 0));
|
|
56530
|
+
}
|
|
56531
|
+
for (const p3 of layout.participants)
|
|
56532
|
+
drawParticipantBottom(svgParts, p3, layout);
|
|
56533
|
+
svgParts.push("</svg>");
|
|
56534
|
+
let svg = svgParts.join("\n");
|
|
56535
|
+
if (opts.theme)
|
|
56536
|
+
svg = applySequenceTheme(svg, opts.theme);
|
|
56537
|
+
return svg;
|
|
56538
|
+
}
|
|
56539
|
+
function drawParticipant(out, p3) {
|
|
56540
|
+
out.push(` <g class="actor" transform="translate(${p3.x},${p3.y})">`);
|
|
56541
|
+
out.push(` <rect class="node-shape" width="${p3.width}" height="${p3.height}" rx="0"/>`);
|
|
56542
|
+
out.push(` <text class="node-label" x="${p3.width / 2}" y="${p3.height / 2}" text-anchor="middle" dominant-baseline="middle">${escapeXml(p3.display)}</text>`);
|
|
56543
|
+
out.push(" </g>");
|
|
56544
|
+
}
|
|
56545
|
+
function drawParticipantBottom(out, p3, layout) {
|
|
56546
|
+
const lifeline = layout.lifelines.find((l3) => Math.abs(l3.x - (p3.x + p3.width / 2)) < 1e-3);
|
|
56547
|
+
const y2 = lifeline ? lifeline.y2 : layout.height - 28;
|
|
56548
|
+
out.push(` <g class="actor" transform="translate(${p3.x},${y2})">`);
|
|
56549
|
+
out.push(` <rect class="node-shape" width="${p3.width}" height="${p3.height}" rx="0"/>`);
|
|
56550
|
+
out.push(` <text class="node-label" x="${p3.width / 2}" y="${p3.height / 2}" text-anchor="middle" dominant-baseline="middle">${escapeXml(p3.display)}</text>`);
|
|
56551
|
+
out.push(" </g>");
|
|
56552
|
+
}
|
|
56553
|
+
function drawMessage(out, m3) {
|
|
56554
|
+
const cls = `msg-line ${m3.line}`.trim();
|
|
56555
|
+
const x1 = m3.x1, x22 = m3.x2, y2 = m3.y;
|
|
56556
|
+
out.push(` <path class="${cls}" d="M ${x1} ${y2} L ${x22} ${y2}" />`);
|
|
56557
|
+
const start = { x: x1, y: y2 };
|
|
56558
|
+
const end = { x: x22, y: y2 };
|
|
56559
|
+
if (m3.endMarker === "arrow")
|
|
56560
|
+
out.push(" " + triangleAtEnd(start, end));
|
|
56561
|
+
if (m3.startMarker === "arrow")
|
|
56562
|
+
out.push(" " + triangleAtStart(start, end));
|
|
56563
|
+
if (m3.endMarker === "open")
|
|
56564
|
+
out.push(` <circle class="openhead" cx="${x22}" cy="${y2}" r="4" />`);
|
|
56565
|
+
if (m3.startMarker === "open")
|
|
56566
|
+
out.push(` <circle class="openhead" cx="${x1}" cy="${y2}" r="4" />`);
|
|
56567
|
+
if (m3.endMarker === "cross")
|
|
56568
|
+
out.push(` <g class="crosshead" transform="translate(${x22},${y2})"><path d="M -4 -4 L 4 4"/><path d="M -4 4 L 4 -4"/></g>`);
|
|
56569
|
+
if (m3.startMarker === "cross")
|
|
56570
|
+
out.push(` <g class="crosshead" transform="translate(${x1},${y2})"><path d="M -4 -4 L 4 4"/><path d="M -4 4 L 4 -4"/></g>`);
|
|
56571
|
+
}
|
|
56572
|
+
function formatMessageLabel(text, counter) {
|
|
56573
|
+
if (!text && counter == null)
|
|
56574
|
+
return void 0;
|
|
56575
|
+
if (counter != null && text)
|
|
56576
|
+
return `${counter}: ${text}`;
|
|
56577
|
+
if (counter != null)
|
|
56578
|
+
return String(counter);
|
|
56579
|
+
return text;
|
|
56580
|
+
}
|
|
56581
|
+
function drawMessageLabel(out, m3, label, _counter) {
|
|
56582
|
+
const xMid = (m3.x1 + m3.x2) / 2;
|
|
56583
|
+
const h3 = 16;
|
|
56584
|
+
const w3 = Math.max(20, measureText(label, 12) + 10);
|
|
56585
|
+
const x3 = xMid - w3 / 2;
|
|
56586
|
+
const y2 = m3.y - 10 - h3 / 2;
|
|
56587
|
+
out.push(` <rect class="msg-label-bg" x="${x3}" y="${y2}" width="${w3}" height="${h3}" rx="0"/>`);
|
|
56588
|
+
out.push(` <text class="msg-label" x="${xMid}" y="${y2 + h3 / 2}" text-anchor="middle">${escapeXml(label)}</text>`);
|
|
56589
|
+
}
|
|
56590
|
+
function drawNote(out, n3) {
|
|
56591
|
+
out.push(` <g class="note" transform="translate(${n3.x},${n3.y})">`);
|
|
56592
|
+
out.push(` <rect width="${n3.width}" height="${n3.height}" rx="0"/>`);
|
|
56593
|
+
out.push(` <text class="note-text" x="${n3.width / 2}" y="${n3.height / 2 + 4}" text-anchor="middle">${escapeXml(n3.text)}</text>`);
|
|
56594
|
+
out.push(" </g>");
|
|
56595
|
+
}
|
|
56596
|
+
function applySequenceTheme(svg, theme) {
|
|
56597
|
+
let out = svg;
|
|
56598
|
+
if (theme.actorBkg)
|
|
56599
|
+
out = out.replace(/\.actor-rect\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.actorBkg)};`));
|
|
56600
|
+
if (theme.actorBorder)
|
|
56601
|
+
out = out.replace(/\.actor-rect\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.actorBorder)};`));
|
|
56602
|
+
if (theme.actorTextColor)
|
|
56603
|
+
out = out.replace(/\.actor-label\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.actorTextColor)};`));
|
|
56604
|
+
if (theme.lifelineColor)
|
|
56605
|
+
out = out.replace(/\.lifeline\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.lifelineColor)};`));
|
|
56606
|
+
if (theme.lineColor)
|
|
56607
|
+
out = out.replace(/\.msg-line\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.lineColor)};`));
|
|
56608
|
+
if (theme.arrowheadColor) {
|
|
56609
|
+
out = out.replace(/\.arrowhead\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.arrowheadColor)};`));
|
|
56610
|
+
out = out.replace(/\.openhead\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.arrowheadColor)};`));
|
|
56611
|
+
out = out.replace(/\.crosshead\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.arrowheadColor)};`));
|
|
56612
|
+
}
|
|
56613
|
+
if (theme.noteBkg)
|
|
56614
|
+
out = out.replace(/\.note\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.noteBkg)};`));
|
|
56615
|
+
if (theme.noteBorder)
|
|
56616
|
+
out = out.replace(/\.note\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.noteBorder)};`));
|
|
56617
|
+
if (theme.noteTextColor)
|
|
56618
|
+
out = out.replace(/\.note-text\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.noteTextColor)};`));
|
|
56619
|
+
if (theme.activationBkg)
|
|
56620
|
+
out = out.replace(/\.activation\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.activationBkg)};`));
|
|
56621
|
+
if (theme.activationBorder)
|
|
56622
|
+
out = out.replace(/\.activation\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.activationBorder)};`));
|
|
56623
|
+
return out;
|
|
56624
|
+
}
|
|
56625
|
+
var init_sequence_renderer = __esm({
|
|
56626
|
+
"node_modules/@probelabs/maid/out/renderer/sequence-renderer.js"() {
|
|
56627
|
+
init_sequence_layout();
|
|
56628
|
+
init_utils4();
|
|
56629
|
+
init_arrow_utils();
|
|
56630
|
+
init_block_utils();
|
|
56631
|
+
init_styles();
|
|
56632
|
+
}
|
|
56633
|
+
});
|
|
56634
|
+
|
|
56635
|
+
// node_modules/@probelabs/maid/out/core/frontmatter.js
|
|
56636
|
+
function parseFrontmatter(input) {
|
|
56637
|
+
const text = input.startsWith("\uFEFF") ? input.slice(1) : input;
|
|
56638
|
+
const lines = text.split(/\r?\n/);
|
|
56639
|
+
if (lines.length < 3 || lines[0].trim() !== "---")
|
|
56640
|
+
return null;
|
|
56641
|
+
let i3 = 1;
|
|
56642
|
+
const block = [];
|
|
56643
|
+
while (i3 < lines.length && lines[i3].trim() !== "---") {
|
|
56644
|
+
block.push(lines[i3]);
|
|
56645
|
+
i3++;
|
|
56646
|
+
}
|
|
56647
|
+
if (i3 >= lines.length)
|
|
56648
|
+
return null;
|
|
56649
|
+
const body = lines.slice(i3 + 1).join("\n");
|
|
56650
|
+
const raw = block.join("\n");
|
|
56651
|
+
const config = {};
|
|
56652
|
+
const themeVars = {};
|
|
56653
|
+
let themeUnderConfig = false;
|
|
56654
|
+
let ctx = "root";
|
|
56655
|
+
for (const line of block) {
|
|
56656
|
+
if (!line.trim())
|
|
56657
|
+
continue;
|
|
56658
|
+
const indent = line.match(/^\s*/)?.[0].length ?? 0;
|
|
56659
|
+
const mKey = line.match(/^\s*([A-Za-z0-9_\-]+):\s*(.*)$/);
|
|
56660
|
+
if (!mKey)
|
|
56661
|
+
continue;
|
|
56662
|
+
const key = mKey[1];
|
|
56663
|
+
let value = mKey[2] || "";
|
|
56664
|
+
if (indent === 0) {
|
|
56665
|
+
if (key === "config") {
|
|
56666
|
+
ctx = "config";
|
|
56667
|
+
continue;
|
|
56668
|
+
}
|
|
56669
|
+
if (key === "themeVariables") {
|
|
56670
|
+
ctx = "theme";
|
|
56671
|
+
continue;
|
|
56672
|
+
}
|
|
56673
|
+
ctx = "root";
|
|
56674
|
+
continue;
|
|
56675
|
+
}
|
|
56676
|
+
if (ctx === "config") {
|
|
56677
|
+
if (indent <= 2 && key !== "pie" && key !== "themeVariables")
|
|
56678
|
+
continue;
|
|
56679
|
+
if (key === "pie") {
|
|
56680
|
+
ctx = "config.pie";
|
|
56681
|
+
ensure(config, "pie", {});
|
|
56682
|
+
continue;
|
|
56683
|
+
}
|
|
56684
|
+
if (key === "themeVariables") {
|
|
56685
|
+
ctx = "theme";
|
|
56686
|
+
themeUnderConfig = true;
|
|
56687
|
+
continue;
|
|
56688
|
+
}
|
|
56689
|
+
continue;
|
|
56690
|
+
}
|
|
56691
|
+
if (ctx === "config.pie") {
|
|
56692
|
+
if (indent < 4) {
|
|
56693
|
+
if (key === "pie") {
|
|
56694
|
+
ctx = "config.pie";
|
|
56695
|
+
ensure(config, "pie", {});
|
|
56696
|
+
continue;
|
|
56697
|
+
}
|
|
56698
|
+
if (key === "themeVariables") {
|
|
56699
|
+
ctx = "theme";
|
|
56700
|
+
themeUnderConfig = true;
|
|
56701
|
+
continue;
|
|
56702
|
+
}
|
|
56703
|
+
ctx = "config";
|
|
56704
|
+
continue;
|
|
56705
|
+
}
|
|
56706
|
+
setKV(config.pie, key, value);
|
|
56707
|
+
continue;
|
|
56708
|
+
}
|
|
56709
|
+
if (ctx === "theme") {
|
|
56710
|
+
if (indent < 2) {
|
|
56711
|
+
ctx = "root";
|
|
56712
|
+
continue;
|
|
56713
|
+
}
|
|
56714
|
+
setKV(themeVars, key, value);
|
|
56715
|
+
continue;
|
|
56716
|
+
}
|
|
56717
|
+
}
|
|
56718
|
+
if (themeUnderConfig && Object.keys(themeVars).length) {
|
|
56719
|
+
ensure(config, "themeVariables", {});
|
|
56720
|
+
Object.assign(config.themeVariables, themeVars);
|
|
56721
|
+
}
|
|
56722
|
+
return { raw, body, config: Object.keys(config).length ? config : void 0, themeVariables: Object.keys(themeVars).length ? themeVars : void 0 };
|
|
56723
|
+
}
|
|
56724
|
+
function ensure(obj, key, def) {
|
|
56725
|
+
if (obj[key] == null)
|
|
56726
|
+
obj[key] = def;
|
|
56727
|
+
}
|
|
56728
|
+
function unquote2(val) {
|
|
56729
|
+
const v3 = val.trim();
|
|
56730
|
+
if (v3.startsWith('"') && v3.endsWith('"') || v3.startsWith("'") && v3.endsWith("'")) {
|
|
56731
|
+
return v3.slice(1, -1);
|
|
56732
|
+
}
|
|
56733
|
+
return v3;
|
|
56734
|
+
}
|
|
56735
|
+
function setKV(target, key, rawValue) {
|
|
56736
|
+
const v3 = unquote2(rawValue);
|
|
56737
|
+
if (v3 === "") {
|
|
56738
|
+
target[key] = "";
|
|
56739
|
+
return;
|
|
56740
|
+
}
|
|
56741
|
+
const num = Number(v3);
|
|
56742
|
+
if (!Number.isNaN(num) && /^-?[0-9]+(\.[0-9]+)?$/.test(v3)) {
|
|
56743
|
+
target[key] = num;
|
|
56744
|
+
return;
|
|
56745
|
+
}
|
|
56746
|
+
if (/^(true|false)$/i.test(v3)) {
|
|
56747
|
+
target[key] = /^true$/i.test(v3);
|
|
56748
|
+
return;
|
|
56749
|
+
}
|
|
56750
|
+
target[key] = v3;
|
|
56751
|
+
}
|
|
56752
|
+
var init_frontmatter = __esm({
|
|
56753
|
+
"node_modules/@probelabs/maid/out/core/frontmatter.js"() {
|
|
56754
|
+
}
|
|
56755
|
+
});
|
|
56756
|
+
|
|
56757
|
+
// node_modules/@probelabs/maid/out/renderer/dot-renderer.js
|
|
56758
|
+
var init_dot_renderer = __esm({
|
|
56759
|
+
"node_modules/@probelabs/maid/out/renderer/dot-renderer.js"() {
|
|
56760
|
+
}
|
|
56761
|
+
});
|
|
56762
|
+
|
|
56763
|
+
// node_modules/@probelabs/maid/out/renderer/index.js
|
|
56764
|
+
function applyPieTheme(svg, theme) {
|
|
56765
|
+
if (!theme)
|
|
56766
|
+
return svg;
|
|
56767
|
+
let out = svg;
|
|
56768
|
+
if (theme.pieOuterStrokeWidth != null || theme.pieStrokeColor) {
|
|
56769
|
+
out = out.replace(/\.pieOuterCircle\s*\{[^}]*\}/, (m3) => {
|
|
56770
|
+
let rule = m3;
|
|
56771
|
+
if (theme.pieStrokeColor)
|
|
56772
|
+
rule = rule.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.pieStrokeColor)};`);
|
|
56773
|
+
if (theme.pieOuterStrokeWidth != null)
|
|
56774
|
+
rule = rule.replace(/stroke-width:\s*[^;]+;/, `stroke-width: ${String(theme.pieOuterStrokeWidth)};`);
|
|
56775
|
+
return rule;
|
|
56776
|
+
});
|
|
56777
|
+
if (theme.pieStrokeColor) {
|
|
56778
|
+
out = out.replace(/\.pieCircle\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.pieStrokeColor)};`));
|
|
56779
|
+
}
|
|
56780
|
+
}
|
|
56781
|
+
if (theme.pieSectionTextColor) {
|
|
56782
|
+
const c3 = String(theme.pieSectionTextColor);
|
|
56783
|
+
out = out.replace(/\.slice-label \{[^}]*\}/, (m3) => m3.replace(/fill:\s*#[0-9A-Fa-f]{3,8}|fill:\s*rgb\([^)]*\)/, `fill: ${c3}`));
|
|
56784
|
+
out = out.replace(/<text class="slice-label"([^>]*)>/g, `<text class="slice-label"$1 fill="${c3}">`);
|
|
56785
|
+
}
|
|
56786
|
+
if (theme.pieTitleTextColor) {
|
|
56787
|
+
const c3 = String(theme.pieTitleTextColor);
|
|
56788
|
+
out = out.replace(/<text class="pie-title"([^>]*)>/g, `<text class="pie-title"$1 fill="${c3}">`);
|
|
56789
|
+
}
|
|
56790
|
+
if (theme.pieSectionTextSize) {
|
|
56791
|
+
const size = String(theme.pieSectionTextSize);
|
|
56792
|
+
out = out.replace(/<text class="slice-label"([^>]*)>/g, `<text class="slice-label"$1 font-size="${size}">`);
|
|
56793
|
+
}
|
|
56794
|
+
if (theme.pieTitleTextSize) {
|
|
56795
|
+
const size = String(theme.pieTitleTextSize);
|
|
56796
|
+
out = out.replace(/<text class="pie-title"([^>]*)>/g, `<text class="pie-title"$1 font-size="${size}">`);
|
|
56797
|
+
}
|
|
56798
|
+
const colors = [];
|
|
56799
|
+
for (let i3 = 1; i3 <= 24; i3++) {
|
|
56800
|
+
const key = "pie" + i3;
|
|
56801
|
+
if (theme[key])
|
|
56802
|
+
colors.push(String(theme[key]));
|
|
56803
|
+
}
|
|
56804
|
+
if (colors.length) {
|
|
56805
|
+
let idx = 0;
|
|
56806
|
+
out = out.replace(/<path[^>]*class="pieCircle"[^>]*\sfill="([^"]+)"/g, (_m2) => {
|
|
56807
|
+
const color = colors[idx] ?? null;
|
|
56808
|
+
idx++;
|
|
56809
|
+
if (color)
|
|
56810
|
+
return _m2.replace(/fill="([^"]+)"/, `fill="${color}"`);
|
|
56811
|
+
return _m2;
|
|
56812
|
+
});
|
|
56813
|
+
}
|
|
56814
|
+
return out;
|
|
56815
|
+
}
|
|
56816
|
+
function applyFlowchartTheme(svg, theme) {
|
|
56817
|
+
if (!theme)
|
|
56818
|
+
return svg;
|
|
56819
|
+
let out = svg;
|
|
56820
|
+
if (theme.nodeBkg || theme.nodeBorder) {
|
|
56821
|
+
out = out.replace(/\.node-shape\s*\{[^}]*\}/, (m3) => {
|
|
56822
|
+
let rule = m3;
|
|
56823
|
+
if (theme.nodeBkg)
|
|
56824
|
+
rule = rule.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.nodeBkg)};`);
|
|
56825
|
+
if (theme.nodeBorder)
|
|
56826
|
+
rule = rule.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.nodeBorder)};`);
|
|
56827
|
+
return rule;
|
|
56828
|
+
});
|
|
56829
|
+
}
|
|
56830
|
+
if (theme.nodeTextColor) {
|
|
56831
|
+
out = out.replace(/\.node-label\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.nodeTextColor)};`));
|
|
56832
|
+
}
|
|
56833
|
+
if (theme.lineColor) {
|
|
56834
|
+
out = out.replace(/\.edge-path\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.lineColor)};`));
|
|
56835
|
+
}
|
|
56836
|
+
if (theme.arrowheadColor) {
|
|
56837
|
+
out = out.replace(/(<path d="M0,0 L0,[0-9.]+ L[0-9.]+,[0-9.]+ z"[^>]*)(fill="[^"]*")/g, (_m2, p1) => `${p1}fill="${String(theme.arrowheadColor)}"`);
|
|
56838
|
+
out = out.replace(/(<circle cx="4\.5" cy="4\.5" r="4\.5"[^>]*)(fill="[^"]*")/g, (_m2, p1) => `${p1}fill="${String(theme.arrowheadColor)}"`);
|
|
56839
|
+
}
|
|
56840
|
+
if (theme.clusterBkg) {
|
|
56841
|
+
out = out.replace(/\.cluster-bg\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.clusterBkg)};`));
|
|
56842
|
+
}
|
|
56843
|
+
if (theme.clusterBorder) {
|
|
56844
|
+
out = out.replace(/\.cluster-border\s*\{[^}]*\}/, (m3) => m3.replace(/stroke:\s*[^;]+;/, `stroke: ${String(theme.clusterBorder)};`));
|
|
56845
|
+
}
|
|
56846
|
+
if (theme.clusterTextColor) {
|
|
56847
|
+
out = out.replace(/\.cluster-label-text\s*\{[^}]*\}/, (m3) => m3.replace(/fill:\s*[^;]+;/, `fill: ${String(theme.clusterTextColor)};`));
|
|
56848
|
+
}
|
|
56849
|
+
if (theme.fontFamily)
|
|
56850
|
+
out = out.replace(/\.node-label\s*\{[^}]*\}/, (m3) => m3.replace(/font-family:\s*[^;]+;/, `font-family: ${String(theme.fontFamily)};`));
|
|
56851
|
+
if (theme.fontSize)
|
|
56852
|
+
out = out.replace(/\.node-label\s*\{[^}]*\}/, (m3) => m3.replace(/font-size:\s*[^;]+;/, `font-size: ${String(theme.fontSize)};`));
|
|
56853
|
+
return out;
|
|
56854
|
+
}
|
|
56855
|
+
function renderMermaid(text, options = {}) {
|
|
56856
|
+
const renderer = new MermaidRenderer(options.layoutEngine, options.renderer);
|
|
56857
|
+
return renderer.renderAny(text, options);
|
|
56858
|
+
}
|
|
56859
|
+
var MermaidRenderer;
|
|
56860
|
+
var init_renderer = __esm({
|
|
56861
|
+
"node_modules/@probelabs/maid/out/renderer/index.js"() {
|
|
56862
|
+
init_lexer2();
|
|
56863
|
+
init_parser2();
|
|
56864
|
+
init_graph_builder();
|
|
56865
|
+
init_layout();
|
|
56866
|
+
init_svg_generator();
|
|
56867
|
+
init_pie_builder();
|
|
56868
|
+
init_pie_renderer();
|
|
56869
|
+
init_sequence_builder();
|
|
56870
|
+
init_sequence_renderer();
|
|
56871
|
+
init_frontmatter();
|
|
56872
|
+
init_layout();
|
|
56873
|
+
init_svg_generator();
|
|
56874
|
+
init_dot_renderer();
|
|
56875
|
+
MermaidRenderer = class {
|
|
56876
|
+
constructor(layoutEngine, renderer) {
|
|
56877
|
+
this.graphBuilder = new GraphBuilder();
|
|
56878
|
+
this.layoutEngine = layoutEngine || new DagreLayoutEngine();
|
|
56879
|
+
this.renderer = renderer || new SVGRenderer();
|
|
56880
|
+
}
|
|
56881
|
+
/**
|
|
56882
|
+
* Renders a Mermaid flowchart diagram
|
|
56883
|
+
*/
|
|
56884
|
+
render(text, options = {}) {
|
|
56885
|
+
const errors = [];
|
|
56886
|
+
const layoutEngine = options.layoutEngine || this.layoutEngine;
|
|
56887
|
+
const renderer = options.renderer || this.renderer;
|
|
56888
|
+
try {
|
|
56889
|
+
const lexResult = tokenize(text);
|
|
56890
|
+
if (lexResult.errors && lexResult.errors.length > 0) {
|
|
56891
|
+
for (const error2 of lexResult.errors) {
|
|
56892
|
+
errors.push({
|
|
56893
|
+
line: error2.line || 1,
|
|
56894
|
+
column: error2.column || 1,
|
|
56895
|
+
message: error2.message,
|
|
56896
|
+
severity: "error",
|
|
56897
|
+
code: "LEXER_ERROR"
|
|
56898
|
+
});
|
|
56899
|
+
}
|
|
56900
|
+
}
|
|
56901
|
+
parserInstance.reset();
|
|
56902
|
+
parserInstance.input = lexResult.tokens;
|
|
56903
|
+
const cst = parserInstance.diagram();
|
|
56904
|
+
if (parserInstance.errors && parserInstance.errors.length > 0) {
|
|
56905
|
+
for (const error2 of parserInstance.errors) {
|
|
56906
|
+
const token = error2.token;
|
|
56907
|
+
errors.push({
|
|
56908
|
+
line: token?.startLine || 1,
|
|
56909
|
+
column: token?.startColumn || 1,
|
|
56910
|
+
message: error2.message,
|
|
56911
|
+
severity: "error",
|
|
56912
|
+
code: "PARSER_ERROR"
|
|
56913
|
+
});
|
|
56914
|
+
}
|
|
56915
|
+
}
|
|
56916
|
+
const graph = this.graphBuilder.build(cst);
|
|
56917
|
+
let layout;
|
|
56918
|
+
try {
|
|
56919
|
+
layout = layoutEngine.layout(graph);
|
|
56920
|
+
} catch (layoutError) {
|
|
56921
|
+
errors.push({
|
|
56922
|
+
line: 1,
|
|
56923
|
+
column: 1,
|
|
56924
|
+
message: layoutError.message || "Layout calculation failed",
|
|
56925
|
+
severity: "error",
|
|
56926
|
+
code: "LAYOUT_ERROR"
|
|
56927
|
+
});
|
|
56928
|
+
return {
|
|
56929
|
+
svg: this.generateErrorSvg(layoutError.message || "Layout calculation failed"),
|
|
56930
|
+
graph,
|
|
56931
|
+
errors
|
|
56932
|
+
};
|
|
56933
|
+
}
|
|
56934
|
+
let svg = renderer.render(layout);
|
|
56935
|
+
if (options.showErrors && errors.length > 0) {
|
|
56936
|
+
svg = this.addErrorOverlays(svg, errors);
|
|
56937
|
+
}
|
|
56938
|
+
return {
|
|
56939
|
+
svg,
|
|
56940
|
+
graph,
|
|
56941
|
+
errors
|
|
56942
|
+
};
|
|
56943
|
+
} catch (error2) {
|
|
56944
|
+
const errorSvg = this.generateErrorSvg(error2.message || "Unknown error occurred");
|
|
56945
|
+
errors.push({
|
|
56946
|
+
line: 1,
|
|
56947
|
+
column: 1,
|
|
56948
|
+
message: error2.message || "Unknown error occurred",
|
|
56949
|
+
severity: "error",
|
|
56950
|
+
code: "RENDER_ERROR"
|
|
56951
|
+
});
|
|
56952
|
+
return {
|
|
56953
|
+
svg: errorSvg,
|
|
56954
|
+
graph: { nodes: [], edges: [], direction: "TD" },
|
|
56955
|
+
errors
|
|
56956
|
+
};
|
|
56957
|
+
}
|
|
56958
|
+
}
|
|
56959
|
+
/**
|
|
56960
|
+
* Renders supported diagram types (flowchart + pie for now)
|
|
56961
|
+
*/
|
|
56962
|
+
renderAny(text, options = {}) {
|
|
56963
|
+
let content = text;
|
|
56964
|
+
let theme;
|
|
56965
|
+
if (text.trimStart().startsWith("---")) {
|
|
56966
|
+
const fm = parseFrontmatter(text);
|
|
56967
|
+
if (fm) {
|
|
56968
|
+
content = fm.body;
|
|
56969
|
+
theme = fm.themeVariables || fm.config && fm.config.themeVariables || void 0;
|
|
56970
|
+
}
|
|
56971
|
+
}
|
|
56972
|
+
const firstLine = content.trim().split("\n")[0];
|
|
56973
|
+
if (/^(flowchart|graph)\s+/i.test(firstLine)) {
|
|
56974
|
+
const res = this.render(content, options);
|
|
56975
|
+
const svg2 = theme ? applyFlowchartTheme(res.svg, theme) : res.svg;
|
|
56976
|
+
return { svg: svg2, graph: res.graph, errors: res.errors };
|
|
56977
|
+
}
|
|
56978
|
+
if (/^pie\b/i.test(firstLine)) {
|
|
56979
|
+
try {
|
|
56980
|
+
const { model, errors } = buildPieModel(content);
|
|
56981
|
+
const svg = renderPie(model, {
|
|
56982
|
+
width: options.width,
|
|
56983
|
+
height: options.height,
|
|
56984
|
+
rimStroke: theme?.pieStrokeColor,
|
|
56985
|
+
rimStrokeWidth: theme?.pieOuterStrokeWidth
|
|
56986
|
+
});
|
|
56987
|
+
const themedSvg = applyPieTheme(svg, theme);
|
|
56988
|
+
return { svg: themedSvg, graph: { nodes: [], edges: [], direction: "TD" }, errors };
|
|
56989
|
+
} catch (e3) {
|
|
56990
|
+
const msg = e3?.message || "Pie render error";
|
|
56991
|
+
const err = [{ line: 1, column: 1, message: msg, severity: "error", code: "PIE_RENDER" }];
|
|
56992
|
+
return { svg: this.generateErrorSvg(msg), graph: { nodes: [], edges: [], direction: "TD" }, errors: err };
|
|
56993
|
+
}
|
|
56994
|
+
}
|
|
56995
|
+
if (/^sequenceDiagram\b/.test(firstLine)) {
|
|
56996
|
+
try {
|
|
56997
|
+
const model = buildSequenceModel(content);
|
|
56998
|
+
const svg = renderSequence(model, { theme });
|
|
56999
|
+
return { svg, graph: { nodes: [], edges: [], direction: "TD" }, errors: [] };
|
|
57000
|
+
} catch (e3) {
|
|
57001
|
+
const msg = e3?.message || "Sequence render error";
|
|
57002
|
+
const err = [{ line: 1, column: 1, message: msg, severity: "error", code: "SEQUENCE_RENDER" }];
|
|
57003
|
+
return { svg: this.generateErrorSvg(msg), graph: { nodes: [], edges: [], direction: "TD" }, errors: err };
|
|
57004
|
+
}
|
|
57005
|
+
}
|
|
57006
|
+
const errorSvg = this.generateErrorSvg("Unsupported diagram type. Rendering supports flowchart, pie, and sequence for now.");
|
|
57007
|
+
return {
|
|
57008
|
+
svg: errorSvg,
|
|
57009
|
+
graph: { nodes: [], edges: [], direction: "TD" },
|
|
57010
|
+
errors: [{
|
|
57011
|
+
line: 1,
|
|
57012
|
+
column: 1,
|
|
57013
|
+
message: "Unsupported diagram type",
|
|
57014
|
+
severity: "error",
|
|
57015
|
+
code: "UNSUPPORTED_TYPE"
|
|
57016
|
+
}]
|
|
57017
|
+
};
|
|
57018
|
+
}
|
|
57019
|
+
addErrorOverlays(svg, errors) {
|
|
57020
|
+
const errorStyle = `
|
|
57021
|
+
<style>
|
|
57022
|
+
.error-indicator {
|
|
57023
|
+
fill: #ff0000;
|
|
57024
|
+
opacity: 0.8;
|
|
57025
|
+
}
|
|
57026
|
+
.error-text {
|
|
57027
|
+
fill: white;
|
|
57028
|
+
font-family: Arial, sans-serif;
|
|
57029
|
+
font-size: 12px;
|
|
57030
|
+
font-weight: bold;
|
|
57031
|
+
}
|
|
57032
|
+
</style>`;
|
|
57033
|
+
const errorIndicator = `
|
|
57034
|
+
<g id="errors">
|
|
57035
|
+
<rect x="5" y="5" width="100" height="25" rx="3" class="error-indicator" />
|
|
57036
|
+
<text x="55" y="20" text-anchor="middle" class="error-text">${errors.length} error${errors.length !== 1 ? "s" : ""}</text>
|
|
57037
|
+
</g>`;
|
|
57038
|
+
return svg.replace("</svg>", `${errorStyle}${errorIndicator}</svg>`);
|
|
57039
|
+
}
|
|
57040
|
+
generateErrorSvg(message) {
|
|
57041
|
+
const width = 400;
|
|
57042
|
+
const height = 200;
|
|
57043
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
57044
|
+
<rect width="${width}" height="${height}" fill="#fee" stroke="#c00" stroke-width="2" />
|
|
57045
|
+
<text x="${width / 2}" y="${height / 2 - 20}" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" fill="#c00">
|
|
57046
|
+
Render Error
|
|
57047
|
+
</text>
|
|
57048
|
+
<text x="${width / 2}" y="${height / 2 + 10}" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#666">
|
|
57049
|
+
${this.wrapText(message, 40).map((line, i3) => `<tspan x="${width / 2}" dy="${i3 === 0 ? 0 : 15}">${this.escapeXml(line)}</tspan>`).join("")}
|
|
57050
|
+
</text>
|
|
57051
|
+
</svg>`;
|
|
57052
|
+
}
|
|
57053
|
+
wrapText(text, maxLength) {
|
|
57054
|
+
const words = text.split(" ");
|
|
57055
|
+
const lines = [];
|
|
57056
|
+
let currentLine = "";
|
|
57057
|
+
for (const word of words) {
|
|
57058
|
+
if (currentLine.length + word.length + 1 <= maxLength) {
|
|
57059
|
+
currentLine += (currentLine ? " " : "") + word;
|
|
57060
|
+
} else {
|
|
57061
|
+
if (currentLine)
|
|
57062
|
+
lines.push(currentLine);
|
|
57063
|
+
currentLine = word;
|
|
57064
|
+
}
|
|
57065
|
+
}
|
|
57066
|
+
if (currentLine)
|
|
57067
|
+
lines.push(currentLine);
|
|
57068
|
+
return lines.slice(0, 3);
|
|
57069
|
+
}
|
|
57070
|
+
escapeXml(text) {
|
|
57071
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
57072
|
+
}
|
|
57073
|
+
};
|
|
57074
|
+
}
|
|
57075
|
+
});
|
|
57076
|
+
|
|
57077
|
+
// node_modules/@probelabs/maid/out/mermaid-compat.js
|
|
57078
|
+
function createMermaidAPI() {
|
|
57079
|
+
return {
|
|
57080
|
+
initialize(_config) {
|
|
57081
|
+
},
|
|
57082
|
+
async render(_id, text, options) {
|
|
57083
|
+
try {
|
|
57084
|
+
const result = renderMermaid(text, options);
|
|
57085
|
+
return { svg: result.svg };
|
|
57086
|
+
} catch (error2) {
|
|
57087
|
+
throw new Error(`Maid render failed: ${error2.message || "Unknown error"}`);
|
|
57088
|
+
}
|
|
57089
|
+
},
|
|
57090
|
+
renderSync(_id, text, options) {
|
|
57091
|
+
try {
|
|
57092
|
+
const result = renderMermaid(text, options);
|
|
57093
|
+
return { svg: result.svg };
|
|
57094
|
+
} catch (error2) {
|
|
57095
|
+
throw new Error(`Maid render failed: ${error2.message || "Unknown error"}`);
|
|
57096
|
+
}
|
|
57097
|
+
}
|
|
57098
|
+
};
|
|
57099
|
+
}
|
|
57100
|
+
var maid;
|
|
57101
|
+
var init_mermaid_compat = __esm({
|
|
57102
|
+
"node_modules/@probelabs/maid/out/mermaid-compat.js"() {
|
|
57103
|
+
init_renderer();
|
|
57104
|
+
maid = createMermaidAPI();
|
|
53684
57105
|
}
|
|
53685
57106
|
});
|
|
53686
57107
|
|
|
@@ -53714,6 +57135,7 @@ var init_out = __esm({
|
|
|
53714
57135
|
init_edits();
|
|
53715
57136
|
init_fixes();
|
|
53716
57137
|
init_renderer();
|
|
57138
|
+
init_mermaid_compat();
|
|
53717
57139
|
init_router();
|
|
53718
57140
|
init_fixes();
|
|
53719
57141
|
init_edits();
|
|
@@ -54455,6 +57877,7 @@ FIXING METHODOLOGY:
|
|
|
54455
57877
|
- Incorrect formatting for diagram-specific elements
|
|
54456
57878
|
- **Parentheses in node labels or subgraph names**: Wrap text containing parentheses in double quotes to prevent GitHub parsing errors
|
|
54457
57879
|
- Single quotes in node labels (GitHub's parser expects double quotes)
|
|
57880
|
+
- **Edge/Arrow labels with spaces**: MUST use pipe syntax like "A --|Label Text|--> B" or "A -- |Label Text| --> B". NEVER use double quotes like "A -- \\"Label\\" --> B" which is INVALID
|
|
54458
57881
|
4. **Preserve semantic meaning** - never change the intended flow or relationships
|
|
54459
57882
|
5. **Use proper escaping** for special characters and spaces
|
|
54460
57883
|
6. **Ensure consistency** in naming conventions and formatting
|
|
@@ -54487,8 +57910,10 @@ When presented with a broken Mermaid diagram, analyze it thoroughly and provide
|
|
|
54487
57910
|
debug: this.options.debug,
|
|
54488
57911
|
tracer: this.options.tracer,
|
|
54489
57912
|
allowEdit: this.options.allowEdit,
|
|
54490
|
-
maxIterations: 2
|
|
57913
|
+
maxIterations: 2,
|
|
54491
57914
|
// Limit mermaid fixing to 2 iterations to prevent long loops
|
|
57915
|
+
disableMermaidValidation: true
|
|
57916
|
+
// CRITICAL: Disable mermaid validation in nested agent to prevent infinite recursion
|
|
54492
57917
|
});
|
|
54493
57918
|
}
|
|
54494
57919
|
return this.agent;
|
|
@@ -57578,7 +61003,7 @@ function parseArgs() {
|
|
|
57578
61003
|
return config;
|
|
57579
61004
|
}
|
|
57580
61005
|
function showHelp() {
|
|
57581
|
-
console.
|
|
61006
|
+
console.error(`
|
|
57582
61007
|
probe agent - AI-powered code exploration tool
|
|
57583
61008
|
|
|
57584
61009
|
Usage:
|
|
@@ -57985,7 +61410,7 @@ async function main() {
|
|
|
57985
61410
|
bashConfig.workingDirectory = config.bashWorkingDir;
|
|
57986
61411
|
}
|
|
57987
61412
|
if (config.verbose) {
|
|
57988
|
-
console.
|
|
61413
|
+
console.error("Bash command execution enabled");
|
|
57989
61414
|
}
|
|
57990
61415
|
}
|
|
57991
61416
|
const agentConfig2 = {
|