@infinilabs/ai-chat 0.0.0 → 0.0.2

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 (119) hide show
  1. package/README.md +310 -56
  2. package/dist/_baseUniq-BFn6cCm9.js +152 -0
  3. package/dist/_baseUniq-nfJyj2zU.cjs +151 -0
  4. package/dist/arc-BWSMkwk2.cjs +130 -0
  5. package/dist/arc-DODeX7B9.js +131 -0
  6. package/dist/architecture-U656AL7Q-B4C0nw6C.js +5 -0
  7. package/dist/architecture-U656AL7Q-CVURQXwt.cjs +5 -0
  8. package/dist/architectureDiagram-VXUJARFQ-2UbdzpNz.cjs +8681 -0
  9. package/dist/architectureDiagram-VXUJARFQ-NCVmzKuE.js +8681 -0
  10. package/dist/blockDiagram-VD42YOAC-B3yCPK1N.cjs +3606 -0
  11. package/dist/blockDiagram-VD42YOAC-C4FsmQfk.js +3606 -0
  12. package/dist/c4Diagram-YG6GDRKO-ATyoKzFV.js +2481 -0
  13. package/dist/c4Diagram-YG6GDRKO-COwVcHWj.cjs +2481 -0
  14. package/dist/channel-2Y73gsu9.cjs +6 -0
  15. package/dist/channel-oB8MffQV.js +7 -0
  16. package/dist/chunk-4BX2VUAB-C3diNHZw.cjs +15 -0
  17. package/dist/chunk-4BX2VUAB-sd2zFBFz.js +16 -0
  18. package/dist/chunk-55IACEB6-6ohTnYE3.js +13 -0
  19. package/dist/chunk-55IACEB6-T-CzlJke.cjs +12 -0
  20. package/dist/chunk-B4BG7PRW-B1zqG62l.cjs +1825 -0
  21. package/dist/chunk-B4BG7PRW-E1dti26Y.js +1826 -0
  22. package/dist/chunk-DI55MBZ5-Dk0kfYBV.cjs +1914 -0
  23. package/dist/chunk-DI55MBZ5-DpHw-vMw.js +1915 -0
  24. package/dist/chunk-FMBD7UC4-B1vXpasq.js +19 -0
  25. package/dist/chunk-FMBD7UC4-CShN9-qf.cjs +18 -0
  26. package/dist/chunk-QN33PNHL-Cw7FG91D.js +24 -0
  27. package/dist/chunk-QN33PNHL-DJi1fhak.cjs +23 -0
  28. package/dist/chunk-QZHKN3VN-BweiBR9P.js +17 -0
  29. package/dist/chunk-QZHKN3VN-DfUW_gDw.cjs +16 -0
  30. package/dist/chunk-TZMSLE5B-DY2Kbag4.cjs +107 -0
  31. package/dist/chunk-TZMSLE5B-ZQ2Esoix.js +108 -0
  32. package/dist/classDiagram-2ON5EDUG-D2tIbkjc.js +19 -0
  33. package/dist/classDiagram-2ON5EDUG-DRhRmkUb.cjs +19 -0
  34. package/dist/classDiagram-v2-WZHVMYZB-D2tIbkjc.js +19 -0
  35. package/dist/classDiagram-v2-WZHVMYZB-DRhRmkUb.cjs +19 -0
  36. package/dist/clone-BMkj3yun.cjs +7 -0
  37. package/dist/clone-ChHXIoR6.js +8 -0
  38. package/dist/cose-bilkent-S5V4N54A-BXnWH5Od.cjs +4942 -0
  39. package/dist/cose-bilkent-S5V4N54A-D15BmpCb.js +4942 -0
  40. package/dist/cytoscape.esm-BfvZ3QT_.js +30239 -0
  41. package/dist/cytoscape.esm-D8IBYQeQ.cjs +30238 -0
  42. package/dist/dagre-6UL2VRFP-DGQ6TW_g.cjs +693 -0
  43. package/dist/dagre-6UL2VRFP-WmhUYWg8.js +693 -0
  44. package/dist/defaultLocale-DVr69WTU.js +206 -0
  45. package/dist/defaultLocale-DwYGIg9G.cjs +203 -0
  46. package/dist/diagram-PSM6KHXK-DSfHBoUT.js +845 -0
  47. package/dist/diagram-PSM6KHXK-J4qyGeN7.cjs +845 -0
  48. package/dist/diagram-QEK2KX5R-D96wT5cH.cjs +300 -0
  49. package/dist/diagram-QEK2KX5R-I_nyexpY.js +300 -0
  50. package/dist/diagram-S2PKOQOG-BC_WyKEe.cjs +210 -0
  51. package/dist/diagram-S2PKOQOG-aooXSMNo.js +210 -0
  52. package/dist/erDiagram-Q2GNP2WA-DQ8Lquay.cjs +1158 -0
  53. package/dist/erDiagram-Q2GNP2WA-DWF8e6EL.js +1158 -0
  54. package/dist/flowDiagram-NV44I4VS-CM9c4F1o.js +2331 -0
  55. package/dist/flowDiagram-NV44I4VS-DpYNkyM2.cjs +2331 -0
  56. package/dist/ganttDiagram-JELNMOA3-CAsoD6rZ.js +3679 -0
  57. package/dist/ganttDiagram-JELNMOA3-DfKahpj4.cjs +3679 -0
  58. package/dist/gitGraph-F6HP7TQM-BX2fz4_i.js +5 -0
  59. package/dist/gitGraph-F6HP7TQM-DRkGg4T1.cjs +5 -0
  60. package/dist/gitGraphDiagram-NY62KEGX-PXpI94u6.js +1203 -0
  61. package/dist/gitGraphDiagram-NY62KEGX-YhnKpooH.cjs +1203 -0
  62. package/dist/graph-BvxpI7Xc.js +596 -0
  63. package/dist/graph-CI_TWBSn.cjs +595 -0
  64. package/dist/index-BctLGjTK.cjs +120500 -0
  65. package/dist/index-CjSgoo1P.js +120485 -0
  66. package/dist/index.cjs +19 -0
  67. package/dist/index.js +12 -19961
  68. package/dist/info-NVLQJR56-BGbTE7dw.cjs +5 -0
  69. package/dist/info-NVLQJR56-DRxIh-N8.js +5 -0
  70. package/dist/infoDiagram-WHAUD3N6-BB2Bnbnh.cjs +31 -0
  71. package/dist/infoDiagram-WHAUD3N6-D_RrgwxS.js +31 -0
  72. package/dist/init-DevvdK2U.cjs +15 -0
  73. package/dist/init-ZxktEp_H.js +16 -0
  74. package/dist/journeyDiagram-XKPGCS4Q-BJjXlMIj.js +1254 -0
  75. package/dist/journeyDiagram-XKPGCS4Q-BcBLsfI9.cjs +1254 -0
  76. package/dist/kanban-definition-3W4ZIXB7-0wwNBZ93.js +1047 -0
  77. package/dist/kanban-definition-3W4ZIXB7-CaY0q4j9.cjs +1047 -0
  78. package/dist/katex-BhpYeT3b.cjs +14523 -0
  79. package/dist/katex-ei8sH3Uy.js +14524 -0
  80. package/dist/layout-CcghncRv.js +2183 -0
  81. package/dist/layout-CvwzED_C.cjs +2182 -0
  82. package/dist/linear-CYow-mAK.cjs +339 -0
  83. package/dist/linear-D_gKQzVp.js +340 -0
  84. package/dist/mermaid-parser.core-CzmkR-3i.cjs +18703 -0
  85. package/dist/mermaid-parser.core-DCMDT-Cp.js +18704 -0
  86. package/dist/min-BBp7Smma.js +41 -0
  87. package/dist/min-Gu1I_bJ9.cjs +40 -0
  88. package/dist/mindmap-definition-VGOIOE7T-D16Pp1u5.cjs +1126 -0
  89. package/dist/mindmap-definition-VGOIOE7T-PjSLRtz4.js +1126 -0
  90. package/dist/ordinal-CxptdPJm.js +76 -0
  91. package/dist/ordinal-D7sQNqXZ.cjs +75 -0
  92. package/dist/packet-BFZMPI3H-BvdogPiS.js +5 -0
  93. package/dist/packet-BFZMPI3H-C7pOHUWY.cjs +5 -0
  94. package/dist/pie-7BOR55EZ-D-DxSHbP.cjs +5 -0
  95. package/dist/pie-7BOR55EZ-DEWJe4Xn.js +5 -0
  96. package/dist/pieDiagram-ADFJNKIX-CoDddKZl.js +237 -0
  97. package/dist/pieDiagram-ADFJNKIX-DjN4DU9l.cjs +237 -0
  98. package/dist/quadrantDiagram-AYHSOK5B-BZOg0JMm.js +1335 -0
  99. package/dist/quadrantDiagram-AYHSOK5B-DXjTSOL4.cjs +1335 -0
  100. package/dist/radar-NHE76QYJ-BrnDXy9q.cjs +5 -0
  101. package/dist/radar-NHE76QYJ-C2WmPmJ4.js +5 -0
  102. package/dist/requirementDiagram-UZGBJVZJ-CCW1O1xH.js +1161 -0
  103. package/dist/requirementDiagram-UZGBJVZJ-e5F3-dDI.cjs +1161 -0
  104. package/dist/sankeyDiagram-TZEHDZUN-BaGzCxTp.js +1193 -0
  105. package/dist/sankeyDiagram-TZEHDZUN-DtIvOvVI.cjs +1193 -0
  106. package/dist/sequenceDiagram-WL72ISMW-0vFhYnxn.cjs +3874 -0
  107. package/dist/sequenceDiagram-WL72ISMW-DL3B7U56.js +3874 -0
  108. package/dist/stateDiagram-FKZM4ZOC-CXW608BR.cjs +447 -0
  109. package/dist/stateDiagram-FKZM4ZOC-Ddw6HxPD.js +447 -0
  110. package/dist/stateDiagram-v2-4FDKWEC3-DZCkQKmp.js +19 -0
  111. package/dist/stateDiagram-v2-4FDKWEC3-DefWUbvq.cjs +19 -0
  112. package/dist/timeline-definition-IT6M3QCI-C3TfA9lE.cjs +1222 -0
  113. package/dist/timeline-definition-IT6M3QCI-DiS88lUo.js +1222 -0
  114. package/dist/treemap-KMMF4GRG-Bl-H6j2c.cjs +5 -0
  115. package/dist/treemap-KMMF4GRG-DGGr_R9A.js +5 -0
  116. package/dist/xychartDiagram-PRI3JC2R-BrOwRjfF.js +1886 -0
  117. package/dist/xychartDiagram-PRI3JC2R-CM06DttH.cjs +1886 -0
  118. package/package.json +22 -11
  119. package/dist/index.css +0 -1582
