@miragon/context-maps-renderer 0.2.0 → 0.4.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 (80) hide show
  1. package/README.md +100 -10
  2. package/dist/CmBaseViewer.d.ts +67 -8
  3. package/dist/CmBaseViewer.d.ts.map +1 -1
  4. package/dist/Modeler.d.ts +3 -2
  5. package/dist/Modeler.d.ts.map +1 -1
  6. package/dist/NavigatedViewer.d.ts +1 -1
  7. package/dist/NavigatedViewer.d.ts.map +1 -1
  8. package/dist/chrome/ShortcutsDialog.d.ts +13 -0
  9. package/dist/chrome/ShortcutsDialog.d.ts.map +1 -0
  10. package/dist/chrome/TitleDialog.d.ts +15 -0
  11. package/dist/chrome/TitleDialog.d.ts.map +1 -0
  12. package/dist/chrome/dialog.d.ts +39 -0
  13. package/dist/chrome/dialog.d.ts.map +1 -0
  14. package/dist/chrome/index.d.ts +10 -0
  15. package/dist/chrome/index.d.ts.map +1 -0
  16. package/dist/chrome/menu.d.ts +50 -0
  17. package/dist/chrome/menu.d.ts.map +1 -0
  18. package/dist/chrome/shortcuts.d.ts +41 -0
  19. package/dist/chrome/shortcuts.d.ts.map +1 -0
  20. package/dist/collaborative/CollaborativeContextMaps.d.ts +32 -0
  21. package/dist/collaborative/CollaborativeContextMaps.d.ts.map +1 -0
  22. package/dist/collaborative/index.d.ts +2 -0
  23. package/dist/collaborative/index.d.ts.map +1 -0
  24. package/dist/connect-handles/CmConnectHandles.d.ts +3 -1
  25. package/dist/connect-handles/CmConnectHandles.d.ts.map +1 -1
  26. package/dist/connect-handles/index.d.ts.map +1 -1
  27. package/dist/context-maps.css +1 -1
  28. package/dist/context-pad/CmContextPadProvider.d.ts +5 -1
  29. package/dist/context-pad/CmContextPadProvider.d.ts.map +1 -1
  30. package/dist/context-pad/index.d.ts.map +1 -1
  31. package/dist/draw/lucide.d.ts +29 -0
  32. package/dist/draw/lucide.d.ts.map +1 -0
  33. package/dist/hover-tooltip/CmHoverTooltip.d.ts +16 -0
  34. package/dist/hover-tooltip/CmHoverTooltip.d.ts.map +1 -0
  35. package/dist/hover-tooltip/index.d.ts +5 -0
  36. package/dist/hover-tooltip/index.d.ts.map +1 -0
  37. package/dist/index.d.ts +11 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1431 -654
  40. package/dist/index.js.map +1 -1
  41. package/dist/io/CmExporter.d.ts +1 -3
  42. package/dist/io/CmExporter.d.ts.map +1 -1
  43. package/dist/io/CmImporter.d.ts +14 -1
  44. package/dist/io/CmImporter.d.ts.map +1 -1
  45. package/dist/io/saveSvg.d.ts.map +1 -1
  46. package/dist/io/types.d.ts +9 -1
  47. package/dist/io/types.d.ts.map +1 -1
  48. package/dist/keyboard/CmKeyboard.d.ts +11 -1
  49. package/dist/keyboard/CmKeyboard.d.ts.map +1 -1
  50. package/dist/keyboard/index.d.ts +2 -1
  51. package/dist/keyboard/index.d.ts.map +1 -1
  52. package/dist/label-editing/CmLabelEditing.d.ts +30 -1
  53. package/dist/label-editing/CmLabelEditing.d.ts.map +1 -1
  54. package/dist/label-editing/index.d.ts.map +1 -1
  55. package/dist/legend/CmLegend.d.ts.map +1 -1
  56. package/dist/legend/index.d.ts +6 -0
  57. package/dist/legend/index.d.ts.map +1 -1
  58. package/dist/legend/legendContent.d.ts +38 -0
  59. package/dist/legend/legendContent.d.ts.map +1 -0
  60. package/dist/model/CmElementFactory.d.ts.map +1 -1
  61. package/dist/model/di-types.d.ts +4 -0
  62. package/dist/model/di-types.d.ts.map +1 -1
  63. package/dist/modeling/CmModeling.d.ts +2 -0
  64. package/dist/modeling/CmModeling.d.ts.map +1 -1
  65. package/dist/modeling/cmd/UpdateTitleHandler.d.ts +17 -0
  66. package/dist/modeling/cmd/UpdateTitleHandler.d.ts.map +1 -0
  67. package/dist/palette/CmPaletteProvider.d.ts +30 -2
  68. package/dist/palette/CmPaletteProvider.d.ts.map +1 -1
  69. package/dist/palette/index.d.ts +2 -1
  70. package/dist/palette/index.d.ts.map +1 -1
  71. package/dist/read-only/CmReadOnly.d.ts +20 -0
  72. package/dist/read-only/CmReadOnly.d.ts.map +1 -0
  73. package/dist/read-only/index.d.ts +5 -0
  74. package/dist/read-only/index.d.ts.map +1 -0
  75. package/dist/theme/palette.d.ts +26 -22
  76. package/dist/theme/palette.d.ts.map +1 -1
  77. package/dist/validation/CmValidationMarkers.d.ts.map +1 -1
  78. package/package.json +15 -7
  79. package/dist/draw/icons.d.ts +0 -16
  80. package/dist/draw/icons.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,71 +1,81 @@
1
1
  import e from "diagram-js/lib/Diagram";
2
- import t from "diagram-js/lib/layout/CroppingConnectionDocking";
3
- import { ALL_PATTERN_SPECS as n, ALL_SUBDOMAIN_SPECS as r, DOCUMENT_VERSION as i, DOWNSTREAM_ROLES as a, DOWNSTREAM_ROLE_SPECS as o, MARK_COLORS as s, MARK_TEXT_COLOR as c, RELATIONSHIP_PATTERN_SPECS as l, SUBDOMAIN_TYPE_SPECS as u, UPSTREAM_ROLES as d, UPSTREAM_ROLE_SPECS as f, isSymmetricPattern as p, newId as m, validateDocument as h } from "@miragon/context-maps-schema-model";
4
- import g from "diagram-js/lib/core/ElementFactory";
5
- import { asTRBL as ee, getMid as _ } from "diagram-js/lib/layout/LayoutUtil";
6
- import te from "diagram-js/lib/draw/BaseRenderer";
7
- import { append as v, attr as y, clear as b, create as x } from "tiny-svg";
8
- import S from "diagram-js/lib/features/selection";
9
- import C from "diagram-js/lib/navigation/zoomscroll";
10
- import ne from "diagram-js/lib/navigation/movecanvas";
11
- import re from "diagram-js/lib/features/connection-preview";
12
- import ie from "diagram-js/lib/features/modeling";
13
- import ae from "diagram-js/lib/features/move";
14
- import oe from "diagram-js/lib/features/outline";
15
- import se from "diagram-js/lib/features/rules";
16
- import ce from "diagram-js/lib/features/rules/RuleProvider";
17
- import le from "diagram-js/lib/command/CommandInterceptor";
18
- import { hasPrimaryModifier as ue } from "diagram-js/lib/util/Mouse";
19
- import de from "diagram-js/lib/features/palette";
20
- import fe from "diagram-js/lib/features/create";
21
- import w from "diagram-js/lib/features/connect";
22
- import pe from "diagram-js/lib/features/lasso-tool";
23
- import me from "diagram-js/lib/features/context-pad";
24
- import he from "diagram-js/lib/features/popup-menu";
25
- import ge from "diagram-js/lib/features/auto-place";
26
- import _e from "diagram-js-direct-editing";
27
- import { DEFAULT_DISTANCE as ve, findFreePosition as ye, generateGetNextPosition as be } from "diagram-js/lib/features/auto-place/AutoPlaceUtil";
28
- import xe from "diagram-js/lib/features/overlays";
2
+ import { ALL_PATTERN_SPECS as t, ALL_SUBDOMAIN_SPECS as n, CONTEXT_KEYS as r, DIAGRAM_ROOT_ID as i, DOCUMENT_KEYS as a, DOCUMENT_VERSION as o, DOWNSTREAM_ROLES as s, DOWNSTREAM_ROLE_SPECS as c, MARK_COLORS as l, MARK_TEXT_COLOR as u, RELATIONSHIP_KEYS as d, RELATIONSHIP_PATTERN_SPECS as f, SUBDOMAIN_TYPE_SPECS as p, UPSTREAM_ROLES as m, UPSTREAM_ROLE_SPECS as h, foreignFields as g, isSymmetricPattern as ee, newId as te, parseDocumentText as ne, reservedIdProblem as re, serializeDocumentText as ie, validateDocument as ae } from "@miragon/context-maps-schema-model";
3
+ import oe from "diagram-js/lib/layout/CroppingConnectionDocking";
4
+ import se from "diagram-js/lib/core/ElementFactory";
5
+ import { asTRBL as ce, getMid as _ } from "diagram-js/lib/layout/LayoutUtil";
6
+ import le from "diagram-js/lib/draw/BaseRenderer";
7
+ import { append as v, attr as y, clear as ue, create as b } from "tiny-svg";
8
+ import x from "diagram-js/lib/features/selection";
9
+ import de from "diagram-js/lib/navigation/zoomscroll";
10
+ import fe from "diagram-js/lib/navigation/movecanvas";
11
+ import pe from "diagram-js/lib/features/connection-preview";
12
+ import S from "diagram-js/lib/features/modeling";
13
+ import me from "diagram-js/lib/features/move";
14
+ import he from "diagram-js/lib/features/outline";
15
+ import ge from "diagram-js/lib/features/rules";
16
+ import _e from "diagram-js/lib/features/rules/RuleProvider";
17
+ import ve from "diagram-js/lib/command/CommandInterceptor";
18
+ import { hasPrimaryModifier as ye } from "diagram-js/lib/util/Mouse";
19
+ import be from "diagram-js/lib/features/palette";
20
+ import xe from "diagram-js/lib/features/create";
21
+ import C from "diagram-js/lib/features/connect";
22
+ import Se from "diagram-js/lib/features/lasso-tool";
23
+ import Ce from "diagram-js-direct-editing";
24
+ import we from "diagram-js/lib/features/context-pad";
25
+ import Te from "diagram-js/lib/features/popup-menu";
26
+ import Ee from "diagram-js/lib/features/auto-place";
27
+ import { DEFAULT_DISTANCE as De, findFreePosition as Oe, generateGetNextPosition as ke } from "diagram-js/lib/features/auto-place/AutoPlaceUtil";
28
+ import Ae from "diagram-js/lib/features/overlays";
29
+ import { MODELER_API_VERSION as je } from "@miragon/modeler-api";
30
+ import { getBBox as Me } from "diagram-js/lib/util/Elements";
29
31
  //#region src/model/di-types.ts
