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,76 @@
1
+ import { i as initRange } from "./init-ZxktEp_H.js";
2
+ class InternMap extends Map {
3
+ constructor(entries, key = keyof) {
4
+ super();
5
+ Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
6
+ if (entries != null) for (const [key2, value] of entries) this.set(key2, value);
7
+ }
8
+ get(key) {
9
+ return super.get(intern_get(this, key));
10
+ }
11
+ has(key) {
12
+ return super.has(intern_get(this, key));
13
+ }
14
+ set(key, value) {
15
+ return super.set(intern_set(this, key), value);
16
+ }
17
+ delete(key) {
18
+ return super.delete(intern_delete(this, key));
19
+ }
20
+ }
21
+ function intern_get({ _intern, _key }, value) {
22
+ const key = _key(value);
23
+ return _intern.has(key) ? _intern.get(key) : value;
24
+ }
25
+ function intern_set({ _intern, _key }, value) {
26
+ const key = _key(value);
27
+ if (_intern.has(key)) return _intern.get(key);
28
+ _intern.set(key, value);
29
+ return value;
30
+ }
31
+ function intern_delete({ _intern, _key }, value) {
32
+ const key = _key(value);
33
+ if (_intern.has(key)) {
34
+ value = _intern.get(key);
35
+ _intern.delete(key);
36
+ }
37
+ return value;
38
+ }
39
+ function keyof(value) {
40
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
41
+ }
42
+ const implicit = Symbol("implicit");
43
+ function ordinal() {
44
+ var index = new InternMap(), domain = [], range = [], unknown = implicit;
45
+ function scale(d) {
46
+ let i = index.get(d);
47
+ if (i === void 0) {
48
+ if (unknown !== implicit) return unknown;
49
+ index.set(d, i = domain.push(d) - 1);
50
+ }
51
+ return range[i % range.length];
52
+ }
53
+ scale.domain = function(_) {
54
+ if (!arguments.length) return domain.slice();
55
+ domain = [], index = new InternMap();
56
+ for (const value of _) {
57
+ if (index.has(value)) continue;
58
+ index.set(value, domain.push(value) - 1);
59
+ }
60
+ return scale;
61
+ };
62
+ scale.range = function(_) {
63
+ return arguments.length ? (range = Array.from(_), scale) : range.slice();
64
+ };
65
+ scale.unknown = function(_) {
66
+ return arguments.length ? (unknown = _, scale) : unknown;
67
+ };
68
+ scale.copy = function() {
69
+ return ordinal(domain, range).unknown(unknown);
70
+ };
71
+ initRange.apply(scale, arguments);
72
+ return scale;
73
+ }
74
+ export {
75
+ ordinal as o
76
+ };
@@ -0,0 +1,127 @@
1
+ import { g as getStyles, r as renderer, d as db } from "./chunk-MOJQB5TN-BykRa615.js";
2
+ import { p as populateCommonDb } from "./chunk-JWPE2WC7-BW4n_ZhH.js";
3
+ import { _ as __name, l as log } from "./mermaid.core-BRk3IzY2.js";
4
+ import { M as MermaidParseError, d as createRailroadPegServices } from "./cynefin-VYW2F7L2-DTNV7gvQ.js";
5
+ import "./index-DZ7I8r_C.js";
6
+ var langiumParser = createRailroadPegServices().RailroadPeg.parser.LangiumParser;
7
+ var transformOrderedChoice = /* @__PURE__ */ __name((choice) => {
8
+ const alternatives = choice.alternatives.map(transformSequence);
9
+ if (alternatives.length === 1) {
10
+ return alternatives[0];
11
+ }
12
+ return {
13
+ type: "choice",
14
+ alternatives
15
+ };
16
+ }, "transformOrderedChoice");
17
+ var transformSequence = /* @__PURE__ */ __name((sequence) => {
18
+ const elements = sequence.elements.map(transformPrefix);
19
+ if (elements.length === 1) {
20
+ return elements[0];
21
+ }
22
+ return {
23
+ type: "sequence",
24
+ elements
25
+ };
26
+ }, "transformSequence");
27
+ var transformPrefix = /* @__PURE__ */ __name((prefix) => {
28
+ const inner = transformSuffix(prefix.suffix);
29
+ if (!prefix.operator) {
30
+ return inner;
31
+ }
32
+ const label = prefix.operator === "&" ? `&${nodeToLabel(inner)}` : `!${nodeToLabel(inner)}`;
33
+ return {
34
+ type: "special",
35
+ text: label
36
+ };
37
+ }, "transformPrefix");
38
+ var nodeToLabel = /* @__PURE__ */ __name((node) => {
39
+ switch (node.type) {
40
+ case "terminal":
41
+ return `"${node.value}"`;
42
+ case "nonterminal":
43
+ return node.name;
44
+ case "special":
45
+ return node.text;
46
+ default:
47
+ return "(...)";
48
+ }
49
+ }, "nodeToLabel");
50
+ var transformSuffix = /* @__PURE__ */ __name((suffix) => {
51
+ const inner = transformPrimary(suffix.primary);
52
+ if (!suffix.operator) {
53
+ return inner;
54
+ }
55
+ switch (suffix.operator) {
56
+ case "?":
57
+ return { type: "optional", element: inner };
58
+ case "*":
59
+ return { type: "repetition", element: inner, min: 0, max: Infinity };
60
+ case "+":
61
+ return { type: "repetition", element: inner, min: 1, max: Infinity };
62
+ default:
63
+ throw new Error(`Unsupported PEG suffix operator: ${suffix.operator}`);
64
+ }
65
+ }, "transformSuffix");
66
+ var transformPrimary = /* @__PURE__ */ __name((primary) => {
67
+ switch (primary.$type) {
68
+ case "PegLiteral":
69
+ return {
70
+ type: "terminal",
71
+ value: primary.value
72
+ };
73
+ case "PegIdentifier":
74
+ return {
75
+ type: "nonterminal",
76
+ name: primary.name
77
+ };
78
+ case "PegGroup":
79
+ return transformOrderedChoice(primary.element);
80
+ case "PegAny":
81
+ return {
82
+ type: "special",
83
+ text: primary.dot
84
+ };
85
+ default:
86
+ throw new Error(`Unsupported PEG primary node: ${primary.$type}`);
87
+ }
88
+ }, "transformPrimary");
89
+ var transformRule = /* @__PURE__ */ __name((rule) => {
90
+ return {
91
+ name: rule.name,
92
+ definition: transformOrderedChoice(rule.definition)
93
+ };
94
+ }, "transformRule");
95
+ var populateDb = /* @__PURE__ */ __name((ast) => {
96
+ populateCommonDb(ast, db);
97
+ if (ast.title) {
98
+ db.setTitle(ast.title);
99
+ }
100
+ ast.rules.map((rule) => db.addRule(transformRule(rule)));
101
+ }, "populateDb");
102
+ var parser = {
103
+ parse: /* @__PURE__ */ __name((input) => {
104
+ db.clear();
105
+ log.debug("[PEG Parser] Starting Langium parse");
106
+ const result = langiumParser.parse(input);
107
+ if (result.lexerErrors.length > 0 || result.parserErrors.length > 0) {
108
+ throw new MermaidParseError(result);
109
+ }
110
+ const ast = result.value;
111
+ log.debug("[PEG Parser] Parsed rules:", ast.rules.length);
112
+ populateDb(ast);
113
+ log.debug("[PEG Parser] Parse complete");
114
+ }, "parse"),
115
+ parser: {
116
+ yy: db
117
+ }
118
+ };
119
+ var diagram = {
120
+ parser,
121
+ db,
122
+ renderer,
123
+ styles: getStyles
124
+ };
125
+ export {
126
+ diagram
127
+ };
@@ -0,0 +1,318 @@
1
+ import { p as populateCommonDb } from "./chunk-JWPE2WC7-BW4n_ZhH.js";
2
+ import { a2 as constant, a5 as tau, b5 as array, g as getAccDescription, s as setAccDescription, a as getAccTitle, b as setAccTitle, o as getDiagramTitle, n as setDiagramTitle, _ as __name, l as log, c as getConfig2$1, A as cleanAndMerge, D as selectSvgElement, K as parseFontSize, e as configureSvgSize, p as clear, B as defaultConfig_default } from "./mermaid.core-BRk3IzY2.js";
3
+ import { p as parse } from "./cynefin-VYW2F7L2-DTNV7gvQ.js";
4
+ import { d as d3arc } from "./arc-DmDBHE0H.js";
5
+ import { o as ordinal } from "./ordinal-DSZU4PqD.js";
6
+ import "./index-DZ7I8r_C.js";
7
+ import "./init-ZxktEp_H.js";
8
+ function descending(a, b) {
9
+ return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
10
+ }
11
+ function identity(d) {
12
+ return d;
13
+ }
14
+ function d3pie() {
15
+ var value = identity, sortValues = descending, sort = null, startAngle = constant(0), endAngle = constant(tau), padAngle = constant(0);
16
+ function pie(data) {
17
+ var i, n = (data = array(data)).length, j, k, sum = 0, index = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), a1, p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), pa = p * (da < 0 ? -1 : 1), v;
18
+ for (i = 0; i < n; ++i) {
19
+ if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
20
+ sum += v;
21
+ }
22
+ }
23
+ if (sortValues != null) index.sort(function(i2, j2) {
24
+ return sortValues(arcs[i2], arcs[j2]);
25
+ });
26
+ else if (sort != null) index.sort(function(i2, j2) {
27
+ return sort(data[i2], data[j2]);
28
+ });
29
+ for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {
30
+ j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
31
+ data: data[j],
32
+ index: i,
33
+ value: v,
34
+ startAngle: a0,
35
+ endAngle: a1,
36
+ padAngle: p
37
+ };
38
+ }
39
+ return arcs;
40
+ }
41
+ pie.value = function(_) {
42
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie) : value;
43
+ };
44
+ pie.sortValues = function(_) {
45
+ return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
46
+ };
47
+ pie.sort = function(_) {
48
+ return arguments.length ? (sort = _, sortValues = null, pie) : sort;
49
+ };
50
+ pie.startAngle = function(_) {
51
+ return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie) : startAngle;
52
+ };
53
+ pie.endAngle = function(_) {
54
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle;
55
+ };
56
+ pie.padAngle = function(_) {
57
+ return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle;
58
+ };
59
+ return pie;
60
+ }
61
+ var DEFAULT_PIE_CONFIG = defaultConfig_default.pie;
62
+ var DEFAULT_PIE_DB = {
63
+ sections: /* @__PURE__ */ new Map(),
64
+ showData: false
65
+ };
66
+ var sections = DEFAULT_PIE_DB.sections;
67
+ var showData = DEFAULT_PIE_DB.showData;
68
+ var config = structuredClone(DEFAULT_PIE_CONFIG);
69
+ var getConfig2 = /* @__PURE__ */ __name(() => structuredClone(config), "getConfig");
70
+ var clear2 = /* @__PURE__ */ __name(() => {
71
+ sections = /* @__PURE__ */ new Map();
72
+ showData = DEFAULT_PIE_DB.showData;
73
+ clear();
74
+ }, "clear");
75
+ var addSection = /* @__PURE__ */ __name(({ label, value }) => {
76
+ if (value < 0) {
77
+ throw new Error(
78
+ `"${label}" has invalid value: ${value}. Negative values are not allowed in pie charts. All slice values must be >= 0.`
79
+ );
80
+ }
81
+ if (!sections.has(label)) {
82
+ sections.set(label, value);
83
+ log.debug(`added new section: ${label}, with value: ${value}`);
84
+ }
85
+ }, "addSection");
86
+ var getSections = /* @__PURE__ */ __name(() => sections, "getSections");
87
+ var setShowData = /* @__PURE__ */ __name((toggle) => {
88
+ showData = toggle;
89
+ }, "setShowData");
90
+ var getShowData = /* @__PURE__ */ __name(() => showData, "getShowData");
91
+ var db = {
92
+ getConfig: getConfig2,
93
+ clear: clear2,
94
+ setDiagramTitle,
95
+ getDiagramTitle,
96
+ setAccTitle,
97
+ getAccTitle,
98
+ setAccDescription,
99
+ getAccDescription,
100
+ addSection,
101
+ getSections,
102
+ setShowData,
103
+ getShowData
104
+ };
105
+ var populateDb = /* @__PURE__ */ __name((ast, db2) => {
106
+ populateCommonDb(ast, db2);
107
+ db2.setShowData(ast.showData);
108
+ ast.sections.map(db2.addSection);
109
+ }, "populateDb");
110
+ var parser = {
111
+ parse: /* @__PURE__ */ __name(async (input) => {
112
+ const ast = await parse("pie", input);
113
+ log.debug(ast);
114
+ populateDb(ast, db);
115
+ }, "parse")
116
+ };
117
+ var getStyles = /* @__PURE__ */ __name((options) => `
118
+ .pieCircle{
119
+ stroke: ${options.pieStrokeColor};
120
+ stroke-width : ${options.pieStrokeWidth};
121
+ opacity : ${options.pieOpacity};
122
+ }
123
+ .pieCircle.highlighted{
124
+ scale: 1.05;
125
+ opacity: 1;
126
+ }
127
+ .pieCircle.highlightedOnHover:hover{
128
+ transition-duration: 250ms;
129
+ scale: 1.05;
130
+ opacity: 1;
131
+ }
132
+ .pieOuterCircle{
133
+ stroke: ${options.pieOuterStrokeColor};
134
+ stroke-width: ${options.pieOuterStrokeWidth};
135
+ fill: none;
136
+ }
137
+ .pieTitleText {
138
+ text-anchor: middle;
139
+ font-size: ${options.pieTitleTextSize};
140
+ fill: ${options.pieTitleTextColor};
141
+ font-family: ${options.fontFamily};
142
+ }
143
+ .slice {
144
+ font-family: ${options.fontFamily};
145
+ fill: ${options.pieSectionTextColor};
146
+ font-size:${options.pieSectionTextSize};
147
+ // fill: white;
148
+ }
149
+ .legend text {
150
+ fill: ${options.pieLegendTextColor};
151
+ font-family: ${options.fontFamily};
152
+ font-size: ${options.pieLegendTextSize};
153
+ }
154
+ `, "getStyles");
155
+ var pieStyles_default = getStyles;
156
+ var createPieArcs = /* @__PURE__ */ __name((sections2) => {
157
+ const sum = [...sections2.values()].reduce((acc, val) => acc + val, 0);
158
+ const pieData = [...sections2.entries()].map(([label, value]) => ({ label, value })).filter((d) => d.value / sum * 100 >= 1);
159
+ const pie = d3pie().value((d) => d.value).sort(null);
160
+ return pie(pieData);
161
+ }, "createPieArcs");
162
+ var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
163
+ var _a;
164
+ log.debug("rendering pie chart\n" + text);
165
+ const db2 = diagObj.db;
166
+ const globalConfig = getConfig2$1();
167
+ const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie);
168
+ const MARGIN = 40;
169
+ const LEGEND_RECT_SIZE = 18;
170
+ const LEGEND_SPACING = 4;
171
+ const height = 450;
172
+ const pieWidth = height;
173
+ const svg = selectSvgElement(id);
174
+ const group = svg.append("g");
175
+ group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")");
176
+ const { themeVariables } = globalConfig;
177
+ let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
178
+ outerStrokeWidth ?? (outerStrokeWidth = 2);
179
+ const legendPosition = pieConfig.legendPosition;
180
+ const textPosition = pieConfig.textPosition;
181
+ const innerHole = pieConfig.donutHole > 0 && pieConfig.donutHole <= 0.9 ? pieConfig.donutHole : 0;
182
+ const radius = Math.min(pieWidth, height) / 2 - MARGIN;
183
+ const arcGenerator = d3arc().innerRadius(innerHole * radius).outerRadius(radius);
184
+ const labelArcGenerator = d3arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
185
+ const pie = group.append("g");
186
+ pie.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
187
+ const sections2 = db2.getSections();
188
+ const arcs = createPieArcs(sections2);
189
+ const myGeneratedColors = [
190
+ themeVariables.pie1,
191
+ themeVariables.pie2,
192
+ themeVariables.pie3,
193
+ themeVariables.pie4,
194
+ themeVariables.pie5,
195
+ themeVariables.pie6,
196
+ themeVariables.pie7,
197
+ themeVariables.pie8,
198
+ themeVariables.pie9,
199
+ themeVariables.pie10,
200
+ themeVariables.pie11,
201
+ themeVariables.pie12
202
+ ];
203
+ let sum = 0;
204
+ sections2.forEach((section) => {
205
+ sum += section;
206
+ });
207
+ const filteredArcs = arcs.filter((datum) => (datum.data.value / sum * 100).toFixed(0) !== "0");
208
+ const color = ordinal(myGeneratedColors).domain([
209
+ ...sections2.keys()
210
+ ]);
211
+ pie.selectAll("mySlices").data(filteredArcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => {
212
+ return color(datum.data.label);
213
+ }).attr("class", (datum) => {
214
+ let className = "pieCircle";
215
+ if (pieConfig.highlightSlice === "hover") {
216
+ className += " highlightedOnHover";
217
+ } else if (pieConfig.highlightSlice === datum.data.label) {
218
+ className += " highlighted";
219
+ }
220
+ return className;
221
+ });
222
+ pie.selectAll("mySlices").data(filteredArcs).enter().append("text").text((datum) => {
223
+ return (datum.data.value / sum * 100).toFixed(0) + "%";
224
+ }).attr("transform", (datum) => {
225
+ return "translate(" + labelArcGenerator.centroid(datum) + ")";
226
+ }).style("text-anchor", "middle").attr("class", "slice");
227
+ const titleText = group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -400 / 2).attr("class", "pieTitleText");
228
+ const allSectionData = [...sections2.entries()].map(([label, value]) => ({
229
+ label,
230
+ value
231
+ }));
232
+ const legend = group.selectAll(".legend").data(allSectionData).enter().append("g").attr("class", "legend");
233
+ legend.append("rect").attr("width", LEGEND_RECT_SIZE).attr("height", LEGEND_RECT_SIZE).style("fill", (d) => color(d.label)).style("stroke", (d) => color(d.label));
234
+ legend.append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((d) => {
235
+ if (db2.getShowData()) {
236
+ return `${d.label} [${d.value}]`;
237
+ }
238
+ return d.label;
239
+ });
240
+ const longestTextWidth = Math.max(
241
+ ...legend.selectAll("text").nodes().map((node) => (node == null ? void 0 : node.getBoundingClientRect().width) ?? 0)
242
+ );
243
+ let chartAndLegendHeight = height;
244
+ let chartAndLegendWidth = pieWidth + MARGIN;
245
+ const legendHeight = LEGEND_RECT_SIZE + LEGEND_SPACING;
246
+ const totalLegendHeight = allSectionData.length * legendHeight;
247
+ switch (legendPosition) {
248
+ case "center":
249
+ legend.attr("transform", (_datum, index) => {
250
+ const offset = legendHeight * allSectionData.length / 2;
251
+ const horizontal = -longestTextWidth / 2 - (LEGEND_RECT_SIZE + LEGEND_SPACING);
252
+ const vertical = index * legendHeight - offset;
253
+ return "translate(" + horizontal + "," + vertical + ")";
254
+ });
255
+ break;
256
+ case "top":
257
+ chartAndLegendHeight += totalLegendHeight;
258
+ legend.attr("transform", (_datum, index) => {
259
+ const offset = radius;
260
+ const horizontal = -longestTextWidth / 2 - (LEGEND_RECT_SIZE + LEGEND_SPACING);
261
+ const vertical = index * legendHeight - offset;
262
+ return `translate(${horizontal}, ${vertical})`;
263
+ });
264
+ pie.attr("transform", () => {
265
+ return `translate(0, ${totalLegendHeight + legendHeight})`;
266
+ });
267
+ break;
268
+ case "bottom":
269
+ chartAndLegendHeight += totalLegendHeight;
270
+ legend.attr("transform", (_datum, index) => {
271
+ const offset = -radius - legendHeight;
272
+ const horizontal = -longestTextWidth / 2 - (LEGEND_RECT_SIZE + LEGEND_SPACING);
273
+ const vertical = index * legendHeight - offset;
274
+ return "translate(" + horizontal + "," + vertical + ")";
275
+ });
276
+ break;
277
+ case "left":
278
+ chartAndLegendWidth += LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth;
279
+ legend.attr("transform", (_datum, index) => {
280
+ const offset = legendHeight * allSectionData.length / 2;
281
+ const horizontal = -radius - (LEGEND_RECT_SIZE + LEGEND_SPACING);
282
+ const vertical = index * legendHeight - offset;
283
+ return "translate(" + horizontal + "," + vertical + ")";
284
+ });
285
+ pie.attr("transform", () => {
286
+ return `translate(${longestTextWidth + LEGEND_RECT_SIZE + LEGEND_SPACING}, 0)`;
287
+ });
288
+ break;
289
+ case "right":
290
+ default:
291
+ chartAndLegendWidth += LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth;
292
+ legend.attr("transform", (_datum, index) => {
293
+ const offset = legendHeight * allSectionData.length / 2;
294
+ const horizontal = 12 * LEGEND_RECT_SIZE;
295
+ const vertical = index * legendHeight - offset;
296
+ return "translate(" + horizontal + "," + vertical + ")";
297
+ });
298
+ break;
299
+ }
300
+ const titleWidth = ((_a = titleText.node()) == null ? void 0 : _a.getBoundingClientRect().width) ?? 0;
301
+ const titleLeft = pieWidth / 2 - titleWidth / 2;
302
+ const titleRight = pieWidth / 2 + titleWidth / 2;
303
+ const viewBoxX = Math.min(0, titleLeft);
304
+ const viewBoxRight = Math.max(chartAndLegendWidth, titleRight);
305
+ const totalWidth = viewBoxRight - viewBoxX;
306
+ svg.attr("viewBox", `${viewBoxX} 0 ${totalWidth} ${chartAndLegendHeight}`);
307
+ configureSvgSize(svg, chartAndLegendHeight, totalWidth, pieConfig.useMaxWidth);
308
+ }, "draw");
309
+ var renderer = { draw };
310
+ var diagram = {
311
+ parser,
312
+ db,
313
+ renderer,
314
+ styles: pieStyles_default
315
+ };
316
+ export {
317
+ diagram
318
+ };