@miragon/wardley-renderer 0.2.0 → 0.2.1

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 (62) hide show
  1. package/dist/Modeler.d.ts.map +1 -1
  2. package/dist/WardleyBaseViewer.d.ts +3 -0
  3. package/dist/WardleyBaseViewer.d.ts.map +1 -1
  4. package/dist/context-pad/WardleyContextPadProvider.d.ts.map +1 -1
  5. package/dist/draw/WardleyRenderer.d.ts +5 -1
  6. package/dist/draw/WardleyRenderer.d.ts.map +1 -1
  7. package/dist/draw/icons.d.ts +2 -0
  8. package/dist/draw/icons.d.ts.map +1 -1
  9. package/dist/draw/palette-icons.d.ts.map +1 -1
  10. package/dist/draw/styles.d.ts +12 -1
  11. package/dist/draw/styles.d.ts.map +1 -1
  12. package/dist/draw-tool/WardleyDrawTool.d.ts +46 -0
  13. package/dist/draw-tool/WardleyDrawTool.d.ts.map +1 -0
  14. package/dist/draw-tool/WardleyDrawingHandles.d.ts +31 -0
  15. package/dist/draw-tool/WardleyDrawingHandles.d.ts.map +1 -0
  16. package/dist/draw-tool/WardleyDrawingHitProvider.d.ts +13 -0
  17. package/dist/draw-tool/WardleyDrawingHitProvider.d.ts.map +1 -0
  18. package/dist/draw-tool/index.d.ts +6 -0
  19. package/dist/draw-tool/index.d.ts.map +1 -0
  20. package/dist/evolution-grid/EvolutionConstraintBehavior.d.ts +25 -1
  21. package/dist/evolution-grid/EvolutionConstraintBehavior.d.ts.map +1 -1
  22. package/dist/evolution-grid/EvolutionGrid.d.ts +1 -0
  23. package/dist/evolution-grid/EvolutionGrid.d.ts.map +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1354 -482
  27. package/dist/index.js.map +1 -1
  28. package/dist/io/WardleyExporter.d.ts +3 -1
  29. package/dist/io/WardleyExporter.d.ts.map +1 -1
  30. package/dist/io/WardleyImporter.d.ts.map +1 -1
  31. package/dist/io/saveSvg.d.ts +10 -3
  32. package/dist/io/saveSvg.d.ts.map +1 -1
  33. package/dist/keyboard/WardleyKeyboard.d.ts +10 -3
  34. package/dist/keyboard/WardleyKeyboard.d.ts.map +1 -1
  35. package/dist/label-editing/WardleyLabelEditing.d.ts +6 -1
  36. package/dist/label-editing/WardleyLabelEditing.d.ts.map +1 -1
  37. package/dist/lasso/WardleyLassoBehavior.d.ts +12 -0
  38. package/dist/lasso/WardleyLassoBehavior.d.ts.map +1 -0
  39. package/dist/lasso/index.d.ts +5 -0
  40. package/dist/lasso/index.d.ts.map +1 -0
  41. package/dist/model/WardleyElementFactory.d.ts +15 -1
  42. package/dist/model/WardleyElementFactory.d.ts.map +1 -1
  43. package/dist/model/di-types.d.ts +22 -3
  44. package/dist/model/di-types.d.ts.map +1 -1
  45. package/dist/modeling/WardleyCopyPaste.d.ts +44 -0
  46. package/dist/modeling/WardleyCopyPaste.d.ts.map +1 -0
  47. package/dist/modeling/WardleyModeling.d.ts +3 -3
  48. package/dist/modeling/WardleyModeling.d.ts.map +1 -1
  49. package/dist/modeling/index.d.ts +1 -0
  50. package/dist/modeling/index.d.ts.map +1 -1
  51. package/dist/ordering/WardleyOrderingProvider.d.ts +17 -0
  52. package/dist/ordering/WardleyOrderingProvider.d.ts.map +1 -0
  53. package/dist/ordering/index.d.ts +5 -0
  54. package/dist/ordering/index.d.ts.map +1 -0
  55. package/dist/palette/WardleyPaletteProvider.d.ts +5 -1
  56. package/dist/palette/WardleyPaletteProvider.d.ts.map +1 -1
  57. package/dist/rules/WardleyRules.d.ts +3 -3
  58. package/dist/rules/WardleyRules.d.ts.map +1 -1
  59. package/dist/snapping/StageSnapping.d.ts +3 -2
  60. package/dist/snapping/StageSnapping.d.ts.map +1 -1
  61. package/dist/wardley.css +1 -1
  62. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,46 +1,49 @@
1
1
  import e from "diagram-js/lib/Diagram";
2
- import { parseDSL as t, serializeDSL as n } from "@miragon/wardley-dsl";
3
- import { append as r, attr as i, clear as a, create as o } from "tiny-svg";
4
- import { CURRENT_SCHEMA_VERSION as s, DEFAULT_EVOLUTION_LABELS as c, DEFAULT_STAGE_BOUNDARIES as l, evolutionStage as u, validateMap as d } from "@miragon/wardley-schema-model";
5
- import f from "diagram-js/lib/command/CommandInterceptor";
6
- import ee from "diagram-js/lib/draw/BaseRenderer";
7
- import te from "diagram-js/lib/features/selection";
8
- import ne from "diagram-js/lib/navigation/zoomscroll";
9
- import re from "diagram-js/lib/navigation/movecanvas";
10
- import ie from "diagram-js/lib/features/keyboard";
11
- import ae from "diagram-js/lib/features/modeling";
12
- import oe from "diagram-js/lib/features/move";
13
- import se from "diagram-js/lib/features/create";
14
- import ce from "diagram-js/lib/features/connect";
15
- import le from "diagram-js/lib/features/context-pad";
16
- import ue from "diagram-js/lib/features/palette";
17
- import de from "diagram-js/lib/features/rules";
18
- import fe from "diagram-js/lib/features/outline";
19
- import pe from "diagram-js/lib/features/resize";
20
- import me from "diagram-js/lib/features/popup-menu";
21
- import he from "diagram-js/lib/features/rules/RuleProvider";
22
- import ge from "diagram-js/lib/features/connection-preview";
2
+ import { parseDSLWithDiagnostics as t, serializeDSL as n } from "@miragon/wardley-dsl";
3
+ import { CURRENT_SCHEMA_VERSION as r, DEFAULT_EVOLUTION_LABELS as i, DEFAULT_PLOT_SIZE as a, DEFAULT_STAGE_BOUNDARIES as o, evolutionStage as s, validateMap as c } from "@miragon/wardley-schema-model";
4
+ import { append as l, attr as u, clear as d, create as f, remove as p } from "tiny-svg";
5
+ import ee from "diagram-js/lib/command/CommandInterceptor";
6
+ import te from "diagram-js/lib/draw/BaseRenderer";
7
+ import ne from "diagram-js/lib/features/selection";
8
+ import re from "diagram-js/lib/navigation/zoomscroll";
9
+ import ie from "diagram-js/lib/navigation/movecanvas";
10
+ import ae from "diagram-js/lib/features/keyboard";
11
+ import oe from "diagram-js/lib/features/modeling";
12
+ import se from "diagram-js/lib/features/move";
13
+ import ce from "diagram-js/lib/features/create";
14
+ import le from "diagram-js/lib/features/connect";
15
+ import ue from "diagram-js/lib/features/context-pad";
16
+ import de from "diagram-js/lib/features/palette";
17
+ import fe from "diagram-js/lib/features/rules";
18
+ import pe from "diagram-js/lib/features/outline";
19
+ import me from "diagram-js/lib/features/resize";
20
+ import he from "diagram-js/lib/features/popup-menu";
21
+ import ge from "diagram-js/lib/features/mouse";
22
+ import _e from "diagram-js/lib/features/lasso-tool";
23
+ import ve from "diagram-js/lib/features/rules/RuleProvider";
24
+ import ye from "diagram-js/lib/features/connection-preview";
25
+ import be from "diagram-js/lib/features/ordering/OrderingProvider";
23
26
  //#region src/draw/styles.ts
