@sinm/kai 1.8.5
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.
- package/LICENSE +21 -0
- package/README.md +219 -0
- package/bin/kai-cli.js +21 -0
- package/dist-cli/kai-cli.js +218494 -0
- package/dist-electron/renderer/assets/_baseUniq-C3qTPmDE.js +660 -0
- package/dist-electron/renderer/assets/arc-BNCDL4e8.js +131 -0
- package/dist-electron/renderer/assets/architectureDiagram-Q4EWVU46-BdbGbDeJ.js +8718 -0
- package/dist-electron/renderer/assets/blockDiagram-DXYQGD6D-QiXI7ilT.js +3637 -0
- package/dist-electron/renderer/assets/c4Diagram-AHTNJAMY-BddxtMgY.js +2482 -0
- package/dist-electron/renderer/assets/channel-C_JLiB8I.js +7 -0
- package/dist-electron/renderer/assets/chunk-4BX2VUAB-s-dHrXuO.js +16 -0
- package/dist-electron/renderer/assets/chunk-4TB4RGXK-vzGbJGfp.js +1920 -0
- package/dist-electron/renderer/assets/chunk-55IACEB6-DS6S48ws.js +13 -0
- package/dist-electron/renderer/assets/chunk-EDXVE4YY-CkjF90gW.js +24 -0
- package/dist-electron/renderer/assets/chunk-FMBD7UC4-BXvIgVUY.js +19 -0
- package/dist-electron/renderer/assets/chunk-OYMX7WX6-YZbrtKSv.js +1939 -0
- package/dist-electron/renderer/assets/chunk-QZHKN3VN-BbLYRfB3.js +19 -0
- package/dist-electron/renderer/assets/chunk-YZCP3GAM-JVGt9SK_.js +116 -0
- package/dist-electron/renderer/assets/classDiagram-6PBFFD2Q-BwZMRjub.js +23 -0
- package/dist-electron/renderer/assets/classDiagram-v2-HSJHXN6E-BwZMRjub.js +23 -0
- package/dist-electron/renderer/assets/clone-BC-6Iyrf.js +8 -0
- package/dist-electron/renderer/assets/cose-bilkent-S5V4N54A-C3CGX8BH.js +4942 -0
- package/dist-electron/renderer/assets/cytoscape.esm-D6E6cAed.js +30246 -0
- package/dist-electron/renderer/assets/dagre-KV5264BT-DXOCL1ZZ.js +694 -0
- package/dist-electron/renderer/assets/defaultLocale-B2RvLBDe.js +206 -0
- package/dist-electron/renderer/assets/diagram-5BDNPKRD-B9dghm7-.js +171 -0
- package/dist-electron/renderer/assets/diagram-G4DWMVQ6-DDupyCeT.js +853 -0
- package/dist-electron/renderer/assets/diagram-MMDJMWI5-Bagr5R3p.js +303 -0
- package/dist-electron/renderer/assets/diagram-TYMM5635-YL5sCgeo.js +214 -0
- package/dist-electron/renderer/assets/erDiagram-SMLLAGMA-CHytCe4p.js +1227 -0
- package/dist-electron/renderer/assets/flowDiagram-DWJPFMVM-BJgPbbzi.js +2332 -0
- package/dist-electron/renderer/assets/ganttDiagram-T4ZO3ILL-BN-Vq0iy.js +3714 -0
- package/dist-electron/renderer/assets/gitGraphDiagram-UUTBAWPF-CbUpEcLb.js +1375 -0
- package/dist-electron/renderer/assets/graph-Di49T8Ee.js +953 -0
- package/dist-electron/renderer/assets/index-C55TZN9T.css +14105 -0
- package/dist-electron/renderer/assets/index-D-H_6heO.js +91405 -0
- package/dist-electron/renderer/assets/infoDiagram-42DDH7IO-BPl-rsFx.js +33 -0
- package/dist-electron/renderer/assets/init-ZxktEp_H.js +16 -0
- package/dist-electron/renderer/assets/ishikawaDiagram-UXIWVN3A-C8ly-VN_.js +967 -0
- package/dist-electron/renderer/assets/journeyDiagram-VCZTEJTY-nUjo5Mzy.js +1255 -0
- package/dist-electron/renderer/assets/kanban-definition-6JOO6SKY-DWVGGGQB.js +1052 -0
- package/dist-electron/renderer/assets/katex-CYis69t2.js +14301 -0
- package/dist-electron/renderer/assets/layout-BO15dWax.js +2217 -0
- package/dist-electron/renderer/assets/linear-bwcJeNAk.js +340 -0
- package/dist-electron/renderer/assets/min-CSnTolL5.js +41 -0
- package/dist-electron/renderer/assets/mindmap-definition-QFDTVHPH-WJVpu9VT.js +1186 -0
- package/dist-electron/renderer/assets/ordinal-CxptdPJm.js +76 -0
- package/dist-electron/renderer/assets/pieDiagram-DEJITSTG-DF_DZ5Q4.js +248 -0
- package/dist-electron/renderer/assets/quadrantDiagram-34T5L4WZ-UhXGuJcr.js +1342 -0
- package/dist-electron/renderer/assets/requirementDiagram-MS252O5E-BtD6ux77.js +1204 -0
- package/dist-electron/renderer/assets/sankeyDiagram-XADWPNL6-CC4IbM1T.js +1205 -0
- package/dist-electron/renderer/assets/sequenceDiagram-FGHM5R23-Da4bQBSu.js +4502 -0
- package/dist-electron/renderer/assets/stateDiagram-FHFEXIEX-zEkMqOXM.js +452 -0
- package/dist-electron/renderer/assets/stateDiagram-v2-QKLJ7IA2-DpXHvwUL.js +21 -0
- package/dist-electron/renderer/assets/timeline-definition-GMOUNBTQ-DJnjzEUR.js +1596 -0
- package/dist-electron/renderer/assets/vennDiagram-DHZGUBPP-f6WAsZFS.js +2486 -0
- package/dist-electron/renderer/assets/wardley-RL74JXVD-pTLEMWKj.js +24199 -0
- package/dist-electron/renderer/assets/wardleyDiagram-NUSXRM2D-GRV6kOg2.js +901 -0
- package/dist-electron/renderer/assets/xychartDiagram-5P7HB3ND-BAcUBgxf.js +1932 -0
- package/dist-electron/renderer/index.html +13 -0
- package/package.json +52 -0
|
@@ -0,0 +1,967 @@
|
|
|
1
|
+
import { _ as __name, c as getConfig2, N as parseFontSize, I as selectSvgElement, as as at, z as clear, k as common_default, p as setDiagramTitle, a as getAccTitle, b as setAccTitle, g as getAccDescription, s as setAccDescription, q as getDiagramTitle, e as configureSvgSize } from "./index-D-H_6heO.js";
|
|
2
|
+
var parser = (function() {
|
|
3
|
+
var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
|
|
4
|
+
for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
|
|
5
|
+
return o2;
|
|
6
|
+
}, "o"), $V0 = [1, 4], $V1 = [1, 14], $V2 = [1, 12], $V3 = [1, 13], $V4 = [6, 7, 8], $V5 = [1, 20], $V6 = [1, 18], $V7 = [1, 19], $V8 = [6, 7, 11], $V9 = [1, 6, 13, 14], $Va = [1, 23], $Vb = [1, 24], $Vc = [1, 6, 7, 11, 13, 14];
|
|
7
|
+
var parser2 = {
|
|
8
|
+
trace: /* @__PURE__ */ __name(function trace() {
|
|
9
|
+
}, "trace"),
|
|
10
|
+
yy: {},
|
|
11
|
+
symbols_: { "error": 2, "start": 3, "ishikawa": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "ISHIKAWA": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "TEXT": 14, "$accept": 0, "$end": 1 },
|
|
12
|
+
terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "ISHIKAWA", 11: "EOF", 13: "SPACELIST", 14: "TEXT" },
|
|
13
|
+
productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 1], [12, 1], [12, 1]],
|
|
14
|
+
performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
|
15
|
+
var $0 = $$.length - 1;
|
|
16
|
+
switch (yystate) {
|
|
17
|
+
case 6:
|
|
18
|
+
case 7:
|
|
19
|
+
return yy;
|
|
20
|
+
case 15:
|
|
21
|
+
yy.addNode($$[$0 - 1].length, $$[$0].trim());
|
|
22
|
+
break;
|
|
23
|
+
case 16:
|
|
24
|
+
yy.addNode(0, $$[$0].trim());
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}, "anonymous"),
|
|
28
|
+
table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: $V3 }, o($V4, [2, 3]), { 1: [2, 2] }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 6], 6: $V1, 12: 15, 13: $V2, 14: $V3 }, { 6: $V1, 9: 16, 12: 11, 13: $V2, 14: $V3 }, { 6: $V5, 7: $V6, 10: 17, 11: $V7 }, o($V8, [2, 18], { 14: [1, 21] }), o($V8, [2, 16]), o($V8, [2, 17]), { 6: $V5, 7: $V6, 10: 22, 11: $V7 }, { 1: [2, 7], 6: $V1, 12: 15, 13: $V2, 14: $V3 }, o($V9, [2, 14], { 7: $Va, 11: $Vb }), o($Vc, [2, 8]), o($Vc, [2, 9]), o($Vc, [2, 10]), o($V8, [2, 15]), o($V9, [2, 13], { 7: $Va, 11: $Vb }), o($Vc, [2, 11]), o($Vc, [2, 12])],
|
|
29
|
+
defaultActions: { 2: [2, 1], 6: [2, 2] },
|
|
30
|
+
parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
|
|
31
|
+
if (hash.recoverable) {
|
|
32
|
+
this.trace(str);
|
|
33
|
+
} else {
|
|
34
|
+
var error = new Error(str);
|
|
35
|
+
error.hash = hash;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}, "parseError"),
|
|
39
|
+
parse: /* @__PURE__ */ __name(function parse(input) {
|
|
40
|
+
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
|
41
|
+
var args = lstack.slice.call(arguments, 1);
|
|
42
|
+
var lexer2 = Object.create(this.lexer);
|
|
43
|
+
var sharedState = { yy: {} };
|
|
44
|
+
for (var k in this.yy) {
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
|
46
|
+
sharedState.yy[k] = this.yy[k];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
lexer2.setInput(input, sharedState.yy);
|
|
50
|
+
sharedState.yy.lexer = lexer2;
|
|
51
|
+
sharedState.yy.parser = this;
|
|
52
|
+
if (typeof lexer2.yylloc == "undefined") {
|
|
53
|
+
lexer2.yylloc = {};
|
|
54
|
+
}
|
|
55
|
+
var yyloc = lexer2.yylloc;
|
|
56
|
+
lstack.push(yyloc);
|
|
57
|
+
var ranges = lexer2.options && lexer2.options.ranges;
|
|
58
|
+
if (typeof sharedState.yy.parseError === "function") {
|
|
59
|
+
this.parseError = sharedState.yy.parseError;
|
|
60
|
+
} else {
|
|
61
|
+
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
62
|
+
}
|
|
63
|
+
function popStack(n) {
|
|
64
|
+
stack.length = stack.length - 2 * n;
|
|
65
|
+
vstack.length = vstack.length - n;
|
|
66
|
+
lstack.length = lstack.length - n;
|
|
67
|
+
}
|
|
68
|
+
__name(popStack, "popStack");
|
|
69
|
+
function lex() {
|
|
70
|
+
var token;
|
|
71
|
+
token = tstack.pop() || lexer2.lex() || EOF;
|
|
72
|
+
if (typeof token !== "number") {
|
|
73
|
+
if (token instanceof Array) {
|
|
74
|
+
tstack = token;
|
|
75
|
+
token = tstack.pop();
|
|
76
|
+
}
|
|
77
|
+
token = self.symbols_[token] || token;
|
|
78
|
+
}
|
|
79
|
+
return token;
|
|
80
|
+
}
|
|
81
|
+
__name(lex, "lex");
|
|
82
|
+
var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
|
83
|
+
while (true) {
|
|
84
|
+
state = stack[stack.length - 1];
|
|
85
|
+
if (this.defaultActions[state]) {
|
|
86
|
+
action = this.defaultActions[state];
|
|
87
|
+
} else {
|
|
88
|
+
if (symbol === null || typeof symbol == "undefined") {
|
|
89
|
+
symbol = lex();
|
|
90
|
+
}
|
|
91
|
+
action = table[state] && table[state][symbol];
|
|
92
|
+
}
|
|
93
|
+
if (typeof action === "undefined" || !action.length || !action[0]) {
|
|
94
|
+
var errStr = "";
|
|
95
|
+
expected = [];
|
|
96
|
+
for (p in table[state]) {
|
|
97
|
+
if (this.terminals_[p] && p > TERROR) {
|
|
98
|
+
expected.push("'" + this.terminals_[p] + "'");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (lexer2.showPosition) {
|
|
102
|
+
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
|
103
|
+
} else {
|
|
104
|
+
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
|
105
|
+
}
|
|
106
|
+
this.parseError(errStr, {
|
|
107
|
+
text: lexer2.match,
|
|
108
|
+
token: this.terminals_[symbol] || symbol,
|
|
109
|
+
line: lexer2.yylineno,
|
|
110
|
+
loc: yyloc,
|
|
111
|
+
expected
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (action[0] instanceof Array && action.length > 1) {
|
|
115
|
+
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
|
116
|
+
}
|
|
117
|
+
switch (action[0]) {
|
|
118
|
+
case 1:
|
|
119
|
+
stack.push(symbol);
|
|
120
|
+
vstack.push(lexer2.yytext);
|
|
121
|
+
lstack.push(lexer2.yylloc);
|
|
122
|
+
stack.push(action[1]);
|
|
123
|
+
symbol = null;
|
|
124
|
+
{
|
|
125
|
+
yyleng = lexer2.yyleng;
|
|
126
|
+
yytext = lexer2.yytext;
|
|
127
|
+
yylineno = lexer2.yylineno;
|
|
128
|
+
yyloc = lexer2.yylloc;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case 2:
|
|
132
|
+
len = this.productions_[action[1]][1];
|
|
133
|
+
yyval.$ = vstack[vstack.length - len];
|
|
134
|
+
yyval._$ = {
|
|
135
|
+
first_line: lstack[lstack.length - (len || 1)].first_line,
|
|
136
|
+
last_line: lstack[lstack.length - 1].last_line,
|
|
137
|
+
first_column: lstack[lstack.length - (len || 1)].first_column,
|
|
138
|
+
last_column: lstack[lstack.length - 1].last_column
|
|
139
|
+
};
|
|
140
|
+
if (ranges) {
|
|
141
|
+
yyval._$.range = [
|
|
142
|
+
lstack[lstack.length - (len || 1)].range[0],
|
|
143
|
+
lstack[lstack.length - 1].range[1]
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
r = this.performAction.apply(yyval, [
|
|
147
|
+
yytext,
|
|
148
|
+
yyleng,
|
|
149
|
+
yylineno,
|
|
150
|
+
sharedState.yy,
|
|
151
|
+
action[1],
|
|
152
|
+
vstack,
|
|
153
|
+
lstack
|
|
154
|
+
].concat(args));
|
|
155
|
+
if (typeof r !== "undefined") {
|
|
156
|
+
return r;
|
|
157
|
+
}
|
|
158
|
+
if (len) {
|
|
159
|
+
stack = stack.slice(0, -1 * len * 2);
|
|
160
|
+
vstack = vstack.slice(0, -1 * len);
|
|
161
|
+
lstack = lstack.slice(0, -1 * len);
|
|
162
|
+
}
|
|
163
|
+
stack.push(this.productions_[action[1]][0]);
|
|
164
|
+
vstack.push(yyval.$);
|
|
165
|
+
lstack.push(yyval._$);
|
|
166
|
+
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
|
167
|
+
stack.push(newState);
|
|
168
|
+
break;
|
|
169
|
+
case 3:
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}, "parse")
|
|
175
|
+
};
|
|
176
|
+
var lexer = /* @__PURE__ */ (function() {
|
|
177
|
+
var lexer2 = {
|
|
178
|
+
EOF: 1,
|
|
179
|
+
parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
|
|
180
|
+
if (this.yy.parser) {
|
|
181
|
+
this.yy.parser.parseError(str, hash);
|
|
182
|
+
} else {
|
|
183
|
+
throw new Error(str);
|
|
184
|
+
}
|
|
185
|
+
}, "parseError"),
|
|
186
|
+
// resets the lexer, sets new input
|
|
187
|
+
setInput: /* @__PURE__ */ __name(function(input, yy) {
|
|
188
|
+
this.yy = yy || this.yy || {};
|
|
189
|
+
this._input = input;
|
|
190
|
+
this._more = this._backtrack = this.done = false;
|
|
191
|
+
this.yylineno = this.yyleng = 0;
|
|
192
|
+
this.yytext = this.matched = this.match = "";
|
|
193
|
+
this.conditionStack = ["INITIAL"];
|
|
194
|
+
this.yylloc = {
|
|
195
|
+
first_line: 1,
|
|
196
|
+
first_column: 0,
|
|
197
|
+
last_line: 1,
|
|
198
|
+
last_column: 0
|
|
199
|
+
};
|
|
200
|
+
if (this.options.ranges) {
|
|
201
|
+
this.yylloc.range = [0, 0];
|
|
202
|
+
}
|
|
203
|
+
this.offset = 0;
|
|
204
|
+
return this;
|
|
205
|
+
}, "setInput"),
|
|
206
|
+
// consumes and returns one char from the input
|
|
207
|
+
input: /* @__PURE__ */ __name(function() {
|
|
208
|
+
var ch = this._input[0];
|
|
209
|
+
this.yytext += ch;
|
|
210
|
+
this.yyleng++;
|
|
211
|
+
this.offset++;
|
|
212
|
+
this.match += ch;
|
|
213
|
+
this.matched += ch;
|
|
214
|
+
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
|
215
|
+
if (lines) {
|
|
216
|
+
this.yylineno++;
|
|
217
|
+
this.yylloc.last_line++;
|
|
218
|
+
} else {
|
|
219
|
+
this.yylloc.last_column++;
|
|
220
|
+
}
|
|
221
|
+
if (this.options.ranges) {
|
|
222
|
+
this.yylloc.range[1]++;
|
|
223
|
+
}
|
|
224
|
+
this._input = this._input.slice(1);
|
|
225
|
+
return ch;
|
|
226
|
+
}, "input"),
|
|
227
|
+
// unshifts one char (or a string) into the input
|
|
228
|
+
unput: /* @__PURE__ */ __name(function(ch) {
|
|
229
|
+
var len = ch.length;
|
|
230
|
+
var lines = ch.split(/(?:\r\n?|\n)/g);
|
|
231
|
+
this._input = ch + this._input;
|
|
232
|
+
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
|
233
|
+
this.offset -= len;
|
|
234
|
+
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
|
235
|
+
this.match = this.match.substr(0, this.match.length - 1);
|
|
236
|
+
this.matched = this.matched.substr(0, this.matched.length - 1);
|
|
237
|
+
if (lines.length - 1) {
|
|
238
|
+
this.yylineno -= lines.length - 1;
|
|
239
|
+
}
|
|
240
|
+
var r = this.yylloc.range;
|
|
241
|
+
this.yylloc = {
|
|
242
|
+
first_line: this.yylloc.first_line,
|
|
243
|
+
last_line: this.yylineno + 1,
|
|
244
|
+
first_column: this.yylloc.first_column,
|
|
245
|
+
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
|
|
246
|
+
};
|
|
247
|
+
if (this.options.ranges) {
|
|
248
|
+
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
|
249
|
+
}
|
|
250
|
+
this.yyleng = this.yytext.length;
|
|
251
|
+
return this;
|
|
252
|
+
}, "unput"),
|
|
253
|
+
// When called from action, caches matched text and appends it on next action
|
|
254
|
+
more: /* @__PURE__ */ __name(function() {
|
|
255
|
+
this._more = true;
|
|
256
|
+
return this;
|
|
257
|
+
}, "more"),
|
|
258
|
+
// 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.
|
|
259
|
+
reject: /* @__PURE__ */ __name(function() {
|
|
260
|
+
if (this.options.backtrack_lexer) {
|
|
261
|
+
this._backtrack = true;
|
|
262
|
+
} else {
|
|
263
|
+
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(), {
|
|
264
|
+
text: "",
|
|
265
|
+
token: null,
|
|
266
|
+
line: this.yylineno
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return this;
|
|
270
|
+
}, "reject"),
|
|
271
|
+
// retain first n characters of the match
|
|
272
|
+
less: /* @__PURE__ */ __name(function(n) {
|
|
273
|
+
this.unput(this.match.slice(n));
|
|
274
|
+
}, "less"),
|
|
275
|
+
// displays already matched input, i.e. for error messages
|
|
276
|
+
pastInput: /* @__PURE__ */ __name(function() {
|
|
277
|
+
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
278
|
+
return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
|
279
|
+
}, "pastInput"),
|
|
280
|
+
// displays upcoming input, i.e. for error messages
|
|
281
|
+
upcomingInput: /* @__PURE__ */ __name(function() {
|
|
282
|
+
var next = this.match;
|
|
283
|
+
if (next.length < 20) {
|
|
284
|
+
next += this._input.substr(0, 20 - next.length);
|
|
285
|
+
}
|
|
286
|
+
return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
|
287
|
+
}, "upcomingInput"),
|
|
288
|
+
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
289
|
+
showPosition: /* @__PURE__ */ __name(function() {
|
|
290
|
+
var pre = this.pastInput();
|
|
291
|
+
var c = new Array(pre.length + 1).join("-");
|
|
292
|
+
return pre + this.upcomingInput() + "\n" + c + "^";
|
|
293
|
+
}, "showPosition"),
|
|
294
|
+
// test the lexed token: return FALSE when not a match, otherwise return token
|
|
295
|
+
test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
|
|
296
|
+
var token, lines, backup;
|
|
297
|
+
if (this.options.backtrack_lexer) {
|
|
298
|
+
backup = {
|
|
299
|
+
yylineno: this.yylineno,
|
|
300
|
+
yylloc: {
|
|
301
|
+
first_line: this.yylloc.first_line,
|
|
302
|
+
last_line: this.last_line,
|
|
303
|
+
first_column: this.yylloc.first_column,
|
|
304
|
+
last_column: this.yylloc.last_column
|
|
305
|
+
},
|
|
306
|
+
yytext: this.yytext,
|
|
307
|
+
match: this.match,
|
|
308
|
+
matches: this.matches,
|
|
309
|
+
matched: this.matched,
|
|
310
|
+
yyleng: this.yyleng,
|
|
311
|
+
offset: this.offset,
|
|
312
|
+
_more: this._more,
|
|
313
|
+
_input: this._input,
|
|
314
|
+
yy: this.yy,
|
|
315
|
+
conditionStack: this.conditionStack.slice(0),
|
|
316
|
+
done: this.done
|
|
317
|
+
};
|
|
318
|
+
if (this.options.ranges) {
|
|
319
|
+
backup.yylloc.range = this.yylloc.range.slice(0);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
|
323
|
+
if (lines) {
|
|
324
|
+
this.yylineno += lines.length;
|
|
325
|
+
}
|
|
326
|
+
this.yylloc = {
|
|
327
|
+
first_line: this.yylloc.last_line,
|
|
328
|
+
last_line: this.yylineno + 1,
|
|
329
|
+
first_column: this.yylloc.last_column,
|
|
330
|
+
last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
|
331
|
+
};
|
|
332
|
+
this.yytext += match[0];
|
|
333
|
+
this.match += match[0];
|
|
334
|
+
this.matches = match;
|
|
335
|
+
this.yyleng = this.yytext.length;
|
|
336
|
+
if (this.options.ranges) {
|
|
337
|
+
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
|
338
|
+
}
|
|
339
|
+
this._more = false;
|
|
340
|
+
this._backtrack = false;
|
|
341
|
+
this._input = this._input.slice(match[0].length);
|
|
342
|
+
this.matched += match[0];
|
|
343
|
+
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
|
344
|
+
if (this.done && this._input) {
|
|
345
|
+
this.done = false;
|
|
346
|
+
}
|
|
347
|
+
if (token) {
|
|
348
|
+
return token;
|
|
349
|
+
} else if (this._backtrack) {
|
|
350
|
+
for (var k in backup) {
|
|
351
|
+
this[k] = backup[k];
|
|
352
|
+
}
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return false;
|
|
356
|
+
}, "test_match"),
|
|
357
|
+
// return next match in input
|
|
358
|
+
next: /* @__PURE__ */ __name(function() {
|
|
359
|
+
if (this.done) {
|
|
360
|
+
return this.EOF;
|
|
361
|
+
}
|
|
362
|
+
if (!this._input) {
|
|
363
|
+
this.done = true;
|
|
364
|
+
}
|
|
365
|
+
var token, match, tempMatch, index;
|
|
366
|
+
if (!this._more) {
|
|
367
|
+
this.yytext = "";
|
|
368
|
+
this.match = "";
|
|
369
|
+
}
|
|
370
|
+
var rules = this._currentRules();
|
|
371
|
+
for (var i = 0; i < rules.length; i++) {
|
|
372
|
+
tempMatch = this._input.match(this.rules[rules[i]]);
|
|
373
|
+
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
|
374
|
+
match = tempMatch;
|
|
375
|
+
index = i;
|
|
376
|
+
if (this.options.backtrack_lexer) {
|
|
377
|
+
token = this.test_match(tempMatch, rules[i]);
|
|
378
|
+
if (token !== false) {
|
|
379
|
+
return token;
|
|
380
|
+
} else if (this._backtrack) {
|
|
381
|
+
match = false;
|
|
382
|
+
continue;
|
|
383
|
+
} else {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
} else if (!this.options.flex) {
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (match) {
|
|
392
|
+
token = this.test_match(match, rules[index]);
|
|
393
|
+
if (token !== false) {
|
|
394
|
+
return token;
|
|
395
|
+
}
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
if (this._input === "") {
|
|
399
|
+
return this.EOF;
|
|
400
|
+
} else {
|
|
401
|
+
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
|
402
|
+
text: "",
|
|
403
|
+
token: null,
|
|
404
|
+
line: this.yylineno
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}, "next"),
|
|
408
|
+
// return next match that has a token
|
|
409
|
+
lex: /* @__PURE__ */ __name(function lex() {
|
|
410
|
+
var r = this.next();
|
|
411
|
+
if (r) {
|
|
412
|
+
return r;
|
|
413
|
+
} else {
|
|
414
|
+
return this.lex();
|
|
415
|
+
}
|
|
416
|
+
}, "lex"),
|
|
417
|
+
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
|
418
|
+
begin: /* @__PURE__ */ __name(function begin(condition) {
|
|
419
|
+
this.conditionStack.push(condition);
|
|
420
|
+
}, "begin"),
|
|
421
|
+
// pop the previously active lexer condition state off the condition stack
|
|
422
|
+
popState: /* @__PURE__ */ __name(function popState() {
|
|
423
|
+
var n = this.conditionStack.length - 1;
|
|
424
|
+
if (n > 0) {
|
|
425
|
+
return this.conditionStack.pop();
|
|
426
|
+
} else {
|
|
427
|
+
return this.conditionStack[0];
|
|
428
|
+
}
|
|
429
|
+
}, "popState"),
|
|
430
|
+
// produce the lexer rule set which is active for the currently active lexer condition state
|
|
431
|
+
_currentRules: /* @__PURE__ */ __name(function _currentRules() {
|
|
432
|
+
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
|
433
|
+
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
|
434
|
+
} else {
|
|
435
|
+
return this.conditions["INITIAL"].rules;
|
|
436
|
+
}
|
|
437
|
+
}, "_currentRules"),
|
|
438
|
+
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
|
439
|
+
topState: /* @__PURE__ */ __name(function topState(n) {
|
|
440
|
+
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
|
441
|
+
if (n >= 0) {
|
|
442
|
+
return this.conditionStack[n];
|
|
443
|
+
} else {
|
|
444
|
+
return "INITIAL";
|
|
445
|
+
}
|
|
446
|
+
}, "topState"),
|
|
447
|
+
// alias for begin(condition)
|
|
448
|
+
pushState: /* @__PURE__ */ __name(function pushState(condition) {
|
|
449
|
+
this.begin(condition);
|
|
450
|
+
}, "pushState"),
|
|
451
|
+
// return the number of states currently on the stack
|
|
452
|
+
stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
|
|
453
|
+
return this.conditionStack.length;
|
|
454
|
+
}, "stateStackSize"),
|
|
455
|
+
options: { "case-insensitive": true },
|
|
456
|
+
performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
|
457
|
+
switch ($avoiding_name_collisions) {
|
|
458
|
+
case 0:
|
|
459
|
+
return 6;
|
|
460
|
+
case 1:
|
|
461
|
+
return 8;
|
|
462
|
+
case 2:
|
|
463
|
+
return 8;
|
|
464
|
+
case 3:
|
|
465
|
+
return 6;
|
|
466
|
+
case 4:
|
|
467
|
+
return 7;
|
|
468
|
+
case 5:
|
|
469
|
+
return 13;
|
|
470
|
+
case 6:
|
|
471
|
+
return 14;
|
|
472
|
+
case 7:
|
|
473
|
+
return 11;
|
|
474
|
+
}
|
|
475
|
+
}, "anonymous"),
|
|
476
|
+
rules: [/^(?:\s*%%.*)/i, /^(?:ishikawa-beta\b)/i, /^(?:ishikawa\b)/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:[^\n]+)/i, /^(?:$)/i],
|
|
477
|
+
conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } }
|
|
478
|
+
};
|
|
479
|
+
return lexer2;
|
|
480
|
+
})();
|
|
481
|
+
parser2.lexer = lexer;
|
|
482
|
+
function Parser() {
|
|
483
|
+
this.yy = {};
|
|
484
|
+
}
|
|
485
|
+
__name(Parser, "Parser");
|
|
486
|
+
Parser.prototype = parser2;
|
|
487
|
+
parser2.Parser = Parser;
|
|
488
|
+
return new Parser();
|
|
489
|
+
})();
|
|
490
|
+
parser.parser = parser;
|
|
491
|
+
var ishikawa_default = parser;
|
|
492
|
+
var IshikawaDB = class {
|
|
493
|
+
constructor() {
|
|
494
|
+
this.stack = [];
|
|
495
|
+
this.clear = this.clear.bind(this);
|
|
496
|
+
this.addNode = this.addNode.bind(this);
|
|
497
|
+
this.getRoot = this.getRoot.bind(this);
|
|
498
|
+
}
|
|
499
|
+
static {
|
|
500
|
+
__name(this, "IshikawaDB");
|
|
501
|
+
}
|
|
502
|
+
clear() {
|
|
503
|
+
this.root = void 0;
|
|
504
|
+
this.stack = [];
|
|
505
|
+
this.baseLevel = void 0;
|
|
506
|
+
clear();
|
|
507
|
+
}
|
|
508
|
+
getRoot() {
|
|
509
|
+
return this.root;
|
|
510
|
+
}
|
|
511
|
+
addNode(rawLevel, text) {
|
|
512
|
+
const label = common_default.sanitizeText(text, getConfig2());
|
|
513
|
+
if (!this.root) {
|
|
514
|
+
this.root = { text: label, children: [] };
|
|
515
|
+
this.stack = [{ level: 0, node: this.root }];
|
|
516
|
+
setDiagramTitle(label);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
this.baseLevel ??= rawLevel;
|
|
520
|
+
let level = rawLevel - this.baseLevel + 1;
|
|
521
|
+
if (level <= 0) {
|
|
522
|
+
level = 1;
|
|
523
|
+
}
|
|
524
|
+
while (this.stack.length > 1 && this.stack[this.stack.length - 1].level >= level) {
|
|
525
|
+
this.stack.pop();
|
|
526
|
+
}
|
|
527
|
+
const parent = this.stack[this.stack.length - 1].node;
|
|
528
|
+
const node = { text: label, children: [] };
|
|
529
|
+
parent.children.push(node);
|
|
530
|
+
this.stack.push({ level, node });
|
|
531
|
+
}
|
|
532
|
+
getAccTitle() {
|
|
533
|
+
return getAccTitle();
|
|
534
|
+
}
|
|
535
|
+
setAccTitle(title) {
|
|
536
|
+
setAccTitle(title);
|
|
537
|
+
}
|
|
538
|
+
getAccDescription() {
|
|
539
|
+
return getAccDescription();
|
|
540
|
+
}
|
|
541
|
+
setAccDescription(description) {
|
|
542
|
+
setAccDescription(description);
|
|
543
|
+
}
|
|
544
|
+
getDiagramTitle() {
|
|
545
|
+
return getDiagramTitle();
|
|
546
|
+
}
|
|
547
|
+
setDiagramTitle(title) {
|
|
548
|
+
setDiagramTitle(title);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
var FONT_SIZE_DEFAULT = 14;
|
|
552
|
+
var SPINE_BASE_LENGTH = 250;
|
|
553
|
+
var BONE_STUB = 30;
|
|
554
|
+
var BONE_BASE = 60;
|
|
555
|
+
var BONE_PER_CHILD = 5;
|
|
556
|
+
var ANGLE = 82 * Math.PI / 180;
|
|
557
|
+
var COS_A = Math.cos(ANGLE);
|
|
558
|
+
var SIN_A = Math.sin(ANGLE);
|
|
559
|
+
var applyPaddedViewBox = /* @__PURE__ */ __name((svgEl, pad, maxW) => {
|
|
560
|
+
const bbox = svgEl.node().getBBox();
|
|
561
|
+
const w = bbox.width + pad * 2;
|
|
562
|
+
const h = bbox.height + pad * 2;
|
|
563
|
+
configureSvgSize(svgEl, h, w, maxW);
|
|
564
|
+
svgEl.attr("viewBox", `${bbox.x - pad} ${bbox.y - pad} ${w} ${h}`);
|
|
565
|
+
}, "applyPaddedViewBox");
|
|
566
|
+
var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
|
|
567
|
+
const db = diagram2.db;
|
|
568
|
+
const root = db.getRoot();
|
|
569
|
+
if (!root) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const drawConfig = getConfig2();
|
|
573
|
+
const { look, handDrawnSeed, themeVariables } = drawConfig;
|
|
574
|
+
const fontSize = parseFontSize(drawConfig.fontSize)[0] ?? FONT_SIZE_DEFAULT;
|
|
575
|
+
const isHandDrawn = look === "handDrawn";
|
|
576
|
+
const causes = root.children ?? [];
|
|
577
|
+
const padding = drawConfig.ishikawa?.diagramPadding ?? 20;
|
|
578
|
+
const useMaxWidth = drawConfig.ishikawa?.useMaxWidth ?? false;
|
|
579
|
+
const svg = selectSvgElement(id);
|
|
580
|
+
const g = svg.append("g").attr("class", "ishikawa");
|
|
581
|
+
const roughSvg = isHandDrawn ? at.svg(svg.node()) : void 0;
|
|
582
|
+
const roughContext = roughSvg ? {
|
|
583
|
+
roughSvg,
|
|
584
|
+
seed: handDrawnSeed ?? 0,
|
|
585
|
+
lineColor: themeVariables?.lineColor ?? "#333",
|
|
586
|
+
fillColor: themeVariables?.mainBkg ?? "#fff"
|
|
587
|
+
} : void 0;
|
|
588
|
+
const markerId = `ishikawa-arrow-${id}`;
|
|
589
|
+
if (!isHandDrawn) {
|
|
590
|
+
g.append("defs").append("marker").attr("id", markerId).attr("viewBox", "0 0 10 10").attr("refX", 0).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 Z").attr("class", "ishikawa-arrow");
|
|
591
|
+
}
|
|
592
|
+
let spineX = 0;
|
|
593
|
+
let spineY = SPINE_BASE_LENGTH;
|
|
594
|
+
const spineLine = isHandDrawn ? void 0 : drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine");
|
|
595
|
+
drawHead(g, spineX, spineY, root.text, fontSize, roughContext);
|
|
596
|
+
if (!causes.length) {
|
|
597
|
+
if (isHandDrawn) {
|
|
598
|
+
drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine", roughContext);
|
|
599
|
+
}
|
|
600
|
+
applyPaddedViewBox(svg, padding, useMaxWidth);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
spineX -= 20;
|
|
604
|
+
const upperCauses = causes.filter((_, i) => i % 2 === 0);
|
|
605
|
+
const lowerCauses = causes.filter((_, i) => i % 2 === 1);
|
|
606
|
+
const upperStats = sideStats(upperCauses);
|
|
607
|
+
const lowerStats = sideStats(lowerCauses);
|
|
608
|
+
const descendantTotal = upperStats.total + lowerStats.total;
|
|
609
|
+
let upperLen = SPINE_BASE_LENGTH;
|
|
610
|
+
let lowerLen = SPINE_BASE_LENGTH;
|
|
611
|
+
if (descendantTotal > 0) {
|
|
612
|
+
const pool = SPINE_BASE_LENGTH * 2;
|
|
613
|
+
const minLen = SPINE_BASE_LENGTH * 0.3;
|
|
614
|
+
upperLen = Math.max(minLen, pool * (upperStats.total / descendantTotal));
|
|
615
|
+
lowerLen = Math.max(minLen, pool * (lowerStats.total / descendantTotal));
|
|
616
|
+
}
|
|
617
|
+
const minSpacing = fontSize * 2;
|
|
618
|
+
upperLen = Math.max(upperLen, upperStats.max * minSpacing);
|
|
619
|
+
lowerLen = Math.max(lowerLen, lowerStats.max * minSpacing);
|
|
620
|
+
spineY = Math.max(upperLen, SPINE_BASE_LENGTH);
|
|
621
|
+
if (spineLine) {
|
|
622
|
+
spineLine.attr("y1", spineY).attr("y2", spineY);
|
|
623
|
+
}
|
|
624
|
+
g.select(".ishikawa-head-group").attr("transform", `translate(0,${spineY})`);
|
|
625
|
+
const pairCount = Math.ceil(causes.length / 2);
|
|
626
|
+
for (let p = 0; p < pairCount; p++) {
|
|
627
|
+
const pg = g.append("g").attr("class", "ishikawa-pair");
|
|
628
|
+
for (const [cause, dir, len] of [
|
|
629
|
+
[causes[p * 2], -1, upperLen],
|
|
630
|
+
[causes[p * 2 + 1], 1, lowerLen]
|
|
631
|
+
]) {
|
|
632
|
+
if (cause) {
|
|
633
|
+
drawBranch(pg, cause, spineX, spineY, dir, len, fontSize, roughContext);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
spineX = pg.selectAll("text").nodes().reduce((left, n) => Math.min(left, n.getBBox().x), Infinity);
|
|
637
|
+
}
|
|
638
|
+
if (isHandDrawn) {
|
|
639
|
+
drawLine(g, spineX, spineY, 0, spineY, "ishikawa-spine", roughContext);
|
|
640
|
+
} else {
|
|
641
|
+
spineLine.attr("x1", spineX);
|
|
642
|
+
const markerUrl = `url(#${markerId})`;
|
|
643
|
+
g.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start", markerUrl);
|
|
644
|
+
}
|
|
645
|
+
applyPaddedViewBox(svg, padding, useMaxWidth);
|
|
646
|
+
}, "draw");
|
|
647
|
+
var sideStats = /* @__PURE__ */ __name((nodes) => {
|
|
648
|
+
const countDescendants = /* @__PURE__ */ __name((node) => node.children.reduce((sum, child) => sum + 1 + countDescendants(child), 0), "countDescendants");
|
|
649
|
+
return nodes.reduce(
|
|
650
|
+
(stats, node) => {
|
|
651
|
+
const descendants = countDescendants(node);
|
|
652
|
+
stats.total += descendants;
|
|
653
|
+
stats.max = Math.max(stats.max, descendants);
|
|
654
|
+
return stats;
|
|
655
|
+
},
|
|
656
|
+
{ total: 0, max: 0 }
|
|
657
|
+
);
|
|
658
|
+
}, "sideStats");
|
|
659
|
+
var drawHead = /* @__PURE__ */ __name((svg, x, y, label, fontSize, roughContext) => {
|
|
660
|
+
const maxChars = Math.max(6, Math.floor(110 / (fontSize * 0.6)));
|
|
661
|
+
const headGroup = svg.append("g").attr("class", "ishikawa-head-group").attr("transform", `translate(${x},${y})`);
|
|
662
|
+
const textEl = drawMultilineText(
|
|
663
|
+
headGroup,
|
|
664
|
+
wrapText(label, maxChars),
|
|
665
|
+
0,
|
|
666
|
+
0,
|
|
667
|
+
"ishikawa-head-label",
|
|
668
|
+
"start",
|
|
669
|
+
fontSize
|
|
670
|
+
);
|
|
671
|
+
const tb = textEl.node().getBBox();
|
|
672
|
+
const w = Math.max(60, tb.width + 6);
|
|
673
|
+
const h = Math.max(40, tb.height * 2 + 40);
|
|
674
|
+
const headPath = `M 0 ${-h / 2} L 0 ${h / 2} Q ${w * 2.4} 0 0 ${-h / 2} Z`;
|
|
675
|
+
if (roughContext) {
|
|
676
|
+
const roughNode = roughContext.roughSvg.path(headPath, {
|
|
677
|
+
roughness: 1.5,
|
|
678
|
+
seed: roughContext.seed,
|
|
679
|
+
fill: roughContext.fillColor,
|
|
680
|
+
fillStyle: "hachure",
|
|
681
|
+
fillWeight: 2.5,
|
|
682
|
+
hachureGap: 5,
|
|
683
|
+
stroke: roughContext.lineColor,
|
|
684
|
+
strokeWidth: 2
|
|
685
|
+
});
|
|
686
|
+
headGroup.insert(() => roughNode, ":first-child").attr("class", "ishikawa-head");
|
|
687
|
+
} else {
|
|
688
|
+
headGroup.insert("path", ":first-child").attr("class", "ishikawa-head").attr("d", headPath);
|
|
689
|
+
}
|
|
690
|
+
textEl.attr("transform", `translate(${(w - tb.width) / 2 - tb.x + 3},${-tb.y - tb.height / 2})`);
|
|
691
|
+
}, "drawHead");
|
|
692
|
+
var flattenTree = /* @__PURE__ */ __name((children, direction) => {
|
|
693
|
+
const entries = [];
|
|
694
|
+
const yOrder = [];
|
|
695
|
+
const walk = /* @__PURE__ */ __name((nodes, pid, depth) => {
|
|
696
|
+
const ordered = direction === -1 ? [...nodes].reverse() : nodes;
|
|
697
|
+
for (const child of ordered) {
|
|
698
|
+
const idx = entries.length;
|
|
699
|
+
const gc = child.children ?? [];
|
|
700
|
+
entries.push({
|
|
701
|
+
depth,
|
|
702
|
+
text: wrapText(child.text, 15),
|
|
703
|
+
parentIndex: pid,
|
|
704
|
+
childCount: gc.length
|
|
705
|
+
});
|
|
706
|
+
if (depth % 2 === 0) {
|
|
707
|
+
yOrder.push(idx);
|
|
708
|
+
if (gc.length) {
|
|
709
|
+
walk(gc, idx, depth + 1);
|
|
710
|
+
}
|
|
711
|
+
} else {
|
|
712
|
+
if (gc.length) {
|
|
713
|
+
walk(gc, idx, depth + 1);
|
|
714
|
+
}
|
|
715
|
+
yOrder.push(idx);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}, "walk");
|
|
719
|
+
walk(children, -1, 2);
|
|
720
|
+
return { entries, yOrder };
|
|
721
|
+
}, "flattenTree");
|
|
722
|
+
var drawCauseLabel = /* @__PURE__ */ __name((svg, text, x, y, direction, fontSize, roughContext) => {
|
|
723
|
+
const lg = svg.append("g").attr("class", "ishikawa-label-group");
|
|
724
|
+
const lt = drawMultilineText(
|
|
725
|
+
lg,
|
|
726
|
+
text,
|
|
727
|
+
x,
|
|
728
|
+
y + 11 * direction,
|
|
729
|
+
"ishikawa-label cause",
|
|
730
|
+
"middle",
|
|
731
|
+
fontSize
|
|
732
|
+
);
|
|
733
|
+
const tb = lt.node().getBBox();
|
|
734
|
+
if (roughContext) {
|
|
735
|
+
const roughNode = roughContext.roughSvg.rectangle(
|
|
736
|
+
tb.x - 20,
|
|
737
|
+
tb.y - 2,
|
|
738
|
+
tb.width + 40,
|
|
739
|
+
tb.height + 4,
|
|
740
|
+
{
|
|
741
|
+
roughness: 1.5,
|
|
742
|
+
seed: roughContext.seed,
|
|
743
|
+
fill: roughContext.fillColor,
|
|
744
|
+
fillStyle: "hachure",
|
|
745
|
+
fillWeight: 2.5,
|
|
746
|
+
hachureGap: 5,
|
|
747
|
+
stroke: roughContext.lineColor,
|
|
748
|
+
strokeWidth: 2
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
lg.insert(() => roughNode, ":first-child").attr("class", "ishikawa-label-box");
|
|
752
|
+
} else {
|
|
753
|
+
lg.insert("rect", ":first-child").attr("class", "ishikawa-label-box").attr("x", tb.x - 20).attr("y", tb.y - 2).attr("width", tb.width + 40).attr("height", tb.height + 4);
|
|
754
|
+
}
|
|
755
|
+
}, "drawCauseLabel");
|
|
756
|
+
var drawArrowMarker = /* @__PURE__ */ __name((g, x, y, dx, dy, roughContext) => {
|
|
757
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
758
|
+
if (len === 0) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
const ux = dx / len;
|
|
762
|
+
const uy = dy / len;
|
|
763
|
+
const s = 6;
|
|
764
|
+
const px = -uy * s;
|
|
765
|
+
const py = ux * s;
|
|
766
|
+
const tipX = x;
|
|
767
|
+
const tipY = y;
|
|
768
|
+
const d = `M ${tipX} ${tipY} L ${tipX - ux * s * 2 + px} ${tipY - uy * s * 2 + py} L ${tipX - ux * s * 2 - px} ${tipY - uy * s * 2 - py} Z`;
|
|
769
|
+
const roughNode = roughContext.roughSvg.path(d, {
|
|
770
|
+
roughness: 1,
|
|
771
|
+
seed: roughContext.seed,
|
|
772
|
+
fill: roughContext.lineColor,
|
|
773
|
+
fillStyle: "solid",
|
|
774
|
+
stroke: roughContext.lineColor,
|
|
775
|
+
strokeWidth: 1
|
|
776
|
+
});
|
|
777
|
+
g.append(() => roughNode);
|
|
778
|
+
}, "drawArrowMarker");
|
|
779
|
+
var drawBranch = /* @__PURE__ */ __name((svg, node, startX, startY, direction, length, fontSize, roughContext) => {
|
|
780
|
+
const children = node.children ?? [];
|
|
781
|
+
const lineLen = length * (children.length ? 1 : 0.2);
|
|
782
|
+
const dx = -COS_A * lineLen;
|
|
783
|
+
const dy = SIN_A * lineLen * direction;
|
|
784
|
+
const endX = startX + dx;
|
|
785
|
+
const endY = startY + dy;
|
|
786
|
+
drawLine(svg, startX, startY, endX, endY, "ishikawa-branch", roughContext);
|
|
787
|
+
if (roughContext) {
|
|
788
|
+
drawArrowMarker(svg, startX, startY, startX - endX, startY - endY, roughContext);
|
|
789
|
+
}
|
|
790
|
+
drawCauseLabel(svg, node.text, endX, endY, direction, fontSize, roughContext);
|
|
791
|
+
if (!children.length) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
const { entries, yOrder } = flattenTree(children, direction);
|
|
795
|
+
const entryCount = entries.length;
|
|
796
|
+
const ys = new Array(entryCount);
|
|
797
|
+
for (const [slot, entryIdx] of yOrder.entries()) {
|
|
798
|
+
ys[entryIdx] = startY + dy * ((slot + 1) / (entryCount + 1));
|
|
799
|
+
}
|
|
800
|
+
const bones = /* @__PURE__ */ new Map();
|
|
801
|
+
bones.set(-1, {
|
|
802
|
+
x0: startX,
|
|
803
|
+
y0: startY,
|
|
804
|
+
x1: endX,
|
|
805
|
+
y1: endY,
|
|
806
|
+
childCount: children.length,
|
|
807
|
+
childrenDrawn: 0
|
|
808
|
+
});
|
|
809
|
+
const diagonalX = -COS_A;
|
|
810
|
+
const diagonalY = SIN_A * direction;
|
|
811
|
+
const oddLabel = direction < 0 ? "ishikawa-label up" : "ishikawa-label down";
|
|
812
|
+
for (const [i, e] of entries.entries()) {
|
|
813
|
+
const y = ys[i];
|
|
814
|
+
const par = bones.get(e.parentIndex);
|
|
815
|
+
const grp = svg.append("g").attr("class", "ishikawa-sub-group");
|
|
816
|
+
let bx0 = 0;
|
|
817
|
+
let by0 = 0;
|
|
818
|
+
let bx1 = 0;
|
|
819
|
+
if (e.depth % 2 === 0) {
|
|
820
|
+
const dyP = par.y1 - par.y0;
|
|
821
|
+
bx0 = lerp(par.x0, par.x1, dyP ? (y - par.y0) / dyP : 0.5);
|
|
822
|
+
by0 = y;
|
|
823
|
+
bx1 = bx0 - (e.childCount > 0 ? BONE_BASE + e.childCount * BONE_PER_CHILD : BONE_STUB);
|
|
824
|
+
drawLine(grp, bx0, y, bx1, y, "ishikawa-sub-branch", roughContext);
|
|
825
|
+
if (roughContext) {
|
|
826
|
+
drawArrowMarker(grp, bx0, y, 1, 0, roughContext);
|
|
827
|
+
}
|
|
828
|
+
drawMultilineText(grp, e.text, bx1, y, "ishikawa-label align", "end", fontSize);
|
|
829
|
+
} else {
|
|
830
|
+
const k = par.childrenDrawn++;
|
|
831
|
+
bx0 = lerp(par.x0, par.x1, (par.childCount - k) / (par.childCount + 1));
|
|
832
|
+
by0 = par.y0;
|
|
833
|
+
bx1 = bx0 + diagonalX * ((y - by0) / diagonalY);
|
|
834
|
+
drawLine(grp, bx0, by0, bx1, y, "ishikawa-sub-branch", roughContext);
|
|
835
|
+
if (roughContext) {
|
|
836
|
+
drawArrowMarker(grp, bx0, by0, bx0 - bx1, by0 - y, roughContext);
|
|
837
|
+
}
|
|
838
|
+
drawMultilineText(grp, e.text, bx1, y, oddLabel, "end", fontSize);
|
|
839
|
+
}
|
|
840
|
+
if (e.childCount > 0) {
|
|
841
|
+
bones.set(i, {
|
|
842
|
+
x0: bx0,
|
|
843
|
+
y0: by0,
|
|
844
|
+
x1: bx1,
|
|
845
|
+
y1: y,
|
|
846
|
+
childCount: e.childCount,
|
|
847
|
+
childrenDrawn: 0
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}, "drawBranch");
|
|
852
|
+
var splitLines = /* @__PURE__ */ __name((text) => text.split(/<br\s*\/?>|\n/), "splitLines");
|
|
853
|
+
var wrapText = /* @__PURE__ */ __name((text, maxChars) => {
|
|
854
|
+
if (text.length <= maxChars) {
|
|
855
|
+
return text;
|
|
856
|
+
}
|
|
857
|
+
const lines = [];
|
|
858
|
+
for (const word of text.split(/\s+/)) {
|
|
859
|
+
const last = lines.length - 1;
|
|
860
|
+
if (last >= 0 && lines[last].length + 1 + word.length <= maxChars) {
|
|
861
|
+
lines[last] += " " + word;
|
|
862
|
+
} else {
|
|
863
|
+
lines.push(word);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return lines.join("\n");
|
|
867
|
+
}, "wrapText");
|
|
868
|
+
var drawMultilineText = /* @__PURE__ */ __name((g, text, x, y, cls, anchor, fontSize) => {
|
|
869
|
+
const lines = splitLines(text);
|
|
870
|
+
const lh = fontSize * 1.05;
|
|
871
|
+
const el = g.append("text").attr("class", cls).attr("text-anchor", anchor).attr("x", x).attr("y", y - (lines.length - 1) * lh / 2);
|
|
872
|
+
for (const [i, line] of lines.entries()) {
|
|
873
|
+
el.append("tspan").attr("x", x).attr("dy", i === 0 ? 0 : lh).text(line);
|
|
874
|
+
}
|
|
875
|
+
return el;
|
|
876
|
+
}, "drawMultilineText");
|
|
877
|
+
var lerp = /* @__PURE__ */ __name((a, b, t) => a + (b - a) * t, "lerp");
|
|
878
|
+
var drawLine = /* @__PURE__ */ __name((g, x1, y1, x2, y2, cls, roughContext) => {
|
|
879
|
+
if (roughContext) {
|
|
880
|
+
const roughNode = roughContext.roughSvg.line(x1, y1, x2, y2, {
|
|
881
|
+
roughness: 1.5,
|
|
882
|
+
seed: roughContext.seed,
|
|
883
|
+
stroke: roughContext.lineColor,
|
|
884
|
+
strokeWidth: 2
|
|
885
|
+
});
|
|
886
|
+
g.append(() => roughNode).attr("class", cls);
|
|
887
|
+
return void 0;
|
|
888
|
+
}
|
|
889
|
+
return g.append("line").attr("class", cls).attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2);
|
|
890
|
+
}, "drawLine");
|
|
891
|
+
var renderer = { draw };
|
|
892
|
+
var getStyles = /* @__PURE__ */ __name((options) => `
|
|
893
|
+
.ishikawa .ishikawa-spine,
|
|
894
|
+
.ishikawa .ishikawa-branch,
|
|
895
|
+
.ishikawa .ishikawa-sub-branch {
|
|
896
|
+
stroke: ${options.lineColor};
|
|
897
|
+
stroke-width: 2;
|
|
898
|
+
fill: none;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.ishikawa .ishikawa-sub-branch {
|
|
902
|
+
stroke-width: 1;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.ishikawa .ishikawa-arrow {
|
|
906
|
+
fill: ${options.lineColor};
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
.ishikawa .ishikawa-head {
|
|
910
|
+
fill: ${options.mainBkg};
|
|
911
|
+
stroke: ${options.lineColor};
|
|
912
|
+
stroke-width: 2;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.ishikawa .ishikawa-label-box {
|
|
916
|
+
fill: ${options.mainBkg};
|
|
917
|
+
stroke: ${options.lineColor};
|
|
918
|
+
stroke-width: 2;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
.ishikawa text {
|
|
922
|
+
font-family: ${options.fontFamily};
|
|
923
|
+
font-size: ${options.fontSize};
|
|
924
|
+
fill: ${options.textColor};
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
.ishikawa .ishikawa-head-label {
|
|
928
|
+
font-weight: 600;
|
|
929
|
+
text-anchor: middle;
|
|
930
|
+
dominant-baseline: middle;
|
|
931
|
+
font-size: 14px;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
.ishikawa .ishikawa-label {
|
|
935
|
+
text-anchor: end;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
.ishikawa .ishikawa-label.cause {
|
|
939
|
+
text-anchor: middle;
|
|
940
|
+
dominant-baseline: middle;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
.ishikawa .ishikawa-label.align {
|
|
944
|
+
text-anchor: end;
|
|
945
|
+
dominant-baseline: middle;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
.ishikawa .ishikawa-label.up {
|
|
949
|
+
dominant-baseline: baseline;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
.ishikawa .ishikawa-label.down {
|
|
953
|
+
dominant-baseline: hanging;
|
|
954
|
+
}
|
|
955
|
+
`, "getStyles");
|
|
956
|
+
var ishikawaStyles_default = getStyles;
|
|
957
|
+
var diagram = {
|
|
958
|
+
parser: ishikawa_default,
|
|
959
|
+
get db() {
|
|
960
|
+
return new IshikawaDB();
|
|
961
|
+
},
|
|
962
|
+
renderer,
|
|
963
|
+
styles: ishikawaStyles_default
|
|
964
|
+
};
|
|
965
|
+
export {
|
|
966
|
+
diagram
|
|
967
|
+
};
|