@zettelgeist/cli 0.1.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 (189) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +64 -0
  3. package/dist/bin.js +2211 -0
  4. package/dist/bin.js.map +7 -0
  5. package/dist/templates/export.html +27 -0
  6. package/dist/templates/skill/SKILL.md +220 -0
  7. package/dist/viewer-bundle/architecture-YZFGNWBL-W2K3EQOM.js +14 -0
  8. package/dist/viewer-bundle/architecture-YZFGNWBL-W2K3EQOM.js.map +7 -0
  9. package/dist/viewer-bundle/architectureDiagram-Q4EWVU46-LCGRUEWT.js +8884 -0
  10. package/dist/viewer-bundle/architectureDiagram-Q4EWVU46-LCGRUEWT.js.map +7 -0
  11. package/dist/viewer-bundle/base.css +248 -0
  12. package/dist/viewer-bundle/blockDiagram-DXYQGD6D-KAM7BOAP.js +3777 -0
  13. package/dist/viewer-bundle/blockDiagram-DXYQGD6D-KAM7BOAP.js.map +7 -0
  14. package/dist/viewer-bundle/board.css +370 -0
  15. package/dist/viewer-bundle/c4Diagram-AHTNJAMY-C3FIQYXA.js +2596 -0
  16. package/dist/viewer-bundle/c4Diagram-AHTNJAMY-C3FIQYXA.js.map +7 -0
  17. package/dist/viewer-bundle/chunk-2QXGXAO5.js +68 -0
  18. package/dist/viewer-bundle/chunk-2QXGXAO5.js.map +7 -0
  19. package/dist/viewer-bundle/chunk-5PZT7VUU.js +67 -0
  20. package/dist/viewer-bundle/chunk-5PZT7VUU.js.map +7 -0
  21. package/dist/viewer-bundle/chunk-5YJCJF2C.js +112 -0
  22. package/dist/viewer-bundle/chunk-5YJCJF2C.js.map +7 -0
  23. package/dist/viewer-bundle/chunk-6LYV7PBV.js +1011 -0
  24. package/dist/viewer-bundle/chunk-6LYV7PBV.js.map +7 -0
  25. package/dist/viewer-bundle/chunk-6VW7D5WX.js +48 -0
  26. package/dist/viewer-bundle/chunk-6VW7D5WX.js.map +7 -0
  27. package/dist/viewer-bundle/chunk-76C5OSD4.js +2048 -0
  28. package/dist/viewer-bundle/chunk-76C5OSD4.js.map +7 -0
  29. package/dist/viewer-bundle/chunk-7NZMPQDX.js +6957 -0
  30. package/dist/viewer-bundle/chunk-7NZMPQDX.js.map +7 -0
  31. package/dist/viewer-bundle/chunk-A634GTZN.js +122 -0
  32. package/dist/viewer-bundle/chunk-A634GTZN.js.map +7 -0
  33. package/dist/viewer-bundle/chunk-AJQJUKMU.js +133 -0
  34. package/dist/viewer-bundle/chunk-AJQJUKMU.js.map +7 -0
  35. package/dist/viewer-bundle/chunk-BM2KPNFW.js +5556 -0
  36. package/dist/viewer-bundle/chunk-BM2KPNFW.js.map +7 -0
  37. package/dist/viewer-bundle/chunk-CIDUOCCG.js +25 -0
  38. package/dist/viewer-bundle/chunk-CIDUOCCG.js.map +7 -0
  39. package/dist/viewer-bundle/chunk-CZHJHAOR.js +6397 -0
  40. package/dist/viewer-bundle/chunk-CZHJHAOR.js.map +7 -0
  41. package/dist/viewer-bundle/chunk-D5RLIWY4.js +125 -0
  42. package/dist/viewer-bundle/chunk-D5RLIWY4.js.map +7 -0
  43. package/dist/viewer-bundle/chunk-DI52DQAC.js +44 -0
  44. package/dist/viewer-bundle/chunk-DI52DQAC.js.map +7 -0
  45. package/dist/viewer-bundle/chunk-EXJQLTIV.js +51 -0
  46. package/dist/viewer-bundle/chunk-EXJQLTIV.js.map +7 -0
  47. package/dist/viewer-bundle/chunk-G3PPZWPW.js +96 -0
  48. package/dist/viewer-bundle/chunk-G3PPZWPW.js.map +7 -0
  49. package/dist/viewer-bundle/chunk-GTW4IDD4.js +30297 -0
  50. package/dist/viewer-bundle/chunk-GTW4IDD4.js.map +7 -0
  51. package/dist/viewer-bundle/chunk-GVE7OA3Z.js +59 -0
  52. package/dist/viewer-bundle/chunk-GVE7OA3Z.js.map +7 -0
  53. package/dist/viewer-bundle/chunk-JBUVKVPY.js +2042 -0
  54. package/dist/viewer-bundle/chunk-JBUVKVPY.js.map +7 -0
  55. package/dist/viewer-bundle/chunk-JQLVOAQB.js +20 -0
  56. package/dist/viewer-bundle/chunk-JQLVOAQB.js.map +7 -0
  57. package/dist/viewer-bundle/chunk-LQMQSYLO.js +101 -0
  58. package/dist/viewer-bundle/chunk-LQMQSYLO.js.map +7 -0
  59. package/dist/viewer-bundle/chunk-MBFAQ3IK.js +34 -0
  60. package/dist/viewer-bundle/chunk-MBFAQ3IK.js.map +7 -0
  61. package/dist/viewer-bundle/chunk-N7G7IIKG.js +25 -0
  62. package/dist/viewer-bundle/chunk-N7G7IIKG.js.map +7 -0
  63. package/dist/viewer-bundle/chunk-NW4YG3NS.js +171 -0
  64. package/dist/viewer-bundle/chunk-NW4YG3NS.js.map +7 -0
  65. package/dist/viewer-bundle/chunk-ODEP5TKB.js +61 -0
  66. package/dist/viewer-bundle/chunk-ODEP5TKB.js.map +7 -0
  67. package/dist/viewer-bundle/chunk-OGKINV23.js +1050 -0
  68. package/dist/viewer-bundle/chunk-OGKINV23.js.map +7 -0
  69. package/dist/viewer-bundle/chunk-OGMSNDVH.js +1994 -0
  70. package/dist/viewer-bundle/chunk-OGMSNDVH.js.map +7 -0
  71. package/dist/viewer-bundle/chunk-QJVSDNAW.js +25 -0
  72. package/dist/viewer-bundle/chunk-QJVSDNAW.js.map +7 -0
  73. package/dist/viewer-bundle/chunk-RBTT26R4.js +2721 -0
  74. package/dist/viewer-bundle/chunk-RBTT26R4.js.map +7 -0
  75. package/dist/viewer-bundle/chunk-RQIPIIE2.js +48 -0
  76. package/dist/viewer-bundle/chunk-RQIPIIE2.js.map +7 -0
  77. package/dist/viewer-bundle/chunk-SRTYTXTX.js +22 -0
  78. package/dist/viewer-bundle/chunk-SRTYTXTX.js.map +7 -0
  79. package/dist/viewer-bundle/chunk-TRL7YIZG.js +1663 -0
  80. package/dist/viewer-bundle/chunk-TRL7YIZG.js.map +7 -0
  81. package/dist/viewer-bundle/chunk-U5T7X4BV.js +172 -0
  82. package/dist/viewer-bundle/chunk-U5T7X4BV.js.map +7 -0
  83. package/dist/viewer-bundle/chunk-UCAW6C6C.js +48 -0
  84. package/dist/viewer-bundle/chunk-UCAW6C6C.js.map +7 -0
  85. package/dist/viewer-bundle/chunk-UEAG4BJQ.js +93 -0
  86. package/dist/viewer-bundle/chunk-UEAG4BJQ.js.map +7 -0
  87. package/dist/viewer-bundle/chunk-UVRE3R6A.js +1039 -0
  88. package/dist/viewer-bundle/chunk-UVRE3R6A.js.map +7 -0
  89. package/dist/viewer-bundle/chunk-VODO7SV4.js +25029 -0
  90. package/dist/viewer-bundle/chunk-VODO7SV4.js.map +7 -0
  91. package/dist/viewer-bundle/chunk-YEU62MVS.js +682 -0
  92. package/dist/viewer-bundle/chunk-YEU62MVS.js.map +7 -0
  93. package/dist/viewer-bundle/chunk-YFQT7PPW.js +987 -0
  94. package/dist/viewer-bundle/chunk-YFQT7PPW.js.map +7 -0
  95. package/dist/viewer-bundle/chunk-Z4G7FG27.js +48 -0
  96. package/dist/viewer-bundle/chunk-Z4G7FG27.js.map +7 -0
  97. package/dist/viewer-bundle/chunk-ZW4Y7DIF.js +2044 -0
  98. package/dist/viewer-bundle/chunk-ZW4Y7DIF.js.map +7 -0
  99. package/dist/viewer-bundle/classDiagram-6PBFFD2Q-7VKYXLUX.js +46 -0
  100. package/dist/viewer-bundle/classDiagram-6PBFFD2Q-7VKYXLUX.js.map +7 -0
  101. package/dist/viewer-bundle/classDiagram-v2-HSJHXN6E-ACCNN7EN.js +46 -0
  102. package/dist/viewer-bundle/classDiagram-v2-HSJHXN6E-ACCNN7EN.js.map +7 -0
  103. package/dist/viewer-bundle/cose-bilkent-S5V4N54A-MUJHAA34.js +5009 -0
  104. package/dist/viewer-bundle/cose-bilkent-S5V4N54A-MUJHAA34.js.map +7 -0
  105. package/dist/viewer-bundle/dagre-KV5264BT-YC5VV3WF.js +739 -0
  106. package/dist/viewer-bundle/dagre-KV5264BT-YC5VV3WF.js.map +7 -0
  107. package/dist/viewer-bundle/dark.css +13 -0
  108. package/dist/viewer-bundle/detail.css +539 -0
  109. package/dist/viewer-bundle/diagram-5BDNPKRD-RXFPVFYK.js +214 -0
  110. package/dist/viewer-bundle/diagram-5BDNPKRD-RXFPVFYK.js.map +7 -0
  111. package/dist/viewer-bundle/diagram-G4DWMVQ6-KN7CBNBQ.js +578 -0
  112. package/dist/viewer-bundle/diagram-G4DWMVQ6-KN7CBNBQ.js.map +7 -0
  113. package/dist/viewer-bundle/diagram-MMDJMWI5-ZN6TQ7ZC.js +345 -0
  114. package/dist/viewer-bundle/diagram-MMDJMWI5-ZN6TQ7ZC.js.map +7 -0
  115. package/dist/viewer-bundle/diagram-TYMM5635-MMTUJ4KA.js +255 -0
  116. package/dist/viewer-bundle/diagram-TYMM5635-MMTUJ4KA.js.map +7 -0
  117. package/dist/viewer-bundle/docs.css +88 -0
  118. package/dist/viewer-bundle/edit-modal-BEGC2AO6.js +176 -0
  119. package/dist/viewer-bundle/edit-modal-BEGC2AO6.js.map +7 -0
  120. package/dist/viewer-bundle/erDiagram-SMLLAGMA-TBHMLD2E.js +1349 -0
  121. package/dist/viewer-bundle/erDiagram-SMLLAGMA-TBHMLD2E.js.map +7 -0
  122. package/dist/viewer-bundle/flowDiagram-DWJPFMVM-BZHLK6QB.js +2501 -0
  123. package/dist/viewer-bundle/flowDiagram-DWJPFMVM-BZHLK6QB.js.map +7 -0
  124. package/dist/viewer-bundle/ganttDiagram-T4ZO3ILL-YBARPTQR.js +2654 -0
  125. package/dist/viewer-bundle/ganttDiagram-T4ZO3ILL-YBARPTQR.js.map +7 -0
  126. package/dist/viewer-bundle/gitGraph-7Q5UKJZL-HENKIQDX.js +14 -0
  127. package/dist/viewer-bundle/gitGraph-7Q5UKJZL-HENKIQDX.js.map +7 -0
  128. package/dist/viewer-bundle/gitGraphDiagram-UUTBAWPF-M4VV3YVA.js +1946 -0
  129. package/dist/viewer-bundle/gitGraphDiagram-UUTBAWPF-M4VV3YVA.js.map +7 -0
  130. package/dist/viewer-bundle/index.html +28 -0
  131. package/dist/viewer-bundle/info-OMHHGYJF-E773USRS.js +14 -0
  132. package/dist/viewer-bundle/info-OMHHGYJF-E773USRS.js.map +7 -0
  133. package/dist/viewer-bundle/infoDiagram-42DDH7IO-C7JGUXKK.js +59 -0
  134. package/dist/viewer-bundle/infoDiagram-42DDH7IO-C7JGUXKK.js.map +7 -0
  135. package/dist/viewer-bundle/ishikawaDiagram-UXIWVN3A-YBC4X4VB.js +1012 -0
  136. package/dist/viewer-bundle/ishikawaDiagram-UXIWVN3A-YBC4X4VB.js.map +7 -0
  137. package/dist/viewer-bundle/journeyDiagram-VCZTEJTY-6WKVEOOO.js +1303 -0
  138. package/dist/viewer-bundle/journeyDiagram-VCZTEJTY-6WKVEOOO.js.map +7 -0
  139. package/dist/viewer-bundle/kanban-definition-6JOO6SKY-URTTHHO4.js +1131 -0
  140. package/dist/viewer-bundle/kanban-definition-6JOO6SKY-URTTHHO4.js.map +7 -0
  141. package/dist/viewer-bundle/katex-QN5266ZE.js +14318 -0
  142. package/dist/viewer-bundle/katex-QN5266ZE.js.map +7 -0
  143. package/dist/viewer-bundle/light.css +15 -0
  144. package/dist/viewer-bundle/main.js +4816 -0
  145. package/dist/viewer-bundle/main.js.map +7 -0
  146. package/dist/viewer-bundle/mermaid.core-AEBXU2JK.js +1708 -0
  147. package/dist/viewer-bundle/mermaid.core-AEBXU2JK.js.map +7 -0
  148. package/dist/viewer-bundle/mindmap-definition-QFDTVHPH-KUMAMRSF.js +1277 -0
  149. package/dist/viewer-bundle/mindmap-definition-QFDTVHPH-KUMAMRSF.js.map +7 -0
  150. package/dist/viewer-bundle/packet-4T2RLAQJ-IRYWWA66.js +14 -0
  151. package/dist/viewer-bundle/packet-4T2RLAQJ-IRYWWA66.js.map +7 -0
  152. package/dist/viewer-bundle/pico.classless.min.css +4 -0
  153. package/dist/viewer-bundle/pie-ZZUOXDRM-JYO4VL5N.js +14 -0
  154. package/dist/viewer-bundle/pie-ZZUOXDRM-JYO4VL5N.js.map +7 -0
  155. package/dist/viewer-bundle/pieDiagram-DEJITSTG-QOEHQN3N.js +238 -0
  156. package/dist/viewer-bundle/pieDiagram-DEJITSTG-QOEHQN3N.js.map +7 -0
  157. package/dist/viewer-bundle/prompt-modal-C4LHI7BS.js +12 -0
  158. package/dist/viewer-bundle/prompt-modal-C4LHI7BS.js.map +7 -0
  159. package/dist/viewer-bundle/quadrantDiagram-34T5L4WZ-SJNPUU5N.js +1409 -0
  160. package/dist/viewer-bundle/quadrantDiagram-34T5L4WZ-SJNPUU5N.js.map +7 -0
  161. package/dist/viewer-bundle/radar-PYXPWWZC-45BRYQSB.js +14 -0
  162. package/dist/viewer-bundle/radar-PYXPWWZC-45BRYQSB.js.map +7 -0
  163. package/dist/viewer-bundle/reason-modal-MK34MQ73.js +68 -0
  164. package/dist/viewer-bundle/reason-modal-MK34MQ73.js.map +7 -0
  165. package/dist/viewer-bundle/requirementDiagram-MS252O5E-UOMT3FCC.js +1311 -0
  166. package/dist/viewer-bundle/requirementDiagram-MS252O5E-UOMT3FCC.js.map +7 -0
  167. package/dist/viewer-bundle/sankeyDiagram-XADWPNL6-LAVJ5C6A.js +1263 -0
  168. package/dist/viewer-bundle/sankeyDiagram-XADWPNL6-LAVJ5C6A.js.map +7 -0
  169. package/dist/viewer-bundle/sequenceDiagram-FGHM5R23-3IWTOUNQ.js +4655 -0
  170. package/dist/viewer-bundle/sequenceDiagram-FGHM5R23-3IWTOUNQ.js.map +7 -0
  171. package/dist/viewer-bundle/stateDiagram-FHFEXIEX-S2OVQQON.js +495 -0
  172. package/dist/viewer-bundle/stateDiagram-FHFEXIEX-S2OVQQON.js.map +7 -0
  173. package/dist/viewer-bundle/stateDiagram-v2-QKLJ7IA2-XNZ3XXSV.js +44 -0
  174. package/dist/viewer-bundle/stateDiagram-v2-QKLJ7IA2-XNZ3XXSV.js.map +7 -0
  175. package/dist/viewer-bundle/timeline-definition-GMOUNBTQ-FHVZ7MHE.js +1646 -0
  176. package/dist/viewer-bundle/timeline-definition-GMOUNBTQ-FHVZ7MHE.js.map +7 -0
  177. package/dist/viewer-bundle/treeView-SZITEDCU-RXZXNYAM.js +14 -0
  178. package/dist/viewer-bundle/treeView-SZITEDCU-RXZXNYAM.js.map +7 -0
  179. package/dist/viewer-bundle/treemap-W4RFUUIX-2IGOFSJM.js +14 -0
  180. package/dist/viewer-bundle/treemap-W4RFUUIX-2IGOFSJM.js.map +7 -0
  181. package/dist/viewer-bundle/vennDiagram-DHZGUBPP-HEAOEXEZ.js +2544 -0
  182. package/dist/viewer-bundle/vennDiagram-DHZGUBPP-HEAOEXEZ.js.map +7 -0
  183. package/dist/viewer-bundle/wardley-RL74JXVD-VSPCLOX2.js +14 -0
  184. package/dist/viewer-bundle/wardley-RL74JXVD-VSPCLOX2.js.map +7 -0
  185. package/dist/viewer-bundle/wardleyDiagram-NUSXRM2D-EBY4FG3X.js +938 -0
  186. package/dist/viewer-bundle/wardleyDiagram-NUSXRM2D-EBY4FG3X.js.map +7 -0
  187. package/dist/viewer-bundle/xychartDiagram-5P7HB3ND-SSMUQEXK.js +1952 -0
  188. package/dist/viewer-bundle/xychartDiagram-5P7HB3ND-SSMUQEXK.js.map +7 -0
  189. package/package.json +51 -0
