whipped 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cli.js +1294 -259
  2. package/dist/mcp-server.js +150 -2
  3. package/dist/migrations/014_companion_sessions.sql +34 -0
  4. package/dist/migrations/015_companion_worktree_mode.sql +45 -0
  5. package/dist/migrations/016_companion_plans.sql +22 -0
  6. package/dist/migrations/017_companion_saved_plans.sql +23 -0
  7. package/dist/migrations/018_generalize_plan_session_ref.sql +29 -0
  8. package/dist/migrations/019_rename_plan_to_canvas.sql +20 -0
  9. package/dist/web-ui/assets/abnfDiagram-VRR7QNED-RwOyl_Kz.js +119 -0
  10. package/dist/web-ui/assets/arc-DmDBHE0H.js +131 -0
  11. package/dist/web-ui/assets/architectureDiagram-ZJ3FMSHR-RTwadm6J.js +8821 -0
  12. package/dist/web-ui/assets/blockDiagram-677ZJIJ3-Dvv5uMUE.js +3801 -0
  13. package/dist/web-ui/assets/c4Diagram-LMCZKHZV-bvr9R9cD.js +2479 -0
  14. package/dist/web-ui/assets/channel-BGhlETgZ.js +7 -0
  15. package/dist/web-ui/assets/chunk-2Q5K7J3B-BRq-Qbau.js +17 -0
  16. package/dist/web-ui/assets/chunk-32BRIVSS-Dy1BUZGx.js +116 -0
  17. package/dist/web-ui/assets/chunk-5VM5RSS4-DCUiIwIc.js +19 -0
  18. package/dist/web-ui/assets/chunk-EX3LRPZG-Cg_Vtzwz.js +1996 -0
  19. package/dist/web-ui/assets/chunk-JWPE2WC7-BW4n_ZhH.js +17 -0
  20. package/dist/web-ui/assets/chunk-MOJQB5TN-BykRa615.js +855 -0
  21. package/dist/web-ui/assets/chunk-RYQCIY6F-D4F7oV1d.js +476 -0
  22. package/dist/web-ui/assets/chunk-V7JOEXUC-DD4mm30h.js +2022 -0
  23. package/dist/web-ui/assets/chunk-VR4S4FIN-Fgvcluvk.js +25 -0
  24. package/dist/web-ui/assets/chunk-XXDRQBXY-C4FVmO5r.js +13 -0
  25. package/dist/web-ui/assets/classDiagram-OUVF2IWQ-DD4KIYF1.js +24 -0
  26. package/dist/web-ui/assets/classDiagram-v2-EOCWNBFH-DD4KIYF1.js +24 -0
  27. package/dist/web-ui/assets/cose-bilkent-JH36ORCC-ekFwvYt9.js +4943 -0
  28. package/dist/web-ui/assets/cynefin-VYW2F7L2-DTNV7gvQ.js +31527 -0
  29. package/dist/web-ui/assets/cynefinDiagram-TSTJHNR4-koYialeC.js +454 -0
  30. package/dist/web-ui/assets/cytoscape.esm-CaQ7Fomf.js +30346 -0
  31. package/dist/web-ui/assets/dagre-VKFMJZFB-Do43FV3o.js +526 -0
  32. package/dist/web-ui/assets/defaultLocale-B2RvLBDe.js +206 -0
  33. package/dist/web-ui/assets/diagram-FQU43EPY-D0STdny6.js +636 -0
  34. package/dist/web-ui/assets/diagram-G47NLZAW-D9g6BdZT.js +858 -0
  35. package/dist/web-ui/assets/diagram-NH7WQ7WH-zLW6CAmi.js +212 -0
  36. package/dist/web-ui/assets/diagram-OA4YK3LP-CA5tvsYw.js +492 -0
  37. package/dist/web-ui/assets/diagram-WEI45ONY-CLmYUHR0.js +309 -0
  38. package/dist/web-ui/assets/ebnfDiagram-CCIWWBDH-KkHubBI6.js +139 -0
  39. package/dist/web-ui/assets/erDiagram-Q63AITRT-BJna2u1n.js +1238 -0
  40. package/dist/web-ui/assets/flowDiagram-23GEKE2U-DVJKalah.js +2353 -0
  41. package/dist/web-ui/assets/ganttDiagram-NO4QXBWP-D9HwNV4u.js +3733 -0
  42. package/dist/web-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  43. package/dist/web-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  44. package/dist/web-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  45. package/dist/web-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  46. package/dist/web-ui/assets/geist-mono-cyrillic-ext-wght-normal-I4S5GZfc.woff2 +0 -0
  47. package/dist/web-ui/assets/geist-mono-cyrillic-wght-normal-BmXc_FBt.woff2 +0 -0
  48. package/dist/web-ui/assets/geist-mono-latin-ext-wght-normal-DrnZ1wKl.woff2 +0 -0
  49. package/dist/web-ui/assets/geist-mono-latin-wght-normal-B_7UjwxQ.woff2 +0 -0
  50. package/dist/web-ui/assets/geist-mono-symbols2-wght-normal-GZpp1pK2.woff2 +0 -0
  51. package/dist/web-ui/assets/geist-mono-vietnamese-wght-normal-D8KDMBhC.woff2 +0 -0
  52. package/dist/web-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  53. package/dist/web-ui/assets/gitGraphDiagram-IHSO6WYX-B7wnoO0J.js +1385 -0
  54. package/dist/web-ui/assets/graph-BMLV0goG.js +2042 -0
  55. package/dist/web-ui/assets/{index-CRXPsGTP.css → index-DPjATOCj.css} +800 -1207
  56. package/dist/web-ui/assets/{index-CuGz83Sg.js → index-DZ7I8r_C.js} +41629 -39831
  57. package/dist/web-ui/assets/infoDiagram-FWYZ7A6U-BY6XoiF8.js +32 -0
  58. package/dist/web-ui/assets/init-ZxktEp_H.js +16 -0
  59. package/dist/web-ui/assets/ishikawaDiagram-FXEZZL3T-BaZVnO8j.js +967 -0
  60. package/dist/web-ui/assets/journeyDiagram-5HDEW3XC-CUA6DUAQ.js +1256 -0
  61. package/dist/web-ui/assets/kanban-definition-HUTT4EX6-5W5tiWrd.js +1055 -0
  62. package/dist/web-ui/assets/katex-CqNtglxf.js +14499 -0
  63. package/dist/web-ui/assets/layout-BNmRhaUB.js +2359 -0
  64. package/dist/web-ui/assets/linear-CfvGIyDE.js +340 -0
  65. package/dist/web-ui/assets/map-BEO0Bu8q.js +298 -0
  66. package/dist/web-ui/assets/mermaid.core-BRk3IzY2.js +26639 -0
  67. package/dist/web-ui/assets/mindmap-definition-LN4V7U3C-2GmLg6ou.js +1183 -0
  68. package/dist/web-ui/assets/ordinal-DSZU4PqD.js +76 -0
  69. package/dist/web-ui/assets/pegDiagram-2B236MQR-gTEdrkJg.js +127 -0
  70. package/dist/web-ui/assets/pieDiagram-ENE6RG2P-CYXjIhqC.js +318 -0
  71. package/dist/web-ui/assets/quadrantDiagram-ABIIQ3AL-BStRZxwf.js +1341 -0
  72. package/dist/web-ui/assets/railroadDiagram-RFXS5EU6-btveDRG2.js +93 -0
  73. package/dist/web-ui/assets/requirementDiagram-TGXJPOKE-Cy_155rE.js +1205 -0
  74. package/dist/web-ui/assets/sankeyDiagram-HTMAVEWB-Chtvw3_G.js +1264 -0
  75. package/dist/web-ui/assets/sequenceDiagram-DBY2YBRQ-DDuMVEX1.js +4523 -0
  76. package/dist/web-ui/assets/sizeCapture-X5ZJPWSS-Bylf0o6J.js +64 -0
  77. package/dist/web-ui/assets/stateDiagram-2N3HPSRC-DIzLeR5G.js +453 -0
  78. package/dist/web-ui/assets/stateDiagram-v2-6OUMAXLB-zG_WjT1-.js +23 -0
  79. package/dist/web-ui/assets/swimlanes-5IMT3BWC-TKaCmVta.js +8575 -0
  80. package/dist/web-ui/assets/swimlanesDiagram-G3AALYLV-C5eB3qqS.js +21 -0
  81. package/dist/web-ui/assets/timeline-definition-FHXFAJF6-CC5Ujpcu.js +1606 -0
  82. package/dist/web-ui/assets/vennDiagram-L72KCM5P-DUSVXSYT.js +2523 -0
  83. package/dist/web-ui/assets/wardleyDiagram-EHGQE667-CoP9xn89.js +978 -0
  84. package/dist/web-ui/assets/xychartDiagram-FW5EYKEG-B9FqP_kk.js +1972 -0
  85. package/dist/web-ui/index.html +2 -2
  86. package/package.json +14 -16
