@infinilabs/ai-chat 0.0.1 → 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 (116) hide show
  1. package/README.md +10 -1
  2. package/dist/{_baseUniq-BQcAhV7E.js → _baseUniq-BFn6cCm9.js} +1 -1
  3. package/dist/_baseUniq-nfJyj2zU.cjs +151 -0
  4. package/dist/arc-BWSMkwk2.cjs +130 -0
  5. package/dist/{arc-2jwvQ2TN.js → arc-DODeX7B9.js} +1 -1
  6. package/dist/{architecture-U656AL7Q-WuSilpZW.js → architecture-U656AL7Q-B4C0nw6C.js} +1 -1
  7. package/dist/architecture-U656AL7Q-CVURQXwt.cjs +5 -0
  8. package/dist/architectureDiagram-VXUJARFQ-2UbdzpNz.cjs +8681 -0
  9. package/dist/{architectureDiagram-VXUJARFQ-D6SKNy5z.js → architectureDiagram-VXUJARFQ-NCVmzKuE.js} +3 -3
  10. package/dist/blockDiagram-VD42YOAC-B3yCPK1N.cjs +3606 -0
  11. package/dist/{blockDiagram-VD42YOAC-Ct2DD8jj.js → blockDiagram-VD42YOAC-C4FsmQfk.js} +5 -5
  12. package/dist/{c4Diagram-YG6GDRKO-B7wBU4mz.js → c4Diagram-YG6GDRKO-ATyoKzFV.js} +2 -2
  13. package/dist/c4Diagram-YG6GDRKO-COwVcHWj.cjs +2481 -0
  14. package/dist/channel-2Y73gsu9.cjs +6 -0
  15. package/dist/{channel-BRREX19f.js → channel-oB8MffQV.js} +1 -1
  16. package/dist/chunk-4BX2VUAB-C3diNHZw.cjs +15 -0
  17. package/dist/{chunk-4BX2VUAB-BnghU1_v.js → chunk-4BX2VUAB-sd2zFBFz.js} +1 -1
  18. package/dist/{chunk-55IACEB6-Dduk-DEL.js → chunk-55IACEB6-6ohTnYE3.js} +1 -1
  19. package/dist/chunk-55IACEB6-T-CzlJke.cjs +12 -0
  20. package/dist/chunk-B4BG7PRW-B1zqG62l.cjs +1825 -0
  21. package/dist/{chunk-B4BG7PRW-DeHw-z-x.js → chunk-B4BG7PRW-E1dti26Y.js} +4 -4
  22. package/dist/chunk-DI55MBZ5-Dk0kfYBV.cjs +1914 -0
  23. package/dist/{chunk-DI55MBZ5-GTHMAr0M.js → chunk-DI55MBZ5-DpHw-vMw.js} +3 -3
  24. package/dist/{chunk-FMBD7UC4-Bchh4_3W.js → chunk-FMBD7UC4-B1vXpasq.js} +1 -1
  25. package/dist/chunk-FMBD7UC4-CShN9-qf.cjs +18 -0
  26. package/dist/{chunk-QN33PNHL-H6S-NYp0.js → chunk-QN33PNHL-Cw7FG91D.js} +1 -1
  27. package/dist/chunk-QN33PNHL-DJi1fhak.cjs +23 -0
  28. package/dist/{chunk-QZHKN3VN-DdcyNnvM.js → chunk-QZHKN3VN-BweiBR9P.js} +1 -1
  29. package/dist/chunk-QZHKN3VN-DfUW_gDw.cjs +16 -0
  30. package/dist/chunk-TZMSLE5B-DY2Kbag4.cjs +107 -0
  31. package/dist/{chunk-TZMSLE5B-C7te_j4V.js → chunk-TZMSLE5B-ZQ2Esoix.js} +1 -1
  32. package/dist/{classDiagram-2ON5EDUG-CNkHY_Y7.js → classDiagram-2ON5EDUG-D2tIbkjc.js} +2 -2
  33. package/dist/classDiagram-2ON5EDUG-DRhRmkUb.cjs +19 -0
  34. package/dist/{classDiagram-v2-WZHVMYZB-CNkHY_Y7.js → classDiagram-v2-WZHVMYZB-D2tIbkjc.js} +2 -2
  35. package/dist/classDiagram-v2-WZHVMYZB-DRhRmkUb.cjs +19 -0
  36. package/dist/clone-BMkj3yun.cjs +7 -0
  37. package/dist/{clone-DnOD7gQ4.js → clone-ChHXIoR6.js} +1 -1
  38. package/dist/cose-bilkent-S5V4N54A-BXnWH5Od.cjs +4942 -0
  39. package/dist/{cose-bilkent-S5V4N54A-2EKtTYth.js → cose-bilkent-S5V4N54A-D15BmpCb.js} +1 -1
  40. package/dist/cytoscape.esm-D8IBYQeQ.cjs +30238 -0
  41. package/dist/dagre-6UL2VRFP-DGQ6TW_g.cjs +693 -0
  42. package/dist/{dagre-6UL2VRFP-oJLNDO4O.js → dagre-6UL2VRFP-WmhUYWg8.js} +5 -5
  43. package/dist/defaultLocale-DwYGIg9G.cjs +203 -0
  44. package/dist/{diagram-PSM6KHXK-DhMgmu9h.js → diagram-PSM6KHXK-DSfHBoUT.js} +4 -4
  45. package/dist/diagram-PSM6KHXK-J4qyGeN7.cjs +845 -0
  46. package/dist/diagram-QEK2KX5R-D96wT5cH.cjs +300 -0
  47. package/dist/{diagram-QEK2KX5R-pB1vUeno.js → diagram-QEK2KX5R-I_nyexpY.js} +3 -3
  48. package/dist/diagram-S2PKOQOG-BC_WyKEe.cjs +210 -0
  49. package/dist/{diagram-S2PKOQOG-HTooIr24.js → diagram-S2PKOQOG-aooXSMNo.js} +3 -3
  50. package/dist/erDiagram-Q2GNP2WA-DQ8Lquay.cjs +1158 -0
  51. package/dist/{erDiagram-Q2GNP2WA-CCaN2EHf.js → erDiagram-Q2GNP2WA-DWF8e6EL.js} +4 -4
  52. package/dist/{flowDiagram-NV44I4VS-CG0erQtl.js → flowDiagram-NV44I4VS-CM9c4F1o.js} +5 -5
  53. package/dist/flowDiagram-NV44I4VS-DpYNkyM2.cjs +2331 -0
  54. package/dist/{ganttDiagram-JELNMOA3-D3rSLJec.js → ganttDiagram-JELNMOA3-CAsoD6rZ.js} +2 -2
  55. package/dist/ganttDiagram-JELNMOA3-DfKahpj4.cjs +3679 -0
  56. package/dist/{gitGraph-F6HP7TQM-BDWdXs6A.js → gitGraph-F6HP7TQM-BX2fz4_i.js} +1 -1
  57. package/dist/gitGraph-F6HP7TQM-DRkGg4T1.cjs +5 -0
  58. package/dist/{gitGraphDiagram-NY62KEGX-Ip-PiLDb.js → gitGraphDiagram-NY62KEGX-PXpI94u6.js} +4 -4
  59. package/dist/gitGraphDiagram-NY62KEGX-YhnKpooH.cjs +1203 -0
  60. package/dist/{graph-wCViE1vL.js → graph-BvxpI7Xc.js} +2 -2
  61. package/dist/graph-CI_TWBSn.cjs +595 -0
  62. package/dist/index-BctLGjTK.cjs +120500 -0
  63. package/dist/{index-BQvQI7yA.js → index-CjSgoo1P.js} +103324 -100141
  64. package/dist/index.cjs +19 -0
  65. package/dist/index.js +13 -1
  66. package/dist/info-NVLQJR56-BGbTE7dw.cjs +5 -0
  67. package/dist/info-NVLQJR56-DRxIh-N8.js +5 -0
  68. package/dist/infoDiagram-WHAUD3N6-BB2Bnbnh.cjs +31 -0
  69. package/dist/{infoDiagram-WHAUD3N6-BbVs4x8y.js → infoDiagram-WHAUD3N6-D_RrgwxS.js} +2 -2
  70. package/dist/init-DevvdK2U.cjs +15 -0
  71. package/dist/{journeyDiagram-XKPGCS4Q-Cz9ox9GA.js → journeyDiagram-XKPGCS4Q-BJjXlMIj.js} +4 -4
  72. package/dist/journeyDiagram-XKPGCS4Q-BcBLsfI9.cjs +1254 -0
  73. package/dist/{kanban-definition-3W4ZIXB7-ChdUHO5f.js → kanban-definition-3W4ZIXB7-0wwNBZ93.js} +2 -2
  74. package/dist/kanban-definition-3W4ZIXB7-CaY0q4j9.cjs +1047 -0
  75. package/dist/katex-BhpYeT3b.cjs +14523 -0
  76. package/dist/{layout-BaZPdTGN.js → layout-CcghncRv.js} +4 -4
  77. package/dist/layout-CvwzED_C.cjs +2182 -0
  78. package/dist/linear-CYow-mAK.cjs +339 -0
  79. package/dist/{linear-D_RX7hM-.js → linear-D_gKQzVp.js} +1 -1
  80. package/dist/mermaid-parser.core-CzmkR-3i.cjs +18703 -0
  81. package/dist/{mermaid-parser.core-_sn6A3wB.js → mermaid-parser.core-DCMDT-Cp.js} +10 -10
  82. package/dist/{min-BxeM4Drj.js → min-BBp7Smma.js} +2 -2
  83. package/dist/min-Gu1I_bJ9.cjs +40 -0
  84. package/dist/mindmap-definition-VGOIOE7T-D16Pp1u5.cjs +1126 -0
  85. package/dist/{mindmap-definition-VGOIOE7T-BkjJibdi.js → mindmap-definition-VGOIOE7T-PjSLRtz4.js} +3 -3
  86. package/dist/ordinal-D7sQNqXZ.cjs +75 -0
  87. package/dist/{packet-BFZMPI3H-D3RtU0mc.js → packet-BFZMPI3H-BvdogPiS.js} +1 -1
  88. package/dist/packet-BFZMPI3H-C7pOHUWY.cjs +5 -0
  89. package/dist/pie-7BOR55EZ-D-DxSHbP.cjs +5 -0
  90. package/dist/pie-7BOR55EZ-DEWJe4Xn.js +5 -0
  91. package/dist/{pieDiagram-ADFJNKIX-2Yr1gkth.js → pieDiagram-ADFJNKIX-CoDddKZl.js} +4 -4
  92. package/dist/pieDiagram-ADFJNKIX-DjN4DU9l.cjs +237 -0
  93. package/dist/{quadrantDiagram-AYHSOK5B-CjicpXRv.js → quadrantDiagram-AYHSOK5B-BZOg0JMm.js} +2 -2
  94. package/dist/quadrantDiagram-AYHSOK5B-DXjTSOL4.cjs +1335 -0
  95. package/dist/radar-NHE76QYJ-BrnDXy9q.cjs +5 -0
  96. package/dist/{radar-NHE76QYJ-CL0tHnUP.js → radar-NHE76QYJ-C2WmPmJ4.js} +1 -1
  97. package/dist/{requirementDiagram-UZGBJVZJ-DBnhlfjR.js → requirementDiagram-UZGBJVZJ-CCW1O1xH.js} +3 -3
  98. package/dist/requirementDiagram-UZGBJVZJ-e5F3-dDI.cjs +1161 -0
  99. package/dist/{sankeyDiagram-TZEHDZUN-B2FErKCa.js → sankeyDiagram-TZEHDZUN-BaGzCxTp.js} +1 -1
  100. package/dist/sankeyDiagram-TZEHDZUN-DtIvOvVI.cjs +1193 -0
  101. package/dist/sequenceDiagram-WL72ISMW-0vFhYnxn.cjs +3874 -0
  102. package/dist/{sequenceDiagram-WL72ISMW-BkNTlRlB.js → sequenceDiagram-WL72ISMW-DL3B7U56.js} +3 -3
  103. package/dist/stateDiagram-FKZM4ZOC-CXW608BR.cjs +447 -0
  104. package/dist/{stateDiagram-FKZM4ZOC-CAAFQtS9.js → stateDiagram-FKZM4ZOC-Ddw6HxPD.js} +4 -4
  105. package/dist/{stateDiagram-v2-4FDKWEC3-lF6kUebI.js → stateDiagram-v2-4FDKWEC3-DZCkQKmp.js} +2 -2
  106. package/dist/stateDiagram-v2-4FDKWEC3-DefWUbvq.cjs +19 -0
  107. package/dist/timeline-definition-IT6M3QCI-C3TfA9lE.cjs +1222 -0
  108. package/dist/{timeline-definition-IT6M3QCI-CQgMFEPA.js → timeline-definition-IT6M3QCI-DiS88lUo.js} +2 -2
  109. package/dist/treemap-KMMF4GRG-Bl-H6j2c.cjs +5 -0
  110. package/dist/{treemap-KMMF4GRG-B0Mc-u8X.js → treemap-KMMF4GRG-DGGr_R9A.js} +1 -1
  111. package/dist/{xychartDiagram-PRI3JC2R-Cee7LdLr.js → xychartDiagram-PRI3JC2R-BrOwRjfF.js} +2 -2
  112. package/dist/xychartDiagram-PRI3JC2R-CM06DttH.cjs +1886 -0
  113. package/package.json +17 -5
  114. package/dist/index.css +0 -3334
  115. package/dist/info-NVLQJR56-pJlVBPs6.js +0 -5
  116. package/dist/pie-7BOR55EZ-xH--CiaM.js +0 -5