@@ -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 = /* @__PURE__ */ 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,75 @@
1
+ "use strict";
2
+ const init = require("./init-DevvdK2U.cjs");
3
+ class InternMap extends Map {
4
+ constructor(entries, key = keyof) {
5
+ super();
6
+ Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
7
+ if (entries != null) for (const [key2, value] of entries) this.set(key2, value);
8
+ }
9
+ get(key) {
10
+ return super.get(intern_get(this, key));
11
+ }
12
+ has(key) {
13
+ return super.has(intern_get(this, key));
14
+ }
15
+ set(key, value) {
16
+ return super.set(intern_set(this, key), value);
17
+ }
18
+ delete(key) {
19
+ return super.delete(intern_delete(this, key));
20
+ }
21
+ }
22
+ function intern_get({ _intern, _key }, value) {
23
+ const key = _key(value);
24
+ return _intern.has(key) ? _intern.get(key) : value;
25
+ }
26
+ function intern_set({ _intern, _key }, value) {
27
+ const key = _key(value);
28
+ if (_intern.has(key)) return _intern.get(key);
29
+ _intern.set(key, value);
30
+ return value;
31
+ }
32
+ function intern_delete({ _intern, _key }, value) {
33
+ const key = _key(value);
34
+ if (_intern.has(key)) {
35
+ value = _intern.get(key);
36
+ _intern.delete(key);
37
+ }
38
+ return value;
39
+ }
40
+ function keyof(value) {
41
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
42
+ }
43
+ const implicit = /* @__PURE__ */ Symbol("implicit");
44
+ function ordinal() {
45
+ var index = new InternMap(), domain = [], range = [], unknown = implicit;
46
+ function scale(d) {
47
+ let i = index.get(d);
48
+ if (i === void 0) {
49
+ if (unknown !== implicit) return unknown;
50
+ index.set(d, i = domain.push(d) - 1);
51
+ }
52
+ return range[i % range.length];
53
+ }
54
+ scale.domain = function(_) {
55
+ if (!arguments.length) return domain.slice();
56
+ domain = [], index = new InternMap();
57
+ for (const value of _) {
58
+ if (index.has(value)) continue;
59
+ index.set(value, domain.push(value) - 1);
60
+ }
61
+ return scale;
62
+ };
63
+ scale.range = function(_) {
64
+ return arguments.length ? (range = Array.from(_), scale) : range.slice();
65
+ };
66
+ scale.unknown = function(_) {
67
+ return arguments.length ? (unknown = _, scale) : unknown;
68
+ };
69
+ scale.copy = function() {
70
+ return ordinal(domain, range).unknown(unknown);
71
+ };
72
+ init.initRange.apply(scale, arguments);
73
+ return scale;
74
+ }
75
+ exports.ordinal = ordinal;
@@ -0,0 +1,5 @@
1
+ import { P, a } from "./mermaid-parser.core-DCMDT-Cp.js";
2
+ export {
3
+ P as PacketModule,
4
+ a as createPacketServices
5
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const mermaidParser_core = require("./mermaid-parser.core-CzmkR-3i.cjs");
4
+ exports.PacketModule = mermaidParser_core.PacketModule;
5
+ exports.createPacketServices = mermaidParser_core.createPacketServices;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const mermaidParser_core = require("./mermaid-parser.core-CzmkR-3i.cjs");
4
+ exports.PieModule = mermaidParser_core.PieModule;
5
+ exports.createPieServices = mermaidParser_core.createPieServices;
@@ -0,0 +1,5 @@
1
+ import { b, d } from "./mermaid-parser.core-DCMDT-Cp.js";
2
+ export {
3
+ b as PieModule,
4
+ d as createPieServices
5
+ };
@@ -0,0 +1,237 @@
1
+ import { a4 as constant, a7 as tau, aB as array, _ as __name, g as getAccDescription, s as setAccDescription, a as getAccTitle, b as setAccTitle, q as getDiagramTitle, p as setDiagramTitle, l as log, c as getConfig2$1, D as cleanAndMerge, H as selectSvgElement, N as parseFontSize, e as configureSvgSize, y as clear, F as defaultConfig_default } from "./index-CjSgoo1P.js";
2
+ import { p as populateCommonDb } from "./chunk-4BX2VUAB-sd2zFBFz.js";
3
+ import { p as parse } from "./mermaid-parser.core-DCMDT-Cp.js";
4
+ import { d as d3arc } from "./arc-DODeX7B9.js";
5
+ import { o as ordinal } from "./ordinal-CxptdPJm.js";
6
+ function descending(a, b) {
7
+ return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
8
+ }
9
+ function identity(d) {
10
+ return d;
11
+ }
12
+ function d3pie() {
13
+ var value = identity, sortValues = descending, sort = null, startAngle = constant(0), endAngle = constant(tau), padAngle = constant(0);
14
+ function pie(data) {
15
+ 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;
16
+ for (i = 0; i < n; ++i) {
17
+ if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
18
+ sum += v;
19
+ }
20
+ }
21
+ if (sortValues != null) index.sort(function(i2, j2) {
22
+ return sortValues(arcs[i2], arcs[j2]);
23
+ });
24
+ else if (sort != null) index.sort(function(i2, j2) {
25
+ return sort(data[i2], data[j2]);
26
+ });
27
+ for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {
28
+ j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
29
+ data: data[j],
30
+ index: i,
31
+ value: v,
32
+ startAngle: a0,
33
+ endAngle: a1,
34
+ padAngle: p
35
+ };
36
+ }
37
+ return arcs;
38
+ }
39
+ pie.value = function(_) {
40
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie) : value;
41
+ };
42
+ pie.sortValues = function(_) {
43
+ return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
44
+ };
45
+ pie.sort = function(_) {
46
+ return arguments.length ? (sort = _, sortValues = null, pie) : sort;
47
+ };
48
+ pie.startAngle = function(_) {
49
+ return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie) : startAngle;
50
+ };
51
+ pie.endAngle = function(_) {
52
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle;
53
+ };
54
+ pie.padAngle = function(_) {
55
+ return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle;
56
+ };
57
+ return pie;
58
+ }
59
+ var DEFAULT_PIE_CONFIG = defaultConfig_default.pie;
60
+ var DEFAULT_PIE_DB = {
61
+ sections: /* @__PURE__ */ new Map(),
62
+ showData: false
63
+ };
64
+ var sections = DEFAULT_PIE_DB.sections;
65
+ var showData = DEFAULT_PIE_DB.showData;
66
+ var config = structuredClone(DEFAULT_PIE_CONFIG);
67
+ var getConfig2 = /* @__PURE__ */ __name(() => structuredClone(config), "getConfig");
68
+ var clear2 = /* @__PURE__ */ __name(() => {
69
+ sections = /* @__PURE__ */ new Map();
70
+ showData = DEFAULT_PIE_DB.showData;
71
+ clear();
72
+ }, "clear");
73
+ var addSection = /* @__PURE__ */ __name(({ label, value }) => {
74
+ if (value < 0) {
75
+ throw new Error(
76
+ `"${label}" has invalid value: ${value}. Negative values are not allowed in pie charts. All slice values must be >= 0.`
77
+ );
78
+ }
79
+ if (!sections.has(label)) {
80
+ sections.set(label, value);
81
+ log.debug(`added new section: ${label}, with value: ${value}`);
82
+ }
83
+ }, "addSection");
84
+ var getSections = /* @__PURE__ */ __name(() => sections, "getSections");
85
+ var setShowData = /* @__PURE__ */ __name((toggle) => {
86
+ showData = toggle;
87
+ }, "setShowData");
88
+ var getShowData = /* @__PURE__ */ __name(() => showData, "getShowData");
89
+ var db = {
90
+ getConfig: getConfig2,
91
+ clear: clear2,
92
+ setDiagramTitle,
93
+ getDiagramTitle,
94
+ setAccTitle,
95
+ getAccTitle,
96
+ setAccDescription,
97
+ getAccDescription,
98
+ addSection,
99
+ getSections,
100
+ setShowData,
101
+ getShowData
102
+ };
103
+ var populateDb = /* @__PURE__ */ __name((ast, db2) => {
104
+ populateCommonDb(ast, db2);
105
+ db2.setShowData(ast.showData);
106
+ ast.sections.map(db2.addSection);
107
+ }, "populateDb");
108
+ var parser = {
109
+ parse: /* @__PURE__ */ __name(async (input) => {
110
+ const ast = await parse("pie", input);
111
+ log.debug(ast);
112
+ populateDb(ast, db);
113
+ }, "parse")
114
+ };
115
+ var getStyles = /* @__PURE__ */ __name((options) => `
116
+ .pieCircle{
117
+ stroke: ${options.pieStrokeColor};
118
+ stroke-width : ${options.pieStrokeWidth};
119
+ opacity : ${options.pieOpacity};
120
+ }
121
+ .pieOuterCircle{
122
+ stroke: ${options.pieOuterStrokeColor};
123
+ stroke-width: ${options.pieOuterStrokeWidth};
124
+ fill: none;
125
+ }
126
+ .pieTitleText {
127
+ text-anchor: middle;
128
+ font-size: ${options.pieTitleTextSize};
129
+ fill: ${options.pieTitleTextColor};
130
+ font-family: ${options.fontFamily};
131
+ }
132
+ .slice {
133
+ font-family: ${options.fontFamily};
134
+ fill: ${options.pieSectionTextColor};
135
+ font-size:${options.pieSectionTextSize};
136
+ // fill: white;
137
+ }
138
+ .legend text {
139
+ fill: ${options.pieLegendTextColor};
140
+ font-family: ${options.fontFamily};
141
+ font-size: ${options.pieLegendTextSize};
142
+ }
143
+ `, "getStyles");
144
+ var pieStyles_default = getStyles;
145
+ var createPieArcs = /* @__PURE__ */ __name((sections2) => {
146
+ const sum = [...sections2.values()].reduce((acc, val) => acc + val, 0);
147
+ const pieData = [...sections2.entries()].map(([label, value]) => ({ label, value })).filter((d) => d.value / sum * 100 >= 1).sort((a, b) => b.value - a.value);
148
+ const pie = d3pie().value((d) => d.value);
149
+ return pie(pieData);
150
+ }, "createPieArcs");
151
+ var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
152
+ log.debug("rendering pie chart\n" + text);
153
+ const db2 = diagObj.db;
154
+ const globalConfig = getConfig2$1();
155
+ const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie);
156
+ const MARGIN = 40;
157
+ const LEGEND_RECT_SIZE = 18;
158
+ const LEGEND_SPACING = 4;
159
+ const height = 450;
160
+ const pieWidth = height;
161
+ const svg = selectSvgElement(id);
162
+ const group = svg.append("g");
163
+ group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")");
164
+ const { themeVariables } = globalConfig;
165
+ let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
166
+ outerStrokeWidth ??= 2;
167
+ const textPosition = pieConfig.textPosition;
168
+ const radius = Math.min(pieWidth, height) / 2 - MARGIN;
169
+ const arcGenerator = d3arc().innerRadius(0).outerRadius(radius);
170
+ const labelArcGenerator = d3arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
171
+ group.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
172
+ const sections2 = db2.getSections();
173
+ const arcs = createPieArcs(sections2);
174
+ const myGeneratedColors = [
175
+ themeVariables.pie1,
176
+ themeVariables.pie2,
177
+ themeVariables.pie3,
178
+ themeVariables.pie4,
179
+ themeVariables.pie5,
180
+ themeVariables.pie6,
181
+ themeVariables.pie7,
182
+ themeVariables.pie8,
183
+ themeVariables.pie9,
184
+ themeVariables.pie10,
185
+ themeVariables.pie11,
186
+ themeVariables.pie12
187
+ ];
188
+ let sum = 0;
189
+ sections2.forEach((section) => {
190
+ sum += section;
191
+ });
192
+ const filteredArcs = arcs.filter((datum) => (datum.data.value / sum * 100).toFixed(0) !== "0");
193
+ const color = ordinal(myGeneratedColors);
194
+ group.selectAll("mySlices").data(filteredArcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => {
195
+ return color(datum.data.label);
196
+ }).attr("class", "pieCircle");
197
+ group.selectAll("mySlices").data(filteredArcs).enter().append("text").text((datum) => {
198
+ return (datum.data.value / sum * 100).toFixed(0) + "%";
199
+ }).attr("transform", (datum) => {
200
+ return "translate(" + labelArcGenerator.centroid(datum) + ")";
201
+ }).style("text-anchor", "middle").attr("class", "slice");
202
+ group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -400 / 2).attr("class", "pieTitleText");
203
+ const allSectionData = [...sections2.entries()].map(([label, value]) => ({
204
+ label,
205
+ value
206
+ }));
207
+ const legend = group.selectAll(".legend").data(allSectionData).enter().append("g").attr("class", "legend").attr("transform", (_datum, index) => {
208
+ const height2 = LEGEND_RECT_SIZE + LEGEND_SPACING;
209
+ const offset = height2 * allSectionData.length / 2;
210
+ const horizontal = 12 * LEGEND_RECT_SIZE;
211
+ const vertical = index * height2 - offset;
212
+ return "translate(" + horizontal + "," + vertical + ")";
213
+ });
214
+ 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));
215
+ legend.append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((d) => {
216
+ if (db2.getShowData()) {
217
+ return `${d.label} [${d.value}]`;
218
+ }
219
+ return d.label;
220
+ });
221
+ const longestTextWidth = Math.max(
222
+ ...legend.selectAll("text").nodes().map((node) => node?.getBoundingClientRect().width ?? 0)
223
+ );
224
+ const totalWidth = pieWidth + MARGIN + LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth;
225
+ svg.attr("viewBox", `0 0 ${totalWidth} ${height}`);
226
+ configureSvgSize(svg, height, totalWidth, pieConfig.useMaxWidth);
227
+ }, "draw");
228
+ var renderer = { draw };
229
+ var diagram = {
230
+ parser,
231
+ db,
232
+ renderer,
233
+ styles: pieStyles_default
234
+ };
235
+ export {
236
+ diagram
237
+ };
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const index = require("./index-BctLGjTK.cjs");
4
+ const chunk4BX2VUAB = require("./chunk-4BX2VUAB-C3diNHZw.cjs");
5
+ const mermaidParser_core = require("./mermaid-parser.core-CzmkR-3i.cjs");
6
+ const arc = require("./arc-BWSMkwk2.cjs");
7
+ const ordinal = require("./ordinal-D7sQNqXZ.cjs");
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 = index.constant(0), endAngle = index.constant(index.tau), padAngle = index.constant(0);
16
+ function pie(data) {
17
+ var i, n = (data = index.array(data)).length, j, k, sum = 0, index$1 = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(index.tau, Math.max(-index.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$1[i] = i] = +value(data[i], i, data)) > 0) {
20
+ sum += v;
21
+ }
22
+ }
23
+ if (sortValues != null) index$1.sort(function(i2, j2) {
24
+ return sortValues(arcs[i2], arcs[j2]);
25
+ });
26
+ else if (sort != null) index$1.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$1[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" ? _ : index.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" ? _ : index.constant(+_), pie) : startAngle;
52
+ };
53
+ pie.endAngle = function(_) {
54
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : index.constant(+_), pie) : endAngle;
55
+ };
56
+ pie.padAngle = function(_) {
57
+ return arguments.length ? (padAngle = typeof _ === "function" ? _ : index.constant(+_), pie) : padAngle;
58
+ };
59
+ return pie;
60
+ }
61
+ var DEFAULT_PIE_CONFIG = index.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__ */ index.__name(() => structuredClone(config), "getConfig");
70
+ var clear2 = /* @__PURE__ */ index.__name(() => {
71
+ sections = /* @__PURE__ */ new Map();
72
+ showData = DEFAULT_PIE_DB.showData;
73
+ index.clear();
74
+ }, "clear");
75
+ var addSection = /* @__PURE__ */ index.__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
+ index.log.debug(`added new section: ${label}, with value: ${value}`);
84
+ }
85
+ }, "addSection");
86
+ var getSections = /* @__PURE__ */ index.__name(() => sections, "getSections");
87
+ var setShowData = /* @__PURE__ */ index.__name((toggle) => {
88
+ showData = toggle;
89
+ }, "setShowData");
90
+ var getShowData = /* @__PURE__ */ index.__name(() => showData, "getShowData");
91
+ var db = {
92
+ getConfig: getConfig2,
93
+ clear: clear2,
94
+ setDiagramTitle: index.setDiagramTitle,
95
+ getDiagramTitle: index.getDiagramTitle,
96
+ setAccTitle: index.setAccTitle,
97
+ getAccTitle: index.getAccTitle,
98
+ setAccDescription: index.setAccDescription,
99
+ getAccDescription: index.getAccDescription,
100
+ addSection,
101
+ getSections,
102
+ setShowData,
103
+ getShowData
104
+ };
105
+ var populateDb = /* @__PURE__ */ index.__name((ast, db2) => {
106
+ chunk4BX2VUAB.populateCommonDb(ast, db2);
107
+ db2.setShowData(ast.showData);
108
+ ast.sections.map(db2.addSection);
109
+ }, "populateDb");
110
+ var parser = {
111
+ parse: /* @__PURE__ */ index.__name(async (input) => {
112
+ const ast = await mermaidParser_core.parse("pie", input);
113
+ index.log.debug(ast);
114
+ populateDb(ast, db);
115
+ }, "parse")
116
+ };
117
+ var getStyles = /* @__PURE__ */ index.__name((options) => `
118
+ .pieCircle{
119
+ stroke: ${options.pieStrokeColor};
120
+ stroke-width : ${options.pieStrokeWidth};
121
+ opacity : ${options.pieOpacity};
122
+ }
123
+ .pieOuterCircle{
124
+ stroke: ${options.pieOuterStrokeColor};
125
+ stroke-width: ${options.pieOuterStrokeWidth};
126
+ fill: none;
127
+ }
128
+ .pieTitleText {
129
+ text-anchor: middle;
130
+ font-size: ${options.pieTitleTextSize};
131
+ fill: ${options.pieTitleTextColor};
132
+ font-family: ${options.fontFamily};
133
+ }
134
+ .slice {
135
+ font-family: ${options.fontFamily};
136
+ fill: ${options.pieSectionTextColor};
137
+ font-size:${options.pieSectionTextSize};
138
+ // fill: white;
139
+ }
140
+ .legend text {
141
+ fill: ${options.pieLegendTextColor};
142
+ font-family: ${options.fontFamily};
143
+ font-size: ${options.pieLegendTextSize};
144
+ }
145
+ `, "getStyles");
146
+ var pieStyles_default = getStyles;
147
+ var createPieArcs = /* @__PURE__ */ index.__name((sections2) => {
148
+ const sum = [...sections2.values()].reduce((acc, val) => acc + val, 0);
149
+ const pieData = [...sections2.entries()].map(([label, value]) => ({ label, value })).filter((d) => d.value / sum * 100 >= 1).sort((a, b) => b.value - a.value);
150
+ const pie = d3pie().value((d) => d.value);
151
+ return pie(pieData);
152
+ }, "createPieArcs");
153
+ var draw = /* @__PURE__ */ index.__name((text, id, _version, diagObj) => {
154
+ index.log.debug("rendering pie chart\n" + text);
155
+ const db2 = diagObj.db;
156
+ const globalConfig = index.getConfig2();
157
+ const pieConfig = index.cleanAndMerge(db2.getConfig(), globalConfig.pie);
158
+ const MARGIN = 40;
159
+ const LEGEND_RECT_SIZE = 18;
160
+ const LEGEND_SPACING = 4;
161
+ const height = 450;
162
+ const pieWidth = height;
163
+ const svg = index.selectSvgElement(id);
164
+ const group = svg.append("g");
165
+ group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")");
166
+ const { themeVariables } = globalConfig;
167
+ let [outerStrokeWidth] = index.parseFontSize(themeVariables.pieOuterStrokeWidth);
168
+ outerStrokeWidth ??= 2;
169
+ const textPosition = pieConfig.textPosition;
170
+ const radius = Math.min(pieWidth, height) / 2 - MARGIN;
171
+ const arcGenerator = arc.d3arc().innerRadius(0).outerRadius(radius);
172
+ const labelArcGenerator = arc.d3arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
173
+ group.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
174
+ const sections2 = db2.getSections();
175
+ const arcs = createPieArcs(sections2);
176
+ const myGeneratedColors = [
177
+ themeVariables.pie1,
178
+ themeVariables.pie2,
179
+ themeVariables.pie3,
180
+ themeVariables.pie4,
181
+ themeVariables.pie5,
182
+ themeVariables.pie6,
183
+ themeVariables.pie7,
184
+ themeVariables.pie8,
185
+ themeVariables.pie9,
186
+ themeVariables.pie10,
187
+ themeVariables.pie11,
188
+ themeVariables.pie12
189
+ ];
190
+ let sum = 0;
191
+ sections2.forEach((section) => {
192
+ sum += section;
193
+ });
194
+ const filteredArcs = arcs.filter((datum) => (datum.data.value / sum * 100).toFixed(0) !== "0");
195
+ const color = ordinal.ordinal(myGeneratedColors);
196
+ group.selectAll("mySlices").data(filteredArcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => {
197
+ return color(datum.data.label);
198
+ }).attr("class", "pieCircle");
199
+ group.selectAll("mySlices").data(filteredArcs).enter().append("text").text((datum) => {
200
+ return (datum.data.value / sum * 100).toFixed(0) + "%";
201
+ }).attr("transform", (datum) => {
202
+ return "translate(" + labelArcGenerator.centroid(datum) + ")";
203
+ }).style("text-anchor", "middle").attr("class", "slice");
204
+ group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -400 / 2).attr("class", "pieTitleText");
205
+ const allSectionData = [...sections2.entries()].map(([label, value]) => ({
206
+ label,
207
+ value
208
+ }));
209
+ const legend = group.selectAll(".legend").data(allSectionData).enter().append("g").attr("class", "legend").attr("transform", (_datum, index2) => {
210
+ const height2 = LEGEND_RECT_SIZE + LEGEND_SPACING;
211
+ const offset = height2 * allSectionData.length / 2;
212
+ const horizontal = 12 * LEGEND_RECT_SIZE;
213
+ const vertical = index2 * height2 - offset;
214
+ return "translate(" + horizontal + "," + vertical + ")";
215
+ });
216
+ 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));
217
+ legend.append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((d) => {
218
+ if (db2.getShowData()) {
219
+ return `${d.label} [${d.value}]`;
220
+ }
221
+ return d.label;
222
+ });
223
+ const longestTextWidth = Math.max(
224
+ ...legend.selectAll("text").nodes().map((node) => node?.getBoundingClientRect().width ?? 0)
225
+ );
226
+ const totalWidth = pieWidth + MARGIN + LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth;
227
+ svg.attr("viewBox", `0 0 ${totalWidth} ${height}`);
228
+ index.configureSvgSize(svg, height, totalWidth, pieConfig.useMaxWidth);
229
+ }, "draw");
230
+ var renderer = { draw };
231
+ var diagram = {
232
+ parser,
233
+ db,
234
+ renderer,
235
+ styles: pieStyles_default
236
+ };
237
+ exports.diagram = diagram;