@bytechain.cn/colamd 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/.github/workflows/release.yml +66 -0
  2. package/.trae/documents/fix-mermaid-colors-and-sankey.md +50 -0
  3. package/CLAUDE.md +87 -0
  4. package/LICENSE +21 -0
  5. package/README.md +540 -0
  6. package/README_CN.md +543 -0
  7. package/demo.md +486 -0
  8. package/dist/main/index.js +735 -0
  9. package/dist/preload/index.js +71 -0
  10. package/dist/renderer/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  11. package/dist/renderer/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  12. package/dist/renderer/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  13. package/dist/renderer/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  14. package/dist/renderer/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  15. package/dist/renderer/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  16. package/dist/renderer/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  17. package/dist/renderer/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  18. package/dist/renderer/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  19. package/dist/renderer/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  20. package/dist/renderer/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  21. package/dist/renderer/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  22. package/dist/renderer/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  23. package/dist/renderer/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  24. package/dist/renderer/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  25. package/dist/renderer/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  26. package/dist/renderer/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  27. package/dist/renderer/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  28. package/dist/renderer/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  29. package/dist/renderer/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  30. package/dist/renderer/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  31. package/dist/renderer/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  32. package/dist/renderer/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  33. package/dist/renderer/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  34. package/dist/renderer/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  35. package/dist/renderer/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  36. package/dist/renderer/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  37. package/dist/renderer/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  38. package/dist/renderer/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  39. package/dist/renderer/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  40. package/dist/renderer/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  41. package/dist/renderer/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  42. package/dist/renderer/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  43. package/dist/renderer/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  44. package/dist/renderer/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  45. package/dist/renderer/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  46. package/dist/renderer/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  47. package/dist/renderer/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  48. package/dist/renderer/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  49. package/dist/renderer/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  50. package/dist/renderer/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  51. package/dist/renderer/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  52. package/dist/renderer/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  53. package/dist/renderer/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  54. package/dist/renderer/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  55. package/dist/renderer/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  56. package/dist/renderer/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  57. package/dist/renderer/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  58. package/dist/renderer/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  59. package/dist/renderer/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  60. package/dist/renderer/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  61. package/dist/renderer/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  62. package/dist/renderer/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  63. package/dist/renderer/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  64. package/dist/renderer/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  65. package/dist/renderer/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  66. package/dist/renderer/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  67. package/dist/renderer/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  68. package/dist/renderer/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  69. package/dist/renderer/assets/arc-tTbbM8LO.js +131 -0
  70. package/dist/renderer/assets/architectureDiagram-3BPJPVTR-CEgYow6c.js +8720 -0
  71. package/dist/renderer/assets/blockDiagram-GPEHLZMM-LHyVtPwW.js +3825 -0
  72. package/dist/renderer/assets/c4Diagram-AAUBKEIU-C1P1eJrf.js +2482 -0
  73. package/dist/renderer/assets/channel-upve91Tq.js +7 -0
  74. package/dist/renderer/assets/chunk-2J33WTMH-lag2vhq9.js +24 -0
  75. package/dist/renderer/assets/chunk-4BX2VUAB-BXJ8Ggh-.js +16 -0
  76. package/dist/renderer/assets/chunk-55IACEB6-CiBpxRa1.js +13 -0
  77. package/dist/renderer/assets/chunk-727SXJPM-ODeKQFXC.js +2016 -0
  78. package/dist/renderer/assets/chunk-AQP2D5EJ-BK7xJolB.js +1953 -0
  79. package/dist/renderer/assets/chunk-FMBD7UC4-BxpCZPtz.js +19 -0
  80. package/dist/renderer/assets/chunk-ND2GUHAM-CqqaU9Ue.js +116 -0
  81. package/dist/renderer/assets/chunk-QZHKN3VN-Biq_K124.js +19 -0
  82. package/dist/renderer/assets/classDiagram-4FO5ZUOK-Cq95X99o.js +23 -0
  83. package/dist/renderer/assets/classDiagram-v2-Q7XG4LA2-Cq95X99o.js +23 -0
  84. package/dist/renderer/assets/cose-bilkent-S5V4N54A-XasiD0bu.js +4942 -0
  85. package/dist/renderer/assets/cytoscape.esm-CpHeHM5e.js +30269 -0
  86. package/dist/renderer/assets/dagre-BM42HDAG-Nq84Gfx4.js +705 -0
  87. package/dist/renderer/assets/defaultLocale-B2RvLBDe.js +206 -0
  88. package/dist/renderer/assets/diagram-2AECGRRQ-DwuB1GWt.js +301 -0
  89. package/dist/renderer/assets/diagram-5GNKFQAL-C2tgeI1h.js +169 -0
  90. package/dist/renderer/assets/diagram-KO2AKTUF-D5KzjNBc.js +632 -0
  91. package/dist/renderer/assets/diagram-LMA3HP47-C12xHS1c.js +212 -0
  92. package/dist/renderer/assets/diagram-OG6HWLK6-CnxI9oEa.js +851 -0
  93. package/dist/renderer/assets/erDiagram-TEJ5UH35-D_uPaKwn.js +1227 -0
  94. package/dist/renderer/assets/flowDiagram-I6XJVG4X-B6q_1-tE.js +2332 -0
  95. package/dist/renderer/assets/ganttDiagram-6RSMTGT7-CFo7ifF9.js +3720 -0
  96. package/dist/renderer/assets/gitGraphDiagram-PVQCEYII-WSexHTnq.js +1373 -0
  97. package/dist/renderer/assets/graph-DyX_9f6d.js +1988 -0
  98. package/dist/renderer/assets/index-DW7LS8C1.js +72292 -0
  99. package/dist/renderer/assets/index-dyHEFYvY.css +2184 -0
  100. package/dist/renderer/assets/infoDiagram-5YYISTIA-DaeJdLRq.js +31 -0
  101. package/dist/renderer/assets/init-ZxktEp_H.js +16 -0
  102. package/dist/renderer/assets/ishikawaDiagram-YF4QCWOH-DDCZc35f.js +967 -0
  103. package/dist/renderer/assets/journeyDiagram-JHISSGLW-BEdmpAgl.js +1255 -0
  104. package/dist/renderer/assets/kanban-definition-UN3LZRKU-BEFtQcFb.js +1052 -0
  105. package/dist/renderer/assets/layout-CAJgQHdw.js +2610 -0
  106. package/dist/renderer/assets/linear-B2ggJ8Am.js +340 -0
  107. package/dist/renderer/assets/mindmap-definition-RKZ34NQL-DSxVgHB5.js +1180 -0
  108. package/dist/renderer/assets/ordinal-DSZU4PqD.js +76 -0
  109. package/dist/renderer/assets/pieDiagram-4H26LBE5-CwYoJBuL.js +246 -0
  110. package/dist/renderer/assets/quadrantDiagram-W4KKPZXB-CST9Fvg9.js +1344 -0
  111. package/dist/renderer/assets/requirementDiagram-4Y6WPE33-DtrH52jS.js +1204 -0
  112. package/dist/renderer/assets/sankeyDiagram-5OEKKPKP-ca1tPzJ_.js +1274 -0
  113. package/dist/renderer/assets/sequenceDiagram-3UESZ5HK-Dfp1EJZ7.js +4514 -0
  114. package/dist/renderer/assets/stateDiagram-AJRCARHV-Bha2QoNB.js +450 -0
  115. package/dist/renderer/assets/stateDiagram-v2-BHNVJYJU-DWgFUYu1.js +21 -0
  116. package/dist/renderer/assets/timeline-definition-PNZ67QCA-C3h_-OTj.js +1596 -0
  117. package/dist/renderer/assets/vennDiagram-CIIHVFJN-DFzjSrZi.js +2486 -0
  118. package/dist/renderer/assets/wardley-L42UT6IY-Cx-VbqoS.js +30699 -0
  119. package/dist/renderer/assets/wardleyDiagram-YWT4CUSO-S2D9XqX6.js +975 -0
  120. package/dist/renderer/assets/xychartDiagram-2RQKCTM6-Cfxigbts.js +1932 -0
  121. package/dist/renderer/index.html +19 -0
  122. package/docs/agent-diff-view.md +48 -0
  123. package/electron-builder.yml +57 -0
  124. package/electron.vite.config.ts +30 -0
  125. package/package.json +40 -0
  126. package/resources/entitlements.mac.plist +12 -0
  127. package/resources/icon.icns +0 -0
  128. package/resources/icon.png +0 -0
  129. package/resources/icon.svg +23 -0
  130. package/resources/templates/slides/icon.png +0 -0
  131. package/resources/templates/slides/slides-template.md +74 -0
  132. package/resources/templates/slides/template.html +535 -0
  133. package/scripts/afterPack.js +13 -0
  134. package/src/main/index.ts +881 -0
  135. package/src/preload/index.ts +110 -0
  136. package/src/renderer/editor/editor.ts +204 -0
  137. package/src/renderer/editor/html-view.ts +15 -0
  138. package/src/renderer/editor/plugins/index.ts +76 -0
  139. package/src/renderer/editor/plugins/math-plugin.ts +297 -0
  140. package/src/renderer/editor/plugins/mermaid-plugin-custom.css +431 -0
  141. package/src/renderer/editor/plugins/mermaid-plugin-dark.css +428 -0
  142. package/src/renderer/editor/plugins/mermaid-plugin-elegant.css +443 -0
  143. package/src/renderer/editor/plugins/mermaid-plugin-newsprint.css +208 -0
  144. package/src/renderer/editor/plugins/mermaid-plugin.css +111 -0
  145. package/src/renderer/editor/plugins/mermaid-plugin.ts +679 -0
  146. package/src/renderer/env.d.ts +7 -0
  147. package/src/renderer/index.html +18 -0
  148. package/src/renderer/main.ts +303 -0
  149. package/src/renderer/themes/base.css +509 -0
  150. package/src/renderer/themes/theme-manager.ts +40 -0
  151. package/themes/README.md +280 -0
  152. package/themes/elegant.css +664 -0
  153. package/themes/guizang.css +732 -0
  154. package/tsconfig.json +14 -0
  155. package/tsconfig.main.json +11 -0
  156. package/tsconfig.preload.json +11 -0
  157. package/tsconfig.renderer.json +12 -0