30
- function T(e) {
32
+ function Ne(e) {
31
33
  return typeof e == "object" && e ? e.cmKind : void 0;
32
34
  }
33
- function E(e) {
34
- return typeof T(e) == "string";
35
+ function w(e) {
36
+ return typeof Ne(e) == "string";
35
37
  }
36
- function D(e) {
37
- return T(e) === "context";
38
+ function T(e) {
39
+ return Ne(e) === "context";
38
40
  }
39
- function O(e) {
40
- return T(e) === "relationship";
41
+ function E(e) {
42
+ return Ne(e) === "relationship";
41
43
  }
42
44
  //#endregion
43
45
  //#region src/io/saveSvg.ts
44
- var Se = 40;
45
- function Ce(e, t) {
46
- let n = e.getContainer().querySelector("svg");
46
+ var Pe = 40, Fe = [
47
+ "tabindex",
48
+ "role",
49
+ "aria-label"
50
+ ];
51
+ function Ie(e, t) {
52
+ let n = e.getContainer().querySelector(":scope > svg");
47
53
  if (!n) throw Error("No SVG found in the canvas container.");
48
54
  let r = Infinity, i = Infinity, a = -Infinity, o = -Infinity;
49
55
  for (let e of t.getAll()) {
50
- if (!D(e)) continue;
56
+ if (!T(e)) continue;
51
57
  let t = e;
52
58
  r = Math.min(r, t.x), i = Math.min(i, t.y), a = Math.max(a, t.x + t.width), o = Math.max(o, t.y + t.height);
53
59
  }
54
60
  Number.isFinite(r) || (r = 0, i = 0, a = 100, o = 100);
55
- let s = r - Se, c = i - Se, l = a - r + 80, u = o - i + 80, d = n.cloneNode(!0);
61
+ let s = r - Pe, c = i - Pe, l = a - r + 80, u = o - i + 80, d = n.cloneNode(!0);
62
+ for (let e of Fe) d.removeAttribute(e);
56
63
  d.setAttribute("xmlns", "http://www.w3.org/2000/svg"), d.setAttribute("viewBox", `${s} ${c} ${l} ${u}`), d.setAttribute("width", String(Math.round(l))), d.setAttribute("height", String(Math.round(u)));
57
64
  let f = d.querySelector(".viewport");
58
65
  return f && f.removeAttribute("transform"), { svg: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + new XMLSerializer().serializeToString(d) };
59
66
  }
60
67
  //#endregion
61
68
  //#region src/io/types.ts
62
- var we = "cm-root";
63
- //#endregion
64
- //#region src/CmBaseViewer.ts
65
- function Te(e) {
69
+ var D = i, Le = {
70
+ top: 84,
71
+ right: 56,
72
+ bottom: 56,
73
+ left: 56
74
+ }, Re = .001;
75
+ function ze(e) {
66
76
  return typeof e == "number" ? `${e}px` : e;
67
77
  }
68
- var k = class {
78
+ var Be = class {
69
79
  _diagram;
70
80
  _container;
71
81
  _options;
@@ -74,14 +84,19 @@ var k = class {
74
84
  }
75
85
  _createContainer(e) {
76
86
  let t = e.container ?? document.createElement("div");
77
- return t.classList.add("cm-djs-container"), t.style.width = Te(e.width ?? "100%"), t.style.height = Te(e.height ?? (e.container ? "100%" : "600px")), t;
87
+ return t.classList.add("cm-djs-container"), t.style.width = ze(e.width ?? "100%"), t.style.height = ze(e.height ?? (e.container ? "100%" : "600px")), t;
78
88
  }
79
89
  _ensureDiagram() {
80
90
  if (!this._diagram) {
81
91
  let t = [...this._getModules(), ...this._options.additionalModules ?? []];
82
92
  this._diagram = new e({
83
93
  canvas: { container: this._container },
84
- modules: t
94
+ modules: t,
95
+ cmKeyboard: { undoRedoKeys: this._options.undoRedoKeys ?? !0 },
96
+ cmPalette: {
97
+ freeRectInsets: this.freeRectInsets,
98
+ freeRectCenter: this.freeRectCenter
99
+ }
85
100
  });
86
101
  }
87
102
  return this._diagram;
@@ -89,6 +104,14 @@ var k = class {
89
104
  get(e) {
90
105
  return this._ensureDiagram().get(e);
91
106
  }
107
+ freeRectInsets = () => {
108
+ let { freeArea: e, freeRectInsets: t } = this._options;
109
+ return (e ? e.insets?.() : t?.()) ?? Le;
110
+ };
111
+ freeRectCenter = () => this._options.freeArea?.center?.();
112
+ _optional(e) {
113
+ return this._ensureDiagram().get(e, !1);
114
+ }
92
115
  on(e, t, n = 1e3) {
93
116
  this.get("eventBus").on(e, n, t);
94
117
  }
@@ -97,55 +120,65 @@ var k = class {
97
120
  }
98
121
  importDocument(e) {
99
122
  let t = this._ensureDiagram(), n = t.get("eventBus"), r = t.get("cmImporter");
100
- r.clear();
101
- let i = r.import(e);
102
- return this._fit(), n.fire("import.done", { warnings: i }), { warnings: i };
123
+ r.assertImportable(e);
124
+ let i = this._optional("cmLabelEditing");
125
+ i?.suspend(), this._optional("cmContextPadProvider")?.cancelPrompt(), this._optional("popupMenu")?.close(), r.clear();
126
+ let a = r.import(e);
127
+ return this._optional("commandStack")?.clear(!1), (this._options.fitOnImport ?? !0) && this._fit(), n.fire("import.done", { warnings: a }), i?.resumeAfterImport(), { warnings: a };
128
+ }
129
+ importText(e) {
130
+ let t = ne(e);
131
+ if (!t.ok) throw Error(t.error);
132
+ return this.importDocument(t.document);
103
133
  }
104
134
  exportDocument() {
105
135
  return this.get("cmExporter").export();
106
136
  }
137
+ exportText() {
138
+ return ie(this.exportDocument());
139
+ }
107
140
  setMeta(e) {
108
- let t = this.get("canvas"), n;
109
- try {
110
- n = t.getRootElement();
111
- } catch {
112
- return;
113
- }
114
- if (!n || n.id !== "cm-root") return;
115
- let r = n.businessObject ?? { title: "Untitled context map" };
116
- n.businessObject = {
117
- ...r,
118
- ...e
141
+ if (e.title === void 0 || this._optional("cmReadOnly")?.isReadOnly()) return;
142
+ let t = this._documentRoot();
143
+ if (!t?.businessObject || t.businessObject.title === e.title) return;
144
+ let n = this._optional("cmModeling");
145
+ n ? n.setTitle(e.title) : t.businessObject = {
146
+ ...t.businessObject,
147
+ title: e.title
119
148
  };
120
149
  }
121
150
  getMeta() {
122
- try {
123
- return this.get("canvas").getRootElement().businessObject;
124
- } catch {
125
- return;
126
- }
151
+ return this._documentRoot()?.businessObject;
152
+ }
153
+ _documentRoot() {
154
+ return this.get("elementRegistry").get(D);
127
155
  }
128
156
  saveSVG() {
129
- return Ce(this.get("canvas"), this.get("elementRegistry"));
157
+ return Ie(this.get("canvas"), this.get("elementRegistry"));
130
158
  }
131
- _fit(e = 84, t = 56, n = t) {
132
- let r = this.get("canvas"), i = this.get("elementRegistry"), a = Infinity, o = Infinity, s = -Infinity, c = -Infinity;
133
- for (let e of i.getAll()) {
159
+ _fit() {
160
+ let e = this.get("canvas"), t = this.get("elementRegistry"), n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
161
+ for (let e of t.getAll()) {
134
162
  let t = e;
135
- typeof t.x == "number" && typeof t.y == "number" && typeof t.width == "number" && typeof t.height == "number" && (a = Math.min(a, t.x), o = Math.min(o, t.y), s = Math.max(s, t.x + t.width), c = Math.max(c, t.y + t.height));
163
+ typeof t.x == "number" && typeof t.y == "number" && typeof t.width == "number" && typeof t.height == "number" && (n = Math.min(n, t.x), r = Math.min(r, t.y), i = Math.max(i, t.x + t.width), a = Math.max(a, t.y + t.height));
136
164
  }
137
- if (!Number.isFinite(a)) return;
138
- let l = this._container.getBoundingClientRect(), u = l.width, d = l.height, f = Math.max(s - a, 1), p = Math.max(c - o, 1);
139
- if (!u || !d) {
140
- r.zoom("fit-viewport");
165
+ let { width: o, height: s } = e.getSize();
166
+ if (!(o > 0 && s > 0)) return;
167
+ if (!Number.isFinite(n)) {
168
+ e.viewbox({
169
+ x: 0,
170
+ y: 0,
171
+ width: o,
172
+ height: s
173
+ });
141
174
  return;
142
175
  }
143
- let m = Math.min((u - n - t) / f, (d - e - t) / p, 1.25), h = n + (u - n - t - m * f) / 2;
144
- r.viewbox({
145
- x: a - h / m,
146
- y: o - e / m,
147
- width: u / m,
148
- height: d / m
176
+ let c = this.freeRectInsets(), l = Math.max(o - c.left - c.right, 1), u = Math.max(s - c.top - c.bottom, 1), d = Math.max(i - n, 1), f = Math.max(a - r, 1), p = Math.max(Math.min(l / d, u / f, 1), Re);
177
+ e.viewbox({
178
+ x: n + d / 2 - (c.left + l / 2) / p,
179
+ y: r + f / 2 - (c.top + u / 2) / p,
180
+ width: o / p,
181
+ height: s / p
149
182
  });
150
183
  }
151
184
  attachTo(e) {
@@ -163,14 +196,21 @@ var k = class {
163
196
  get container() {
164
197
  return this._container;
165
198
  }
166
- }, Ee = class {
199
+ };
200
+ //#endregion
201
+ //#region src/model/CmElementFactory.ts
202
+ function Ve(e, t) {
203
+ let n = g(e, t);
204
+ return Object.keys(n).length > 0 ? { cmForeign: n } : {};
205
+ }
206
+ var He = class {
167
207
  elementFactory;
168
208
  static $inject = ["elementFactory"];
169
209
  constructor(e) {
170
210
  this.elementFactory = e;
171
211
  }
172
212
  createContext(e) {
173
- let t = (e.subdomainType ? u[e.subdomainType] : void 0)?.minSize ?? {
213
+ let t = (e.subdomainType ? p[e.subdomainType] : void 0)?.minSize ?? {
174
214
  width: 120,
175
215
  height: 72
176
216
  };
@@ -186,7 +226,8 @@ var k = class {
186
226
  ...e.team ? { team: e.team } : {},
187
227
  ...e.description ? { description: e.description } : {},
188
228
  ...e.fill ? { fill: e.fill } : {},
189
- ...e.stroke ? { stroke: e.stroke } : {}
229
+ ...e.stroke ? { stroke: e.stroke } : {},
230
+ ...Ve(e, r)
190
231
  });
191
232
  }
192
233
  createRelationship(e, t, n, r) {
@@ -201,11 +242,12 @@ var k = class {
201
242
  ...e.downstreamRoles?.length ? { downstreamRoles: [...e.downstreamRoles] } : {},
202
243
  ...e.label ? { cmLabel: e.label } : {},
203
244
  ...e.description ? { description: e.description } : {},
204
- ...e.implementationTechnology ? { implementationTechnology: e.implementationTechnology } : {}
245
+ ...e.implementationTechnology ? { implementationTechnology: e.implementationTechnology } : {},
246
+ ...Ve(e, d)
205
247
  });
206
248
  }
207
249
  createNewContext(e, t) {
208
- let n = (e ? u[e] : void 0)?.defaultSize ?? u.generic.defaultSize;
250
+ let n = (e ? p[e] : void 0)?.defaultSize ?? p.generic.defaultSize;
209
251
  return this.elementFactory.createShape({
210
252
  width: n.width,
211
253
  height: n.height,
@@ -214,14 +256,14 @@ var k = class {
214
256
  cmLabel: t ?? "New Context"
215
257
  });
216
258
  }
217
- }, De = class extends g {
259
+ }, Ue = class extends se {
218
260
  create(e, t) {
219
261
  return !t?.id && (e === "shape" || e === "connection") && (t = {
220
262
  ...t,
221
- id: m(e === "shape" ? "ctx" : "rel")
263
+ id: te(e === "shape" ? "ctx" : "rel")
222
264
  }), super.create(e, t);
223
265
  }
224
- }, Oe = class {
266
+ }, We = class {
225
267
  docking;
226
268
  static $inject = ["connectionDocking"];
227
269
  constructor(e) {
@@ -231,11 +273,11 @@ var k = class {
231
273
  let n = t.source ?? e.source, r = t.target ?? e.target, i = [n ? _(n) : t.connectionStart || void 0, r ? _(r) : t.connectionEnd || void 0].filter(Boolean);
232
274
  return e.waypoints = i, n && r && i.length === 2 ? this.docking.getCroppedWaypoints(e, n, r) : i;
233
275
  }
234
- }, ke = {
235
- elementFactory: ["type", De],
236
- cmElementFactory: ["type", Ee],
237
- connectionDocking: ["type", t]
238
- }, A = {
276
+ }, Ge = {
277
+ elementFactory: ["type", Ue],
278
+ cmElementFactory: ["type", He],
279
+ connectionDocking: ["type", oe]
280
+ }, O = {
239
281
  blau: "#335DE5",
240
282
  blauLink: "#2B50D4",
241
283
  blauHell: "#6B8AFF",
@@ -243,40 +285,38 @@ var k = class {
243
285
  grau: "#F9F7F7",
244
286
  schwarz: "#1D1D1D",
245
287
  weiss: "#FFFFFF",
246
- success: "#0B7A55",
247
- warning: "#92610A",
248
- danger: "#C92A2A",
249
- info: "#2B50D4",
288
+ linie: "#E6E2E2",
289
+ success: "#00E676",
290
+ warning: "#FFB000",
291
+ danger: "#CD1839",
292
+ info: "#335DE5",
250
293
  gradientBrand: "linear-gradient(120deg, #335DE5 30%, #00E676)"
251
- }, Ae = {
252
- "--cd-blau": A.blau,
253
- "--cd-gruen": A.gruen,
254
- "--cd-grau": A.grau,
255
- "--cd-schwarz": A.schwarz,
256
- "--cd-weiss": A.weiss,
257
- "--cd-blau-link": A.blauLink,
258
- "--cd-blau-hell": A.blauHell,
259
- "--cd-success": A.success,
260
- "--cd-success-soft": "rgba(11, 122, 85, 0.12)",
261
- "--cd-warning": A.warning,
262
- "--cd-warning-soft": "rgba(146, 97, 10, 0.12)",
263
- "--cd-danger": A.danger,
264
- "--cd-danger-soft": "rgba(201, 42, 42, 0.12)",
265
- "--cd-info": A.info,
266
- "--cd-info-soft": "rgba(43, 80, 212, 0.12)",
267
- "--cd-gradient-brand": A.gradientBrand
268
- }, je = 1500;
269
- A.blau;
270
- var j = A.schwarz, Me = "#5B5B5B", M = {
294
+ }, Ke = {
295
+ "--cd-blau": O.blau,
296
+ "--cd-gruen": O.gruen,
297
+ "--cd-grau": O.grau,
298
+ "--cd-schwarz": O.schwarz,
299
+ "--cd-weiss": O.weiss,
300
+ "--cd-blau-link": O.blauLink,
301
+ "--cd-blau-hell": O.blauHell,
302
+ "--cd-linie": O.linie,
303
+ "--cd-success": O.success,
304
+ "--cd-warning": O.warning,
305
+ "--cd-danger": O.danger,
306
+ "--cd-info": O.info,
307
+ "--cd-gradient-brand": O.gradientBrand
308
+ }, qe = 1500;
309
+ O.blau;
310
+ var k = O.schwarz, Je = "#5B5B5B", A = {
271
311
  family: "'Geist Variable', 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",
272
312
  label: 13.5,
273
313
  small: 11
274
- }, N = A.weiss, Ne = "#F1F1EE", Pe = "#8A8577";
314
+ }, j = O.weiss, Ye = "#F1F1EE", Xe = "#8A8577";
275
315
  //#endregion
276
316
  //#region src/draw/endRoleChips.ts
277
- function P(e, t, n, r) {
317
+ function M(e, t, n, r) {
278
318
  if (r.length === 0) return null;
279
- let i = t.x - e.x, a = t.y - e.y, o = Math.hypot(i, a) || 1, s = i / o, c = a / o, l = M.small * .64, u = M.small + 6, d = r.map((e) => e.length * l + 12), f = d.reduce((e, t) => e + t, 0) + 3 * (r.length - 1), p = f + 8, m = u + 8, h = 11 + n.length * l / 2 + 8 + p / 2, g = {
319
+ let i = t.x - e.x, a = t.y - e.y, o = Math.hypot(i, a) || 1, s = i / o, c = a / o, l = A.small * .64, u = A.small + 6, d = r.map((e) => e.length * l + 12), f = d.reduce((e, t) => e + t, 0) + 3 * (r.length - 1), p = f + 8, m = u + 8, h = 11 + n.length * l / 2 + 8 + p / 2, g = {
280
320
  x: e.x + s * h,
281
321
  y: e.y + c * h
282
322
  };
@@ -296,17 +336,17 @@ function P(e, t, n, r) {
296
336
  }
297
337
  //#endregion
298
338
  //#region src/draw/ContextMapsRenderer.ts
299
- var Fe = class extends te {
339
+ var Ze = class extends le {
300
340
  static $inject = ["eventBus"];
301
341
  constructor(e) {
302
- super(e, je);
342
+ super(e, qe);
303
343
  }
304
344
  canRender(e) {
305
- return E(e);
345
+ return w(e);
306
346
  }
307
347
  drawShape(e, t) {
308
- if (b(e), D(t)) return this.drawContext(e, t);
309
- let n = y(x("rect"), {
348
+ if (ue(e), T(t)) return this.drawContext(e, t);
349
+ let n = y(b("rect"), {
310
350
  width: t.width,
311
351
  height: t.height,
312
352
  fill: "#eee"
@@ -314,11 +354,11 @@ var Fe = class extends te {
314
354
  return v(e, n), n;
315
355
  }
316
356
  drawConnection(e, t) {
317
- if (b(e), O(t)) return this.drawRelationship(e, t);
318
- let n = y(x("polyline"), {
357
+ if (ue(e), E(t)) return this.drawRelationship(e, t);
358
+ let n = y(b("polyline"), {
319
359
  points: (t.waypoints ?? []).map((e) => `${e.x},${e.y}`).join(" "),
320
360
  fill: "none",
321
- stroke: j
361
+ stroke: k
322
362
  });
323
363
  return v(e, n), n;
324
364
  }
@@ -331,7 +371,7 @@ var Fe = class extends te {
331
371
  return t.length === 0 ? "" : t.map((e, t) => `${t === 0 ? "M" : "L"}${e.x},${e.y}`).join("");
332
372
  }
333
373
  drawContext(e, t) {
334
- let n = t.subdomainType ? u[t.subdomainType] : void 0, r = Math.max(t.width, 1), i = Math.max(t.height, 1), a = y(x("rect"), {
374
+ let n = t.subdomainType ? p[t.subdomainType] : void 0, r = Math.max(t.width, 1), i = Math.max(t.height, 1), a = y(b("rect"), {
335
375
  x: 1,
336
376
  y: 1,
337
377
  width: r - 2,
@@ -344,12 +384,12 @@ var Fe = class extends te {
344
384
  "stroke-linejoin": "round"
345
385
  });
346
386
  if (v(e, a), this.appendLabel(e, t.cmLabel ?? "", r, i, !!t.team, { "font-weight": "650" }), t.subdomainType && n) {
347
- v(e, ze(t.subdomainType, 15, 15, 18, n.stroke));
348
- let r = y(x("text"), {
387
+ v(e, tt(t.subdomainType, 15, 15, 18, n.stroke));
388
+ let r = y(b("text"), {
349
389
  x: 28,
350
390
  y: 15,
351
- "font-family": M.family,
352
- "font-size": M.small,
391
+ "font-family": A.family,
392
+ "font-size": A.small,
353
393
  "font-weight": "700",
354
394
  fill: n.stroke,
355
395
  "text-anchor": "start",
@@ -359,15 +399,15 @@ var Fe = class extends te {
359
399
  r.textContent = n.label, v(e, r);
360
400
  }
361
401
  if (t.team) {
362
- let n = 19 + t.team.length * M.small * .55, a = r / 2 - n / 2, o = i - 12, s = Ve(a + 7, o, 14, Me);
402
+ let n = 19 + t.team.length * A.small * .55, a = r / 2 - n / 2, o = i - 12, s = rt(a + 7, o, 14, Je);
363
403
  y(s, { class: "cm-team" }), v(e, s);
364
- let c = y(x("text"), {
404
+ let c = y(b("text"), {
365
405
  class: "cm-team",
366
406
  x: a + 14 + 5,
367
407
  y: o,
368
- "font-family": M.family,
369
- "font-size": M.small,
370
- fill: Me,
408
+ "font-family": A.family,
409
+ "font-size": A.small,
410
+ fill: Je,
371
411
  "text-anchor": "start",
372
412
  "dominant-baseline": "central"
373
413
  });
@@ -376,7 +416,7 @@ var Fe = class extends te {
376
416
  return a;
377
417
  }
378
418
  drawRelationship(e, t) {
379
- let n = l[t.pattern] ?? l["upstream-downstream"], r = t.waypoints ?? [], i = n.dash, a = y(x("polyline"), {
419
+ let n = f[t.pattern] ?? f["upstream-downstream"], r = t.waypoints ?? [], i = n.dash, a = y(b("polyline"), {
380
420
  points: r.map((e) => `${e.x},${e.y}`).join(" "),
381
421
  fill: "none",
382
422
  stroke: n.stroke,
@@ -389,7 +429,7 @@ var Fe = class extends te {
389
429
  let i = r[0], a = r[r.length - 1], o = t.upstreamRoles ?? [], s = t.downstreamRoles ?? [];
390
430
  if (n.symmetric) {
391
431
  let t = (i.x + a.x) / 2, r = (i.y + a.y) / 2;
392
- this.chip(e, t, r, n.abbreviation, N, n.stroke, n.stroke);
432
+ this.chip(e, t, r, n.abbreviation, j, n.stroke, n.stroke);
393
433
  } else {
394
434
  let n = t.pattern === "customer-supplier";
395
435
  this.endMarkers(e, i, a, n ? "S" : "U", o), this.endMarkers(e, a, i, n ? "C" : "D", s);
@@ -398,43 +438,43 @@ var Fe = class extends te {
398
438
  return a;
399
439
  }
400
440
  endMarkers(e, t, n, r, i) {
401
- let a = n.x - t.x, o = n.y - t.y, c = Math.hypot(a, o) || 1, l = a / c, u = o / c, d = s[r] ?? j, f = y(x("text"), {
402
- x: t.x + l * 11,
441
+ let a = n.x - t.x, o = n.y - t.y, s = Math.hypot(a, o) || 1, c = a / s, u = o / s, d = l[r] ?? k, f = y(b("text"), {
442
+ x: t.x + c * 11,
403
443
  y: t.y + u * 11,
404
- "font-family": M.family,
405
- "font-size": M.small + 1,
444
+ "font-family": A.family,
445
+ "font-size": A.small + 1,
406
446
  "font-weight": "800",
407
447
  fill: d,
408
- stroke: N,
448
+ stroke: j,
409
449
  "stroke-width": 3,
410
450
  "paint-order": "stroke",
411
451
  "text-anchor": "middle",
412
452
  "dominant-baseline": "central"
413
453
  });
414
454
  f.textContent = r, v(e, f);
415
- let p = P(t, n, r, i);
455
+ let p = M(t, n, r, i);
416
456
  if (!p) return;
417
- let { box: m, center: h, chipWidths: g, chipHeight: ee, innerWidth: _, gap: te } = p, b = h.y, S = y(x("rect"), {
457
+ let { box: m, center: h, chipWidths: g, chipHeight: ee, innerWidth: te, gap: ne } = p, re = h.y, ie = y(b("rect"), {
418
458
  x: m.x,
419
459
  y: m.y,
420
460
  width: m.width,
421
461
  height: m.height,
422
462
  rx: 6,
423
463
  ry: 6,
424
- fill: N,
464
+ fill: j,
425
465
  "fill-opacity": .96,
426
466
  stroke: "#d9d5cc",
427
467
  "stroke-width": 1
428
468
  });
429
- v(e, S);
430
- let C = h.x - _ / 2;
469
+ v(e, ie);
470
+ let ae = h.x - te / 2;
431
471
  i.forEach((t, n) => {
432
- let r = g[n], i = s[t] ?? "#8A8577";
433
- this.miniChip(e, C + r / 2, b, r, ee, t, i), C += r + te;
472
+ let r = g[n], i = l[t] ?? "#8A8577";
473
+ this.miniChip(e, ae + r / 2, re, r, ee, t, i), ae += r + ne;
434
474
  });
435
475
  }
436
476
  miniChip(e, t, n, r, i, a, o) {
437
- let s = y(x("rect"), {
477
+ let s = y(b("rect"), {
438
478
  x: t - r / 2,
439
479
  y: n - i / 2,
440
480
  width: r,
@@ -442,25 +482,25 @@ var Fe = class extends te {
442
482
  rx: 3,
443
483
  ry: 3,
444
484
  fill: o,
445
- stroke: Ie(o),
485
+ stroke: Qe(o),
446
486
  "stroke-width": 1
447
487
  });
448
488
  v(e, s);
449
- let l = y(x("text"), {
489
+ let c = y(b("text"), {
450
490
  x: t,
451
491
  y: n,
452
- "font-family": M.family,
453
- "font-size": M.small,
492
+ "font-family": A.family,
493
+ "font-size": A.small,
454
494
  "font-weight": "700",
455
- fill: c,
495
+ fill: u,
456
496
  "text-anchor": "middle",
457
497
  "dominant-baseline": "central"
458
498
  });
459
- l.textContent = a, v(e, l);
499
+ c.textContent = a, v(e, c);
460
500
  }
461
501
  chip(e, t, n, r, i, a, o) {
462
502
  if (!r) return;
463
- let s = M.small * .64, c = r.length * s + 12, l = M.small + 8, u = y(x("rect"), {
503
+ let s = A.small * .64, c = r.length * s + 12, l = A.small + 8, u = y(b("rect"), {
464
504
  x: t - c / 2,
465
505
  y: n - l / 2,
466
506
  width: c,
@@ -470,14 +510,14 @@ var Fe = class extends te {
470
510
  fill: i,
471
511
  stroke: o,
472
512
  "stroke-width": 1,
473
- ...i === N ? { "fill-opacity": .95 } : {}
513
+ ...i === j ? { "fill-opacity": .95 } : {}
474
514
  });
475
515
  v(e, u);
476
- let d = y(x("text"), {
516
+ let d = y(b("text"), {
477
517
  x: t,
478
518
  y: n,
479
- "font-family": M.family,
480
- "font-size": M.small,
519
+ "font-family": A.family,
520
+ "font-size": A.small,
481
521
  "font-weight": "700",
482
522
  fill: a,
483
523
  "text-anchor": "middle",
@@ -486,17 +526,17 @@ var Fe = class extends te {
486
526
  d.textContent = r, v(e, d);
487
527
  }
488
528
  appendLabel(e, t, n, r, i, a) {
489
- let o = typeof a["font-size"] == "number" ? a["font-size"] : M.label, s = String(a["font-weight"] ?? "400"), c = n - 20, l = We(t, c, o, s), u = o * 1.2, d = r - 36 - (i ? 18 : 8), f = Math.max(1, Math.floor(d / u));
490
- l.length > f && (l = l.slice(0, f), l[f - 1] = Ue(l[f - 1], c, o, s));
529
+ let o = typeof a["font-size"] == "number" ? a["font-size"] : A.label, s = String(a["font-weight"] ?? "400"), c = n - 20, l = ot(t, c, o, s), u = o * 1.2, d = r - 36 - (i ? 18 : 8), f = Math.max(1, Math.floor(d / u));
530
+ l.length > f && (l = l.slice(0, f), l[f - 1] = at(l[f - 1], c, o, s));
491
531
  let p = 36 + u / 2;
492
532
  l.forEach((t, r) => {
493
- let i = y(x("text"), {
533
+ let i = y(b("text"), {
494
534
  class: "cm-name",
495
535
  x: n / 2,
496
536
  y: p + r * u,
497
- "font-family": M.family,
537
+ "font-family": A.family,
498
538
  "font-size": o,
499
- fill: j,
539
+ fill: k,
500
540
  "text-anchor": "middle",
501
541
  "dominant-baseline": "central",
502
542
  ...a
@@ -505,16 +545,16 @@ var Fe = class extends te {
505
545
  });
506
546
  }
507
547
  };
508
- function Ie(e, t = .7) {
548
+ function Qe(e, t = .7) {
509
549
  let n = /^#([0-9a-f]{6})$/i.exec(e);
510
550
  if (!n) return e;
511
551
  let r = parseInt(n[1], 16);
512
552
  return `rgb(${Math.round((r >> 16 & 255) * t)},${Math.round((r >> 8 & 255) * t)},${Math.round((r & 255) * t)})`;
513
553
  }
514
- var Le = "M12 2l2.9 6.26L22 9.27l-5 4.87L18.18 22 12 18.56 5.82 22 7 14.14l-5-4.87 7.1-1.01z", Re = "M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z";
515
- function ze(e, t, n, r, i) {
554
+ var $e = "M12 2l2.9 6.26L22 9.27l-5 4.87L18.18 22 12 18.56 5.82 22 7 14.14l-5-4.87 7.1-1.01z", et = "M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z";
555
+ function tt(e, t, n, r, i) {
516
556
  if (e === "generic") {
517
- let e = x("g"), a = y(x("circle"), {
557
+ let e = b("g"), a = y(b("circle"), {
518
558
  cx: t,
519
559
  cy: n,
520
560
  r: r / 2 - 1,
@@ -525,44 +565,44 @@ function ze(e, t, n, r, i) {
525
565
  });
526
566
  return v(e, a), e;
527
567
  }
528
- let a = r / 24, o = e === "supporting" ? " rotate(90 12 12)" : "", s = x("g");
568
+ let a = r / 24, o = e === "supporting" ? " rotate(90 12 12)" : "", s = b("g");
529
569
  y(s, { transform: `translate(${t - 12 * a} ${n - 12 * a}) scale(${a})${o}` });
530
- let c = y(x("path"), {
531
- d: e === "core" ? Le : Re,
570
+ let c = y(b("path"), {
571
+ d: e === "core" ? $e : et,
532
572
  fill: i
533
573
  });
534
574
  return v(s, c), s;
535
575
  }
536
- var Be = "M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z";
537
- function Ve(e, t, n, r) {
538
- let i = n / 24, a = x("g");
576
+ var nt = "M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z";
577
+ function rt(e, t, n, r) {
578
+ let i = n / 24, a = b("g");
539
579
  y(a, { transform: `translate(${e - 12 * i} ${t - 12 * i}) scale(${i})` });
540
- let o = y(x("path"), {
541
- d: Be,
580
+ let o = y(b("path"), {
581
+ d: nt,
542
582
  fill: r
543
583
  });
544
584
  return v(a, o), a;
545
585
  }
546
- var F;
547
- function He(e, t, n) {
548
- return F === void 0 && (F = typeof document > "u" ? null : document.createElement("canvas").getContext("2d")), F ? (F.font = `${n} ${t}px ${M.family}`, F.measureText(e).width) : e.length * t * .58;
586
+ var N;
587
+ function it(e, t, n) {
588
+ return N === void 0 && (N = typeof document > "u" ? null : document.createElement("canvas").getContext("2d")), N ? (N.font = `${n} ${t}px ${A.family}`, N.measureText(e).width) : e.length * t * .58;
549
589
  }
550
- function Ue(e, t, n, r) {
590
+ function at(e, t, n, r) {
551
591
  let i = e;
552
- for (; i && He(`${i}…`, n, r) > t;) i = i.slice(0, -1).trimEnd();
592
+ for (; i && it(`${i}…`, n, r) > t;) i = i.slice(0, -1).trimEnd();
553
593
  return `${i}…`;
554
594
  }
555
- function We(e, t, n, r) {
595
+ function ot(e, t, n, r) {
556
596
  let i = e.split("\n");
557
597
  return i.every((e) => e.trim() === "") ? [] : i.flatMap((e) => {
558
- let i = Ge(e, t, n, r);
598
+ let i = st(e, t, n, r);
559
599
  return i.length ? i : [""];
560
600
  });
561
601
  }
562
- function Ge(e, t, n, r) {
602
+ function st(e, t, n, r) {
563
603
  let i = e.split(/\s+/).filter(Boolean);
564
604
  if (i.length === 0) return [];
565
- let a = (e) => He(e, n, r) <= t, o = [], s = "";
605
+ let a = (e) => it(e, n, r) <= t, o = [], s = "";
566
606
  for (let e of i) {
567
607
  let t = s ? `${s} ${e}` : e;
568
608
  if (a(t)) {
@@ -585,13 +625,13 @@ function Ge(e, t, n, r) {
585
625
  }
586
626
  //#endregion
587
627
  //#region src/draw/index.ts
588
- var Ke = {
628
+ var ct = {
589
629
  __init__: ["cmRenderer"],
590
- cmRenderer: ["type", Fe]
630
+ cmRenderer: ["type", Ze]
591
631
  };
592
632
  //#endregion
593
633
  //#region src/io/CmImporter.ts
594
- function qe(e, t) {
634
+ function lt(e, t) {
595
635
  let n = e.x + e.width / 2, r = e.y + e.height / 2, i = t.x - n, a = t.y - r;
596
636
  if (i === 0 && a === 0) return {
597
637
  x: n,
@@ -603,13 +643,13 @@ function qe(e, t) {
603
643
  y: r + a * c
604
644
  };
605
645
  }
606
- function Je(e) {
646
+ function ut(e) {
607
647
  return {
608
648
  x: e.x + e.width / 2,
609
649
  y: e.y + e.height / 2
610
650
  };
611
651
  }
612
- var Ye = class {
652
+ var dt = class {
613
653
  canvas;
614
654
  elementFactory;
615
655
  factory;
@@ -625,59 +665,65 @@ var Ye = class {
625
665
  constructor(e, t, n, r, i) {
626
666
  this.canvas = e, this.elementFactory = t, this.factory = n, this.eventBus = r, this.elementRegistry = i;
627
667
  }
668
+ assertImportable(e) {
669
+ let t = /* @__PURE__ */ new Set();
670
+ for (let { id: n } of [...e.contexts, ...e.relationships]) {
671
+ let e = re(n);
672
+ if (e) throw Error(`Cannot draw the map: ${e}.`);
673
+ if (t.has(n)) throw Error(`The id "${n}" is used more than once.`);
674
+ t.add(n);
675
+ }
676
+ }
628
677
  import(e) {
629
678
  let t = [];
630
679
  this.eventBus.fire("import.render.start", { document: e });
631
- let n;
632
- try {
633
- n = this.canvas.getRootElement();
634
- } catch {
635
- n = void 0;
636
- }
637
- let r;
638
- n && n.id === "cm-root" ? r = n : (r = this.elementFactory.createRoot({ id: we }), this.canvas.setRootElement(r)), r.businessObject = { title: e.title };
639
- let i = /* @__PURE__ */ new Map();
680
+ let n = this.documentRoot(), r = g(e, a), i = [];
681
+ n.businessObject = {
682
+ title: e.title,
683
+ ...Object.keys(r).length > 0 ? { foreign: r } : {}
684
+ };
685
+ let o = /* @__PURE__ */ new Map();
640
686
  for (let t of e.contexts) {
641
687
  let e = this.factory.createContext(t);
642
- i.set(t.id, e);
688
+ o.set(t.id, e);
643
689
  }
644
- for (let n of e.relationships) {
645
- let e = i.get(n.from), a = i.get(n.to);
690
+ for (let r of e.relationships) {
691
+ let e = o.get(r.from), a = o.get(r.to);
646
692
  if (!e || !a) {
647
- t.push({
648
- message: `Relationship "${n.id}" references a missing context; skipped.`,
649
- elementId: n.id
693
+ i.push(r), t.push({
694
+ message: `Relationship "${r.id}" references a missing context; it stays in the file but is not drawn.`,
695
+ elementId: r.id
650
696
  });
651
697
  continue;
652
698
  }
653
- let o = [qe(e, Je(a)), qe(a, Je(e))], s = this.factory.createRelationship(n, e, a, o);
654
- this.canvas.addConnection(s, r);
699
+ let s = [lt(e, ut(a)), lt(a, ut(e))], c = this.factory.createRelationship(r, e, a, s);
700
+ this.canvas.addConnection(c, n);
655
701
  }
656
- for (let e of i.values()) this.canvas.addShape(e, r);
657
- return this.eventBus.fire("import.render.done", { warnings: t }), t;
702
+ for (let e of o.values()) this.canvas.addShape(e, n);
703
+ return i.length > 0 && (n.businessObject.unplacedRelationships = i), this.eventBus.fire("import.render.done", { warnings: t }), t;
704
+ }
705
+ documentRoot() {
706
+ let e = this.elementRegistry.get(D);
707
+ e || (e = this.elementFactory.createRoot({ id: D }), this.canvas.setRootElement(e));
708
+ for (let t of this.canvas.getRootElements()) t !== e && this.canvas.removeRootElement(t);
709
+ return e;
658
710
  }
659
711
  clear() {
660
- for (let e of [...this.elementRegistry.getAll()]) if (e.id !== "cm-root") try {
661
- "waypoints" in e ? this.canvas.removeConnection(e.id) : this.canvas.removeShape(e.id);
712
+ let e = new Set(this.canvas.getRootElements());
713
+ for (let t of [...this.elementRegistry.getAll()]) if (!e.has(t)) try {
714
+ "waypoints" in t ? this.canvas.removeConnection(t.id) : this.canvas.removeShape(t.id);
662
715
  } catch {}
663
716
  }
664
- }, Xe = class {
717
+ }, ft = class {
665
718
  elementRegistry;
666
- canvas;
667
- static $inject = ["elementRegistry", "canvas"];
668
- constructor(e, t) {
669
- this.elementRegistry = e, this.canvas = t;
719
+ static $inject = ["elementRegistry"];
720
+ constructor(e) {
721
+ this.elementRegistry = e;
670
722
  }
671
723
  export() {
672
- let e;
673
- try {
674
- e = this.canvas.getRootElement().businessObject;
675
- } catch {
676
- e = void 0;
677
- }
678
- let t = [], n = [];
679
- for (let e of this.elementRegistry.getAll()) if (e.id !== "cm-root") {
680
- if (D(e)) {
724
+ let e = this.elementRegistry.get(D)?.businessObject, t = [], n = [];
725
+ for (let e of this.elementRegistry.getAll()) if (e.id !== D) {
726
+ if (T(e)) {
681
727
  let n = e;
682
728
  t.push({
683
729
  id: e.id,
@@ -694,9 +740,10 @@ var Ye = class {
694
740
  ...e.team ? { team: e.team } : {},
695
741
  ...e.description ? { description: e.description } : {},
696
742
  ...e.fill ? { fill: e.fill } : {},
697
- ...e.stroke ? { stroke: e.stroke } : {}
743
+ ...e.stroke ? { stroke: e.stroke } : {},
744
+ ...e.cmForeign
698
745
  });
699
- } else if (O(e)) {
746
+ } else if (E(e)) {
700
747
  let t = e.source, r = e.target;
701
748
  if (!t?.id || !r?.id) continue;
702
749
  n.push({
@@ -708,69 +755,147 @@ var Ye = class {
708
755
  ...e.downstreamRoles?.length ? { downstreamRoles: [...e.downstreamRoles] } : {},
709
756
  ...e.cmLabel ? { label: e.cmLabel } : {},
710
757
  ...e.description ? { description: e.description } : {},
711
- ...e.implementationTechnology ? { implementationTechnology: e.implementationTechnology } : {}
758
+ ...e.implementationTechnology ? { implementationTechnology: e.implementationTechnology } : {},
759
+ ...e.cmForeign
712
760
  });
713
761
  }
714
762
  }
715
- return {
716
- version: i,
763
+ return n.push(...e?.unplacedRelationships ?? []), {
764
+ version: o,
717
765
  title: e?.title ?? "Untitled context map",
718
766
  contexts: t,
719
- relationships: n
767
+ relationships: n,
768
+ ...e?.foreign
720
769
  };
721
770
  }
722
- }, Ze = {
723
- cmImporter: ["type", Ye],
724
- cmExporter: ["type", Xe]
725
- }, Qe = class extends k {
771
+ }, pt = {
772
+ cmImporter: ["type", dt],
773
+ cmExporter: ["type", ft]
774
+ }, mt = class extends Be {
726
775
  _getModules() {
727
776
  return [
728
- ke,
729
- Ke,
730
- Ze
777
+ Ge,
778
+ ct,
779
+ pt
731
780
  ];
732
781
  }
733
- }, $e = class extends Qe {
782
+ }, ht = {
783
+ x: 14,
784
+ y: 18
785
+ }, gt = 12;
786
+ function _t(e) {
787
+ if (T(e)) {
788
+ let t = [];
789
+ return e.description && t.push(e.description), e.team && t.push(`Team: ${e.team}`), t.length === 0 ? null : {
790
+ title: e.cmLabel ?? "Bounded context",
791
+ body: t.join(" · ")
792
+ };
793
+ }
794
+ if (E(e)) {
795
+ let t = f[e.pattern]?.label ?? e.pattern, n = [];
796
+ return e.description && n.push(e.description), e.implementationTechnology && n.push(e.implementationTechnology), {
797
+ title: e.cmLabel ? `${t} · ${e.cmLabel}` : t,
798
+ body: n.join(" · ")
799
+ };
800
+ }
801
+ return null;
802
+ }
803
+ var vt = class {
804
+ static $inject = ["eventBus", "canvas"];
805
+ tooltip;
806
+ title;
807
+ body;
808
+ constructor(e, t) {
809
+ let n = t.getContainer();
810
+ this.tooltip = document.createElement("div"), this.tooltip.className = "cm-hover-tooltip", this.tooltip.setAttribute("role", "tooltip"), this.tooltip.hidden = !0, this.title = document.createElement("strong"), this.body = document.createElement("span"), this.tooltip.append(this.title, this.body), n.append(this.tooltip);
811
+ let r = (e) => {
812
+ let t = n.getBoundingClientRect(), r = this.tooltip.offsetWidth, i = Math.min(e.clientX - t.left + ht.x, t.width - r - gt);
813
+ this.tooltip.style.left = `${Math.max(gt, i)}px`, this.tooltip.style.top = `${e.clientY - t.top + ht.y}px`;
814
+ }, i = () => {
815
+ this.tooltip.hidden = !0, n.removeEventListener("mousemove", r);
816
+ };
817
+ e.on("element.hover", (e) => {
818
+ let t = _t(e.element);
819
+ t ? (this.title.textContent = t.title, this.body.textContent = t.body, this.body.hidden = t.body === "", this.tooltip.hidden = !1, e.originalEvent && r(e.originalEvent), n.addEventListener("mousemove", r)) : i();
820
+ }), e.on([
821
+ "element.out",
822
+ "drag.init",
823
+ "canvas.viewbox.changing",
824
+ "diagram.clear"
825
+ ], i), e.on("diagram.destroy", () => {
826
+ i(), this.tooltip.remove();
827
+ });
828
+ }
829
+ }, yt = {
830
+ __init__: ["cmHoverTooltip"],
831
+ cmHoverTooltip: ["type", vt]
832
+ }, P = class extends mt {
734
833
  _getModules() {
735
834
  return [
736
835
  ...super._getModules(),
737
- S,
738
- C,
739
- ne
836
+ x,
837
+ de,
838
+ fe,
839
+ yt
740
840
  ];
741
841
  }
742
842
  };
743
843
  //#endregion
744
844
  //#region src/modeling/cmd/UpdatePropertiesHandler.ts
745
- function et(e, t, n) {
845
+ function bt(e, t, n) {
746
846
  n === void 0 ? delete e[t] : e[t] = n;
747
847
  }
748
- var tt = class {
848
+ var xt = class {
749
849
  execute(e) {
750
850
  let { element: t, properties: n } = e, r = t, i = {};
751
- for (let e of Object.keys(n)) i[e] = r[e], et(r, e, n[e]);
851
+ for (let e of Object.keys(n)) i[e] = r[e], bt(r, e, n[e]);
752
852
  return e.oldProperties = i, [t];
753
853
  }
754
854
  revert(e) {
755
855
  let { element: t, oldProperties: n } = e, r = t;
756
- if (n) for (let e of Object.keys(n)) et(r, e, n[e]);
856
+ if (n) for (let e of Object.keys(n)) bt(r, e, n[e]);
757
857
  return [t];
758
858
  }
759
859
  };
760
860
  //#endregion
761
861
  //#region src/modeling/cmd/SwapEndsHandler.ts
762
- function I(e) {
862
+ function St(e) {
763
863
  let t = e.source;
764
864
  return e.source = e.target, e.target = t, Array.isArray(e.waypoints) && (e.waypoints = [...e.waypoints].reverse()), [e];
765
865
  }
766
- var nt = class {
866
+ var Ct = class {
867
+ execute(e) {
868
+ return St(e.connection);
869
+ }
870
+ revert(e) {
871
+ return St(e.connection);
872
+ }
873
+ }, wt = class {
874
+ elementRegistry;
875
+ static $inject = ["elementRegistry"];
876
+ constructor(e) {
877
+ this.elementRegistry = e;
878
+ }
879
+ root() {
880
+ let e = this.elementRegistry.get(D);
881
+ if (!e?.businessObject) throw Error("No context map is loaded to rename.");
882
+ return e;
883
+ }
767
884
  execute(e) {
768
- return I(e.connection);
885
+ let t = this.root(), n = t.businessObject;
886
+ return e.oldTitle = n.title, t.businessObject = {
887
+ ...n,
888
+ title: e.title
889
+ }, [];
769
890
  }
770
891
  revert(e) {
771
- return I(e.connection);
892
+ let t = this.root();
893
+ return t.businessObject = {
894
+ ...t.businessObject,
895
+ title: e.oldTitle ?? ""
896
+ }, [];
772
897
  }
773
- }, rt = "element.updateProperties", it = "relationship.swapEnds", at = class {
898
+ }, Tt = "element.updateProperties", Et = "relationship.swapEnds", Dt = "map.updateTitle", Ot = class {
774
899
  commandStack;
775
900
  elementRegistry;
776
901
  graphicsFactory;
@@ -780,17 +905,20 @@ var nt = class {
780
905
  "graphicsFactory"
781
906
  ];
782
907
  constructor(e, t, n) {
783
- this.commandStack = e, this.elementRegistry = t, this.graphicsFactory = n, e.registerHandler(rt, tt), e.registerHandler(it, nt);
908
+ this.commandStack = e, this.elementRegistry = t, this.graphicsFactory = n, e.registerHandler(Tt, xt), e.registerHandler(Et, Ct), e.registerHandler(Dt, wt);
909
+ }
910
+ setTitle(e) {
911
+ this.commandStack.execute(Dt, { title: e });
784
912
  }
785
913
  redraw(e) {
786
914
  let t = this.elementRegistry.getGraphics(e);
787
- t && this.graphicsFactory.update(O(e) ? "connection" : "shape", e, t);
915
+ t && this.graphicsFactory.update(E(e) ? "connection" : "shape", e, t);
788
916
  }
789
917
  swapEnds(e) {
790
- this.commandStack.execute(it, { connection: e }), this.redraw(e);
918
+ this.commandStack.execute(Et, { connection: e }), this.redraw(e);
791
919
  }
792
920
  updateProperties(e, t) {
793
- this.commandStack.execute(rt, {
921
+ this.commandStack.execute(Tt, {
794
922
  element: e,
795
923
  properties: t
796
924
  }), this.redraw(e);
@@ -815,7 +943,7 @@ var nt = class {
815
943
  }
816
944
  setPattern(e, t) {
817
945
  let n = { pattern: t };
818
- if (p(t)) n.upstreamRoles = void 0, n.downstreamRoles = void 0;
946
+ if (ee(t)) n.upstreamRoles = void 0, n.downstreamRoles = void 0;
819
947
  else if (t === "customer-supplier") {
820
948
  let t = (e.upstreamRoles ?? []).filter((e) => e !== "OHS"), r = (e.downstreamRoles ?? []).filter((e) => e !== "CF");
821
949
  n.upstreamRoles = t.length ? t : void 0, n.downstreamRoles = r.length ? r : void 0;
@@ -831,36 +959,36 @@ var nt = class {
831
959
  setImplementationTechnology(e, t) {
832
960
  this.updateProperties(e, { implementationTechnology: t || void 0 });
833
961
  }
834
- }, L = {
962
+ }, F = {
835
963
  __init__: ["cmModeling"],
836
- cmModeling: ["type", at],
837
- layouter: ["type", Oe]
838
- }, ot = class extends ce {
964
+ cmModeling: ["type", Ot],
965
+ layouter: ["type", We]
966
+ }, kt = class extends _e {
839
967
  static $inject = ["eventBus"];
840
968
  constructor(e) {
841
969
  super(e);
842
970
  }
843
971
  init() {
844
- this.addRule(["shape.move", "elements.move"], (e) => e.target && e.target.parent ? null : !0), this.addRule("shape.create", () => !0), this.addRule("shape.resize", () => !1), this.addRule("connection.create", (e) => ct(e.source, e.target)), this.addRule("connection.reconnect", (e) => !!ct(e.source, e.target, e.connection)), this.addRule("connection.updateWaypoints", () => !0);
972
+ this.addRule(["shape.move", "elements.move"], (e) => e.target && e.target.parent ? null : !0), this.addRule("shape.create", () => !0), this.addRule("shape.resize", () => !1), this.addRule("connection.create", (e) => jt(e.source, e.target)), this.addRule("connection.reconnect", (e) => !!jt(e.source, e.target, e.connection)), this.addRule("connection.updateWaypoints", () => !0);
845
973
  }
846
974
  };
847
- function st(e, t, n) {
975
+ function At(e, t, n) {
848
976
  let { incoming: r = [], outgoing: i = [] } = e;
849
977
  return [...r, ...i].some((r) => r !== n && (r.source === e && r.target === t || r.source === t && r.target === e));
850
978
  }
851
- function ct(e, t, n) {
852
- return !D(e) || !D(t) || e === t || st(e, t, n) ? !1 : {
979
+ function jt(e, t, n) {
980
+ return !T(e) || !T(t) || e === t || At(e, t, n) ? !1 : {
853
981
  cmKind: "relationship",
854
982
  pattern: "upstream-downstream"
855
983
  };
856
984
  }
857
985
  //#endregion
858
986
  //#region src/rules/index.ts
859
- var R = {
860
- __depends__: [se],
987
+ var I = {
988
+ __depends__: [ge],
861
989
  __init__: ["cmRules"],
862
- cmRules: ["type", ot]
863
- }, lt = class extends le {
990
+ cmRules: ["type", kt]
991
+ }, Mt = class extends ve {
864
992
  static $inject = [
865
993
  "eventBus",
866
994
  "canvas",
@@ -888,144 +1016,96 @@ var R = {
888
1016
  }
889
1017
  }, !0);
890
1018
  }
891
- }, ut = "cm-dragging", dt = class {
1019
+ }, Nt = "cm-dragging", Pt = class {
892
1020
  static $inject = ["eventBus", "canvas"];
893
1021
  constructor(e, t) {
894
1022
  e.on("drag.init", () => {
895
- t.getContainer().classList.add(ut);
1023
+ t.getContainer().classList.add(Nt);
896
1024
  }), e.on("drag.cleanup", () => {
897
- t.getContainer().classList.remove(ut);
1025
+ t.getContainer().classList.remove(Nt);
898
1026
  });
899
1027
  }
900
- }, ft = 2e3, pt = {
1028
+ }, Ft = 2e3, It = {
901
1029
  __init__: [
902
1030
  "cmFlatModelBehavior",
903
1031
  "cmDragBehavior",
904
1032
  "cmClickSelectionBehavior"
905
1033
  ],
906
- cmFlatModelBehavior: ["type", lt],
907
- cmDragBehavior: ["type", dt],
1034
+ cmFlatModelBehavior: ["type", Mt],
1035
+ cmDragBehavior: ["type", Pt],
908
1036
  cmClickSelectionBehavior: ["type", class {
909
1037
  static $inject = ["eventBus", "selection"];
910
1038
  constructor(e, t) {
911
- e.on("element.click", ft, (e) => {
1039
+ e.on("element.click", Ft, (e) => {
912
1040
  let n = e.element;
913
- if (E(n) && !ue(e) && t.isSelected(n)) return !1;
1041
+ if (w(n) && !ye(e) && t.isSelected(n)) return !1;
914
1042
  });
915
1043
  }
916
1044
  }]
917
- };
918
- //#endregion
919
- //#region src/draw/palette-icons.ts
920
- function z(e, t = 24) {
921
- return `<svg class="cm-palette-svg" width="${t}" height="${t}" viewBox="0 0 26 26" aria-hidden="true">${e}</svg>`;
922
- }
923
- var mt = "M12 2l2.9 6.26L22 9.27l-5 4.87L18.18 22 12 18.56 5.82 22 7 14.14l-5-4.87 7.1-1.01z", ht = "M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z";
924
- function gt(e, t, n, r, i) {
925
- if (e === "generic") return `<circle cx="${t}" cy="${n}" r="${r / 2 - .5}" fill="none" stroke="${i}" stroke-width="1.4" stroke-dasharray="1.8 1.8"/>`;
926
- let a = r / 24, o = e === "supporting" ? " rotate(90 12 12)" : "", s = `translate(${t - 12 * a} ${n - 12 * a}) scale(${a})${o}`;
927
- return `<path d="${e === "core" ? mt : ht}" fill="${i}" transform="${s}"/>`;
928
- }
929
- function B(e) {
930
- let t = e ? u[e] : void 0;
931
- return z(!e || !t ? `<rect x="2" y="4" width="22" height="18" rx="3.5" fill="${Ne}" stroke="${Pe}" stroke-width="1.5"/>` : `<rect x="2" y="4" width="22" height="18" rx="3.5" fill="${t.fill}" stroke="${t.stroke}" stroke-width="1.5"/>` + gt(e, 13, 13, 12, t.stroke));
932
- }
933
- function _t(e, t = 18) {
934
- let n = u[e], r = n?.stroke ?? "#8A8577";
935
- return `<svg class="cm-palette-svg" width="${t}" height="${t}" viewBox="0 0 24 24" aria-hidden="true">${!n || e === "generic" ? `<circle cx="12" cy="12" r="9" fill="none" stroke="${r}" stroke-width="1.8" stroke-dasharray="2.4 2.4"/>` : `<path d="${e === "core" ? mt : ht}" fill="${r}"/>`}</svg>`;
936
- }
937
- function V(e) {
938
- return z(`<rect x="1" y="6.5" width="24" height="13" rx="3" fill="${s[e] ?? "#8A8577"}"/><text x="13" y="16.4" text-anchor="middle" font-size="9.5" font-weight="700" fill="${c}" font-family="${M.family}">${e}</text>`);
939
- }
940
- function H(e = "upstream-downstream", t = 24) {
941
- let n = l[e] ?? l["upstream-downstream"], r = n.dash ? ` stroke-dasharray="${n.dash}"` : "", i = Math.min(n.strokeWidth, 2.6);
942
- return z(`<g stroke="${n.stroke}" stroke-width="${i}" stroke-linecap="round"><circle cx="5" cy="13" r="2.5" fill="${n.stroke}" stroke="none"/><line x1="7" y1="13" x2="19" y2="13"${r}/><circle cx="21" cy="13" r="2.5" fill="${n.stroke}" stroke="none"/></g>`, t);
943
- }
944
- //#endregion
945
- //#region src/draw/icons.ts
946
- var vt = "M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z", yt = "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z", bt = "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z", xt = "M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z", St = "M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z", Ct = "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4v2z", wt = "M3 18h12v-2H3v2zM3 6v2h18V6H3zm0 7h18v-2H3v2z", Tt = "M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z";
947
- function U(e, t = 18) {
948
- return `<svg width="${t}" height="${t}" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="${e}"/></svg>`;
949
- }
950
- function Et(e = 18) {
951
- return `<svg width="${e}" height="${e}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><rect x="4" y="4" width="16" height="16" rx="2" stroke-dasharray="3.2 2.6"/></svg>`;
952
- }
953
- //#endregion
954
- //#region src/palette/CmPaletteProvider.ts
955
- var Dt = "tools", Ot = "cm-1-contexts";
956
- function kt(e, t, n = !0) {
957
- return `<div class="entry cm-palette-entry"${n ? " draggable=\"true\"" : ""} title="${t}">${e}</div>`;
958
- }
959
- var At = class {
960
- create;
961
- lassoTool;
962
- factory;
963
- static $inject = [
964
- "palette",
965
- "create",
966
- "lassoTool",
967
- "cmElementFactory"
968
- ];
969
- constructor(e, t, n, r) {
970
- this.create = t, this.lassoTool = n, this.factory = r, e.registerProvider(this);
1045
+ }, L = "cm.readOnly.changed", Lt = 5e3, Rt = [
1046
+ "elements.move",
1047
+ "shape.move",
1048
+ "shape.resize",
1049
+ "shape.create",
1050
+ "elements.create",
1051
+ "shape.append",
1052
+ "connection.start",
1053
+ "connection.create",
1054
+ "connection.reconnect",
1055
+ "connection.updateWaypoints",
1056
+ "elements.delete"
1057
+ ], zt = class extends _e {
1058
+ bus;
1059
+ static $inject = ["eventBus"];
1060
+ readOnly = !1;
1061
+ constructor(e) {
1062
+ super(e), this.bus = e;
971
1063
  }
972
- getPaletteEntries() {
973
- let e = {}, t = "Lasso tool — drag a box to select multiple elements";
974
- e["lasso-tool"] = {
975
- group: Dt,
976
- title: t,
977
- html: kt(Et(), t, !1),
978
- action: { click: (e) => this.lassoTool.activateSelection(e) }
979
- };
980
- for (let t of r) {
981
- let n = (e) => this.create.start(e, this.factory.createNewContext(t.type, t.label));
982
- e[`context.${t.type}`] = {
983
- group: Ot,
984
- title: `${t.label} — ${t.description}`,
985
- html: kt(B(t.type), `${t.label} — ${t.description}`),
986
- action: {
987
- dragstart: n,
988
- click: n
989
- }
990
- };
991
- }
992
- return e;
1064
+ init() {
1065
+ this.addRule(Rt, Lt, () => !this.readOnly && void 0);
993
1066
  }
994
- }, jt = {
995
- __depends__: [
996
- de,
997
- fe,
998
- w,
999
- pe
1000
- ],
1001
- __init__: ["cmPaletteProvider"],
1002
- cmPaletteProvider: ["type", At]
1003
- }, Mt = {
1067
+ isReadOnly() {
1068
+ return this.readOnly;
1069
+ }
1070
+ setReadOnly(e) {
1071
+ this.readOnly !== e && (this.readOnly = e, this.bus.fire(L, { readOnly: e }));
1072
+ }
1073
+ }, R = {
1074
+ __depends__: [ge],
1075
+ __init__: ["cmReadOnly"],
1076
+ cmReadOnly: ["type", zt]
1077
+ }, Bt = {
1004
1078
  name: "cm-direct-editing",
1005
1079
  team: "cm-direct-editing-team"
1006
- }, Nt = 10, Pt = 20, Ft = class {
1080
+ }, Vt = 10, Ht = 20, Ut = class {
1007
1081
  canvas;
1008
1082
  directEditing;
1009
1083
  modeling;
1084
+ elementRegistry;
1085
+ readOnly;
1010
1086
  static $inject = [
1011
1087
  "eventBus",
1012
1088
  "canvas",
1013
1089
  "directEditing",
1014
- "cmModeling"
1090
+ "cmModeling",
1091
+ "elementRegistry",
1092
+ "cmReadOnly"
1015
1093
  ];
1016
1094
  mode = "name";
1017
1095
  activeMarker;
1018
- constructor(e, t, n, r) {
1019
- this.canvas = t, this.directEditing = n, this.modeling = r, n.registerProvider({
1096
+ suspended;
1097
+ resumeTimer;
1098
+ constructor(e, t, n, r, i, a) {
1099
+ this.canvas = t, this.directEditing = n, this.modeling = r, this.elementRegistry = i, this.readOnly = a, n.registerProvider({
1020
1100
  activate: (e) => this.activationContext(e),
1021
1101
  update: (e, t) => this.commit(e, t)
1022
1102
  }), e.on("element.dblclick", (e) => {
1023
1103
  let t = e.element;
1024
- E(t) && (this.mode = D(t) && t.team && this.isInTeamBand(t, e.originalEvent) ? "team" : "name", n.activate(t));
1025
- }), e.on(["canvas.viewbox.changing", "drag.init"], () => n.complete()), e.on("directEditing.activate", (e) => {
1104
+ w(t) && (this.mode = T(t) && t.team && this.isInTeamBand(t, e.originalEvent) ? "team" : "name", n.activate(t));
1105
+ }), e.on("drag.init", () => n.complete()), e.on("canvas.viewbox.changed", () => this.placeOpenEdit()), e.on("directEditing.activate", (e) => {
1026
1106
  let n = e.active?.element;
1027
1107
  if (!n) return;
1028
- let r = Mt[this.mode];
1108
+ let r = Bt[this.mode];
1029
1109
  t.addMarker(n, r), this.activeMarker = {
1030
1110
  element: n,
1031
1111
  marker: r
@@ -1033,8 +1113,55 @@ var At = class {
1033
1113
  }), e.on(["directEditing.complete", "directEditing.cancel"], () => {
1034
1114
  let e = this.activeMarker;
1035
1115
  e && t.removeMarker(e.element, e.marker), this.activeMarker = void 0;
1116
+ }), e.on("diagram.destroy", () => {
1117
+ clearTimeout(this.resumeTimer), this.suspended = void 0;
1118
+ }), e.on("directEditing.activate.allowed", 2e3, () => !this.readOnly.isReadOnly() && void 0), e.on(L, (e) => {
1119
+ e.readOnly && n.cancel();
1036
1120
  });
1037
1121
  }
1122
+ suspend() {
1123
+ clearTimeout(this.resumeTimer);
1124
+ let e = this.activeMarker?.element;
1125
+ this.directEditing.isActive() && e && (this.suspended = {
1126
+ elementId: e.id,
1127
+ mode: this.mode,
1128
+ text: this.directEditing.getValue()
1129
+ }, this.directEditing.cancel());
1130
+ }
1131
+ resumeAfterImport() {
1132
+ clearTimeout(this.resumeTimer), this.suspended && (this.resumeTimer = setTimeout(() => {
1133
+ let e = this.suspended;
1134
+ this.suspended = void 0, e && !this.directEditing.isActive() && this.resume(e);
1135
+ }, 0));
1136
+ }
1137
+ openEdit() {
1138
+ let e = this.activeMarker?.element;
1139
+ if (this.directEditing.isActive() && e) return {
1140
+ elementId: e.id,
1141
+ text: this.directEditing.getValue()
1142
+ };
1143
+ }
1144
+ placeOpenEdit() {
1145
+ let e = this.activeMarker?.element, t = this.directEditing.$textbox;
1146
+ if (!this.directEditing.isActive() || !e || !t) return;
1147
+ let n = this.activationContext(e);
1148
+ if (!n) return;
1149
+ let { x: r, y: i, width: a, height: o } = n.bounds;
1150
+ Object.assign(t.style, {
1151
+ left: `${r}px`,
1152
+ top: `${i}px`,
1153
+ width: `${a}px`,
1154
+ height: `${o}px`
1155
+ });
1156
+ let s = t.querySelector("[contenteditable]"), c = n.style?.fontSize;
1157
+ s && c !== void 0 && (s.style.fontSize = String(c));
1158
+ }
1159
+ resume(e) {
1160
+ let t = this.elementRegistry.get(e.elementId);
1161
+ if (!w(t) || e.mode === "team" && !T(t) || (this.mode = e.mode, !this.directEditing.activate(t))) return;
1162
+ let n = this.directEditing.$textbox?.querySelector("[contenteditable]");
1163
+ n && (n.innerText = e.text, Wt(n));
1164
+ }
1038
1165
  activate(e) {
1039
1166
  this.mode = "name", this.directEditing.activate(e);
1040
1167
  }
@@ -1050,45 +1177,45 @@ var At = class {
1050
1177
  return t.clientY - i >= r.y + r.height - 22 * n;
1051
1178
  }
1052
1179
  activationContext(e) {
1053
- if (!E(e)) return;
1054
- this.mode === "team" && !D(e) && (this.mode = "name");
1180
+ if (!w(e)) return;
1181
+ this.mode === "team" && !T(e) && (this.mode = "name");
1055
1182
  let t = this.canvas.zoom(), n = this.canvas.getAbsoluteBBox(e);
1056
1183
  if (this.mode === "team") {
1057
1184
  let r = e;
1058
1185
  return {
1059
1186
  bounds: {
1060
- x: n.x + Nt * t,
1187
+ x: n.x + Vt * t,
1061
1188
  y: n.y + n.height - 22 * t,
1062
1189
  width: n.width - 20 * t,
1063
- height: Pt * t
1190
+ height: Ht * t
1064
1191
  },
1065
1192
  text: r.team ?? "",
1066
1193
  style: {
1067
- fontFamily: M.family,
1068
- fontSize: `${M.small * t}px`,
1194
+ fontFamily: A.family,
1195
+ fontSize: `${A.small * t}px`,
1069
1196
  fontWeight: 400,
1070
1197
  lineHeight: 1.2,
1071
1198
  backgroundColor: "transparent",
1072
- border: "1px dashed rgba(51, 93, 229, 0.65)",
1199
+ border: "1px dashed var(--cd-ui-interaktion)",
1073
1200
  textAlign: "center"
1074
1201
  },
1075
1202
  options: { centerVertically: !0 }
1076
1203
  };
1077
1204
  }
1078
1205
  let r = {
1079
- fontFamily: M.family,
1080
- fontSize: `${M.label * t}px`,
1206
+ fontFamily: A.family,
1207
+ fontSize: `${A.label * t}px`,
1081
1208
  fontWeight: 650,
1082
1209
  lineHeight: 1.2,
1083
1210
  backgroundColor: "transparent",
1084
- border: "1px dashed rgba(51, 93, 229, 0.65)",
1211
+ border: "1px dashed var(--cd-ui-interaktion)",
1085
1212
  textAlign: "center"
1086
1213
  };
1087
- if (D(e)) {
1214
+ if (T(e)) {
1088
1215
  let i = e.team ? 18 * t : 0;
1089
1216
  return {
1090
1217
  bounds: {
1091
- x: n.x + Nt * t,
1218
+ x: n.x + Vt * t,
1092
1219
  y: n.y + 36 * t - 1,
1093
1220
  width: n.width - 20 * t,
1094
1221
  height: n.height - 36 * t - i
@@ -1108,7 +1235,7 @@ var At = class {
1108
1235
  text: e.cmLabel ?? "",
1109
1236
  style: {
1110
1237
  ...r,
1111
- backgroundColor: "rgba(255, 255, 255, 0.95)"
1238
+ backgroundColor: "var(--cd-ui-flaeche-hoch)"
1112
1239
  },
1113
1240
  options: { centerVertically: !0 }
1114
1241
  };
@@ -1119,23 +1246,197 @@ var At = class {
1119
1246
  let t = e;
1120
1247
  if (n === (t.team ?? "")) return;
1121
1248
  this.modeling.setTeam(t, n || void 0);
1122
- return;
1123
- }
1124
- n !== (e.cmLabel ?? "") && this.modeling.updateLabel(e, n);
1249
+ } else n !== (e.cmLabel ?? "") && this.modeling.updateLabel(e, n);
1125
1250
  }
1126
- }, W = {
1127
- __depends__: [_e, L],
1251
+ };
1252
+ function Wt(e) {
1253
+ let t = document.createRange();
1254
+ t.selectNodeContents(e), t.collapse(!1);
1255
+ let n = window.getSelection();
1256
+ n?.removeAllRanges(), n?.addRange(t);
1257
+ }
1258
+ //#endregion
1259
+ //#region src/label-editing/index.ts
1260
+ var z = {
1261
+ __depends__: [
1262
+ Ce,
1263
+ F,
1264
+ R
1265
+ ],
1128
1266
  __init__: ["cmLabelEditing"],
1129
- cmLabelEditing: ["type", Ft]
1130
- }, G = "cm-subdomain-menu", It = "cm-pattern-menu", K = "cm-roles-menu", q = "cm-popup-active", J = 8, Lt = {
1267
+ cmLabelEditing: ["type", Ut]
1268
+ };
1269
+ //#endregion
1270
+ //#region src/draw/palette-icons.ts
1271
+ function B(e, t = 24) {
1272
+ return `<svg class="cm-palette-svg" width="${t}" height="${t}" viewBox="0 0 26 26" aria-hidden="true">${e}</svg>`;
1273
+ }
1274
+ var Gt = "M12 2l2.9 6.26L22 9.27l-5 4.87L18.18 22 12 18.56 5.82 22 7 14.14l-5-4.87 7.1-1.01z", Kt = "M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z";
1275
+ function qt(e, t, n, r, i) {
1276
+ if (e === "generic") return `<circle cx="${t}" cy="${n}" r="${r / 2 - .5}" fill="none" stroke="${i}" stroke-width="1.4" stroke-dasharray="1.8 1.8"/>`;
1277
+ let a = r / 24, o = e === "supporting" ? " rotate(90 12 12)" : "", s = `translate(${t - 12 * a} ${n - 12 * a}) scale(${a})${o}`;
1278
+ return `<path d="${e === "core" ? Gt : Kt}" fill="${i}" transform="${s}"/>`;
1279
+ }
1280
+ function V(e) {
1281
+ let t = e ? p[e] : void 0;
1282
+ return B(!e || !t ? `<rect x="2" y="4" width="22" height="18" rx="3.5" fill="${Ye}" stroke="${Xe}" stroke-width="1.5"/>` : `<rect x="2" y="4" width="22" height="18" rx="3.5" fill="${t.fill}" stroke="${t.stroke}" stroke-width="1.5"/>` + qt(e, 13, 13, 12, t.stroke));
1283
+ }
1284
+ function Jt(e, t = 18) {
1285
+ let n = p[e], r = n?.stroke ?? "#8A8577";
1286
+ return `<svg class="cm-palette-svg" width="${t}" height="${t}" viewBox="0 0 24 24" aria-hidden="true">${!n || e === "generic" ? `<circle cx="12" cy="12" r="9" fill="none" stroke="${r}" stroke-width="1.8" stroke-dasharray="2.4 2.4"/>` : `<path d="${e === "core" ? Gt : Kt}" fill="${r}"/>`}</svg>`;
1287
+ }
1288
+ function H(e) {
1289
+ return B(`<rect x="1" y="6.5" width="24" height="13" rx="3" fill="${l[e] ?? "#8A8577"}"/><text x="13" y="16.4" text-anchor="middle" font-size="9.5" font-weight="700" fill="${u}" font-family="${A.family}">${e}</text>`);
1290
+ }
1291
+ function U(e = "upstream-downstream", t = 24) {
1292
+ let n = f[e] ?? f["upstream-downstream"], r = n.dash ? ` stroke-dasharray="${n.dash}"` : "", i = Math.min(n.strokeWidth, 2.6);
1293
+ return B(`<g stroke="${n.stroke}" stroke-width="${i}" stroke-linecap="round"><circle cx="5" cy="13" r="2.5" fill="${n.stroke}" stroke="none"/><line x1="7" y1="13" x2="19" y2="13"${r}/><circle cx="21" cy="13" r="2.5" fill="${n.stroke}" stroke="none"/></g>`, t);
1294
+ }
1295
+ //#endregion
1296
+ //#region src/draw/lucide.ts
1297
+ var Yt = {
1298
+ "arrow-left-right": "<path d=\"M8 3 4 7l4 4\"/><path d=\"M4 7h16\"/><path d=\"m16 21 4-4-4-4\"/><path d=\"M20 17H4\"/>",
1299
+ "arrow-right": "<path d=\"M5 12h14\"/><path d=\"m12 5 7 7-7 7\"/>",
1300
+ "circle-x": "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m15 9-6 6\"/><path d=\"m9 9 6 6\"/>",
1301
+ pencil: "<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\"/><path d=\"m15 5 4 4\"/>",
1302
+ "sliders-horizontal": "<path d=\"M10 5H3\"/><path d=\"M12 19H3\"/><path d=\"M14 3v4\"/><path d=\"M16 17v4\"/><path d=\"M21 12h-9\"/><path d=\"M21 19h-5\"/><path d=\"M21 5h-7\"/><path d=\"M8 10v4\"/><path d=\"M8 12H3\"/>",
1303
+ "square-dashed-mouse-pointer": "<path d=\"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z\"/><path d=\"M5 3a2 2 0 0 0-2 2\"/><path d=\"M19 3a2 2 0 0 1 2 2\"/><path d=\"M5 21a2 2 0 0 1-2-2\"/><path d=\"M9 3h1\"/><path d=\"M9 21h2\"/><path d=\"M14 3h1\"/><path d=\"M3 9v1\"/><path d=\"M21 9v2\"/><path d=\"M3 14v1\"/>",
1304
+ "square-plus": "<rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\"/><path d=\"M8 12h8\"/><path d=\"M12 8v8\"/>",
1305
+ "text-align-start": "<path d=\"M21 5H3\"/><path d=\"M15 12H3\"/><path d=\"M17 19H3\"/>",
1306
+ "triangle-alert": "<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/>",
1307
+ trash: "<path d=\"M10 11v6\"/><path d=\"M14 11v6\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\"/><path d=\"M3 6h18\"/><path d=\"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"/>",
1308
+ users: "<path d=\"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\"/><path d=\"M16 3.128a4 4 0 0 1 0 7.744\"/><path d=\"M22 21v-2a4 4 0 0 0-3-3.87\"/><circle cx=\"9\" cy=\"7\" r=\"4\"/>",
1309
+ x: "<path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/>"
1310
+ };
1311
+ function Xt(e, t, n) {
1312
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${Yt[e]}</svg>`;
1313
+ }
1314
+ function W(e) {
1315
+ return Xt(e, 16, 2.5);
1316
+ }
1317
+ function Zt(e) {
1318
+ return Xt(e, 20, 2);
1319
+ }
1320
+ //#endregion
1321
+ //#region src/palette/CmPaletteProvider.ts
1322
+ var Qt = "tools", $t = "cm-1-contexts", en = 24;
1323
+ function tn(e, t) {
1324
+ return `<div class="entry cm-palette-entry"${t ? " draggable=\"true\"" : ""}>${e}</div>`;
1325
+ }
1326
+ function nn(e) {
1327
+ return e.charAt(0) + e.slice(1).toLowerCase();
1328
+ }
1329
+ function rn(e) {
1330
+ return e.type === "click" && e.detail === 0;
1331
+ }
1332
+ var an = class {
1333
+ create;
1334
+ lassoTool;
1335
+ factory;
1336
+ canvas;
1337
+ modeling;
1338
+ selection;
1339
+ elementRegistry;
1340
+ labelEditing;
1341
+ readOnly;
1342
+ config;
1343
+ static $inject = [
1344
+ "palette",
1345
+ "create",
1346
+ "lassoTool",
1347
+ "cmElementFactory",
1348
+ "canvas",
1349
+ "modeling",
1350
+ "selection",
1351
+ "elementRegistry",
1352
+ "cmLabelEditing",
1353
+ "cmReadOnly",
1354
+ "config.cmPalette"
1355
+ ];
1356
+ constructor(e, t, n, r, i, a, o, s, c, l, u) {
1357
+ this.create = t, this.lassoTool = n, this.factory = r, this.canvas = i, this.modeling = a, this.selection = o, this.elementRegistry = s, this.labelEditing = c, this.readOnly = l, this.config = u, e.registerProvider(this);
1358
+ }
1359
+ getPaletteEntries() {
1360
+ let e = {};
1361
+ e["lasso-tool"] = {
1362
+ group: Qt,
1363
+ title: "Lasso",
1364
+ html: tn(Zt("square-dashed-mouse-pointer"), !1),
1365
+ action: { click: (e) => this.lassoTool.activateSelection(e) }
1366
+ };
1367
+ for (let t of n) {
1368
+ let n = (e) => {
1369
+ let n = this.factory.createNewContext(t.type, t.label);
1370
+ rn(e) ? this.placeInFreeRect(n) : this.create.start(e, n);
1371
+ };
1372
+ e[`context.${t.type}`] = {
1373
+ group: $t,
1374
+ title: nn(t.label),
1375
+ html: tn(V(t.type), !0),
1376
+ action: {
1377
+ dragstart: n,
1378
+ click: n
1379
+ }
1380
+ };
1381
+ }
1382
+ return e;
1383
+ }
1384
+ placeInFreeRect(e) {
1385
+ if (this.readOnly.isReadOnly()) return;
1386
+ let t = this.config?.freeRectCenter?.(), n = t ? {
1387
+ x: t.x,
1388
+ y: t.y
1389
+ } : this.freeRectCentre(), r = (e) => this.elementRegistry.filter((e) => T(e)).some((t) => {
1390
+ let n = t;
1391
+ return Math.abs(n.x + n.width / 2 - e.x) < 1 && Math.abs(n.y + n.height / 2 - e.y) < 1;
1392
+ });
1393
+ for (; r(n);) n.x += en, n.y += en;
1394
+ let i = this.modeling.createShape(e, n, this.canvas.getRootElement());
1395
+ this.selection.select(i), this.canvas.focus(), this.labelEditing.activate(i);
1396
+ }
1397
+ freeRectCentre() {
1398
+ let e = this.canvas.viewbox(), t = this.config?.freeRectInsets?.() ?? {
1399
+ top: 0,
1400
+ right: 0,
1401
+ bottom: 0,
1402
+ left: 0
1403
+ }, n = Math.max(0, e.outer.width - t.left - t.right), r = Math.max(0, e.outer.height - t.top - t.bottom);
1404
+ return {
1405
+ x: e.x + (t.left + n / 2) / e.scale,
1406
+ y: e.y + (t.top + r / 2) / e.scale
1407
+ };
1408
+ }
1409
+ }, on = {
1410
+ __depends__: [
1411
+ be,
1412
+ xe,
1413
+ C,
1414
+ Se,
1415
+ S,
1416
+ x,
1417
+ z,
1418
+ R
1419
+ ],
1420
+ __init__: ["cmPaletteProvider"],
1421
+ cmPaletteProvider: ["type", an]
1422
+ }, sn = "cm-subdomain-menu", cn = "cm-pattern-menu", G = "cm-roles-menu", K = "cm-popup-active", q = 8, ln = {
1131
1423
  OHS: "Open Host Service is one-size-fits-all and not applicable in a customer-supplier relationship.",
1132
1424
  CF: "Conformist is not applicable in a customer-supplier relationship — a customer can negotiate."
1133
1425
  };
1134
- function Y(e, t, n = {}) {
1135
- let r = n.draggable ? " draggable=\"true\"" : "";
1136
- return `<div class="entry cm-pad-entry${n.danger ? " cm-pad-entry--danger" : ""}"${r} title="${t}">${e}</div>`;
1426
+ function un(e) {
1427
+ return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1428
+ }
1429
+ function J(e, t, n = {}) {
1430
+ let r = n.draggable ? " draggable=\"true\"" : "", i = n.danger ? " cm-pad-entry--danger" : "", a = un(t);
1431
+ return `<div class="entry cm-pad-entry${i}"${r} title="${a}" aria-label="${a}">${e}</div>`;
1137
1432
  }
1138
- var Rt = class {
1433
+ function dn(e, t) {
1434
+ let n = t.getBoundingClientRect();
1435
+ e.style.left = `${n.right + q}px`, e.style.top = `${n.top}px`;
1436
+ let r = e.getBoundingClientRect();
1437
+ r.right > window.innerWidth - 8 && (e.style.left = `${Math.max(8, n.left - r.width - q)}px`), r.bottom > window.innerHeight - 8 && (e.style.top = `${Math.max(8, window.innerHeight - 8 - r.height)}px`);
1438
+ }
1439
+ var fn = class {
1139
1440
  contextPad;
1140
1441
  popupMenu;
1141
1442
  eventBus;
@@ -1150,6 +1451,7 @@ var Rt = class {
1150
1451
  selection;
1151
1452
  canvas;
1152
1453
  scheduler;
1454
+ readOnly;
1153
1455
  static $inject = [
1154
1456
  "contextPad",
1155
1457
  "popupMenu",
@@ -1165,16 +1467,24 @@ var Rt = class {
1165
1467
  "cmElementFactory",
1166
1468
  "selection",
1167
1469
  "canvas",
1168
- "scheduler"
1470
+ "scheduler",
1471
+ "cmReadOnly"
1169
1472
  ];
1170
1473
  currentMenu;
1171
- constructor(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m) {
1172
- this.contextPad = e, this.popupMenu = t, this.eventBus = n, this.create = i, this.autoPlace = a, this.rules = o, this.dragging = s, this.modeling = c, this.cmModeling = l, this.labelEditing = u, this.elementFactory = d, this.selection = f, this.canvas = p, this.scheduler = m, e.registerProvider(this), t.registerProvider(G, { getPopupMenuEntries: (e) => this.subdomainMenuEntries(e) }), t.registerProvider(It, { getPopupMenuEntries: (e) => this.patternMenuEntries(e) }), t.registerProvider(K, { getPopupMenuEntries: (e) => this.rolesMenuEntries(e) }), n.on("autoPlace", (e) => {
1474
+ constructor(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
1475
+ this.contextPad = e, this.popupMenu = t, this.eventBus = n, this.create = i, this.autoPlace = a, this.rules = o, this.dragging = s, this.modeling = c, this.cmModeling = l, this.labelEditing = u, this.elementFactory = d, this.selection = f, this.canvas = p, this.scheduler = m, this.readOnly = h, e.registerProvider(this), n.on("contextPad.open.allowed", 2e3, () => !this.readOnly.isReadOnly() && void 0), n.on(L, (n) => {
1476
+ if (n.readOnly) {
1477
+ this.cancelPrompt(), t.close(), e.close();
1478
+ return;
1479
+ }
1480
+ let r = f.get();
1481
+ r.length === 1 ? e.open(r[0], !0) : r.length > 1 && e.open(r, !0);
1482
+ }), t.registerProvider(sn, { getPopupMenuEntries: (e) => this.subdomainMenuEntries(e) }), t.registerProvider(cn, { getPopupMenuEntries: (e) => this.patternMenuEntries(e) }), t.registerProvider(G, { getPopupMenuEntries: (e) => this.rolesMenuEntries(e) }), n.on("autoPlace", (e) => {
1173
1483
  let { source: t, shape: n } = e, r = {
1174
- x: ee(t).right + ve + n.width / 2,
1484
+ x: ce(t).right + De + n.width / 2,
1175
1485
  y: _(t).y
1176
1486
  };
1177
- return ye(t, n, r, be({ y: {
1487
+ return Oe(t, n, r, ke({ y: {
1178
1488
  margin: 30,
1179
1489
  minDistance: 30
1180
1490
  } }));
@@ -1182,7 +1492,7 @@ var Rt = class {
1182
1492
  let { pad: t, target: n } = e;
1183
1493
  if (!t) return;
1184
1494
  let r = !1, i = !1;
1185
- if (O(n)) {
1495
+ if (E(n)) {
1186
1496
  let e = n.waypoints ?? [], t = e[e.length - 1], a = e[e.length - 2];
1187
1497
  if (t && a) {
1188
1498
  let e = t.x - a.x, n = t.y - a.y;
@@ -1211,18 +1521,19 @@ var Rt = class {
1211
1521
  }, "cmContextPad#clampIntoView");
1212
1522
  }
1213
1523
  getContextPadEntries(e) {
1214
- return D(e) ? this.contextEntries(e) : O(e) ? this.relationshipEntries(e) : {};
1524
+ return this.readOnly.isReadOnly() ? {} : T(e) ? this.contextEntries(e) : E(e) ? this.relationshipEntries(e) : {};
1215
1525
  }
1216
1526
  getMultiElementContextPadEntries(e) {
1217
- let t = e.filter(E);
1527
+ if (this.readOnly.isReadOnly()) return {};
1528
+ let t = e.filter(w);
1218
1529
  return t.length === e.length ? { delete: this.deleteEntry(t, "Delete selection") } : {};
1219
1530
  }
1220
1531
  contextEntries(e) {
1221
- let t = e.subdomainType ? u[e.subdomainType] : void 0;
1532
+ let t = e.subdomainType ? p[e.subdomainType] : void 0;
1222
1533
  return {
1223
1534
  "append-context": {
1224
1535
  group: "edit",
1225
- html: Y(U(Ct), "Append a connected context — click to place automatically, drag to position", { draggable: !0 }),
1536
+ html: J(W("square-plus"), "Append a connected context — click to place automatically, drag to position", { draggable: !0 }),
1226
1537
  action: {
1227
1538
  click: () => this.appendContext(e),
1228
1539
  dragstart: (t) => this.startAppend(t, e)
@@ -1230,7 +1541,7 @@ var Rt = class {
1230
1541
  },
1231
1542
  connect: {
1232
1543
  group: "edit",
1233
- html: Y(U(vt), "Connect to another context", { draggable: !0 }),
1544
+ html: J(W("arrow-right"), "Connect to another context", { draggable: !0 }),
1234
1545
  action: {
1235
1546
  click: (t) => this.startConnect(t, e, !0),
1236
1547
  dragstart: (t) => this.startConnect(t, e, !1)
@@ -1238,12 +1549,12 @@ var Rt = class {
1238
1549
  },
1239
1550
  "subdomain-type": {
1240
1551
  group: "edit",
1241
- html: Y(B(e.subdomainType), `Change subdomain type — currently ${t?.label ?? "unclassified"}`),
1242
- action: { click: (t) => this.openMenu(t, e, G, "Subdomain type") }
1552
+ html: J(V(e.subdomainType), `Change subdomain type — currently ${t?.label ?? "unclassified"}`),
1553
+ action: { click: (t) => this.openMenu(t, e, sn, "Subdomain type") }
1243
1554
  },
1244
1555
  team: {
1245
1556
  group: "edit",
1246
- html: Y(U(Tt), `Set owning team — currently ${e.team ?? "none"}`),
1557
+ html: J(W("users"), `Set owning team — currently ${e.team ?? "none"}`),
1247
1558
  action: { click: () => this.labelEditing.activateTeam(e) }
1248
1559
  },
1249
1560
  "edit-label": this.editLabelEntry(e, "Rename context"),
@@ -1292,36 +1603,36 @@ var Rt = class {
1292
1603
  this.scheduler.schedule(() => {
1293
1604
  if (!this.contextPad.isOpen(e)) return;
1294
1605
  let t = this.canvas.getContainer().querySelector(".djs-context-pad.open [data-action=\"subdomain-type\"]");
1295
- t && this.openMenuBeside(t.getBoundingClientRect(), e, G, "Subdomain type");
1606
+ t && this.openMenuBeside(t.getBoundingClientRect(), e, sn, "Subdomain type");
1296
1607
  }, "cmContextPad#openTypeMenu");
1297
1608
  }
1298
1609
  relationshipEntries(e) {
1299
- let t = l[e.pattern], n = { pattern: {
1610
+ let t = f[e.pattern], n = { pattern: {
1300
1611
  group: "edit",
1301
- html: Y(H(t?.pattern), `Change pattern — currently ${t?.label ?? e.pattern}`),
1302
- action: { click: (t) => this.openMenu(t, e, It, "Relationship pattern") }
1612
+ html: J(U(t?.pattern), `Change pattern — currently ${t?.label ?? e.pattern}`),
1613
+ action: { click: (t) => this.openMenu(t, e, cn, "Relationship pattern") }
1303
1614
  } };
1304
1615
  return t && !t.symmetric && (n.roles = {
1305
1616
  group: "edit",
1306
- html: Y(U(St), "Edit integration roles — OHS/PL upstream, ACL/CF downstream"),
1307
- action: { click: (t) => this.openMenu(t, e, K, "Integration roles") }
1617
+ html: J(W("sliders-horizontal"), "Edit integration roles — OHS/PL upstream, ACL/CF downstream"),
1618
+ action: { click: (t) => this.openMenu(t, e, G, "Integration roles") }
1308
1619
  }, n["swap-ends"] = {
1309
1620
  group: "edit",
1310
- html: Y(U(xt), "Swap ends — reverse upstream/downstream"),
1621
+ html: J(W("arrow-left-right"), "Swap ends — reverse upstream/downstream"),
1311
1622
  action: { click: () => this.cmModeling.swapEnds(e) }
1312
1623
  }), n["edit-label"] = this.editLabelEntry(e, "Edit label"), n.description = this.descriptionEntry(e, "What flows here, contracts, notes…"), n.delete = this.deleteEntry([e], "Delete relationship"), n;
1313
1624
  }
1314
1625
  editLabelEntry(e, t) {
1315
1626
  return {
1316
1627
  group: "edit",
1317
- html: Y(U(yt), `${t} — edit the name in place`),
1628
+ html: J(W("pencil"), `${t} — edit the name in place`),
1318
1629
  action: { click: () => this.labelEditing.activate(e) }
1319
1630
  };
1320
1631
  }
1321
1632
  descriptionEntry(e, t) {
1322
1633
  return {
1323
1634
  group: "edit",
1324
- html: Y(U(wt), "Edit description"),
1635
+ html: J(W("text-align-start"), "Edit description"),
1325
1636
  action: { click: (n) => this.openPrompt(n, {
1326
1637
  value: e.description ?? "",
1327
1638
  placeholder: t,
@@ -1332,36 +1643,41 @@ var Rt = class {
1332
1643
  };
1333
1644
  }
1334
1645
  activePrompt;
1646
+ cancelPrompt() {
1647
+ this.activePrompt?.cancel();
1648
+ }
1335
1649
  openPrompt(e, t) {
1336
1650
  this.activePrompt?.cancel();
1337
- let n = (e.delegateTarget ?? e.target).getBoundingClientRect(), r = document.createElement("div");
1338
- r.className = "cm-pad-prompt", r.style.left = `${n.right + J}px`, r.style.top = `${n.top}px`;
1651
+ let n = e.delegateTarget ?? e.target, r = document.createElement("div");
1652
+ r.className = "cm-pad-prompt";
1339
1653
  let i = document.createElement(t.multiline ? "textarea" : "input");
1340
1654
  if (i.className = "cm-pad-prompt__field", i.value = t.value, i.placeholder = t.placeholder, i.setAttribute("aria-label", t.label), i instanceof HTMLTextAreaElement && (i.rows = 4), r.appendChild(i), t.multiline) {
1341
1655
  let e = document.createElement("div");
1342
1656
  e.className = "cm-pad-prompt__hint", e.textContent = "Esc to cancel · ⌘/Ctrl+Enter to save", r.appendChild(e);
1343
1657
  }
1344
- this.canvas.getContainer().appendChild(r);
1345
- let a = r.getBoundingClientRect();
1346
- a.right > window.innerWidth - 8 && (r.style.left = `${Math.max(8, n.left - a.width - J)}px`), a.bottom > window.innerHeight - 8 && (r.style.top = `${Math.max(8, window.innerHeight - 8 - a.height)}px`), i.focus(), i instanceof HTMLTextAreaElement ? i.setSelectionRange(i.value.length, i.value.length) : i.select();
1347
- let o = () => l();
1348
- this.eventBus.on("canvas.viewbox.changing", o);
1349
- let s = !1, c = () => {
1350
- s || (s = !0, this.eventBus.off("canvas.viewbox.changing", o), r.remove(), this.activePrompt = void 0, this.canvas.restoreFocus?.());
1351
- }, l = () => {
1352
- if (s) return;
1658
+ this.canvas.getContainer().appendChild(r), dn(r, n), i.focus(), i instanceof HTMLTextAreaElement ? i.setSelectionRange(i.value.length, i.value.length) : i.select();
1659
+ let a = () => {
1660
+ this.scheduler.schedule(() => {
1661
+ n.isConnected && dn(r, n);
1662
+ }, "cmContextPad#placePrompt");
1663
+ };
1664
+ this.eventBus.on("canvas.viewbox.changed", 200, a);
1665
+ let o = !1, s = () => {
1666
+ o || (o = !0, this.eventBus.off("canvas.viewbox.changed", a), this.scheduler.cancel("cmContextPad#placePrompt"), r.remove(), this.activePrompt = void 0, this.canvas.restoreFocus?.());
1667
+ }, c = () => {
1668
+ if (o) return;
1353
1669
  let e = i.value.trim(), n = e !== t.value.trim();
1354
- c(), n && t.onCommit(e);
1670
+ s(), n && t.onCommit(e);
1355
1671
  };
1356
1672
  i.addEventListener("keydown", (e) => {
1357
1673
  let n = e;
1358
- n.key === "Escape" ? (n.preventDefault(), n.stopPropagation(), c()) : n.key === "Enter" && (!t.multiline || n.ctrlKey || n.metaKey) && (n.preventDefault(), l());
1359
- }), i.addEventListener("blur", l), this.activePrompt = { cancel: c };
1674
+ n.key === "Escape" ? (n.preventDefault(), n.stopPropagation(), s()) : n.key === "Enter" && (!t.multiline || n.ctrlKey || n.metaKey) && (n.preventDefault(), c());
1675
+ }), i.addEventListener("blur", c), this.activePrompt = { cancel: s };
1360
1676
  }
1361
1677
  deleteEntry(e, t) {
1362
1678
  return {
1363
1679
  group: "delete",
1364
- html: Y(U(bt), t, { danger: !0 }),
1680
+ html: J(W("trash"), t, { danger: !0 }),
1365
1681
  action: { click: () => this.modeling.removeElements(e) }
1366
1682
  };
1367
1683
  }
@@ -1371,12 +1687,12 @@ var Rt = class {
1371
1687
  }
1372
1688
  openMenuBeside(e, t, n, r) {
1373
1689
  let i = {
1374
- x: e.right + J,
1690
+ x: e.right + q,
1375
1691
  y: e.top
1376
1692
  };
1377
1693
  this.popupMenu.open(t, n, i, { title: r });
1378
1694
  let a = document.querySelector(".djs-popup"), o = a?.getBoundingClientRect();
1379
- a && o && o.left < e.right && (i.x = Math.max(J, e.left - J - o.width), a.style.left = `${i.x}px`), this.currentMenu = {
1695
+ a && o && o.left < e.right && (i.x = Math.max(q, e.left - q - o.width), a.style.left = `${i.x}px`), this.currentMenu = {
1380
1696
  element: t,
1381
1697
  menuId: n,
1382
1698
  title: r,
@@ -1385,221 +1701,152 @@ var Rt = class {
1385
1701
  }
1386
1702
  reopenMenu(e, t) {
1387
1703
  let n = this.currentMenu;
1388
- !n || n.menuId !== t || n.element !== e || this.popupMenu.open(e, t, n.position, { title: n.title });
1704
+ n && n.menuId === t && n.element === e && this.popupMenu.open(e, t, n.position, { title: n.title });
1389
1705
  }
1390
1706
  subdomainMenuEntries(e) {
1391
- if (!D(e)) return {};
1392
- let t = e.subdomainType, n = {};
1393
- for (let i of r) n[`type-${i.type}`] = {
1707
+ if (!T(e)) return {};
1708
+ let t = e.subdomainType, r = {};
1709
+ for (let i of n) r[`type-${i.type}`] = {
1394
1710
  label: i.label,
1395
1711
  description: i.description,
1396
- imageHtml: B(i.type),
1397
- ...i.type === t ? { className: q } : {},
1712
+ imageHtml: V(i.type),
1713
+ ...i.type === t ? { className: K } : {},
1398
1714
  action: () => {
1399
1715
  i.type !== t && this.cmModeling.setSubdomainType(e, i.type);
1400
1716
  }
1401
1717
  };
1402
- return n["type-none"] = {
1718
+ return r["type-none"] = {
1403
1719
  label: "Unclassified",
1404
1720
  description: "No subdomain classification.",
1405
- imageHtml: B(),
1406
- ...t === void 0 ? { className: q } : {},
1721
+ imageHtml: V(),
1722
+ ...t === void 0 ? { className: K } : {},
1407
1723
  action: () => {
1408
1724
  t !== void 0 && this.cmModeling.setSubdomainType(e, void 0);
1409
1725
  }
1410
- }, n;
1726
+ }, r;
1411
1727
  }
1412
1728
  patternMenuEntries(e) {
1413
- if (!O(e)) return {};
1414
- let t = e.pattern, r = {};
1415
- for (let i of n) r[`pattern-${i.pattern}`] = {
1729
+ if (!E(e)) return {};
1730
+ let n = e.pattern, r = {};
1731
+ for (let i of t) r[`pattern-${i.pattern}`] = {
1416
1732
  label: i.label,
1417
1733
  description: i.description,
1418
- imageHtml: H(i.pattern),
1419
- ...i.pattern === t ? { className: q } : {},
1734
+ imageHtml: U(i.pattern),
1735
+ ...i.pattern === n ? { className: K } : {},
1420
1736
  action: () => {
1421
- i.pattern !== t && this.cmModeling.setPattern(e, i.pattern);
1737
+ i.pattern !== n && this.cmModeling.setPattern(e, i.pattern);
1422
1738
  }
1423
1739
  };
1424
1740
  return r;
1425
1741
  }
1426
1742
  rolesMenuEntries(e) {
1427
- if (!O(e)) return {};
1428
- let t = l[e.pattern];
1743
+ if (!E(e)) return {};
1744
+ let t = f[e.pattern];
1429
1745
  if (!t || t.symmetric) return {};
1430
- let n = e.pattern === "customer-supplier", r = e.upstreamRoles ?? [], i = e.downstreamRoles ?? [], s = {};
1431
- for (let t of d) {
1432
- let i = r.includes(t), a = n ? Lt[t] : void 0, o = a !== void 0 && !i;
1433
- s[`upstream-${t}`] = {
1434
- label: f[t].label,
1435
- description: a ? i ? `${a} Click to remove it.` : a : f[t].description,
1436
- imageHtml: V(t),
1746
+ let n = e.pattern === "customer-supplier", r = e.upstreamRoles ?? [], i = e.downstreamRoles ?? [], a = {};
1747
+ for (let t of m) {
1748
+ let i = r.includes(t), o = n ? ln[t] : void 0, s = o !== void 0 && !i;
1749
+ a[`upstream-${t}`] = {
1750
+ label: h[t].label,
1751
+ description: o ? i ? `${o} Click to remove it.` : o : h[t].description,
1752
+ imageHtml: H(t),
1437
1753
  group: {
1438
1754
  id: "upstream",
1439
1755
  name: "Upstream (from) — OHS and/or PL"
1440
1756
  },
1441
- ...o ? { disabled: !0 } : {},
1442
- ...i ? { className: q } : {},
1757
+ ...s ? { disabled: !0 } : {},
1758
+ ...i ? { className: K } : {},
1443
1759
  action: () => {
1444
- o || (this.cmModeling.setUpstreamRoles(e, i ? r.filter((e) => e !== t) : [...r, t]), this.reopenMenu(e, K));
1760
+ s || (this.cmModeling.setUpstreamRoles(e, i ? r.filter((e) => e !== t) : [...r, t]), this.reopenMenu(e, G));
1445
1761
  }
1446
1762
  };
1447
1763
  }
1448
- for (let t of a) {
1449
- let r = i.includes(t), a = n ? Lt[t] : void 0, c = a !== void 0 && !r;
1450
- s[`downstream-${t}`] = {
1451
- label: o[t].label,
1452
- description: a ? r ? `${a} Click to remove it.` : a : o[t].description,
1453
- imageHtml: V(t),
1764
+ for (let t of s) {
1765
+ let r = i.includes(t), o = n ? ln[t] : void 0, s = o !== void 0 && !r;
1766
+ a[`downstream-${t}`] = {
1767
+ label: c[t].label,
1768
+ description: o ? r ? `${o} Click to remove it.` : o : c[t].description,
1769
+ imageHtml: H(t),
1454
1770
  group: {
1455
1771
  id: "downstream",
1456
1772
  name: "Downstream (to) — ACL or CF, not both"
1457
1773
  },
1458
- ...c ? { disabled: !0 } : {},
1459
- ...r ? { className: q } : {},
1774
+ ...s ? { disabled: !0 } : {},
1775
+ ...r ? { className: K } : {},
1460
1776
  action: () => {
1461
- c || (this.cmModeling.setDownstreamRoles(e, r ? [] : [t]), this.reopenMenu(e, K));
1777
+ s || (this.cmModeling.setDownstreamRoles(e, r ? [] : [t]), this.reopenMenu(e, G));
1462
1778
  }
1463
1779
  };
1464
1780
  }
1465
- return s;
1781
+ return a;
1466
1782
  }
1467
- }, zt = {
1783
+ }, pn = {
1468
1784
  __depends__: [
1469
- me,
1470
- he,
1471
- w,
1472
- fe,
1473
- ge,
1785
+ we,
1786
+ Te,
1787
+ C,
1788
+ xe,
1789
+ Ee,
1790
+ x,
1474
1791
  S,
1475
- ie,
1476
- L,
1477
- R,
1478
- W
1792
+ F,
1793
+ I,
1794
+ z,
1795
+ R
1479
1796
  ],
1480
1797
  __init__: ["cmContextPadProvider"],
1481
- cmContextPadProvider: ["type", Rt]
1482
- }, Bt = [
1483
- {
1484
- token: "OHS",
1485
- ...f.OHS
1486
- },
1487
- {
1488
- token: "PL",
1489
- ...f.PL
1490
- },
1491
- {
1492
- token: "ACL",
1493
- ...o.ACL
1494
- },
1495
- {
1496
- token: "CF",
1497
- ...o.CF
1498
- }
1499
- ];
1500
- function X(e, t, n) {
1501
- let r = document.createElement("div");
1502
- r.className = "cm-legend__row cm-legend-item";
1503
- let i = document.createElement("span");
1504
- i.textContent = t;
1505
- let a = document.createElement("span");
1506
- return a.className = "cm-legend-tip", a.textContent = n, r.addEventListener("mouseenter", () => {
1507
- let e = r.getBoundingClientRect();
1508
- a.style.left = `${e.right + 10}px`, a.style.top = `${e.top + e.height / 2}px`;
1509
- }), r.append(e, i, a), r;
1510
- }
1511
- function Vt(e) {
1512
- let t = document.createElement("span");
1513
- return t.className = "cm-legend__icon", t.innerHTML = e, t;
1514
- }
1515
- function Ht(e) {
1516
- let t = document.createElement("span");
1517
- return t.className = "cm-legend__mark", t.style.background = s[e], t.textContent = e, t;
1518
- }
1519
- function Z(e, t) {
1520
- let n = document.createElement("div");
1521
- return n.className = "cm-legend__group", n.setAttribute("aria-label", e), n.append(...t), n;
1522
- }
1523
- function Ut() {
1524
- let e = document.createElement("div");
1525
- return e.className = "cm-legend__divider", e;
1526
- }
1527
- var Wt = class {
1528
- static $inject = ["canvas", "eventBus"];
1529
- openState = !0;
1530
- host;
1531
- constructor(e, t) {
1532
- this.host = document.createElement("div"), e.getContainer().appendChild(this.host), this.render(), t.on("diagram.destroy", () => this.host.remove());
1533
- }
1534
- isOpen() {
1535
- return this.openState;
1536
- }
1537
- setOpen(e) {
1538
- this.openState !== e && (this.openState = e, this.render());
1539
- }
1540
- toggle() {
1541
- this.setOpen(!this.openState);
1542
- }
1543
- render() {
1544
- let e = this.host.contains(this.host.ownerDocument.activeElement);
1545
- this.host.replaceChildren(this.openState ? this.panel() : this.collapsedButton()), e && this.host.querySelector(".cm-legend__close, .cm-legend-toggle")?.focus();
1546
- }
1547
- panel() {
1548
- let e = document.createElement("div");
1549
- e.className = "cm-legend", e.setAttribute("aria-label", "Legend");
1550
- let t = document.createElement("div");
1551
- t.className = "cm-legend__head";
1552
- let i = document.createElement("strong");
1553
- i.textContent = "Legend";
1554
- let a = document.createElement("button");
1555
- a.type = "button", a.className = "cm-legend__close", a.setAttribute("aria-expanded", "true"), a.setAttribute("aria-label", "Collapse legend"), a.textContent = "–", a.addEventListener("click", () => this.toggle()), t.append(i, a);
1556
- let o = Z("Subdomain types", r.map((e) => X(Vt(_t(e.type)), e.label, e.description))), s = Z("Integration roles", Bt.map((e) => X(Ht(e.token), e.label, `${e.label} — ${e.description}`))), c = Z("Relationship patterns", n.map((e) => X(Vt(H(e.pattern, 18)), `${e.abbreviation} · ${e.label}`, e.description))), l = document.createElement("div");
1557
- return l.className = "cm-legend__body", l.append(o, Ut(), s, Ut(), c), e.append(t, l), e;
1558
- }
1559
- collapsedButton() {
1560
- let e = document.createElement("button");
1561
- e.type = "button", e.className = "cm-legend-toggle", e.setAttribute("aria-expanded", "false"), e.setAttribute("aria-label", "Show legend");
1562
- let t = document.createElement("span");
1563
- t.setAttribute("aria-hidden", "true"), t.textContent = "▤";
1564
- let n = document.createElement("span");
1565
- return n.textContent = "Legend", e.append(t, n), e.addEventListener("click", () => this.toggle()), e;
1566
- }
1567
- }, Gt = {
1568
- __init__: ["cmLegend"],
1569
- cmLegend: ["type", Wt]
1798
+ cmContextPadProvider: ["type", fn]
1570
1799
  };
1571
1800
  //#endregion
1572
1801
  //#region src/keyboard/CmKeyboard.ts
1573
- function Kt(e) {
1802
+ function mn(e) {
1574
1803
  let t = e;
1575
1804
  return t ? t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.tagName === "SELECT" || t.isContentEditable : !1;
1576
1805
  }
1577
- var qt = class {
1806
+ function hn(e, t) {
1807
+ if (!(e instanceof Node) || e instanceof Element && e.closest(".djs-palette")) return !1;
1808
+ let n = t.ownerDocument;
1809
+ return t.contains(e) || e === n.body || e === n.documentElement;
1810
+ }
1811
+ var gn = class {
1578
1812
  static $inject = [
1813
+ "config.cmKeyboard",
1579
1814
  "canvas",
1580
1815
  "commandStack",
1581
1816
  "selection",
1582
- "modeling"
1817
+ "modeling",
1818
+ "elementRegistry",
1819
+ "eventBus",
1820
+ "cmReadOnly"
1583
1821
  ];
1584
- constructor(e, t, n, r) {
1585
- (e.getContainer().ownerDocument ?? document).addEventListener("keydown", (e) => {
1586
- if (Kt(e.target)) return;
1587
- let i = e.ctrlKey || e.metaKey, a = e.key.toLowerCase();
1588
- if (i && a === "z" && !e.shiftKey) e.preventDefault(), t.canUndo() && t.undo();
1589
- else if (i && a === "z" && e.shiftKey || i && a === "y") e.preventDefault(), t.canRedo() && t.redo();
1590
- else if (a === "delete" || a === "backspace") {
1591
- let t = n.get();
1592
- t.length && (e.preventDefault(), r.removeElements([...t]));
1822
+ constructor(e, t, n, r, i, a, o, s) {
1823
+ let c = t.getContainer(), l = c.ownerDocument ?? document, u = e?.undoRedoKeys ?? !0, d = (e) => {
1824
+ if (e.defaultPrevented || !hn(e.target, c) || mn(e.target)) return;
1825
+ let t = e.ctrlKey || e.metaKey, o = e.key.toLowerCase();
1826
+ if (t && o === "a" && !e.shiftKey && !e.altKey) {
1827
+ e.preventDefault(), r.select(a.filter((e) => w(e)));
1828
+ return;
1593
1829
  }
1594
- });
1830
+ if (s.isReadOnly()) return;
1831
+ let l = t && o === "z" && !e.shiftKey, d = t && o === "z" && e.shiftKey || t && o === "y" && !e.shiftKey;
1832
+ if (l || d) {
1833
+ if (!u) return;
1834
+ e.preventDefault(), l && n.canUndo() && n.undo(), d && n.canRedo() && n.redo();
1835
+ } else if (o === "delete" || o === "backspace") {
1836
+ let t = r.get();
1837
+ t.length && (e.preventDefault(), i.removeElements([...t]));
1838
+ }
1839
+ };
1840
+ l.addEventListener("keydown", d), o.on("diagram.destroy", () => l.removeEventListener("keydown", d));
1595
1841
  }
1596
- }, Jt = {
1842
+ }, _n = {
1843
+ __depends__: [R],
1597
1844
  __init__: ["cmKeyboard"],
1598
- cmKeyboard: ["type", qt]
1599
- }, Yt = "cm-validation", Q = 20, $ = 16, Xt = 44, Zt = "#d97706", Qt = "#dc2626";
1600
- function $t(e) {
1601
- let t = e.some((e) => e.kind === "error") ? Qt : Zt, n = document.createElement("div");
1602
- n.className = "cm-validation-marker", n.innerHTML = `<svg width="${Q}" height="${Q}" viewBox="0 0 24 24"><path d="M12 2.5 23 21.5H1Z" fill="${t}" stroke="#fff" stroke-width="1.6" stroke-linejoin="round"/><text x="12" y="18.5" text-anchor="middle" font-size="12" font-weight="800" fill="#fff" font-family="system-ui, sans-serif">!</text></svg>`;
1845
+ cmKeyboard: ["type", gn]
1846
+ }, vn = "cm-validation", yn = 22, Y = 16, bn = 44;
1847
+ function xn(e) {
1848
+ let t = e.some((e) => e.kind === "error"), n = document.createElement("div");
1849
+ n.className = "cm-validation-marker", n.dataset.severity = t ? "error" : "warning", n.innerHTML = W(t ? "circle-x" : "triangle-alert");
1603
1850
  let r = document.createElement("div");
1604
1851
  r.className = "cm-validation-tooltip";
1605
1852
  for (let t of e) {
@@ -1608,13 +1855,13 @@ function $t(e) {
1608
1855
  }
1609
1856
  return n.appendChild(r), n;
1610
1857
  }
1611
- function en(e, t, n) {
1858
+ function Sn(e, t, n) {
1612
1859
  let r = t[0], i = t[t.length - 1], a = i.x - r.x, o = i.y - r.y, s = Math.hypot(a, o) || 1, c = a / s, l = o / s;
1613
1860
  if (n === "middle") return {
1614
- x: (r.x + i.x) / 2 + -l * $,
1615
- y: (r.y + i.y) / 2 + c * $
1861
+ x: (r.x + i.x) / 2 + -l * Y,
1862
+ y: (r.y + i.y) / 2 + c * Y
1616
1863
  };
1617
- let u = e.pattern === "customer-supplier", d = n === "upstream" ? P(r, i, u ? "S" : "U", e.upstreamRoles ?? []) : P(i, r, u ? "C" : "D", e.downstreamRoles ?? []);
1864
+ let u = e.pattern === "customer-supplier", d = n === "upstream" ? M(r, i, u ? "S" : "U", e.upstreamRoles ?? []) : M(i, r, u ? "C" : "D", e.downstreamRoles ?? []);
1618
1865
  if (d) {
1619
1866
  let e = {
1620
1867
  x: d.box.x + d.box.width,
@@ -1625,16 +1872,16 @@ function en(e, t, n) {
1625
1872
  y: e.y + 1
1626
1873
  };
1627
1874
  }
1628
- let f = Math.min(Xt, s * .35), p = n === "upstream" ? r.x + c * f : i.x - c * f, m = n === "upstream" ? r.y + l * f : i.y - l * f;
1875
+ let f = Math.min(bn, s * .35), p = n === "upstream" ? r.x + c * f : i.x - c * f, m = n === "upstream" ? r.y + l * f : i.y - l * f;
1629
1876
  return {
1630
- x: p + -l * $,
1631
- y: m + c * $
1877
+ x: p + -l * Y,
1878
+ y: m + c * Y
1632
1879
  };
1633
1880
  }
1634
1881
  //#endregion
1635
1882
  //#region src/validation/index.ts
1636
- var tn = {
1637
- __depends__: [xe],
1883
+ var Cn = {
1884
+ __depends__: [Ae],
1638
1885
  __init__: ["cmValidationMarkers"],
1639
1886
  cmValidationMarkers: ["type", class {
1640
1887
  elementRegistry;
@@ -1652,8 +1899,8 @@ var tn = {
1652
1899
  e.on("import.render.done", i), e.on("commandStack.changed", i);
1653
1900
  }
1654
1901
  refresh() {
1655
- this.overlays.remove({ type: Yt });
1656
- let e = h(this.exporter.export()), t = /* @__PURE__ */ new Map(), n = (e, n) => {
1902
+ this.overlays.remove({ type: vn });
1903
+ let e = ae(this.exporter.export()), t = /* @__PURE__ */ new Map(), n = (e, n) => {
1657
1904
  for (let r of e) {
1658
1905
  if (!r.relationshipId) continue;
1659
1906
  let e = `${r.relationshipId} ${r.side ?? "middle"}`, i = t.get(e) ?? {
@@ -1669,16 +1916,16 @@ var tn = {
1669
1916
  n(e.errors, "error"), n(e.warnings, "warning");
1670
1917
  for (let [e, n] of t) {
1671
1918
  let t = this.elementRegistry.get(n.relationshipId);
1672
- if (!O(t)) continue;
1919
+ if (!E(t)) continue;
1673
1920
  let r = t.waypoints ?? [];
1674
1921
  if (r.length < 2) continue;
1675
- let i = e.split(" ")[1], { x: a, y: o } = en(t, r, i), s = Math.min(...r.map((e) => e.x)), c = Math.min(...r.map((e) => e.y));
1676
- this.overlays.add(t, Yt, {
1922
+ let i = e.split(" ")[1], { x: a, y: o } = Sn(t, r, i), s = Math.min(...r.map((e) => e.x)), c = Math.min(...r.map((e) => e.y));
1923
+ this.overlays.add(t, vn, {
1677
1924
  position: {
1678
- left: a - s - Q / 2,
1679
- top: o - c - Q / 2
1925
+ left: a - s - yn / 2,
1926
+ top: o - c - yn / 2
1680
1927
  },
1681
- html: $t(n.findings)
1928
+ html: xn(n.findings)
1682
1929
  });
1683
1930
  }
1684
1931
  }
@@ -1686,10 +1933,10 @@ var tn = {
1686
1933
  };
1687
1934
  //#endregion
1688
1935
  //#region src/zorder/CmZOrder.ts
1689
- function nn(e) {
1690
- return +!O(e);
1936
+ function wn(e) {
1937
+ return +!E(e);
1691
1938
  }
1692
- var rn = class {
1939
+ var Tn = class {
1693
1940
  canvas;
1694
1941
  elementRegistry;
1695
1942
  static $inject = [
@@ -1708,33 +1955,33 @@ var rn = class {
1708
1955
  });
1709
1956
  }
1710
1957
  reorder() {
1711
- let e = this.elementRegistry.getAll().filter(E).sort((e, t) => nn(e) - nn(t));
1958
+ let e = this.elementRegistry.getAll().filter(w).sort((e, t) => wn(e) - wn(t));
1712
1959
  for (let t of e) {
1713
1960
  let e = this.canvas.getGraphics(t)?.parentNode, n = e?.parentNode;
1714
1961
  e && n && n.appendChild(e);
1715
1962
  }
1716
1963
  }
1717
- }, an = {
1964
+ }, En = {
1718
1965
  __init__: ["cmZOrder"],
1719
- cmZOrder: ["type", rn]
1720
- }, on = class extends $e {
1966
+ cmZOrder: ["type", Tn]
1967
+ }, Dn = class extends P {
1721
1968
  _getModules() {
1722
1969
  return [
1723
1970
  ...super._getModules(),
1724
- re,
1725
- ie,
1726
- ae,
1727
- oe,
1728
- L,
1971
+ pe,
1972
+ S,
1973
+ me,
1974
+ he,
1729
1975
  R,
1730
- pt,
1731
- jt,
1732
- zt,
1733
- Gt,
1734
- W,
1735
- Jt,
1736
- tn,
1737
- an
1976
+ F,
1977
+ I,
1978
+ It,
1979
+ on,
1980
+ pn,
1981
+ z,
1982
+ _n,
1983
+ Cn,
1984
+ En
1738
1985
  ];
1739
1986
  }
1740
1987
  undo() {
@@ -1749,7 +1996,131 @@ var rn = class {
1749
1996
  canRedo() {
1750
1997
  return this.get("commandStack").canRedo();
1751
1998
  }
1752
- }, sn = "cm-connect-handle", cn = 28, ln = 12, un = [
1999
+ }, On = "context-maps";
2000
+ function kn(e = {}) {
2001
+ return Mn(new Dn({
2002
+ ...jn(e),
2003
+ undoRedoKeys: e.undoRedoKeys ?? !0
2004
+ }), !0);
2005
+ }
2006
+ function An(e = {}) {
2007
+ return Mn(new P(jn(e)), !1);
2008
+ }
2009
+ function jn(e) {
2010
+ return {
2011
+ width: "100%",
2012
+ height: "100%",
2013
+ additionalModules: e.additionalModules ?? [],
2014
+ freeArea: e.freeArea,
2015
+ freeRectInsets: e.freeRectInsets,
2016
+ fitOnImport: e.fitOnImport
2017
+ };
2018
+ }
2019
+ function Mn(e, t) {
2020
+ let n = e.get("eventBus"), r = e.get("canvas"), i = e.get("elementRegistry"), a = e.get("selection"), o = /* @__PURE__ */ new Set(), s = !1, c = "", l = {
2021
+ notation: On,
2022
+ apiVersion: je,
2023
+ editable: t
2024
+ };
2025
+ return t && n.on("commandStack.changed", () => {
2026
+ for (let e of [...o]) e();
2027
+ }), {
2028
+ meta: l,
2029
+ elements: {
2030
+ list: () => s ? [] : i.getAll().filter(w).map(Fn),
2031
+ bounds(e) {
2032
+ if (s) return;
2033
+ let t = i.get(e);
2034
+ return w(t) ? Pn(t) : void 0;
2035
+ },
2036
+ reveal(e) {
2037
+ if (s) return !1;
2038
+ let t = i.get(e);
2039
+ return w(t) ? (a.select(t), r.scrollToElement(t), !0) : !1;
2040
+ },
2041
+ selection: () => s ? [] : Nn(a.get()),
2042
+ onSelection(e) {
2043
+ let t = (t) => e(Nn(t.newSelection ?? []));
2044
+ return n.on("selection.changed", t), () => n.off("selection.changed", t);
2045
+ }
2046
+ },
2047
+ diagram: e,
2048
+ attachTo(t) {
2049
+ e.attachTo(t);
2050
+ },
2051
+ async importText(t) {
2052
+ if (s) throw Error("The modeler was destroyed.");
2053
+ let { warnings: n } = e.importText(t);
2054
+ return { warnings: n.map((e) => e.message) };
2055
+ },
2056
+ exportText() {
2057
+ return s ? c : e.exportText();
2058
+ },
2059
+ onContentChanged(e) {
2060
+ return t ? (o.add(e), () => o.delete(e)) : () => void 0;
2061
+ },
2062
+ getViewState() {
2063
+ if (!s) try {
2064
+ let { x: e, y: t, width: n, height: i } = r.viewbox(), a = {
2065
+ x: e,
2066
+ y: t,
2067
+ width: n,
2068
+ height: i
2069
+ };
2070
+ return In(a) ? a : void 0;
2071
+ } catch {
2072
+ return;
2073
+ }
2074
+ },
2075
+ setViewState(e) {
2076
+ !s && In(e) && r.viewbox({
2077
+ x: e.x,
2078
+ y: e.y,
2079
+ width: e.width,
2080
+ height: e.height
2081
+ });
2082
+ },
2083
+ destroy() {
2084
+ if (!s) {
2085
+ try {
2086
+ c = e.exportText();
2087
+ } catch {
2088
+ c = "";
2089
+ }
2090
+ s = !0, o.clear(), e.destroy();
2091
+ }
2092
+ }
2093
+ };
2094
+ }
2095
+ function Nn(e) {
2096
+ return e.filter(w).map((e) => e.id);
2097
+ }
2098
+ function Pn(e) {
2099
+ let { x: t, y: n, width: r, height: i } = Me(e);
2100
+ return {
2101
+ x: t,
2102
+ y: n,
2103
+ width: r,
2104
+ height: i
2105
+ };
2106
+ }
2107
+ function Fn(e) {
2108
+ return e.cmLabel ? {
2109
+ id: e.id,
2110
+ name: e.cmLabel
2111
+ } : { id: e.id };
2112
+ }
2113
+ function In(e) {
2114
+ if (typeof e != "object" || !e) return !1;
2115
+ let { x: t, y: n, width: r, height: i } = e;
2116
+ return X(t) && X(n) && X(r) && X(i) && r > 0 && i > 0;
2117
+ }
2118
+ function X(e) {
2119
+ return typeof e == "number" && Number.isFinite(e);
2120
+ }
2121
+ //#endregion
2122
+ //#region src/connect-handles/CmConnectHandles.ts
2123
+ var Ln = "cm-connect-handle", Rn = 28, zn = 12, Bn = [
1753
2124
  {
1754
2125
  side: "top",
1755
2126
  rotationDeg: -90
@@ -1767,15 +2138,15 @@ var rn = class {
1767
2138
  rotationDeg: 180
1768
2139
  }
1769
2140
  ];
1770
- function dn(e, t) {
1771
- let n = t.width / 2 - cn / 2, r = t.height / 2 - cn / 2;
2141
+ function Vn(e, t) {
2142
+ let n = t.width / 2 - Rn / 2, r = t.height / 2 - Rn / 2;
1772
2143
  switch (e) {
1773
2144
  case "top": return {
1774
2145
  top: -40,
1775
2146
  left: n
1776
2147
  };
1777
2148
  case "bottom": return {
1778
- top: t.height + ln,
2149
+ top: t.height + zn,
1779
2150
  left: n
1780
2151
  };
1781
2152
  case "left": return {
@@ -1784,37 +2155,41 @@ function dn(e, t) {
1784
2155
  };
1785
2156
  case "right": return {
1786
2157
  top: r,
1787
- left: t.width + ln
2158
+ left: t.width + zn
1788
2159
  };
1789
2160
  }
1790
2161
  }
1791
- var fn = class {
2162
+ var Hn = class {
1792
2163
  eventBus;
1793
2164
  selection;
1794
2165
  overlays;
1795
2166
  dragging;
2167
+ readOnly;
1796
2168
  static $inject = [
1797
2169
  "eventBus",
1798
2170
  "selection",
1799
2171
  "overlays",
1800
2172
  "connect",
1801
- "dragging"
2173
+ "dragging",
2174
+ "cmReadOnly"
1802
2175
  ];
1803
- constructor(e, t, n, r, i) {
1804
- this.eventBus = e, this.selection = t, this.overlays = n, this.dragging = i;
1805
- let a = () => this.refresh();
1806
- e.on("selection.changed", a), e.on("commandStack.changed", a);
2176
+ constructor(e, t, n, r, i, a) {
2177
+ this.eventBus = e, this.selection = t, this.overlays = n, this.dragging = i, this.readOnly = a;
2178
+ let o = () => this.refresh();
2179
+ e.on("selection.changed", o), e.on("commandStack.changed", o), e.on(L, o);
1807
2180
  }
1808
2181
  refresh() {
1809
- this.overlays.remove({ type: sn });
2182
+ if (this.overlays.remove({ type: Ln }), this.readOnly.isReadOnly()) return;
1810
2183
  let e = this.selection.get();
1811
2184
  if (e.length !== 1) return;
1812
2185
  let t = e[0];
1813
- if (!D(t)) return;
2186
+ if (!T(t)) return;
1814
2187
  let n = t;
1815
- for (let { side: e, rotationDeg: r } of un) {
2188
+ for (let { side: e, rotationDeg: r } of Bn) {
1816
2189
  let i = document.createElement("div");
1817
- i.className = "cm-connect-handle", i.dataset.side = e, i.title = "Connect to another context", i.innerHTML = `<span style="display:flex;transform:rotate(${r}deg)">${U(vt)}</span>`, i.addEventListener("mousedown", (e) => {
2190
+ i.className = "cm-connect-handle", i.dataset.side = e, i.title = "Connect to another context", i.setAttribute("aria-label", "Connect to another context");
2191
+ let a = document.createElement("span");
2192
+ a.className = "cm-connect-handle__arrow", a.style.transform = `rotate(${r}deg)`, a.innerHTML = W("arrow-right"), i.append(a), i.addEventListener("mousedown", (e) => {
1818
2193
  e.button === 0 && (e.preventDefault(), e.stopPropagation(), this.dragging.init(e, "connect", {
1819
2194
  autoActivate: !1,
1820
2195
  trapClick: !1,
@@ -1828,22 +2203,424 @@ var fn = class {
1828
2203
  }), this.eventBus.once("connect.cleanup", 250, () => {
1829
2204
  this.selection.get().length === 0 && this.selection.select(t);
1830
2205
  }));
1831
- }), this.overlays.add(t, sn, {
1832
- position: dn(e, n),
2206
+ }), this.overlays.add(t, Ln, {
2207
+ position: Vn(e, n),
1833
2208
  html: i
1834
2209
  });
1835
2210
  }
1836
2211
  }
1837
- }, pn = {
2212
+ }, Un = {
1838
2213
  __depends__: [
1839
- w,
1840
- xe,
1841
- S
2214
+ C,
2215
+ Ae,
2216
+ x,
2217
+ R
1842
2218
  ],
1843
2219
  __init__: ["cmConnectHandles"],
1844
- cmConnectHandles: ["type", fn]
1845
- };
2220
+ cmConnectHandles: ["type", Hn]
2221
+ }, Wn = [
2222
+ {
2223
+ token: "OHS",
2224
+ ...h.OHS
2225
+ },
2226
+ {
2227
+ token: "PL",
2228
+ ...h.PL
2229
+ },
2230
+ {
2231
+ token: "ACL",
2232
+ ...c.ACL
2233
+ },
2234
+ {
2235
+ token: "CF",
2236
+ ...c.CF
2237
+ }
2238
+ ];
2239
+ function Gn() {
2240
+ return [
2241
+ {
2242
+ label: "Subdomain types",
2243
+ rows: n.map((e) => ({
2244
+ preview: V(e.type),
2245
+ label: e.label,
2246
+ explanation: e.description
2247
+ }))
2248
+ },
2249
+ {
2250
+ label: "Integration roles",
2251
+ rows: Wn.map((e) => ({
2252
+ preview: H(e.token),
2253
+ label: `${e.token} · ${e.label}`,
2254
+ explanation: e.description
2255
+ }))
2256
+ },
2257
+ {
2258
+ label: "Relationship patterns",
2259
+ rows: t.map((e) => ({
2260
+ preview: U(e.pattern),
2261
+ label: `${e.abbreviation} · ${e.label}`,
2262
+ explanation: e.description
2263
+ }))
2264
+ }
2265
+ ];
2266
+ }
2267
+ function Kn(e, t = {}) {
2268
+ let n = [];
2269
+ return Gn().forEach((r, i) => {
2270
+ if (i > 0) {
2271
+ let t = document.createElement("div");
2272
+ t.className = "cd-shell-legend-separator", t.setAttribute("role", "separator"), e.append(t);
2273
+ }
2274
+ let a = document.createElement("div");
2275
+ a.className = "cm-legend-group", a.setAttribute("role", "group"), a.setAttribute("aria-label", r.label);
2276
+ for (let e of r.rows) {
2277
+ let r = document.createElement("div");
2278
+ r.className = "cd-shell-legend-row cm-legend-row";
2279
+ let i = document.createElement("span");
2280
+ i.className = "cd-shell-legend-preview", i.innerHTML = e.preview;
2281
+ let o = document.createElement("span");
2282
+ if (o.textContent = e.label, r.append(i, o), t.tooltip) n.push(t.tooltip.attach(r, { label: e.explanation }));
2283
+ else {
2284
+ let t = document.createElement("span");
2285
+ t.className = "cm-visually-hidden", t.textContent = `: ${e.explanation}`, r.append(t);
2286
+ }
2287
+ a.append(r);
2288
+ }
2289
+ e.append(a);
2290
+ }), () => {
2291
+ for (let e of n.splice(0)) e();
2292
+ };
2293
+ }
2294
+ //#endregion
2295
+ //#region src/legend/CmLegend.ts
2296
+ function qn(e) {
2297
+ let t = document.createElement("div");
2298
+ t.className = "cm-legend__row cm-legend-item";
2299
+ let n = document.createElement("span");
2300
+ n.className = "cm-legend__icon", n.innerHTML = e.preview;
2301
+ let r = document.createElement("span");
2302
+ r.textContent = e.label;
2303
+ let i = document.createElement("span");
2304
+ return i.className = "cm-legend-tip", i.textContent = e.explanation, t.addEventListener("mouseenter", () => {
2305
+ let e = t.getBoundingClientRect();
2306
+ i.style.left = `${e.right + 10}px`, i.style.top = `${e.top + e.height / 2}px`;
2307
+ }), t.append(n, r, i), t;
2308
+ }
2309
+ function Jn(e, t) {
2310
+ let n = document.createElement("div");
2311
+ return n.className = "cm-legend__group", n.setAttribute("role", "group"), n.setAttribute("aria-label", e), n.append(...t), n;
2312
+ }
2313
+ function Yn() {
2314
+ let e = document.createElement("div");
2315
+ return e.className = "cm-legend__divider", e;
2316
+ }
2317
+ var Xn = class {
2318
+ static $inject = ["canvas", "eventBus"];
2319
+ openState = !0;
2320
+ host;
2321
+ constructor(e, t) {
2322
+ this.host = document.createElement("div"), e.getContainer().appendChild(this.host), this.render(), t.on("diagram.destroy", () => this.host.remove());
2323
+ }
2324
+ isOpen() {
2325
+ return this.openState;
2326
+ }
2327
+ setOpen(e) {
2328
+ this.openState !== e && (this.openState = e, this.render());
2329
+ }
2330
+ toggle() {
2331
+ this.setOpen(!this.openState);
2332
+ }
2333
+ render() {
2334
+ let e = this.host.contains(this.host.ownerDocument.activeElement);
2335
+ this.host.replaceChildren(this.openState ? this.panel() : this.collapsedButton()), e && this.host.querySelector(".cm-legend__close, .cm-legend-toggle")?.focus();
2336
+ }
2337
+ panel() {
2338
+ let e = document.createElement("div");
2339
+ e.className = "cm-legend", e.setAttribute("aria-label", "Legend");
2340
+ let t = document.createElement("div");
2341
+ t.className = "cm-legend__head";
2342
+ let n = document.createElement("strong");
2343
+ n.textContent = "Legend";
2344
+ let r = document.createElement("button");
2345
+ r.type = "button", r.className = "cm-legend__close", r.setAttribute("aria-expanded", "true"), r.setAttribute("aria-label", "Close legend"), r.innerHTML = W("x"), r.addEventListener("click", () => this.toggle()), t.append(n, r);
2346
+ let i = Gn().map((e) => Jn(e.label, e.rows.map(qn))), a = document.createElement("div");
2347
+ return a.className = "cm-legend__body", i.forEach((e, t) => a.append(...t > 0 ? [Yn()] : [], e)), e.append(t, a), e;
2348
+ }
2349
+ collapsedButton() {
2350
+ let e = document.createElement("button");
2351
+ return e.type = "button", e.className = "cm-legend-toggle", e.setAttribute("aria-expanded", "false"), e.setAttribute("aria-label", "Show legend"), e.textContent = "Legend", e.addEventListener("click", () => this.toggle()), e;
2352
+ }
2353
+ }, Zn = {
2354
+ __init__: ["cmLegend"],
2355
+ cmLegend: ["type", Xn]
2356
+ }, Qn = "Export as JSON";
2357
+ function Z(e, t, n, r) {
2358
+ return {
2359
+ kind: "action",
2360
+ id: e,
2361
+ label: t,
2362
+ ...r ? { icon: r } : {},
2363
+ ...n.shortcut ? { shortcut: n.shortcut } : {},
2364
+ onSelect: () => n.onSelect()
2365
+ };
2366
+ }
2367
+ function $n(e) {
2368
+ let { editTitle: t } = e;
2369
+ return {
2370
+ model: t ? [{
2371
+ kind: "dialog",
2372
+ id: "map-title",
2373
+ label: "Map title…",
2374
+ onSelect: () => t()
2375
+ }] : [],
2376
+ export: [
2377
+ Z("export-png", "Export as PNG", e.exports.png, "file-image"),
2378
+ Z("export-svg", "Export as SVG", e.exports.svg, "file-code-corner"),
2379
+ Z("export-json", Qn, e.exports.json),
2380
+ Z("export-cml", "Export as CML", e.exports.cml)
2381
+ ],
2382
+ help: [{
2383
+ kind: "dialog",
2384
+ id: "keyboard-shortcuts",
2385
+ label: "Keyboard shortcuts…",
2386
+ icon: "keyboard",
2387
+ onSelect: () => e.showKeyboardShortcuts()
2388
+ }]
2389
+ };
2390
+ }
2391
+ //#endregion
2392
+ //#region src/chrome/shortcuts.ts
2393
+ function er(e, t, n) {
2394
+ return t === "mac" ? `⌘${e}` : `${n.ctrl}+${e}`;
2395
+ }
2396
+ function tr(e) {
2397
+ try {
2398
+ return new Intl.NumberFormat(e, { style: "percent" }).format(1);
2399
+ } catch {
2400
+ return new Intl.NumberFormat("en", { style: "percent" }).format(1);
2401
+ }
2402
+ }
2403
+ function nr(e, t) {
2404
+ if (e === "mac") return {
2405
+ zoomIn: "⌘+",
2406
+ zoomOut: "⌘−",
2407
+ zoomToActual: "⌘0",
2408
+ fit: "⇧1"
2409
+ };
2410
+ let { ctrl: n, shift: r, plus: i, minus: a } = t;
2411
+ return {
2412
+ zoomIn: `${n}+${i}`,
2413
+ zoomOut: `${n}+${a}`,
2414
+ zoomToActual: `${n}+0`,
2415
+ fit: `${r}+1`
2416
+ };
2417
+ }
2418
+ function rr(e, t) {
2419
+ if (e === "mac") return {
2420
+ undo: ["⌘Z"],
2421
+ redo: ["⌘⇧Z"],
2422
+ selectAll: ["⌘A"],
2423
+ remove: ["⌫"],
2424
+ lineBreak: ["⇧Enter"],
2425
+ lassoDrag: ["⇧ Drag"]
2426
+ };
2427
+ let { ctrl: n, shift: r } = t;
2428
+ return {
2429
+ undo: [`${n}+Z`],
2430
+ redo: [`${n}+${r}+Z`, `${n}+Y`],
2431
+ selectAll: [`${n}+A`],
2432
+ remove: ["Del", "Backspace"],
2433
+ lineBreak: [`${r}+Enter`],
2434
+ lassoDrag: [`${r}+Drag`]
2435
+ };
2436
+ }
2437
+ function ir(e) {
2438
+ let { platform: t, messages: n } = e;
2439
+ return {
2440
+ title: "File",
2441
+ rows: [{
2442
+ action: n.openFile ?? "Open…",
2443
+ keys: [er("O", t, n.keyNames)]
2444
+ }, {
2445
+ action: Qn,
2446
+ keys: [er("S", t, n.keyNames)]
2447
+ }]
2448
+ };
2449
+ }
2450
+ function ar(e, t = {}) {
2451
+ let { platform: n, messages: r } = e, i = nr(n, r.keyNames), a = rr(n, r.keyNames);
2452
+ return [
2453
+ ...t.fileKeys ? [ir(e)] : [],
2454
+ {
2455
+ title: "View",
2456
+ rows: [
2457
+ {
2458
+ action: r.zoomIn,
2459
+ keys: [i.zoomIn]
2460
+ },
2461
+ {
2462
+ action: r.zoomOut,
2463
+ keys: [i.zoomOut]
2464
+ },
2465
+ {
2466
+ action: r.zoomToActual(tr(e.lang)),
2467
+ keys: [i.zoomToActual]
2468
+ },
2469
+ {
2470
+ action: r.fit,
2471
+ keys: [i.fit]
2472
+ }
2473
+ ]
2474
+ },
2475
+ {
2476
+ title: "Edit",
2477
+ rows: [
2478
+ {
2479
+ action: "Undo",
2480
+ keys: a.undo
2481
+ },
2482
+ {
2483
+ action: "Redo",
2484
+ keys: a.redo
2485
+ },
2486
+ {
2487
+ action: "Select all",
2488
+ keys: a.selectAll
2489
+ },
2490
+ {
2491
+ action: "Delete",
2492
+ keys: a.remove
2493
+ },
2494
+ {
2495
+ action: "Rename",
2496
+ keys: ["Double-click"]
2497
+ },
2498
+ {
2499
+ action: "Save a name",
2500
+ keys: ["Enter"]
2501
+ },
2502
+ {
2503
+ action: "Line break in a name",
2504
+ keys: a.lineBreak
2505
+ },
2506
+ {
2507
+ action: "Discard a name",
2508
+ keys: ["Esc"]
2509
+ }
2510
+ ]
2511
+ },
2512
+ {
2513
+ title: "Tools",
2514
+ rows: [{
2515
+ action: "Create a context from the palette",
2516
+ keys: ["Enter", "Space"]
2517
+ }, {
2518
+ action: "Lasso by dragging",
2519
+ keys: a.lassoDrag
2520
+ }]
2521
+ }
2522
+ ];
2523
+ }
2524
+ //#endregion
2525
+ //#region src/chrome/dialog.ts
2526
+ function Q(e, t, n) {
2527
+ let r = document.createElement(e);
2528
+ return r.className = t, n !== void 0 && (r.textContent = n), r;
2529
+ }
2530
+ function or(e, t, n) {
2531
+ let r = Q("header", "cm-dialog-header"), i = Q("h3", "cm-dialog-title", t.title);
2532
+ i.id = t.titleId;
2533
+ let a = Q("button", "cm-dialog-close");
2534
+ return a.type = "button", a.setAttribute("aria-label", e.messages.close), a.innerHTML = W("x"), a.addEventListener("click", n), r.append(i, a), r;
2535
+ }
2536
+ function sr(e, t) {
2537
+ let n;
2538
+ function r() {
2539
+ let n = Q("dialog", `cm-dialog ${t.className}`);
2540
+ n.setAttribute("aria-labelledby", t.titleId);
2541
+ let r = () => n.close(), i = Q("div", "cm-dialog-panel");
2542
+ return i.append(or(e, t, r), ...t.content(r)), n.append(i), n.addEventListener("click", (e) => {
2543
+ e.target === n && n.close();
2544
+ }), n.addEventListener("close", () => {
2545
+ e.menu.trigger.hidden || e.menu.trigger.focus({ preventScroll: !0 });
2546
+ }), e.root.append(n), n;
2547
+ }
2548
+ return {
2549
+ open() {
2550
+ n ??= r(), !n.open && (t.beforeOpen?.(), n.showModal(), t.afterOpen?.());
2551
+ },
2552
+ close() {
2553
+ n?.close();
2554
+ },
2555
+ isOpen: () => n?.open === !0,
2556
+ destroy() {
2557
+ n?.remove(), n = void 0;
2558
+ }
2559
+ };
2560
+ }
2561
+ //#endregion
2562
+ //#region src/chrome/ShortcutsDialog.ts
2563
+ var $ = "cm-shortcuts", cr = "cm-shortcuts-title";
2564
+ function lr(e, t) {
2565
+ let n = Q("section", `${$}-group`), r = `${cr}-group-${t}`, i = Q("h4", `${$}-group-title`, e.title);
2566
+ i.id = r;
2567
+ let a = Q("table", `${$}-table`);
2568
+ a.setAttribute("aria-labelledby", r);
2569
+ let o = a.createTBody();
2570
+ for (let t of e.rows) {
2571
+ let e = o.insertRow(), n = Q("th", `${$}-action`, t.action);
2572
+ n.scope = "row";
2573
+ let r = Q("td", `${$}-keys`);
2574
+ for (let e of t.keys) r.append(Q("kbd", `${$}-key`, e));
2575
+ e.append(n, r);
2576
+ }
2577
+ return n.append(i, a), n;
2578
+ }
2579
+ function ur(e, t = {}) {
2580
+ return sr(e, {
2581
+ className: $,
2582
+ titleId: cr,
2583
+ title: "Keyboard shortcuts",
2584
+ content() {
2585
+ let n = Q("div", "cm-dialog-body cm-shortcuts-body");
2586
+ return n.append(...ar(e, t).map(lr)), [n];
2587
+ }
2588
+ });
2589
+ }
2590
+ //#endregion
2591
+ //#region src/chrome/TitleDialog.ts
2592
+ var dr = "cm-title-dialog", fr = "cm-title-dialog-title", pr = "cm-title-dialog-field";
2593
+ function mr(e, t) {
2594
+ let n = Q("button", "cm-dialog-button", e);
2595
+ return n.type = t === "primary" ? "submit" : "button", n.dataset.variant = t, n;
2596
+ }
2597
+ function hr(e, t) {
2598
+ let n = Q("input", "cm-dialog-input");
2599
+ return n.id = pr, n.type = "text", n.autocomplete = "off", n.spellcheck = !1, n.autofocus = !0, sr(e, {
2600
+ className: dr,
2601
+ titleId: fr,
2602
+ title: "Map title",
2603
+ beforeOpen() {
2604
+ n.value = t.title();
2605
+ },
2606
+ afterOpen() {
2607
+ n.select();
2608
+ },
2609
+ content(e) {
2610
+ let r = Q("form", "cm-dialog-form");
2611
+ r.noValidate = !0;
2612
+ let i = Q("div", "cm-dialog-body"), a = Q("label", "cm-dialog-label", "Title");
2613
+ a.htmlFor = pr, i.append(a, n);
2614
+ let o = Q("div", "cm-dialog-footer"), s = mr("Cancel", "secondary");
2615
+ return s.addEventListener("click", e), o.append(s, mr("Apply", "primary")), r.append(i, o), r.addEventListener("submit", (r) => {
2616
+ r.preventDefault();
2617
+ let i = n.value.trim();
2618
+ e(), i !== t.title() && t.setTitle(i);
2619
+ }), [r];
2620
+ }
2621
+ });
2622
+ }
1846
2623
  //#endregion
1847
- export { Ae as CD_TOKENS, k as CmBaseViewer, fn as CmConnectHandles, Rt as CmContextPadProvider, Ee as CmElementFactory, Xe as CmExporter, lt as CmFlatModelBehavior, Ye as CmImporter, qt as CmKeyboard, Ft as CmLabelEditing, Wt as CmLegend, at as CmModeling, At as CmPaletteProvider, ot as CmRules, rn as CmZOrder, Fe as ContextMapsRenderer, A as MIRAGON, on as Modeler, $e as NavigatedViewer, we as ROOT_ID, Qe as Viewer, pt as cmBehaviorsModule, pn as cmConnectHandlesModule, zt as cmContextPadModule, Ke as cmDrawModule, Jt as cmKeyboardModule, W as cmLabelEditingModule, Gt as cmLegendModule, ke as cmModelModule, L as cmModelingModule, jt as cmPaletteModule, R as cmRulesModule, an as cmZOrderModule, B as contextIconSvg, Ze as ioModule, D as isCmContext, E as isCmElement, O as isCmRelationship, H as relationshipIconSvg, V as roleChipSvg, Ce as saveSVG, _t as subdomainIconSvg };
2624
+ export { Ke as CD_TOKENS, On as CONTEXT_MAPS_NOTATION, Be as CmBaseViewer, Hn as CmConnectHandles, fn as CmContextPadProvider, He as CmElementFactory, ft as CmExporter, Mt as CmFlatModelBehavior, vt as CmHoverTooltip, dt as CmImporter, gn as CmKeyboard, Ut as CmLabelEditing, Xn as CmLegend, Ot as CmModeling, an as CmPaletteProvider, zt as CmReadOnly, kt as CmRules, Tn as CmZOrder, Ze as ContextMapsRenderer, Qn as JSON_EXPORT_LABEL, O as MIRAGON, Dn as Modeler, P as NavigatedViewer, L as READ_ONLY_CHANGED_EVENT, D as ROOT_ID, mt as Viewer, It as cmBehaviorsModule, Un as cmConnectHandlesModule, pn as cmContextPadModule, ct as cmDrawModule, yt as cmHoverTooltipModule, _n as cmKeyboardModule, z as cmLabelEditingModule, Zn as cmLegendModule, Ge as cmModelModule, F as cmModelingModule, on as cmPaletteModule, R as cmReadOnlyModule, I as cmRulesModule, En as cmZOrderModule, V as contextIconSvg, $n as contextMapMenu, ar as contextMapShortcuts, kn as createCollaborativeModeler, An as createCollaborativeViewer, ur as createShortcutsDialog, hr as createTitleDialog, _t as hoverTipFor, pt as ioModule, T as isCmContext, w as isCmElement, E as isCmRelationship, Gn as legendGroups, U as relationshipIconSvg, Kn as renderLegend, H as roleChipSvg, Ie as saveSVG, Jt as subdomainIconSvg };
1848
2625
 
1849
2626
  //# sourceMappingURL=index.js.map