@@ -0,0 +1,1193 @@
1
+ "use strict";
2
+ var _a, _b, _c;
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const index = require("./index-BctLGjTK.cjs");
5
+ const ordinal = require("./ordinal-D7sQNqXZ.cjs");
6
+ function colors(specifier) {
7
+ var n = specifier.length / 6 | 0, colors2 = new Array(n), i = 0;
8
+ while (i < n) colors2[i] = "#" + specifier.slice(i * 6, ++i * 6);
9
+ return colors2;
10
+ }
11
+ const d3schemeTableau10 = colors("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");
12
+ function max(values, valueof) {
13
+ let max2;
14
+ if (valueof === void 0) {
15
+ for (const value2 of values) {
16
+ if (value2 != null && (max2 < value2 || max2 === void 0 && value2 >= value2)) {
17
+ max2 = value2;
18
+ }
19
+ }
20
+ } else {
21
+ let index2 = -1;
22
+ for (let value2 of values) {
23
+ if ((value2 = valueof(value2, ++index2, values)) != null && (max2 < value2 || max2 === void 0 && value2 >= value2)) {
24
+ max2 = value2;
25
+ }
26
+ }
27
+ }
28
+ return max2;
29
+ }
30
+ function min(values, valueof) {
31
+ let min2;
32
+ if (valueof === void 0) {
33
+ for (const value2 of values) {
34
+ if (value2 != null && (min2 > value2 || min2 === void 0 && value2 >= value2)) {
35
+ min2 = value2;
36
+ }
37
+ }
38
+ } else {
39
+ let index2 = -1;
40
+ for (let value2 of values) {
41
+ if ((value2 = valueof(value2, ++index2, values)) != null && (min2 > value2 || min2 === void 0 && value2 >= value2)) {
42
+ min2 = value2;
43
+ }
44
+ }
45
+ }
46
+ return min2;
47
+ }
48
+ function sum(values, valueof) {
49
+ let sum2 = 0;
50
+ if (valueof === void 0) {
51
+ for (let value2 of values) {
52
+ if (value2 = +value2) {
53
+ sum2 += value2;
54
+ }
55
+ }
56
+ } else {
57
+ let index2 = -1;
58
+ for (let value2 of values) {
59
+ if (value2 = +valueof(value2, ++index2, values)) {
60
+ sum2 += value2;
61
+ }
62
+ }
63
+ }
64
+ return sum2;
65
+ }
66
+ function targetDepth(d) {
67
+ return d.target.depth;
68
+ }
69
+ function left(node) {
70
+ return node.depth;
71
+ }
72
+ function right(node, n) {
73
+ return n - 1 - node.height;
74
+ }
75
+ function justify(node, n) {
76
+ return node.sourceLinks.length ? node.depth : n - 1;
77
+ }
78
+ function center(node) {
79
+ return node.targetLinks.length ? node.depth : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1 : 0;
80
+ }
81
+ function constant$1(x2) {
82
+ return function() {
83
+ return x2;
84
+ };
85
+ }
86
+ function ascendingSourceBreadth(a, b) {
87
+ return ascendingBreadth(a.source, b.source) || a.index - b.index;
88
+ }
89
+ function ascendingTargetBreadth(a, b) {
90
+ return ascendingBreadth(a.target, b.target) || a.index - b.index;
91
+ }
92
+ function ascendingBreadth(a, b) {
93
+ return a.y0 - b.y0;
94
+ }
95
+ function value(d) {
96
+ return d.value;
97
+ }
98
+ function defaultId(d) {
99
+ return d.index;
100
+ }
101
+ function defaultNodes(graph) {
102
+ return graph.nodes;
103
+ }
104
+ function defaultLinks(graph) {
105
+ return graph.links;
106
+ }
107
+ function find(nodeById, id) {
108
+ const node = nodeById.get(id);
109
+ if (!node) throw new Error("missing: " + id);
110
+ return node;
111
+ }
112
+ function computeLinkBreadths({ nodes: nodes2 }) {
113
+ for (const node of nodes2) {
114
+ let y0 = node.y0;
115
+ let y1 = y0;
116
+ for (const link2 of node.sourceLinks) {
117
+ link2.y0 = y0 + link2.width / 2;
118
+ y0 += link2.width;
119
+ }
120
+ for (const link2 of node.targetLinks) {
121
+ link2.y1 = y1 + link2.width / 2;
122
+ y1 += link2.width;
123
+ }
124
+ }
125
+ }
126
+ function Sankey() {
127
+ let x0 = 0, y0 = 0, x1 = 1, y1 = 1;
128
+ let dx = 24;
129
+ let dy = 8, py;
130
+ let id = defaultId;
131
+ let align = justify;
132
+ let sort;
133
+ let linkSort;
134
+ let nodes2 = defaultNodes;
135
+ let links2 = defaultLinks;
136
+ let iterations = 6;
137
+ function sankey() {
138
+ const graph = { nodes: nodes2.apply(null, arguments), links: links2.apply(null, arguments) };
139
+ computeNodeLinks(graph);
140
+ computeNodeValues(graph);
141
+ computeNodeDepths(graph);
142
+ computeNodeHeights(graph);
143
+ computeNodeBreadths(graph);
144
+ computeLinkBreadths(graph);
145
+ return graph;
146
+ }
147
+ sankey.update = function(graph) {
148
+ computeLinkBreadths(graph);
149
+ return graph;
150
+ };
151
+ sankey.nodeId = function(_) {
152
+ return arguments.length ? (id = typeof _ === "function" ? _ : constant$1(_), sankey) : id;
153
+ };
154
+ sankey.nodeAlign = function(_) {
155
+ return arguments.length ? (align = typeof _ === "function" ? _ : constant$1(_), sankey) : align;
156
+ };
157
+ sankey.nodeSort = function(_) {
158
+ return arguments.length ? (sort = _, sankey) : sort;
159
+ };
160
+ sankey.nodeWidth = function(_) {
161
+ return arguments.length ? (dx = +_, sankey) : dx;
162
+ };
163
+ sankey.nodePadding = function(_) {
164
+ return arguments.length ? (dy = py = +_, sankey) : dy;
165
+ };
166
+ sankey.nodes = function(_) {
167
+ return arguments.length ? (nodes2 = typeof _ === "function" ? _ : constant$1(_), sankey) : nodes2;
168
+ };
169
+ sankey.links = function(_) {
170
+ return arguments.length ? (links2 = typeof _ === "function" ? _ : constant$1(_), sankey) : links2;
171
+ };
172
+ sankey.linkSort = function(_) {
173
+ return arguments.length ? (linkSort = _, sankey) : linkSort;
174
+ };
175
+ sankey.size = function(_) {
176
+ return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];
177
+ };
178
+ sankey.extent = function(_) {
179
+ return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];
180
+ };
181
+ sankey.iterations = function(_) {
182
+ return arguments.length ? (iterations = +_, sankey) : iterations;
183
+ };
184
+ function computeNodeLinks({ nodes: nodes3, links: links3 }) {
185
+ for (const [i, node] of nodes3.entries()) {
186
+ node.index = i;
187
+ node.sourceLinks = [];
188
+ node.targetLinks = [];
189
+ }
190
+ const nodeById = new Map(nodes3.map((d, i) => [id(d, i, nodes3), d]));
191
+ for (const [i, link2] of links3.entries()) {
192
+ link2.index = i;
193
+ let { source, target } = link2;
194
+ if (typeof source !== "object") source = link2.source = find(nodeById, source);
195
+ if (typeof target !== "object") target = link2.target = find(nodeById, target);
196
+ source.sourceLinks.push(link2);
197
+ target.targetLinks.push(link2);
198
+ }
199
+ if (linkSort != null) {
200
+ for (const { sourceLinks, targetLinks } of nodes3) {
201
+ sourceLinks.sort(linkSort);
202
+ targetLinks.sort(linkSort);
203
+ }
204
+ }
205
+ }
206
+ function computeNodeValues({ nodes: nodes3 }) {
207
+ for (const node of nodes3) {
208
+ node.value = node.fixedValue === void 0 ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value)) : node.fixedValue;
209
+ }
210
+ }
211
+ function computeNodeDepths({ nodes: nodes3 }) {
212
+ const n = nodes3.length;
213
+ let current = new Set(nodes3);
214
+ let next = /* @__PURE__ */ new Set();
215
+ let x2 = 0;
216
+ while (current.size) {
217
+ for (const node of current) {
218
+ node.depth = x2;
219
+ for (const { target } of node.sourceLinks) {
220
+ next.add(target);
221
+ }
222
+ }
223
+ if (++x2 > n) throw new Error("circular link");
224
+ current = next;
225
+ next = /* @__PURE__ */ new Set();
226
+ }
227
+ }
228
+ function computeNodeHeights({ nodes: nodes3 }) {
229
+ const n = nodes3.length;
230
+ let current = new Set(nodes3);
231
+ let next = /* @__PURE__ */ new Set();
232
+ let x2 = 0;
233
+ while (current.size) {
234
+ for (const node of current) {
235
+ node.height = x2;
236
+ for (const { source } of node.targetLinks) {
237
+ next.add(source);
238
+ }
239
+ }
240
+ if (++x2 > n) throw new Error("circular link");
241
+ current = next;
242
+ next = /* @__PURE__ */ new Set();
243
+ }
244
+ }
245
+ function computeNodeLayers({ nodes: nodes3 }) {
246
+ const x2 = max(nodes3, (d) => d.depth) + 1;
247
+ const kx = (x1 - x0 - dx) / (x2 - 1);
248
+ const columns = new Array(x2);
249
+ for (const node of nodes3) {
250
+ const i = Math.max(0, Math.min(x2 - 1, Math.floor(align.call(null, node, x2))));
251
+ node.layer = i;
252
+ node.x0 = x0 + i * kx;
253
+ node.x1 = node.x0 + dx;
254
+ if (columns[i]) columns[i].push(node);
255
+ else columns[i] = [node];
256
+ }
257
+ if (sort) for (const column of columns) {
258
+ column.sort(sort);
259
+ }
260
+ return columns;
261
+ }
262
+ function initializeNodeBreadths(columns) {
263
+ const ky = min(columns, (c) => (y1 - y0 - (c.length - 1) * py) / sum(c, value));
264
+ for (const nodes3 of columns) {
265
+ let y2 = y0;
266
+ for (const node of nodes3) {
267
+ node.y0 = y2;
268
+ node.y1 = y2 + node.value * ky;
269
+ y2 = node.y1 + py;
270
+ for (const link2 of node.sourceLinks) {
271
+ link2.width = link2.value * ky;
272
+ }
273
+ }
274
+ y2 = (y1 - y2 + py) / (nodes3.length + 1);
275
+ for (let i = 0; i < nodes3.length; ++i) {
276
+ const node = nodes3[i];
277
+ node.y0 += y2 * (i + 1);
278
+ node.y1 += y2 * (i + 1);
279
+ }
280
+ reorderLinks(nodes3);
281
+ }
282
+ }
283
+ function computeNodeBreadths(graph) {
284
+ const columns = computeNodeLayers(graph);
285
+ py = Math.min(dy, (y1 - y0) / (max(columns, (c) => c.length) - 1));
286
+ initializeNodeBreadths(columns);
287
+ for (let i = 0; i < iterations; ++i) {
288
+ const alpha = Math.pow(0.99, i);
289
+ const beta = Math.max(1 - alpha, (i + 1) / iterations);
290
+ relaxRightToLeft(columns, alpha, beta);
291
+ relaxLeftToRight(columns, alpha, beta);
292
+ }
293
+ }
294
+ function relaxLeftToRight(columns, alpha, beta) {
295
+ for (let i = 1, n = columns.length; i < n; ++i) {
296
+ const column = columns[i];
297
+ for (const target of column) {
298
+ let y2 = 0;
299
+ let w = 0;
300
+ for (const { source, value: value2 } of target.targetLinks) {
301
+ let v = value2 * (target.layer - source.layer);
302
+ y2 += targetTop(source, target) * v;
303
+ w += v;
304
+ }
305
+ if (!(w > 0)) continue;
306
+ let dy2 = (y2 / w - target.y0) * alpha;
307
+ target.y0 += dy2;
308
+ target.y1 += dy2;
309
+ reorderNodeLinks(target);
310
+ }
311
+ if (sort === void 0) column.sort(ascendingBreadth);
312
+ resolveCollisions(column, beta);
313
+ }
314
+ }
315
+ function relaxRightToLeft(columns, alpha, beta) {
316
+ for (let n = columns.length, i = n - 2; i >= 0; --i) {
317
+ const column = columns[i];
318
+ for (const source of column) {
319
+ let y2 = 0;
320
+ let w = 0;
321
+ for (const { target, value: value2 } of source.sourceLinks) {
322
+ let v = value2 * (target.layer - source.layer);
323
+ y2 += sourceTop(source, target) * v;
324
+ w += v;
325
+ }
326
+ if (!(w > 0)) continue;
327
+ let dy2 = (y2 / w - source.y0) * alpha;
328
+ source.y0 += dy2;
329
+ source.y1 += dy2;
330
+ reorderNodeLinks(source);
331
+ }
332
+ if (sort === void 0) column.sort(ascendingBreadth);
333
+ resolveCollisions(column, beta);
334
+ }
335
+ }
336
+ function resolveCollisions(nodes3, alpha) {
337
+ const i = nodes3.length >> 1;
338
+ const subject = nodes3[i];
339
+ resolveCollisionsBottomToTop(nodes3, subject.y0 - py, i - 1, alpha);
340
+ resolveCollisionsTopToBottom(nodes3, subject.y1 + py, i + 1, alpha);
341
+ resolveCollisionsBottomToTop(nodes3, y1, nodes3.length - 1, alpha);
342
+ resolveCollisionsTopToBottom(nodes3, y0, 0, alpha);
343
+ }
344
+ function resolveCollisionsTopToBottom(nodes3, y2, i, alpha) {
345
+ for (; i < nodes3.length; ++i) {
346
+ const node = nodes3[i];
347
+ const dy2 = (y2 - node.y0) * alpha;
348
+ if (dy2 > 1e-6) node.y0 += dy2, node.y1 += dy2;
349
+ y2 = node.y1 + py;
350
+ }
351
+ }
352
+ function resolveCollisionsBottomToTop(nodes3, y2, i, alpha) {
353
+ for (; i >= 0; --i) {
354
+ const node = nodes3[i];
355
+ const dy2 = (node.y1 - y2) * alpha;
356
+ if (dy2 > 1e-6) node.y0 -= dy2, node.y1 -= dy2;
357
+ y2 = node.y0 - py;
358
+ }
359
+ }
360
+ function reorderNodeLinks({ sourceLinks, targetLinks }) {
361
+ if (linkSort === void 0) {
362
+ for (const { source: { sourceLinks: sourceLinks2 } } of targetLinks) {
363
+ sourceLinks2.sort(ascendingTargetBreadth);
364
+ }
365
+ for (const { target: { targetLinks: targetLinks2 } } of sourceLinks) {
366
+ targetLinks2.sort(ascendingSourceBreadth);
367
+ }
368
+ }
369
+ }
370
+ function reorderLinks(nodes3) {
371
+ if (linkSort === void 0) {
372
+ for (const { sourceLinks, targetLinks } of nodes3) {
373
+ sourceLinks.sort(ascendingTargetBreadth);
374
+ targetLinks.sort(ascendingSourceBreadth);
375
+ }
376
+ }
377
+ }
378
+ function targetTop(source, target) {
379
+ let y2 = source.y0 - (source.sourceLinks.length - 1) * py / 2;
380
+ for (const { target: node, width } of source.sourceLinks) {
381
+ if (node === target) break;
382
+ y2 += width + py;
383
+ }
384
+ for (const { source: node, width } of target.targetLinks) {
385
+ if (node === source) break;
386
+ y2 -= width;
387
+ }
388
+ return y2;
389
+ }
390
+ function sourceTop(source, target) {
391
+ let y2 = target.y0 - (target.targetLinks.length - 1) * py / 2;
392
+ for (const { source: node, width } of target.targetLinks) {
393
+ if (node === source) break;
394
+ y2 += width + py;
395
+ }
396
+ for (const { target: node, width } of source.sourceLinks) {
397
+ if (node === target) break;
398
+ y2 -= width;
399
+ }
400
+ return y2;
401
+ }
402
+ return sankey;
403
+ }
404
+ var pi = Math.PI, tau = 2 * pi, epsilon = 1e-6, tauEpsilon = tau - epsilon;
405
+ function Path() {
406
+ this._x0 = this._y0 = // start of current subpath
407
+ this._x1 = this._y1 = null;
408
+ this._ = "";
409
+ }
410
+ function path() {
411
+ return new Path();
412
+ }
413
+ Path.prototype = path.prototype = {
414
+ constructor: Path,
415
+ moveTo: function(x2, y2) {
416
+ this._ += "M" + (this._x0 = this._x1 = +x2) + "," + (this._y0 = this._y1 = +y2);
417
+ },
418
+ closePath: function() {
419
+ if (this._x1 !== null) {
420
+ this._x1 = this._x0, this._y1 = this._y0;
421
+ this._ += "Z";
422
+ }
423
+ },
424
+ lineTo: function(x2, y2) {
425
+ this._ += "L" + (this._x1 = +x2) + "," + (this._y1 = +y2);
426
+ },
427
+ quadraticCurveTo: function(x1, y1, x2, y2) {
428
+ this._ += "Q" + +x1 + "," + +y1 + "," + (this._x1 = +x2) + "," + (this._y1 = +y2);
429
+ },
430
+ bezierCurveTo: function(x1, y1, x2, y2, x3, y3) {
431
+ this._ += "C" + +x1 + "," + +y1 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x3) + "," + (this._y1 = +y3);
432
+ },
433
+ arcTo: function(x1, y1, x2, y2, r) {
434
+ x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
435
+ var x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01;
436
+ if (r < 0) throw new Error("negative radius: " + r);
437
+ if (this._x1 === null) {
438
+ this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
439
+ } else if (!(l01_2 > epsilon)) ;
440
+ else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {
441
+ this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
442
+ } else {
443
+ var x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
444
+ if (Math.abs(t01 - 1) > epsilon) {
445
+ this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
446
+ }
447
+ this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
448
+ }
449
+ },
450
+ arc: function(x2, y2, r, a0, a1, ccw) {
451
+ x2 = +x2, y2 = +y2, r = +r, ccw = !!ccw;
452
+ var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x2 + dx, y0 = y2 + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
453
+ if (r < 0) throw new Error("negative radius: " + r);
454
+ if (this._x1 === null) {
455
+ this._ += "M" + x0 + "," + y0;
456
+ } else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {
457
+ this._ += "L" + x0 + "," + y0;
458
+ }
459
+ if (!r) return;
460
+ if (da < 0) da = da % tau + tau;
461
+ if (da > tauEpsilon) {
462
+ this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x2 - dx) + "," + (y2 - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
463
+ } else if (da > epsilon) {
464
+ this._ += "A" + r + "," + r + ",0," + +(da >= pi) + "," + cw + "," + (this._x1 = x2 + r * Math.cos(a1)) + "," + (this._y1 = y2 + r * Math.sin(a1));
465
+ }
466
+ },
467
+ rect: function(x2, y2, w, h) {
468
+ this._ += "M" + (this._x0 = this._x1 = +x2) + "," + (this._y0 = this._y1 = +y2) + "h" + +w + "v" + +h + "h" + -w + "Z";
469
+ },
470
+ toString: function() {
471
+ return this._;
472
+ }
473
+ };
474
+ function constant(x2) {
475
+ return function constant2() {
476
+ return x2;
477
+ };
478
+ }
479
+ function x(p) {
480
+ return p[0];
481
+ }
482
+ function y(p) {
483
+ return p[1];
484
+ }
485
+ var slice = Array.prototype.slice;
486
+ function linkSource(d) {
487
+ return d.source;
488
+ }
489
+ function linkTarget(d) {
490
+ return d.target;
491
+ }
492
+ function link(curve) {
493
+ var source = linkSource, target = linkTarget, x$1 = x, y$1 = y, context = null;
494
+ function link2() {
495
+ var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);
496
+ if (!context) context = buffer = path();
497
+ curve(context, +x$1.apply(this, (argv[0] = s, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv));
498
+ if (buffer) return context = null, buffer + "" || null;
499
+ }
500
+ link2.source = function(_) {
501
+ return arguments.length ? (source = _, link2) : source;
502
+ };
503
+ link2.target = function(_) {
504
+ return arguments.length ? (target = _, link2) : target;
505
+ };
506
+ link2.x = function(_) {
507
+ return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link2) : x$1;
508
+ };
509
+ link2.y = function(_) {
510
+ return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link2) : y$1;
511
+ };
512
+ link2.context = function(_) {
513
+ return arguments.length ? (context = _ == null ? null : _, link2) : context;
514
+ };
515
+ return link2;
516
+ }
517
+ function curveHorizontal(context, x0, y0, x1, y1) {
518
+ context.moveTo(x0, y0);
519
+ context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
520
+ }
521
+ function linkHorizontal() {
522
+ return link(curveHorizontal);
523
+ }
524
+ function horizontalSource(d) {
525
+ return [d.source.x1, d.y0];
526
+ }
527
+ function horizontalTarget(d) {
528
+ return [d.target.x0, d.y1];
529
+ }
530
+ function d3SankeyLinkHorizontal() {
531
+ return linkHorizontal().source(horizontalSource).target(horizontalTarget);
532
+ }
533
+ var parser = (function() {
534
+ var o = /* @__PURE__ */ index.__name(function(k, v, o2, l) {
535
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
536
+ return o2;
537
+ }, "o"), $V0 = [1, 9], $V1 = [1, 10], $V2 = [1, 5, 10, 12];
538
+ var parser2 = {
539
+ trace: /* @__PURE__ */ index.__name(function trace() {
540
+ }, "trace"),
541
+ yy: {},
542
+ symbols_: { "error": 2, "start": 3, "SANKEY": 4, "NEWLINE": 5, "csv": 6, "opt_eof": 7, "record": 8, "csv_tail": 9, "EOF": 10, "field[source]": 11, "COMMA": 12, "field[target]": 13, "field[value]": 14, "field": 15, "escaped": 16, "non_escaped": 17, "DQUOTE": 18, "ESCAPED_TEXT": 19, "NON_ESCAPED_TEXT": 20, "$accept": 0, "$end": 1 },
543
+ terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" },
544
+ productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]],
545
+ performAction: /* @__PURE__ */ index.__name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
546
+ var $0 = $$.length - 1;
547
+ switch (yystate) {
548
+ case 7:
549
+ const source = yy.findOrCreateNode($$[$0 - 4].trim().replaceAll('""', '"'));
550
+ const target = yy.findOrCreateNode($$[$0 - 2].trim().replaceAll('""', '"'));
551
+ const value2 = parseFloat($$[$0].trim());
552
+ yy.addLink(source, target, value2);
553
+ break;
554
+ case 8:
555
+ case 9:
556
+ case 11:
557
+ this.$ = $$[$0];
558
+ break;
559
+ case 10:
560
+ this.$ = $$[$0 - 1];
561
+ break;
562
+ }
563
+ }, "anonymous"),
564
+ table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 1: [2, 6], 7: 11, 10: [1, 12] }, o($V1, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, o($V2, [2, 8]), o($V2, [2, 9]), { 19: [1, 16] }, o($V2, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, o($V1, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 15: 18, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 18: [1, 19] }, o($V1, [2, 3]), { 12: [1, 20] }, o($V2, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: $V0, 20: $V1 }, o([1, 5, 10], [2, 7])],
565
+ defaultActions: { 11: [2, 1], 12: [2, 5] },
566
+ parseError: /* @__PURE__ */ index.__name(function parseError(str, hash) {
567
+ if (hash.recoverable) {
568
+ this.trace(str);
569
+ } else {
570
+ var error = new Error(str);
571
+ error.hash = hash;
572
+ throw error;
573
+ }
574
+ }, "parseError"),
575
+ parse: /* @__PURE__ */ index.__name(function parse(input) {
576
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
577
+ var args = lstack.slice.call(arguments, 1);
578
+ var lexer2 = Object.create(this.lexer);
579
+ var sharedState = { yy: {} };
580
+ for (var k in this.yy) {
581
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
582
+ sharedState.yy[k] = this.yy[k];
583
+ }
584
+ }
585
+ lexer2.setInput(input, sharedState.yy);
586
+ sharedState.yy.lexer = lexer2;
587
+ sharedState.yy.parser = this;
588
+ if (typeof lexer2.yylloc == "undefined") {
589
+ lexer2.yylloc = {};
590
+ }
591
+ var yyloc = lexer2.yylloc;
592
+ lstack.push(yyloc);
593
+ var ranges = lexer2.options && lexer2.options.ranges;
594
+ if (typeof sharedState.yy.parseError === "function") {
595
+ this.parseError = sharedState.yy.parseError;
596
+ } else {
597
+ this.parseError = Object.getPrototypeOf(this).parseError;
598
+ }
599
+ function popStack(n) {
600
+ stack.length = stack.length - 2 * n;
601
+ vstack.length = vstack.length - n;
602
+ lstack.length = lstack.length - n;
603
+ }
604
+ index.__name(popStack, "popStack");
605
+ function lex() {
606
+ var token;
607
+ token = tstack.pop() || lexer2.lex() || EOF;
608
+ if (typeof token !== "number") {
609
+ if (token instanceof Array) {
610
+ tstack = token;
611
+ token = tstack.pop();
612
+ }
613
+ token = self.symbols_[token] || token;
614
+ }
615
+ return token;
616
+ }
617
+ index.__name(lex, "lex");
618
+ var symbol, state, action, r, yyval = {}, p, len, newState, expected;
619
+ while (true) {
620
+ state = stack[stack.length - 1];
621
+ if (this.defaultActions[state]) {
622
+ action = this.defaultActions[state];
623
+ } else {
624
+ if (symbol === null || typeof symbol == "undefined") {
625
+ symbol = lex();
626
+ }
627
+ action = table[state] && table[state][symbol];
628
+ }
629
+ if (typeof action === "undefined" || !action.length || !action[0]) {
630
+ var errStr = "";
631
+ expected = [];
632
+ for (p in table[state]) {
633
+ if (this.terminals_[p] && p > TERROR) {
634
+ expected.push("'" + this.terminals_[p] + "'");
635
+ }
636
+ }
637
+ if (lexer2.showPosition) {
638
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
639
+ } else {
640
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
641
+ }
642
+ this.parseError(errStr, {
643
+ text: lexer2.match,
644
+ token: this.terminals_[symbol] || symbol,
645
+ line: lexer2.yylineno,
646
+ loc: yyloc,
647
+ expected
648
+ });
649
+ }
650
+ if (action[0] instanceof Array && action.length > 1) {
651
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
652
+ }
653
+ switch (action[0]) {
654
+ case 1:
655
+ stack.push(symbol);
656
+ vstack.push(lexer2.yytext);
657
+ lstack.push(lexer2.yylloc);
658
+ stack.push(action[1]);
659
+ symbol = null;
660
+ {
661
+ yyleng = lexer2.yyleng;
662
+ yytext = lexer2.yytext;
663
+ yylineno = lexer2.yylineno;
664
+ yyloc = lexer2.yylloc;
665
+ }
666
+ break;
667
+ case 2:
668
+ len = this.productions_[action[1]][1];
669
+ yyval.$ = vstack[vstack.length - len];
670
+ yyval._$ = {
671
+ first_line: lstack[lstack.length - (len || 1)].first_line,
672
+ last_line: lstack[lstack.length - 1].last_line,
673
+ first_column: lstack[lstack.length - (len || 1)].first_column,
674
+ last_column: lstack[lstack.length - 1].last_column
675
+ };
676
+ if (ranges) {
677
+ yyval._$.range = [
678
+ lstack[lstack.length - (len || 1)].range[0],
679
+ lstack[lstack.length - 1].range[1]
680
+ ];
681
+ }
682
+ r = this.performAction.apply(yyval, [
683
+ yytext,
684
+ yyleng,
685
+ yylineno,
686
+ sharedState.yy,
687
+ action[1],
688
+ vstack,
689
+ lstack
690
+ ].concat(args));
691
+ if (typeof r !== "undefined") {
692
+ return r;
693
+ }
694
+ if (len) {
695
+ stack = stack.slice(0, -1 * len * 2);
696
+ vstack = vstack.slice(0, -1 * len);
697
+ lstack = lstack.slice(0, -1 * len);
698
+ }
699
+ stack.push(this.productions_[action[1]][0]);
700
+ vstack.push(yyval.$);
701
+ lstack.push(yyval._$);
702
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
703
+ stack.push(newState);
704
+ break;
705
+ case 3:
706
+ return true;
707
+ }
708
+ }
709
+ return true;
710
+ }, "parse")
711
+ };
712
+ var lexer = /* @__PURE__ */ (function() {
713
+ var lexer2 = {
714
+ EOF: 1,
715
+ parseError: /* @__PURE__ */ index.__name(function parseError(str, hash) {
716
+ if (this.yy.parser) {
717
+ this.yy.parser.parseError(str, hash);
718
+ } else {
719
+ throw new Error(str);
720
+ }
721
+ }, "parseError"),
722
+ // resets the lexer, sets new input
723
+ setInput: /* @__PURE__ */ index.__name(function(input, yy) {
724
+ this.yy = yy || this.yy || {};
725
+ this._input = input;
726
+ this._more = this._backtrack = this.done = false;
727
+ this.yylineno = this.yyleng = 0;
728
+ this.yytext = this.matched = this.match = "";
729
+ this.conditionStack = ["INITIAL"];
730
+ this.yylloc = {
731
+ first_line: 1,
732
+ first_column: 0,
733
+ last_line: 1,
734
+ last_column: 0
735
+ };
736
+ if (this.options.ranges) {
737
+ this.yylloc.range = [0, 0];
738
+ }
739
+ this.offset = 0;
740
+ return this;
741
+ }, "setInput"),
742
+ // consumes and returns one char from the input
743
+ input: /* @__PURE__ */ index.__name(function() {
744
+ var ch = this._input[0];
745
+ this.yytext += ch;
746
+ this.yyleng++;
747
+ this.offset++;
748
+ this.match += ch;
749
+ this.matched += ch;
750
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
751
+ if (lines) {
752
+ this.yylineno++;
753
+ this.yylloc.last_line++;
754
+ } else {
755
+ this.yylloc.last_column++;
756
+ }
757
+ if (this.options.ranges) {
758
+ this.yylloc.range[1]++;
759
+ }
760
+ this._input = this._input.slice(1);
761
+ return ch;
762
+ }, "input"),
763
+ // unshifts one char (or a string) into the input
764
+ unput: /* @__PURE__ */ index.__name(function(ch) {
765
+ var len = ch.length;
766
+ var lines = ch.split(/(?:\r\n?|\n)/g);
767
+ this._input = ch + this._input;
768
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
769
+ this.offset -= len;
770
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
771
+ this.match = this.match.substr(0, this.match.length - 1);
772
+ this.matched = this.matched.substr(0, this.matched.length - 1);
773
+ if (lines.length - 1) {
774
+ this.yylineno -= lines.length - 1;
775
+ }
776
+ var r = this.yylloc.range;
777
+ this.yylloc = {
778
+ first_line: this.yylloc.first_line,
779
+ last_line: this.yylineno + 1,
780
+ first_column: this.yylloc.first_column,
781
+ last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
782
+ };
783
+ if (this.options.ranges) {
784
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
785
+ }
786
+ this.yyleng = this.yytext.length;
787
+ return this;
788
+ }, "unput"),
789
+ // When called from action, caches matched text and appends it on next action
790
+ more: /* @__PURE__ */ index.__name(function() {
791
+ this._more = true;
792
+ return this;
793
+ }, "more"),
794
+ // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
795
+ reject: /* @__PURE__ */ index.__name(function() {
796
+ if (this.options.backtrack_lexer) {
797
+ this._backtrack = true;
798
+ } else {
799
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
800
+ text: "",
801
+ token: null,
802
+ line: this.yylineno
803
+ });
804
+ }
805
+ return this;
806
+ }, "reject"),
807
+ // retain first n characters of the match
808
+ less: /* @__PURE__ */ index.__name(function(n) {
809
+ this.unput(this.match.slice(n));
810
+ }, "less"),
811
+ // displays already matched input, i.e. for error messages
812
+ pastInput: /* @__PURE__ */ index.__name(function() {
813
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
814
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
815
+ }, "pastInput"),
816
+ // displays upcoming input, i.e. for error messages
817
+ upcomingInput: /* @__PURE__ */ index.__name(function() {
818
+ var next = this.match;
819
+ if (next.length < 20) {
820
+ next += this._input.substr(0, 20 - next.length);
821
+ }
822
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
823
+ }, "upcomingInput"),
824
+ // displays the character position where the lexing error occurred, i.e. for error messages
825
+ showPosition: /* @__PURE__ */ index.__name(function() {
826
+ var pre = this.pastInput();
827
+ var c = new Array(pre.length + 1).join("-");
828
+ return pre + this.upcomingInput() + "\n" + c + "^";
829
+ }, "showPosition"),
830
+ // test the lexed token: return FALSE when not a match, otherwise return token
831
+ test_match: /* @__PURE__ */ index.__name(function(match, indexed_rule) {
832
+ var token, lines, backup;
833
+ if (this.options.backtrack_lexer) {
834
+ backup = {
835
+ yylineno: this.yylineno,
836
+ yylloc: {
837
+ first_line: this.yylloc.first_line,
838
+ last_line: this.last_line,
839
+ first_column: this.yylloc.first_column,
840
+ last_column: this.yylloc.last_column
841
+ },
842
+ yytext: this.yytext,
843
+ match: this.match,
844
+ matches: this.matches,
845
+ matched: this.matched,
846
+ yyleng: this.yyleng,
847
+ offset: this.offset,
848
+ _more: this._more,
849
+ _input: this._input,
850
+ yy: this.yy,
851
+ conditionStack: this.conditionStack.slice(0),
852
+ done: this.done
853
+ };
854
+ if (this.options.ranges) {
855
+ backup.yylloc.range = this.yylloc.range.slice(0);
856
+ }
857
+ }
858
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
859
+ if (lines) {
860
+ this.yylineno += lines.length;
861
+ }
862
+ this.yylloc = {
863
+ first_line: this.yylloc.last_line,
864
+ last_line: this.yylineno + 1,
865
+ first_column: this.yylloc.last_column,
866
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
867
+ };
868
+ this.yytext += match[0];
869
+ this.match += match[0];
870
+ this.matches = match;
871
+ this.yyleng = this.yytext.length;
872
+ if (this.options.ranges) {
873
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
874
+ }
875
+ this._more = false;
876
+ this._backtrack = false;
877
+ this._input = this._input.slice(match[0].length);
878
+ this.matched += match[0];
879
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
880
+ if (this.done && this._input) {
881
+ this.done = false;
882
+ }
883
+ if (token) {
884
+ return token;
885
+ } else if (this._backtrack) {
886
+ for (var k in backup) {
887
+ this[k] = backup[k];
888
+ }
889
+ return false;
890
+ }
891
+ return false;
892
+ }, "test_match"),
893
+ // return next match in input
894
+ next: /* @__PURE__ */ index.__name(function() {
895
+ if (this.done) {
896
+ return this.EOF;
897
+ }
898
+ if (!this._input) {
899
+ this.done = true;
900
+ }
901
+ var token, match, tempMatch, index2;
902
+ if (!this._more) {
903
+ this.yytext = "";
904
+ this.match = "";
905
+ }
906
+ var rules = this._currentRules();
907
+ for (var i = 0; i < rules.length; i++) {
908
+ tempMatch = this._input.match(this.rules[rules[i]]);
909
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
910
+ match = tempMatch;
911
+ index2 = i;
912
+ if (this.options.backtrack_lexer) {
913
+ token = this.test_match(tempMatch, rules[i]);
914
+ if (token !== false) {
915
+ return token;
916
+ } else if (this._backtrack) {
917
+ match = false;
918
+ continue;
919
+ } else {
920
+ return false;
921
+ }
922
+ } else if (!this.options.flex) {
923
+ break;
924
+ }
925
+ }
926
+ }
927
+ if (match) {
928
+ token = this.test_match(match, rules[index2]);
929
+ if (token !== false) {
930
+ return token;
931
+ }
932
+ return false;
933
+ }
934
+ if (this._input === "") {
935
+ return this.EOF;
936
+ } else {
937
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
938
+ text: "",
939
+ token: null,
940
+ line: this.yylineno
941
+ });
942
+ }
943
+ }, "next"),
944
+ // return next match that has a token
945
+ lex: /* @__PURE__ */ index.__name(function lex() {
946
+ var r = this.next();
947
+ if (r) {
948
+ return r;
949
+ } else {
950
+ return this.lex();
951
+ }
952
+ }, "lex"),
953
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
954
+ begin: /* @__PURE__ */ index.__name(function begin(condition) {
955
+ this.conditionStack.push(condition);
956
+ }, "begin"),
957
+ // pop the previously active lexer condition state off the condition stack
958
+ popState: /* @__PURE__ */ index.__name(function popState() {
959
+ var n = this.conditionStack.length - 1;
960
+ if (n > 0) {
961
+ return this.conditionStack.pop();
962
+ } else {
963
+ return this.conditionStack[0];
964
+ }
965
+ }, "popState"),
966
+ // produce the lexer rule set which is active for the currently active lexer condition state
967
+ _currentRules: /* @__PURE__ */ index.__name(function _currentRules() {
968
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
969
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
970
+ } else {
971
+ return this.conditions["INITIAL"].rules;
972
+ }
973
+ }, "_currentRules"),
974
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
975
+ topState: /* @__PURE__ */ index.__name(function topState(n) {
976
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
977
+ if (n >= 0) {
978
+ return this.conditionStack[n];
979
+ } else {
980
+ return "INITIAL";
981
+ }
982
+ }, "topState"),
983
+ // alias for begin(condition)
984
+ pushState: /* @__PURE__ */ index.__name(function pushState(condition) {
985
+ this.begin(condition);
986
+ }, "pushState"),
987
+ // return the number of states currently on the stack
988
+ stateStackSize: /* @__PURE__ */ index.__name(function stateStackSize() {
989
+ return this.conditionStack.length;
990
+ }, "stateStackSize"),
991
+ options: { "case-insensitive": true },
992
+ performAction: /* @__PURE__ */ index.__name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
993
+ switch ($avoiding_name_collisions) {
994
+ case 0:
995
+ this.pushState("csv");
996
+ return 4;
997
+ case 1:
998
+ this.pushState("csv");
999
+ return 4;
1000
+ case 2:
1001
+ return 10;
1002
+ case 3:
1003
+ return 5;
1004
+ case 4:
1005
+ return 12;
1006
+ case 5:
1007
+ this.pushState("escaped_text");
1008
+ return 18;
1009
+ case 6:
1010
+ return 20;
1011
+ case 7:
1012
+ this.popState("escaped_text");
1013
+ return 18;
1014
+ case 8:
1015
+ return 19;
1016
+ }
1017
+ }, "anonymous"),
1018
+ rules: [/^(?:sankey-beta\b)/i, /^(?:sankey\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],
1019
+ conditions: { "csv": { "rules": [2, 3, 4, 5, 6, 7, 8], "inclusive": false }, "escaped_text": { "rules": [7, 8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8], "inclusive": true } }
1020
+ };
1021
+ return lexer2;
1022
+ })();
1023
+ parser2.lexer = lexer;
1024
+ function Parser() {
1025
+ this.yy = {};
1026
+ }
1027
+ index.__name(Parser, "Parser");
1028
+ Parser.prototype = parser2;
1029
+ parser2.Parser = Parser;
1030
+ return new Parser();
1031
+ })();
1032
+ parser.parser = parser;
1033
+ var sankey_default = parser;
1034
+ var links = [];
1035
+ var nodes = [];
1036
+ var nodesMap = /* @__PURE__ */ new Map();
1037
+ var clear2 = /* @__PURE__ */ index.__name(() => {
1038
+ links = [];
1039
+ nodes = [];
1040
+ nodesMap = /* @__PURE__ */ new Map();
1041
+ index.clear();
1042
+ }, "clear");
1043
+ var SankeyLink = (_a = class {
1044
+ constructor(source, target, value2 = 0) {
1045
+ this.source = source;
1046
+ this.target = target;
1047
+ this.value = value2;
1048
+ }
1049
+ }, index.__name(_a, "SankeyLink"), _a);
1050
+ var addLink = /* @__PURE__ */ index.__name((source, target, value2) => {
1051
+ links.push(new SankeyLink(source, target, value2));
1052
+ }, "addLink");
1053
+ var SankeyNode = (_b = class {
1054
+ constructor(ID) {
1055
+ this.ID = ID;
1056
+ }
1057
+ }, index.__name(_b, "SankeyNode"), _b);
1058
+ var findOrCreateNode = /* @__PURE__ */ index.__name((ID) => {
1059
+ ID = index.common_default.sanitizeText(ID, index.getConfig2());
1060
+ let node = nodesMap.get(ID);
1061
+ if (node === void 0) {
1062
+ node = new SankeyNode(ID);
1063
+ nodesMap.set(ID, node);
1064
+ nodes.push(node);
1065
+ }
1066
+ return node;
1067
+ }, "findOrCreateNode");
1068
+ var getNodes = /* @__PURE__ */ index.__name(() => nodes, "getNodes");
1069
+ var getLinks = /* @__PURE__ */ index.__name(() => links, "getLinks");
1070
+ var getGraph = /* @__PURE__ */ index.__name(() => ({
1071
+ nodes: nodes.map((node) => ({ id: node.ID })),
1072
+ links: links.map((link2) => ({
1073
+ source: link2.source.ID,
1074
+ target: link2.target.ID,
1075
+ value: link2.value
1076
+ }))
1077
+ }), "getGraph");
1078
+ var sankeyDB_default = {
1079
+ nodesMap,
1080
+ getConfig: /* @__PURE__ */ index.__name(() => index.getConfig2().sankey, "getConfig"),
1081
+ getNodes,
1082
+ getLinks,
1083
+ getGraph,
1084
+ addLink,
1085
+ findOrCreateNode,
1086
+ getAccTitle: index.getAccTitle,
1087
+ setAccTitle: index.setAccTitle,
1088
+ getAccDescription: index.getAccDescription,
1089
+ setAccDescription: index.setAccDescription,
1090
+ getDiagramTitle: index.getDiagramTitle,
1091
+ setDiagramTitle: index.setDiagramTitle,
1092
+ clear: clear2
1093
+ };
1094
+ var Uid = (_c = class {
1095
+ static next(name) {
1096
+ return new _c(name + ++_c.count);
1097
+ }
1098
+ constructor(id) {
1099
+ this.id = id;
1100
+ this.href = `#${id}`;
1101
+ }
1102
+ toString() {
1103
+ return "url(" + this.href + ")";
1104
+ }
1105
+ }, index.__name(_c, "Uid"), _c.count = 0, _c);
1106
+ var alignmentsMap = {
1107
+ left,
1108
+ right,
1109
+ center,
1110
+ justify
1111
+ };
1112
+ var draw = /* @__PURE__ */ index.__name(function(text, id, _version, diagObj) {
1113
+ const { securityLevel, sankey: conf } = index.getConfig2();
1114
+ const defaultSankeyConfig = index.defaultConfig2.sankey;
1115
+ let sandboxElement;
1116
+ if (securityLevel === "sandbox") {
1117
+ sandboxElement = index.select("#i" + id);
1118
+ }
1119
+ const root = securityLevel === "sandbox" ? index.select(sandboxElement.nodes()[0].contentDocument.body) : index.select("body");
1120
+ const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : index.select(`[id="${id}"]`);
1121
+ const width = conf?.width ?? defaultSankeyConfig.width;
1122
+ const height = conf?.height ?? defaultSankeyConfig.width;
1123
+ const useMaxWidth = conf?.useMaxWidth ?? defaultSankeyConfig.useMaxWidth;
1124
+ const nodeAlignment = conf?.nodeAlignment ?? defaultSankeyConfig.nodeAlignment;
1125
+ const prefix = conf?.prefix ?? defaultSankeyConfig.prefix;
1126
+ const suffix = conf?.suffix ?? defaultSankeyConfig.suffix;
1127
+ const showValues = conf?.showValues ?? defaultSankeyConfig.showValues;
1128
+ const graph = diagObj.db.getGraph();
1129
+ const nodeAlign = alignmentsMap[nodeAlignment];
1130
+ const nodeWidth = 10;
1131
+ const sankey = Sankey().nodeId((d) => d.id).nodeWidth(nodeWidth).nodePadding(10 + (showValues ? 15 : 0)).nodeAlign(nodeAlign).extent([
1132
+ [0, 0],
1133
+ [width, height]
1134
+ ]);
1135
+ sankey(graph);
1136
+ const colorScheme = ordinal.ordinal(d3schemeTableau10);
1137
+ svg.append("g").attr("class", "nodes").selectAll(".node").data(graph.nodes).join("g").attr("class", "node").attr("id", (d) => (d.uid = Uid.next("node-")).id).attr("transform", function(d) {
1138
+ return "translate(" + d.x0 + "," + d.y0 + ")";
1139
+ }).attr("x", (d) => d.x0).attr("y", (d) => d.y0).append("rect").attr("height", (d) => {
1140
+ return d.y1 - d.y0;
1141
+ }).attr("width", (d) => d.x1 - d.x0).attr("fill", (d) => colorScheme(d.id));
1142
+ const getText = /* @__PURE__ */ index.__name(({ id: id2, value: value2 }) => {
1143
+ if (!showValues) {
1144
+ return id2;
1145
+ }
1146
+ return `${id2}
1147
+ ${prefix}${Math.round(value2 * 100) / 100}${suffix}`;
1148
+ }, "getText");
1149
+ svg.append("g").attr("class", "node-labels").attr("font-size", 14).selectAll("text").data(graph.nodes).join("text").attr("x", (d) => d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6).attr("y", (d) => (d.y1 + d.y0) / 2).attr("dy", `${showValues ? "0" : "0.35"}em`).attr("text-anchor", (d) => d.x0 < width / 2 ? "start" : "end").text(getText);
1150
+ const link2 = svg.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(graph.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply");
1151
+ const linkColor = conf?.linkColor ?? "gradient";
1152
+ if (linkColor === "gradient") {
1153
+ const gradient = link2.append("linearGradient").attr("id", (d) => (d.uid = Uid.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (d) => d.source.x1).attr("x2", (d) => d.target.x0);
1154
+ gradient.append("stop").attr("offset", "0%").attr("stop-color", (d) => colorScheme(d.source.id));
1155
+ gradient.append("stop").attr("offset", "100%").attr("stop-color", (d) => colorScheme(d.target.id));
1156
+ }
1157
+ let coloring;
1158
+ switch (linkColor) {
1159
+ case "gradient":
1160
+ coloring = /* @__PURE__ */ index.__name((d) => d.uid, "coloring");
1161
+ break;
1162
+ case "source":
1163
+ coloring = /* @__PURE__ */ index.__name((d) => colorScheme(d.source.id), "coloring");
1164
+ break;
1165
+ case "target":
1166
+ coloring = /* @__PURE__ */ index.__name((d) => colorScheme(d.target.id), "coloring");
1167
+ break;
1168
+ default:
1169
+ coloring = linkColor;
1170
+ }
1171
+ link2.append("path").attr("d", d3SankeyLinkHorizontal()).attr("stroke", coloring).attr("stroke-width", (d) => Math.max(1, d.width));
1172
+ index.setupGraphViewbox(void 0, svg, 0, useMaxWidth);
1173
+ }, "draw");
1174
+ var sankeyRenderer_default = {
1175
+ draw
1176
+ };
1177
+ var prepareTextForParsing = /* @__PURE__ */ index.__name((text) => {
1178
+ const textToParse = text.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, "\n").trim();
1179
+ return textToParse;
1180
+ }, "prepareTextForParsing");
1181
+ var getStyles = /* @__PURE__ */ index.__name((options) => `.label {
1182
+ font-family: ${options.fontFamily};
1183
+ }`, "getStyles");
1184
+ var styles_default = getStyles;
1185
+ var originalParse = sankey_default.parse.bind(sankey_default);
1186
+ sankey_default.parse = (text) => originalParse(prepareTextForParsing(text));
1187
+ var diagram = {
1188
+ styles: styles_default,
1189
+ parser: sankey_default,
1190
+ db: sankeyDB_default,
1191
+ renderer: sankeyRenderer_default
1192
+ };
1193
+ exports.diagram = diagram;