whipped 0.8.1 → 0.9.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 (86) hide show
  1. package/dist/cli.js +1294 -259
  2. package/dist/mcp-server.js +150 -2
  3. package/dist/migrations/014_companion_sessions.sql +34 -0
  4. package/dist/migrations/015_companion_worktree_mode.sql +45 -0
  5. package/dist/migrations/016_companion_plans.sql +22 -0
  6. package/dist/migrations/017_companion_saved_plans.sql +23 -0
  7. package/dist/migrations/018_generalize_plan_session_ref.sql +29 -0
  8. package/dist/migrations/019_rename_plan_to_canvas.sql +20 -0
  9. package/dist/web-ui/assets/abnfDiagram-VRR7QNED-RwOyl_Kz.js +119 -0
  10. package/dist/web-ui/assets/arc-DmDBHE0H.js +131 -0
  11. package/dist/web-ui/assets/architectureDiagram-ZJ3FMSHR-RTwadm6J.js +8821 -0
  12. package/dist/web-ui/assets/blockDiagram-677ZJIJ3-Dvv5uMUE.js +3801 -0
  13. package/dist/web-ui/assets/c4Diagram-LMCZKHZV-bvr9R9cD.js +2479 -0
  14. package/dist/web-ui/assets/channel-BGhlETgZ.js +7 -0
  15. package/dist/web-ui/assets/chunk-2Q5K7J3B-BRq-Qbau.js +17 -0
  16. package/dist/web-ui/assets/chunk-32BRIVSS-Dy1BUZGx.js +116 -0
  17. package/dist/web-ui/assets/chunk-5VM5RSS4-DCUiIwIc.js +19 -0
  18. package/dist/web-ui/assets/chunk-EX3LRPZG-Cg_Vtzwz.js +1996 -0
  19. package/dist/web-ui/assets/chunk-JWPE2WC7-BW4n_ZhH.js +17 -0
  20. package/dist/web-ui/assets/chunk-MOJQB5TN-BykRa615.js +855 -0
  21. package/dist/web-ui/assets/chunk-RYQCIY6F-D4F7oV1d.js +476 -0
  22. package/dist/web-ui/assets/chunk-V7JOEXUC-DD4mm30h.js +2022 -0
  23. package/dist/web-ui/assets/chunk-VR4S4FIN-Fgvcluvk.js +25 -0
  24. package/dist/web-ui/assets/chunk-XXDRQBXY-C4FVmO5r.js +13 -0
  25. package/dist/web-ui/assets/classDiagram-OUVF2IWQ-DD4KIYF1.js +24 -0
  26. package/dist/web-ui/assets/classDiagram-v2-EOCWNBFH-DD4KIYF1.js +24 -0
  27. package/dist/web-ui/assets/cose-bilkent-JH36ORCC-ekFwvYt9.js +4943 -0
  28. package/dist/web-ui/assets/cynefin-VYW2F7L2-DTNV7gvQ.js +31527 -0
  29. package/dist/web-ui/assets/cynefinDiagram-TSTJHNR4-koYialeC.js +454 -0
  30. package/dist/web-ui/assets/cytoscape.esm-CaQ7Fomf.js +30346 -0
  31. package/dist/web-ui/assets/dagre-VKFMJZFB-Do43FV3o.js +526 -0
  32. package/dist/web-ui/assets/defaultLocale-B2RvLBDe.js +206 -0
  33. package/dist/web-ui/assets/diagram-FQU43EPY-D0STdny6.js +636 -0
  34. package/dist/web-ui/assets/diagram-G47NLZAW-D9g6BdZT.js +858 -0
  35. package/dist/web-ui/assets/diagram-NH7WQ7WH-zLW6CAmi.js +212 -0
  36. package/dist/web-ui/assets/diagram-OA4YK3LP-CA5tvsYw.js +492 -0
  37. package/dist/web-ui/assets/diagram-WEI45ONY-CLmYUHR0.js +309 -0
  38. package/dist/web-ui/assets/ebnfDiagram-CCIWWBDH-KkHubBI6.js +139 -0
  39. package/dist/web-ui/assets/erDiagram-Q63AITRT-BJna2u1n.js +1238 -0
  40. package/dist/web-ui/assets/flowDiagram-23GEKE2U-DVJKalah.js +2353 -0
  41. package/dist/web-ui/assets/ganttDiagram-NO4QXBWP-D9HwNV4u.js +3733 -0
  42. package/dist/web-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  43. package/dist/web-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  44. package/dist/web-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  45. package/dist/web-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  46. package/dist/web-ui/assets/geist-mono-cyrillic-ext-wght-normal-I4S5GZfc.woff2 +0 -0
  47. package/dist/web-ui/assets/geist-mono-cyrillic-wght-normal-BmXc_FBt.woff2 +0 -0
  48. package/dist/web-ui/assets/geist-mono-latin-ext-wght-normal-DrnZ1wKl.woff2 +0 -0
  49. package/dist/web-ui/assets/geist-mono-latin-wght-normal-B_7UjwxQ.woff2 +0 -0
  50. package/dist/web-ui/assets/geist-mono-symbols2-wght-normal-GZpp1pK2.woff2 +0 -0
  51. package/dist/web-ui/assets/geist-mono-vietnamese-wght-normal-D8KDMBhC.woff2 +0 -0
  52. package/dist/web-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  53. package/dist/web-ui/assets/gitGraphDiagram-IHSO6WYX-B7wnoO0J.js +1385 -0
  54. package/dist/web-ui/assets/graph-BMLV0goG.js +2042 -0
  55. package/dist/web-ui/assets/{index-CRXPsGTP.css → index-DPjATOCj.css} +800 -1207
  56. package/dist/web-ui/assets/{index-BMFVAmy4.js → index-DZ7I8r_C.js} +41392 -39594
  57. package/dist/web-ui/assets/infoDiagram-FWYZ7A6U-BY6XoiF8.js +32 -0
  58. package/dist/web-ui/assets/init-ZxktEp_H.js +16 -0
  59. package/dist/web-ui/assets/ishikawaDiagram-FXEZZL3T-BaZVnO8j.js +967 -0
  60. package/dist/web-ui/assets/journeyDiagram-5HDEW3XC-CUA6DUAQ.js +1256 -0
  61. package/dist/web-ui/assets/kanban-definition-HUTT4EX6-5W5tiWrd.js +1055 -0
  62. package/dist/web-ui/assets/katex-CqNtglxf.js +14499 -0
  63. package/dist/web-ui/assets/layout-BNmRhaUB.js +2359 -0
  64. package/dist/web-ui/assets/linear-CfvGIyDE.js +340 -0
  65. package/dist/web-ui/assets/map-BEO0Bu8q.js +298 -0
  66. package/dist/web-ui/assets/mermaid.core-BRk3IzY2.js +26639 -0
  67. package/dist/web-ui/assets/mindmap-definition-LN4V7U3C-2GmLg6ou.js +1183 -0
  68. package/dist/web-ui/assets/ordinal-DSZU4PqD.js +76 -0
  69. package/dist/web-ui/assets/pegDiagram-2B236MQR-gTEdrkJg.js +127 -0
  70. package/dist/web-ui/assets/pieDiagram-ENE6RG2P-CYXjIhqC.js +318 -0
  71. package/dist/web-ui/assets/quadrantDiagram-ABIIQ3AL-BStRZxwf.js +1341 -0
  72. package/dist/web-ui/assets/railroadDiagram-RFXS5EU6-btveDRG2.js +93 -0
  73. package/dist/web-ui/assets/requirementDiagram-TGXJPOKE-Cy_155rE.js +1205 -0
  74. package/dist/web-ui/assets/sankeyDiagram-HTMAVEWB-Chtvw3_G.js +1264 -0
  75. package/dist/web-ui/assets/sequenceDiagram-DBY2YBRQ-DDuMVEX1.js +4523 -0
  76. package/dist/web-ui/assets/sizeCapture-X5ZJPWSS-Bylf0o6J.js +64 -0
  77. package/dist/web-ui/assets/stateDiagram-2N3HPSRC-DIzLeR5G.js +453 -0
  78. package/dist/web-ui/assets/stateDiagram-v2-6OUMAXLB-zG_WjT1-.js +23 -0
  79. package/dist/web-ui/assets/swimlanes-5IMT3BWC-TKaCmVta.js +8575 -0
  80. package/dist/web-ui/assets/swimlanesDiagram-G3AALYLV-C5eB3qqS.js +21 -0
  81. package/dist/web-ui/assets/timeline-definition-FHXFAJF6-CC5Ujpcu.js +1606 -0
  82. package/dist/web-ui/assets/vennDiagram-L72KCM5P-DUSVXSYT.js +2523 -0
  83. package/dist/web-ui/assets/wardleyDiagram-EHGQE667-CoP9xn89.js +978 -0
  84. package/dist/web-ui/assets/xychartDiagram-FW5EYKEG-B9FqP_kk.js +1972 -0
  85. package/dist/web-ui/index.html +2 -2
  86. package/package.json +1 -1
