@sinm/kai 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -0
  3. package/bin/kai-cli.js +21 -0
  4. package/dist-cli/kai-cli.js +218494 -0
  5. package/dist-electron/renderer/assets/_baseUniq-C3qTPmDE.js +660 -0
  6. package/dist-electron/renderer/assets/arc-BNCDL4e8.js +131 -0
  7. package/dist-electron/renderer/assets/architectureDiagram-Q4EWVU46-BdbGbDeJ.js +8718 -0
  8. package/dist-electron/renderer/assets/blockDiagram-DXYQGD6D-QiXI7ilT.js +3637 -0
  9. package/dist-electron/renderer/assets/c4Diagram-AHTNJAMY-BddxtMgY.js +2482 -0
  10. package/dist-electron/renderer/assets/channel-C_JLiB8I.js +7 -0
  11. package/dist-electron/renderer/assets/chunk-4BX2VUAB-s-dHrXuO.js +16 -0
  12. package/dist-electron/renderer/assets/chunk-4TB4RGXK-vzGbJGfp.js +1920 -0
  13. package/dist-electron/renderer/assets/chunk-55IACEB6-DS6S48ws.js +13 -0
  14. package/dist-electron/renderer/assets/chunk-EDXVE4YY-CkjF90gW.js +24 -0
  15. package/dist-electron/renderer/assets/chunk-FMBD7UC4-BXvIgVUY.js +19 -0
  16. package/dist-electron/renderer/assets/chunk-OYMX7WX6-YZbrtKSv.js +1939 -0
  17. package/dist-electron/renderer/assets/chunk-QZHKN3VN-BbLYRfB3.js +19 -0
  18. package/dist-electron/renderer/assets/chunk-YZCP3GAM-JVGt9SK_.js +116 -0
  19. package/dist-electron/renderer/assets/classDiagram-6PBFFD2Q-BwZMRjub.js +23 -0
  20. package/dist-electron/renderer/assets/classDiagram-v2-HSJHXN6E-BwZMRjub.js +23 -0
  21. package/dist-electron/renderer/assets/clone-BC-6Iyrf.js +8 -0
  22. package/dist-electron/renderer/assets/cose-bilkent-S5V4N54A-C3CGX8BH.js +4942 -0
  23. package/dist-electron/renderer/assets/cytoscape.esm-D6E6cAed.js +30246 -0
  24. package/dist-electron/renderer/assets/dagre-KV5264BT-DXOCL1ZZ.js +694 -0
  25. package/dist-electron/renderer/assets/defaultLocale-B2RvLBDe.js +206 -0
  26. package/dist-electron/renderer/assets/diagram-5BDNPKRD-B9dghm7-.js +171 -0
  27. package/dist-electron/renderer/assets/diagram-G4DWMVQ6-DDupyCeT.js +853 -0
  28. package/dist-electron/renderer/assets/diagram-MMDJMWI5-Bagr5R3p.js +303 -0
  29. package/dist-electron/renderer/assets/diagram-TYMM5635-YL5sCgeo.js +214 -0
  30. package/dist-electron/renderer/assets/erDiagram-SMLLAGMA-CHytCe4p.js +1227 -0
  31. package/dist-electron/renderer/assets/flowDiagram-DWJPFMVM-BJgPbbzi.js +2332 -0
  32. package/dist-electron/renderer/assets/ganttDiagram-T4ZO3ILL-BN-Vq0iy.js +3714 -0
  33. package/dist-electron/renderer/assets/gitGraphDiagram-UUTBAWPF-CbUpEcLb.js +1375 -0
  34. package/dist-electron/renderer/assets/graph-Di49T8Ee.js +953 -0
  35. package/dist-electron/renderer/assets/index-C55TZN9T.css +14105 -0
  36. package/dist-electron/renderer/assets/index-D-H_6heO.js +91405 -0
  37. package/dist-electron/renderer/assets/infoDiagram-42DDH7IO-BPl-rsFx.js +33 -0
  38. package/dist-electron/renderer/assets/init-ZxktEp_H.js +16 -0
  39. package/dist-electron/renderer/assets/ishikawaDiagram-UXIWVN3A-C8ly-VN_.js +967 -0
  40. package/dist-electron/renderer/assets/journeyDiagram-VCZTEJTY-nUjo5Mzy.js +1255 -0
  41. package/dist-electron/renderer/assets/kanban-definition-6JOO6SKY-DWVGGGQB.js +1052 -0
  42. package/dist-electron/renderer/assets/katex-CYis69t2.js +14301 -0
  43. package/dist-electron/renderer/assets/layout-BO15dWax.js +2217 -0
  44. package/dist-electron/renderer/assets/linear-bwcJeNAk.js +340 -0
  45. package/dist-electron/renderer/assets/min-CSnTolL5.js +41 -0
  46. package/dist-electron/renderer/assets/mindmap-definition-QFDTVHPH-WJVpu9VT.js +1186 -0
  47. package/dist-electron/renderer/assets/ordinal-CxptdPJm.js +76 -0
  48. package/dist-electron/renderer/assets/pieDiagram-DEJITSTG-DF_DZ5Q4.js +248 -0
  49. package/dist-electron/renderer/assets/quadrantDiagram-34T5L4WZ-UhXGuJcr.js +1342 -0
  50. package/dist-electron/renderer/assets/requirementDiagram-MS252O5E-BtD6ux77.js +1204 -0
  51. package/dist-electron/renderer/assets/sankeyDiagram-XADWPNL6-CC4IbM1T.js +1205 -0
  52. package/dist-electron/renderer/assets/sequenceDiagram-FGHM5R23-Da4bQBSu.js +4502 -0
  53. package/dist-electron/renderer/assets/stateDiagram-FHFEXIEX-zEkMqOXM.js +452 -0
  54. package/dist-electron/renderer/assets/stateDiagram-v2-QKLJ7IA2-DpXHvwUL.js +21 -0
  55. package/dist-electron/renderer/assets/timeline-definition-GMOUNBTQ-DJnjzEUR.js +1596 -0
  56. package/dist-electron/renderer/assets/vennDiagram-DHZGUBPP-f6WAsZFS.js +2486 -0
  57. package/dist-electron/renderer/assets/wardley-RL74JXVD-pTLEMWKj.js +24199 -0
  58. package/dist-electron/renderer/assets/wardleyDiagram-NUSXRM2D-GRV6kOg2.js +901 -0
  59. package/dist-electron/renderer/assets/xychartDiagram-5P7HB3ND-BAcUBgxf.js +1932 -0
  60. package/dist-electron/renderer/index.html +13 -0
  61. package/package.json +52 -0
