@infinilabs/ai-chat 0.0.0 → 0.0.2

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 (119) hide show
  1. package/README.md +310 -56
  2. package/dist/_baseUniq-BFn6cCm9.js +152 -0
  3. package/dist/_baseUniq-nfJyj2zU.cjs +151 -0
  4. package/dist/arc-BWSMkwk2.cjs +130 -0
  5. package/dist/arc-DODeX7B9.js +131 -0
  6. package/dist/architecture-U656AL7Q-B4C0nw6C.js +5 -0
  7. package/dist/architecture-U656AL7Q-CVURQXwt.cjs +5 -0
  8. package/dist/architectureDiagram-VXUJARFQ-2UbdzpNz.cjs +8681 -0
  9. package/dist/architectureDiagram-VXUJARFQ-NCVmzKuE.js +8681 -0
  10. package/dist/blockDiagram-VD42YOAC-B3yCPK1N.cjs +3606 -0
  11. package/dist/blockDiagram-VD42YOAC-C4FsmQfk.js +3606 -0
  12. package/dist/c4Diagram-YG6GDRKO-ATyoKzFV.js +2481 -0
  13. package/dist/c4Diagram-YG6GDRKO-COwVcHWj.cjs +2481 -0
  14. package/dist/channel-2Y73gsu9.cjs +6 -0
  15. package/dist/channel-oB8MffQV.js +7 -0
  16. package/dist/chunk-4BX2VUAB-C3diNHZw.cjs +15 -0
  17. package/dist/chunk-4BX2VUAB-sd2zFBFz.js +16 -0
  18. package/dist/chunk-55IACEB6-6ohTnYE3.js +13 -0
  19. package/dist/chunk-55IACEB6-T-CzlJke.cjs +12 -0
  20. package/dist/chunk-B4BG7PRW-B1zqG62l.cjs +1825 -0
  21. package/dist/chunk-B4BG7PRW-E1dti26Y.js +1826 -0
  22. package/dist/chunk-DI55MBZ5-Dk0kfYBV.cjs +1914 -0
  23. package/dist/chunk-DI55MBZ5-DpHw-vMw.js +1915 -0
  24. package/dist/chunk-FMBD7UC4-B1vXpasq.js +19 -0
  25. package/dist/chunk-FMBD7UC4-CShN9-qf.cjs +18 -0
  26. package/dist/chunk-QN33PNHL-Cw7FG91D.js +24 -0
  27. package/dist/chunk-QN33PNHL-DJi1fhak.cjs +23 -0
  28. package/dist/chunk-QZHKN3VN-BweiBR9P.js +17 -0
  29. package/dist/chunk-QZHKN3VN-DfUW_gDw.cjs +16 -0
  30. package/dist/chunk-TZMSLE5B-DY2Kbag4.cjs +107 -0
  31. package/dist/chunk-TZMSLE5B-ZQ2Esoix.js +108 -0
  32. package/dist/classDiagram-2ON5EDUG-D2tIbkjc.js +19 -0
  33. package/dist/classDiagram-2ON5EDUG-DRhRmkUb.cjs +19 -0
  34. package/dist/classDiagram-v2-WZHVMYZB-D2tIbkjc.js +19 -0
  35. package/dist/classDiagram-v2-WZHVMYZB-DRhRmkUb.cjs +19 -0
  36. package/dist/clone-BMkj3yun.cjs +7 -0
  37. package/dist/clone-ChHXIoR6.js +8 -0
  38. package/dist/cose-bilkent-S5V4N54A-BXnWH5Od.cjs +4942 -0
  39. package/dist/cose-bilkent-S5V4N54A-D15BmpCb.js +4942 -0
  40. package/dist/cytoscape.esm-BfvZ3QT_.js +30239 -0
  41. package/dist/cytoscape.esm-D8IBYQeQ.cjs +30238 -0
  42. package/dist/dagre-6UL2VRFP-DGQ6TW_g.cjs +693 -0
  43. package/dist/dagre-6UL2VRFP-WmhUYWg8.js +693 -0
  44. package/dist/defaultLocale-DVr69WTU.js +206 -0
  45. package/dist/defaultLocale-DwYGIg9G.cjs +203 -0
  46. package/dist/diagram-PSM6KHXK-DSfHBoUT.js +845 -0
  47. package/dist/diagram-PSM6KHXK-J4qyGeN7.cjs +845 -0
  48. package/dist/diagram-QEK2KX5R-D96wT5cH.cjs +300 -0
  49. package/dist/diagram-QEK2KX5R-I_nyexpY.js +300 -0
  50. package/dist/diagram-S2PKOQOG-BC_WyKEe.cjs +210 -0
  51. package/dist/diagram-S2PKOQOG-aooXSMNo.js +210 -0
  52. package/dist/erDiagram-Q2GNP2WA-DQ8Lquay.cjs +1158 -0
  53. package/dist/erDiagram-Q2GNP2WA-DWF8e6EL.js +1158 -0
  54. package/dist/flowDiagram-NV44I4VS-CM9c4F1o.js +2331 -0
  55. package/dist/flowDiagram-NV44I4VS-DpYNkyM2.cjs +2331 -0
  56. package/dist/ganttDiagram-JELNMOA3-CAsoD6rZ.js +3679 -0
  57. package/dist/ganttDiagram-JELNMOA3-DfKahpj4.cjs +3679 -0
  58. package/dist/gitGraph-F6HP7TQM-BX2fz4_i.js +5 -0
  59. package/dist/gitGraph-F6HP7TQM-DRkGg4T1.cjs +5 -0
  60. package/dist/gitGraphDiagram-NY62KEGX-PXpI94u6.js +1203 -0
  61. package/dist/gitGraphDiagram-NY62KEGX-YhnKpooH.cjs +1203 -0
  62. package/dist/graph-BvxpI7Xc.js +596 -0
  63. package/dist/graph-CI_TWBSn.cjs +595 -0
  64. package/dist/index-BctLGjTK.cjs +120500 -0
  65. package/dist/index-CjSgoo1P.js +120485 -0
  66. package/dist/index.cjs +19 -0
  67. package/dist/index.js +12 -19961
  68. package/dist/info-NVLQJR56-BGbTE7dw.cjs +5 -0
  69. package/dist/info-NVLQJR56-DRxIh-N8.js +5 -0
  70. package/dist/infoDiagram-WHAUD3N6-BB2Bnbnh.cjs +31 -0
  71. package/dist/infoDiagram-WHAUD3N6-D_RrgwxS.js +31 -0
  72. package/dist/init-DevvdK2U.cjs +15 -0
  73. package/dist/init-ZxktEp_H.js +16 -0
  74. package/dist/journeyDiagram-XKPGCS4Q-BJjXlMIj.js +1254 -0
  75. package/dist/journeyDiagram-XKPGCS4Q-BcBLsfI9.cjs +1254 -0
  76. package/dist/kanban-definition-3W4ZIXB7-0wwNBZ93.js +1047 -0
  77. package/dist/kanban-definition-3W4ZIXB7-CaY0q4j9.cjs +1047 -0
  78. package/dist/katex-BhpYeT3b.cjs +14523 -0
  79. package/dist/katex-ei8sH3Uy.js +14524 -0
  80. package/dist/layout-CcghncRv.js +2183 -0
  81. package/dist/layout-CvwzED_C.cjs +2182 -0
  82. package/dist/linear-CYow-mAK.cjs +339 -0
  83. package/dist/linear-D_gKQzVp.js +340 -0
  84. package/dist/mermaid-parser.core-CzmkR-3i.cjs +18703 -0
  85. package/dist/mermaid-parser.core-DCMDT-Cp.js +18704 -0
  86. package/dist/min-BBp7Smma.js +41 -0
  87. package/dist/min-Gu1I_bJ9.cjs +40 -0
  88. package/dist/mindmap-definition-VGOIOE7T-D16Pp1u5.cjs +1126 -0
  89. package/dist/mindmap-definition-VGOIOE7T-PjSLRtz4.js +1126 -0
  90. package/dist/ordinal-CxptdPJm.js +76 -0
  91. package/dist/ordinal-D7sQNqXZ.cjs +75 -0
  92. package/dist/packet-BFZMPI3H-BvdogPiS.js +5 -0
  93. package/dist/packet-BFZMPI3H-C7pOHUWY.cjs +5 -0
  94. package/dist/pie-7BOR55EZ-D-DxSHbP.cjs +5 -0
  95. package/dist/pie-7BOR55EZ-DEWJe4Xn.js +5 -0
  96. package/dist/pieDiagram-ADFJNKIX-CoDddKZl.js +237 -0
  97. package/dist/pieDiagram-ADFJNKIX-DjN4DU9l.cjs +237 -0
  98. package/dist/quadrantDiagram-AYHSOK5B-BZOg0JMm.js +1335 -0
  99. package/dist/quadrantDiagram-AYHSOK5B-DXjTSOL4.cjs +1335 -0
  100. package/dist/radar-NHE76QYJ-BrnDXy9q.cjs +5 -0
  101. package/dist/radar-NHE76QYJ-C2WmPmJ4.js +5 -0
  102. package/dist/requirementDiagram-UZGBJVZJ-CCW1O1xH.js +1161 -0
  103. package/dist/requirementDiagram-UZGBJVZJ-e5F3-dDI.cjs +1161 -0
  104. package/dist/sankeyDiagram-TZEHDZUN-BaGzCxTp.js +1193 -0
  105. package/dist/sankeyDiagram-TZEHDZUN-DtIvOvVI.cjs +1193 -0
  106. package/dist/sequenceDiagram-WL72ISMW-0vFhYnxn.cjs +3874 -0
  107. package/dist/sequenceDiagram-WL72ISMW-DL3B7U56.js +3874 -0
  108. package/dist/stateDiagram-FKZM4ZOC-CXW608BR.cjs +447 -0
  109. package/dist/stateDiagram-FKZM4ZOC-Ddw6HxPD.js +447 -0
  110. package/dist/stateDiagram-v2-4FDKWEC3-DZCkQKmp.js +19 -0
  111. package/dist/stateDiagram-v2-4FDKWEC3-DefWUbvq.cjs +19 -0
  112. package/dist/timeline-definition-IT6M3QCI-C3TfA9lE.cjs +1222 -0
  113. package/dist/timeline-definition-IT6M3QCI-DiS88lUo.js +1222 -0
  114. package/dist/treemap-KMMF4GRG-Bl-H6j2c.cjs +5 -0
  115. package/dist/treemap-KMMF4GRG-DGGr_R9A.js +5 -0
  116. package/dist/xychartDiagram-PRI3JC2R-BrOwRjfF.js +1886 -0
  117. package/dist/xychartDiagram-PRI3JC2R-CM06DttH.cjs +1886 -0
  118. package/package.json +22 -11
  119. package/dist/index.css +0 -1582