@@ -0,0 +1,64 @@
1
+ import { _ as __name } from "./mermaid.core-BRk3IzY2.js";
2
+ import "./index-DZ7I8r_C.js";
3
+ var DDLT_SIZE_CAPTURE_VERSION = 1;
4
+ function getCaptureGlobal() {
5
+ if (typeof globalThis === "undefined") {
6
+ return void 0;
7
+ }
8
+ return globalThis;
9
+ }
10
+ __name(getCaptureGlobal, "getCaptureGlobal");
11
+ function shouldCaptureSizes() {
12
+ var _a;
13
+ return Boolean((_a = getCaptureGlobal()) == null ? void 0 : _a.mermaidCaptureSizes);
14
+ }
15
+ __name(shouldCaptureSizes, "shouldCaptureSizes");
16
+ function capturedFromLocation() {
17
+ if (typeof location === "undefined") {
18
+ return "browser-dev";
19
+ }
20
+ return `${location.pathname}${location.search}`;
21
+ }
22
+ __name(capturedFromLocation, "capturedFromLocation");
23
+ function emitCapturedSizes(captured, element) {
24
+ const g = getCaptureGlobal();
25
+ if (!g) {
26
+ return;
27
+ }
28
+ const domNode = element.node();
29
+ const ownerSvg = (domNode && "ownerSVGElement" in domNode ? domNode.ownerSVGElement : null) ?? domNode;
30
+ const svgId = (ownerSvg == null ? void 0 : ownerSvg.id) ?? "(unknown)";
31
+ g.mermaidCapturedSizes ?? (g.mermaidCapturedSizes = []);
32
+ const entry = { svgId, sizes: captured };
33
+ g.mermaidCapturedSizes.push(entry);
34
+ g.mermaidLastCapturedSizes = entry;
35
+ }
36
+ __name(emitCapturedSizes, "emitCapturedSizes");
37
+ function captureNodeSizes(element, data4Layout) {
38
+ const nodes = [];
39
+ for (const node of data4Layout.nodes) {
40
+ if (node.isGroup) {
41
+ continue;
42
+ }
43
+ nodes.push({ id: node.id, width: node.width ?? 0, height: node.height ?? 0 });
44
+ }
45
+ if (nodes.length === 0) {
46
+ return;
47
+ }
48
+ emitCapturedSizes(
49
+ {
50
+ metadata: {
51
+ captureVersion: DDLT_SIZE_CAPTURE_VERSION,
52
+ capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
53
+ capturedFrom: capturedFromLocation()
54
+ },
55
+ nodes
56
+ },
57
+ element
58
+ );
59
+ }
60
+ __name(captureNodeSizes, "captureNodeSizes");
61
+ export {
62
+ captureNodeSizes,
63
+ shouldCaptureSizes
64
+ };
@@ -0,0 +1,453 @@
1
+ import { s as styles_default, a as stateDiagram_default, S as StateDB } from "./chunk-EX3LRPZG-Cg_Vtzwz.js";
2
+ import { _ as __name, c as getConfig2, d as select, l as log, e as configureSvgSize, k as common_default, P as line, Q as curveBasis, L as getUrl, x as utils_default } from "./mermaid.core-BRk3IzY2.js";
3
+ import { G as Graph } from "./graph-BMLV0goG.js";
4
+ import { l as layout } from "./layout-BNmRhaUB.js";
5
+ import "./chunk-XXDRQBXY-C4FVmO5r.js";
6
+ import "./chunk-VR4S4FIN-Fgvcluvk.js";
7
+ import "./chunk-32BRIVSS-Dy1BUZGx.js";
8
+ import "./index-DZ7I8r_C.js";
9
+ import "./map-BEO0Bu8q.js";
10
+ 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");
11
+ 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");
12
+ var drawSimpleState = /* @__PURE__ */ __name((g, stateDef) => {
13
+ 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);
14
+ const classBox = state.node().getBBox();
15
+ 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);
16
+ return state;
17
+ }, "drawSimpleState");
18
+ var drawDescrState = /* @__PURE__ */ __name((g, stateDef) => {
19
+ const addTspan = /* @__PURE__ */ __name(function(textEl, txt, isFirst2) {
20
+ const tSpan = textEl.append("tspan").attr("x", 2 * getConfig2().state.padding).text(txt);
21
+ if (!isFirst2) {
22
+ tSpan.attr("dy", getConfig2().state.textHeight);
23
+ }
24
+ }, "addTspan");
25
+ 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]);
26
+ const titleBox = title.node().getBBox();
27
+ const titleHeight = titleBox.height;
28
+ const description = g.append("text").attr("x", getConfig2().state.padding).attr(
29
+ "y",
30
+ titleHeight + getConfig2().state.padding * 0.4 + getConfig2().state.dividerMargin + getConfig2().state.textHeight
31
+ ).attr("class", "state-description");
32
+ let isFirst = true;
33
+ let isSecond = true;
34
+ stateDef.descriptions.forEach(function(descr) {
35
+ if (!isFirst) {
36
+ addTspan(description, descr, isSecond);
37
+ isSecond = false;
38
+ }
39
+ isFirst = false;
40
+ });
41
+ 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");
42
+ const descrBox = description.node().getBBox();
43
+ const width = Math.max(descrBox.width, titleBox.width);
44
+ descrLine.attr("x2", width + 3 * getConfig2().state.padding);
45
+ 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);
46
+ return g;
47
+ }, "drawDescrState");
48
+ var addTitleAndBox = /* @__PURE__ */ __name((g, stateDef, altBkg) => {
49
+ const pad = getConfig2().state.padding;
50
+ const dblPad = 2 * getConfig2().state.padding;
51
+ const orgBox = g.node().getBBox();
52
+ const orgWidth = orgBox.width;
53
+ const orgX = orgBox.x;
54
+ 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);
55
+ const titleBox = title.node().getBBox();
56
+ const titleWidth = titleBox.width + dblPad;
57
+ let width = Math.max(titleWidth, orgWidth);
58
+ if (width === orgWidth) {
59
+ width = width + dblPad;
60
+ }
61
+ let startX;
62
+ const graphBox = g.node().getBBox();
63
+ if (stateDef.doc) ;
64
+ startX = orgX - pad;
65
+ if (titleWidth > orgWidth) {
66
+ startX = (orgWidth - width) / 2 + pad;
67
+ }
68
+ if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) {
69
+ startX = orgX - (titleWidth - orgWidth) / 2;
70
+ }
71
+ const lineY = 1 - getConfig2().state.textHeight;
72
+ g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr(
73
+ "height",
74
+ graphBox.height + getConfig2().state.textHeight + getConfig2().state.titleShift + 1
75
+ ).attr("rx", "0");
76
+ title.attr("x", startX + pad);
77
+ if (titleWidth <= orgWidth) {
78
+ title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);
79
+ }
80
+ g.insert("rect", ":first-child").attr("x", startX).attr(
81
+ "y",
82
+ getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
83
+ ).attr("width", width).attr("height", getConfig2().state.textHeight * 3).attr("rx", getConfig2().state.radius);
84
+ g.insert("rect", ":first-child").attr("x", startX).attr(
85
+ "y",
86
+ getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
87
+ ).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig2().state.textHeight).attr("rx", getConfig2().state.radius);
88
+ return g;
89
+ }, "addTitleAndBox");
90
+ var drawEndState = /* @__PURE__ */ __name((g) => {
91
+ g.append("circle").attr("class", "end-state-outer").attr("r", getConfig2().state.sizeUnit + getConfig2().state.miniPadding).attr(
92
+ "cx",
93
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
94
+ ).attr(
95
+ "cy",
96
+ getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
97
+ );
98
+ 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);
99
+ }, "drawEndState");
100
+ var drawForkJoinState = /* @__PURE__ */ __name((g, stateDef) => {
101
+ let width = getConfig2().state.forkWidth;
102
+ let height = getConfig2().state.forkHeight;
103
+ if (stateDef.parentId) {
104
+ let tmp = width;
105
+ width = height;
106
+ height = tmp;
107
+ }
108
+ 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);
109
+ }, "drawForkJoinState");
110
+ var _drawLongText = /* @__PURE__ */ __name((_text, x, y, g) => {
111
+ let textHeight = 0;
112
+ const textElem = g.append("text");
113
+ textElem.style("text-anchor", "start");
114
+ textElem.attr("class", "noteText");
115
+ let text = _text.replace(/\r\n/g, "<br/>");
116
+ text = text.replace(/\n/g, "<br/>");
117
+ const lines = text.split(common_default.lineBreakRegex);
118
+ let tHeight = 1.25 * getConfig2().state.noteMargin;
119
+ for (const line2 of lines) {
120
+ const txt = line2.trim();
121
+ if (txt.length > 0) {
122
+ const span = textElem.append("tspan");
123
+ span.text(txt);
124
+ if (tHeight === 0) {
125
+ const textBounds = span.node().getBBox();
126
+ tHeight += textBounds.height;
127
+ }
128
+ textHeight += tHeight;
129
+ span.attr("x", x + getConfig2().state.noteMargin);
130
+ span.attr("y", y + textHeight + 1.25 * getConfig2().state.noteMargin);
131
+ }
132
+ }
133
+ return { textWidth: textElem.node().getBBox().width, textHeight };
134
+ }, "_drawLongText");
135
+ var drawNote = /* @__PURE__ */ __name((text, g) => {
136
+ g.attr("class", "state-note");
137
+ const note = g.append("rect").attr("x", 0).attr("y", getConfig2().state.padding);
138
+ const rectElem = g.append("g");
139
+ const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
140
+ note.attr("height", textHeight + 2 * getConfig2().state.noteMargin);
141
+ note.attr("width", textWidth + getConfig2().state.noteMargin * 2);
142
+ return note;
143
+ }, "drawNote");
144
+ var drawState = /* @__PURE__ */ __name(function(elem, stateDef) {
145
+ const id = stateDef.id;
146
+ const stateInfo = {
147
+ id,
148
+ label: stateDef.id,
149
+ width: 0,
150
+ height: 0
151
+ };
152
+ const g = elem.append("g").attr("id", id).attr("class", "stateGroup");
153
+ if (stateDef.type === "start") {
154
+ drawStartState(g);
155
+ }
156
+ if (stateDef.type === "end") {
157
+ drawEndState(g);
158
+ }
159
+ if (stateDef.type === "fork" || stateDef.type === "join") {
160
+ drawForkJoinState(g, stateDef);
161
+ }
162
+ if (stateDef.type === "note") {
163
+ drawNote(stateDef.note.text, g);
164
+ }
165
+ if (stateDef.type === "divider") {
166
+ drawDivider(g);
167
+ }
168
+ if (stateDef.type === "default" && stateDef.descriptions.length === 0) {
169
+ drawSimpleState(g, stateDef);
170
+ }
171
+ if (stateDef.type === "default" && stateDef.descriptions.length > 0) {
172
+ drawDescrState(g, stateDef);
173
+ }
174
+ const stateBox = g.node().getBBox();
175
+ stateInfo.width = stateBox.width + 2 * getConfig2().state.padding;
176
+ stateInfo.height = stateBox.height + 2 * getConfig2().state.padding;
177
+ return stateInfo;
178
+ }, "drawState");
179
+ var edgeCount = 0;
180
+ var drawEdge = /* @__PURE__ */ __name(function(elem, path, relation) {
181
+ const getRelationType = /* @__PURE__ */ __name(function(type) {
182
+ switch (type) {
183
+ case StateDB.relationType.AGGREGATION:
184
+ return "aggregation";
185
+ case StateDB.relationType.EXTENSION:
186
+ return "extension";
187
+ case StateDB.relationType.COMPOSITION:
188
+ return "composition";
189
+ case StateDB.relationType.DEPENDENCY:
190
+ return "dependency";
191
+ }
192
+ }, "getRelationType");
193
+ path.points = path.points.filter((p) => !Number.isNaN(p.y));
194
+ const lineData = path.points;
195
+ const lineFunction = line().x(function(d) {
196
+ return d.x;
197
+ }).y(function(d) {
198
+ return d.y;
199
+ }).curve(curveBasis);
200
+ const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition");
201
+ let url = "";
202
+ if (getConfig2().state.arrowMarkerAbsolute) {
203
+ url = getUrl(true);
204
+ }
205
+ svgPath.attr(
206
+ "marker-end",
207
+ "url(" + url + "#" + getRelationType(StateDB.relationType.DEPENDENCY) + "End)"
208
+ );
209
+ if (relation.title !== void 0) {
210
+ const label = elem.append("g").attr("class", "stateLabel");
211
+ const { x, y } = utils_default.calcLabelPosition(path.points);
212
+ const rows = common_default.getRows(relation.title);
213
+ let titleHeight = 0;
214
+ const titleRows = [];
215
+ let maxWidth = 0;
216
+ let minX = 0;
217
+ for (let i = 0; i <= rows.length; i++) {
218
+ const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight);
219
+ const boundsTmp = title.node().getBBox();
220
+ maxWidth = Math.max(maxWidth, boundsTmp.width);
221
+ minX = Math.min(minX, boundsTmp.x);
222
+ log.info(boundsTmp.x, x, y + titleHeight);
223
+ if (titleHeight === 0) {
224
+ const titleBox = title.node().getBBox();
225
+ titleHeight = titleBox.height;
226
+ log.info("Title height", titleHeight, y);
227
+ }
228
+ titleRows.push(title);
229
+ }
230
+ let boxHeight = titleHeight * rows.length;
231
+ if (rows.length > 1) {
232
+ const heightAdj = (rows.length - 1) * titleHeight * 0.5;
233
+ titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj));
234
+ boxHeight = titleHeight * rows.length;
235
+ }
236
+ const bounds = label.node().getBBox();
237
+ 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);
238
+ log.info(bounds);
239
+ }
240
+ edgeCount++;
241
+ }, "drawEdge");
242
+ var conf;
243
+ var transformationLog = {};
244
+ var setConf = /* @__PURE__ */ __name(function() {
245
+ }, "setConf");
246
+ var insertMarkers = /* @__PURE__ */ __name(function(elem) {
247
+ 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");
248
+ }, "insertMarkers");
249
+ var draw = /* @__PURE__ */ __name(function(text, id, _version, diagObj) {
250
+ conf = getConfig2().state;
251
+ const securityLevel = getConfig2().securityLevel;
252
+ let sandboxElement;
253
+ if (securityLevel === "sandbox") {
254
+ sandboxElement = select("#i" + id);
255
+ }
256
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
257
+ const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
258
+ log.debug("Rendering diagram " + text);
259
+ const diagram2 = root.select(`[id='${id}']`);
260
+ insertMarkers(diagram2);
261
+ const rootDoc = diagObj.db.getRootDoc();
262
+ const rootG = diagram2.append("g").attr("id", id + "-root");
263
+ renderDoc(rootDoc, rootG, void 0, false, root, doc, diagObj);
264
+ const padding = conf.padding;
265
+ const bounds = diagram2.node().getBBox();
266
+ const width = bounds.width + padding * 2;
267
+ const height = bounds.height + padding * 2;
268
+ const svgWidth = width * 1.75;
269
+ configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth);
270
+ diagram2.attr(
271
+ "viewBox",
272
+ `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height
273
+ );
274
+ }, "draw");
275
+ var getLabelWidth = /* @__PURE__ */ __name((text) => {
276
+ return text ? text.length * conf.fontSizeFactor : 1;
277
+ }, "getLabelWidth");
278
+ var renderDoc = /* @__PURE__ */ __name((doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => {
279
+ const graph = new Graph({
280
+ compound: true,
281
+ multigraph: true
282
+ });
283
+ let i;
284
+ let edgeFreeDoc = true;
285
+ for (i = 0; i < doc.length; i++) {
286
+ if (doc[i].stmt === "relation") {
287
+ edgeFreeDoc = false;
288
+ break;
289
+ }
290
+ }
291
+ if (parentId) {
292
+ graph.setGraph({
293
+ rankdir: "LR",
294
+ multigraph: true,
295
+ compound: true,
296
+ // acyclicer: 'greedy',
297
+ ranker: "tight-tree",
298
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
299
+ nodeSep: edgeFreeDoc ? 1 : 50,
300
+ isMultiGraph: true
301
+ // ranksep: 5,
302
+ // nodesep: 1
303
+ });
304
+ } else {
305
+ graph.setGraph({
306
+ rankdir: "TB",
307
+ multigraph: true,
308
+ compound: true,
309
+ // isCompound: true,
310
+ // acyclicer: 'greedy',
311
+ // ranker: 'longest-path'
312
+ ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
313
+ nodeSep: edgeFreeDoc ? 1 : 50,
314
+ ranker: "tight-tree",
315
+ // ranker: 'network-simplex'
316
+ isMultiGraph: true
317
+ });
318
+ }
319
+ graph.setDefaultEdgeLabel(function() {
320
+ return {};
321
+ });
322
+ const states = diagObj.db.getStates();
323
+ const relations = diagObj.db.getRelations();
324
+ const keys = Object.keys(states);
325
+ for (const key of keys) {
326
+ const stateDef = states[key];
327
+ if (parentId) {
328
+ stateDef.parentId = parentId;
329
+ }
330
+ let node;
331
+ if (stateDef.doc) {
332
+ let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup");
333
+ node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj);
334
+ {
335
+ sub = addTitleAndBox(sub, stateDef, altBkg);
336
+ let boxBounds = sub.node().getBBox();
337
+ node.width = boxBounds.width;
338
+ node.height = boxBounds.height + conf.padding / 2;
339
+ transformationLog[stateDef.id] = { y: conf.compositTitleSize };
340
+ }
341
+ } else {
342
+ node = drawState(diagram2, stateDef, graph);
343
+ }
344
+ if (stateDef.note) {
345
+ const noteDef = {
346
+ descriptions: [],
347
+ id: stateDef.id + "-note",
348
+ note: stateDef.note,
349
+ type: "note"
350
+ };
351
+ const note = drawState(diagram2, noteDef, graph);
352
+ if (stateDef.note.position === "left of") {
353
+ graph.setNode(node.id + "-note", note);
354
+ graph.setNode(node.id, node);
355
+ } else {
356
+ graph.setNode(node.id, node);
357
+ graph.setNode(node.id + "-note", note);
358
+ }
359
+ graph.setParent(node.id, node.id + "-group");
360
+ graph.setParent(node.id + "-note", node.id + "-group");
361
+ } else {
362
+ graph.setNode(node.id, node);
363
+ }
364
+ }
365
+ log.debug("Count=", graph.nodeCount(), graph);
366
+ let cnt = 0;
367
+ relations.forEach(function(relation) {
368
+ cnt++;
369
+ log.debug("Setting edge", relation);
370
+ graph.setEdge(
371
+ relation.id1,
372
+ relation.id2,
373
+ {
374
+ relation,
375
+ width: getLabelWidth(relation.title),
376
+ height: conf.labelHeight * common_default.getRows(relation.title).length,
377
+ labelpos: "c"
378
+ },
379
+ "id" + cnt
380
+ );
381
+ });
382
+ layout(graph);
383
+ log.debug("Graph after layout", graph.nodes());
384
+ const svgElem = diagram2.node();
385
+ graph.nodes().forEach(function(v) {
386
+ if (v !== void 0 && graph.node(v) !== void 0) {
387
+ log.warn("Node " + v + ": " + JSON.stringify(graph.node(v)));
388
+ root.select("#" + svgElem.id + " #" + v).attr(
389
+ "transform",
390
+ "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) + " )"
391
+ );
392
+ root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2);
393
+ const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider");
394
+ dividers.forEach((divider) => {
395
+ const parent = divider.parentElement;
396
+ let pWidth = 0;
397
+ let pShift = 0;
398
+ if (parent) {
399
+ if (parent.parentElement) {
400
+ pWidth = parent.parentElement.getBBox().width;
401
+ }
402
+ pShift = parseInt(parent.getAttribute("data-x-shift"), 10);
403
+ if (Number.isNaN(pShift)) {
404
+ pShift = 0;
405
+ }
406
+ }
407
+ divider.setAttribute("x1", 0 - pShift + 8);
408
+ divider.setAttribute("x2", pWidth - pShift - 8);
409
+ });
410
+ } else {
411
+ log.debug("No Node " + v + ": " + JSON.stringify(graph.node(v)));
412
+ }
413
+ });
414
+ let stateBox = svgElem.getBBox();
415
+ graph.edges().forEach(function(e) {
416
+ if (e !== void 0 && graph.edge(e) !== void 0) {
417
+ log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
418
+ drawEdge(diagram2, graph.edge(e), graph.edge(e).relation);
419
+ }
420
+ });
421
+ stateBox = svgElem.getBBox();
422
+ const stateInfo = {
423
+ id: parentId ? parentId : "root",
424
+ label: parentId ? parentId : "root",
425
+ width: 0,
426
+ height: 0
427
+ };
428
+ stateInfo.width = stateBox.width + 2 * conf.padding;
429
+ stateInfo.height = stateBox.height + 2 * conf.padding;
430
+ log.debug("Doc rendered", stateInfo, graph);
431
+ return stateInfo;
432
+ }, "renderDoc");
433
+ var stateRenderer_default = {
434
+ setConf,
435
+ draw
436
+ };
437
+ var diagram = {
438
+ parser: stateDiagram_default,
439
+ get db() {
440
+ return new StateDB(1);
441
+ },
442
+ renderer: stateRenderer_default,
443
+ styles: styles_default,
444
+ init: /* @__PURE__ */ __name((cnf) => {
445
+ if (!cnf.state) {
446
+ cnf.state = {};
447
+ }
448
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
449
+ }, "init")
450
+ };
451
+ export {
452
+ diagram
453
+ };
@@ -0,0 +1,23 @@
1
+ import { s as styles_default, b as stateRenderer_v3_unified_default, a as stateDiagram_default, S as StateDB } from "./chunk-EX3LRPZG-Cg_Vtzwz.js";
2
+ import { _ as __name } from "./mermaid.core-BRk3IzY2.js";
3
+ import "./chunk-XXDRQBXY-C4FVmO5r.js";
4
+ import "./chunk-VR4S4FIN-Fgvcluvk.js";
5
+ import "./chunk-32BRIVSS-Dy1BUZGx.js";
6
+ import "./index-DZ7I8r_C.js";
7
+ var diagram = {
8
+ parser: stateDiagram_default,
9
+ get db() {
10
+ return new StateDB(2);
11
+ },
12
+ renderer: stateRenderer_v3_unified_default,
13
+ styles: styles_default,
14
+ init: /* @__PURE__ */ __name((cnf) => {
15
+ if (!cnf.state) {
16
+ cnf.state = {};
17
+ }
18
+ cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
19
+ }, "init")
20
+ };
21
+ export {
22
+ diagram
23
+ };