@@ -0,0 +1,450 @@
1
+ import { s as styles_default, a as stateDiagram_default, S as StateDB } from "./chunk-AQP2D5EJ-BK7xJolB.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-DW7LS8C1.js";
3
+ import { G as Graph } from "./graph-DyX_9f6d.js";
4
+ import { l as layout } from "./layout-CAJgQHdw.js";
5
+ import "./chunk-55IACEB6-CiBpxRa1.js";
6
+ import "./chunk-2J33WTMH-lag2vhq9.js";
7
+ 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");
8
+ 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");
9
+ var drawSimpleState = /* @__PURE__ */ __name((g, stateDef) => {
10
+ 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);
11
+ const classBox = state.node().getBBox();
12
+ 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);
13
+ return state;
14
+ }, "drawSimpleState");
15
+ var drawDescrState = /* @__PURE__ */ __name((g, stateDef) => {
16
+ const addTspan = /* @__PURE__ */ __name(function(textEl, txt, isFirst2) {
17
+ const tSpan = textEl.append("tspan").attr("x", 2 * getConfig2().state.padding).text(txt);
18
+ if (!isFirst2) {
19
+ tSpan.attr("dy", getConfig2().state.textHeight);
20
+ }
21
+ }, "addTspan");
22
+ 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]);
23
+ const titleBox = title.node().getBBox();
24
+ const titleHeight = titleBox.height;
25
+ const description = g.append("text").attr("x", getConfig2().state.padding).attr(
26
+ "y",
27
+ titleHeight + getConfig2().state.padding * 0.4 + getConfig2().state.dividerMargin + getConfig2().state.textHeight
28
+ ).attr("class", "state-description");
29
+ let isFirst = true;
30
+ let isSecond = true;
31
+ stateDef.descriptions.forEach(function(descr) {
32
+ if (!isFirst) {
33
+ addTspan(description, descr, isSecond);
34
+ isSecond = false;
35
+ }
36
+ isFirst = false;
37
+ });
38
+ 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");
39
+ const descrBox = description.node().getBBox();
40
+ const width = Math.max(descrBox.width, titleBox.width);
41
+ descrLine.attr("x2", width + 3 * getConfig2().state.padding);
42
+ 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);
43
+ return g;
44
+ }, "drawDescrState");
45
+ var addTitleAndBox = /* @__PURE__ */ __name((g, stateDef, altBkg) => {
46
+ const pad = getConfig2().state.padding;
47
+ const dblPad = 2 * getConfig2().state.padding;
48
+ const orgBox = g.node().getBBox();
49
+ const orgWidth = orgBox.width;
50
+ const orgX = orgBox.x;
51
+ 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);
52
+ const titleBox = title.node().getBBox();
53
+ const titleWidth = titleBox.width + dblPad;
54
+ let width = Math.max(titleWidth, orgWidth);
55
+ if (width === orgWidth) {
56
+ width = width + dblPad;
57
+ }
58
+ let startX;
59
+ const graphBox = g.node().getBBox();
60
+ if (stateDef.doc) ;
61
+ startX = orgX - pad;
62
+ if (titleWidth > orgWidth) {
63
+ startX = (orgWidth - width) / 2 + pad;
64
+ }
65
+ if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) {
66
+ startX = orgX - (titleWidth - orgWidth) / 2;
67
+ }
68
+ const lineY = 1 - getConfig2().state.textHeight;
69
+ g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr(
70
+ "height",
71
+ graphBox.height + getConfig2().state.textHeight + getConfig2().state.titleShift + 1
72
+ ).attr("rx", "0");
73
+ title.attr("x", startX + pad);
74
+ if (titleWidth <= orgWidth) {
75
+ title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);
76
+ }
77
+ g.insert("rect", ":first-child").attr("x", startX).attr(
78
+ "y",
79
+ getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
80
+ ).attr("width", width).attr("height", getConfig2().state.textHeight * 3).attr("rx", getConfig2().state.radius);
81
+ g.insert("rect", ":first-child").attr("x", startX).attr(
82
+ "y",
83
+ getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
84
+ ).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig2().state.textHeight).attr("rx", getConfig2().state.radius);
85
+ return g;
86
+ }, "addTitleAndBox");
87
+ var drawEndState = /* @__PURE__ */ __name((g) => {
88
+ g.append("circle").attr("class", "end-state-outer").attr("r", getConfig2().state.sizeUnit + getConfig2().state.miniPadding).attr(
89
+ "cx",
90
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
91
+ ).attr(
92
+ "cy",
93
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
94
+ );
95
+ 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);
96
+ }, "drawEndState");
97
+ var drawForkJoinState = /* @__PURE__ */ __name((g, stateDef) => {
98
+ let width = getConfig2().state.forkWidth;
99
+ let height = getConfig2().state.forkHeight;
100
+ if (stateDef.parentId) {
101
+ let tmp = width;
102
+ width = height;
103
+ height = tmp;
104
+ }
105
+ 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);
106
+ }, "drawForkJoinState");
107
+ var _drawLongText = /* @__PURE__ */ __name((_text, x, y, g) => {
108
+ let textHeight = 0;
109
+ const textElem = g.append("text");
110
+ textElem.style("text-anchor", "start");
111
+ textElem.attr("class", "noteText");
112
+ let text = _text.replace(/\r\n/g, "<br/>");
113
+ text = text.replace(/\n/g, "<br/>");
114
+ const lines = text.split(common_default.lineBreakRegex);
115
+ let tHeight = 1.25 * getConfig2().state.noteMargin;
116
+ for (const line2 of lines) {
117
+ const txt = line2.trim();
118
+ if (txt.length > 0) {
119
+ const span = textElem.append("tspan");
120
+ span.text(txt);
121
+ if (tHeight === 0) {
122
+ const textBounds = span.node().getBBox();
123
+ tHeight += textBounds.height;
124
+ }
125
+ textHeight += tHeight;
126
+ span.attr("x", x + getConfig2().state.noteMargin);
127
+ span.attr("y", y + textHeight + 1.25 * getConfig2().state.noteMargin);
128
+ }
129
+ }
130
+ return { textWidth: textElem.node().getBBox().width, textHeight };
131
+ }, "_drawLongText");
132
+ var drawNote = /* @__PURE__ */ __name((text, g) => {
133
+ g.attr("class", "state-note");
134
+ const note = g.append("rect").attr("x", 0).attr("y", getConfig2().state.padding);
135
+ const rectElem = g.append("g");
136
+ const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
137
+ note.attr("height", textHeight + 2 * getConfig2().state.noteMargin);
138
+ note.attr("width", textWidth + getConfig2().state.noteMargin * 2);
139
+ return note;
140
+ }, "drawNote");
141
+ var drawState = /* @__PURE__ */ __name(function(elem, stateDef) {
142
+ const id = stateDef.id;
143
+ const stateInfo = {
144
+ id,
145
+ label: stateDef.id,
146
+ width: 0,
147
+ height: 0
148
+ };
149
+ const g = elem.append("g").attr("id", id).attr("class", "stateGroup");
150
+ if (stateDef.type === "start") {
151
+ drawStartState(g);
152
+ }
153
+ if (stateDef.type === "end") {
154
+ drawEndState(g);
155
+ }
156
+ if (stateDef.type === "fork" || stateDef.type === "join") {
157
+ drawForkJoinState(g, stateDef);
158
+ }
159
+ if (stateDef.type === "note") {
160
+ drawNote(stateDef.note.text, g);
161
+ }
162
+ if (stateDef.type === "divider") {
163
+ drawDivider(g);
164
+ }
165
+ if (stateDef.type === "default" && stateDef.descriptions.length === 0) {
166
+ drawSimpleState(g, stateDef);
167
+ }
168
+ if (stateDef.type === "default" && stateDef.descriptions.length > 0) {
169
+ drawDescrState(g, stateDef);
170
+ }
171
+ const stateBox = g.node().getBBox();
172
+ stateInfo.width = stateBox.width + 2 * getConfig2().state.padding;
173
+ stateInfo.height = stateBox.height + 2 * getConfig2().state.padding;
174
+ return stateInfo;
175
+ }, "drawState");
176
+ var edgeCount = 0;
177
+ var drawEdge = /* @__PURE__ */ __name(function(elem, path, relation) {
178
+ const getRelationType = /* @__PURE__ */ __name(function(type) {
179
+ switch (type) {
180
+ case StateDB.relationType.AGGREGATION:
181
+ return "aggregation";
182
+ case StateDB.relationType.EXTENSION:
183
+ return "extension";
184
+ case StateDB.relationType.COMPOSITION:
185
+ return "composition";
186
+ case StateDB.relationType.DEPENDENCY:
187
+ return "dependency";
188
+ }
189
+ }, "getRelationType");
190
+ path.points = path.points.filter((p) => !Number.isNaN(p.y));
191
+ const lineData = path.points;
192
+ const lineFunction = line().x(function(d) {
193
+ return d.x;
194
+ }).y(function(d) {
195
+ return d.y;
196
+ }).curve(curveBasis);
197
+ const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition");
198
+ let url = "";
199
+ if (getConfig2().state.arrowMarkerAbsolute) {
200
+ url = getUrl(true);
201
+ }
202
+ svgPath.attr(
203
+ "marker-end",
204
+ "url(" + url + "#" + getRelationType(StateDB.relationType.DEPENDENCY) + "End)"
205
+ );
206
+ if (relation.title !== void 0) {
207
+ const label = elem.append("g").attr("class", "stateLabel");
208
+ const { x, y } = utils_default.calcLabelPosition(path.points);
209
+ const rows = common_default.getRows(relation.title);
210
+ let titleHeight = 0;
211
+ const titleRows = [];
212
+ let maxWidth = 0;
213
+ let minX = 0;
214
+ for (let i = 0; i <= rows.length; i++) {
215
+ const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight);
216
+ const boundsTmp = title.node().getBBox();
217
+ maxWidth = Math.max(maxWidth, boundsTmp.width);
218
+ minX = Math.min(minX, boundsTmp.x);
219
+ log.info(boundsTmp.x, x, y + titleHeight);
220
+ if (titleHeight === 0) {
221
+ const titleBox = title.node().getBBox();
222
+ titleHeight = titleBox.height;
223
+ log.info("Title height", titleHeight, y);
224
+ }
225
+ titleRows.push(title);
226
+ }
227
+ let boxHeight = titleHeight * rows.length;
228
+ if (rows.length > 1) {
229
+ const heightAdj = (rows.length - 1) * titleHeight * 0.5;
230
+ titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj));
231
+ boxHeight = titleHeight * rows.length;
232
+ }
233
+ const bounds = label.node().getBBox();
234
+ 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);
235
+ log.info(bounds);
236
+ }
237
+ edgeCount++;
238
+ }, "drawEdge");
239
+ var conf;
240
+ var transformationLog = {};
241
+ var setConf = /* @__PURE__ */ __name(function() {
242
+ }, "setConf");
243
+ var insertMarkers = /* @__PURE__ */ __name(function(elem) {
244
+ 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");
245
+ }, "insertMarkers");
246
+ var draw = /* @__PURE__ */ __name(function(text, id, _version, diagObj) {
247
+ conf = getConfig2().state;
248
+ const securityLevel = getConfig2().securityLevel;
249
+ let sandboxElement;
250
+ if (securityLevel === "sandbox") {
251
+ sandboxElement = select("#i" + id);
252
+ }
253
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
254
+ const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
255
+ log.debug("Rendering diagram " + text);
256
+ const diagram2 = root.select(`[id='${id}']`);
257
+ insertMarkers(diagram2);
258
+ const rootDoc = diagObj.db.getRootDoc();
259
+ const rootG = diagram2.append("g").attr("id", id + "-root");
260
+ renderDoc(rootDoc, rootG, void 0, false, root, doc, diagObj);
261
+ const padding = conf.padding;
262
+ const bounds = diagram2.node().getBBox();
263
+ const width = bounds.width + padding * 2;
264
+ const height = bounds.height + padding * 2;
265
+ const svgWidth = width * 1.75;
266
+ configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth);
267
+ diagram2.attr(
268
+ "viewBox",
269
+ `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height
270
+ );
271
+ }, "draw");
272
+ var getLabelWidth = /* @__PURE__ */ __name((text) => {
273
+ return text ? text.length * conf.fontSizeFactor : 1;
274
+ }, "getLabelWidth");
275
+ var renderDoc = /* @__PURE__ */ __name((doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => {
276
+ const graph = new Graph({
277
+ compound: true,
278
+ multigraph: true
279
+ });
280
+ let i;
281
+ let edgeFreeDoc = true;
282
+ for (i = 0; i < doc.length; i++) {
283
+ if (doc[i].stmt === "relation") {
284
+ edgeFreeDoc = false;
285
+ break;
286
+ }
287
+ }
288
+ if (parentId) {
289
+ graph.setGraph({
290
+ rankdir: "LR",
291
+ multigraph: true,
292
+ compound: true,
293
+ // acyclicer: 'greedy',
294
+ ranker: "tight-tree",
295
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
296
+ nodeSep: edgeFreeDoc ? 1 : 50,
297
+ isMultiGraph: true
298
+ // ranksep: 5,
299
+ // nodesep: 1
300
+ });
301
+ } else {
302
+ graph.setGraph({
303
+ rankdir: "TB",
304
+ multigraph: true,
305
+ compound: true,
306
+ // isCompound: true,
307
+ // acyclicer: 'greedy',
308
+ // ranker: 'longest-path'
309
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
310
+ nodeSep: edgeFreeDoc ? 1 : 50,
311
+ ranker: "tight-tree",
312
+ // ranker: 'network-simplex'
313
+ isMultiGraph: true
314
+ });
315
+ }
316
+ graph.setDefaultEdgeLabel(function() {
317
+ return {};
318
+ });
319
+ const states = diagObj.db.getStates();
320
+ const relations = diagObj.db.getRelations();
321
+ const keys = Object.keys(states);
322
+ for (const key of keys) {
323
+ const stateDef = states[key];
324
+ if (parentId) {
325
+ stateDef.parentId = parentId;
326
+ }
327
+ let node;
328
+ if (stateDef.doc) {
329
+ let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup");
330
+ node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj);
331
+ {
332
+ sub = addTitleAndBox(sub, stateDef, altBkg);
333
+ let boxBounds = sub.node().getBBox();
334
+ node.width = boxBounds.width;
335
+ node.height = boxBounds.height + conf.padding / 2;
336
+ transformationLog[stateDef.id] = { y: conf.compositTitleSize };
337
+ }
338
+ } else {
339
+ node = drawState(diagram2, stateDef, graph);
340
+ }
341
+ if (stateDef.note) {
342
+ const noteDef = {
343
+ descriptions: [],
344
+ id: stateDef.id + "-note",
345
+ note: stateDef.note,
346
+ type: "note"
347
+ };
348
+ const note = drawState(diagram2, noteDef, graph);
349
+ if (stateDef.note.position === "left of") {
350
+ graph.setNode(node.id + "-note", note);
351
+ graph.setNode(node.id, node);
352
+ } else {
353
+ graph.setNode(node.id, node);
354
+ graph.setNode(node.id + "-note", note);
355
+ }
356
+ graph.setParent(node.id, node.id + "-group");
357
+ graph.setParent(node.id + "-note", node.id + "-group");
358
+ } else {
359
+ graph.setNode(node.id, node);
360
+ }
361
+ }
362
+ log.debug("Count=", graph.nodeCount(), graph);
363
+ let cnt = 0;
364
+ relations.forEach(function(relation) {
365
+ cnt++;
366
+ log.debug("Setting edge", relation);
367
+ graph.setEdge(
368
+ relation.id1,
369
+ relation.id2,
370
+ {
371
+ relation,
372
+ width: getLabelWidth(relation.title),
373
+ height: conf.labelHeight * common_default.getRows(relation.title).length,
374
+ labelpos: "c"
375
+ },
376
+ "id" + cnt
377
+ );
378
+ });
379
+ layout(graph);
380
+ log.debug("Graph after layout", graph.nodes());
381
+ const svgElem = diagram2.node();
382
+ graph.nodes().forEach(function(v) {
383
+ if (v !== void 0 && graph.node(v) !== void 0) {
384
+ log.warn("Node " + v + ": " + JSON.stringify(graph.node(v)));
385
+ root.select("#" + svgElem.id + " #" + v).attr(
386
+ "transform",
387
+ "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) + " )"
388
+ );
389
+ root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2);
390
+ const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider");
391
+ dividers.forEach((divider) => {
392
+ const parent = divider.parentElement;
393
+ let pWidth = 0;
394
+ let pShift = 0;
395
+ if (parent) {
396
+ if (parent.parentElement) {
397
+ pWidth = parent.parentElement.getBBox().width;
398
+ }
399
+ pShift = parseInt(parent.getAttribute("data-x-shift"), 10);
400
+ if (Number.isNaN(pShift)) {
401
+ pShift = 0;
402
+ }
403
+ }
404
+ divider.setAttribute("x1", 0 - pShift + 8);
405
+ divider.setAttribute("x2", pWidth - pShift - 8);
406
+ });
407
+ } else {
408
+ log.debug("No Node " + v + ": " + JSON.stringify(graph.node(v)));
409
+ }
410
+ });
411
+ let stateBox = svgElem.getBBox();
412
+ graph.edges().forEach(function(e) {
413
+ if (e !== void 0 && graph.edge(e) !== void 0) {
414
+ log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
415
+ drawEdge(diagram2, graph.edge(e), graph.edge(e).relation);
416
+ }
417
+ });
418
+ stateBox = svgElem.getBBox();
419
+ const stateInfo = {
420
+ id: parentId ? parentId : "root",
421
+ label: parentId ? parentId : "root",
422
+ width: 0,
423
+ height: 0
424
+ };
425
+ stateInfo.width = stateBox.width + 2 * conf.padding;
426
+ stateInfo.height = stateBox.height + 2 * conf.padding;
427
+ log.debug("Doc rendered", stateInfo, graph);
428
+ return stateInfo;
429
+ }, "renderDoc");
430
+ var stateRenderer_default = {
431
+ setConf,
432
+ draw
433
+ };
434
+ var diagram = {
435
+ parser: stateDiagram_default,
436
+ get db() {
437
+ return new StateDB(1);
438
+ },
439
+ renderer: stateRenderer_default,
440
+ styles: styles_default,
441
+ init: /* @__PURE__ */ __name((cnf) => {
442
+ if (!cnf.state) {
443
+ cnf.state = {};
444
+ }
445
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
446
+ }, "init")
447
+ };
448
+ export {
449
+ diagram
450
+ };
@@ -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-AQP2D5EJ-BK7xJolB.js";
2
+ import { _ as __name } from "./index-DW7LS8C1.js";
3
+ import "./chunk-55IACEB6-CiBpxRa1.js";
4
+ import "./chunk-2J33WTMH-lag2vhq9.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
+ };