@@ -0,0 +1,452 @@
1
+ import { s as styles_default, a as stateDiagram_default, S as StateDB } from "./chunk-OYMX7WX6-YZbrtKSv.js";
2
+ import { _ as __name, c as getConfig2, d as select, l as log, e as configureSvgSize, k as common_default, R as line, S as curveBasis, O as getUrl, u as utils_default } from "./index-D-H_6heO.js";
3
+ import { G as Graph } from "./graph-Di49T8Ee.js";
4
+ import { l as layout } from "./layout-BO15dWax.js";
5
+ import "./chunk-55IACEB6-DS6S48ws.js";
6
+ import "./chunk-EDXVE4YY-CkjF90gW.js";
7
+ import "./_baseUniq-C3qTPmDE.js";
8
+ import "./min-CSnTolL5.js";
9
+ var drawStartState = /* @__PURE__ */ __name((g) => g.append("circle").attr("class", "start-state").attr("r", getConfig2().state.sizeUnit).attr("cx", getConfig2().state.padding + getConfig2().state.sizeUnit).attr("cy", getConfig2().state.padding + getConfig2().state.sizeUnit), "drawStartState");
10
+ var drawDivider = /* @__PURE__ */ __name((g) => g.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", getConfig2().state.textHeight).attr("class", "divider").attr("x2", getConfig2().state.textHeight * 2).attr("y1", 0).attr("y2", 0), "drawDivider");
11
+ var drawSimpleState = /* @__PURE__ */ __name((g, stateDef) => {
12
+ const state = g.append("text").attr("x", 2 * getConfig2().state.padding).attr("y", getConfig2().state.textHeight + 2 * getConfig2().state.padding).attr("font-size", getConfig2().state.fontSize).attr("class", "state-title").text(stateDef.id);
13
+ const classBox = state.node().getBBox();
14
+ g.insert("rect", ":first-child").attr("x", getConfig2().state.padding).attr("y", getConfig2().state.padding).attr("width", classBox.width + 2 * getConfig2().state.padding).attr("height", classBox.height + 2 * getConfig2().state.padding).attr("rx", getConfig2().state.radius);
15
+ return state;
16
+ }, "drawSimpleState");
17
+ var drawDescrState = /* @__PURE__ */ __name((g, stateDef) => {
18
+ const addTspan = /* @__PURE__ */ __name(function(textEl, txt, isFirst2) {
19
+ const tSpan = textEl.append("tspan").attr("x", 2 * getConfig2().state.padding).text(txt);
20
+ if (!isFirst2) {
21
+ tSpan.attr("dy", getConfig2().state.textHeight);
22
+ }
23
+ }, "addTspan");
24
+ const title = g.append("text").attr("x", 2 * getConfig2().state.padding).attr("y", getConfig2().state.textHeight + 1.3 * getConfig2().state.padding).attr("font-size", getConfig2().state.fontSize).attr("class", "state-title").text(stateDef.descriptions[0]);
25
+ const titleBox = title.node().getBBox();
26
+ const titleHeight = titleBox.height;
27
+ const description = g.append("text").attr("x", getConfig2().state.padding).attr(
28
+ "y",
29
+ titleHeight + getConfig2().state.padding * 0.4 + getConfig2().state.dividerMargin + getConfig2().state.textHeight
30
+ ).attr("class", "state-description");
31
+ let isFirst = true;
32
+ let isSecond = true;
33
+ stateDef.descriptions.forEach(function(descr) {
34
+ if (!isFirst) {
35
+ addTspan(description, descr, isSecond);
36
+ isSecond = false;
37
+ }
38
+ isFirst = false;
39
+ });
40
+ const descrLine = g.append("line").attr("x1", getConfig2().state.padding).attr("y1", getConfig2().state.padding + titleHeight + getConfig2().state.dividerMargin / 2).attr("y2", getConfig2().state.padding + titleHeight + getConfig2().state.dividerMargin / 2).attr("class", "descr-divider");
41
+ const descrBox = description.node().getBBox();
42
+ const width = Math.max(descrBox.width, titleBox.width);
43
+ descrLine.attr("x2", width + 3 * getConfig2().state.padding);
44
+ g.insert("rect", ":first-child").attr("x", getConfig2().state.padding).attr("y", getConfig2().state.padding).attr("width", width + 2 * getConfig2().state.padding).attr("height", descrBox.height + titleHeight + 2 * getConfig2().state.padding).attr("rx", getConfig2().state.radius);
45
+ return g;
46
+ }, "drawDescrState");
47
+ var addTitleAndBox = /* @__PURE__ */ __name((g, stateDef, altBkg) => {
48
+ const pad = getConfig2().state.padding;
49
+ const dblPad = 2 * getConfig2().state.padding;
50
+ const orgBox = g.node().getBBox();
51
+ const orgWidth = orgBox.width;
52
+ const orgX = orgBox.x;
53
+ const title = g.append("text").attr("x", 0).attr("y", getConfig2().state.titleShift).attr("font-size", getConfig2().state.fontSize).attr("class", "state-title").text(stateDef.id);
54
+ const titleBox = title.node().getBBox();
55
+ const titleWidth = titleBox.width + dblPad;
56
+ let width = Math.max(titleWidth, orgWidth);
57
+ if (width === orgWidth) {
58
+ width = width + dblPad;
59
+ }
60
+ let startX;
61
+ const graphBox = g.node().getBBox();
62
+ if (stateDef.doc) ;
63
+ startX = orgX - pad;
64
+ if (titleWidth > orgWidth) {
65
+ startX = (orgWidth - width) / 2 + pad;
66
+ }
67
+ if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) {
68
+ startX = orgX - (titleWidth - orgWidth) / 2;
69
+ }
70
+ const lineY = 1 - getConfig2().state.textHeight;
71
+ g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr(
72
+ "height",
73
+ graphBox.height + getConfig2().state.textHeight + getConfig2().state.titleShift + 1
74
+ ).attr("rx", "0");
75
+ title.attr("x", startX + pad);
76
+ if (titleWidth <= orgWidth) {
77
+ title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);
78
+ }
79
+ g.insert("rect", ":first-child").attr("x", startX).attr(
80
+ "y",
81
+ getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
82
+ ).attr("width", width).attr("height", getConfig2().state.textHeight * 3).attr("rx", getConfig2().state.radius);
83
+ g.insert("rect", ":first-child").attr("x", startX).attr(
84
+ "y",
85
+ getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
86
+ ).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig2().state.textHeight).attr("rx", getConfig2().state.radius);
87
+ return g;
88
+ }, "addTitleAndBox");
89
+ var drawEndState = /* @__PURE__ */ __name((g) => {
90
+ g.append("circle").attr("class", "end-state-outer").attr("r", getConfig2().state.sizeUnit + getConfig2().state.miniPadding).attr(
91
+ "cx",
92
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
93
+ ).attr(
94
+ "cy",
95
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
96
+ );
97
+ return g.append("circle").attr("class", "end-state-inner").attr("r", getConfig2().state.sizeUnit).attr("cx", getConfig2().state.padding + getConfig2().state.sizeUnit + 2).attr("cy", getConfig2().state.padding + getConfig2().state.sizeUnit + 2);
98
+ }, "drawEndState");
99
+ var drawForkJoinState = /* @__PURE__ */ __name((g, stateDef) => {
100
+ let width = getConfig2().state.forkWidth;
101
+ let height = getConfig2().state.forkHeight;
102
+ if (stateDef.parentId) {
103
+ let tmp = width;
104
+ width = height;
105
+ height = tmp;
106
+ }
107
+ return g.append("rect").style("stroke", "black").style("fill", "black").attr("width", width).attr("height", height).attr("x", getConfig2().state.padding).attr("y", getConfig2().state.padding);
108
+ }, "drawForkJoinState");
109
+ var _drawLongText = /* @__PURE__ */ __name((_text, x, y, g) => {
110
+ let textHeight = 0;
111
+ const textElem = g.append("text");
112
+ textElem.style("text-anchor", "start");
113
+ textElem.attr("class", "noteText");
114
+ let text = _text.replace(/\r\n/g, "<br/>");
115
+ text = text.replace(/\n/g, "<br/>");
116
+ const lines = text.split(common_default.lineBreakRegex);
117
+ let tHeight = 1.25 * getConfig2().state.noteMargin;
118
+ for (const line2 of lines) {
119
+ const txt = line2.trim();
120
+ if (txt.length > 0) {
121
+ const span = textElem.append("tspan");
122
+ span.text(txt);
123
+ if (tHeight === 0) {
124
+ const textBounds = span.node().getBBox();
125
+ tHeight += textBounds.height;
126
+ }
127
+ textHeight += tHeight;
128
+ span.attr("x", x + getConfig2().state.noteMargin);
129
+ span.attr("y", y + textHeight + 1.25 * getConfig2().state.noteMargin);
130
+ }
131
+ }
132
+ return { textWidth: textElem.node().getBBox().width, textHeight };
133
+ }, "_drawLongText");
134
+ var drawNote = /* @__PURE__ */ __name((text, g) => {
135
+ g.attr("class", "state-note");
136
+ const note = g.append("rect").attr("x", 0).attr("y", getConfig2().state.padding);
137
+ const rectElem = g.append("g");
138
+ const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
139
+ note.attr("height", textHeight + 2 * getConfig2().state.noteMargin);
140
+ note.attr("width", textWidth + getConfig2().state.noteMargin * 2);
141
+ return note;
142
+ }, "drawNote");
143
+ var drawState = /* @__PURE__ */ __name(function(elem, stateDef) {
144
+ const id = stateDef.id;
145
+ const stateInfo = {
146
+ id,
147
+ label: stateDef.id,
148
+ width: 0,
149
+ height: 0
150
+ };
151
+ const g = elem.append("g").attr("id", id).attr("class", "stateGroup");
152
+ if (stateDef.type === "start") {
153
+ drawStartState(g);
154
+ }
155
+ if (stateDef.type === "end") {
156
+ drawEndState(g);
157
+ }
158
+ if (stateDef.type === "fork" || stateDef.type === "join") {
159
+ drawForkJoinState(g, stateDef);
160
+ }
161
+ if (stateDef.type === "note") {
162
+ drawNote(stateDef.note.text, g);
163
+ }
164
+ if (stateDef.type === "divider") {
165
+ drawDivider(g);
166
+ }
167
+ if (stateDef.type === "default" && stateDef.descriptions.length === 0) {
168
+ drawSimpleState(g, stateDef);
169
+ }
170
+ if (stateDef.type === "default" && stateDef.descriptions.length > 0) {
171
+ drawDescrState(g, stateDef);
172
+ }
173
+ const stateBox = g.node().getBBox();
174
+ stateInfo.width = stateBox.width + 2 * getConfig2().state.padding;
175
+ stateInfo.height = stateBox.height + 2 * getConfig2().state.padding;
176
+ return stateInfo;
177
+ }, "drawState");
178
+ var edgeCount = 0;
179
+ var drawEdge = /* @__PURE__ */ __name(function(elem, path, relation) {
180
+ const getRelationType = /* @__PURE__ */ __name(function(type) {
181
+ switch (type) {
182
+ case StateDB.relationType.AGGREGATION:
183
+ return "aggregation";
184
+ case StateDB.relationType.EXTENSION:
185
+ return "extension";
186
+ case StateDB.relationType.COMPOSITION:
187
+ return "composition";
188
+ case StateDB.relationType.DEPENDENCY:
189
+ return "dependency";
190
+ }
191
+ }, "getRelationType");
192
+ path.points = path.points.filter((p) => !Number.isNaN(p.y));
193
+ const lineData = path.points;
194
+ const lineFunction = line().x(function(d) {
195
+ return d.x;
196
+ }).y(function(d) {
197
+ return d.y;
198
+ }).curve(curveBasis);
199
+ const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition");
200
+ let url = "";
201
+ if (getConfig2().state.arrowMarkerAbsolute) {
202
+ url = getUrl(true);
203
+ }
204
+ svgPath.attr(
205
+ "marker-end",
206
+ "url(" + url + "#" + getRelationType(StateDB.relationType.DEPENDENCY) + "End)"
207
+ );
208
+ if (relation.title !== void 0) {
209
+ const label = elem.append("g").attr("class", "stateLabel");
210
+ const { x, y } = utils_default.calcLabelPosition(path.points);
211
+ const rows = common_default.getRows(relation.title);
212
+ let titleHeight = 0;
213
+ const titleRows = [];
214
+ let maxWidth = 0;
215
+ let minX = 0;
216
+ for (let i = 0; i <= rows.length; i++) {
217
+ const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight);
218
+ const boundsTmp = title.node().getBBox();
219
+ maxWidth = Math.max(maxWidth, boundsTmp.width);
220
+ minX = Math.min(minX, boundsTmp.x);
221
+ log.info(boundsTmp.x, x, y + titleHeight);
222
+ if (titleHeight === 0) {
223
+ const titleBox = title.node().getBBox();
224
+ titleHeight = titleBox.height;
225
+ log.info("Title height", titleHeight, y);
226
+ }
227
+ titleRows.push(title);
228
+ }
229
+ let boxHeight = titleHeight * rows.length;
230
+ if (rows.length > 1) {
231
+ const heightAdj = (rows.length - 1) * titleHeight * 0.5;
232
+ titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj));
233
+ boxHeight = titleHeight * rows.length;
234
+ }
235
+ const bounds = label.node().getBBox();
236
+ label.insert("rect", ":first-child").attr("class", "box").attr("x", x - maxWidth / 2 - getConfig2().state.padding / 2).attr("y", y - boxHeight / 2 - getConfig2().state.padding / 2 - 3.5).attr("width", maxWidth + getConfig2().state.padding).attr("height", boxHeight + getConfig2().state.padding);
237
+ log.info(bounds);
238
+ }
239
+ edgeCount++;
240
+ }, "drawEdge");
241
+ var conf;
242
+ var transformationLog = {};
243
+ var setConf = /* @__PURE__ */ __name(function() {
244
+ }, "setConf");
245
+ var insertMarkers = /* @__PURE__ */ __name(function(elem) {
246
+ elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z");
247
+ }, "insertMarkers");
248
+ var draw = /* @__PURE__ */ __name(function(text, id, _version, diagObj) {
249
+ conf = getConfig2().state;
250
+ const securityLevel = getConfig2().securityLevel;
251
+ let sandboxElement;
252
+ if (securityLevel === "sandbox") {
253
+ sandboxElement = select("#i" + id);
254
+ }
255
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
256
+ const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
257
+ log.debug("Rendering diagram " + text);
258
+ const diagram2 = root.select(`[id='${id}']`);
259
+ insertMarkers(diagram2);
260
+ const rootDoc = diagObj.db.getRootDoc();
261
+ const rootG = diagram2.append("g").attr("id", id + "-root");
262
+ renderDoc(rootDoc, rootG, void 0, false, root, doc, diagObj);
263
+ const padding = conf.padding;
264
+ const bounds = diagram2.node().getBBox();
265
+ const width = bounds.width + padding * 2;
266
+ const height = bounds.height + padding * 2;
267
+ const svgWidth = width * 1.75;
268
+ configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth);
269
+ diagram2.attr(
270
+ "viewBox",
271
+ `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height
272
+ );
273
+ }, "draw");
274
+ var getLabelWidth = /* @__PURE__ */ __name((text) => {
275
+ return text ? text.length * conf.fontSizeFactor : 1;
276
+ }, "getLabelWidth");
277
+ var renderDoc = /* @__PURE__ */ __name((doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => {
278
+ const graph = new Graph({
279
+ compound: true,
280
+ multigraph: true
281
+ });
282
+ let i;
283
+ let edgeFreeDoc = true;
284
+ for (i = 0; i < doc.length; i++) {
285
+ if (doc[i].stmt === "relation") {
286
+ edgeFreeDoc = false;
287
+ break;
288
+ }
289
+ }
290
+ if (parentId) {
291
+ graph.setGraph({
292
+ rankdir: "LR",
293
+ multigraph: true,
294
+ compound: true,
295
+ // acyclicer: 'greedy',
296
+ ranker: "tight-tree",
297
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
298
+ nodeSep: edgeFreeDoc ? 1 : 50,
299
+ isMultiGraph: true
300
+ // ranksep: 5,
301
+ // nodesep: 1
302
+ });
303
+ } else {
304
+ graph.setGraph({
305
+ rankdir: "TB",
306
+ multigraph: true,
307
+ compound: true,
308
+ // isCompound: true,
309
+ // acyclicer: 'greedy',
310
+ // ranker: 'longest-path'
311
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
312
+ nodeSep: edgeFreeDoc ? 1 : 50,
313
+ ranker: "tight-tree",
314
+ // ranker: 'network-simplex'
315
+ isMultiGraph: true
316
+ });
317
+ }
318
+ graph.setDefaultEdgeLabel(function() {
319
+ return {};
320
+ });
321
+ const states = diagObj.db.getStates();
322
+ const relations = diagObj.db.getRelations();
323
+ const keys = Object.keys(states);
324
+ for (const key of keys) {
325
+ const stateDef = states[key];
326
+ if (parentId) {
327
+ stateDef.parentId = parentId;
328
+ }
329
+ let node;
330
+ if (stateDef.doc) {
331
+ let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup");
332
+ node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj);
333
+ {
334
+ sub = addTitleAndBox(sub, stateDef, altBkg);
335
+ let boxBounds = sub.node().getBBox();
336
+ node.width = boxBounds.width;
337
+ node.height = boxBounds.height + conf.padding / 2;
338
+ transformationLog[stateDef.id] = { y: conf.compositTitleSize };
339
+ }
340
+ } else {
341
+ node = drawState(diagram2, stateDef, graph);
342
+ }
343
+ if (stateDef.note) {
344
+ const noteDef = {
345
+ descriptions: [],
346
+ id: stateDef.id + "-note",
347
+ note: stateDef.note,
348
+ type: "note"
349
+ };
350
+ const note = drawState(diagram2, noteDef, graph);
351
+ if (stateDef.note.position === "left of") {
352
+ graph.setNode(node.id + "-note", note);
353
+ graph.setNode(node.id, node);
354
+ } else {
355
+ graph.setNode(node.id, node);
356
+ graph.setNode(node.id + "-note", note);
357
+ }
358
+ graph.setParent(node.id, node.id + "-group");
359
+ graph.setParent(node.id + "-note", node.id + "-group");
360
+ } else {
361
+ graph.setNode(node.id, node);
362
+ }
363
+ }
364
+ log.debug("Count=", graph.nodeCount(), graph);
365
+ let cnt = 0;
366
+ relations.forEach(function(relation) {
367
+ cnt++;
368
+ log.debug("Setting edge", relation);
369
+ graph.setEdge(
370
+ relation.id1,
371
+ relation.id2,
372
+ {
373
+ relation,
374
+ width: getLabelWidth(relation.title),
375
+ height: conf.labelHeight * common_default.getRows(relation.title).length,
376
+ labelpos: "c"
377
+ },
378
+ "id" + cnt
379
+ );
380
+ });
381
+ layout(graph);
382
+ log.debug("Graph after layout", graph.nodes());
383
+ const svgElem = diagram2.node();
384
+ graph.nodes().forEach(function(v) {
385
+ if (v !== void 0 && graph.node(v) !== void 0) {
386
+ log.warn("Node " + v + ": " + JSON.stringify(graph.node(v)));
387
+ root.select("#" + svgElem.id + " #" + v).attr(
388
+ "transform",
389
+ "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + " )"
390
+ );
391
+ root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2);
392
+ const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider");
393
+ dividers.forEach((divider) => {
394
+ const parent = divider.parentElement;
395
+ let pWidth = 0;
396
+ let pShift = 0;
397
+ if (parent) {
398
+ if (parent.parentElement) {
399
+ pWidth = parent.parentElement.getBBox().width;
400
+ }
401
+ pShift = parseInt(parent.getAttribute("data-x-shift"), 10);
402
+ if (Number.isNaN(pShift)) {
403
+ pShift = 0;
404
+ }
405
+ }
406
+ divider.setAttribute("x1", 0 - pShift + 8);
407
+ divider.setAttribute("x2", pWidth - pShift - 8);
408
+ });
409
+ } else {
410
+ log.debug("No Node " + v + ": " + JSON.stringify(graph.node(v)));
411
+ }
412
+ });
413
+ let stateBox = svgElem.getBBox();
414
+ graph.edges().forEach(function(e) {
415
+ if (e !== void 0 && graph.edge(e) !== void 0) {
416
+ log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
417
+ drawEdge(diagram2, graph.edge(e), graph.edge(e).relation);
418
+ }
419
+ });
420
+ stateBox = svgElem.getBBox();
421
+ const stateInfo = {
422
+ id: parentId ? parentId : "root",
423
+ label: parentId ? parentId : "root",
424
+ width: 0,
425
+ height: 0
426
+ };
427
+ stateInfo.width = stateBox.width + 2 * conf.padding;
428
+ stateInfo.height = stateBox.height + 2 * conf.padding;
429
+ log.debug("Doc rendered", stateInfo, graph);
430
+ return stateInfo;
431
+ }, "renderDoc");
432
+ var stateRenderer_default = {
433
+ setConf,
434
+ draw
435
+ };
436
+ var diagram = {
437
+ parser: stateDiagram_default,
438
+ get db() {
439
+ return new StateDB(1);
440
+ },
441
+ renderer: stateRenderer_default,
442
+ styles: styles_default,
443
+ init: /* @__PURE__ */ __name((cnf) => {
444
+ if (!cnf.state) {
445
+ cnf.state = {};
446
+ }
447
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
448
+ }, "init")
449
+ };
450
+ export {
451
+ diagram
452
+ };
@@ -0,0 +1,21 @@
1
+ import { s as styles_default, b as stateRenderer_v3_unified_default, a as stateDiagram_default, S as StateDB } from "./chunk-OYMX7WX6-YZbrtKSv.js";
2
+ import { _ as __name } from "./index-D-H_6heO.js";
3
+ import "./chunk-55IACEB6-DS6S48ws.js";
4
+ import "./chunk-EDXVE4YY-CkjF90gW.js";
5
+ var diagram = {
6
+ parser: stateDiagram_default,
7
+ get db() {
8
+ return new StateDB(2);
9
+ },
10
+ renderer: stateRenderer_v3_unified_default,
11
+ styles: styles_default,
12
+ init: /* @__PURE__ */ __name((cnf) => {
13
+ if (!cnf.state) {
14
+ cnf.state = {};
15
+ }
16
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
17
+ }, "init")
18
+ };
19
+ export {
20
+ diagram
21
+ };