24
- var p = {
25
- width: 1080,
26
- height: 680,
27
+ var m = {
28
+ width: a.width,
29
+ height: a.height,
27
30
  marginLeft: 66,
28
31
  marginTop: 38,
29
32
  marginRight: 44,
30
33
  marginBottom: 58
31
- }, _e = {
34
+ }, xe = {
32
35
  width: 480,
33
36
  height: 320
34
- }, ve = 8, ye = 6, be = 7.5;
35
- function m(e) {
37
+ }, Se = 8, Ce = 6, we = 7.5;
38
+ function h(e) {
36
39
  let t = (e && e.length ? e : "note").split("\n"), n = Math.max(1, ...t.map((e) => e.length));
37
40
  return {
38
41
  lines: t,
39
- width: Math.max(34, Math.round(n * be) + ve * 2),
40
- height: Math.max(34, t.length * 17 + ye * 2)
42
+ width: Math.max(34, Math.round(n * we) + Se * 2),
43
+ height: Math.max(34, t.length * 17 + Ce * 2)
41
44
  };
42
45
  }
43
- var h = {
46
+ var g = {
44
47
  paper: "#fbfaf7",
45
48
  ink: "#1b1b1a",
46
49
  inkSoft: "#3a3a37",
@@ -58,8 +61,12 @@ var h = {
58
61
  movement: "#bf2f2a",
59
62
  inertia: "#1b1b1a",
60
63
  noteText: "#4a4640",
61
- pipeline: "#1b1b1a"
62
- }, xe = [
64
+ pipeline: "#1b1b1a",
65
+ annotationFill: "#fff8e6",
66
+ plotBackground: "#ffffff",
67
+ accelerator: "#0e7c74",
68
+ deaccelerator: "#bf2f2a"
69
+ }, Te = [
63
70
  {
64
71
  id: "green",
65
72
  name: "Green · good",
@@ -100,7 +107,7 @@ var h = {
100
107
  name: "Slate · neutral",
101
108
  value: "#475569"
102
109
  }
103
- ], Se = {
110
+ ], _ = {
104
111
  pioneers: {
105
112
  fill: "rgba(14,124,116,0.07)",
106
113
  stroke: "#0e7c74"
@@ -113,7 +120,7 @@ var h = {
113
120
  fill: "rgba(120,53,170,0.07)",
114
121
  stroke: "#7835aa"
115
122
  }
116
- }, g = {
123
+ }, v = {
117
124
  family: "'Spline Sans Variable', 'Spline Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",
118
125
  label: 13,
119
126
  axis: 12,
@@ -121,23 +128,28 @@ var h = {
121
128
  };
122
129
  //#endregion
123
130
  //#region src/io/saveSvg.ts
124
- function Ce(e) {
125
- let t = e.getContainer().querySelector("svg");
126
- if (!t) throw Error("No SVG found in the canvas container.");
127
- let n = t.cloneNode(!0), r = p.marginLeft + p.width + p.marginRight, i = p.marginTop + p.height + p.marginBottom;
128
- n.setAttribute("xmlns", "http://www.w3.org/2000/svg"), n.setAttribute("viewBox", `0 0 ${r} ${i}`), n.setAttribute("width", String(r)), n.setAttribute("height", String(i));
129
- let a = n.querySelector(".viewport");
130
- return a && a.removeAttribute("transform"), { svg: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + new XMLSerializer().serializeToString(n) };
131
+ function Ee(e, t) {
132
+ let n = e.getContainer().querySelector("svg");
133
+ if (!n) throw Error("No SVG found in the canvas container.");
134
+ let r = n.cloneNode(!0), i = t ?? {
135
+ x: 0,
136
+ y: 0,
137
+ width: m.marginLeft + m.width + m.marginRight,
138
+ height: m.marginTop + m.height + m.marginBottom
139
+ };
140
+ r.setAttribute("xmlns", "http://www.w3.org/2000/svg"), r.setAttribute("viewBox", `${i.x} ${i.y} ${i.width} ${i.height}`), r.setAttribute("width", String(i.width)), r.setAttribute("height", String(i.height));
141
+ let a = r.querySelector(".viewport");
142
+ return a && a.removeAttribute("transform"), { svg: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + new XMLSerializer().serializeToString(r) };
131
143
  }
132
144
  //#endregion
133
145
  //#region src/io/types.ts
134
- var we = "wardley-root";
146
+ var De = "wardley-root";
135
147
  //#endregion
136
148
  //#region src/WardleyBaseViewer.ts
137
- function Te(e) {
149
+ function Oe(e) {
138
150
  return typeof e == "number" ? `${e}px` : e;
139
151
  }
140
- var Ee = class {
152
+ var ke = class {
141
153
  _diagram;
142
154
  _container;
143
155
  _options;
@@ -146,7 +158,7 @@ var Ee = class {
146
158
  }
147
159
  _createContainer(e) {
148
160
  let t = e.container ?? document.createElement("div");
149
- return t.classList.add("wardley-container"), t.style.width = Te(e.width ?? "100%"), t.style.height = Te(e.height ?? (e.container ? "100%" : "600px")), t;
161
+ return t.classList.add("wardley-container"), t.style.width = Oe(e.width ?? "100%"), t.style.height = Oe(e.height ?? (e.container ? "100%" : "600px")), t;
150
162
  }
151
163
  _ensureDiagram() {
152
164
  if (!this._diagram) {
@@ -171,13 +183,28 @@ var Ee = class {
171
183
  let t = this._ensureDiagram(), n = t.get("eventBus"), r = t.get("wardleyImporter");
172
184
  r.clear();
173
185
  let i = r.import(e);
174
- return n.fire("import.done", { warnings: i }), { warnings: i };
186
+ return this._applyStyleClass(e.config.style), t.get("commandStack").clear(), n.fire("import.done", { warnings: i }), { warnings: i };
187
+ }
188
+ _applyStyleClass(e) {
189
+ let t = this._container.classList;
190
+ for (let e of [
191
+ "wardley",
192
+ "handwritten",
193
+ "colour",
194
+ "dark"
195
+ ]) t.remove(`wardley-${e}`);
196
+ e && e !== "wardley" && t.add(`wardley-${e}`);
175
197
  }
176
198
  async importDSL(e) {
177
199
  let n = this._ensureDiagram().get("eventBus");
178
200
  n.fire("import.parse.start", { text: e });
179
- let r = t(e);
180
- return n.fire("import.parse.done", { map: r }), this.importMap(r);
201
+ let { map: r, diagnostics: i } = t(e);
202
+ n.fire("import.parse.done", {
203
+ map: r,
204
+ diagnostics: i
205
+ });
206
+ let { warnings: a } = await this.importMap(r);
207
+ return { warnings: [...i.map((e) => ({ message: `Line ${e.line}: ${e.message} — "${e.text}"` })), ...a] };
181
208
  }
182
209
  exportMap() {
183
210
  return this.get("wardleyExporter").export();
@@ -218,7 +245,7 @@ var Ee = class {
218
245
  return n(this.exportMap());
219
246
  }
220
247
  async saveSVG() {
221
- return Ce(this.get("canvas"));
248
+ return Ee(this.get("canvas"), this.get("evolutionGrid").outerBounds());
222
249
  }
223
250
  attachTo(e) {
224
251
  e.appendChild(this._container), this.get("canvas").resized();
@@ -235,7 +262,7 @@ var Ee = class {
235
262
  get container() {
236
263
  return this._container;
237
264
  }
238
- }, _ = class {
265
+ }, Ae = class {
239
266
  elementFactory;
240
267
  grid;
241
268
  elementRegistry;
@@ -259,17 +286,28 @@ var Ee = class {
259
286
  for (; n.has(`${e} ${r}`);) r++;
260
287
  return `${e} ${r}`;
261
288
  }
289
+ nextAnnotationNumber() {
290
+ let e = 0;
291
+ for (let t of this.elementRegistry.getAll()) {
292
+ let n = t.annotationNumber;
293
+ typeof n == "number" && n > e && (e = n);
294
+ }
295
+ return e + 1;
296
+ }
262
297
  createComponent(e) {
263
- return this.node("component", e.id, e.label, e.position.visibility, e.position.evolution, e, {
298
+ let t = this.node("component", e.id, e.label, e.position.visibility, e.position.evolution, e, {
264
299
  ...e.decorators ? { decorators: e.decorators } : {},
265
- ...e.movement ? { movement: e.movement } : {}
300
+ ...e.movement ? { movement: e.movement } : {},
301
+ ...e.labelOffset ? { labelOffset: e.labelOffset } : {},
302
+ ...e.pipelineId ? { pipelineId: e.pipelineId } : {}
266
303
  });
304
+ return e.pipelineId && (t.y += 30 / 2), t;
267
305
  }
268
306
  createAnchor(e) {
269
- return this.node("anchor", e.id, e.label, e.position.visibility, e.position.evolution, e);
307
+ return this.node("anchor", e.id, e.label, e.position.visibility, e.position.evolution, e, { ...e.labelOffset ? { labelOffset: e.labelOffset } : {} });
270
308
  }
271
309
  createNote(e) {
272
- let { width: t, height: n } = m(e.label), r = this.grid.toCanvas(e.position);
310
+ let { width: t, height: n } = h(e.label), r = this.grid.toCanvas(e.position);
273
311
  return this.elementFactory.createShape({
274
312
  id: e.id,
275
313
  x: r.x - t / 2,
@@ -295,7 +333,7 @@ var Ee = class {
295
333
  return this.elementFactory.createShape({
296
334
  id: e.id,
297
335
  x: t.x,
298
- y: t.y - 30 / 2,
336
+ y: t.y,
299
337
  width: r,
300
338
  height: 30,
301
339
  wardleyType: "pipeline",
@@ -305,7 +343,8 @@ var Ee = class {
305
343
  evolutionStart: e.evolutionStart,
306
344
  evolutionEnd: e.evolutionEnd,
307
345
  isFrame: !0,
308
- businessObject: e
346
+ businessObject: e,
347
+ ...e.color ? { color: e.color } : {}
309
348
  });
310
349
  }
311
350
  createAnnotation(e) {
@@ -316,25 +355,59 @@ var Ee = class {
316
355
  return this.node("accelerator", e.id, e.label, e.position.visibility, e.position.evolution, e, { acceleratorDirection: e.direction });
317
356
  }
318
357
  createAttitude(e) {
319
- let t = this.grid.toCanvas(e.position);
358
+ let t = this.grid.toCanvas(e.position), n = this.grid.toCanvas(e.corner2), r = Math.min(t.x, n.x), i = Math.min(t.y, n.y);
320
359
  return this.elementFactory.createShape({
321
360
  id: e.id,
322
- x: t.x,
323
- y: t.y,
324
- width: Math.max(e.width, 4),
325
- height: Math.max(e.height, 4),
361
+ x: r,
362
+ y: i,
363
+ width: Math.max(Math.abs(n.x - t.x), 4),
364
+ height: Math.max(Math.abs(n.y - t.y), 4),
326
365
  wardleyType: "attitude",
327
366
  wardleyLabel: e.label || e.kind,
328
367
  attitudeKind: e.kind,
329
368
  evolution: e.position.evolution,
330
369
  visibility: e.position.visibility,
370
+ corner2: e.corner2,
331
371
  isFrame: !0,
332
- businessObject: e
372
+ businessObject: e,
373
+ ...e.color ? { color: e.color } : {}
333
374
  });
334
375
  }
335
376
  createSubmap(e) {
336
377
  return this.node("submap", e.id, e.label, e.position.visibility, e.position.evolution, e);
337
378
  }
379
+ createDrawing(e) {
380
+ let t = e.points.map((e) => this.grid.toCanvas(e));
381
+ return this.drawingFromCanvasPoints(t, {
382
+ id: e.id,
383
+ ...e.closed ? { closed: !0 } : {},
384
+ ...e.strokeStyle ? { strokeStyle: e.strokeStyle } : {},
385
+ ...e.color ? { color: e.color } : {},
386
+ businessObject: e
387
+ });
388
+ }
389
+ drawingFromCanvasPoints(e, t = {}) {
390
+ let n = e.map((e) => e.x), r = e.map((e) => e.y), i = Math.min(...n), a = Math.min(...r), o = Math.max(Math.max(...n) - i, 4), s = Math.max(Math.max(...r) - a, 4), c = e[0], l = this.grid.fromCanvas(c);
391
+ return this.elementFactory.createShape({
392
+ ...t.id ? { id: t.id } : {},
393
+ x: i,
394
+ y: a,
395
+ width: o,
396
+ height: s,
397
+ wardleyType: "drawing",
398
+ wardleyLabel: "",
399
+ evolution: l.evolution,
400
+ visibility: l.visibility,
401
+ drawingPoints: e.map((e) => ({
402
+ x: e.x - i,
403
+ y: e.y - a
404
+ })),
405
+ ...t.closed ? { closed: !0 } : {},
406
+ ...t.strokeStyle ? { strokeStyle: t.strokeStyle } : {},
407
+ ...t.color ? { color: t.color } : {},
408
+ ...t.businessObject ? { businessObject: t.businessObject } : {}
409
+ });
410
+ }
338
411
  createNew(e, t, n = {}) {
339
412
  let r = this.uniqueLabel(t);
340
413
  if (e === "pipeline") return this.elementFactory.createShape({
@@ -359,7 +432,7 @@ var Ee = class {
359
432
  isFrame: !0
360
433
  });
361
434
  if (e === "note") {
362
- let { width: e, height: t } = m(r);
435
+ let { width: e, height: t } = h(r);
363
436
  return this.elementFactory.createShape({
364
437
  width: e,
365
438
  height: t,
@@ -369,7 +442,7 @@ var Ee = class {
369
442
  visibility: .5
370
443
  });
371
444
  }
372
- let i = n.market ? { market: !0 } : n.ecosystem ? { ecosystem: !0 } : void 0;
445
+ let i = n.market ? { market: !0 } : n.ecosystem ? { ecosystem: !0 } : void 0, a = e === "annotation" ? n.annotationNumber ?? this.nextAnnotationNumber() : void 0;
373
446
  return this.elementFactory.createShape({
374
447
  width: 34,
375
448
  height: 34,
@@ -378,7 +451,7 @@ var Ee = class {
378
451
  evolution: .5,
379
452
  visibility: .5,
380
453
  ...n.acceleratorDirection ? { acceleratorDirection: n.acceleratorDirection } : {},
381
- ...n.annotationNumber === void 0 ? {} : { annotationNumber: n.annotationNumber },
454
+ ...a === void 0 ? {} : { annotationNumber: a },
382
455
  ...i ? { decorators: i } : {}
383
456
  });
384
457
  }
@@ -393,7 +466,7 @@ var Ee = class {
393
466
  let s = this.grid.toCanvas({
394
467
  visibility: r,
395
468
  evolution: i
396
- });
469
+ }), c = a?.color;
397
470
  return this.elementFactory.createShape({
398
471
  id: t,
399
472
  x: s.x - 34 / 2,
@@ -405,6 +478,7 @@ var Ee = class {
405
478
  evolution: i,
406
479
  visibility: r,
407
480
  businessObject: a,
481
+ ...c ? { color: c } : {},
408
482
  ...o
409
483
  });
410
484
  }
@@ -414,7 +488,7 @@ var Ee = class {
414
488
  id: t.id,
415
489
  source: n,
416
490
  target: r,
417
- waypoints: [v(n), v(r)],
491
+ waypoints: [je(n), je(r)],
418
492
  wardleyType: e,
419
493
  bidirectional: i,
420
494
  ...a ? { flowValue: a } : {},
@@ -423,63 +497,70 @@ var Ee = class {
423
497
  });
424
498
  }
425
499
  };
426
- function v(e) {
427
- return {
500
+ function je(e) {
501
+ return e.wardleyType === "pipeline" ? {
502
+ x: e.x + e.width / 2,
503
+ y: e.y
504
+ } : {
428
505
  x: e.x + e.width / 2,
429
506
  y: e.y + e.height / 2
430
507
  };
431
508
  }
432
509
  //#endregion
433
510
  //#region src/model/di-types.ts
434
- function y(e) {
511
+ function Me(e) {
435
512
  return typeof e == "object" && !!e;
436
513
  }
514
+ function y(e) {
515
+ return Me(e) && typeof e.wardleyType == "string" && "evolution" in e;
516
+ }
437
517
  function b(e) {
438
- return y(e) && typeof e.wardleyType == "string" && "evolution" in e;
518
+ return Me(e) && typeof e.wardleyType == "string" && "waypoints" in e;
439
519
  }
440
- function x(e) {
441
- return y(e) && typeof e.wardleyType == "string" && "waypoints" in e;
520
+ function Ne(e) {
521
+ return y(e) && e.wardleyType === "component";
442
522
  }
443
- function S(e) {
444
- return b(e) && e.wardleyType === "component";
523
+ function x(e) {
524
+ return y(e) && e.wardleyType === "pipeline";
445
525
  }
446
- function C(e) {
447
- return b(e) && e.wardleyType === "pipeline";
526
+ function Pe(e) {
527
+ return y(e) && e.wardleyType === "attitude";
448
528
  }
449
529
  //#endregion
450
530
  //#region src/model/index.ts
451
- var w = { wardleyElementFactory: ["type", _] }, De = "wardley-axes";
452
- function T(e) {
531
+ var Fe = { wardleyElementFactory: ["type", Ae] }, Ie = "wardley-axes";
532
+ function Le(e) {
453
533
  return e < 0 ? 0 : e > 1 ? 1 : e;
454
534
  }
455
- var E = class {
535
+ var Re = class {
456
536
  canvas;
457
537
  static $inject = ["canvas"];
458
- boundaries = l;
459
- labels = c;
538
+ boundaries = o;
539
+ labels = i;
460
540
  yAxisLabel = "Value Chain";
461
- plotWidth = p.width;
462
- plotHeight = p.height;
541
+ yAxisEndLabels = ["invisible", "visible"];
542
+ plotWidth = m.width;
543
+ plotHeight = m.height;
463
544
  constructor(e) {
464
545
  this.canvas = e;
465
546
  }
466
547
  configure(e) {
467
- this.boundaries = e.stageBoundaries ?? l, this.labels = e.evolutionLabels ?? c, this.yAxisLabel = e.yAxisLabel ?? "Value Chain", this.plotWidth = Math.max(e.size?.width ?? p.width, _e.width), this.plotHeight = Math.max(e.size?.height ?? p.height, _e.height);
548
+ this.boundaries = e.stageBoundaries ?? o, this.labels = e.evolutionLabels ?? i, this.yAxisLabel = e.yAxisLabel ?? "Value Chain", this.yAxisEndLabels = e.yAxisEndLabels ?? ["invisible", "visible"], this.plotWidth = Math.max(e.size?.width ?? m.width, xe.width), this.plotHeight = Math.max(e.size?.height ?? m.height, xe.height);
468
549
  }
469
550
  toCanvas(e) {
470
551
  return {
471
- x: p.marginLeft + e.evolution * this.plotWidth,
472
- y: p.marginTop + (1 - e.visibility) * this.plotHeight
552
+ x: m.marginLeft + e.evolution * this.plotWidth,
553
+ y: m.marginTop + (1 - e.visibility) * this.plotHeight
473
554
  };
474
555
  }
475
556
  fromCanvas(e) {
476
557
  return {
477
- evolution: T((e.x - p.marginLeft) / this.plotWidth),
478
- visibility: T(1 - (e.y - p.marginTop) / this.plotHeight)
558
+ evolution: Le((e.x - m.marginLeft) / this.plotWidth),
559
+ visibility: Le(1 - (e.y - m.marginTop) / this.plotHeight)
479
560
  };
480
561
  }
481
562
  stageOf(e) {
482
- return u(e, this.boundaries);
563
+ return s(e, this.boundaries);
483
564
  }
484
565
  getBoundaries() {
485
566
  return this.boundaries;
@@ -494,114 +575,136 @@ var E = class {
494
575
  return {
495
576
  x: 0,
496
577
  y: 0,
497
- width: p.marginLeft + this.plotWidth + p.marginRight,
498
- height: p.marginTop + this.plotHeight + p.marginBottom
578
+ width: m.marginLeft + this.plotWidth + m.marginRight,
579
+ height: m.marginTop + this.plotHeight + m.marginBottom
499
580
  };
500
581
  }
501
582
  render() {
502
- let e = this.canvas.getLayer(De, -1);
503
- a(e);
504
- let t = p.marginLeft, n = p.marginTop, o = t + this.plotWidth, s = n + this.plotHeight;
505
- r(e, D(t, n, this.plotWidth, this.plotHeight, {
506
- fill: "#ffffff",
507
- stroke: h.grid
583
+ let e = this.canvas.getLayer(Ie, -1);
584
+ d(e);
585
+ let t = m.marginLeft, n = m.marginTop, r = t + this.plotWidth, i = n + this.plotHeight;
586
+ l(e, ze(t, n, this.plotWidth, this.plotHeight, {
587
+ fill: g.plotBackground,
588
+ stroke: g.grid
508
589
  }));
509
- let c = [
590
+ let a = [
510
591
  0,
511
592
  ...this.boundaries,
512
593
  1
513
594
  ];
514
- for (let i = 0; i < 4; i++) {
515
- let a = t + c[i] * this.plotWidth, o = t + c[i + 1] * this.plotWidth;
516
- i % 2 == 1 && r(e, D(a, n, o - a, this.plotHeight, {
517
- fill: h.band,
595
+ for (let r = 0; r < 4; r++) {
596
+ let o = t + a[r] * this.plotWidth, s = t + a[r + 1] * this.plotWidth;
597
+ r % 2 == 1 && l(e, ze(o, n, s - o, this.plotHeight, {
598
+ fill: g.band,
518
599
  stroke: "none"
519
- })), i > 0 && r(e, O(a, n, a, s, {
520
- stroke: h.grid,
600
+ })), r > 0 && l(e, S(o, n, o, i, {
601
+ stroke: g.grid,
521
602
  "stroke-dasharray": "3 5"
522
603
  }));
523
- let l = (a + o) / 2;
524
- r(e, k(this.labels[i].toUpperCase(), l, s + 18, {
604
+ let c = (o + s) / 2;
605
+ l(e, C(this.labels[r].toUpperCase(), c, i + 18, {
525
606
  "text-anchor": "middle",
526
- "font-size": g.stage,
607
+ "font-size": v.stage,
527
608
  "letter-spacing": "0.08em",
528
- fill: h.axisText
609
+ fill: g.axisText
529
610
  }));
530
611
  }
531
- r(e, O(t, s, o + 10, s, { stroke: h.axis })), r(e, A(o + 10, s, "right")), r(e, k("Evolution", o + 6, s + 38, {
612
+ l(e, S(t, i, r + 10, i, { stroke: g.axis })), l(e, Be(r + 10, i, "right")), l(e, C("Evolution", r + 6, i + 38, {
532
613
  "text-anchor": "end",
533
- "font-size": g.axis,
534
- fill: h.axisText,
614
+ "font-size": v.axis,
615
+ fill: g.axisText,
535
616
  "font-style": "italic"
536
- })), r(e, O(t, s, t, n - 10, { stroke: h.axis })), r(e, A(t, n - 10, "up"));
537
- let l = k(this.yAxisLabel, 0, 0, {
617
+ })), l(e, S(t, i, t, n - 10, { stroke: g.axis })), l(e, Be(t, n - 10, "up"));
618
+ let o = C(this.yAxisLabel, 0, 0, {
538
619
  "text-anchor": "middle",
539
- "font-size": g.axis,
540
- fill: h.axisText,
620
+ "font-size": v.axis,
621
+ fill: g.axisText,
541
622
  "font-style": "italic"
542
623
  });
543
- i(l, { transform: `translate(${t - 46}, ${(n + s) / 2}) rotate(-90)` }), r(e, l), r(e, k("visible", t - 10, n + 11, {
624
+ u(o, { transform: `translate(${t - 46}, ${(n + i) / 2}) rotate(-90)` }), l(e, o), l(e, C(this.yAxisEndLabels[1], t - 10, n + 11, {
544
625
  "text-anchor": "end",
545
- "font-size": g.stage,
546
- fill: h.axisText
547
- })), r(e, k("invisible", t - 10, s - 2, {
626
+ "font-size": v.stage,
627
+ fill: g.axisText
628
+ })), l(e, C(this.yAxisEndLabels[0], t - 10, i - 2, {
548
629
  "text-anchor": "end",
549
- "font-size": g.stage,
550
- fill: h.axisText
630
+ "font-size": v.stage,
631
+ fill: g.axisText
551
632
  }));
552
633
  }
553
634
  };
554
- function D(e, t, n, r, a) {
555
- return i(o("rect"), {
635
+ function ze(e, t, n, r, i) {
636
+ return u(f("rect"), {
556
637
  x: e,
557
638
  y: t,
558
639
  width: n,
559
640
  height: r,
560
641
  "stroke-width": 1,
561
- ...a
642
+ ...i
562
643
  });
563
644
  }
564
- function O(e, t, n, r, a) {
565
- return i(o("line"), {
645
+ function S(e, t, n, r, i) {
646
+ return u(f("line"), {
566
647
  x1: e,
567
648
  y1: t,
568
649
  x2: n,
569
650
  y2: r,
570
651
  "stroke-width": 1,
571
- ...a
652
+ ...i
572
653
  });
573
654
  }
574
- function k(e, t, n, r) {
575
- let a = i(o("text"), {
655
+ function C(e, t, n, r) {
656
+ let i = u(f("text"), {
576
657
  x: t,
577
658
  y: n,
578
- "font-family": g.family,
659
+ "font-family": v.family,
579
660
  ...r
580
661
  });
581
- return a.textContent = e, a;
662
+ return i.textContent = e, i;
582
663
  }
583
- function A(e, t, n) {
664
+ function Be(e, t, n) {
584
665
  let r = n === "right" ? `${e - 5},${t - 5} ${e + 2},${t} ${e - 5},${t + 5}` : `${e - 5},${t + 5} ${e},${t - 2} ${e + 5},${t + 5}`;
585
- return i(o("polygon"), {
666
+ return u(f("polygon"), {
586
667
  points: r,
587
- fill: h.axis
668
+ fill: g.axis
588
669
  });
589
670
  }
590
671
  //#endregion
591
672
  //#region src/evolution-grid/EvolutionConstraintBehavior.ts
592
- var j = [
673
+ var w = [
593
674
  "shape.move",
594
675
  "shape.create",
595
676
  "shape.resize",
596
677
  "elements.move",
597
678
  "elements.create"
598
- ], Oe = class extends f {
679
+ ], Ve = class extends ee {
680
+ eventBus;
599
681
  grid;
600
- static $inject = ["eventBus", "evolutionGrid"];
601
- constructor(e, t) {
602
- super(e), this.grid = t;
603
- let n = (e) => this.syncAll(e.context);
604
- this.postExecuted(j, n), this.reverted(j, n);
682
+ elementRegistry;
683
+ static $inject = [
684
+ "eventBus",
685
+ "evolutionGrid",
686
+ "elementRegistry"
687
+ ];
688
+ constructor(e, t, n) {
689
+ super(e), this.eventBus = e, this.grid = t, this.elementRegistry = n;
690
+ let r = (e) => this.syncAll(e.context);
691
+ this.postExecuted(w, r), this.reverted(w, r);
692
+ let i = (e) => {
693
+ if ([
694
+ e.context?.shape,
695
+ e.context?.element,
696
+ ...e.context?.elements ?? []
697
+ ].some((e) => y(e) && e.wardleyType === "component")) for (let e of this.elementRegistry.filter((e) => x(e))) this.eventBus.fire("element.changed", { element: e });
698
+ };
699
+ this.postExecuted([
700
+ "shape.create",
701
+ "shape.delete",
702
+ "element.updateProperties"
703
+ ], i), this.reverted([
704
+ "shape.create",
705
+ "shape.delete",
706
+ "element.updateProperties"
707
+ ], i);
605
708
  }
606
709
  syncAll(e) {
607
710
  if (!e) return;
@@ -610,27 +713,40 @@ var j = [
610
713
  ...e.shapes ?? [],
611
714
  ...e.elements ?? []
612
715
  ];
613
- for (let e of t) b(e) && this.syncFromGeometry(e);
716
+ for (let e of t) y(e) && this.syncFromGeometry(e);
614
717
  }
615
718
  syncFromGeometry(e) {
616
719
  let t = e.y + e.height / 2;
617
720
  if (e.wardleyType === "pipeline") {
618
- let n = this.grid.fromCanvas({
721
+ let t = e.y, n = this.grid.fromCanvas({
619
722
  x: e.x,
620
723
  y: t
621
724
  }), r = this.grid.fromCanvas({
622
725
  x: e.x + e.width,
623
726
  y: t
727
+ }), [i, a] = We(n.evolution, r.evolution);
728
+ e.evolutionStart = i, e.evolutionEnd = a, e.evolution = Ue((i + a) / 2), e.visibility = n.visibility;
729
+ let o = this.grid.toCanvas({
730
+ visibility: e.visibility,
731
+ evolution: i
732
+ }), s = this.grid.toCanvas({
733
+ visibility: e.visibility,
734
+ evolution: a
624
735
  });
625
- e.evolutionStart = n.evolution, e.evolutionEnd = Math.max(r.evolution, n.evolution + .001), e.evolution = (e.evolutionStart + e.evolutionEnd) / 2, e.visibility = n.visibility;
736
+ this.applyGeometry(e, o.x, o.y, Math.max(s.x - o.x, 2)), this.reconcileMembership(e);
626
737
  return;
627
738
  }
628
739
  if (e.wardleyType === "attitude") {
629
740
  let t = this.grid.fromCanvas({
630
741
  x: e.x,
631
742
  y: e.y
743
+ }), n = this.grid.fromCanvas({
744
+ x: e.x + e.width,
745
+ y: e.y + e.height
632
746
  });
633
- e.evolution = t.evolution, e.visibility = t.visibility;
747
+ e.evolution = t.evolution, e.visibility = t.visibility, e.corner2 = n;
748
+ let r = this.grid.toCanvas(t), i = this.grid.toCanvas(n);
749
+ this.applyGeometry(e, r.x, r.y, Math.max(i.x - r.x, 4), Math.max(i.y - r.y, 4));
634
750
  return;
635
751
  }
636
752
  let n = this.grid.fromCanvas({
@@ -638,33 +754,80 @@ var j = [
638
754
  y: t
639
755
  });
640
756
  e.evolution = n.evolution, e.visibility = n.visibility;
757
+ let r = this.grid.toCanvas(n);
758
+ this.applyGeometry(e, r.x - e.width / 2, r.y - e.height / 2), e.wardleyType === "component" && this.updateMembership(e);
759
+ }
760
+ applyGeometry(e, t, n, r, i) {
761
+ (Math.abs(t - e.x) > .5 || Math.abs(n - e.y) > .5 || r !== void 0 && Math.abs(r - e.width) > .5 || i !== void 0 && Math.abs(i - e.height) > .5) && (e.x = t, e.y = n, r !== void 0 && (e.width = r), i !== void 0 && (e.height = i), this.fireChanged(e));
762
+ }
763
+ updateMembership(e) {
764
+ let t = e.x + e.width / 2, n = e.y + e.height / 2, r = this.elementRegistry.filter((e) => x(e)).find((r) => r.wardleyLabel !== e.wardleyLabel && t >= r.x && t <= r.x + r.width && n >= r.y && n <= r.y + r.height);
765
+ r ? (e.pipelineId = r.id, this.glueToPipeline(e, r)) : e.pipelineId && delete e.pipelineId;
766
+ }
767
+ glueToPipeline(e, t) {
768
+ e.y = t.y + t.height / 2 - e.height / 2, e.visibility = t.visibility, this.fireChanged(e);
769
+ }
770
+ reconcileMembership(e) {
771
+ let t = this.elementRegistry.filter((e) => y(e) && e.wardleyType === "component");
772
+ for (let n of t) {
773
+ if (n.wardleyLabel === e.wardleyLabel) continue;
774
+ let t = n.x + n.width / 2, r = n.y + n.height / 2, i = t >= e.x && t <= e.x + e.width && r >= e.y && r <= e.y + e.height;
775
+ if (i && n.pipelineId !== e.id) n.pipelineId = e.id, n.visibility = e.visibility, this.fireChanged(n);
776
+ else if (!i && n.pipelineId === e.id) {
777
+ delete n.pipelineId;
778
+ let e = this.grid.fromCanvas({
779
+ x: t,
780
+ y: r
781
+ });
782
+ n.evolution = e.evolution, n.visibility = e.visibility, this.fireChanged(n);
783
+ }
784
+ }
641
785
  }
642
- }, M = { evolutionGrid: ["type", E] }, ke = {
786
+ fireChanged(e) {
787
+ this.eventBus.fire("element.changed", { element: e });
788
+ for (let t of [...e.incoming ?? [], ...e.outgoing ?? []]) this.eventBus.fire("element.changed", { element: t });
789
+ }
790
+ }, He = .001;
791
+ function Ue(e) {
792
+ return e < 0 ? 0 : e > 1 ? 1 : e;
793
+ }
794
+ function We(e, t) {
795
+ let n = Ue(Math.max(t, e + He));
796
+ return [Math.max(0, Math.min(e, n - He)), n];
797
+ }
798
+ //#endregion
799
+ //#region src/evolution-grid/index.ts
800
+ var T = { evolutionGrid: ["type", Re] }, Ge = {
643
801
  __init__: ["evolutionConstraintBehavior"],
644
- __depends__: [M],
645
- evolutionConstraintBehavior: ["type", Oe]
646
- }, N = "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z", Ae = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z", je = "M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z", Me = "M15.5 5H11l5 7-5 7h4.5l5-7zM8.5 5H4l5 7-5 7h4.5l5-7z", Ne = "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.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z", P = "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z", Pe = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z", Fe = "M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z", Ie = "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z", Le = "M4 7v2c0 .55-.45 1-1 1H2v2h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h1v-2H7c-.55 0-1-.45-1-1v-2c0-.84-.35-1.61-.92-2.18L4.85 12l.23-.82C5.65 10.61 6 9.84 6 9V7c0-.55.45-1 1-1h1V4H7C5.35 4 4 5.35 4 7zm16 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-1v2h1c.55 0 1 .45 1 1v2c0 .84.35 1.61.92 2.18l.23.82-.23.82c-.57.57-.92 1.34-.92 2.18v2c0 .55-.45 1-1 1h-1v2h1c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-2h-1z", Re = "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z", ze = "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z", Be = "M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92z", Ve = "M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z", He = "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z", Ue = "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z", We = "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z", Ge = "M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 8 6.5 8 8 8.67 8 9.5 7.33 11 6.5 11zm3-4C8.67 7 8 6.33 8 5.5S8.67 4 9.5 4s1.5.67 1.5 1.5S10.33 7 9.5 7zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 4 14.5 4s1.5.67 1.5 1.5S15.33 7 14.5 7zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 8 17.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z", Ke = "M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z", qe = "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z", Je = "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z", Ye = "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z";
647
- function Xe(e, t, n, a, s) {
648
- let c = o("g"), l = a / 24;
649
- return i(c, {
650
- transform: `translate(${t - a / 2}, ${n - a / 2}) scale(${l})`,
651
- fill: s,
802
+ __depends__: [T],
803
+ evolutionConstraintBehavior: ["type", Ve]
804
+ }, E = "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z", Ke = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z", qe = "M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z", Je = "M15.5 5H11l5 7-5 7h4.5l5-7zM8.5 5H4l5 7-5 7h4.5l5-7z", D = "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.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z", O = "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z", Ye = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z", Xe = "M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z", Ze = "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z", Qe = "M4 7v2c0 .55-.45 1-1 1H2v2h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h1v-2H7c-.55 0-1-.45-1-1v-2c0-.84-.35-1.61-.92-2.18L4.85 12l.23-.82C5.65 10.61 6 9.84 6 9V7c0-.55.45-1 1-1h1V4H7C5.35 4 4 5.35 4 7zm16 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-1v2h1c.55 0 1 .45 1 1v2c0 .84.35 1.61.92 2.18l.23.82-.23.82c-.57.57-.92 1.34-.92 2.18v2c0 .55-.45 1-1 1h-1v2h1c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-2h-1z", $e = "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z", et = "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z", tt = "M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92z", nt = "M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z", rt = "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z", it = "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z", at = "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z", ot = "M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 8 6.5 8 8 8.67 8 9.5 7.33 11 6.5 11zm3-4C8.67 7 8 6.33 8 5.5S8.67 4 9.5 4s1.5.67 1.5 1.5S10.33 7 9.5 7zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 4 14.5 4s1.5.67 1.5 1.5S15.33 7 14.5 7zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 8 17.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z", k = "M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z", A = "M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z", st = "M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z", ct = "M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z", lt = "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z", ut = "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z", dt = "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z";
805
+ function j(e, t, n, r, i) {
806
+ let a = f("g"), o = r / 24;
807
+ return u(a, {
808
+ transform: `translate(${t - r / 2}, ${n - r / 2}) scale(${o})`,
809
+ fill: i,
652
810
  stroke: "none"
653
- }), r(c, i(o("path"), { d: e })), c;
811
+ }), l(a, u(f("path"), { d: e })), a;
654
812
  }
655
- function Ze(e, t = 18) {
813
+ function M(e, t = 18) {
656
814
  return `<svg viewBox="0 0 24 24" width="${t}" height="${t}" fill="currentColor" aria-hidden="true"><path d="${e}"/></svg>`;
657
815
  }
658
816
  //#endregion
659
817
  //#region src/draw/WardleyRenderer.ts
660
- var Qe = 1500, $e = class extends ee {
818
+ var ft = 1500, N = class extends te {
661
819
  grid;
662
- static $inject = ["eventBus", "evolutionGrid"];
663
- constructor(e, t) {
664
- super(e, Qe), this.grid = t;
820
+ elementRegistry;
821
+ static $inject = [
822
+ "eventBus",
823
+ "evolutionGrid",
824
+ "elementRegistry"
825
+ ];
826
+ constructor(e, t, n) {
827
+ super(e, ft), this.grid = t, this.elementRegistry = n;
665
828
  }
666
829
  canRender(e) {
667
- return b(e) || x(e);
830
+ return y(e) || b(e);
668
831
  }
669
832
  drawShape(e, t) {
670
833
  let n = t;
@@ -676,29 +839,42 @@ var Qe = 1500, $e = class extends ee {
676
839
  case "annotation": return this.drawAnnotation(e, n);
677
840
  case "accelerator": return this.drawAccelerator(e, n);
678
841
  case "submap": return this.drawSubmap(e, n);
842
+ case "drawing": return this.drawDrawing(e, n);
679
843
  default: return this.drawComponent(e, n);
680
844
  }
681
845
  }
846
+ drawDrawing(e, t) {
847
+ let n = t.drawingPoints ?? [], r = t.strokeStyle === "dashed" ? "8 5" : t.strokeStyle === "dotted" ? "2 4" : void 0, i = u(f(t.closed ? "polygon" : "polyline"), {
848
+ points: n.map((e) => `${e.x},${e.y}`).join(" "),
849
+ fill: "none",
850
+ stroke: t.color ?? g.ink,
851
+ "stroke-width": 2,
852
+ "stroke-linecap": "round",
853
+ "stroke-linejoin": "round",
854
+ ...r ? { "stroke-dasharray": r } : {}
855
+ });
856
+ return l(e, i), i;
857
+ }
682
858
  drawConnection(e, t) {
683
- let n = t, a = n.wardleyType === "flow", s = a ? h.flow : h.dependency, [c, l] = nt(n), u = i(o("polyline"), {
684
- points: `${c.x},${c.y} ${l.x},${l.y}`,
859
+ let n = t, r = n.wardleyType === "flow", i = r ? g.flow : g.dependency, [a, o] = ht(n), s = u(f("polyline"), {
860
+ points: `${a.x},${a.y} ${o.x},${o.y}`,
685
861
  fill: "none",
686
- stroke: s,
687
- "stroke-width": a ? 2.5 : 1.5,
862
+ stroke: i,
863
+ "stroke-width": r ? 2.5 : 1.5,
688
864
  "stroke-linecap": "round"
689
865
  });
690
- r(e, u), r(e, L(c, l, s, a ? 11 : 9, a ? 5 : 4)), a && n.bidirectional && r(e, L(l, c, s, 11, 5));
691
- let d = (c.x + l.x) / 2, f = (c.y + l.y) / 2;
692
- return a && n.flowValue && r(e, I(n.flowValue, d, f - 5, {
866
+ l(e, s), r && (l(e, L(a, o, i, 11, 5)), n.bidirectional && l(e, L(o, a, i, 11, 5)));
867
+ let c = (a.x + o.x) / 2, d = (a.y + o.y) / 2;
868
+ return r && n.flowValue && l(e, I(n.flowValue, c, d - 5, {
693
869
  "text-anchor": "middle",
694
870
  "font-size": 11,
695
- fill: h.flow
696
- })), n.linkLabel && r(e, I(n.linkLabel, d, f + (n.flowValue ? 12 : -4), {
871
+ fill: g.flow
872
+ })), n.linkLabel && l(e, I(n.linkLabel, c, d + (n.flowValue ? 12 : -4), {
697
873
  "text-anchor": "middle",
698
874
  "font-size": 11,
699
875
  "font-style": "italic",
700
- fill: h.axisText
701
- })), u;
876
+ fill: g.axisText
877
+ })), s;
702
878
  }
703
879
  getShapePath(e) {
704
880
  let { x: t, y: n, width: r, height: i } = e;
@@ -709,160 +885,185 @@ var Qe = 1500, $e = class extends ee {
709
885
  return t ? `M${t.x},${t.y}` + n.map((e) => `L${e.x},${e.y}`).join("") : "";
710
886
  }
711
887
  drawComponent(e, t) {
712
- let n = t.width / 2, i = t.height / 2, a = !!t.movement, o = t.decorators;
888
+ let n = t.width / 2, r = t.height / 2, i = !!t.movement, a = t.decorators;
713
889
  if (t.movement) {
714
- let a = this.grid.toCanvas({
890
+ let i = t.movement, a = this.grid.toCanvas({
715
891
  visibility: t.visibility,
716
892
  evolution: t.evolution
717
893
  }), o = this.grid.toCanvas({
718
894
  visibility: t.visibility,
719
- evolution: t.movement.targetEvolution
720
- }).x - a.x;
721
- r(e, et(n, i, n + o, i, {
722
- stroke: h.movement,
723
- "stroke-width": 1.5
724
- })), r(e, L({
895
+ evolution: i.targetEvolution
896
+ }).x - a.x, s = n + o, c = s - (Math.sign(o) || 1) * 17;
897
+ l(e, F(n, r, c, r, {
898
+ stroke: g.movement,
899
+ "stroke-width": 1.5,
900
+ "stroke-dasharray": "6 4"
901
+ })), l(e, L({
725
902
  x: n,
726
- y: i
903
+ y: r
727
904
  }, {
728
- x: n + o,
729
- y: i
730
- }, h.movement)), r(e, F(n + o, i, 15, {
731
- fill: h.paper,
732
- stroke: h.movement,
905
+ x: c,
906
+ y: r
907
+ }, g.movement)), l(e, P(s, r, 15, {
908
+ fill: g.paper,
909
+ stroke: g.movement,
733
910
  "stroke-width": 2,
734
911
  class: "wardley-evolve-handle"
912
+ })), l(e, I(i.newLabel ?? t.wardleyLabel, s + 15 + 7, r - 4, {
913
+ "font-weight": "500",
914
+ fill: g.movement
915
+ })), i.method && l(e, I(i.method, s + 15 + 7, r + 11, {
916
+ "font-size": 10.5,
917
+ fill: g.movement
735
918
  }));
736
919
  }
737
- if (o?.inertia) {
920
+ if (a?.inertia) {
738
921
  let t = n + 15 + 3;
739
- r(e, et(t, i - 13, t, i + 13, {
740
- stroke: h.inertia,
922
+ l(e, F(t, r - 13, t, r + 13, {
923
+ stroke: g.inertia,
741
924
  "stroke-width": 3,
742
925
  "stroke-linecap": "round"
743
926
  }));
744
927
  }
745
- let s = F(n, i, 15, {
746
- fill: h.componentFill,
747
- stroke: h.stroke,
928
+ let o = t.color ?? g.stroke, s = P(n, r, 15, {
929
+ fill: g.componentFill,
930
+ stroke: o,
748
931
  "stroke-width": 2
749
932
  });
750
- return r(e, s), a && r(e, F(n, i, 12, {
933
+ if (l(e, s), i && l(e, P(n, r, 12, {
751
934
  fill: "none",
752
- stroke: h.stroke,
935
+ stroke: o,
753
936
  "stroke-width": 1.5
754
- })), o?.ecosystem ? r(e, F(n, i, 4.5, {
937
+ })), a?.ecosystem && l(e, P(n, r, 18.5, {
755
938
  fill: "none",
756
- stroke: h.stroke,
757
- "stroke-width": 1.5
758
- })) : o?.market && r(e, F(n, i, 3, { fill: h.stroke })), r(e, I(t.wardleyLabel, n + 15 + 7, i - 4, { "font-weight": "500" })), o?.method && r(e, I(o.method, n + 15 + 7, i + 11, {
939
+ stroke: o,
940
+ "stroke-width": 1.25,
941
+ "stroke-dasharray": "1.5 3",
942
+ "stroke-linecap": "round"
943
+ })), a?.market) for (let [t, i] of [
944
+ [0, -3.8],
945
+ [-3.4, 2.4],
946
+ [3.4, 2.4]
947
+ ]) l(e, P(n + t, r + i, 1.7, { fill: o }));
948
+ let c = n + 15 + 7 + (t.labelOffset?.dx ?? 0), u = r - 4 + (t.labelOffset?.dy ?? 0);
949
+ return l(e, I(t.wardleyLabel, c, u, {
950
+ "font-weight": "500",
951
+ ...t.color ? { fill: t.color } : {}
952
+ })), a?.method && l(e, I(a.method, c, u + 15, {
759
953
  "font-size": 10.5,
760
- fill: h.axisText
954
+ fill: g.axisText
761
955
  })), s;
762
956
  }
763
957
  drawAnchor(e, t) {
764
- let n = t.width / 2, i = t.height / 2, a = Xe(N, n, i, 26, h.ink);
765
- return r(e, a), r(e, I(t.wardleyLabel, n, i - 26 / 2 - 4, {
958
+ let n = t.width / 2, r = t.height / 2, i = j(E, n, r, 26, t.color ?? g.ink);
959
+ return l(e, i), l(e, I(t.wardleyLabel, n + (t.labelOffset?.dx ?? 0), r - 26 / 2 - 4 + (t.labelOffset?.dy ?? 0), {
766
960
  "text-anchor": "middle",
767
- "font-weight": "700"
768
- })), a;
961
+ "font-weight": "700",
962
+ ...t.color ? { fill: t.color } : {}
963
+ })), i;
769
964
  }
770
965
  drawPipeline(e, t) {
771
- let n = i(o("rect"), {
966
+ let n = Math.max(t.width, 1), r = t.color, i = u(f("rect"), {
772
967
  x: 0,
773
968
  y: 0,
774
- width: Math.max(t.width, 1),
969
+ width: n,
775
970
  height: Math.max(t.height, 1),
776
971
  rx: 4,
777
- fill: h.accentSoft,
778
- stroke: h.pipeline,
972
+ fill: "none",
973
+ stroke: r ?? g.pipeline,
779
974
  "stroke-width": 1.25,
780
975
  "stroke-dasharray": "6 3"
781
976
  });
782
- return r(e, n), r(e, I(t.wardleyLabel, 4, -6, { "font-weight": "500" })), n;
977
+ return l(e, i), !this.elementRegistry.filter((e) => y(e) && e.wardleyType === "component").some((e) => e.wardleyLabel === t.wardleyLabel) && (l(e, u(f("rect"), {
978
+ x: n / 2 - 8,
979
+ y: -8,
980
+ width: 16,
981
+ height: 16,
982
+ fill: g.componentFill,
983
+ stroke: r ?? g.stroke,
984
+ "stroke-width": 2
985
+ })), l(e, I(t.wardleyLabel, n / 2 + 8 + 6, -4, {
986
+ "font-weight": "500",
987
+ ...r ? { fill: r } : {}
988
+ }))), i;
783
989
  }
784
990
  drawNote(e, t) {
785
- let n = t.color, i = (t.wardleyLabel ?? "").split("\n"), a = t.width / 2, s = t.height / 2 - (i.length - 1) * 17 / 2 + 4, c = {
991
+ let n = t.color, r = (t.wardleyLabel ?? "").split("\n"), i = t.width / 2, a = t.height / 2 - (r.length - 1) * 17 / 2 + 4, o = {
786
992
  "text-anchor": "middle",
787
- fill: n ?? h.noteText,
993
+ fill: n ?? g.noteText,
788
994
  "font-style": "italic",
789
995
  ...n ? { "font-weight": "600" } : {}
790
- }, l;
791
- return i.forEach((t, n) => {
792
- let i = I(t, a, s + n * 17, c);
793
- r(e, i), l ||= i;
794
- }), l ?? o("text");
996
+ }, s;
997
+ return r.forEach((t, n) => {
998
+ let r = I(t, i, a + n * 17, o);
999
+ l(e, r), s ||= r;
1000
+ }), s ?? f("text");
795
1001
  }
796
1002
  drawAttitude(e, t) {
797
- let n = Se[t.attitudeKind ?? "pioneers"] ?? {
798
- fill: "rgba(0,0,0,0.05)",
799
- stroke: "#666666"
800
- }, a = i(o("rect"), {
1003
+ let n = _[t.attitudeKind ?? "pioneers"] ?? _.pioneers, r = t.color ?? n.stroke, i = u(f("rect"), {
801
1004
  x: 0,
802
1005
  y: 0,
803
1006
  width: Math.max(t.width, 1),
804
1007
  height: Math.max(t.height, 1),
805
1008
  rx: 10,
806
1009
  fill: n.fill,
807
- stroke: n.stroke,
1010
+ stroke: r,
808
1011
  "stroke-width": 1.25,
809
1012
  "stroke-dasharray": "5 4"
810
1013
  });
811
- return r(e, a), r(e, I(rt(t.attitudeKind ?? t.wardleyLabel), 10, 18, {
812
- fill: n.stroke,
1014
+ return l(e, i), l(e, I(t.wardleyLabel && t.wardleyLabel !== t.attitudeKind ? t.wardleyLabel : gt(t.attitudeKind ?? "pioneers"), 10, 18, {
1015
+ fill: r,
813
1016
  "font-weight": "700",
814
1017
  "letter-spacing": "0.04em"
815
- })), a;
1018
+ })), i;
816
1019
  }
817
1020
  drawAnnotation(e, t) {
818
- let n = t.width / 2, i = t.height / 2, a = F(n, i, 10, {
819
- fill: "#fff8e6",
820
- stroke: h.stroke,
1021
+ let n = t.width / 2, r = t.height / 2, i = P(n, r, 10, {
1022
+ fill: g.annotationFill,
1023
+ stroke: t.color ?? g.stroke,
821
1024
  "stroke-width": 1.25
822
1025
  });
823
- return r(e, a), r(e, I(String(t.annotationNumber ?? ""), n, i + 4, {
1026
+ return l(e, i), l(e, I(String(t.annotationNumber ?? ""), n, r + 4, {
824
1027
  "text-anchor": "middle",
825
1028
  "font-size": 11,
826
1029
  "font-weight": "700"
827
- }, !1)), t.wardleyLabel && r(e, I(t.wardleyLabel, n + 15, i + 4, {
1030
+ }, !1)), t.wardleyLabel && l(e, I(t.wardleyLabel, n + 15, r + 4, {
828
1031
  "font-size": 12,
829
- fill: h.noteText
830
- })), a;
1032
+ fill: g.noteText
1033
+ })), i;
831
1034
  }
832
1035
  drawAccelerator(e, t) {
833
- let n = t.width / 2, i = t.height / 2, a = t.acceleratorDirection !== "deaccelerate", o = I(a ? "»" : "«", n, i + 6, {
834
- "text-anchor": "middle",
835
- "font-size": 19,
836
- "font-weight": "700",
837
- fill: a ? h.flow : h.movement
838
- });
839
- return r(e, o), t.wardleyLabel && r(e, I(t.wardleyLabel, n + 11, i + 6, { "font-size": 12 })), o;
1036
+ let n = t.width / 2, r = t.height / 2, i = t.acceleratorDirection !== "deaccelerate", a = j(i ? k : A, n, r, 24, t.color ?? (i ? g.accelerator : g.deaccelerator));
1037
+ return l(e, a), t.wardleyLabel && l(e, I(t.wardleyLabel, n + 15, r + 5, { "font-size": 12 })), a;
840
1038
  }
841
1039
  drawSubmap(e, t) {
842
- let n = t.width / 2, a = t.height / 2, s = i(o("rect"), {
1040
+ let n = t.width / 2, r = t.height / 2, i = t.color ?? g.stroke, a = u(f("rect"), {
843
1041
  x: n - 16,
844
- y: a - 16,
1042
+ y: r - 16,
845
1043
  width: 32,
846
1044
  height: 32,
847
1045
  rx: 3,
848
- fill: h.componentFill,
849
- stroke: h.stroke,
1046
+ fill: g.componentFill,
1047
+ stroke: i,
850
1048
  "stroke-width": 2
851
1049
  });
852
- return r(e, s), r(e, i(o("rect"), {
1050
+ return l(e, a), l(e, u(f("rect"), {
853
1051
  x: n - 16 + 3,
854
- y: a - 16 + 3,
1052
+ y: r - 16 + 3,
855
1053
  width: 26,
856
1054
  height: 26,
857
1055
  rx: 1.5,
858
1056
  fill: "none",
859
- stroke: h.stroke,
1057
+ stroke: i,
860
1058
  "stroke-width": 1
861
- })), r(e, I(t.wardleyLabel, n + 16 + 6, a - 6, { "font-weight": "500" })), s;
1059
+ })), l(e, I(t.wardleyLabel, n + 16 + 6, r - 6, {
1060
+ "font-weight": "500",
1061
+ ...t.color ? { fill: t.color } : {}
1062
+ })), a;
862
1063
  }
863
1064
  };
864
- function F(e, t, n, r) {
865
- return i(o("circle"), {
1065
+ function P(e, t, n, r) {
1066
+ return u(f("circle"), {
866
1067
  cx: e,
867
1068
  cy: t,
868
1069
  r: n,
@@ -870,43 +1071,52 @@ function F(e, t, n, r) {
870
1071
  ...r
871
1072
  });
872
1073
  }
873
- function et(e, t, n, r, a) {
874
- return i(o("line"), {
1074
+ function F(e, t, n, r, i) {
1075
+ return u(f("line"), {
875
1076
  x1: e,
876
1077
  y1: t,
877
1078
  x2: n,
878
1079
  y2: r,
879
- ...a
1080
+ ...i
880
1081
  });
881
1082
  }
882
- function I(e, t, n, r = {}, a = !0) {
883
- let s = a ? {
884
- stroke: h.paper,
1083
+ function I(e, t, n, r = {}, i = !0) {
1084
+ let a = i ? {
1085
+ stroke: g.paper,
885
1086
  "stroke-width": 3.5,
886
1087
  "paint-order": "stroke",
887
1088
  "stroke-linejoin": "round"
888
- } : {}, c = i(o("text"), {
1089
+ } : {}, o = u(f("text"), {
889
1090
  x: t,
890
1091
  y: n,
891
- "font-family": g.family,
892
- "font-size": g.label,
893
- fill: h.ink,
894
- ...s,
1092
+ "font-family": v.family,
1093
+ "font-size": v.label,
1094
+ fill: g.ink,
1095
+ ...a,
895
1096
  ...r
896
1097
  });
897
- return c.textContent = e, c;
1098
+ return o.textContent = e, o;
898
1099
  }
899
- function L(e, t, n, r = 10, a = 5) {
900
- let s = Math.atan2(t.y - e.y, t.x - e.x), c = t.x - r * Math.cos(s), l = t.y - r * Math.sin(s), u = `${t.x},${t.y} ${c - a * Math.sin(s)},${l + a * Math.cos(s)} ${c + a * Math.sin(s)},${l - a * Math.cos(s)}`;
901
- return i(o("polygon"), {
902
- points: u,
1100
+ function L(e, t, n, r = 10, i = 5) {
1101
+ let a = Math.atan2(t.y - e.y, t.x - e.x), o = t.x - r * Math.cos(a), s = t.y - r * Math.sin(a), c = `${t.x},${t.y} ${o - i * Math.sin(a)},${s + i * Math.cos(a)} ${o + i * Math.sin(a)},${s - i * Math.cos(a)}`;
1102
+ return u(f("polygon"), {
1103
+ points: c,
903
1104
  fill: n
904
1105
  });
905
1106
  }
906
- function tt(e) {
907
- return e.wardleyType === "component" ? 17 : e.wardleyType === "anchor" ? 14 : Math.min(e.width, e.height) / 2;
1107
+ function pt(e) {
1108
+ return e.wardleyType === "component" ? 17 : e.wardleyType === "anchor" ? 14 : e.wardleyType === "pipeline" ? 10 : Math.min(e.width, e.height) / 2;
1109
+ }
1110
+ function mt(e) {
1111
+ return e.wardleyType === "pipeline" ? {
1112
+ x: e.x + e.width / 2,
1113
+ y: e.y
1114
+ } : {
1115
+ x: e.x + e.width / 2,
1116
+ y: e.y + e.height / 2
1117
+ };
908
1118
  }
909
- function nt(e) {
1119
+ function ht(e) {
910
1120
  let t = e.source, n = e.target, r = e.waypoints;
911
1121
  if (!t || !n) {
912
1122
  let e = r[0] ?? {
@@ -915,13 +1125,7 @@ function nt(e) {
915
1125
  };
916
1126
  return [e, r[r.length - 1] ?? e];
917
1127
  }
918
- let i = {
919
- x: t.x + t.width / 2,
920
- y: t.y + t.height / 2
921
- }, a = {
922
- x: n.x + n.width / 2,
923
- y: n.y + n.height / 2
924
- }, o = a.x - i.x, s = a.y - i.y, c = Math.hypot(o, s) || 1, l = o / c, u = s / c, d = tt(t), f = tt(n);
1128
+ let i = mt(t), a = mt(n), o = a.x - i.x, s = a.y - i.y, c = Math.hypot(o, s) || 1, l = o / c, u = s / c, d = pt(t), f = pt(n);
925
1129
  return c <= d + f + 2 ? [i, a] : [{
926
1130
  x: i.x + l * d,
927
1131
  y: i.y + u * d
@@ -930,15 +1134,15 @@ function nt(e) {
930
1134
  y: a.y - u * f
931
1135
  }];
932
1136
  }
933
- function rt(e) {
1137
+ function gt(e) {
934
1138
  return e && e.charAt(0).toUpperCase() + e.slice(1);
935
1139
  }
936
1140
  //#endregion
937
1141
  //#region src/draw/index.ts
938
- var it = {
1142
+ var _t = {
939
1143
  __init__: ["wardleyRenderer"],
940
- wardleyRenderer: ["type", $e]
941
- }, at = new Set(["attitude", "pipeline"]), ot = {
1144
+ wardleyRenderer: ["type", N]
1145
+ }, vt = new Set(["attitude", "pipeline"]), yt = {
942
1146
  attitude: 0,
943
1147
  pipeline: 1,
944
1148
  note: 2,
@@ -947,7 +1151,7 @@ var it = {
947
1151
  annotation: 5,
948
1152
  submap: 3,
949
1153
  accelerator: 3
950
- }, st = class {
1154
+ }, bt = class {
951
1155
  canvas;
952
1156
  elementFactory;
953
1157
  factory;
@@ -978,8 +1182,8 @@ var it = {
978
1182
  r = void 0;
979
1183
  }
980
1184
  let i;
981
- r && r.id === "wardley-root" ? i = r : (i = this.elementFactory.createRoot({ id: we }), this.canvas.setRootElement(i)), i.businessObject = n, this.grid.render();
982
- let a = /* @__PURE__ */ new Map(), o = [...e.elements].sort((e, t) => (ot[e.elementType] ?? 9) - (ot[t.elementType] ?? 9)), s = o.filter((e) => at.has(e.elementType)), c = o.filter((e) => !at.has(e.elementType)), l = 0;
1185
+ r && r.id === "wardley-root" ? i = r : (i = this.elementFactory.createRoot({ id: De }), this.canvas.setRootElement(i)), i.businessObject = n, this.grid.render();
1186
+ let a = /* @__PURE__ */ new Map(), o = [...e.elements].sort((e, t) => (yt[e.elementType] ?? 9) - (yt[t.elementType] ?? 9)), s = o.filter((e) => vt.has(e.elementType)), c = o.filter((e) => !vt.has(e.elementType)), l = 0;
983
1187
  for (let e of s) {
984
1188
  let t = this.createShape(e);
985
1189
  t && (this.canvas.addShape(t, i), a.set(e.id, t), l++);
@@ -1000,6 +1204,10 @@ var it = {
1000
1204
  let o = n.edgeType === "flow" ? this.factory.createFlow(n, e, r) : this.factory.createDependency(n, e, r);
1001
1205
  this.canvas.addConnection(o, i, l);
1002
1206
  }
1207
+ for (let e of s) {
1208
+ let t = a.get(e.id);
1209
+ t && e.elementType === "pipeline" && this.eventBus.fire("element.changed", { element: t });
1210
+ }
1003
1211
  return this.canvas.viewbox(this.grid.outerBounds()), this.eventBus.fire("import.render.done", { warnings: t }), t;
1004
1212
  }
1005
1213
  createShape(e) {
@@ -1012,6 +1220,7 @@ var it = {
1012
1220
  case "attitude": return this.factory.createAttitude(e);
1013
1221
  case "accelerator": return this.factory.createAccelerator(e);
1014
1222
  case "submap": return this.factory.createSubmap(e);
1223
+ case "drawing": return this.factory.createDrawing(e);
1015
1224
  default: return;
1016
1225
  }
1017
1226
  }
@@ -1031,24 +1240,29 @@ function R(e) {
1031
1240
  for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = r);
1032
1241
  return t;
1033
1242
  }
1034
- var ct = class {
1243
+ var xt = class {
1035
1244
  elementRegistry;
1036
1245
  canvas;
1037
- static $inject = ["elementRegistry", "canvas"];
1038
- constructor(e, t) {
1039
- this.elementRegistry = e, this.canvas = t;
1246
+ grid;
1247
+ static $inject = [
1248
+ "elementRegistry",
1249
+ "canvas",
1250
+ "evolutionGrid"
1251
+ ];
1252
+ constructor(e, t, n) {
1253
+ this.elementRegistry = e, this.canvas = t, this.grid = n;
1040
1254
  }
1041
1255
  export() {
1042
- let e = this.canvas.getRootElement().businessObject, t = e?.config ?? { title: "Untitled Map" }, n = [], r = [];
1256
+ let e = this.canvas.getRootElement().businessObject, t = e?.config ?? { title: "Untitled Map" }, n = [], i = [];
1043
1257
  for (let e of this.elementRegistry.getAll()) if (e.id !== "wardley-root") {
1044
- if (x(e)) if (e.businessObject) r.push(e.businessObject);
1258
+ if (b(e)) if (e.businessObject) i.push(e.businessObject);
1045
1259
  else {
1046
1260
  let t = {
1047
1261
  id: e.id,
1048
1262
  from: e.source?.id ?? "",
1049
1263
  to: e.target?.id ?? ""
1050
1264
  };
1051
- r.push(e.wardleyType === "flow" ? {
1265
+ i.push(e.wardleyType === "flow" ? {
1052
1266
  ...t,
1053
1267
  edgeType: "flow",
1054
1268
  ...e.bidirectional ? { bidirectional: !0 } : {}
@@ -1057,16 +1271,30 @@ var ct = class {
1057
1271
  edgeType: "dependency"
1058
1272
  });
1059
1273
  }
1060
- else if (b(e)) {
1274
+ else if (y(e)) {
1061
1275
  let t = this.buildElement(e);
1062
1276
  t && n.push(t);
1063
1277
  }
1064
1278
  }
1065
- return d({
1066
- schemaVersion: s,
1279
+ let a = new Set(n.filter((e) => e.elementType === "pipeline").map((e) => e.id));
1280
+ return c({
1281
+ schemaVersion: r,
1067
1282
  config: t,
1068
- elements: n,
1069
- edges: r,
1283
+ elements: n.map((e) => {
1284
+ if (e.elementType === "component" && e.pipelineId && !a.has(e.pipelineId)) {
1285
+ let { pipelineId: t, ...n } = e;
1286
+ return n;
1287
+ }
1288
+ if (e.elementType === "pipeline") {
1289
+ let t = n.filter((t) => t.elementType === "component" && t.pipelineId === e.id).map((e) => e.id);
1290
+ return {
1291
+ ...e,
1292
+ childIds: t
1293
+ };
1294
+ }
1295
+ return e;
1296
+ }),
1297
+ edges: i,
1070
1298
  ...e?.rawPassthrough ? { rawPassthrough: e.rawPassthrough } : {}
1071
1299
  });
1072
1300
  }
@@ -1081,16 +1309,21 @@ var ct = class {
1081
1309
  elementType: "component",
1082
1310
  label: e.wardleyLabel,
1083
1311
  position: t,
1312
+ labelOffset: e.labelOffset ?? n?.labelOffset,
1084
1313
  decorators: e.decorators,
1085
1314
  movement: e.movement,
1086
- pipelineId: n?.pipelineId
1315
+ pipelineId: e.pipelineId,
1316
+ url: n?.url,
1317
+ color: e.color
1087
1318
  });
1088
- case "anchor": return {
1319
+ case "anchor": return R({
1089
1320
  id: e.id,
1090
1321
  elementType: "anchor",
1091
1322
  label: e.wardleyLabel,
1092
- position: t
1093
- };
1323
+ position: t,
1324
+ labelOffset: e.labelOffset ?? n?.labelOffset,
1325
+ color: e.color
1326
+ });
1094
1327
  case "note": return R({
1095
1328
  id: e.id,
1096
1329
  elementType: "note",
@@ -1106,7 +1339,8 @@ var ct = class {
1106
1339
  position: t,
1107
1340
  evolutionStart: e.evolutionStart ?? 0,
1108
1341
  evolutionEnd: e.evolutionEnd ?? 1,
1109
- childIds: n?.childIds ?? []
1342
+ childIds: n?.childIds ?? [],
1343
+ ...e.color ? { color: e.color } : {}
1110
1344
  };
1111
1345
  case "attitude": return {
1112
1346
  id: e.id,
@@ -1114,55 +1348,80 @@ var ct = class {
1114
1348
  kind: e.attitudeKind ?? "pioneers",
1115
1349
  label: e.wardleyLabel,
1116
1350
  position: t,
1117
- width: e.width,
1118
- height: e.height
1351
+ corner2: e.corner2 ?? n?.corner2 ?? {
1352
+ visibility: Math.max(0, t.visibility - .1),
1353
+ evolution: Math.min(1, t.evolution + .15)
1354
+ },
1355
+ ...e.color ? { color: e.color } : {}
1119
1356
  };
1120
1357
  case "accelerator": return {
1121
1358
  id: e.id,
1122
1359
  elementType: "accelerator",
1123
1360
  direction: e.acceleratorDirection ?? "accelerate",
1124
1361
  label: e.wardleyLabel,
1125
- position: t
1126
- };
1127
- case "annotation": return {
1128
- id: e.id,
1129
- elementType: "annotation",
1130
- label: e.wardleyLabel,
1131
1362
  position: t,
1132
- number: e.annotationNumber ?? 0,
1133
- positions: [t],
1134
- text: e.wardleyLabel
1363
+ ...e.color ? { color: e.color } : {}
1135
1364
  };
1365
+ case "annotation": {
1366
+ let r = (n?.positions ?? []).slice(1);
1367
+ return {
1368
+ id: e.id,
1369
+ elementType: "annotation",
1370
+ label: e.wardleyLabel,
1371
+ position: t,
1372
+ number: e.annotationNumber ?? 0,
1373
+ positions: [t, ...r],
1374
+ text: e.wardleyLabel,
1375
+ ...e.color ? { color: e.color } : {}
1376
+ };
1377
+ }
1136
1378
  case "submap": return R({
1137
1379
  id: e.id,
1138
1380
  elementType: "submap",
1139
1381
  label: e.wardleyLabel,
1140
1382
  position: t,
1141
- urlRef: n?.urlRef
1383
+ urlRef: n?.urlRef,
1384
+ color: e.color
1142
1385
  });
1386
+ case "drawing": {
1387
+ let t = (e.drawingPoints ?? []).map((t) => this.grid.fromCanvas({
1388
+ x: e.x + t.x,
1389
+ y: e.y + t.y
1390
+ }));
1391
+ return t.length < 2 ? void 0 : {
1392
+ id: e.id,
1393
+ elementType: "drawing",
1394
+ label: "",
1395
+ position: t[0],
1396
+ points: t,
1397
+ ...e.closed ? { closed: !0 } : {},
1398
+ ...e.strokeStyle ? { strokeStyle: e.strokeStyle } : {},
1399
+ ...e.color ? { color: e.color } : {}
1400
+ };
1401
+ }
1143
1402
  default: return e.wardleyType, n ? {
1144
1403
  ...n,
1145
1404
  position: t
1146
1405
  } : void 0;
1147
1406
  }
1148
1407
  }
1149
- }, lt = {
1150
- wardleyImporter: ["type", st],
1151
- wardleyExporter: ["type", ct]
1152
- }, ut = class extends Ee {
1408
+ }, St = {
1409
+ wardleyImporter: ["type", bt],
1410
+ wardleyExporter: ["type", xt]
1411
+ }, Ct = class extends ke {
1153
1412
  _getModules() {
1154
1413
  return [
1155
- w,
1156
- M,
1157
- it,
1158
- lt
1414
+ Fe,
1415
+ T,
1416
+ _t,
1417
+ St
1159
1418
  ];
1160
1419
  }
1161
- }, dt = 180, ft = 80, pt = 120, mt = .5, ht = (e, t, n) => e < t ? t : e > n ? n : e;
1162
- function gt(e, t, n, r) {
1163
- return t <= r ? ht(e, n, n + r - t) : n + r / 2 - t / 2;
1420
+ }, wt = 180, Tt = 80, Et = 120, Dt = .5, Ot = (e, t, n) => e < t ? t : e > n ? n : e;
1421
+ function kt(e, t, n, r) {
1422
+ return t <= r ? Ot(e, n, n + r - t) : n + r / 2 - t / 2;
1164
1423
  }
1165
- var _t = class {
1424
+ var At = class {
1166
1425
  canvas;
1167
1426
  grid;
1168
1427
  static $inject = [
@@ -1179,8 +1438,8 @@ var _t = class {
1179
1438
  constrain(e) {
1180
1439
  let t = e ?? this.canvas.viewbox(), n = this.grid.outerBounds();
1181
1440
  if (!(n.width > 0) || !(n.height > 0) || !(t.width > 0) || !(t.height > 0)) return;
1182
- let r = gt(t.x, t.width, n.x - pt, n.width + 2 * pt), i = gt(t.y, t.height, n.y - dt, n.height + dt + ft);
1183
- if (!(Math.abs(r - t.x) < mt && Math.abs(i - t.y) < mt)) {
1441
+ let r = kt(t.x, t.width, n.x - Et, n.width + 2 * Et), i = kt(t.y, t.height, n.y - wt, n.height + wt + Tt);
1442
+ if (!(Math.abs(r - t.x) < Dt && Math.abs(i - t.y) < Dt)) {
1184
1443
  this.applying = !0;
1185
1444
  try {
1186
1445
  this.canvas.viewbox({
@@ -1194,58 +1453,58 @@ var _t = class {
1194
1453
  }
1195
1454
  }
1196
1455
  }
1197
- }, vt = {
1456
+ }, jt = {
1198
1457
  __init__: ["panConstraint"],
1199
- panConstraint: ["type", _t]
1200
- }, yt = class extends ut {
1458
+ panConstraint: ["type", At]
1459
+ }, Mt = class extends Ct {
1201
1460
  _getModules() {
1202
1461
  return [
1203
1462
  ...super._getModules(),
1204
- te,
1205
1463
  ne,
1206
1464
  re,
1207
1465
  ie,
1208
- vt
1466
+ ae,
1467
+ jt
1209
1468
  ];
1210
1469
  }
1211
1470
  };
1212
1471
  //#endregion
1213
1472
  //#region src/modeling/cmd/UpdatePropertiesHandler.ts
1214
- function bt(e, t, n) {
1473
+ function Nt(e, t, n) {
1215
1474
  n === void 0 ? delete e[t] : e[t] = n;
1216
1475
  }
1217
- var xt = class {
1476
+ var Pt = class {
1218
1477
  execute(e) {
1219
1478
  let { element: t, properties: n } = e, r = t, i = {};
1220
- for (let e of Object.keys(n)) i[e] = r[e], bt(r, e, n[e]);
1479
+ for (let e of Object.keys(n)) i[e] = r[e], Nt(r, e, n[e]);
1221
1480
  return e.oldProperties = i, [t];
1222
1481
  }
1223
1482
  revert(e) {
1224
1483
  let { element: t, oldProperties: n } = e, r = t;
1225
- if (n) for (let e of Object.keys(n)) bt(r, e, n[e]);
1484
+ if (n) for (let e of Object.keys(n)) Nt(r, e, n[e]);
1226
1485
  return [t];
1227
1486
  }
1228
- }, St = "element.updateProperties";
1229
- function Ct(e) {
1487
+ }, Ft = "element.updateProperties";
1488
+ function It(e) {
1230
1489
  let t = {};
1231
1490
  for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = r);
1232
1491
  return t;
1233
1492
  }
1234
- var wt = class {
1493
+ var z = class {
1235
1494
  commandStack;
1236
1495
  static $inject = ["commandStack"];
1237
1496
  constructor(e) {
1238
- this.commandStack = e, e.registerHandler(St, xt);
1497
+ this.commandStack = e, e.registerHandler(Ft, Pt);
1239
1498
  }
1240
1499
  updateProperties(e, t) {
1241
- this.commandStack.execute(St, {
1500
+ this.commandStack.execute(Ft, {
1242
1501
  element: e,
1243
1502
  properties: t
1244
1503
  });
1245
1504
  }
1246
1505
  updateLabel(e, t) {
1247
1506
  if (e.wardleyType === "note") {
1248
- let { width: n, height: r } = m(t), i = e.x + e.width / 2, a = e.y + e.height / 2;
1507
+ let { width: n, height: r } = h(t), i = e.x + e.width / 2, a = e.y + e.height / 2;
1249
1508
  this.updateProperties(e, {
1250
1509
  wardleyLabel: t,
1251
1510
  width: n,
@@ -1258,8 +1517,9 @@ var wt = class {
1258
1517
  this.updateProperties(e, { wardleyLabel: t });
1259
1518
  }
1260
1519
  evolveComponent(e, t, n = {}) {
1261
- this.updateProperties(e, { movement: Ct({
1262
- targetEvolution: Tt(t),
1520
+ let r = Lt(t);
1521
+ r <= e.evolution || this.updateProperties(e, { movement: It({
1522
+ targetEvolution: r,
1263
1523
  newLabel: n.newLabel,
1264
1524
  method: n.method
1265
1525
  }) });
@@ -1283,84 +1543,272 @@ var wt = class {
1283
1543
  this.updateProperties(e, { color: t });
1284
1544
  }
1285
1545
  };
1286
- function Tt(e) {
1546
+ function Lt(e) {
1287
1547
  return e < 0 ? 0 : e > 1 ? 1 : e;
1288
1548
  }
1289
1549
  //#endregion
1550
+ //#region src/modeling/WardleyCopyPaste.ts
1551
+ var Rt = 24, zt = [
1552
+ "wardleyType",
1553
+ "evolution",
1554
+ "visibility",
1555
+ "decorators",
1556
+ "movement",
1557
+ "evolutionStart",
1558
+ "evolutionEnd",
1559
+ "annotationNumber",
1560
+ "attitudeKind",
1561
+ "corner2",
1562
+ "acceleratorDirection",
1563
+ "labelOffset",
1564
+ "color",
1565
+ "drawingPoints",
1566
+ "closed",
1567
+ "strokeStyle"
1568
+ ], Bt = [
1569
+ "wardleyType",
1570
+ "bidirectional",
1571
+ "flowValue",
1572
+ "linkLabel"
1573
+ ];
1574
+ function Vt(e, t) {
1575
+ let n = {};
1576
+ for (let r of t) {
1577
+ let t = e[r];
1578
+ t !== void 0 && (n[r] = structuredClone(t));
1579
+ }
1580
+ return n;
1581
+ }
1582
+ var Ht = class {
1583
+ selection;
1584
+ modeling;
1585
+ elementFactory;
1586
+ elementRegistry;
1587
+ canvas;
1588
+ create;
1589
+ mouse;
1590
+ static $inject = [
1591
+ "selection",
1592
+ "modeling",
1593
+ "elementFactory",
1594
+ "elementRegistry",
1595
+ "canvas",
1596
+ "create",
1597
+ "mouse"
1598
+ ];
1599
+ clipboard = null;
1600
+ pasteCount = 0;
1601
+ constructor(e, t, n, r, i, a, o) {
1602
+ this.selection = e, this.modeling = t, this.elementFactory = n, this.elementRegistry = r, this.canvas = i, this.create = a, this.mouse = o;
1603
+ }
1604
+ copy() {
1605
+ let e = this.selection.get().filter((e) => y(e));
1606
+ if (!e.length) return !1;
1607
+ let t = new Map(e.map((e, t) => [e, t])), n = [], r = /* @__PURE__ */ new Set();
1608
+ for (let i of e) for (let e of [...i.incoming ?? [], ...i.outgoing ?? []]) {
1609
+ if (!b(e) || r.has(e)) continue;
1610
+ let i = t.get(e.source), a = t.get(e.target);
1611
+ i === void 0 || a === void 0 || (r.add(e), n.push({
1612
+ sourceIdx: i,
1613
+ targetIdx: a,
1614
+ props: Vt(e, Bt)
1615
+ }));
1616
+ }
1617
+ return this.clipboard = {
1618
+ shapes: e.map((e) => ({
1619
+ props: Vt(e, zt),
1620
+ x: e.x,
1621
+ y: e.y,
1622
+ width: e.width,
1623
+ height: e.height,
1624
+ label: e.wardleyLabel ?? ""
1625
+ })),
1626
+ connections: n
1627
+ }, this.pasteCount = 0, !0;
1628
+ }
1629
+ paste() {
1630
+ if (!this.clipboard?.shapes.length) return !1;
1631
+ let e = this.buildClones(), t = this.mouse.getLastMoveEvent();
1632
+ return t ? (this.create.start(t, [...e.shapes, ...e.connections]), !0) : this.insertWithOffset(e);
1633
+ }
1634
+ duplicate() {
1635
+ return this.copy() ? this.insertWithOffset(this.buildClones()) : !1;
1636
+ }
1637
+ buildClones() {
1638
+ let e = this.clipboard, t = this.uniqueLabels(e.shapes.map((e) => e.label)), n = e.shapes.map((e, n) => this.elementFactory.createShape({
1639
+ ...structuredClone(e.props),
1640
+ x: e.x,
1641
+ y: e.y,
1642
+ width: e.width,
1643
+ height: e.height,
1644
+ wardleyLabel: t[n],
1645
+ ...e.props.wardleyType === "pipeline" || e.props.wardleyType === "attitude" ? { isFrame: !0 } : {}
1646
+ }));
1647
+ return {
1648
+ shapes: n,
1649
+ connections: e.connections.map((e) => this.elementFactory.createConnection({
1650
+ ...structuredClone(e.props),
1651
+ source: n[e.sourceIdx],
1652
+ target: n[e.targetIdx],
1653
+ waypoints: [Ut(n[e.sourceIdx]), Ut(n[e.targetIdx])]
1654
+ }))
1655
+ };
1656
+ }
1657
+ insertWithOffset(e) {
1658
+ this.pasteCount++;
1659
+ let t = Rt * this.pasteCount, n = Wt(e.shapes), r = this.modeling.createElements([...e.shapes, ...e.connections], {
1660
+ x: n.cx + t,
1661
+ y: n.cy + t
1662
+ }, this.canvas.getRootElement());
1663
+ return this.selection.select(r), !0;
1664
+ }
1665
+ uniqueLabels(e) {
1666
+ let t = /* @__PURE__ */ new Set();
1667
+ for (let e of this.elementRegistry.getAll()) {
1668
+ let n = e.wardleyLabel;
1669
+ typeof n == "string" && t.add(n);
1670
+ }
1671
+ return e.map((e) => {
1672
+ let n = e, r = 2;
1673
+ for (; t.has(n);) n = `${e} ${r++}`;
1674
+ return t.add(n), n;
1675
+ });
1676
+ }
1677
+ };
1678
+ function Ut(e) {
1679
+ return {
1680
+ x: e.x + e.width / 2,
1681
+ y: e.y + e.height / 2
1682
+ };
1683
+ }
1684
+ function Wt(e) {
1685
+ let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y)), r = Math.max(...e.map((e) => e.x + e.width)), i = Math.max(...e.map((e) => e.y + e.height));
1686
+ return {
1687
+ cx: (t + r) / 2,
1688
+ cy: (n + i) / 2
1689
+ };
1690
+ }
1691
+ //#endregion
1290
1692
  //#region src/modeling/index.ts
1291
- var Et = {
1693
+ var Gt = {
1694
+ __depends__: [ge, ce],
1292
1695
  __init__: ["wardleyModeling"],
1293
- wardleyModeling: ["type", wt]
1294
- }, Dt = new Set(["component", "anchor"]);
1295
- function z(e) {
1296
- return b(e) && Dt.has(e.wardleyType);
1696
+ wardleyModeling: ["type", z],
1697
+ wardleyCopyPaste: ["type", Ht]
1698
+ }, Kt = {
1699
+ __depends__: [_e],
1700
+ __init__: ["wardleyLassoBehavior"],
1701
+ wardleyLassoBehavior: ["type", class {
1702
+ static $inject = [
1703
+ "eventBus",
1704
+ "canvas",
1705
+ "lassoTool"
1706
+ ];
1707
+ constructor(e, t, n) {
1708
+ e.on("element.mousedown", 1500, (e) => {
1709
+ let r = e.originalEvent;
1710
+ if (!r?.shiftKey) return;
1711
+ let i;
1712
+ try {
1713
+ i = t.getRootElement();
1714
+ } catch {
1715
+ return;
1716
+ }
1717
+ if (e.element === i) return n.activateLasso(r), !1;
1718
+ });
1719
+ }
1720
+ }]
1721
+ }, qt = new Set([
1722
+ "component",
1723
+ "anchor",
1724
+ "submap",
1725
+ "pipeline"
1726
+ ]);
1727
+ function B(e) {
1728
+ return y(e) && qt.has(e.wardleyType);
1297
1729
  }
1298
- var Ot = class extends he {
1730
+ function Jt(e, t) {
1731
+ return (e.outgoing ?? []).some((e) => e.target === t) || (e.incoming ?? []).some((e) => e.source === t);
1732
+ }
1733
+ var Yt = class extends ve {
1299
1734
  static $inject = ["eventBus"];
1300
1735
  constructor(e) {
1301
1736
  super(e);
1302
1737
  }
1303
1738
  init() {
1304
- this.addRule("connection.start", (e) => z(e.source)), this.addRule("connection.create", (e) => {
1739
+ this.addRule("connection.start", (e) => B(e.source)), this.addRule("connection.create", (e) => {
1305
1740
  let { source: t, target: n } = e;
1306
- return !z(t) || !z(n) || t === n ? !1 : { wardleyType: "dependency" };
1307
- }), this.addRule(["shape.move", "elements.move"], () => !0), this.addRule("shape.create", () => !0), this.addRule("shape.resize", (e) => C(e.shape));
1741
+ return !B(t) || !B(n) || t === n || Jt(t, n) ? !1 : { wardleyType: "dependency" };
1742
+ }), this.addRule(["shape.move", "elements.move"], () => !0), this.addRule("shape.create", () => !0), this.addRule("elements.create", () => !0), this.addRule("shape.resize", (e) => x(e.shape) || Pe(e.shape));
1308
1743
  }
1309
- }, kt = {
1744
+ }, Xt = {
1310
1745
  __init__: ["wardleyRules"],
1311
- wardleyRules: ["type", Ot]
1312
- }, At = 8, jt = {
1746
+ wardleyRules: ["type", Yt]
1747
+ }, Zt = 8, Qt = {
1313
1748
  __init__: ["stageSnapping"],
1314
1749
  stageSnapping: ["type", class {
1315
1750
  static $inject = ["eventBus", "evolutionGrid"];
1316
1751
  constructor(e, t) {
1317
- e.on([
1318
- "shape.move.move",
1319
- "shape.move.end",
1752
+ let n = () => t.getBoundaries().map((e) => t.toCanvas({
1753
+ visibility: .5,
1754
+ evolution: e
1755
+ }).x), r = (e, t) => {
1756
+ typeof e.dx == "number" && typeof e.x == "number" && (e.dx += t - e.x), e.x = t;
1757
+ };
1758
+ e.on(["shape.move.move", "shape.move.end"], 1500, (e) => {
1759
+ if (e.originalEvent?.shiftKey || typeof e.x != "number" || typeof e.dx != "number") return;
1760
+ let t = e.context?.shape;
1761
+ if (!t) return;
1762
+ let r = t.x + t.width / 2 + e.dx;
1763
+ for (let t of n()) if (Math.abs(r - t) <= Zt) {
1764
+ let n = t - r;
1765
+ e.dx += n, e.x += n;
1766
+ break;
1767
+ }
1768
+ }), e.on([
1320
1769
  "create.move",
1321
1770
  "create.end",
1322
- "shape.resize.move",
1323
- "shape.resize.end"
1771
+ "resize.move",
1772
+ "resize.end"
1324
1773
  ], 1500, (e) => {
1325
- if (e.originalEvent?.shiftKey || typeof e.x != "number") return;
1326
- let n = t.getBoundaries().map((e) => t.toCanvas({
1327
- visibility: .5,
1328
- evolution: e
1329
- }).x);
1330
- for (let t of n) if (Math.abs(e.x - t) <= At) {
1331
- e.x = t;
1332
- break;
1774
+ if (!e.originalEvent?.shiftKey && typeof e.x == "number") {
1775
+ for (let t of n()) if (Math.abs(e.x - t) <= Zt) {
1776
+ r(e, t);
1777
+ break;
1778
+ }
1333
1779
  }
1334
1780
  });
1335
1781
  }
1336
1782
  }]
1337
- }, B = (e) => `<svg width="24" height="24" viewBox="0 0 24 24" class="wardley-palette-svg">${e}</svg>`, V = (e = "") => `<circle cx="12" cy="12" r="7" fill="${h.componentFill}" stroke="${h.stroke}" stroke-width="2"/>${e}`, H = (e, t) => `<text x="12" text-anchor="middle" font-family="${g.family}" ${t}>${e}</text>`, U = {
1338
- component: B(V()),
1339
- market: B(V(`<circle cx="12" cy="12" r="2.6" fill="${h.stroke}"/>`)),
1340
- ecosystem: B(V(`<circle cx="12" cy="12" r="4" fill="none" stroke="${h.stroke}" stroke-width="1.5"/>`)),
1341
- anchor: B(`<path d="${N}" fill="${h.ink}"/>`),
1342
- pipeline: B(`<rect x="2" y="8" width="20" height="8" rx="3" fill="${h.accentSoft}" stroke="${h.pipeline}" stroke-width="1.5" stroke-dasharray="3 2"/>`),
1343
- note: B(`<g stroke="${h.noteText}" stroke-width="1.5" stroke-linecap="round"><line x1="5" y1="8" x2="19" y2="8"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="5" y1="16" x2="13" y2="16"/></g>`),
1344
- annotation: B(`<circle cx="12" cy="12" r="8" fill="#fff8e6" stroke="${h.stroke}" stroke-width="1.25"/>` + H("1", `y="16" font-size="11" font-weight="700" fill="${h.stroke}"`)),
1345
- accelerator: B(H("»", `y="17.5" font-size="19" font-weight="700" fill="${h.flow}"`)),
1346
- deaccelerator: B(H("«", `y="17.5" font-size="19" font-weight="700" fill="${h.movement}"`)),
1347
- submap: B(`<rect x="4" y="4" width="16" height="16" rx="3" fill="${h.componentFill}" stroke="${h.stroke}" stroke-width="2"/><rect x="7.5" y="7.5" width="9" height="9" rx="1.5" fill="none" stroke="${h.stroke}" stroke-width="1"/>`)
1783
+ }, V = (e) => `<svg width="24" height="24" viewBox="0 0 24 24" class="wardley-palette-svg">${e}</svg>`, H = (e = "") => `<circle cx="12" cy="12" r="7" fill="${g.componentFill}" stroke="${g.stroke}" stroke-width="2"/>${e}`, U = {
1784
+ draw: V(`<polyline points="3,18 8.5,7 14,14 21,4" fill="none" stroke="${g.ink}" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="3" cy="18" r="2.2" fill="${g.componentFill}" stroke="${g.ink}" stroke-width="1.4"/>`),
1785
+ lasso: V(`<rect x="3" y="3" width="13" height="13" rx="2" fill="none" stroke="${g.ink}" stroke-width="1.5" stroke-dasharray="3 2.5"/><path d="M13.5 13.5l7 2.7-3 1.3-1.3 3z" fill="${g.ink}"/>`),
1786
+ component: V(H()),
1787
+ market: V(H(`<circle cx="12" cy="10" r="1.4" fill="${g.stroke}"/><circle cx="10.2" cy="13.4" r="1.4" fill="${g.stroke}"/><circle cx="13.8" cy="13.4" r="1.4" fill="${g.stroke}"/>`)),
1788
+ ecosystem: V(H(`<circle cx="12" cy="12" r="10" fill="none" stroke="${g.stroke}" stroke-width="1.25" stroke-dasharray="1.5 3" stroke-linecap="round"/>`)),
1789
+ anchor: V(`<path d="${E}" fill="${g.ink}"/>`),
1790
+ pipeline: V(`<rect x="9.5" y="2.5" width="5.5" height="5.5" fill="${g.componentFill}" stroke="${g.stroke}" stroke-width="1.5"/><rect x="2" y="10" width="20" height="9" rx="2" fill="none" stroke="${g.pipeline}" stroke-width="1.25" stroke-dasharray="3 2"/><circle cx="7" cy="14.5" r="2.2" fill="${g.componentFill}" stroke="${g.stroke}" stroke-width="1.2"/><circle cx="17" cy="14.5" r="2.2" fill="${g.componentFill}" stroke="${g.stroke}" stroke-width="1.2"/>`),
1791
+ note: V(`<g stroke="${g.noteText}" stroke-width="1.5" stroke-linecap="round"><line x1="5" y1="8" x2="19" y2="8"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="5" y1="16" x2="13" y2="16"/></g>`),
1792
+ annotation: V(`<circle cx="12" cy="12" r="8" fill="${g.annotationFill}" stroke="${g.stroke}" stroke-width="1.25"/>` + ((e, t) => `<text x="12" text-anchor="middle" font-family="${v.family}" ${t}>${e}</text>`)("1", `y="16" font-size="11" font-weight="700" fill="${g.stroke}"`)),
1793
+ accelerator: V(`<path d="${k}" fill="${g.accelerator}"/>`),
1794
+ deaccelerator: V(`<path d="${A}" fill="${g.deaccelerator}"/>`),
1795
+ submap: V(`<rect x="4" y="4" width="16" height="16" rx="3" fill="${g.componentFill}" stroke="${g.stroke}" stroke-width="2"/><rect x="7.5" y="7.5" width="9" height="9" rx="1.5" fill="none" stroke="${g.stroke}" stroke-width="1"/>`)
1348
1796
  };
1349
1797
  function W(e) {
1350
- let t = Se[e] ?? {
1798
+ let t = _[e] ?? {
1351
1799
  fill: "rgba(0,0,0,0.05)",
1352
1800
  stroke: "#666666"
1353
1801
  };
1354
- return B(`<rect x="2" y="6" width="20" height="12" rx="3" fill="${t.fill}" stroke="${t.stroke}" stroke-width="1.5" stroke-dasharray="3 2"/>`);
1802
+ return V(`<rect x="2" y="6" width="20" height="12" rx="3" fill="${t.fill}" stroke="${t.stroke}" stroke-width="1.5" stroke-dasharray="3 2"/>`);
1355
1803
  }
1356
1804
  //#endregion
1357
1805
  //#region src/palette/WardleyPaletteProvider.ts
1358
- var G = "wardley-1-blocks", K = "wardley-2-strategy", Mt = "wardley-3-notes", Nt = [
1806
+ var G = "wardley-1-blocks", K = "wardley-2-strategy", $t = [
1359
1807
  {
1360
1808
  key: "component",
1361
1809
  type: "component",
1362
1810
  label: "Component",
1363
- title: "Component",
1811
+ title: "Component — C",
1364
1812
  icon: U.component,
1365
1813
  group: G
1366
1814
  },
@@ -1386,7 +1834,7 @@ var G = "wardley-1-blocks", K = "wardley-2-strategy", Mt = "wardley-3-notes", Nt
1386
1834
  key: "anchor",
1387
1835
  type: "anchor",
1388
1836
  label: "User",
1389
- title: "Anchor / User",
1837
+ title: "Anchor / User — U",
1390
1838
  icon: U.anchor,
1391
1839
  group: G
1392
1840
  },
@@ -1457,33 +1905,39 @@ var G = "wardley-1-blocks", K = "wardley-2-strategy", Mt = "wardley-3-notes", Nt
1457
1905
  label: "Note",
1458
1906
  title: "Note",
1459
1907
  icon: U.note,
1460
- group: Mt
1461
- },
1462
- {
1463
- key: "annotation",
1464
- type: "annotation",
1465
- label: "Annotation",
1466
- title: "Annotation (numbered marker)",
1467
- icon: U.annotation,
1468
- group: Mt,
1469
- extra: { annotationNumber: 1 }
1470
- }
1471
- ], Pt = {
1908
+ group: "wardley-3-notes"
1909
+ }
1910
+ ], en = {
1472
1911
  __init__: ["wardleyPaletteProvider"],
1473
1912
  wardleyPaletteProvider: ["type", class {
1474
1913
  create;
1475
1914
  factory;
1915
+ lassoTool;
1916
+ drawTool;
1476
1917
  static $inject = [
1477
1918
  "palette",
1478
1919
  "create",
1479
- "wardleyElementFactory"
1920
+ "wardleyElementFactory",
1921
+ "lassoTool",
1922
+ "wardleyDrawTool"
1480
1923
  ];
1481
- constructor(e, t, n) {
1482
- this.create = t, this.factory = n, e.registerProvider(this);
1924
+ constructor(e, t, n, r, i) {
1925
+ this.create = t, this.factory = n, this.lassoTool = r, this.drawTool = i, e.registerProvider(this);
1483
1926
  }
1484
1927
  getPaletteEntries() {
1485
1928
  let e = {};
1486
- for (let t of Nt) {
1929
+ e["lasso-tool"] = {
1930
+ group: "tools",
1931
+ title: "Selection tool — L (or Shift+drag)",
1932
+ html: `<div class="entry wardley-palette-entry" title="Selection tool — L (or Shift+drag)">${U.lasso}</div>`,
1933
+ action: { click: (e) => this.lassoTool.activateSelection(e) }
1934
+ }, e["draw-tool"] = {
1935
+ group: "tools",
1936
+ title: "Draw — click point by point, double-click/Enter finishes, click the start point to close",
1937
+ html: `<div class="entry wardley-palette-entry" title="Draw — click point by point, double-click/Enter finishes, click the start point to close">${U.draw}</div>`,
1938
+ action: { click: () => this.drawTool.toggle() }
1939
+ };
1940
+ for (let t of $t) {
1487
1941
  let n = (e) => {
1488
1942
  let n = this.factory.createNew(t.type, t.label, t.extra ?? {});
1489
1943
  this.create.start(e, n);
@@ -1507,14 +1961,14 @@ var G = "wardley-1-blocks", K = "wardley-2-strategy", Mt = "wardley-3-notes", Nt
1507
1961
  }, Y = {
1508
1962
  id: "method",
1509
1963
  name: "Sourcing"
1510
- }, Ft = {
1964
+ }, tn = {
1511
1965
  id: "props",
1512
1966
  name: "Properties"
1513
1967
  };
1514
1968
  function X(e, t) {
1515
1969
  return e ? `✓ ${t}` : t;
1516
1970
  }
1517
- var It = class {
1971
+ var nn = class {
1518
1972
  modeling;
1519
1973
  static $inject = ["popupMenu", "wardleyModeling"];
1520
1974
  constructor(e, t) {
@@ -1522,7 +1976,7 @@ var It = class {
1522
1976
  }
1523
1977
  getPopupMenuEntries(e) {
1524
1978
  let t = Array.isArray(e) ? e[0] : e;
1525
- return S(t) ? this.componentEntries(t) : {};
1979
+ return Ne(t) ? this.componentEntries(t) : {};
1526
1980
  }
1527
1981
  componentEntries(e) {
1528
1982
  let t = e.decorators ?? {}, n = t.ecosystem ? "ecosystem" : t.market ? "market" : "normal", r = t.method;
@@ -1564,23 +2018,23 @@ var It = class {
1564
2018
  },
1565
2019
  "prop-inertia": {
1566
2020
  label: X(!!t.inertia, "Inertia"),
1567
- group: Ft,
2021
+ group: tn,
1568
2022
  action: () => this.modeling.toggleInertia(e)
1569
2023
  }
1570
2024
  };
1571
2025
  }
1572
- }, Lt = {
2026
+ }, rn = {
1573
2027
  __init__: ["wardleyElementSettings"],
1574
- wardleyElementSettings: ["type", It]
2028
+ wardleyElementSettings: ["type", nn]
1575
2029
  };
1576
2030
  //#endregion
1577
2031
  //#region src/context-pad/WardleyContextPadProvider.ts
1578
2032
  function Z(e, t, n = !1) {
1579
- return `<div class="entry wardley-cp-entry"${n ? " draggable=\"true\"" : ""} title="${t}">${Ze(e)}</div>`;
2033
+ return `<div class="entry wardley-cp-entry"${n ? " draggable=\"true\"" : ""} title="${t}">${M(e)}</div>`;
1580
2034
  }
1581
2035
  //#endregion
1582
2036
  //#region src/context-pad/index.ts
1583
- var Rt = {
2037
+ var an = {
1584
2038
  __init__: ["wardleyContextPadProvider"],
1585
2039
  wardleyContextPadProvider: ["type", class {
1586
2040
  modeling;
@@ -1608,15 +2062,26 @@ var Rt = {
1608
2062
  this.modeling = t, this.connect = n, this.create = r, this.popupMenu = i, this.wardleyModeling = a, this.labelEditing = o, this.evolveDragging = s, this.factory = c, this.colorPicker = l, e.registerProvider(this);
1609
2063
  }
1610
2064
  getContextPadEntries(e) {
1611
- if (x(e)) return { delete: {
1612
- group: "edit",
1613
- title: "Delete connection",
1614
- html: Z(P, "Delete connection"),
1615
- action: { click: () => this.modeling.removeElements([e]) }
1616
- } };
1617
- if (!b(e)) return {};
2065
+ if (b(e)) {
2066
+ let t = e, n = t.wardleyType === "flow";
2067
+ return {
2068
+ "edit-value": {
2069
+ group: "edit",
2070
+ title: n ? "Edit flow value" : "Edit link annotation",
2071
+ html: Z(D, n ? "Edit flow value" : "Edit link annotation"),
2072
+ action: { click: () => this.labelEditing.activateConnection(t) }
2073
+ },
2074
+ delete: {
2075
+ group: "edit",
2076
+ title: "Delete connection",
2077
+ html: Z(O, "Delete connection"),
2078
+ action: { click: () => this.modeling.removeElements([e]) }
2079
+ }
2080
+ };
2081
+ }
2082
+ if (!y(e)) return {};
1618
2083
  let t = e, n = {};
1619
- if (t.wardleyType === "component" || t.wardleyType === "anchor") {
2084
+ if (t.wardleyType === "component" || t.wardleyType === "anchor" || t.wardleyType === "submap" || t.wardleyType === "pipeline") {
1620
2085
  let e = (e) => {
1621
2086
  let n = this.factory.createNew("component", "Component");
1622
2087
  this.create.start(e, n, { source: t });
@@ -1624,7 +2089,7 @@ var Rt = {
1624
2089
  n.append = {
1625
2090
  group: "edit",
1626
2091
  title: "Append component (auto-connect)",
1627
- html: Z(Ae, "Append component", !0),
2092
+ html: Z(Ke, "Append component", !0),
1628
2093
  action: {
1629
2094
  click: e,
1630
2095
  dragstart: e
@@ -1636,7 +2101,7 @@ var Rt = {
1636
2101
  n.connect = {
1637
2102
  group: "edit",
1638
2103
  title: "Connect to existing element",
1639
- html: Z(je, "Connect to existing element", !0),
2104
+ html: Z(qe, "Connect to existing element", !0),
1640
2105
  action: {
1641
2106
  click: r,
1642
2107
  dragstart: r
@@ -1647,15 +2112,15 @@ var Rt = {
1647
2112
  if (t.movement) n["evolve-clear"] = {
1648
2113
  group: "wardley",
1649
2114
  title: "Remove evolve",
1650
- html: Z(Pe, "Remove evolve"),
2115
+ html: Z(Ye, "Remove evolve"),
1651
2116
  action: { click: () => this.wardleyModeling.clearMovement(t) }
1652
2117
  };
1653
- else {
2118
+ else if (t.evolution < .999) {
1654
2119
  let e = (e) => this.evolveDragging.start(e, t);
1655
2120
  n.evolve = {
1656
2121
  group: "wardley",
1657
2122
  title: "Evolve: drag to set the target maturity",
1658
- html: Z(Me, "Evolve: drag to set the target maturity", !0),
2123
+ html: Z(Je, "Evolve: drag to set the target maturity", !0),
1659
2124
  action: {
1660
2125
  click: e,
1661
2126
  dragstart: e
@@ -1665,7 +2130,7 @@ var Rt = {
1665
2130
  n.settings = {
1666
2131
  group: "wardley",
1667
2132
  title: "Settings (type, sourcing, inertia)",
1668
- html: Z(We, "Settings"),
2133
+ html: Z(at, "Settings"),
1669
2134
  action: { click: (e) => {
1670
2135
  let n = e;
1671
2136
  this.popupMenu.open(t, q, {
@@ -1675,28 +2140,50 @@ var Rt = {
1675
2140
  } }
1676
2141
  };
1677
2142
  }
1678
- return t.wardleyType === "note" && (n.color = {
2143
+ if (t.wardleyType === "drawing") {
2144
+ let e = t.strokeStyle === "dashed" ? "dotted" : t.strokeStyle === "dotted" ? void 0 : "dashed", r = `Line style: ${t.strokeStyle ?? "solid"} (click to change)`;
2145
+ n["stroke-style"] = {
2146
+ group: "wardley",
2147
+ title: r,
2148
+ html: Z(st, r),
2149
+ action: { click: () => this.wardleyModeling.updateProperties(t, { strokeStyle: e }) }
2150
+ };
2151
+ }
2152
+ n.color = {
1679
2153
  group: "wardley",
1680
- title: "Note color",
1681
- html: Z(Ge, "Note color"),
2154
+ title: "Color",
2155
+ html: Z(ot, "Color"),
1682
2156
  action: { click: (e) => {
1683
2157
  let n = e;
1684
2158
  this.colorPicker.open(t, n.clientX, n.clientY);
1685
2159
  } }
1686
- }), n["edit-label"] = {
2160
+ };
2161
+ let r = t.businessObject, i = r?.url ?? r?.urlRef;
2162
+ return i && (n["open-link"] = {
2163
+ group: "wardley",
2164
+ title: `Open link (${i})`,
2165
+ html: Z(qe, "Open link"),
2166
+ action: { click: () => window.open(i, "_blank", "noopener") }
2167
+ }), t.wardleyType !== "drawing" && (n["edit-label"] = {
1687
2168
  group: "edit",
1688
2169
  title: "Edit label",
1689
- html: Z(Ne, "Edit label"),
2170
+ html: Z(D, "Edit label"),
1690
2171
  action: { click: () => this.labelEditing.activate(t) }
1691
- }, n.delete = {
2172
+ }), n.delete = {
1692
2173
  group: "edit",
1693
2174
  title: "Delete",
1694
- html: Z(P, "Delete"),
2175
+ html: Z(O, "Delete"),
1695
2176
  action: { click: () => this.modeling.removeElements([t]) }
1696
2177
  }, n;
1697
2178
  }
1698
2179
  }]
1699
- }, zt = class {
2180
+ };
2181
+ //#endregion
2182
+ //#region src/label-editing/WardleyLabelEditing.ts
2183
+ function on(e) {
2184
+ return e.replace(/->/g, "→").replace(/;/g, ",").replace(/\[/g, "(").replace(/\]/g, ")").trim();
2185
+ }
2186
+ var sn = class {
1700
2187
  canvas;
1701
2188
  modeling;
1702
2189
  factory;
@@ -1709,7 +2196,7 @@ var Rt = {
1709
2196
  active = null;
1710
2197
  constructor(e, t, n, r) {
1711
2198
  this.canvas = t, this.modeling = n, this.factory = r, e.on("element.dblclick", (e) => {
1712
- b(e.element) && this.activate(e.element);
2199
+ y(e.element) ? this.activate(e.element) : b(e.element) && this.activateConnection(e.element);
1713
2200
  }), e.on([
1714
2201
  "element.mousedown",
1715
2202
  "drag.init",
@@ -1728,7 +2215,7 @@ var Rt = {
1728
2215
  c || (c = !0, s.removeEventListener("keydown", d), s.removeEventListener("blur", f), s.remove(), this.active = null);
1729
2216
  }, u = () => {
1730
2217
  if (c) return;
1731
- let t = s.value.trim(), n = t && t !== e.wardleyLabel;
2218
+ let t = on(s.value), n = t && t !== e.wardleyLabel;
1732
2219
  if (l(), !n) return;
1733
2220
  let r = i ? t : this.factory.uniqueLabel(t, e.id);
1734
2221
  this.modeling.updateLabel(e, r);
@@ -1748,48 +2235,129 @@ var Rt = {
1748
2235
  cleanup: l
1749
2236
  };
1750
2237
  }
2238
+ activateConnection(e) {
2239
+ this.active?.commit();
2240
+ let t = this.canvas.getContainer(), n = this.canvas.zoom(), r = this.canvas.viewbox(), i = e.waypoints[0], a = e.waypoints[e.waypoints.length - 1];
2241
+ if (!i || !a) return;
2242
+ let o = e.wardleyType === "flow", s = document.createElement("input");
2243
+ s.type = "text", s.className = "wardley-label-input", s.placeholder = o ? "flow value (e.g. $0.10)" : "link annotation", s.value = (o ? e.flowValue : e.linkLabel) ?? "", s.style.position = "absolute", s.style.left = `${((i.x + a.x) / 2 - 60 - r.x) * n}px`, s.style.top = `${((i.y + a.y) / 2 - 26 - r.y) * n}px`, t.appendChild(s), s.focus(), s.select();
2244
+ let c = !1, l = () => {
2245
+ c || (c = !0, s.removeEventListener("keydown", d), s.removeEventListener("blur", f), s.remove(), this.active = null);
2246
+ }, u = () => {
2247
+ if (c) return;
2248
+ let t = s.value.replace(/'/g, "’").replace(/;/g, ",").trim(), n = (o ? e.flowValue : e.linkLabel) ?? "";
2249
+ if (l(), t === n) return;
2250
+ let r = e.businessObject, i = r ? o ? {
2251
+ ...r,
2252
+ ...t ? { flowValue: t } : {}
2253
+ } : {
2254
+ ...r,
2255
+ ...t ? { label: t } : {}
2256
+ } : void 0;
2257
+ i && !t && (o ? delete i.flowValue : delete i.label), this.modeling.updateProperties(e, {
2258
+ [o ? "flowValue" : "linkLabel"]: t || void 0,
2259
+ ...i ? { businessObject: i } : {}
2260
+ });
2261
+ }, d = (e) => {
2262
+ e.key === "Escape" ? (e.preventDefault(), l()) : e.key === "Enter" && (e.preventDefault(), u());
2263
+ }, f = () => u();
2264
+ s.addEventListener("keydown", d), s.addEventListener("blur", f), this.active = {
2265
+ field: s,
2266
+ commit: u,
2267
+ cleanup: l
2268
+ };
2269
+ }
1751
2270
  cancel() {
1752
2271
  this.active?.cleanup();
1753
2272
  }
1754
- }, Bt = {
2273
+ }, cn = {
1755
2274
  __init__: ["wardleyLabelEditing"],
1756
- wardleyLabelEditing: ["type", zt]
1757
- }, Vt = class {
2275
+ wardleyLabelEditing: ["type", sn]
2276
+ }, ln = 2, un = 10, dn = {
2277
+ arrowleft: {
2278
+ x: -1,
2279
+ y: 0
2280
+ },
2281
+ arrowright: {
2282
+ x: 1,
2283
+ y: 0
2284
+ },
2285
+ arrowup: {
2286
+ x: 0,
2287
+ y: -1
2288
+ },
2289
+ arrowdown: {
2290
+ x: 0,
2291
+ y: 1
2292
+ }
2293
+ }, fn = class {
1758
2294
  static $inject = [
1759
2295
  "canvas",
1760
2296
  "commandStack",
1761
2297
  "selection",
1762
- "modeling"
2298
+ "modeling",
2299
+ "wardleyCopyPaste",
2300
+ "wardleyElementFactory",
2301
+ "create",
2302
+ "mouse",
2303
+ "lassoTool",
2304
+ "eventBus"
1763
2305
  ];
1764
- constructor(e, t, n, r) {
1765
- let i = e.getContainer();
1766
- i.hasAttribute("tabindex") || i.setAttribute("tabindex", "0"), i.addEventListener("keydown", (e) => {
1767
- if (Ht(e.target)) return;
1768
- let i = e.ctrlKey || e.metaKey, a = e.key.toLowerCase();
1769
- if (i && a === "z" && !e.shiftKey) e.preventDefault(), t.undo();
1770
- else if (i && a === "z" && e.shiftKey || i && a === "y") e.preventDefault(), t.redo();
1771
- else if (a === "delete" || a === "backspace") {
2306
+ constructor(e, t, n, r, i, a, o, s, c, l) {
2307
+ let u = e.getContainer();
2308
+ u.hasAttribute("tabindex") || u.setAttribute("tabindex", "0");
2309
+ let d = (e) => {
2310
+ if (pn(e.target)) return;
2311
+ let l = e.ctrlKey || e.metaKey, u = e.key.toLowerCase();
2312
+ if (l && u === "z" && !e.shiftKey) e.preventDefault(), t.undo();
2313
+ else if (l && u === "z" && e.shiftKey || l && u === "y") e.preventDefault(), t.redo();
2314
+ else if (l && u === "c") i.copy() && e.preventDefault();
2315
+ else if (l && u === "v") i.paste() && e.preventDefault();
2316
+ else if (l && u === "d") e.preventDefault(), i.duplicate();
2317
+ else if (u === "delete" || u === "backspace") {
1772
2318
  let t = n.get();
1773
2319
  t.length && (e.preventDefault(), r.removeElements(t));
2320
+ } else if (!l && !e.altKey && (u === "c" || u === "u")) {
2321
+ let t = s.getLastMoveEvent();
2322
+ if (t) {
2323
+ e.preventDefault();
2324
+ let n = u === "c" ? a.createNew("component", "Component") : a.createNew("anchor", "User");
2325
+ o.start(t, n);
2326
+ }
2327
+ } else if (!l && !e.altKey && u === "l") {
2328
+ e.preventDefault();
2329
+ let t = s.getLastMoveEvent();
2330
+ c.activateSelection(t ?? e, !!t);
2331
+ } else if (u in dn && !l) {
2332
+ let t = n.get();
2333
+ if (t.length) {
2334
+ e.preventDefault();
2335
+ let n = e.shiftKey ? un : ln, i = dn[u];
2336
+ r.moveElements(t, {
2337
+ x: i.x * n,
2338
+ y: i.y * n
2339
+ });
2340
+ }
1774
2341
  }
1775
- });
2342
+ };
2343
+ document.addEventListener("keydown", d), l.on("diagram.destroy", () => document.removeEventListener("keydown", d));
1776
2344
  }
1777
2345
  };
1778
- function Ht(e) {
2346
+ function pn(e) {
1779
2347
  if (!(e instanceof HTMLElement)) return !1;
1780
2348
  let t = e.tagName;
1781
2349
  return t === "INPUT" || t === "TEXTAREA" || e.isContentEditable;
1782
2350
  }
1783
2351
  //#endregion
1784
2352
  //#region src/keyboard/index.ts
1785
- var Ut = {
2353
+ var mn = {
1786
2354
  __init__: ["wardleyKeyboard"],
1787
- wardleyKeyboard: ["type", Vt]
1788
- }, Q = "wardley.evolve", Wt = .005, Gt = "wardley-evolve-handle";
1789
- function Kt(e) {
2355
+ wardleyKeyboard: ["type", fn]
2356
+ }, Q = "wardley.evolve", hn = .005, gn = "wardley-evolve-handle";
2357
+ function _n(e) {
1790
2358
  return e < 0 ? 0 : e > 1 ? 1 : e;
1791
2359
  }
1792
- var $ = class {
2360
+ var vn = class {
1793
2361
  dragging;
1794
2362
  static $inject = [
1795
2363
  "eventBus",
@@ -1805,32 +2373,32 @@ var $ = class {
1805
2373
  n === void 0 ? delete t.movement : t.movement = n, e.fire("element.changed", { element: t });
1806
2374
  }, s = (e, t) => {
1807
2375
  let r = i.getContainer().getBoundingClientRect(), a = i.viewbox(), o = a.x + (e - r.left) * (a.width / r.width);
1808
- return Kt(n.fromCanvas({
2376
+ return _n(n.fromCanvas({
1809
2377
  x: o,
1810
2378
  y: t
1811
2379
  }).evolution);
1812
2380
  };
1813
2381
  i.getContainer().addEventListener("mousedown", (e) => {
1814
2382
  let t = e.target;
1815
- if (!t?.closest(`.${Gt}`)) return;
2383
+ if (!t?.closest(`.${gn}`)) return;
1816
2384
  let n = t.closest("[data-element-id]")?.getAttribute("data-element-id"), i = n ? a.get(n) : void 0;
1817
2385
  if (!i || i.wardleyType !== "component") return;
1818
2386
  e.stopPropagation(), e.preventDefault();
1819
2387
  let c = i.movement, l = i.y + i.height / 2, u, d = (e) => {
1820
2388
  u = s(e.clientX, l), o(i, { targetEvolution: u });
1821
2389
  }, f = () => {
1822
- document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", f), o(i, c), u !== void 0 && Math.abs(u - i.evolution) > Wt && r.evolveComponent(i, u);
2390
+ document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", f), o(i, c), u !== void 0 && Math.abs(u - i.evolution) > hn && r.evolveComponent(i, u);
1823
2391
  };
1824
2392
  document.addEventListener("mousemove", d), document.addEventListener("mouseup", f);
1825
2393
  }, !0), e.on(`${Q}.move`, (e) => {
1826
- let { shape: t } = e.context, r = t.y + t.height / 2, i = Kt(n.fromCanvas({
2394
+ let { shape: t } = e.context, r = t.y + t.height / 2, i = _n(n.fromCanvas({
1827
2395
  x: e.x,
1828
2396
  y: r
1829
2397
  }).evolution);
1830
2398
  e.context.target = i, o(t, { targetEvolution: i });
1831
2399
  }), e.on(`${Q}.end`, (e) => {
1832
2400
  let t = e.context, { shape: n, target: i } = t;
1833
- o(n, t.originalMovement), i !== void 0 && Math.abs(i - n.evolution) > Wt && r.evolveComponent(n, i), t.committed = !0;
2401
+ o(n, t.originalMovement), i !== void 0 && Math.abs(i - n.evolution) > hn && r.evolveComponent(n, i), t.committed = !0;
1834
2402
  }), e.on(`${Q}.cleanup`, (e) => {
1835
2403
  let t = e.context;
1836
2404
  t && !t.committed && o(t.shape, t.originalMovement);
@@ -1846,10 +2414,10 @@ var $ = class {
1846
2414
  data: { context: n }
1847
2415
  });
1848
2416
  }
1849
- }, qt = {
2417
+ }, yn = {
1850
2418
  __init__: ["wardleyEvolveDragging"],
1851
- wardleyEvolveDragging: ["type", $]
1852
- }, Jt = 500, Yt = class {
2419
+ wardleyEvolveDragging: ["type", vn]
2420
+ }, bn = 500, xn = class {
1853
2421
  static $inject = ["injector", "eventBus"];
1854
2422
  constructor(e, t) {
1855
2423
  let n = e.get("connectionPreview", !1), r = e.get("wardleyLabelEditing", !1);
@@ -1874,18 +2442,18 @@ var $ = class {
1874
2442
  "create.cleanup"
1875
2443
  ], (e) => {
1876
2444
  n.cleanUp(e.context);
1877
- })), r && t.on("create.end", Jt, (e) => {
2445
+ })), r && t.on("create.end", bn, (e) => {
1878
2446
  let { context: t } = e;
1879
2447
  if (!t.source || !t.canExecute || !t.shape) return;
1880
2448
  let n = t.shape;
1881
2449
  setTimeout(() => r.activate(n), 0);
1882
2450
  });
1883
2451
  }
1884
- }, Xt = {
1885
- __depends__: [ge],
2452
+ }, Sn = {
2453
+ __depends__: [ye],
1886
2454
  __init__: ["wardleyAppendBehavior"],
1887
- wardleyAppendBehavior: ["type", Yt]
1888
- }, Zt = class {
2455
+ wardleyAppendBehavior: ["type", xn]
2456
+ }, Cn = class {
1889
2457
  canvas;
1890
2458
  modeling;
1891
2459
  static $inject = [
@@ -1915,7 +2483,7 @@ var $ = class {
1915
2483
  value: void 0,
1916
2484
  title: "No color",
1917
2485
  cls: "wardley-cp-none"
1918
- }, ...xe.map((e) => ({
2486
+ }, ...Te.map((e) => ({
1919
2487
  value: e.value,
1920
2488
  title: e.name,
1921
2489
  cls: ""
@@ -1935,35 +2503,339 @@ var $ = class {
1935
2503
  close() {
1936
2504
  this.popover && (this.popover.remove(), this.popover = void 0, document.removeEventListener("click", this.onDocPointer, !0), document.removeEventListener("keydown", this.onKey, !0));
1937
2505
  }
1938
- }, Qt = {
2506
+ }, wn = {
1939
2507
  __init__: ["wardleyColorPicker"],
1940
- wardleyColorPicker: ["type", Zt]
1941
- }, $t = class extends yt {
2508
+ wardleyColorPicker: ["type", Cn]
2509
+ };
2510
+ //#endregion
2511
+ //#region src/ordering/WardleyOrderingProvider.ts
2512
+ function $(e) {
2513
+ return y(e) && (e.wardleyType === "attitude" || e.wardleyType === "pipeline");
2514
+ }
2515
+ //#endregion
2516
+ //#region src/ordering/index.ts
2517
+ var Tn = {
2518
+ __init__: ["wardleyOrderingProvider"],
2519
+ wardleyOrderingProvider: ["type", class extends be {
2520
+ static $inject = ["eventBus"];
2521
+ constructor(e) {
2522
+ super(e);
2523
+ }
2524
+ getOrdering(e, t) {
2525
+ let n = t.children ?? [];
2526
+ return b(e) ? {
2527
+ parent: t,
2528
+ index: n.filter((t) => t !== e && ($(t) || b(t))).length
2529
+ } : $(e) ? {
2530
+ parent: t,
2531
+ index: n.filter((t) => t !== e && $(t)).length
2532
+ } : { parent: t };
2533
+ }
2534
+ }]
2535
+ }, En = 12, Dn = class {
2536
+ canvas;
2537
+ eventBus;
2538
+ modeling;
2539
+ selection;
2540
+ factory;
2541
+ static $inject = [
2542
+ "canvas",
2543
+ "eventBus",
2544
+ "modeling",
2545
+ "selection",
2546
+ "wardleyElementFactory"
2547
+ ];
2548
+ active = !1;
2549
+ points = [];
2550
+ cursor = null;
2551
+ layer = null;
2552
+ constructor(e, t, n, r, i) {
2553
+ this.canvas = e, this.eventBus = t, this.modeling = n, this.selection = r, this.factory = i, t.on("diagram.destroy", () => this.cancel());
2554
+ }
2555
+ isActive() {
2556
+ return this.active;
2557
+ }
2558
+ toggle() {
2559
+ this.active ? this.cancel() : this.activate();
2560
+ }
2561
+ outerContainer() {
2562
+ let e = this.canvas.getContainer();
2563
+ return e.closest(".wardley-container") ?? e;
2564
+ }
2565
+ activate() {
2566
+ if (this.active) return;
2567
+ this.active = !0, this.points = [], this.cursor = null;
2568
+ let e = this.canvas.getContainer();
2569
+ this.outerContainer().classList.add("wardley-draw-mode"), e.addEventListener("mousedown", this.onMouseDown, !0), e.addEventListener("dblclick", this.onDblClick, !0), e.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("keydown", this.onKeyDown, !0), this.eventBus.fire("tool-manager.update", { tool: "draw" });
2570
+ }
2571
+ finish() {
2572
+ let e = [...this.points];
2573
+ if (this.deactivate(), e.length < 2) return;
2574
+ let t = this.factory.drawingFromCanvasPoints(e), n = this.modeling.createShape(t, {
2575
+ x: t.x + t.width / 2,
2576
+ y: t.y + t.height / 2
2577
+ }, this.canvas.getRootElement());
2578
+ this.selection.select(n);
2579
+ }
2580
+ finishClosed() {
2581
+ let e = [...this.points];
2582
+ if (this.deactivate(), e.length < 3) return;
2583
+ let t = this.factory.drawingFromCanvasPoints(e, { closed: !0 }), n = this.modeling.createShape(t, {
2584
+ x: t.x + t.width / 2,
2585
+ y: t.y + t.height / 2
2586
+ }, this.canvas.getRootElement());
2587
+ this.selection.select(n);
2588
+ }
2589
+ cancel() {
2590
+ this.deactivate();
2591
+ }
2592
+ deactivate() {
2593
+ if (!this.active) return;
2594
+ this.active = !1;
2595
+ let e = this.canvas.getContainer();
2596
+ this.outerContainer().classList.remove("wardley-draw-mode"), e.removeEventListener("mousedown", this.onMouseDown, !0), e.removeEventListener("dblclick", this.onDblClick, !0), e.removeEventListener("mousemove", this.onMouseMove, !0), document.removeEventListener("keydown", this.onKeyDown, !0), this.points = [], this.cursor = null, this.clearPreview(), this.eventBus.fire("tool-manager.update", { tool: null });
2597
+ }
2598
+ toCanvasPoint(e) {
2599
+ let t = this.canvas.getContainer().getBoundingClientRect(), n = this.canvas.viewbox(), r = this.canvas.zoom();
2600
+ return {
2601
+ x: (e.clientX - t.left) / r + n.x,
2602
+ y: (e.clientY - t.top) / r + n.y
2603
+ };
2604
+ }
2605
+ isChromeTarget(e) {
2606
+ return !!e.target?.closest(".djs-palette, .djs-context-pad, .wardley-color-picker");
2607
+ }
2608
+ onMouseDown = (e) => {
2609
+ if (e.button !== 0 || this.isChromeTarget(e)) return;
2610
+ e.preventDefault(), e.stopPropagation();
2611
+ let t = this.toCanvasPoint(e), n = this.points[0];
2612
+ if (n && this.points.length >= 3 && On(t, n) <= En) {
2613
+ this.finishClosed();
2614
+ return;
2615
+ }
2616
+ let r = this.points[this.points.length - 1];
2617
+ if (r && On(t, r) <= En) {
2618
+ this.points.length >= 2 && this.finish();
2619
+ return;
2620
+ }
2621
+ this.points.push(t), this.renderPreview();
2622
+ };
2623
+ onDblClick = (e) => {
2624
+ this.isChromeTarget(e) || (e.preventDefault(), e.stopPropagation(), this.finish());
2625
+ };
2626
+ onMouseMove = (e) => {
2627
+ this.points.length && (this.cursor = this.toCanvasPoint(e), this.renderPreview());
2628
+ };
2629
+ onKeyDown = (e) => {
2630
+ e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(), this.points.length >= 2 ? this.finish() : this.cancel()) : e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), this.finish());
2631
+ };
2632
+ renderPreview() {
2633
+ if (this.clearPreview(), !this.points.length) return;
2634
+ let e = this.canvas.getLayer("wardley-draw-preview", 1e3), t = f("g"), n = this.cursor ? [...this.points, this.cursor] : this.points;
2635
+ l(t, u(f("polyline"), {
2636
+ points: n.map((e) => `${e.x},${e.y}`).join(" "),
2637
+ fill: "none",
2638
+ stroke: g.ink,
2639
+ "stroke-width": 2,
2640
+ "stroke-linecap": "round",
2641
+ "stroke-linejoin": "round",
2642
+ "stroke-dasharray": "5 4"
2643
+ }));
2644
+ let r = this.points[0];
2645
+ if (l(t, u(f("circle"), {
2646
+ cx: r.x,
2647
+ cy: r.y,
2648
+ r: this.points.length >= 3 ? 5 : 3,
2649
+ fill: g.paper,
2650
+ stroke: g.ink,
2651
+ "stroke-width": 1.5
2652
+ })), this.points.length >= 2) {
2653
+ let e = this.points[this.points.length - 1];
2654
+ l(t, u(f("circle"), {
2655
+ cx: e.x,
2656
+ cy: e.y,
2657
+ r: 5,
2658
+ fill: g.paper,
2659
+ stroke: g.ink,
2660
+ "stroke-width": 1.5
2661
+ }));
2662
+ }
2663
+ l(e, t), this.layer = t;
2664
+ }
2665
+ clearPreview() {
2666
+ this.layer &&= (p(this.layer), null);
2667
+ }
2668
+ };
2669
+ function On(e, t) {
2670
+ return Math.hypot(e.x - t.x, e.y - t.y);
2671
+ }
2672
+ //#endregion
2673
+ //#region src/draw-tool/WardleyDrawingHandles.ts
2674
+ var kn = class {
2675
+ eventBus;
2676
+ canvas;
2677
+ modeling;
2678
+ grid;
2679
+ static $inject = [
2680
+ "eventBus",
2681
+ "canvas",
2682
+ "wardleyModeling",
2683
+ "evolutionGrid"
2684
+ ];
2685
+ shape = null;
2686
+ group = null;
2687
+ dragPreview = null;
2688
+ constructor(e, t, n, r) {
2689
+ this.eventBus = e, this.canvas = t, this.modeling = n, this.grid = r, e.on("selection.changed", (e) => {
2690
+ let t = e.newSelection ?? [], n = t.length === 1 ? t[0] : null;
2691
+ this.attach(y(n) && n.wardleyType === "drawing" ? n : null);
2692
+ }), e.on("element.changed", (e) => {
2693
+ this.shape && e.element === this.shape && this.render();
2694
+ }), e.on(["diagram.clear", "diagram.destroy"], () => this.attach(null));
2695
+ }
2696
+ attach(e) {
2697
+ this.shape = e, this.render();
2698
+ }
2699
+ absolutePoints() {
2700
+ let e = this.shape;
2701
+ return (e.drawingPoints ?? []).map((t) => ({
2702
+ x: e.x + t.x,
2703
+ y: e.y + t.y
2704
+ }));
2705
+ }
2706
+ render() {
2707
+ if (this.clear(), !this.shape) return;
2708
+ let e = this.canvas.getLayer("wardley-drawing-handles", 1100), t = f("g");
2709
+ this.absolutePoints().forEach((e, n) => {
2710
+ let r = u(f("circle"), {
2711
+ cx: e.x,
2712
+ cy: e.y,
2713
+ r: 5,
2714
+ fill: g.paper,
2715
+ stroke: g.ink,
2716
+ "stroke-width": 1.5,
2717
+ class: "wardley-drawing-handle"
2718
+ });
2719
+ r.addEventListener("mousedown", (e) => this.startDrag(e, n)), l(t, r);
2720
+ }), l(e, t), this.group = t;
2721
+ }
2722
+ startDrag(e, t) {
2723
+ if (e.button !== 0 || !this.shape) return;
2724
+ e.preventDefault(), e.stopPropagation();
2725
+ let n = this.shape, r = this.absolutePoints(), i = (e) => {
2726
+ r[t] = this.toCanvasPoint(e), this.renderDragPreview(r, !!n.closed);
2727
+ }, a = (e) => {
2728
+ document.removeEventListener("mousemove", i, !0), document.removeEventListener("mouseup", a, !0), r[t] = this.toCanvasPoint(e), this.clearDragPreview(), this.commit(n, r);
2729
+ };
2730
+ document.addEventListener("mousemove", i, !0), document.addEventListener("mouseup", a, !0);
2731
+ }
2732
+ commit(e, t) {
2733
+ let n = t.map((e) => e.x), r = t.map((e) => e.y), i = Math.min(...n), a = Math.min(...r), o = this.grid.fromCanvas(t[0]);
2734
+ this.modeling.updateProperties(e, {
2735
+ x: i,
2736
+ y: a,
2737
+ width: Math.max(Math.max(...n) - i, 4),
2738
+ height: Math.max(Math.max(...r) - a, 4),
2739
+ drawingPoints: t.map((e) => ({
2740
+ x: e.x - i,
2741
+ y: e.y - a
2742
+ })),
2743
+ evolution: o.evolution,
2744
+ visibility: o.visibility
2745
+ }), this.render();
2746
+ }
2747
+ renderDragPreview(e, t) {
2748
+ this.clearDragPreview();
2749
+ let n = this.canvas.getLayer("wardley-drawing-handles", 1100), r = u(f(t ? "polygon" : "polyline"), {
2750
+ points: e.map((e) => `${e.x},${e.y}`).join(" "),
2751
+ fill: "none",
2752
+ stroke: g.ink,
2753
+ "stroke-width": 1.5,
2754
+ "stroke-dasharray": "5 4",
2755
+ "pointer-events": "none"
2756
+ });
2757
+ l(n, r), this.dragPreview = r;
2758
+ }
2759
+ clearDragPreview() {
2760
+ this.dragPreview &&= (p(this.dragPreview), null);
2761
+ }
2762
+ clear() {
2763
+ this.clearDragPreview(), this.group &&= (p(this.group), null);
2764
+ }
2765
+ toCanvasPoint(e) {
2766
+ let t = this.canvas.getContainer().getBoundingClientRect(), n = this.canvas.viewbox(), r = this.canvas.zoom();
2767
+ return {
2768
+ x: (e.clientX - t.left) / r + n.x,
2769
+ y: (e.clientY - t.top) / r + n.y
2770
+ };
2771
+ }
2772
+ };
2773
+ //#endregion
2774
+ //#region src/draw-tool/WardleyDrawingHitProvider.ts
2775
+ function An(e) {
2776
+ return y(e) && e.wardleyType === "drawing";
2777
+ }
2778
+ var jn = class {
2779
+ static $inject = ["eventBus", "interactionEvents"];
2780
+ constructor(e, t) {
2781
+ e.on("interactionEvents.createHit", (e) => {
2782
+ if (!(!An(e.element) || !e.gfx)) return Mn(e.element, e.gfx), !1;
2783
+ }), e.on("interactionEvents.updateHit", (e) => {
2784
+ if (!(!An(e.element) || !e.gfx)) return t.removeHits(e.gfx), Mn(e.element, e.gfx), !1;
2785
+ });
2786
+ }
2787
+ };
2788
+ function Mn(e, t) {
2789
+ let n = e.drawingPoints ?? [], r = f(e.closed ? "polygon" : "polyline");
2790
+ u(r, {
2791
+ points: n.map((e) => `${e.x},${e.y}`).join(" "),
2792
+ class: "djs-hit djs-hit-stroke",
2793
+ fill: "none",
2794
+ stroke: "white",
2795
+ "stroke-width": 15,
2796
+ "stroke-opacity": 0
2797
+ }), l(t, r);
2798
+ }
2799
+ //#endregion
2800
+ //#region src/draw-tool/index.ts
2801
+ var Nn = {
2802
+ __init__: [
2803
+ "wardleyDrawTool",
2804
+ "wardleyDrawingHandles",
2805
+ "wardleyDrawingHitProvider"
2806
+ ],
2807
+ wardleyDrawTool: ["type", Dn],
2808
+ wardleyDrawingHandles: ["type", kn],
2809
+ wardleyDrawingHitProvider: ["type", jn]
2810
+ }, Pn = class extends Mt {
1942
2811
  _getModules() {
1943
2812
  return [
1944
2813
  ...super._getModules(),
1945
- ae,
1946
- de,
1947
2814
  oe,
2815
+ fe,
1948
2816
  se,
1949
2817
  ce,
1950
2818
  le,
1951
2819
  ue,
1952
- fe,
2820
+ de,
1953
2821
  pe,
1954
2822
  me,
1955
- Et,
1956
- kt,
1957
- ke,
1958
- jt,
1959
- Pt,
1960
- Rt,
1961
- Bt,
1962
- Ut,
1963
- qt,
1964
- Lt,
2823
+ he,
2824
+ Gt,
1965
2825
  Xt,
1966
- Qt
2826
+ Ge,
2827
+ Qt,
2828
+ en,
2829
+ an,
2830
+ cn,
2831
+ mn,
2832
+ yn,
2833
+ rn,
2834
+ Sn,
2835
+ wn,
2836
+ Kt,
2837
+ Tn,
2838
+ Nn
1967
2839
  ];
1968
2840
  }
1969
2841
  undo() {
@@ -1980,6 +2852,6 @@ var $ = class {
1980
2852
  }
1981
2853
  };
1982
2854
  //#endregion
1983
- export { E as EvolutionGrid, Je as ICON_ADD, Ke as ICON_ASPECT_RATIO, Re as ICON_CODE, Le as ICON_DATA_OBJECT, P as ICON_DELETE, ze as ICON_DOWNLOAD, Ne as ICON_EDIT, Ve as ICON_FOLDER_OPEN, He as ICON_IMAGE, qe as ICON_MENU, Ue as ICON_NEW, N as ICON_PERSON, Ie as ICON_REDO, Be as ICON_SHARE, Fe as ICON_UNDO, Ye as ICON_VISIBILITY, $t as Modeler, xe as NOTE_COLORS, yt as NavigatedViewer, q as POPUP_PROVIDER_ID, _t as PanConstraint, vt as PanConstraintModule, we as ROOT_ID, ut as Viewer, Yt as WardleyAppendBehavior, Ee as WardleyBaseViewer, Zt as WardleyColorPicker, _ as WardleyElementFactory, It as WardleyElementSettingsProvider, $ as WardleyEvolveDragging, ct as WardleyExporter, st as WardleyImporter, zt as WardleyLabelEditing, wt as WardleyModeling, $e as WardleyRenderer, Ot as WardleyRules, ke as evolutionConstraintModule, M as evolutionGridModule, Ze as iconMarkup, lt as ioModule, S as isComponent, C as isPipeline, x as isWardleyConnection, b as isWardleyShape, Bt as labelEditingModule, Ce as saveSVG, jt as stageSnappingModule, Xt as wardleyAppendModule, Qt as wardleyColorPickerModule, Rt as wardleyContextPadModule, it as wardleyDrawModule, qt as wardleyEvolveModule, Ut as wardleyKeyboardModule, w as wardleyModelModule, Et as wardleyModelingModule, Pt as wardleyPaletteModule, Lt as wardleyPopupModule, kt as wardleyRulesModule };
2855
+ export { g as COLORS, Re as EvolutionGrid, ut as ICON_ADD, ct as ICON_ASPECT_RATIO, $e as ICON_CODE, Qe as ICON_DATA_OBJECT, O as ICON_DELETE, et as ICON_DOWNLOAD, D as ICON_EDIT, nt as ICON_FOLDER_OPEN, rt as ICON_IMAGE, lt as ICON_MENU, it as ICON_NEW, E as ICON_PERSON, Ze as ICON_REDO, tt as ICON_SHARE, Xe as ICON_UNDO, dt as ICON_VISIBILITY, Pn as Modeler, Te as NOTE_COLORS, Mt as NavigatedViewer, m as PLOT, q as POPUP_PROVIDER_ID, At as PanConstraint, jt as PanConstraintModule, De as ROOT_ID, Ct as Viewer, xn as WardleyAppendBehavior, ke as WardleyBaseViewer, Cn as WardleyColorPicker, Ae as WardleyElementFactory, nn as WardleyElementSettingsProvider, vn as WardleyEvolveDragging, xt as WardleyExporter, bt as WardleyImporter, sn as WardleyLabelEditing, z as WardleyModeling, N as WardleyRenderer, Yt as WardleyRules, Ge as evolutionConstraintModule, T as evolutionGridModule, M as iconMarkup, St as ioModule, Ne as isComponent, x as isPipeline, b as isWardleyConnection, y as isWardleyShape, cn as labelEditingModule, Ee as saveSVG, Qt as stageSnappingModule, Sn as wardleyAppendModule, wn as wardleyColorPickerModule, an as wardleyContextPadModule, _t as wardleyDrawModule, yn as wardleyEvolveModule, mn as wardleyKeyboardModule, Fe as wardleyModelModule, Gt as wardleyModelingModule, en as wardleyPaletteModule, rn as wardleyPopupModule, Xt as wardleyRulesModule };
1984
2856
 
1985
2857
  //# sourceMappingURL=index.js.map