1 | import { p as R, d as N, s as $ } from "./styles-11e81fdd.js";
|
2 | import { l as c, c as r, j as k, A as B, t as G, o as E, q as A, n as C, f as _ } from "./mermaid-9f2aa176.js";
|
3 | import { G as q } from "./graph-0ee63739.js";
|
4 | import { r as z } from "./index-bb6d8841.js";
|
5 | import "./layout-fd473db2.js";
|
6 | import "./clone-afc2f047.js";
|
7 | import "./edges-16357fde.js";
|
8 | import "./createText-03b82060.js";
|
9 | import "./line-24d93f1b.js";
|
10 | import "./array-2ff2c7a6.js";
|
11 | import "./path-428ebac9.js";
|
12 | const S = (o) => _.sanitizeText(o, r());
|
13 | let v = {
|
14 | dividerMargin: 10,
|
15 | padding: 5,
|
16 | textHeight: 10,
|
17 | curve: void 0
|
18 | };
|
19 | const P = function(o, e, p, n) {
|
20 | const t = Object.keys(o);
|
21 | c.info("keys:", t), c.info(o), t.forEach(function(s) {
|
22 | var y, d;
|
23 | const l = o[s], i = {
|
24 | shape: "rect",
|
25 | id: l.id,
|
26 | domId: l.domId,
|
27 | labelText: S(l.id),
|
28 | labelStyle: "",
|
29 | style: "fill: none; stroke: black",
|
30 |
|
31 | padding: ((y = r().flowchart) == null ? void 0 : y.padding) ?? ((d = r().class) == null ? void 0 : d.padding)
|
32 | };
|
33 | e.setNode(l.id, i), I(l.classes, e, p, n, l.id), c.info("setNode", i);
|
34 | });
|
35 | }, I = function(o, e, p, n, t) {
|
36 | const s = Object.keys(o);
|
37 | c.info("keys:", s), c.info(o), s.filter((l) => o[l].parent == t).forEach(function(l) {
|
38 | var u, m;
|
39 | const a = o[l], i = a.cssClasses.join(" "), y = E(a.styles), d = a.label ?? a.id, f = 0, h = "class_box", b = {
|
40 | labelStyle: y.labelStyle,
|
41 | shape: h,
|
42 | labelText: S(d),
|
43 | classData: a,
|
44 | rx: f,
|
45 | ry: f,
|
46 | class: i,
|
47 | style: y.style,
|
48 | id: a.id,
|
49 | domId: a.domId,
|
50 | tooltip: n.db.getTooltip(a.id, t) || "",
|
51 | haveCallback: a.haveCallback,
|
52 | link: a.link,
|
53 | width: a.type === "group" ? 500 : void 0,
|
54 | type: a.type,
|
55 |
|
56 | padding: ((u = r().flowchart) == null ? void 0 : u.padding) ?? ((m = r().class) == null ? void 0 : m.padding)
|
57 | };
|
58 | e.setNode(a.id, b), t && e.setParent(a.id, t), c.info("setNode", b);
|
59 | });
|
60 | }, F = function(o, e, p, n) {
|
61 | c.info(o), o.forEach(function(t, s) {
|
62 | var m, g;
|
63 | const l = t, a = "", i = { labelStyle: "", style: "" }, y = l.text, d = 0, f = "note", h = {
|
64 | labelStyle: i.labelStyle,
|
65 | shape: f,
|
66 | labelText: S(y),
|
67 | noteData: l,
|
68 | rx: d,
|
69 | ry: d,
|
70 | class: a,
|
71 | style: i.style,
|
72 | id: l.id,
|
73 | domId: l.id,
|
74 | tooltip: "",
|
75 | type: "note",
|
76 |
|
77 | padding: ((m = r().flowchart) == null ? void 0 : m.padding) ?? ((g = r().class) == null ? void 0 : g.padding)
|
78 | };
|
79 | if (e.setNode(l.id, h), c.info("setNode", h), !l.class || !(l.class in n))
|
80 | return;
|
81 | const b = p + s, u = {
|
82 | id: `edgeNote${b}`,
|
83 |
|
84 | classes: "relation",
|
85 | pattern: "dotted",
|
86 |
|
87 | arrowhead: "none",
|
88 |
|
89 | startLabelRight: "",
|
90 | endLabelLeft: "",
|
91 |
|
92 | arrowTypeStart: "none",
|
93 | arrowTypeEnd: "none",
|
94 | style: "fill:none",
|
95 | labelStyle: "",
|
96 | curve: A(v.curve, C)
|
97 | };
|
98 | e.setEdge(l.id, l.class, u, b);
|
99 | });
|
100 | }, H = function(o, e) {
|
101 | const p = r().flowchart;
|
102 | let n = 0;
|
103 | o.forEach(function(t) {
|
104 | var l;
|
105 | n++;
|
106 | const s = {
|
107 |
|
108 | classes: "relation",
|
109 | pattern: t.relation.lineType == 1 ? "dashed" : "solid",
|
110 | id: `id_${t.id1}_${t.id2}_${n}`,
|
111 |
|
112 | arrowhead: t.type === "arrow_open" ? "none" : "normal",
|
113 |
|
114 | startLabelRight: t.relationTitle1 === "none" ? "" : t.relationTitle1,
|
115 | endLabelLeft: t.relationTitle2 === "none" ? "" : t.relationTitle2,
|
116 |
|
117 | arrowTypeStart: D(t.relation.type1),
|
118 | arrowTypeEnd: D(t.relation.type2),
|
119 | style: "fill:none",
|
120 | labelStyle: "",
|
121 | curve: A(p == null ? void 0 : p.curve, C)
|
122 | };
|
123 | if (c.info(s, t), t.style !== void 0) {
|
124 | const a = E(t.style);
|
125 | s.style = a.style, s.labelStyle = a.labelStyle;
|
126 | }
|
127 | t.text = t.title, t.text === void 0 ? t.style !== void 0 && (s.arrowheadStyle = "fill: #333") : (s.arrowheadStyle = "fill: #333", s.labelpos = "c", ((l = r().flowchart) == null ? void 0 : l.htmlLabels) ?? r().htmlLabels ? (s.labelType = "html", s.label = '<span class="edgeLabel">' + t.text + "</span>") : (s.labelType = "text", s.label = t.text.replace(_.lineBreakRegex, `
|
128 | `), t.style === void 0 && (s.style = s.style || "stroke: #333; stroke-width: 1.5px;fill:none"), s.labelStyle = s.labelStyle.replace("color:", "fill:"))), e.setEdge(t.id1, t.id2, s, n);
|
129 | });
|
130 | }, V = function(o) {
|
131 | v = {
|
132 | ...v,
|
133 | ...o
|
134 | };
|
135 | }, W = async function(o, e, p, n) {
|
136 | c.info("Drawing class - ", e);
|
137 | const t = r().flowchart ?? r().class, s = r().securityLevel;
|
138 | c.info("config:", t);
|
139 | const l = (t == null ? void 0 : t.nodeSpacing) ?? 50, a = (t == null ? void 0 : t.rankSpacing) ?? 50, i = new q({
|
140 | multigraph: !0,
|
141 | compound: !0
|
142 | }).setGraph({
|
143 | rankdir: n.db.getDirection(),
|
144 | nodesep: l,
|
145 | ranksep: a,
|
146 | marginx: 8,
|
147 | marginy: 8
|
148 | }).setDefaultEdgeLabel(function() {
|
149 | return {};
|
150 | }), y = n.db.getNamespaces(), d = n.db.getClasses(), f = n.db.getRelations(), h = n.db.getNotes();
|
151 | c.info(f), P(y, i, e, n), I(d, i, e, n), H(f, i), F(h, i, f.length + 1, d);
|
152 | let b;
|
153 | s === "sandbox" && (b = k("#i" + e));
|
154 | const u = s === "sandbox" ? k(b.nodes()[0].contentDocument.body) : k("body"), m = u.select(`[id="${e}"]`), g = u.select("#" + e + " g");
|
155 | if (await z(
|
156 | g,
|
157 | i,
|
158 | ["aggregation", "extension", "composition", "dependency", "lollipop"],
|
159 | "classDiagram",
|
160 | e
|
161 | ), B.insertTitle(m, "classTitleText", (t == null ? void 0 : t.titleTopMargin) ?? 5, n.db.getDiagramTitle()), G(i, m, t == null ? void 0 : t.diagramPadding, t == null ? void 0 : t.useMaxWidth), !(t != null && t.htmlLabels)) {
|
162 | const T = s === "sandbox" ? b.nodes()[0].contentDocument : document, M = T.querySelectorAll('[id="' + e + '"] .edgeLabel .label');
|
163 | for (const w of M) {
|
164 | const L = w.getBBox(), x = T.createElementNS("http://www.w3.org/2000/svg", "rect");
|
165 | x.setAttribute("rx", 0), x.setAttribute("ry", 0), x.setAttribute("width", L.width), x.setAttribute("height", L.height), w.insertBefore(x, w.firstChild);
|
166 | }
|
167 | }
|
168 | };
|
169 | function D(o) {
|
170 | let e;
|
171 | switch (o) {
|
172 | case 0:
|
173 | e = "aggregation";
|
174 | break;
|
175 | case 1:
|
176 | e = "extension";
|
177 | break;
|
178 | case 2:
|
179 | e = "composition";
|
180 | break;
|
181 | case 3:
|
182 | e = "dependency";
|
183 | break;
|
184 | case 4:
|
185 | e = "lollipop";
|
186 | break;
|
187 | default:
|
188 | e = "none";
|
189 | }
|
190 | return e;
|
191 | }
|
192 | const J = {
|
193 | setConf: V,
|
194 | draw: W
|
195 | }, ot = {
|
196 | parser: R,
|
197 | db: N,
|
198 | renderer: J,
|
199 | styles: $,
|
200 | init: (o) => {
|
201 | o.class || (o.class = {}), o.class.arrowMarkerAbsolute = o.arrowMarkerAbsolute, N.clear();
|
202 | }
|
203 | };
|
204 | export {
|
205 | ot as diagram
|
206 | };
|