@@ -0,0 +1,978 @@
1
+ var _a;
2
+ import { p as populateCommonDb } from "./chunk-JWPE2WC7-BW4n_ZhH.js";
3
+ import { s as setAccDescription, g as getAccDescription, o as getDiagramTitle, n as setDiagramTitle, a as getAccTitle, b as setAccTitle, _ as __name, E as getThemeVariables3, y as getConfig, A as cleanAndMerge, l as log, D as selectSvgElement, e as configureSvgSize, p as clear, c as getConfig2 } from "./mermaid.core-BRk3IzY2.js";
4
+ import { p as parse } from "./cynefin-VYW2F7L2-DTNV7gvQ.js";
5
+ import "./index-DZ7I8r_C.js";
6
+ var toPercent = /* @__PURE__ */ __name((value, context) => {
7
+ const normalized = value <= 1 ? value * 100 : value;
8
+ if (normalized < 0 || normalized > 100) {
9
+ throw new Error(
10
+ `${context} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${value}`
11
+ );
12
+ }
13
+ return normalized;
14
+ }, "toPercent");
15
+ var toCoordinates = /* @__PURE__ */ __name((visibility, evolution, context) => {
16
+ return {
17
+ x: toPercent(evolution, `${context} evolution`),
18
+ y: toPercent(visibility, `${context} visibility`)
19
+ };
20
+ }, "toCoordinates");
21
+ var getFlowFromPort = /* @__PURE__ */ __name((port) => {
22
+ if (!port) {
23
+ return void 0;
24
+ }
25
+ if (port === "+<>") {
26
+ return "bidirectional";
27
+ }
28
+ if (port === "+<") {
29
+ return "backward";
30
+ }
31
+ if (port === "+>") {
32
+ return "forward";
33
+ }
34
+ return void 0;
35
+ }, "getFlowFromPort");
36
+ var extractFlowFromArrow = /* @__PURE__ */ __name((arrow) => {
37
+ if (!(arrow == null ? void 0 : arrow.startsWith("+"))) {
38
+ return {};
39
+ }
40
+ const labelMatch = /^\+'([^']*)'/.exec(arrow);
41
+ const flowLabel = labelMatch == null ? void 0 : labelMatch[1];
42
+ if (arrow.includes("<>")) {
43
+ return { flow: "bidirectional", label: flowLabel };
44
+ }
45
+ if (arrow.includes("<")) {
46
+ return { flow: "backward", label: flowLabel };
47
+ }
48
+ if (arrow.includes(">")) {
49
+ return { flow: "forward", label: flowLabel };
50
+ }
51
+ return { label: flowLabel };
52
+ }, "extractFlowFromArrow");
53
+ var populateDb = /* @__PURE__ */ __name((ast, db) => {
54
+ populateCommonDb(ast, db);
55
+ if (ast.size) {
56
+ db.setSize(ast.size.width, ast.size.height);
57
+ }
58
+ if (ast.evolution) {
59
+ const stages = ast.evolution.stages.map((stage) => {
60
+ if (stage.secondName) {
61
+ return `${stage.name.trim()} / ${stage.secondName.trim()}`;
62
+ }
63
+ return stage.name.trim();
64
+ });
65
+ const stageBoundaries = ast.evolution.stages.filter((stage) => stage.boundary !== void 0).map((stage) => stage.boundary);
66
+ db.updateAxes({ stages, stageBoundaries });
67
+ }
68
+ ast.anchors.forEach((anchor) => {
69
+ const coords = toCoordinates(anchor.visibility, anchor.evolution, `Anchor "${anchor.name}"`);
70
+ db.addNode(anchor.name, anchor.name, coords.x, coords.y, "anchor");
71
+ });
72
+ ast.components.forEach((component) => {
73
+ var _a2;
74
+ const coords = toCoordinates(
75
+ component.visibility,
76
+ component.evolution,
77
+ `Component "${component.name}"`
78
+ );
79
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
80
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
81
+ const sourceStrategy = (_a2 = component.decorator) == null ? void 0 : _a2.strategy;
82
+ db.addNode(
83
+ component.name,
84
+ component.name,
85
+ coords.x,
86
+ coords.y,
87
+ "component",
88
+ labelOffsetX,
89
+ labelOffsetY,
90
+ component.inertia,
91
+ sourceStrategy
92
+ );
93
+ });
94
+ ast.notes.forEach((note) => {
95
+ const coords = toCoordinates(note.visibility, note.evolution, `Note "${note.text}"`);
96
+ db.addNote(note.text, coords.x, coords.y);
97
+ });
98
+ ast.pipelines.forEach((pipeline) => {
99
+ const parentNode = db.getNode(pipeline.parent);
100
+ if (!parentNode || typeof parentNode.y !== "number") {
101
+ throw new Error(
102
+ `Pipeline "${pipeline.parent}" must reference an existing component with coordinates.`
103
+ );
104
+ }
105
+ const parentY = parentNode.y;
106
+ db.startPipeline(pipeline.parent);
107
+ pipeline.components.forEach((component) => {
108
+ const componentId = `${pipeline.parent}_${component.name}`;
109
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
110
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
111
+ const x = toPercent(component.evolution, `Pipeline component "${component.name}" evolution`);
112
+ db.addNode(
113
+ componentId,
114
+ component.name,
115
+ x,
116
+ parentY,
117
+ "pipeline-component",
118
+ labelOffsetX,
119
+ labelOffsetY
120
+ );
121
+ db.addPipelineComponent(pipeline.parent, componentId);
122
+ });
123
+ });
124
+ ast.links.forEach((link) => {
125
+ const isDashed = !!link.arrow && (link.arrow.includes("-.->") || link.arrow.includes(".-."));
126
+ let flow = getFlowFromPort(link.fromPort) ?? getFlowFromPort(link.toPort);
127
+ const { flow: arrowFlow, label: flowLabel } = extractFlowFromArrow(link.arrow);
128
+ if (!flow && arrowFlow) {
129
+ flow = arrowFlow;
130
+ }
131
+ const annotation = link.linkLabel;
132
+ const label = flowLabel ?? annotation;
133
+ db.addLink(db.resolveNodeId(link.from), db.resolveNodeId(link.to), isDashed, label, flow);
134
+ });
135
+ ast.evolves.forEach((evolve) => {
136
+ const node = db.getNode(evolve.component);
137
+ if ((node == null ? void 0 : node.y) !== void 0) {
138
+ const target = toPercent(evolve.target, `Evolve target for "${evolve.component}"`);
139
+ db.addTrend(evolve.component, target, node.y);
140
+ }
141
+ });
142
+ if (ast.annotations.length > 0) {
143
+ const annotationsBox = ast.annotations[0];
144
+ const coords = toCoordinates(annotationsBox.x, annotationsBox.y, "Annotations box");
145
+ db.setAnnotationsBox(coords.x, coords.y);
146
+ }
147
+ ast.annotation.forEach((annotation) => {
148
+ const coords = toCoordinates(annotation.x, annotation.y, `Annotation ${annotation.number}`);
149
+ db.addAnnotation(annotation.number, [{ x: coords.x, y: coords.y }], annotation.text);
150
+ });
151
+ ast.accelerators.forEach((accelerator) => {
152
+ const coords = toCoordinates(accelerator.x, accelerator.y, `Accelerator "${accelerator.name}"`);
153
+ db.addAccelerator(accelerator.name, coords.x, coords.y);
154
+ });
155
+ ast.deaccelerators.forEach((deaccelerator) => {
156
+ const coords = toCoordinates(
157
+ deaccelerator.x,
158
+ deaccelerator.y,
159
+ `Deaccelerator "${deaccelerator.name}"`
160
+ );
161
+ db.addDeaccelerator(deaccelerator.name, coords.x, coords.y);
162
+ });
163
+ }, "populateDb");
164
+ var parser = {
165
+ parser: {
166
+ // @ts-expect-error - WardleyDB is not assignable to DiagramDB
167
+ yy: void 0
168
+ },
169
+ parse: /* @__PURE__ */ __name(async (input) => {
170
+ var _a2;
171
+ const ast = await parse("wardley", input);
172
+ log.debug(ast);
173
+ const db = (_a2 = parser.parser) == null ? void 0 : _a2.yy;
174
+ if (!db || typeof db.addNode !== "function") {
175
+ throw new Error(
176
+ "parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
177
+ );
178
+ }
179
+ populateDb(ast, db);
180
+ }, "parse")
181
+ };
182
+ var WardleyBuilder = (_a = class {
183
+ constructor() {
184
+ this.nodes = /* @__PURE__ */ new Map();
185
+ this.links = [];
186
+ this.trends = /* @__PURE__ */ new Map();
187
+ this.pipelines = /* @__PURE__ */ new Map();
188
+ this.annotations = [];
189
+ this.notes = [];
190
+ this.accelerators = [];
191
+ this.deaccelerators = [];
192
+ this.axes = {};
193
+ }
194
+ addNode(node) {
195
+ const existing = this.nodes.get(node.id) ?? { id: node.id, label: node.label };
196
+ const merged = {
197
+ ...existing,
198
+ ...node,
199
+ className: node.className ?? existing.className,
200
+ labelOffsetX: node.labelOffsetX ?? existing.labelOffsetX,
201
+ labelOffsetY: node.labelOffsetY ?? existing.labelOffsetY
202
+ };
203
+ this.nodes.set(node.id, merged);
204
+ }
205
+ addLink(link) {
206
+ this.links.push(link);
207
+ }
208
+ addTrend(trend) {
209
+ this.trends.set(trend.nodeId, trend);
210
+ }
211
+ startPipeline(nodeId) {
212
+ this.pipelines.set(nodeId, { nodeId, componentIds: [] });
213
+ const node = this.nodes.get(nodeId);
214
+ if (node) {
215
+ node.isPipelineParent = true;
216
+ }
217
+ }
218
+ addPipelineComponent(pipelineNodeId, componentId) {
219
+ const pipeline = this.pipelines.get(pipelineNodeId);
220
+ if (pipeline) {
221
+ pipeline.componentIds.push(componentId);
222
+ }
223
+ const node = this.nodes.get(componentId);
224
+ if (node) {
225
+ node.inPipeline = true;
226
+ }
227
+ }
228
+ addAnnotation(annotation) {
229
+ this.annotations.push(annotation);
230
+ }
231
+ addNote(note) {
232
+ this.notes.push(note);
233
+ }
234
+ addAccelerator(accelerator) {
235
+ this.accelerators.push(accelerator);
236
+ }
237
+ addDeaccelerator(deaccelerator) {
238
+ this.deaccelerators.push(deaccelerator);
239
+ }
240
+ setAnnotationsBox(x, y) {
241
+ this.annotationsBox = { x, y };
242
+ }
243
+ setAxes(partial) {
244
+ this.axes = {
245
+ ...this.axes,
246
+ ...partial
247
+ };
248
+ }
249
+ setSize(width, height) {
250
+ this.size = { width, height };
251
+ }
252
+ getNode(id) {
253
+ return this.nodes.get(id);
254
+ }
255
+ /**
256
+ * Resolve a name to a node ID. Tries exact ID match first,
257
+ * then falls back to finding a node whose label matches the name
258
+ * (handles pipeline components which have synthetic IDs like "Parent_Child").
259
+ */
260
+ resolveNodeId(name) {
261
+ if (this.nodes.has(name)) {
262
+ return name;
263
+ }
264
+ for (const [id, node] of this.nodes) {
265
+ if (node.label === name) {
266
+ return id;
267
+ }
268
+ }
269
+ return name;
270
+ }
271
+ build() {
272
+ const nodes = [];
273
+ for (const node of this.nodes.values()) {
274
+ if (typeof node.x !== "number" || typeof node.y !== "number") {
275
+ throw new Error(`Node "${node.label}" is missing coordinates`);
276
+ }
277
+ nodes.push(node);
278
+ }
279
+ return {
280
+ nodes,
281
+ links: [...this.links],
282
+ trends: [...this.trends.values()],
283
+ pipelines: [...this.pipelines.values()],
284
+ annotations: [...this.annotations],
285
+ notes: [...this.notes],
286
+ accelerators: [...this.accelerators],
287
+ deaccelerators: [...this.deaccelerators],
288
+ annotationsBox: this.annotationsBox,
289
+ axes: { ...this.axes },
290
+ size: this.size
291
+ };
292
+ }
293
+ clear() {
294
+ this.nodes.clear();
295
+ this.links = [];
296
+ this.trends.clear();
297
+ this.pipelines.clear();
298
+ this.annotations = [];
299
+ this.notes = [];
300
+ this.accelerators = [];
301
+ this.deaccelerators = [];
302
+ this.annotationsBox = void 0;
303
+ this.axes = {};
304
+ this.size = void 0;
305
+ }
306
+ }, __name(_a, "WardleyBuilder"), _a);
307
+ var builder = new WardleyBuilder();
308
+ function getConfig3() {
309
+ return getConfig2()["wardley-beta"];
310
+ }
311
+ __name(getConfig3, "getConfig");
312
+ function addNode(id, label, x, y, className, labelOffsetX, labelOffsetY, inertia, sourceStrategy) {
313
+ builder.addNode({
314
+ id,
315
+ label,
316
+ x,
317
+ y,
318
+ className,
319
+ labelOffsetX,
320
+ labelOffsetY,
321
+ inertia,
322
+ sourceStrategy
323
+ });
324
+ }
325
+ __name(addNode, "addNode");
326
+ function addLink(sourceId, targetId, dashed = false, label, flow) {
327
+ builder.addLink({
328
+ source: sourceId,
329
+ target: targetId,
330
+ dashed,
331
+ label,
332
+ flow
333
+ });
334
+ }
335
+ __name(addLink, "addLink");
336
+ function addTrend(nodeId, targetX, targetY) {
337
+ builder.addTrend({ nodeId, targetX, targetY });
338
+ }
339
+ __name(addTrend, "addTrend");
340
+ function addAnnotation(number, coordinates, text) {
341
+ builder.addAnnotation({
342
+ number,
343
+ coordinates,
344
+ text
345
+ });
346
+ }
347
+ __name(addAnnotation, "addAnnotation");
348
+ function addNote(text, x, y) {
349
+ builder.addNote({
350
+ text,
351
+ x,
352
+ y
353
+ });
354
+ }
355
+ __name(addNote, "addNote");
356
+ function addAccelerator(name, x, y) {
357
+ builder.addAccelerator({
358
+ name,
359
+ x,
360
+ y
361
+ });
362
+ }
363
+ __name(addAccelerator, "addAccelerator");
364
+ function addDeaccelerator(name, x, y) {
365
+ builder.addDeaccelerator({
366
+ name,
367
+ x,
368
+ y
369
+ });
370
+ }
371
+ __name(addDeaccelerator, "addDeaccelerator");
372
+ function setAnnotationsBox(x, y) {
373
+ builder.setAnnotationsBox(x, y);
374
+ }
375
+ __name(setAnnotationsBox, "setAnnotationsBox");
376
+ function setSize(width, height) {
377
+ builder.setSize(width, height);
378
+ }
379
+ __name(setSize, "setSize");
380
+ function startPipeline(nodeId) {
381
+ builder.startPipeline(nodeId);
382
+ }
383
+ __name(startPipeline, "startPipeline");
384
+ function addPipelineComponent(pipelineNodeId, componentId) {
385
+ builder.addPipelineComponent(pipelineNodeId, componentId);
386
+ }
387
+ __name(addPipelineComponent, "addPipelineComponent");
388
+ function updateAxes(partial) {
389
+ builder.setAxes(partial);
390
+ }
391
+ __name(updateAxes, "updateAxes");
392
+ function getNode(id) {
393
+ return builder.getNode(id);
394
+ }
395
+ __name(getNode, "getNode");
396
+ function resolveNodeId(name) {
397
+ return builder.resolveNodeId(name);
398
+ }
399
+ __name(resolveNodeId, "resolveNodeId");
400
+ function getWardleyData() {
401
+ return builder.build();
402
+ }
403
+ __name(getWardleyData, "getWardleyData");
404
+ function clear2() {
405
+ builder.clear();
406
+ clear();
407
+ }
408
+ __name(clear2, "clear");
409
+ var wardleyDb_default = {
410
+ getConfig: getConfig3,
411
+ addNode,
412
+ addLink,
413
+ addTrend,
414
+ addAnnotation,
415
+ addNote,
416
+ addAccelerator,
417
+ addDeaccelerator,
418
+ setAnnotationsBox,
419
+ setSize,
420
+ startPipeline,
421
+ addPipelineComponent,
422
+ updateAxes,
423
+ getNode,
424
+ resolveNodeId,
425
+ getWardleyData,
426
+ clear: clear2,
427
+ setAccTitle,
428
+ getAccTitle,
429
+ setDiagramTitle,
430
+ getDiagramTitle,
431
+ getAccDescription,
432
+ setAccDescription
433
+ };
434
+ var DEFAULT_STAGES = ["Genesis", "Custom Built", "Product", "Commodity"];
435
+ var getTheme = /* @__PURE__ */ __name(() => {
436
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
437
+ const { themeVariables } = getConfig2();
438
+ return {
439
+ backgroundColor: ((_a2 = themeVariables.wardley) == null ? void 0 : _a2.backgroundColor) ?? themeVariables.background ?? "#fff",
440
+ axisColor: ((_b = themeVariables.wardley) == null ? void 0 : _b.axisColor) ?? "#000",
441
+ axisTextColor: ((_c = themeVariables.wardley) == null ? void 0 : _c.axisTextColor) ?? themeVariables.primaryTextColor ?? "#222",
442
+ gridColor: ((_d = themeVariables.wardley) == null ? void 0 : _d.gridColor) ?? "rgba(100, 100, 100, 0.2)",
443
+ componentFill: ((_e = themeVariables.wardley) == null ? void 0 : _e.componentFill) ?? "#fff",
444
+ componentStroke: ((_f = themeVariables.wardley) == null ? void 0 : _f.componentStroke) ?? "#000",
445
+ componentLabelColor: ((_g = themeVariables.wardley) == null ? void 0 : _g.componentLabelColor) ?? themeVariables.primaryTextColor ?? "#222",
446
+ linkStroke: ((_h = themeVariables.wardley) == null ? void 0 : _h.linkStroke) ?? "#000",
447
+ evolutionStroke: ((_i = themeVariables.wardley) == null ? void 0 : _i.evolutionStroke) ?? "#dc3545",
448
+ annotationStroke: ((_j = themeVariables.wardley) == null ? void 0 : _j.annotationStroke) ?? "#000",
449
+ annotationTextColor: ((_k = themeVariables.wardley) == null ? void 0 : _k.annotationTextColor) ?? themeVariables.primaryTextColor ?? "#222",
450
+ annotationFill: ((_l = themeVariables.wardley) == null ? void 0 : _l.annotationFill) ?? themeVariables.background ?? "#fff"
451
+ };
452
+ }, "getTheme");
453
+ var getConfigValues = /* @__PURE__ */ __name(() => {
454
+ const wardleyConfig = getConfig2()["wardley-beta"];
455
+ return {
456
+ width: (wardleyConfig == null ? void 0 : wardleyConfig.width) ?? 900,
457
+ height: (wardleyConfig == null ? void 0 : wardleyConfig.height) ?? 600,
458
+ padding: (wardleyConfig == null ? void 0 : wardleyConfig.padding) ?? 48,
459
+ nodeRadius: (wardleyConfig == null ? void 0 : wardleyConfig.nodeRadius) ?? 6,
460
+ nodeLabelOffset: (wardleyConfig == null ? void 0 : wardleyConfig.nodeLabelOffset) ?? 8,
461
+ axisFontSize: (wardleyConfig == null ? void 0 : wardleyConfig.axisFontSize) ?? 12,
462
+ labelFontSize: (wardleyConfig == null ? void 0 : wardleyConfig.labelFontSize) ?? 10,
463
+ showGrid: (wardleyConfig == null ? void 0 : wardleyConfig.showGrid) ?? false,
464
+ useMaxWidth: (wardleyConfig == null ? void 0 : wardleyConfig.useMaxWidth) ?? true
465
+ };
466
+ }, "getConfigValues");
467
+ var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
468
+ var _a2, _b;
469
+ log.debug("Rendering Wardley map\n" + text);
470
+ const configValues = getConfigValues();
471
+ const theme = getTheme();
472
+ const squareSize = configValues.nodeRadius * 1.6;
473
+ const db = diagObj.db;
474
+ const data = db.getWardleyData();
475
+ const title = db.getDiagramTitle();
476
+ const width = ((_a2 = data.size) == null ? void 0 : _a2.width) ?? configValues.width;
477
+ const height = ((_b = data.size) == null ? void 0 : _b.height) ?? configValues.height;
478
+ const svg = selectSvgElement(id);
479
+ svg.selectAll("*").remove();
480
+ configureSvgSize(svg, height, width, configValues.useMaxWidth);
481
+ svg.attr("viewBox", `0 0 ${width} ${height}`);
482
+ const root = svg.append("g").attr("class", "wardley-map");
483
+ const defs = svg.append("defs");
484
+ defs.append("marker").attr("id", `arrow-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto-start-reverse").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.evolutionStroke).attr("stroke", "none");
485
+ defs.append("marker").attr("id", `link-arrow-end-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
486
+ defs.append("marker").attr("id", `link-arrow-start-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 1).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
487
+ root.append("rect").attr("class", "wardley-background").attr("width", width).attr("height", height).attr("fill", theme.backgroundColor);
488
+ const chartWidth = width - configValues.padding * 2;
489
+ const chartHeight = height - configValues.padding * 2;
490
+ if (title) {
491
+ root.append("text").attr("class", "wardley-title").attr("x", width / 2).attr("y", configValues.padding / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize * 1.05).attr("font-weight", "bold").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
492
+ }
493
+ const projectX = /* @__PURE__ */ __name((value) => configValues.padding + value / 100 * chartWidth, "projectX");
494
+ const projectY = /* @__PURE__ */ __name((value) => height - configValues.padding - value / 100 * chartHeight, "projectY");
495
+ const axisGroup = root.append("g").attr("class", "wardley-axes");
496
+ axisGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
497
+ axisGroup.append("line").attr("x1", configValues.padding).attr("x2", configValues.padding).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
498
+ const xLabel = data.axes.xLabel ?? "Evolution";
499
+ const yLabel = data.axes.yLabel ?? "Visibility";
500
+ axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-x").attr("x", configValues.padding + chartWidth / 2).attr("y", height - configValues.padding / 4).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").text(xLabel);
501
+ axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-y").attr("x", configValues.padding / 3).attr("y", configValues.padding + chartHeight / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").attr(
502
+ "transform",
503
+ `rotate(-90 ${configValues.padding / 3} ${configValues.padding + chartHeight / 2})`
504
+ ).text(yLabel);
505
+ const stages = data.axes.stages && data.axes.stages.length > 0 ? data.axes.stages : DEFAULT_STAGES;
506
+ if (stages.length > 0) {
507
+ const stageGroup = root.append("g").attr("class", "wardley-stages");
508
+ const boundaries = data.axes.stageBoundaries;
509
+ const stagePositions = [];
510
+ if (boundaries && boundaries.length === stages.length) {
511
+ let prevBoundary = 0;
512
+ boundaries.forEach((boundary) => {
513
+ stagePositions.push({ start: prevBoundary, end: boundary });
514
+ prevBoundary = boundary;
515
+ });
516
+ } else {
517
+ const stageWidth = 1 / stages.length;
518
+ stages.forEach((_, index) => {
519
+ stagePositions.push({
520
+ start: index * stageWidth,
521
+ end: (index + 1) * stageWidth
522
+ });
523
+ });
524
+ }
525
+ stages.forEach((stage, index) => {
526
+ const pos = stagePositions[index];
527
+ const startX = configValues.padding + pos.start * chartWidth;
528
+ const endX = configValues.padding + pos.end * chartWidth;
529
+ const centerX = (startX + endX) / 2;
530
+ if (index > 0) {
531
+ stageGroup.append("line").attr("x1", startX).attr("x2", startX).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", "#000").attr("stroke-width", 1).attr("stroke-dasharray", "5 5").attr("opacity", 0.8);
532
+ }
533
+ stageGroup.append("text").attr("class", "wardley-stage-label").attr("x", centerX).attr("y", height - configValues.padding / 1.5).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize - 2).attr("text-anchor", "middle").text(stage);
534
+ });
535
+ }
536
+ if (configValues.showGrid) {
537
+ const gridGroup = root.append("g").attr("class", "wardley-grid");
538
+ for (let i = 1; i < 4; i++) {
539
+ const ratio = i / 4;
540
+ const x = configValues.padding + chartWidth * ratio;
541
+ gridGroup.append("line").attr("x1", x).attr("x2", x).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
542
+ gridGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding - chartHeight * ratio).attr("y2", height - configValues.padding - chartHeight * ratio).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
543
+ }
544
+ }
545
+ const positions = /* @__PURE__ */ new Map();
546
+ data.nodes.forEach((node) => {
547
+ positions.set(node.id, {
548
+ x: projectX(node.x),
549
+ y: projectY(node.y),
550
+ node
551
+ });
552
+ });
553
+ if (data.pipelines.length > 0) {
554
+ const pipelineGroup = root.append("g").attr("class", "wardley-pipelines");
555
+ const pipelineLinksGroup = root.append("g").attr("class", "wardley-pipeline-links");
556
+ data.pipelines.forEach((pipeline) => {
557
+ if (pipeline.componentIds.length === 0) {
558
+ return;
559
+ }
560
+ const sortedComponents = pipeline.componentIds.map((id2) => ({ id: id2, pos: positions.get(id2), node: data.nodes.find((n) => n.id === id2) })).filter((c) => c.pos && c.node).sort((a, b) => a.node.x - b.node.x);
561
+ for (let i = 0; i < sortedComponents.length - 1; i++) {
562
+ const current = sortedComponents[i];
563
+ const next = sortedComponents[i + 1];
564
+ pipelineLinksGroup.append("line").attr("class", "wardley-pipeline-evolution-link").attr("x1", current.pos.x).attr("y1", current.pos.y).attr("x2", next.pos.x).attr("y2", next.pos.y).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4");
565
+ }
566
+ let minX = Infinity;
567
+ let maxX = -Infinity;
568
+ let y = 0;
569
+ pipeline.componentIds.forEach((componentId) => {
570
+ const pos = positions.get(componentId);
571
+ if (pos) {
572
+ minX = Math.min(minX, pos.x);
573
+ maxX = Math.max(maxX, pos.x);
574
+ y = pos.y;
575
+ }
576
+ });
577
+ if (minX !== Infinity && maxX !== -Infinity) {
578
+ const padding = 15;
579
+ const height2 = configValues.nodeRadius * 4;
580
+ const boxTop = y - height2 / 2;
581
+ const parentPos = positions.get(pipeline.nodeId);
582
+ if (parentPos) {
583
+ const centerX = (minX + maxX) / 2;
584
+ parentPos.x = centerX;
585
+ parentPos.y = boxTop - squareSize / 6;
586
+ }
587
+ pipelineGroup.append("rect").attr("class", "wardley-pipeline-box").attr("x", minX - padding).attr("y", boxTop).attr("width", maxX - minX + padding * 2).attr("height", height2).attr("fill", "none").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
588
+ }
589
+ });
590
+ }
591
+ const linksGroup = root.append("g").attr("class", "wardley-links");
592
+ const pipelineMap = /* @__PURE__ */ new Map();
593
+ data.pipelines.forEach((pipeline) => {
594
+ pipelineMap.set(pipeline.nodeId, new Set(pipeline.componentIds));
595
+ });
596
+ const validLinks = data.links.filter((link) => {
597
+ if (!positions.has(link.source) || !positions.has(link.target)) {
598
+ return false;
599
+ }
600
+ const pipelineComponents = pipelineMap.get(link.target);
601
+ if (pipelineComponents == null ? void 0 : pipelineComponents.has(link.source)) {
602
+ return false;
603
+ }
604
+ return true;
605
+ });
606
+ linksGroup.selectAll("line").data(validLinks).enter().append("line").attr("class", (link) => `wardley-link${link.dashed ? " wardley-link--dashed" : ""}`).attr("x1", (link) => {
607
+ const sourcePos = positions.get(link.source);
608
+ const targetPos = positions.get(link.target);
609
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
610
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
611
+ const dx = targetPos.x - sourcePos.x;
612
+ const dy = targetPos.y - sourcePos.y;
613
+ const distance = Math.sqrt(dx * dx + dy * dy);
614
+ return sourcePos.x + dx / distance * radius;
615
+ }).attr("y1", (link) => {
616
+ const sourcePos = positions.get(link.source);
617
+ const targetPos = positions.get(link.target);
618
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
619
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
620
+ const dx = targetPos.x - sourcePos.x;
621
+ const dy = targetPos.y - sourcePos.y;
622
+ const distance = Math.sqrt(dx * dx + dy * dy);
623
+ return sourcePos.y + dy / distance * radius;
624
+ }).attr("x2", (link) => {
625
+ const sourcePos = positions.get(link.source);
626
+ const targetPos = positions.get(link.target);
627
+ const targetNode = data.nodes.find((n) => n.id === link.target);
628
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
629
+ const dx = sourcePos.x - targetPos.x;
630
+ const dy = sourcePos.y - targetPos.y;
631
+ const distance = Math.sqrt(dx * dx + dy * dy);
632
+ return targetPos.x + dx / distance * radius;
633
+ }).attr("y2", (link) => {
634
+ const sourcePos = positions.get(link.source);
635
+ const targetPos = positions.get(link.target);
636
+ const targetNode = data.nodes.find((n) => n.id === link.target);
637
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
638
+ const dx = sourcePos.x - targetPos.x;
639
+ const dy = sourcePos.y - targetPos.y;
640
+ const distance = Math.sqrt(dx * dx + dy * dy);
641
+ return targetPos.y + dy / distance * radius;
642
+ }).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", (link) => link.dashed ? "6 6" : null).attr("marker-end", (link) => {
643
+ if (link.flow === "forward" || link.flow === "bidirectional") {
644
+ return `url(#link-arrow-end-${id})`;
645
+ }
646
+ return null;
647
+ }).attr("marker-start", (link) => {
648
+ if (link.flow === "backward" || link.flow === "bidirectional") {
649
+ return `url(#link-arrow-start-${id})`;
650
+ }
651
+ return null;
652
+ });
653
+ linksGroup.selectAll("text").data(validLinks.filter((link) => link.label)).enter().append("text").attr("class", "wardley-link-label").attr("x", (link) => {
654
+ const sourcePos = positions.get(link.source);
655
+ const targetPos = positions.get(link.target);
656
+ const midX = (sourcePos.x + targetPos.x) / 2;
657
+ const dy = targetPos.y - sourcePos.y;
658
+ const dx = targetPos.x - sourcePos.x;
659
+ const distance = Math.sqrt(dx * dx + dy * dy);
660
+ const offset = 8;
661
+ const perpX = dy / distance;
662
+ return midX + perpX * offset;
663
+ }).attr("y", (link) => {
664
+ const sourcePos = positions.get(link.source);
665
+ const targetPos = positions.get(link.target);
666
+ const midY = (sourcePos.y + targetPos.y) / 2;
667
+ const dx = targetPos.x - sourcePos.x;
668
+ const dy = targetPos.y - sourcePos.y;
669
+ const distance = Math.sqrt(dx * dx + dy * dy);
670
+ const offset = 8;
671
+ const perpY = -dx / distance;
672
+ return midY + perpY * offset;
673
+ }).attr("fill", theme.axisTextColor).attr("font-size", configValues.labelFontSize).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("transform", (link) => {
674
+ const sourcePos = positions.get(link.source);
675
+ const targetPos = positions.get(link.target);
676
+ const midX = (sourcePos.x + targetPos.x) / 2;
677
+ const midY = (sourcePos.y + targetPos.y) / 2;
678
+ const dx = targetPos.x - sourcePos.x;
679
+ const dy = targetPos.y - sourcePos.y;
680
+ const distance = Math.sqrt(dx * dx + dy * dy);
681
+ const offset = 8;
682
+ const perpX = dy / distance;
683
+ const perpY = -dx / distance;
684
+ const labelX = midX + perpX * offset;
685
+ const labelY = midY + perpY * offset;
686
+ let angle = Math.atan2(dy, dx) * 180 / Math.PI;
687
+ if (angle > 90 || angle < -90) {
688
+ angle += 180;
689
+ }
690
+ return `rotate(${angle} ${labelX} ${labelY})`;
691
+ }).text((link) => link.label);
692
+ const trendGroup = root.append("g").attr("class", "wardley-trends");
693
+ const trendsWithPositions = data.trends.map((trend) => {
694
+ const origin = positions.get(trend.nodeId);
695
+ if (!origin) {
696
+ return null;
697
+ }
698
+ const targetX = projectX(trend.targetX);
699
+ const targetY = projectY(trend.targetY);
700
+ const dx = targetX - origin.x;
701
+ const dy = targetY - origin.y;
702
+ const distance = Math.sqrt(dx * dx + dy * dy);
703
+ const shortenBy = configValues.nodeRadius + 2;
704
+ const adjustedX2 = distance > shortenBy ? targetX - dx / distance * shortenBy : targetX;
705
+ const adjustedY2 = distance > shortenBy ? targetY - dy / distance * shortenBy : targetY;
706
+ return {
707
+ origin,
708
+ targetX,
709
+ targetY,
710
+ adjustedX2,
711
+ adjustedY2
712
+ };
713
+ }).filter((trend) => trend !== null);
714
+ trendGroup.selectAll("line").data(trendsWithPositions).enter().append("line").attr("class", "wardley-trend").attr("x1", (trend) => trend.origin.x).attr("y1", (trend) => trend.origin.y).attr("x2", (trend) => trend.adjustedX2).attr("y2", (trend) => trend.adjustedY2).attr("stroke", theme.evolutionStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4").attr("marker-end", `url(#arrow-${id})`);
715
+ const nodesGroup = root.append("g").attr("class", "wardley-nodes");
716
+ const nodeEnter = nodesGroup.selectAll("g").data(data.nodes).enter().append("g").attr(
717
+ "class",
718
+ (node) => ["wardley-node", node.className ? `wardley-node--${node.className}` : ""].filter(Boolean).join(" ")
719
+ );
720
+ nodeEnter.filter((node) => node.sourceStrategy === "outsource").append("circle").attr("class", "wardley-outsource-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#666").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
721
+ nodeEnter.filter((node) => node.sourceStrategy === "buy").append("circle").attr("class", "wardley-buy-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#ccc").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
722
+ nodeEnter.filter((node) => node.sourceStrategy === "build").append("circle").attr("class", "wardley-build-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#eee").attr("stroke", "#000").attr("stroke-width", 1);
723
+ const marketNodes = nodeEnter.filter((node) => node.sourceStrategy === "market");
724
+ marketNodes.append("circle").attr("class", "wardley-market-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
725
+ nodeEnter.filter(
726
+ (node) => !node.isPipelineParent && node.sourceStrategy !== "market" && node.className !== "anchor"
727
+ ).append("circle").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
728
+ const smallCircleRadius = configValues.nodeRadius * 0.7;
729
+ const triangleRadius = configValues.nodeRadius * 1.2;
730
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x).attr("y1", (node) => positions.get(node.id).y - triangleRadius).attr("x2", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
731
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
732
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x).attr("y2", (node) => positions.get(node.id).y - triangleRadius).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
733
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y - triangleRadius).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
734
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
735
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
736
+ nodeEnter.filter((node) => node.isPipelineParent === true).append("rect").attr("x", (node) => positions.get(node.id).x - squareSize / 2).attr("y", (node) => positions.get(node.id).y - squareSize / 2).attr("width", squareSize).attr("height", squareSize).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
737
+ nodeEnter.filter((node) => node.inertia === true).append("line").attr("class", "wardley-inertia").attr("x1", (node) => {
738
+ const pos = positions.get(node.id);
739
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
740
+ if (node.sourceStrategy) {
741
+ offset += configValues.nodeRadius + 10;
742
+ }
743
+ return pos.x + offset;
744
+ }).attr("y1", (node) => {
745
+ const pos = positions.get(node.id);
746
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
747
+ return pos.y - lineHeight / 2;
748
+ }).attr("x2", (node) => {
749
+ const pos = positions.get(node.id);
750
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
751
+ if (node.sourceStrategy) {
752
+ offset += configValues.nodeRadius + 10;
753
+ }
754
+ return pos.x + offset;
755
+ }).attr("y2", (node) => {
756
+ const pos = positions.get(node.id);
757
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
758
+ return pos.y + lineHeight / 2;
759
+ }).attr("stroke", theme.componentStroke).attr("stroke-width", 6);
760
+ nodeEnter.append("text").attr("x", (node) => {
761
+ const pos = positions.get(node.id);
762
+ if (node.className === "anchor") {
763
+ return node.labelOffsetX !== void 0 ? pos.x + node.labelOffsetX : pos.x;
764
+ }
765
+ let defaultOffset = configValues.nodeLabelOffset;
766
+ if (node.sourceStrategy && node.labelOffsetX === void 0) {
767
+ defaultOffset += 10;
768
+ }
769
+ const customOffset = node.labelOffsetX ?? defaultOffset;
770
+ return pos.x + customOffset;
771
+ }).attr("y", (node) => {
772
+ const pos = positions.get(node.id);
773
+ if (node.className === "anchor") {
774
+ return node.labelOffsetY !== void 0 ? pos.y + node.labelOffsetY : pos.y - 3;
775
+ }
776
+ let defaultOffset = -configValues.nodeLabelOffset;
777
+ if (node.sourceStrategy && node.labelOffsetY === void 0) {
778
+ defaultOffset -= 10;
779
+ }
780
+ const customOffset = node.labelOffsetY ?? defaultOffset;
781
+ return pos.y + customOffset;
782
+ }).attr("class", "wardley-node-label").attr("fill", (node) => {
783
+ if (node.className === "evolved") {
784
+ return theme.evolutionStroke;
785
+ }
786
+ if (node.className === "anchor") {
787
+ return "#000";
788
+ }
789
+ return theme.componentLabelColor;
790
+ }).attr("font-size", configValues.labelFontSize).attr("font-weight", (node) => node.className === "anchor" ? "bold" : "normal").attr("text-anchor", (node) => node.className === "anchor" ? "middle" : "start").attr("dominant-baseline", (node) => node.className === "anchor" ? "middle" : "auto").text((node) => node.label);
791
+ if (data.annotations.length > 0) {
792
+ const annotationsGroup = root.append("g").attr("class", "wardley-annotations");
793
+ data.annotations.forEach((annotation) => {
794
+ const projectedCoords = annotation.coordinates.map((coord) => ({
795
+ x: projectX(coord.x),
796
+ y: projectY(coord.y)
797
+ }));
798
+ if (projectedCoords.length > 1) {
799
+ for (let i = 0; i < projectedCoords.length - 1; i++) {
800
+ annotationsGroup.append("line").attr("class", "wardley-annotation-line").attr("x1", projectedCoords[i].x).attr("y1", projectedCoords[i].y).attr("x2", projectedCoords[i + 1].x).attr("y2", projectedCoords[i + 1].y).attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("stroke-dasharray", "4 4");
801
+ }
802
+ }
803
+ projectedCoords.forEach((coord) => {
804
+ const annotationNode = annotationsGroup.append("g").attr("class", "wardley-annotation");
805
+ annotationNode.append("circle").attr("cx", coord.x).attr("cy", coord.y).attr("r", 10).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5);
806
+ annotationNode.append("text").attr("x", coord.x).attr("y", coord.y).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(annotation.number);
807
+ });
808
+ });
809
+ if (data.annotationsBox) {
810
+ let boxX = projectX(data.annotationsBox.x);
811
+ let boxY = projectY(data.annotationsBox.y);
812
+ const padding = 10;
813
+ const lineHeight = 16;
814
+ const fontSize = 11;
815
+ const textBoxGroup = annotationsGroup.append("g").attr("class", "wardley-annotations-box");
816
+ const sortedAnnotations = [...data.annotations].filter((a) => a.text).sort((a, b) => a.number - b.number);
817
+ const textElements = [];
818
+ sortedAnnotations.forEach((annotation, idx) => {
819
+ const text2 = textBoxGroup.append("text").attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight).attr("font-size", fontSize).attr("fill", theme.axisTextColor).attr("text-anchor", "start").attr("dominant-baseline", "middle").text(`${annotation.number}. ${annotation.text}`);
820
+ textElements.push(text2);
821
+ });
822
+ if (textElements.length > 0) {
823
+ let maxWidth = 0;
824
+ let maxHeight = 0;
825
+ textElements.forEach((text2) => {
826
+ const textNode = text2.node();
827
+ const textWidth = textNode.getComputedTextLength();
828
+ maxWidth = Math.max(maxWidth, textWidth);
829
+ const bbox = textNode.getBBox();
830
+ maxHeight = Math.max(maxHeight, bbox.height);
831
+ });
832
+ const boxWidth = maxWidth + padding * 2 + 105;
833
+ const boxHeight = sortedAnnotations.length * lineHeight + padding * 2 + maxHeight / 2;
834
+ const minX = configValues.padding;
835
+ const maxX = width - configValues.padding - boxWidth;
836
+ const minY = configValues.padding;
837
+ const maxY = height - configValues.padding - boxHeight;
838
+ boxX = Math.max(minX, Math.min(boxX, maxX));
839
+ boxY = Math.max(minY, Math.min(boxY, maxY));
840
+ textElements.forEach((text2, idx) => {
841
+ text2.attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight);
842
+ });
843
+ textBoxGroup.insert("rect", "text").attr("x", boxX).attr("y", boxY).attr("width", boxWidth).attr("height", boxHeight).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
844
+ }
845
+ }
846
+ }
847
+ if (data.notes.length > 0) {
848
+ const notesGroup = root.append("g").attr("class", "wardley-notes");
849
+ data.notes.forEach((note) => {
850
+ const noteX = projectX(note.x);
851
+ const noteY = projectY(note.y);
852
+ notesGroup.append("text").attr("x", noteX).attr("y", noteY).attr("text-anchor", "start").attr("font-size", 11).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(note.text);
853
+ });
854
+ }
855
+ if (data.accelerators.length > 0) {
856
+ const acceleratorsGroup = root.append("g").attr("class", "wardley-accelerators");
857
+ data.accelerators.forEach((accelerator) => {
858
+ const accX = projectX(accelerator.x);
859
+ const accY = projectY(accelerator.y);
860
+ const arrowWidth = 60;
861
+ const arrowHeight = 30;
862
+ const arrowHeadWidth = 20;
863
+ const arrowPath = `
864
+ M ${accX} ${accY - arrowHeight / 2}
865
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2}
866
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2 - 8}
867
+ L ${accX + arrowWidth} ${accY}
868
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2 + 8}
869
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2}
870
+ L ${accX} ${accY + arrowHeight / 2}
871
+ Z
872
+ `;
873
+ acceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
874
+ acceleratorsGroup.append("text").attr("x", accX + arrowWidth / 2).attr("y", accY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(accelerator.name);
875
+ });
876
+ }
877
+ if (data.deaccelerators.length > 0) {
878
+ const deacceleratorsGroup = root.append("g").attr("class", "wardley-deaccelerators");
879
+ data.deaccelerators.forEach((deaccelerator) => {
880
+ const decX = projectX(deaccelerator.x);
881
+ const decY = projectY(deaccelerator.y);
882
+ const arrowWidth = 60;
883
+ const arrowHeight = 30;
884
+ const arrowHeadWidth = 20;
885
+ const arrowPath = `
886
+ M ${decX + arrowWidth} ${decY - arrowHeight / 2}
887
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2}
888
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2 - 8}
889
+ L ${decX} ${decY}
890
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2 + 8}
891
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2}
892
+ L ${decX + arrowWidth} ${decY + arrowHeight / 2}
893
+ Z
894
+ `;
895
+ deacceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
896
+ deacceleratorsGroup.append("text").attr("x", decX + arrowWidth / 2).attr("y", decY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(deaccelerator.name);
897
+ });
898
+ }
899
+ }, "draw");
900
+ var wardleyRenderer_default = {
901
+ draw
902
+ };
903
+ var styles = /* @__PURE__ */ __name(({
904
+ wardley
905
+ } = {}) => {
906
+ const defaultThemeVariables = getThemeVariables3();
907
+ const currentConfig = getConfig();
908
+ const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
909
+ const w = cleanAndMerge(themeVariables.wardley, wardley);
910
+ return `
911
+ .wardley-background {
912
+ fill: ${w.backgroundColor};
913
+ }
914
+ .wardley-axes line, .wardley-axes path {
915
+ stroke: ${w.axisColor};
916
+ }
917
+ .wardley-axis-label {
918
+ fill: ${w.axisTextColor};
919
+ }
920
+ .wardley-stage-label {
921
+ fill: ${w.axisTextColor};
922
+ }
923
+ .wardley-grid line {
924
+ stroke: ${w.gridColor};
925
+ }
926
+ .wardley-node circle {
927
+ fill: ${w.componentFill};
928
+ stroke: ${w.componentStroke};
929
+ }
930
+ .wardley-node-label {
931
+ fill: ${w.componentLabelColor};
932
+ }
933
+ .wardley-link {
934
+ stroke: ${w.linkStroke};
935
+ }
936
+ .wardley-link--dashed {
937
+ stroke-dasharray: 4 4;
938
+ }
939
+ .wardley-link-label {
940
+ fill: ${w.axisTextColor};
941
+ }
942
+ .wardley-trend line {
943
+ stroke: ${w.evolutionStroke};
944
+ }
945
+ .wardley-annotation-line {
946
+ stroke: ${w.annotationStroke};
947
+ }
948
+ .wardley-annotation circle {
949
+ fill: ${w.annotationFill};
950
+ stroke: ${w.annotationStroke};
951
+ }
952
+ .wardley-annotation text {
953
+ fill: ${w.annotationTextColor};
954
+ }
955
+ .wardley-annotations-box rect {
956
+ fill: ${w.annotationFill};
957
+ stroke: ${w.annotationStroke};
958
+ }
959
+ .wardley-annotations-box text {
960
+ fill: ${w.annotationTextColor};
961
+ }
962
+ .wardley-pipeline-box {
963
+ stroke: ${w.componentStroke};
964
+ }
965
+ .wardley-notes text {
966
+ fill: ${w.axisTextColor};
967
+ }
968
+ `;
969
+ }, "styles");
970
+ var diagram = {
971
+ parser,
972
+ db: wardleyDb_default,
973
+ renderer: wardleyRenderer_default,
974
+ styles
975
+ };
976
+ export {
977
+ diagram
978
+ };