@@ -0,0 +1,938 @@
1
+ import {
2
+ populateCommonDb
3
+ } from "./chunk-SRTYTXTX.js";
4
+ import {
5
+ selectSvgElement
6
+ } from "./chunk-N7G7IIKG.js";
7
+ import {
8
+ parse
9
+ } from "./chunk-UEAG4BJQ.js";
10
+ import "./chunk-Z4G7FG27.js";
11
+ import "./chunk-D5RLIWY4.js";
12
+ import "./chunk-EXJQLTIV.js";
13
+ import "./chunk-RQIPIIE2.js";
14
+ import "./chunk-6VW7D5WX.js";
15
+ import "./chunk-GVE7OA3Z.js";
16
+ import "./chunk-ODEP5TKB.js";
17
+ import "./chunk-2QXGXAO5.js";
18
+ import "./chunk-UCAW6C6C.js";
19
+ import "./chunk-VODO7SV4.js";
20
+ import "./chunk-YFQT7PPW.js";
21
+ import "./chunk-A634GTZN.js";
22
+ import {
23
+ clear,
24
+ configureSvgSize,
25
+ getAccDescription,
26
+ getAccTitle,
27
+ getConfig2,
28
+ getDiagramTitle,
29
+ sanitizeText,
30
+ setAccDescription,
31
+ setAccTitle,
32
+ setDiagramTitle
33
+ } from "./chunk-7NZMPQDX.js";
34
+ import "./chunk-YEU62MVS.js";
35
+ import {
36
+ __name,
37
+ log
38
+ } from "./chunk-CZHJHAOR.js";
39
+ import "./chunk-DI52DQAC.js";
40
+
41
+ // ../../node_modules/.pnpm/mermaid@11.14.0/node_modules/mermaid/dist/chunks/mermaid.core/wardleyDiagram-NUSXRM2D.mjs
42
+ var toPercent = /* @__PURE__ */ __name((value, context) => {
43
+ const normalized = value <= 1 ? value * 100 : value;
44
+ if (normalized < 0 || normalized > 100) {
45
+ throw new Error(
46
+ `${context} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${value}`
47
+ );
48
+ }
49
+ return normalized;
50
+ }, "toPercent");
51
+ var toCoordinates = /* @__PURE__ */ __name((visibility, evolution, context) => {
52
+ return {
53
+ x: toPercent(evolution, `${context} evolution`),
54
+ y: toPercent(visibility, `${context} visibility`)
55
+ };
56
+ }, "toCoordinates");
57
+ var getFlowFromPort = /* @__PURE__ */ __name((port) => {
58
+ if (!port) {
59
+ return void 0;
60
+ }
61
+ if (port === "+<>") {
62
+ return "bidirectional";
63
+ }
64
+ if (port === "+<") {
65
+ return "backward";
66
+ }
67
+ if (port === "+>") {
68
+ return "forward";
69
+ }
70
+ return void 0;
71
+ }, "getFlowFromPort");
72
+ var extractFlowFromArrow = /* @__PURE__ */ __name((arrow) => {
73
+ if (!arrow?.startsWith("+")) {
74
+ return {};
75
+ }
76
+ const labelMatch = /^\+'([^']*)'/.exec(arrow);
77
+ const flowLabel = labelMatch?.[1];
78
+ if (arrow.includes("<>")) {
79
+ return { flow: "bidirectional", label: flowLabel };
80
+ }
81
+ if (arrow.includes("<")) {
82
+ return { flow: "backward", label: flowLabel };
83
+ }
84
+ if (arrow.includes(">")) {
85
+ return { flow: "forward", label: flowLabel };
86
+ }
87
+ return { label: flowLabel };
88
+ }, "extractFlowFromArrow");
89
+ var populateDb = /* @__PURE__ */ __name((ast, db) => {
90
+ populateCommonDb(ast, db);
91
+ if (ast.size) {
92
+ db.setSize(ast.size.width, ast.size.height);
93
+ }
94
+ if (ast.evolution) {
95
+ const stages = ast.evolution.stages.map((stage) => {
96
+ if (stage.secondName) {
97
+ return `${stage.name.trim()} / ${stage.secondName.trim()}`;
98
+ }
99
+ return stage.name.trim();
100
+ });
101
+ const stageBoundaries = ast.evolution.stages.filter((stage) => stage.boundary !== void 0).map((stage) => stage.boundary);
102
+ db.updateAxes({ stages, stageBoundaries });
103
+ }
104
+ ast.anchors.forEach((anchor) => {
105
+ const coords = toCoordinates(anchor.visibility, anchor.evolution, `Anchor "${anchor.name}"`);
106
+ db.addNode(anchor.name, anchor.name, coords.x, coords.y, "anchor");
107
+ });
108
+ ast.components.forEach((component) => {
109
+ const coords = toCoordinates(
110
+ component.visibility,
111
+ component.evolution,
112
+ `Component "${component.name}"`
113
+ );
114
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
115
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
116
+ const sourceStrategy = component.decorator?.strategy;
117
+ db.addNode(
118
+ component.name,
119
+ component.name,
120
+ coords.x,
121
+ coords.y,
122
+ "component",
123
+ labelOffsetX,
124
+ labelOffsetY,
125
+ component.inertia,
126
+ sourceStrategy
127
+ );
128
+ });
129
+ ast.notes.forEach((note) => {
130
+ const coords = toCoordinates(note.visibility, note.evolution, `Note "${note.text}"`);
131
+ db.addNote(note.text, coords.x, coords.y);
132
+ });
133
+ ast.pipelines.forEach((pipeline) => {
134
+ const parentNode = db.getNode(pipeline.parent);
135
+ if (!parentNode || typeof parentNode.y !== "number") {
136
+ throw new Error(
137
+ `Pipeline "${pipeline.parent}" must reference an existing component with coordinates.`
138
+ );
139
+ }
140
+ const parentY = parentNode.y;
141
+ db.startPipeline(pipeline.parent);
142
+ pipeline.components.forEach((component) => {
143
+ const componentId = `${pipeline.parent}_${component.name}`;
144
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
145
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
146
+ const x = toPercent(component.evolution, `Pipeline component "${component.name}" evolution`);
147
+ db.addNode(
148
+ componentId,
149
+ component.name,
150
+ x,
151
+ parentY,
152
+ "pipeline-component",
153
+ labelOffsetX,
154
+ labelOffsetY
155
+ );
156
+ db.addPipelineComponent(pipeline.parent, componentId);
157
+ });
158
+ });
159
+ ast.links.forEach((link) => {
160
+ const isDashed = !!link.arrow && (link.arrow.includes("-.->") || link.arrow.includes(".-."));
161
+ let flow = getFlowFromPort(link.fromPort) ?? getFlowFromPort(link.toPort);
162
+ const { flow: arrowFlow, label: flowLabel } = extractFlowFromArrow(link.arrow);
163
+ if (!flow && arrowFlow) {
164
+ flow = arrowFlow;
165
+ }
166
+ const annotation = link.linkLabel;
167
+ const label = flowLabel ?? annotation;
168
+ db.addLink(link.from, link.to, isDashed, label, flow);
169
+ });
170
+ ast.evolves.forEach((evolve) => {
171
+ const node = db.getNode(evolve.component);
172
+ if (node?.y !== void 0) {
173
+ const target = toPercent(evolve.target, `Evolve target for "${evolve.component}"`);
174
+ db.addTrend(evolve.component, target, node.y);
175
+ }
176
+ });
177
+ if (ast.annotations.length > 0) {
178
+ const annotationsBox = ast.annotations[0];
179
+ const coords = toCoordinates(annotationsBox.x, annotationsBox.y, "Annotations box");
180
+ db.setAnnotationsBox(coords.x, coords.y);
181
+ }
182
+ ast.annotation.forEach((annotation) => {
183
+ const coords = toCoordinates(annotation.x, annotation.y, `Annotation ${annotation.number}`);
184
+ db.addAnnotation(annotation.number, [{ x: coords.x, y: coords.y }], annotation.text);
185
+ });
186
+ ast.accelerators.forEach((accelerator) => {
187
+ const coords = toCoordinates(accelerator.x, accelerator.y, `Accelerator "${accelerator.name}"`);
188
+ db.addAccelerator(accelerator.name, coords.x, coords.y);
189
+ });
190
+ ast.deaccelerators.forEach((deaccelerator) => {
191
+ const coords = toCoordinates(
192
+ deaccelerator.x,
193
+ deaccelerator.y,
194
+ `Deaccelerator "${deaccelerator.name}"`
195
+ );
196
+ db.addDeaccelerator(deaccelerator.name, coords.x, coords.y);
197
+ });
198
+ }, "populateDb");
199
+ var parser = {
200
+ parser: {
201
+ // @ts-expect-error - WardleyDB is not assignable to DiagramDB
202
+ yy: void 0
203
+ },
204
+ parse: /* @__PURE__ */ __name(async (input) => {
205
+ const ast = await parse("wardley", input);
206
+ log.debug(ast);
207
+ const db = parser.parser?.yy;
208
+ if (!db || typeof db.addNode !== "function") {
209
+ throw new Error(
210
+ "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."
211
+ );
212
+ }
213
+ populateDb(ast, db);
214
+ }, "parse")
215
+ };
216
+ var WardleyBuilder = class {
217
+ constructor() {
218
+ this.nodes = /* @__PURE__ */ new Map();
219
+ this.links = [];
220
+ this.trends = /* @__PURE__ */ new Map();
221
+ this.pipelines = /* @__PURE__ */ new Map();
222
+ this.annotations = [];
223
+ this.notes = [];
224
+ this.accelerators = [];
225
+ this.deaccelerators = [];
226
+ this.axes = {};
227
+ }
228
+ static {
229
+ __name(this, "WardleyBuilder");
230
+ }
231
+ addNode(node) {
232
+ const existing = this.nodes.get(node.id) ?? { id: node.id, label: node.label };
233
+ const merged = {
234
+ ...existing,
235
+ ...node,
236
+ className: node.className ?? existing.className,
237
+ labelOffsetX: node.labelOffsetX ?? existing.labelOffsetX,
238
+ labelOffsetY: node.labelOffsetY ?? existing.labelOffsetY
239
+ };
240
+ this.nodes.set(node.id, merged);
241
+ }
242
+ addLink(link) {
243
+ this.links.push(link);
244
+ }
245
+ addTrend(trend) {
246
+ this.trends.set(trend.nodeId, trend);
247
+ }
248
+ startPipeline(nodeId) {
249
+ this.pipelines.set(nodeId, { nodeId, componentIds: [] });
250
+ const node = this.nodes.get(nodeId);
251
+ if (node) {
252
+ node.isPipelineParent = true;
253
+ }
254
+ }
255
+ addPipelineComponent(pipelineNodeId, componentId) {
256
+ const pipeline = this.pipelines.get(pipelineNodeId);
257
+ if (pipeline) {
258
+ pipeline.componentIds.push(componentId);
259
+ }
260
+ const node = this.nodes.get(componentId);
261
+ if (node) {
262
+ node.inPipeline = true;
263
+ }
264
+ }
265
+ addAnnotation(annotation) {
266
+ this.annotations.push(annotation);
267
+ }
268
+ addNote(note) {
269
+ this.notes.push(note);
270
+ }
271
+ addAccelerator(accelerator) {
272
+ this.accelerators.push(accelerator);
273
+ }
274
+ addDeaccelerator(deaccelerator) {
275
+ this.deaccelerators.push(deaccelerator);
276
+ }
277
+ setAnnotationsBox(x, y) {
278
+ this.annotationsBox = { x, y };
279
+ }
280
+ setAxes(partial) {
281
+ this.axes = {
282
+ ...this.axes,
283
+ ...partial
284
+ };
285
+ }
286
+ setSize(width, height) {
287
+ this.size = { width, height };
288
+ }
289
+ getNode(id) {
290
+ return this.nodes.get(id);
291
+ }
292
+ build() {
293
+ const nodes = [];
294
+ for (const node of this.nodes.values()) {
295
+ if (typeof node.x !== "number" || typeof node.y !== "number") {
296
+ throw new Error(`Node "${node.label}" is missing coordinates`);
297
+ }
298
+ nodes.push(node);
299
+ }
300
+ return {
301
+ nodes,
302
+ links: [...this.links],
303
+ trends: [...this.trends.values()],
304
+ pipelines: [...this.pipelines.values()],
305
+ annotations: [...this.annotations],
306
+ notes: [...this.notes],
307
+ accelerators: [...this.accelerators],
308
+ deaccelerators: [...this.deaccelerators],
309
+ annotationsBox: this.annotationsBox,
310
+ axes: { ...this.axes },
311
+ size: this.size
312
+ };
313
+ }
314
+ clear() {
315
+ this.nodes.clear();
316
+ this.links = [];
317
+ this.trends.clear();
318
+ this.pipelines.clear();
319
+ this.annotations = [];
320
+ this.notes = [];
321
+ this.accelerators = [];
322
+ this.deaccelerators = [];
323
+ this.annotationsBox = void 0;
324
+ this.axes = {};
325
+ this.size = void 0;
326
+ }
327
+ };
328
+ var builder = new WardleyBuilder();
329
+ function textSanitizer(text) {
330
+ const config = getConfig2();
331
+ return sanitizeText(text.trim(), config);
332
+ }
333
+ __name(textSanitizer, "textSanitizer");
334
+ function getConfig22() {
335
+ return getConfig2()["wardley-beta"];
336
+ }
337
+ __name(getConfig22, "getConfig");
338
+ function addNode(id, label, x, y, className, labelOffsetX, labelOffsetY, inertia, sourceStrategy) {
339
+ builder.addNode({
340
+ id,
341
+ label: textSanitizer(label),
342
+ x,
343
+ y,
344
+ className,
345
+ labelOffsetX,
346
+ labelOffsetY,
347
+ inertia,
348
+ sourceStrategy
349
+ });
350
+ }
351
+ __name(addNode, "addNode");
352
+ function addLink(sourceId, targetId, dashed = false, label, flow) {
353
+ builder.addLink({ source: sourceId, target: targetId, dashed, label, flow });
354
+ }
355
+ __name(addLink, "addLink");
356
+ function addTrend(nodeId, targetX, targetY) {
357
+ builder.addTrend({ nodeId, targetX, targetY });
358
+ }
359
+ __name(addTrend, "addTrend");
360
+ function addAnnotation(number, coordinates, text) {
361
+ builder.addAnnotation({
362
+ number,
363
+ coordinates,
364
+ text: text ? textSanitizer(text) : void 0
365
+ });
366
+ }
367
+ __name(addAnnotation, "addAnnotation");
368
+ function addNote(text, x, y) {
369
+ builder.addNote({
370
+ text: textSanitizer(text),
371
+ x,
372
+ y
373
+ });
374
+ }
375
+ __name(addNote, "addNote");
376
+ function addAccelerator(name, x, y) {
377
+ builder.addAccelerator({
378
+ name: textSanitizer(name),
379
+ x,
380
+ y
381
+ });
382
+ }
383
+ __name(addAccelerator, "addAccelerator");
384
+ function addDeaccelerator(name, x, y) {
385
+ builder.addDeaccelerator({
386
+ name: textSanitizer(name),
387
+ x,
388
+ y
389
+ });
390
+ }
391
+ __name(addDeaccelerator, "addDeaccelerator");
392
+ function setAnnotationsBox(x, y) {
393
+ builder.setAnnotationsBox(x, y);
394
+ }
395
+ __name(setAnnotationsBox, "setAnnotationsBox");
396
+ function setSize(width, height) {
397
+ builder.setSize(width, height);
398
+ }
399
+ __name(setSize, "setSize");
400
+ function startPipeline(nodeId) {
401
+ builder.startPipeline(nodeId);
402
+ }
403
+ __name(startPipeline, "startPipeline");
404
+ function addPipelineComponent(pipelineNodeId, componentId) {
405
+ builder.addPipelineComponent(pipelineNodeId, componentId);
406
+ }
407
+ __name(addPipelineComponent, "addPipelineComponent");
408
+ function updateAxes(partial) {
409
+ const sanitized = {};
410
+ if (partial.xLabel) {
411
+ sanitized.xLabel = textSanitizer(partial.xLabel);
412
+ }
413
+ if (partial.yLabel) {
414
+ sanitized.yLabel = textSanitizer(partial.yLabel);
415
+ }
416
+ if (partial.stages) {
417
+ sanitized.stages = partial.stages.map((stage) => textSanitizer(stage));
418
+ }
419
+ if (partial.stageBoundaries) {
420
+ sanitized.stageBoundaries = partial.stageBoundaries;
421
+ }
422
+ builder.setAxes(sanitized);
423
+ }
424
+ __name(updateAxes, "updateAxes");
425
+ function getNode(id) {
426
+ return builder.getNode(id);
427
+ }
428
+ __name(getNode, "getNode");
429
+ function getWardleyData() {
430
+ return builder.build();
431
+ }
432
+ __name(getWardleyData, "getWardleyData");
433
+ function clear2() {
434
+ builder.clear();
435
+ clear();
436
+ }
437
+ __name(clear2, "clear");
438
+ var wardleyDb_default = {
439
+ getConfig: getConfig22,
440
+ addNode,
441
+ addLink,
442
+ addTrend,
443
+ addAnnotation,
444
+ addNote,
445
+ addAccelerator,
446
+ addDeaccelerator,
447
+ setAnnotationsBox,
448
+ setSize,
449
+ startPipeline,
450
+ addPipelineComponent,
451
+ updateAxes,
452
+ getNode,
453
+ getWardleyData,
454
+ clear: clear2,
455
+ setAccTitle,
456
+ getAccTitle,
457
+ setDiagramTitle,
458
+ getDiagramTitle,
459
+ getAccDescription,
460
+ setAccDescription
461
+ };
462
+ var DEFAULT_STAGES = ["Genesis", "Custom Built", "Product", "Commodity"];
463
+ var getTheme = /* @__PURE__ */ __name(() => {
464
+ const { themeVariables } = getConfig2();
465
+ return {
466
+ backgroundColor: themeVariables.wardley?.backgroundColor ?? themeVariables.background ?? "#fff",
467
+ axisColor: themeVariables.wardley?.axisColor ?? "#000",
468
+ axisTextColor: themeVariables.wardley?.axisTextColor ?? themeVariables.primaryTextColor ?? "#222",
469
+ gridColor: themeVariables.wardley?.gridColor ?? "rgba(100, 100, 100, 0.2)",
470
+ componentFill: themeVariables.wardley?.componentFill ?? "#fff",
471
+ componentStroke: themeVariables.wardley?.componentStroke ?? "#000",
472
+ componentLabelColor: themeVariables.wardley?.componentLabelColor ?? themeVariables.primaryTextColor ?? "#222",
473
+ linkStroke: themeVariables.wardley?.linkStroke ?? "#000",
474
+ evolutionStroke: themeVariables.wardley?.evolutionStroke ?? "#dc3545",
475
+ annotationStroke: themeVariables.wardley?.annotationStroke ?? "#000",
476
+ annotationTextColor: themeVariables.wardley?.annotationTextColor ?? themeVariables.primaryTextColor ?? "#222",
477
+ annotationFill: themeVariables.wardley?.annotationFill ?? themeVariables.background ?? "#fff"
478
+ };
479
+ }, "getTheme");
480
+ var getConfigValues = /* @__PURE__ */ __name(() => {
481
+ const wardleyConfig = getConfig2()["wardley-beta"];
482
+ return {
483
+ width: wardleyConfig?.width ?? 900,
484
+ height: wardleyConfig?.height ?? 600,
485
+ padding: wardleyConfig?.padding ?? 48,
486
+ nodeRadius: wardleyConfig?.nodeRadius ?? 6,
487
+ nodeLabelOffset: wardleyConfig?.nodeLabelOffset ?? 8,
488
+ axisFontSize: wardleyConfig?.axisFontSize ?? 12,
489
+ labelFontSize: wardleyConfig?.labelFontSize ?? 10,
490
+ showGrid: wardleyConfig?.showGrid ?? false,
491
+ useMaxWidth: wardleyConfig?.useMaxWidth ?? true
492
+ };
493
+ }, "getConfigValues");
494
+ var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
495
+ log.debug("Rendering Wardley map\n" + text);
496
+ const configValues = getConfigValues();
497
+ const theme = getTheme();
498
+ const squareSize = configValues.nodeRadius * 1.6;
499
+ const db = diagObj.db;
500
+ const data = db.getWardleyData();
501
+ const title = db.getDiagramTitle();
502
+ const width = data.size?.width ?? configValues.width;
503
+ const height = data.size?.height ?? configValues.height;
504
+ const svg = selectSvgElement(id);
505
+ svg.selectAll("*").remove();
506
+ configureSvgSize(svg, height, width, configValues.useMaxWidth);
507
+ svg.attr("viewBox", `0 0 ${width} ${height}`);
508
+ const root = svg.append("g").attr("class", "wardley-map");
509
+ const defs = svg.append("defs");
510
+ 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");
511
+ 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");
512
+ 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");
513
+ root.append("rect").attr("class", "wardley-background").attr("width", width).attr("height", height).attr("fill", theme.backgroundColor);
514
+ const chartWidth = width - configValues.padding * 2;
515
+ const chartHeight = height - configValues.padding * 2;
516
+ if (title) {
517
+ 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);
518
+ }
519
+ const projectX = /* @__PURE__ */ __name((value) => configValues.padding + value / 100 * chartWidth, "projectX");
520
+ const projectY = /* @__PURE__ */ __name((value) => height - configValues.padding - value / 100 * chartHeight, "projectY");
521
+ const axisGroup = root.append("g").attr("class", "wardley-axes");
522
+ 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);
523
+ 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);
524
+ const xLabel = data.axes.xLabel ?? "Evolution";
525
+ const yLabel = data.axes.yLabel ?? "Visibility";
526
+ 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);
527
+ 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(
528
+ "transform",
529
+ `rotate(-90 ${configValues.padding / 3} ${configValues.padding + chartHeight / 2})`
530
+ ).text(yLabel);
531
+ const stages = data.axes.stages && data.axes.stages.length > 0 ? data.axes.stages : DEFAULT_STAGES;
532
+ if (stages.length > 0) {
533
+ const stageGroup = root.append("g").attr("class", "wardley-stages");
534
+ const boundaries = data.axes.stageBoundaries;
535
+ const stagePositions = [];
536
+ if (boundaries && boundaries.length === stages.length) {
537
+ let prevBoundary = 0;
538
+ boundaries.forEach((boundary) => {
539
+ stagePositions.push({ start: prevBoundary, end: boundary });
540
+ prevBoundary = boundary;
541
+ });
542
+ } else {
543
+ const stageWidth = 1 / stages.length;
544
+ stages.forEach((_, index) => {
545
+ stagePositions.push({
546
+ start: index * stageWidth,
547
+ end: (index + 1) * stageWidth
548
+ });
549
+ });
550
+ }
551
+ stages.forEach((stage, index) => {
552
+ const pos = stagePositions[index];
553
+ const startX = configValues.padding + pos.start * chartWidth;
554
+ const endX = configValues.padding + pos.end * chartWidth;
555
+ const centerX = (startX + endX) / 2;
556
+ if (index > 0) {
557
+ 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);
558
+ }
559
+ 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);
560
+ });
561
+ }
562
+ if (configValues.showGrid) {
563
+ const gridGroup = root.append("g").attr("class", "wardley-grid");
564
+ for (let i = 1; i < 4; i++) {
565
+ const ratio = i / 4;
566
+ const x = configValues.padding + chartWidth * ratio;
567
+ 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");
568
+ 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");
569
+ }
570
+ }
571
+ const positions = /* @__PURE__ */ new Map();
572
+ data.nodes.forEach((node) => {
573
+ positions.set(node.id, {
574
+ x: projectX(node.x),
575
+ y: projectY(node.y),
576
+ node
577
+ });
578
+ });
579
+ if (data.pipelines.length > 0) {
580
+ const pipelineGroup = root.append("g").attr("class", "wardley-pipelines");
581
+ const pipelineLinksGroup = root.append("g").attr("class", "wardley-pipeline-links");
582
+ data.pipelines.forEach((pipeline) => {
583
+ if (pipeline.componentIds.length === 0) {
584
+ return;
585
+ }
586
+ 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);
587
+ for (let i = 0; i < sortedComponents.length - 1; i++) {
588
+ const current = sortedComponents[i];
589
+ const next = sortedComponents[i + 1];
590
+ 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");
591
+ }
592
+ let minX = Infinity;
593
+ let maxX = -Infinity;
594
+ let y = 0;
595
+ pipeline.componentIds.forEach((componentId) => {
596
+ const pos = positions.get(componentId);
597
+ if (pos) {
598
+ minX = Math.min(minX, pos.x);
599
+ maxX = Math.max(maxX, pos.x);
600
+ y = pos.y;
601
+ }
602
+ });
603
+ if (minX !== Infinity && maxX !== -Infinity) {
604
+ const padding = 15;
605
+ const height2 = configValues.nodeRadius * 4;
606
+ const boxTop = y - height2 / 2;
607
+ const parentPos = positions.get(pipeline.nodeId);
608
+ if (parentPos) {
609
+ const centerX = (minX + maxX) / 2;
610
+ parentPos.x = centerX;
611
+ parentPos.y = boxTop - squareSize / 6;
612
+ }
613
+ 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);
614
+ }
615
+ });
616
+ }
617
+ const linksGroup = root.append("g").attr("class", "wardley-links");
618
+ const pipelineMap = /* @__PURE__ */ new Map();
619
+ data.pipelines.forEach((pipeline) => {
620
+ pipelineMap.set(pipeline.nodeId, new Set(pipeline.componentIds));
621
+ });
622
+ const validLinks = data.links.filter((link) => {
623
+ if (!positions.has(link.source) || !positions.has(link.target)) {
624
+ return false;
625
+ }
626
+ const pipelineComponents = pipelineMap.get(link.target);
627
+ if (pipelineComponents?.has(link.source)) {
628
+ return false;
629
+ }
630
+ return true;
631
+ });
632
+ linksGroup.selectAll("line").data(validLinks).enter().append("line").attr("class", (link) => `wardley-link${link.dashed ? " wardley-link--dashed" : ""}`).attr("x1", (link) => {
633
+ const sourcePos = positions.get(link.source);
634
+ const targetPos = positions.get(link.target);
635
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
636
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
637
+ const dx = targetPos.x - sourcePos.x;
638
+ const dy = targetPos.y - sourcePos.y;
639
+ const distance = Math.sqrt(dx * dx + dy * dy);
640
+ return sourcePos.x + dx / distance * radius;
641
+ }).attr("y1", (link) => {
642
+ const sourcePos = positions.get(link.source);
643
+ const targetPos = positions.get(link.target);
644
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
645
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
646
+ const dx = targetPos.x - sourcePos.x;
647
+ const dy = targetPos.y - sourcePos.y;
648
+ const distance = Math.sqrt(dx * dx + dy * dy);
649
+ return sourcePos.y + dy / distance * radius;
650
+ }).attr("x2", (link) => {
651
+ const sourcePos = positions.get(link.source);
652
+ const targetPos = positions.get(link.target);
653
+ const targetNode = data.nodes.find((n) => n.id === link.target);
654
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
655
+ const dx = sourcePos.x - targetPos.x;
656
+ const dy = sourcePos.y - targetPos.y;
657
+ const distance = Math.sqrt(dx * dx + dy * dy);
658
+ return targetPos.x + dx / distance * radius;
659
+ }).attr("y2", (link) => {
660
+ const sourcePos = positions.get(link.source);
661
+ const targetPos = positions.get(link.target);
662
+ const targetNode = data.nodes.find((n) => n.id === link.target);
663
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
664
+ const dx = sourcePos.x - targetPos.x;
665
+ const dy = sourcePos.y - targetPos.y;
666
+ const distance = Math.sqrt(dx * dx + dy * dy);
667
+ return targetPos.y + dy / distance * radius;
668
+ }).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", (link) => link.dashed ? "6 6" : null).attr("marker-end", (link) => {
669
+ if (link.flow === "forward" || link.flow === "bidirectional") {
670
+ return `url(#link-arrow-end-${id})`;
671
+ }
672
+ return null;
673
+ }).attr("marker-start", (link) => {
674
+ if (link.flow === "backward" || link.flow === "bidirectional") {
675
+ return `url(#link-arrow-start-${id})`;
676
+ }
677
+ return null;
678
+ });
679
+ linksGroup.selectAll("text").data(validLinks.filter((link) => link.label)).enter().append("text").attr("class", "wardley-link-label").attr("x", (link) => {
680
+ const sourcePos = positions.get(link.source);
681
+ const targetPos = positions.get(link.target);
682
+ const midX = (sourcePos.x + targetPos.x) / 2;
683
+ const dy = targetPos.y - sourcePos.y;
684
+ const dx = targetPos.x - sourcePos.x;
685
+ const distance = Math.sqrt(dx * dx + dy * dy);
686
+ const offset = 8;
687
+ const perpX = dy / distance;
688
+ return midX + perpX * offset;
689
+ }).attr("y", (link) => {
690
+ const sourcePos = positions.get(link.source);
691
+ const targetPos = positions.get(link.target);
692
+ const midY = (sourcePos.y + targetPos.y) / 2;
693
+ const dx = targetPos.x - sourcePos.x;
694
+ const dy = targetPos.y - sourcePos.y;
695
+ const distance = Math.sqrt(dx * dx + dy * dy);
696
+ const offset = 8;
697
+ const perpY = -dx / distance;
698
+ return midY + perpY * offset;
699
+ }).attr("fill", theme.axisTextColor).attr("font-size", configValues.labelFontSize).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("transform", (link) => {
700
+ const sourcePos = positions.get(link.source);
701
+ const targetPos = positions.get(link.target);
702
+ const midX = (sourcePos.x + targetPos.x) / 2;
703
+ const midY = (sourcePos.y + targetPos.y) / 2;
704
+ const dx = targetPos.x - sourcePos.x;
705
+ const dy = targetPos.y - sourcePos.y;
706
+ const distance = Math.sqrt(dx * dx + dy * dy);
707
+ const offset = 8;
708
+ const perpX = dy / distance;
709
+ const perpY = -dx / distance;
710
+ const labelX = midX + perpX * offset;
711
+ const labelY = midY + perpY * offset;
712
+ let angle = Math.atan2(dy, dx) * 180 / Math.PI;
713
+ if (angle > 90 || angle < -90) {
714
+ angle += 180;
715
+ }
716
+ return `rotate(${angle} ${labelX} ${labelY})`;
717
+ }).text((link) => link.label);
718
+ const trendGroup = root.append("g").attr("class", "wardley-trends");
719
+ const trendsWithPositions = data.trends.map((trend) => {
720
+ const origin = positions.get(trend.nodeId);
721
+ if (!origin) {
722
+ return null;
723
+ }
724
+ const targetX = projectX(trend.targetX);
725
+ const targetY = projectY(trend.targetY);
726
+ const dx = targetX - origin.x;
727
+ const dy = targetY - origin.y;
728
+ const distance = Math.sqrt(dx * dx + dy * dy);
729
+ const shortenBy = configValues.nodeRadius + 2;
730
+ const adjustedX2 = distance > shortenBy ? targetX - dx / distance * shortenBy : targetX;
731
+ const adjustedY2 = distance > shortenBy ? targetY - dy / distance * shortenBy : targetY;
732
+ return {
733
+ origin,
734
+ targetX,
735
+ targetY,
736
+ adjustedX2,
737
+ adjustedY2
738
+ };
739
+ }).filter((trend) => trend !== null);
740
+ 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})`);
741
+ const nodesGroup = root.append("g").attr("class", "wardley-nodes");
742
+ const nodeEnter = nodesGroup.selectAll("g").data(data.nodes).enter().append("g").attr(
743
+ "class",
744
+ (node) => ["wardley-node", node.className ? `wardley-node--${node.className}` : ""].filter(Boolean).join(" ")
745
+ );
746
+ 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);
747
+ 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);
748
+ 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);
749
+ const marketNodes = nodeEnter.filter((node) => node.sourceStrategy === "market");
750
+ 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);
751
+ nodeEnter.filter(
752
+ (node) => !node.isPipelineParent && node.sourceStrategy !== "market" && node.className !== "anchor"
753
+ ).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);
754
+ const smallCircleRadius = configValues.nodeRadius * 0.7;
755
+ const triangleRadius = configValues.nodeRadius * 1.2;
756
+ 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);
757
+ 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);
758
+ 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);
759
+ 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);
760
+ 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);
761
+ 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);
762
+ 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);
763
+ nodeEnter.filter((node) => node.inertia === true).append("line").attr("class", "wardley-inertia").attr("x1", (node) => {
764
+ const pos = positions.get(node.id);
765
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
766
+ if (node.sourceStrategy) {
767
+ offset += configValues.nodeRadius + 10;
768
+ }
769
+ return pos.x + offset;
770
+ }).attr("y1", (node) => {
771
+ const pos = positions.get(node.id);
772
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
773
+ return pos.y - lineHeight / 2;
774
+ }).attr("x2", (node) => {
775
+ const pos = positions.get(node.id);
776
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
777
+ if (node.sourceStrategy) {
778
+ offset += configValues.nodeRadius + 10;
779
+ }
780
+ return pos.x + offset;
781
+ }).attr("y2", (node) => {
782
+ const pos = positions.get(node.id);
783
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
784
+ return pos.y + lineHeight / 2;
785
+ }).attr("stroke", theme.componentStroke).attr("stroke-width", 6);
786
+ nodeEnter.append("text").attr("x", (node) => {
787
+ const pos = positions.get(node.id);
788
+ if (node.className === "anchor") {
789
+ return node.labelOffsetX !== void 0 ? pos.x + node.labelOffsetX : pos.x;
790
+ }
791
+ let defaultOffset = configValues.nodeLabelOffset;
792
+ if (node.sourceStrategy && node.labelOffsetX === void 0) {
793
+ defaultOffset += 10;
794
+ }
795
+ const customOffset = node.labelOffsetX ?? defaultOffset;
796
+ return pos.x + customOffset;
797
+ }).attr("y", (node) => {
798
+ const pos = positions.get(node.id);
799
+ if (node.className === "anchor") {
800
+ return node.labelOffsetY !== void 0 ? pos.y + node.labelOffsetY : pos.y - 3;
801
+ }
802
+ let defaultOffset = -configValues.nodeLabelOffset;
803
+ if (node.sourceStrategy && node.labelOffsetY === void 0) {
804
+ defaultOffset -= 10;
805
+ }
806
+ const customOffset = node.labelOffsetY ?? defaultOffset;
807
+ return pos.y + customOffset;
808
+ }).attr("class", "wardley-node-label").attr("fill", (node) => {
809
+ if (node.className === "evolved") {
810
+ return theme.evolutionStroke;
811
+ }
812
+ if (node.className === "anchor") {
813
+ return "#000";
814
+ }
815
+ return theme.componentLabelColor;
816
+ }).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);
817
+ if (data.annotations.length > 0) {
818
+ const annotationsGroup = root.append("g").attr("class", "wardley-annotations");
819
+ data.annotations.forEach((annotation) => {
820
+ const projectedCoords = annotation.coordinates.map((coord) => ({
821
+ x: projectX(coord.x),
822
+ y: projectY(coord.y)
823
+ }));
824
+ if (projectedCoords.length > 1) {
825
+ for (let i = 0; i < projectedCoords.length - 1; i++) {
826
+ 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");
827
+ }
828
+ }
829
+ projectedCoords.forEach((coord) => {
830
+ const annotationNode = annotationsGroup.append("g").attr("class", "wardley-annotation");
831
+ 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);
832
+ 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);
833
+ });
834
+ });
835
+ if (data.annotationsBox) {
836
+ let boxX = projectX(data.annotationsBox.x);
837
+ let boxY = projectY(data.annotationsBox.y);
838
+ const padding = 10;
839
+ const lineHeight = 16;
840
+ const fontSize = 11;
841
+ const textBoxGroup = annotationsGroup.append("g").attr("class", "wardley-annotations-box");
842
+ const sortedAnnotations = [...data.annotations].filter((a) => a.text).sort((a, b) => a.number - b.number);
843
+ const textElements = [];
844
+ sortedAnnotations.forEach((annotation, idx) => {
845
+ 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}`);
846
+ textElements.push(text2);
847
+ });
848
+ if (textElements.length > 0) {
849
+ let maxWidth = 0;
850
+ let maxHeight = 0;
851
+ textElements.forEach((text2) => {
852
+ const textNode = text2.node();
853
+ const textWidth = textNode.getComputedTextLength();
854
+ maxWidth = Math.max(maxWidth, textWidth);
855
+ const bbox = textNode.getBBox();
856
+ maxHeight = Math.max(maxHeight, bbox.height);
857
+ });
858
+ const boxWidth = maxWidth + padding * 2 + 105;
859
+ const boxHeight = sortedAnnotations.length * lineHeight + padding * 2 + maxHeight / 2;
860
+ const minX = configValues.padding;
861
+ const maxX = width - configValues.padding - boxWidth;
862
+ const minY = configValues.padding;
863
+ const maxY = height - configValues.padding - boxHeight;
864
+ boxX = Math.max(minX, Math.min(boxX, maxX));
865
+ boxY = Math.max(minY, Math.min(boxY, maxY));
866
+ textElements.forEach((text2, idx) => {
867
+ text2.attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight);
868
+ });
869
+ 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);
870
+ }
871
+ }
872
+ }
873
+ if (data.notes.length > 0) {
874
+ const notesGroup = root.append("g").attr("class", "wardley-notes");
875
+ data.notes.forEach((note) => {
876
+ const noteX = projectX(note.x);
877
+ const noteY = projectY(note.y);
878
+ 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);
879
+ });
880
+ }
881
+ if (data.accelerators.length > 0) {
882
+ const acceleratorsGroup = root.append("g").attr("class", "wardley-accelerators");
883
+ data.accelerators.forEach((accelerator) => {
884
+ const accX = projectX(accelerator.x);
885
+ const accY = projectY(accelerator.y);
886
+ const arrowWidth = 60;
887
+ const arrowHeight = 30;
888
+ const arrowHeadWidth = 20;
889
+ const arrowPath = `
890
+ M ${accX} ${accY - arrowHeight / 2}
891
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2}
892
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2 - 8}
893
+ L ${accX + arrowWidth} ${accY}
894
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2 + 8}
895
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2}
896
+ L ${accX} ${accY + arrowHeight / 2}
897
+ Z
898
+ `;
899
+ acceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
900
+ 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);
901
+ });
902
+ }
903
+ if (data.deaccelerators.length > 0) {
904
+ const deacceleratorsGroup = root.append("g").attr("class", "wardley-deaccelerators");
905
+ data.deaccelerators.forEach((deaccelerator) => {
906
+ const decX = projectX(deaccelerator.x);
907
+ const decY = projectY(deaccelerator.y);
908
+ const arrowWidth = 60;
909
+ const arrowHeight = 30;
910
+ const arrowHeadWidth = 20;
911
+ const arrowPath = `
912
+ M ${decX + arrowWidth} ${decY - arrowHeight / 2}
913
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2}
914
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2 - 8}
915
+ L ${decX} ${decY}
916
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2 + 8}
917
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2}
918
+ L ${decX + arrowWidth} ${decY + arrowHeight / 2}
919
+ Z
920
+ `;
921
+ deacceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
922
+ 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);
923
+ });
924
+ }
925
+ }, "draw");
926
+ var wardleyRenderer_default = {
927
+ draw
928
+ };
929
+ var diagram = {
930
+ parser,
931
+ db: wardleyDb_default,
932
+ renderer: wardleyRenderer_default,
933
+ styles: /* @__PURE__ */ __name(() => "", "styles")
934
+ };
935
+ export {
936
+ diagram
937
+ };
938
+ //# sourceMappingURL=wardleyDiagram-NUSXRM2D-EBY4FG3X.js.map