@@ -0,0 +1,447 @@
1
+ import { s as styles_default, a as stateDiagram_default, S as StateDB } from "./chunk-DI55MBZ5-DpHw-vMw.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-CjSgoo1P.js";
3
+ import { G as Graph } from "./graph-BvxpI7Xc.js";
4
+ import { l as layout } from "./layout-CcghncRv.js";
5
+ 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");
6
+ 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");
7
+ var drawSimpleState = /* @__PURE__ */ __name((g, stateDef) => {
8
+ 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);
9
+ const classBox = state.node().getBBox();
10
+ 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);
11
+ return state;
12
+ }, "drawSimpleState");
13
+ var drawDescrState = /* @__PURE__ */ __name((g, stateDef) => {
14
+ const addTspan = /* @__PURE__ */ __name(function(textEl, txt, isFirst2) {
15
+ const tSpan = textEl.append("tspan").attr("x", 2 * getConfig2().state.padding).text(txt);
16
+ if (!isFirst2) {
17
+ tSpan.attr("dy", getConfig2().state.textHeight);
18
+ }
19
+ }, "addTspan");
20
+ 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]);
21
+ const titleBox = title.node().getBBox();
22
+ const titleHeight = titleBox.height;
23
+ const description = g.append("text").attr("x", getConfig2().state.padding).attr(
24
+ "y",
25
+ titleHeight + getConfig2().state.padding * 0.4 + getConfig2().state.dividerMargin + getConfig2().state.textHeight
26
+ ).attr("class", "state-description");
27
+ let isFirst = true;
28
+ let isSecond = true;
29
+ stateDef.descriptions.forEach(function(descr) {
30
+ if (!isFirst) {
31
+ addTspan(description, descr, isSecond);
32
+ isSecond = false;
33
+ }
34
+ isFirst = false;
35
+ });
36
+ 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");
37
+ const descrBox = description.node().getBBox();
38
+ const width = Math.max(descrBox.width, titleBox.width);
39
+ descrLine.attr("x2", width + 3 * getConfig2().state.padding);
40
+ 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);
41
+ return g;
42
+ }, "drawDescrState");
43
+ var addTitleAndBox = /* @__PURE__ */ __name((g, stateDef, altBkg) => {
44
+ const pad = getConfig2().state.padding;
45
+ const dblPad = 2 * getConfig2().state.padding;
46
+ const orgBox = g.node().getBBox();
47
+ const orgWidth = orgBox.width;
48
+ const orgX = orgBox.x;
49
+ 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);
50
+ const titleBox = title.node().getBBox();
51
+ const titleWidth = titleBox.width + dblPad;
52
+ let width = Math.max(titleWidth, orgWidth);
53
+ if (width === orgWidth) {
54
+ width = width + dblPad;
55
+ }
56
+ let startX;
57
+ const graphBox = g.node().getBBox();
58
+ if (stateDef.doc) ;
59
+ startX = orgX - pad;
60
+ if (titleWidth > orgWidth) {
61
+ startX = (orgWidth - width) / 2 + pad;
62
+ }
63
+ if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) {
64
+ startX = orgX - (titleWidth - orgWidth) / 2;
65
+ }
66
+ const lineY = 1 - getConfig2().state.textHeight;
67
+ g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr(
68
+ "height",
69
+ graphBox.height + getConfig2().state.textHeight + getConfig2().state.titleShift + 1
70
+ ).attr("rx", "0");
71
+ title.attr("x", startX + pad);
72
+ if (titleWidth <= orgWidth) {
73
+ title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);
74
+ }
75
+ g.insert("rect", ":first-child").attr("x", startX).attr(
76
+ "y",
77
+ getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
78
+ ).attr("width", width).attr("height", getConfig2().state.textHeight * 3).attr("rx", getConfig2().state.radius);
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", graphBox.height + 3 + 2 * getConfig2().state.textHeight).attr("rx", getConfig2().state.radius);
83
+ return g;
84
+ }, "addTitleAndBox");
85
+ var drawEndState = /* @__PURE__ */ __name((g) => {
86
+ g.append("circle").attr("class", "end-state-outer").attr("r", getConfig2().state.sizeUnit + getConfig2().state.miniPadding).attr(
87
+ "cx",
88
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
89
+ ).attr(
90
+ "cy",
91
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
92
+ );
93
+ 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);
94
+ }, "drawEndState");
95
+ var drawForkJoinState = /* @__PURE__ */ __name((g, stateDef) => {
96
+ let width = getConfig2().state.forkWidth;
97
+ let height = getConfig2().state.forkHeight;
98
+ if (stateDef.parentId) {
99
+ let tmp = width;
100
+ width = height;
101
+ height = tmp;
102
+ }
103
+ 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);
104
+ }, "drawForkJoinState");
105
+ var _drawLongText = /* @__PURE__ */ __name((_text, x, y, g) => {
106
+ let textHeight = 0;
107
+ const textElem = g.append("text");
108
+ textElem.style("text-anchor", "start");
109
+ textElem.attr("class", "noteText");
110
+ let text = _text.replace(/\r\n/g, "<br/>");
111
+ text = text.replace(/\n/g, "<br/>");
112
+ const lines = text.split(common_default.lineBreakRegex);
113
+ let tHeight = 1.25 * getConfig2().state.noteMargin;
114
+ for (const line2 of lines) {
115
+ const txt = line2.trim();
116
+ if (txt.length > 0) {
117
+ const span = textElem.append("tspan");
118
+ span.text(txt);
119
+ if (tHeight === 0) {
120
+ const textBounds = span.node().getBBox();
121
+ tHeight += textBounds.height;
122
+ }
123
+ textHeight += tHeight;
124
+ span.attr("x", x + getConfig2().state.noteMargin);
125
+ span.attr("y", y + textHeight + 1.25 * getConfig2().state.noteMargin);
126
+ }
127
+ }
128
+ return { textWidth: textElem.node().getBBox().width, textHeight };
129
+ }, "_drawLongText");
130
+ var drawNote = /* @__PURE__ */ __name((text, g) => {
131
+ g.attr("class", "state-note");
132
+ const note = g.append("rect").attr("x", 0).attr("y", getConfig2().state.padding);
133
+ const rectElem = g.append("g");
134
+ const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
135
+ note.attr("height", textHeight + 2 * getConfig2().state.noteMargin);
136
+ note.attr("width", textWidth + getConfig2().state.noteMargin * 2);
137
+ return note;
138
+ }, "drawNote");
139
+ var drawState = /* @__PURE__ */ __name(function(elem, stateDef) {
140
+ const id = stateDef.id;
141
+ const stateInfo = {
142
+ id,
143
+ label: stateDef.id,
144
+ width: 0,
145
+ height: 0
146
+ };
147
+ const g = elem.append("g").attr("id", id).attr("class", "stateGroup");
148
+ if (stateDef.type === "start") {
149
+ drawStartState(g);
150
+ }
151
+ if (stateDef.type === "end") {
152
+ drawEndState(g);
153
+ }
154
+ if (stateDef.type === "fork" || stateDef.type === "join") {
155
+ drawForkJoinState(g, stateDef);
156
+ }
157
+ if (stateDef.type === "note") {
158
+ drawNote(stateDef.note.text, g);
159
+ }
160
+ if (stateDef.type === "divider") {
161
+ drawDivider(g);
162
+ }
163
+ if (stateDef.type === "default" && stateDef.descriptions.length === 0) {
164
+ drawSimpleState(g, stateDef);
165
+ }
166
+ if (stateDef.type === "default" && stateDef.descriptions.length > 0) {
167
+ drawDescrState(g, stateDef);
168
+ }
169
+ const stateBox = g.node().getBBox();
170
+ stateInfo.width = stateBox.width + 2 * getConfig2().state.padding;
171
+ stateInfo.height = stateBox.height + 2 * getConfig2().state.padding;
172
+ return stateInfo;
173
+ }, "drawState");
174
+ var edgeCount = 0;
175
+ var drawEdge = /* @__PURE__ */ __name(function(elem, path, relation) {
176
+ const getRelationType = /* @__PURE__ */ __name(function(type) {
177
+ switch (type) {
178
+ case StateDB.relationType.AGGREGATION:
179
+ return "aggregation";
180
+ case StateDB.relationType.EXTENSION:
181
+ return "extension";
182
+ case StateDB.relationType.COMPOSITION:
183
+ return "composition";
184
+ case StateDB.relationType.DEPENDENCY:
185
+ return "dependency";
186
+ }
187
+ }, "getRelationType");
188
+ path.points = path.points.filter((p) => !Number.isNaN(p.y));
189
+ const lineData = path.points;
190
+ const lineFunction = line().x(function(d) {
191
+ return d.x;
192
+ }).y(function(d) {
193
+ return d.y;
194
+ }).curve(curveBasis);
195
+ const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition");
196
+ let url = "";
197
+ if (getConfig2().state.arrowMarkerAbsolute) {
198
+ url = getUrl(true);
199
+ }
200
+ svgPath.attr(
201
+ "marker-end",
202
+ "url(" + url + "#" + getRelationType(StateDB.relationType.DEPENDENCY) + "End)"
203
+ );
204
+ if (relation.title !== void 0) {
205
+ const label = elem.append("g").attr("class", "stateLabel");
206
+ const { x, y } = utils_default.calcLabelPosition(path.points);
207
+ const rows = common_default.getRows(relation.title);
208
+ let titleHeight = 0;
209
+ const titleRows = [];
210
+ let maxWidth = 0;
211
+ let minX = 0;
212
+ for (let i = 0; i <= rows.length; i++) {
213
+ const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight);
214
+ const boundsTmp = title.node().getBBox();
215
+ maxWidth = Math.max(maxWidth, boundsTmp.width);
216
+ minX = Math.min(minX, boundsTmp.x);
217
+ log.info(boundsTmp.x, x, y + titleHeight);
218
+ if (titleHeight === 0) {
219
+ const titleBox = title.node().getBBox();
220
+ titleHeight = titleBox.height;
221
+ log.info("Title height", titleHeight, y);
222
+ }
223
+ titleRows.push(title);
224
+ }
225
+ let boxHeight = titleHeight * rows.length;
226
+ if (rows.length > 1) {
227
+ const heightAdj = (rows.length - 1) * titleHeight * 0.5;
228
+ titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj));
229
+ boxHeight = titleHeight * rows.length;
230
+ }
231
+ const bounds = label.node().getBBox();
232
+ 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);
233
+ log.info(bounds);
234
+ }
235
+ edgeCount++;
236
+ }, "drawEdge");
237
+ var conf;
238
+ var transformationLog = {};
239
+ var setConf = /* @__PURE__ */ __name(function() {
240
+ }, "setConf");
241
+ var insertMarkers = /* @__PURE__ */ __name(function(elem) {
242
+ 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");
243
+ }, "insertMarkers");
244
+ var draw = /* @__PURE__ */ __name(function(text, id, _version, diagObj) {
245
+ conf = getConfig2().state;
246
+ const securityLevel = getConfig2().securityLevel;
247
+ let sandboxElement;
248
+ if (securityLevel === "sandbox") {
249
+ sandboxElement = select("#i" + id);
250
+ }
251
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
252
+ const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
253
+ log.debug("Rendering diagram " + text);
254
+ const diagram2 = root.select(`[id='${id}']`);
255
+ insertMarkers(diagram2);
256
+ const rootDoc = diagObj.db.getRootDoc();
257
+ renderDoc(rootDoc, diagram2, void 0, false, root, doc, diagObj);
258
+ const padding = conf.padding;
259
+ const bounds = diagram2.node().getBBox();
260
+ const width = bounds.width + padding * 2;
261
+ const height = bounds.height + padding * 2;
262
+ const svgWidth = width * 1.75;
263
+ configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth);
264
+ diagram2.attr(
265
+ "viewBox",
266
+ `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height
267
+ );
268
+ }, "draw");
269
+ var getLabelWidth = /* @__PURE__ */ __name((text) => {
270
+ return text ? text.length * conf.fontSizeFactor : 1;
271
+ }, "getLabelWidth");
272
+ var renderDoc = /* @__PURE__ */ __name((doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => {
273
+ const graph = new Graph({
274
+ compound: true,
275
+ multigraph: true
276
+ });
277
+ let i;
278
+ let edgeFreeDoc = true;
279
+ for (i = 0; i < doc.length; i++) {
280
+ if (doc[i].stmt === "relation") {
281
+ edgeFreeDoc = false;
282
+ break;
283
+ }
284
+ }
285
+ if (parentId) {
286
+ graph.setGraph({
287
+ rankdir: "LR",
288
+ multigraph: true,
289
+ compound: true,
290
+ // acyclicer: 'greedy',
291
+ ranker: "tight-tree",
292
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
293
+ nodeSep: edgeFreeDoc ? 1 : 50,
294
+ isMultiGraph: true
295
+ // ranksep: 5,
296
+ // nodesep: 1
297
+ });
298
+ } else {
299
+ graph.setGraph({
300
+ rankdir: "TB",
301
+ multigraph: true,
302
+ compound: true,
303
+ // isCompound: true,
304
+ // acyclicer: 'greedy',
305
+ // ranker: 'longest-path'
306
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
307
+ nodeSep: edgeFreeDoc ? 1 : 50,
308
+ ranker: "tight-tree",
309
+ // ranker: 'network-simplex'
310
+ isMultiGraph: true
311
+ });
312
+ }
313
+ graph.setDefaultEdgeLabel(function() {
314
+ return {};
315
+ });
316
+ const states = diagObj.db.getStates();
317
+ const relations = diagObj.db.getRelations();
318
+ const keys = Object.keys(states);
319
+ for (const key of keys) {
320
+ const stateDef = states[key];
321
+ if (parentId) {
322
+ stateDef.parentId = parentId;
323
+ }
324
+ let node;
325
+ if (stateDef.doc) {
326
+ let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup");
327
+ node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj);
328
+ {
329
+ sub = addTitleAndBox(sub, stateDef, altBkg);
330
+ let boxBounds = sub.node().getBBox();
331
+ node.width = boxBounds.width;
332
+ node.height = boxBounds.height + conf.padding / 2;
333
+ transformationLog[stateDef.id] = { y: conf.compositTitleSize };
334
+ }
335
+ } else {
336
+ node = drawState(diagram2, stateDef, graph);
337
+ }
338
+ if (stateDef.note) {
339
+ const noteDef = {
340
+ descriptions: [],
341
+ id: stateDef.id + "-note",
342
+ note: stateDef.note,
343
+ type: "note"
344
+ };
345
+ const note = drawState(diagram2, noteDef, graph);
346
+ if (stateDef.note.position === "left of") {
347
+ graph.setNode(node.id + "-note", note);
348
+ graph.setNode(node.id, node);
349
+ } else {
350
+ graph.setNode(node.id, node);
351
+ graph.setNode(node.id + "-note", note);
352
+ }
353
+ graph.setParent(node.id, node.id + "-group");
354
+ graph.setParent(node.id + "-note", node.id + "-group");
355
+ } else {
356
+ graph.setNode(node.id, node);
357
+ }
358
+ }
359
+ log.debug("Count=", graph.nodeCount(), graph);
360
+ let cnt = 0;
361
+ relations.forEach(function(relation) {
362
+ cnt++;
363
+ log.debug("Setting edge", relation);
364
+ graph.setEdge(
365
+ relation.id1,
366
+ relation.id2,
367
+ {
368
+ relation,
369
+ width: getLabelWidth(relation.title),
370
+ height: conf.labelHeight * common_default.getRows(relation.title).length,
371
+ labelpos: "c"
372
+ },
373
+ "id" + cnt
374
+ );
375
+ });
376
+ layout(graph);
377
+ log.debug("Graph after layout", graph.nodes());
378
+ const svgElem = diagram2.node();
379
+ graph.nodes().forEach(function(v) {
380
+ if (v !== void 0 && graph.node(v) !== void 0) {
381
+ log.warn("Node " + v + ": " + JSON.stringify(graph.node(v)));
382
+ root.select("#" + svgElem.id + " #" + v).attr(
383
+ "transform",
384
+ "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) + " )"
385
+ );
386
+ root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2);
387
+ const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider");
388
+ dividers.forEach((divider) => {
389
+ const parent = divider.parentElement;
390
+ let pWidth = 0;
391
+ let pShift = 0;
392
+ if (parent) {
393
+ if (parent.parentElement) {
394
+ pWidth = parent.parentElement.getBBox().width;
395
+ }
396
+ pShift = parseInt(parent.getAttribute("data-x-shift"), 10);
397
+ if (Number.isNaN(pShift)) {
398
+ pShift = 0;
399
+ }
400
+ }
401
+ divider.setAttribute("x1", 0 - pShift + 8);
402
+ divider.setAttribute("x2", pWidth - pShift - 8);
403
+ });
404
+ } else {
405
+ log.debug("No Node " + v + ": " + JSON.stringify(graph.node(v)));
406
+ }
407
+ });
408
+ let stateBox = svgElem.getBBox();
409
+ graph.edges().forEach(function(e) {
410
+ if (e !== void 0 && graph.edge(e) !== void 0) {
411
+ log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
412
+ drawEdge(diagram2, graph.edge(e), graph.edge(e).relation);
413
+ }
414
+ });
415
+ stateBox = svgElem.getBBox();
416
+ const stateInfo = {
417
+ id: parentId ? parentId : "root",
418
+ label: parentId ? parentId : "root",
419
+ width: 0,
420
+ height: 0
421
+ };
422
+ stateInfo.width = stateBox.width + 2 * conf.padding;
423
+ stateInfo.height = stateBox.height + 2 * conf.padding;
424
+ log.debug("Doc rendered", stateInfo, graph);
425
+ return stateInfo;
426
+ }, "renderDoc");
427
+ var stateRenderer_default = {
428
+ setConf,
429
+ draw
430
+ };
431
+ var diagram = {
432
+ parser: stateDiagram_default,
433
+ get db() {
434
+ return new StateDB(1);
435
+ },
436
+ renderer: stateRenderer_default,
437
+ styles: styles_default,
438
+ init: /* @__PURE__ */ __name((cnf) => {
439
+ if (!cnf.state) {
440
+ cnf.state = {};
441
+ }
442
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
443
+ }, "init")
444
+ };
445
+ export {
446
+ diagram
447
+ };
@@ -0,0 +1,19 @@
1
+ import { s as styles_default, b as stateRenderer_v3_unified_default, a as stateDiagram_default, S as StateDB } from "./chunk-DI55MBZ5-DpHw-vMw.js";
2
+ import { _ as __name } from "./index-CjSgoo1P.js";
3
+ var diagram = {
4
+ parser: stateDiagram_default,
5
+ get db() {
6
+ return new StateDB(2);
7
+ },
8
+ renderer: stateRenderer_v3_unified_default,
9
+ styles: styles_default,
10
+ init: /* @__PURE__ */ __name((cnf) => {
11
+ if (!cnf.state) {
12
+ cnf.state = {};
13
+ }
14
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
15
+ }, "init")
16
+ };
17
+ export {
18
+ diagram
19
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const chunkDI55MBZ5 = require("./chunk-DI55MBZ5-Dk0kfYBV.cjs");
4
+ const index = require("./index-BctLGjTK.cjs");
5
+ var diagram = {
6
+ parser: chunkDI55MBZ5.stateDiagram_default,
7
+ get db() {
8
+ return new chunkDI55MBZ5.StateDB(2);
9
+ },
10
+ renderer: chunkDI55MBZ5.stateRenderer_v3_unified_default,
11
+ styles: chunkDI55MBZ5.styles_default,
12
+ init: /* @__PURE__ */ index.__name((cnf) => {
13
+ if (!cnf.state) {
14
+ cnf.state = {};
15
+ }
16
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
17
+ }, "init")
18
+ };
19
+ exports.diagram = diagram;