whipped 0.8.1 → 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-BMFVAmy4.js → index-DZ7I8r_C.js} +41392 -39594
  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 +1 -1
@@ -0,0 +1,454 @@
1
+ import { p as populateCommonDb } from "./chunk-JWPE2WC7-BW4n_ZhH.js";
2
+ import { s as setAccDescription, g as getAccDescription, o as getDiagramTitle, n as setDiagramTitle, a as getAccTitle, b as setAccTitle, _ as __name, l as log, D as selectSvgElement, e as configureSvgSize, p as clear, A as cleanAndMerge, y as getConfig, B as defaultConfig_default, E as getThemeVariables3 } from "./mermaid.core-BRk3IzY2.js";
3
+ import { p as parse } from "./cynefin-VYW2F7L2-DTNV7gvQ.js";
4
+ import "./index-DZ7I8r_C.js";
5
+ var createDefaultData = /* @__PURE__ */ __name(() => ({
6
+ domains: /* @__PURE__ */ new Map(),
7
+ transitions: []
8
+ }), "createDefaultData");
9
+ var data = createDefaultData();
10
+ var getDomains = /* @__PURE__ */ __name(() => data.domains, "getDomains");
11
+ var getTransitions = /* @__PURE__ */ __name(() => data.transitions, "getTransitions");
12
+ var setDomains = /* @__PURE__ */ __name((blocks) => {
13
+ if (!blocks) {
14
+ return;
15
+ }
16
+ for (const block of blocks) {
17
+ const domainName = block.domain;
18
+ const items = (block.items ?? []).map((item) => ({
19
+ label: item.label
20
+ }));
21
+ data.domains.set(domainName, {
22
+ name: domainName,
23
+ items
24
+ });
25
+ }
26
+ }, "setDomains");
27
+ var setTransitions = /* @__PURE__ */ __name((transitions) => {
28
+ if (!transitions) {
29
+ return;
30
+ }
31
+ data.transitions = transitions.filter((t) => {
32
+ if (t.from === t.to) {
33
+ log.warn(
34
+ `Cynefin: self-loop transition on domain "${t.from}" is not meaningful and will be skipped.`
35
+ );
36
+ return false;
37
+ }
38
+ return true;
39
+ }).map((t) => ({
40
+ from: t.from,
41
+ to: t.to,
42
+ label: t.label || void 0
43
+ }));
44
+ }, "setTransitions");
45
+ var getConfig2 = /* @__PURE__ */ __name(() => {
46
+ return cleanAndMerge({
47
+ ...defaultConfig_default.cynefin,
48
+ ...getConfig().cynefin
49
+ });
50
+ }, "getConfig");
51
+ var clear2 = /* @__PURE__ */ __name(() => {
52
+ clear();
53
+ data = createDefaultData();
54
+ }, "clear");
55
+ var db = {
56
+ getDomains,
57
+ getTransitions,
58
+ setDomains,
59
+ setTransitions,
60
+ getConfig: getConfig2,
61
+ clear: clear2,
62
+ setAccTitle,
63
+ getAccTitle,
64
+ setDiagramTitle,
65
+ getDiagramTitle,
66
+ getAccDescription,
67
+ setAccDescription
68
+ };
69
+ var populate = /* @__PURE__ */ __name((ast) => {
70
+ populateCommonDb(ast, db);
71
+ db.setDomains(ast.domains);
72
+ db.setTransitions(ast.transitions);
73
+ }, "populate");
74
+ var parser = {
75
+ parse: /* @__PURE__ */ __name(async (input) => {
76
+ const ast = await parse("cynefin", input);
77
+ log.debug(ast);
78
+ populate(ast);
79
+ }, "parse")
80
+ };
81
+ function seededRandom(seed) {
82
+ let t = seed + 1831565813 | 0;
83
+ t = Math.imul(t ^ t >>> 15, t | 1);
84
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
85
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
86
+ }
87
+ __name(seededRandom, "seededRandom");
88
+ function hashString(str) {
89
+ let hash = 0;
90
+ for (let i = 0; i < str.length; i++) {
91
+ const ch = str.charCodeAt(i);
92
+ hash = (hash << 5) - hash + ch;
93
+ hash |= 0;
94
+ }
95
+ return hash;
96
+ }
97
+ __name(hashString, "hashString");
98
+ function resolveSeed(configuredSeed, id) {
99
+ if (typeof configuredSeed === "number" && Number.isFinite(configuredSeed) && configuredSeed !== 0) {
100
+ return configuredSeed;
101
+ }
102
+ return hashString(id);
103
+ }
104
+ __name(resolveSeed, "resolveSeed");
105
+ function generateFoldPath(width, height, seed, amplitudeOverride) {
106
+ const cx = width / 2;
107
+ const amplitude = amplitudeOverride ?? width * 0.015;
108
+ const segments = 7;
109
+ const segHeight = height / segments;
110
+ const points = [];
111
+ for (let i = 0; i <= segments; i++) {
112
+ const jitter = seededRandom(seed + i * 17) * amplitude * 2 - amplitude;
113
+ points.push({ x: cx + jitter, y: i * segHeight });
114
+ }
115
+ let d = `M${points[0].x},${points[0].y}`;
116
+ for (let i = 0; i < points.length - 1; i++) {
117
+ const p0 = points[i];
118
+ const p1 = points[i + 1];
119
+ const midY = (p0.y + p1.y) / 2;
120
+ const dir = i % 2 === 0 ? 1 : -1;
121
+ const offset = amplitude * 1.5 * dir * seededRandom(seed + i * 31 + 7);
122
+ const cp1x = p0.x + offset;
123
+ const cp1y = midY;
124
+ const cp2x = p1.x - offset;
125
+ const cp2y = midY;
126
+ d += ` C${cp1x},${cp1y} ${cp2x},${cp2y} ${p1.x},${p1.y}`;
127
+ }
128
+ return d;
129
+ }
130
+ __name(generateFoldPath, "generateFoldPath");
131
+ function generateHorizontalBoundary(width, height, seed, amplitudeOverride) {
132
+ const cy = height / 2;
133
+ const amplitude = amplitudeOverride ?? height * 0.015;
134
+ const segments = 7;
135
+ const segWidth = width / segments;
136
+ const points = [];
137
+ for (let i = 0; i <= segments; i++) {
138
+ const jitter = seededRandom(seed + i * 23) * amplitude * 2 - amplitude;
139
+ points.push({ x: i * segWidth, y: cy + jitter });
140
+ }
141
+ let d = `M${points[0].x},${points[0].y}`;
142
+ for (let i = 0; i < points.length - 1; i++) {
143
+ const p0 = points[i];
144
+ const p1 = points[i + 1];
145
+ const midX = (p0.x + p1.x) / 2;
146
+ const dir = i % 2 === 0 ? 1 : -1;
147
+ const offset = amplitude * 1.5 * dir * seededRandom(seed + i * 37 + 11);
148
+ const cp1x = midX;
149
+ const cp1y = p0.y + offset;
150
+ const cp2x = midX;
151
+ const cp2y = p1.y - offset;
152
+ d += ` C${cp1x},${cp1y} ${cp2x},${cp2y} ${p1.x},${p1.y}`;
153
+ }
154
+ return d;
155
+ }
156
+ __name(generateHorizontalBoundary, "generateHorizontalBoundary");
157
+ function generateCliffPath(width, height) {
158
+ const cx = width / 2;
159
+ const topY = height * 0.5;
160
+ const bottomY = height;
161
+ const amplitude = width * 0.03;
162
+ return [
163
+ `M${cx},${topY}`,
164
+ `C${cx + amplitude},${topY + (bottomY - topY) * 0.2}`,
165
+ `${cx - amplitude * 1.5},${topY + (bottomY - topY) * 0.55}`,
166
+ `${cx + amplitude * 0.5},${topY + (bottomY - topY) * 0.75}`,
167
+ `C${cx - amplitude},${topY + (bottomY - topY) * 0.85}`,
168
+ `${cx + amplitude * 0.3},${topY + (bottomY - topY) * 0.95}`,
169
+ `${cx},${bottomY}`
170
+ ].join(" ");
171
+ }
172
+ __name(generateCliffPath, "generateCliffPath");
173
+ function generateConfusionPath(cx, cy, rx, ry) {
174
+ return [
175
+ `M${cx - rx},${cy}`,
176
+ `A${rx},${ry} 0 1,1 ${cx + rx},${cy}`,
177
+ `A${rx},${ry} 0 1,1 ${cx - rx},${cy}`,
178
+ "Z"
179
+ ].join(" ");
180
+ }
181
+ __name(generateConfusionPath, "generateConfusionPath");
182
+ var DOMAIN_META = {
183
+ complex: { model: "Probe → Sense → Respond", practice: "Emergent Practices" },
184
+ complicated: { model: "Sense → Analyse → Respond", practice: "Good Practices" },
185
+ clear: { model: "Sense → Categorise → Respond", practice: "Best Practices" },
186
+ chaotic: { model: "Act → Sense → Respond", practice: "Novel Practices" },
187
+ confusion: { model: "", practice: "Disorder" }
188
+ };
189
+ var getDomainLayouts = /* @__PURE__ */ __name((width, height) => {
190
+ const hw = width / 2;
191
+ const hh = height / 2;
192
+ return {
193
+ complex: { cx: hw / 2, cy: hh / 2, x: 0, y: 0, w: hw, h: hh },
194
+ complicated: { cx: hw + hw / 2, cy: hh / 2, x: hw, y: 0, w: hw, h: hh },
195
+ chaotic: { cx: hw / 2, cy: hh + hh / 2, x: 0, y: hh, w: hw, h: hh },
196
+ clear: { cx: hw + hw / 2, cy: hh + hh / 2, x: hw, y: hh, w: hw, h: hh },
197
+ confusion: { cx: hw, cy: hh, x: hw * 0.7, y: hh * 0.7, w: hw * 0.6, h: hh * 0.6 }
198
+ };
199
+ }, "getDomainLayouts");
200
+ var getCynefinDomainColors = /* @__PURE__ */ __name(() => {
201
+ const defaultThemeVariables = getThemeVariables3();
202
+ const currentConfig = getConfig();
203
+ const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
204
+ return themeVariables.cynefin;
205
+ }, "getCynefinDomainColors");
206
+ var MAX_CONFUSION_ITEMS = 3;
207
+ var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
208
+ const db2 = diagram2.db;
209
+ const domains = db2.getDomains();
210
+ const transitions = db2.getTransitions();
211
+ const title = db2.getDiagramTitle();
212
+ const accTitle = db2.getAccTitle();
213
+ const accDescription = db2.getAccDescription();
214
+ const config = db2.getConfig();
215
+ const domainColors = getCynefinDomainColors();
216
+ log.debug("Rendering Cynefin diagram");
217
+ const width = config.width;
218
+ const height = config.height;
219
+ const padding = config.padding;
220
+ const showDomainDescriptions = config.showDomainDescriptions;
221
+ const boundaryAmplitude = config.boundaryAmplitude;
222
+ const totalWidth = width + padding * 2;
223
+ const totalHeight = height + padding * 2;
224
+ const domainBg = {
225
+ complex: domainColors.complexBg,
226
+ complicated: domainColors.complicatedBg,
227
+ clear: domainColors.clearBg,
228
+ chaotic: domainColors.chaoticBg,
229
+ confusion: domainColors.confusionBg
230
+ };
231
+ const svg = selectSvgElement(id);
232
+ configureSvgSize(svg, totalHeight, totalWidth, config.useMaxWidth ?? true);
233
+ svg.attr("viewBox", `0 0 ${totalWidth} ${totalHeight}`);
234
+ if (accTitle) {
235
+ svg.append("title").text(accTitle);
236
+ }
237
+ if (accDescription) {
238
+ svg.append("desc").text(accDescription);
239
+ }
240
+ const root = svg.append("g").attr("transform", `translate(${padding}, ${padding})`);
241
+ const layouts = getDomainLayouts(width, height);
242
+ const seed = resolveSeed(config.seed, id);
243
+ const bgGroup = root.append("g").attr("class", "cynefin-backgrounds");
244
+ const quadrantDomains = ["complex", "complicated", "chaotic", "clear"];
245
+ for (const domainName of quadrantDomains) {
246
+ const layout = layouts[domainName];
247
+ bgGroup.append("rect").attr("class", "cynefinDomain").attr("x", layout.x).attr("y", layout.y).attr("width", layout.w).attr("height", layout.h).attr("fill", domainBg[domainName]).attr("fill-opacity", 0.4).attr("stroke", "none");
248
+ }
249
+ const boundaryGroup = root.append("g").attr("class", "cynefin-boundaries");
250
+ boundaryGroup.append("path").attr("class", "cynefinBoundary").attr("d", generateFoldPath(width, height, seed, boundaryAmplitude)).attr("fill", "none");
251
+ boundaryGroup.append("path").attr("class", "cynefinBoundary").attr("d", generateHorizontalBoundary(width, height, seed + 100, boundaryAmplitude)).attr("fill", "none");
252
+ boundaryGroup.append("path").attr("class", "cynefinCliff").attr("d", generateCliffPath(width, height)).attr("fill", "none");
253
+ const confusionRx = width * 0.15;
254
+ const confusionRy = height * 0.15;
255
+ root.append("path").attr("class", "cynefinConfusion").attr("d", generateConfusionPath(width / 2, height / 2, confusionRx, confusionRy)).attr("fill", domainBg.confusion).attr("fill-opacity", 0.5);
256
+ const labelGroup = root.append("g").attr("class", "cynefin-labels");
257
+ for (const domainName of quadrantDomains) {
258
+ const layout = layouts[domainName];
259
+ labelGroup.append("text").attr("class", "cynefinDomainLabel").attr("x", layout.cx).attr("y", showDomainDescriptions ? layout.cy - 30 : layout.cy).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(domainName.charAt(0).toUpperCase() + domainName.slice(1));
260
+ }
261
+ labelGroup.append("text").attr("class", "cynefinDomainLabel").attr("x", width / 2).attr("y", showDomainDescriptions ? height / 2 - 10 : height / 2).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text("Confusion");
262
+ if (showDomainDescriptions) {
263
+ const subtitleGroup = root.append("g").attr("class", "cynefin-subtitles");
264
+ for (const domainName of quadrantDomains) {
265
+ const layout = layouts[domainName];
266
+ const meta = DOMAIN_META[domainName];
267
+ subtitleGroup.append("text").attr("class", "cynefinSubtitle").attr("x", layout.cx).attr("y", layout.cy - 10).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(meta.model);
268
+ subtitleGroup.append("text").attr("class", "cynefinSubtitle").attr("x", layout.cx).attr("y", layout.cy + 5).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(meta.practice);
269
+ }
270
+ subtitleGroup.append("text").attr("class", "cynefinSubtitle").attr("x", width / 2).attr("y", height / 2 + 8).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(DOMAIN_META.confusion.practice);
271
+ }
272
+ const itemGroup = root.append("g").attr("class", "cynefin-items");
273
+ const itemHeight = 26;
274
+ const itemPaddingX = 10;
275
+ const allDomains = ["complex", "complicated", "chaotic", "clear", "confusion"];
276
+ for (const domainName of allDomains) {
277
+ const domain = domains.get(domainName);
278
+ if (!domain || domain.items.length === 0) {
279
+ continue;
280
+ }
281
+ const layout = layouts[domainName];
282
+ const isConfusion = domainName === "confusion";
283
+ let itemsToRender = domain.items;
284
+ let overflowCount = 0;
285
+ if (isConfusion && domain.items.length > MAX_CONFUSION_ITEMS) {
286
+ overflowCount = domain.items.length - MAX_CONFUSION_ITEMS;
287
+ itemsToRender = domain.items.slice(0, MAX_CONFUSION_ITEMS);
288
+ }
289
+ let startY;
290
+ if (isConfusion) {
291
+ const labelOffset = showDomainDescriptions ? 22 : 14;
292
+ startY = layout.cy + labelOffset;
293
+ } else {
294
+ startY = layout.cy + (showDomainDescriptions ? 25 : 15);
295
+ }
296
+ [...itemsToRender].forEach((item, idx) => {
297
+ const itemY = startY + idx * (itemHeight + 4);
298
+ const g = itemGroup.append("g");
299
+ const textEl = g.append("text").attr("class", "cynefinItemText").attr("x", 0).attr("y", itemHeight / 2).attr("text-anchor", "middle").attr("dominant-baseline", "central").text(item.label);
300
+ let measuredWidth = item.label.length * 7;
301
+ const textNode = textEl.node();
302
+ if (textNode && typeof textNode.getBBox === "function") {
303
+ const bbox = textNode.getBBox();
304
+ if (bbox.width > 0) {
305
+ measuredWidth = bbox.width;
306
+ }
307
+ }
308
+ const badgeWidth = measuredWidth + itemPaddingX * 2;
309
+ const itemX = layout.cx - badgeWidth / 2;
310
+ g.attr("transform", `translate(${itemX}, ${itemY})`);
311
+ g.insert("rect", "text").attr("class", "cynefinItem").attr("x", 0).attr("y", 0).attr("width", badgeWidth).attr("height", itemHeight).attr("rx", 4).attr("ry", 4).attr("fill", domainBg[domainName]).attr("fill-opacity", 0.95);
312
+ textEl.attr("x", badgeWidth / 2).attr("y", itemHeight / 2);
313
+ });
314
+ if (overflowCount > 0) {
315
+ const overflowY = startY + itemsToRender.length * (itemHeight + 4);
316
+ const overflowLabel = `+${overflowCount} more`;
317
+ const g = itemGroup.append("g");
318
+ const textEl = g.append("text").attr("class", "cynefinItemText").attr("x", 0).attr("y", itemHeight / 2).attr("text-anchor", "middle").attr("dominant-baseline", "central").text(overflowLabel);
319
+ let measuredWidth = overflowLabel.length * 7;
320
+ const textNode = textEl.node();
321
+ if (textNode && typeof textNode.getBBox === "function") {
322
+ const bbox = textNode.getBBox();
323
+ if (bbox.width > 0) {
324
+ measuredWidth = bbox.width;
325
+ }
326
+ }
327
+ const badgeWidth = measuredWidth + itemPaddingX * 2;
328
+ const itemX = layout.cx - badgeWidth / 2;
329
+ g.attr("transform", `translate(${itemX}, ${overflowY})`);
330
+ g.insert("rect", "text").attr("class", "cynefinItemOverflow").attr("x", 0).attr("y", 0).attr("width", badgeWidth).attr("height", itemHeight).attr("rx", 4).attr("ry", 4).attr("fill", domainBg[domainName]).attr("fill-opacity", 0.6);
331
+ textEl.attr("x", badgeWidth / 2).attr("y", itemHeight / 2);
332
+ }
333
+ }
334
+ if (transitions.length > 0) {
335
+ const defs = svg.select("defs").empty() ? svg.append("defs") : svg.select("defs");
336
+ const markerId = `cynefin-arrow-${id}`;
337
+ defs.append("marker").attr("id", markerId).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("class", "cynefinArrowHead");
338
+ const arrowGroup = root.append("g").attr("class", "cynefin-arrows");
339
+ transitions.forEach((transition) => {
340
+ const fromLayout = layouts[transition.from];
341
+ const toLayout = layouts[transition.to];
342
+ if (!fromLayout || !toLayout) {
343
+ return;
344
+ }
345
+ if (transition.from === transition.to) {
346
+ log.warn(`Cynefin renderer: skipping self-loop on domain "${transition.from}"`);
347
+ return;
348
+ }
349
+ const x1 = fromLayout.cx;
350
+ const y1 = fromLayout.cy;
351
+ const x2 = toLayout.cx;
352
+ const y2 = toLayout.cy;
353
+ const mx = (x1 + x2) / 2;
354
+ const my = (y1 + y2) / 2;
355
+ const dx = x2 - x1;
356
+ const dy = y2 - y1;
357
+ const len = Math.sqrt(dx * dx + dy * dy);
358
+ const offsetAmount = len * 0.15;
359
+ const nx = -dy / len;
360
+ const ny = dx / len;
361
+ const cpx = mx + nx * offsetAmount;
362
+ const cpy = my + ny * offsetAmount;
363
+ arrowGroup.append("path").attr("class", "cynefinArrowLine").attr("d", `M${x1},${y1} Q${cpx},${cpy} ${x2},${y2}`).attr("fill", "none").attr("marker-end", `url(#${markerId})`);
364
+ if (transition.label) {
365
+ arrowGroup.append("text").attr("class", "cynefinArrowLabel").attr("x", cpx).attr("y", cpy - 6).attr("text-anchor", "middle").attr("dominant-baseline", "auto").text(transition.label);
366
+ }
367
+ });
368
+ }
369
+ if (title) {
370
+ root.append("text").attr("class", "cynefinTitle").attr("x", width / 2).attr("y", -padding / 2).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
371
+ }
372
+ }, "draw");
373
+ var renderer = { draw };
374
+ var getCynefinTheme = /* @__PURE__ */ __name(() => {
375
+ const defaultThemeVariables = getThemeVariables3();
376
+ const currentConfig = getConfig();
377
+ const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
378
+ return themeVariables.cynefin;
379
+ }, "getCynefinTheme");
380
+ var styles = /* @__PURE__ */ __name(() => {
381
+ const t = getCynefinTheme();
382
+ return `
383
+ .cynefinDomain {
384
+ stroke: none;
385
+ }
386
+ .cynefinDomainLabel {
387
+ font-size: ${t.domainFontSize}px;
388
+ font-weight: bold;
389
+ fill: ${t.labelColor};
390
+ }
391
+ .cynefinSubtitle {
392
+ font-size: ${t.itemFontSize - 1}px;
393
+ fill: ${t.textColor};
394
+ font-style: italic;
395
+ }
396
+ .cynefinItem {
397
+ fill-opacity: 0.95;
398
+ stroke: ${t.boundaryColor};
399
+ stroke-width: 1;
400
+ }
401
+ .cynefinItemText {
402
+ font-size: ${t.itemFontSize}px;
403
+ fill: ${t.textColor};
404
+ }
405
+ .cynefinItemOverflow {
406
+ fill-opacity: 0.6;
407
+ stroke: ${t.boundaryColor};
408
+ stroke-width: 1;
409
+ stroke-dasharray: 3 2;
410
+ }
411
+ .cynefinBoundary {
412
+ stroke: ${t.boundaryColor};
413
+ stroke-width: ${t.boundaryWidth};
414
+ stroke-dasharray: 6 3;
415
+ }
416
+ .cynefinCliff {
417
+ stroke: ${t.cliffColor};
418
+ stroke-width: ${t.cliffWidth};
419
+ }
420
+ .cynefinConfusion {
421
+ stroke: ${t.boundaryColor};
422
+ stroke-width: 1.5;
423
+ stroke-dasharray: 4 2;
424
+ }
425
+ .cynefinArrowLine {
426
+ stroke: ${t.arrowColor};
427
+ stroke-width: ${t.arrowWidth};
428
+ fill: none;
429
+ }
430
+ .cynefinArrowHead {
431
+ fill: ${t.arrowColor};
432
+ stroke: none;
433
+ }
434
+ .cynefinArrowLabel {
435
+ font-size: ${t.itemFontSize - 1}px;
436
+ fill: ${t.textColor};
437
+ }
438
+ .cynefinTitle {
439
+ font-size: ${t.domainFontSize + 2}px;
440
+ font-weight: bold;
441
+ fill: ${t.labelColor};
442
+ }
443
+ `;
444
+ }, "styles");
445
+ var styles_default = styles;
446
+ var diagram = {
447
+ parser,
448
+ db,
449
+ renderer,
450
+ styles: styles_default
451
+ };
452
+ export {
453
+ diagram
454
+ };