markmap-view 0.15.5 → 0.15.6

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/dist/index.js CHANGED
@@ -1,352 +1,337 @@
1
- /*! markmap-view v0.15.5 | MIT License */
2
- import { Hook, getId, addClass, walkTree, childSelector, noop } from 'markmap-common';
3
- export { loadCSS, loadJS } from 'markmap-common';
4
- import { scaleOrdinal, schemeCategory10, zoomTransform, select, zoom, linkHorizontal, min, max, zoomIdentity, minIndex } from 'd3';
5
-
6
- function _extends() {
7
- _extends = Object.assign ? Object.assign.bind() : function (target) {
8
- for (var i = 1; i < arguments.length; i++) {
9
- var source = arguments[i];
10
- for (var key in source) {
11
- if (Object.prototype.hasOwnProperty.call(source, key)) {
12
- target[key] = source[key];
13
- }
14
- }
15
- }
16
- return target;
1
+ import { Hook as U, getId as at, addClass as lt, walkTree as M, childSelector as b, noop as A } from "markmap-common";
2
+ import { loadCSS as Ce, loadJS as we } from "markmap-common";
3
+ import { scaleOrdinal as G, schemeCategory10 as ct, zoomTransform as O, select as ht, zoom as dt, linkHorizontal as ut, min as I, max as W, zoomIdentity as pt, minIndex as ft } from "d3";
4
+ /*! @gera2ld/jsx-dom v2.2.2 | ISC License */
5
+ const Z = 1, J = 2, gt = "http://www.w3.org/2000/svg", H = "http://www.w3.org/1999/xlink", mt = {
6
+ show: H,
7
+ actuate: H,
8
+ href: H
9
+ }, xt = (e) => typeof e == "string" || typeof e == "number", yt = (e) => (e == null ? void 0 : e.vtype) === Z, St = (e) => (e == null ? void 0 : e.vtype) === J;
10
+ function N(e, t) {
11
+ let n;
12
+ if (typeof e == "string")
13
+ n = Z;
14
+ else if (typeof e == "function")
15
+ n = J;
16
+ else
17
+ throw new Error("Invalid VNode type");
18
+ return {
19
+ vtype: n,
20
+ type: e,
21
+ props: t
17
22
  };
18
- return _extends.apply(this, arguments);
19
- }
20
-
21
- function count(node) {
22
- var sum = 0,
23
- children = node.children,
24
- i = children && children.length;
25
- if (!i) sum = 1;else while (--i >= 0) sum += children[i].value;
26
- node.value = sum;
27
23
  }
28
- function node_count () {
29
- return this.eachAfter(count);
24
+ function vt(e) {
25
+ return e.children;
30
26
  }
31
-
32
- function node_each (callback) {
33
- var node = this,
34
- current,
35
- next = [node],
36
- children,
37
- i,
38
- n;
39
- do {
40
- current = next.reverse(), next = [];
41
- while (node = current.pop()) {
42
- callback(node), children = node.children;
43
- if (children) for (i = 0, n = children.length; i < n; ++i) {
44
- next.push(children[i]);
45
- }
46
- }
47
- } while (next.length);
48
- return this;
49
- }
50
-
51
- function node_eachBefore (callback) {
52
- var node = this,
53
- nodes = [node],
54
- children,
55
- i;
56
- while (node = nodes.pop()) {
57
- callback(node), children = node.children;
58
- if (children) for (i = children.length - 1; i >= 0; --i) {
59
- nodes.push(children[i]);
60
- }
27
+ const zt = {
28
+ isSvg: !1
29
+ };
30
+ function V(e, t) {
31
+ Array.isArray(t) || (t = [t]), t = t.filter(Boolean), t.length && e.append(...t);
32
+ }
33
+ function kt(e, t, n) {
34
+ for (const i in t)
35
+ if (!(i === "key" || i === "children" || i === "ref"))
36
+ if (i === "dangerouslySetInnerHTML")
37
+ e.innerHTML = t[i].__html;
38
+ else if (i === "innerHTML" || i === "textContent" || i === "innerText" || i === "value" && ["textarea", "select"].includes(e.tagName)) {
39
+ const r = t[i];
40
+ r != null && (e[i] = r);
41
+ } else
42
+ i.startsWith("on") ? e[i.toLowerCase()] = t[i] : Et(e, i, t[i], n.isSvg);
43
+ }
44
+ const bt = {
45
+ className: "class",
46
+ labelFor: "for"
47
+ };
48
+ function Et(e, t, n, i) {
49
+ if (t = bt[t] || t, n === !0)
50
+ e.setAttribute(t, "");
51
+ else if (n === !1)
52
+ e.removeAttribute(t);
53
+ else {
54
+ const r = i ? mt[t] : void 0;
55
+ r !== void 0 ? e.setAttributeNS(r, t, n) : e.setAttribute(t, n);
61
56
  }
62
- return this;
63
57
  }
64
-
65
- function node_eachAfter (callback) {
66
- var node = this,
67
- nodes = [node],
68
- next = [],
69
- children,
70
- i,
71
- n;
72
- while (node = nodes.pop()) {
73
- next.push(node), children = node.children;
74
- if (children) for (i = 0, n = children.length; i < n; ++i) {
75
- nodes.push(children[i]);
76
- }
77
- }
78
- while (node = next.pop()) {
79
- callback(node);
80
- }
81
- return this;
58
+ function Ct(e) {
59
+ return e.reduce((t, n) => t.concat(n), []);
82
60
  }
83
-
84
- function node_sum (value) {
85
- return this.eachAfter(function (node) {
86
- var sum = +value(node.data) || 0,
87
- children = node.children,
88
- i = children && children.length;
89
- while (--i >= 0) sum += children[i].value;
90
- node.value = sum;
91
- });
61
+ function D(e, t) {
62
+ return Array.isArray(e) ? Ct(e.map((n) => D(n, t))) : _(e, t);
92
63
  }
93
-
94
- function node_sort (compare) {
95
- return this.eachBefore(function (node) {
96
- if (node.children) {
97
- node.children.sort(compare);
64
+ function _(e, t = zt) {
65
+ if (e == null || typeof e == "boolean")
66
+ return null;
67
+ if (e instanceof Node)
68
+ return e;
69
+ if (St(e)) {
70
+ const {
71
+ type: n,
72
+ props: i
73
+ } = e;
74
+ if (n === vt) {
75
+ const a = document.createDocumentFragment();
76
+ if (i.children) {
77
+ const c = D(i.children, t);
78
+ V(a, c);
79
+ }
80
+ return a;
98
81
  }
99
- });
100
- }
101
-
102
- function node_path (end) {
103
- var start = this,
104
- ancestor = leastCommonAncestor(start, end),
105
- nodes = [start];
106
- while (start !== ancestor) {
107
- start = start.parent;
108
- nodes.push(start);
109
- }
110
- var k = nodes.length;
111
- while (end !== ancestor) {
112
- nodes.splice(k, 0, end);
113
- end = end.parent;
114
- }
115
- return nodes;
116
- }
117
- function leastCommonAncestor(a, b) {
118
- if (a === b) return a;
119
- var aNodes = a.ancestors(),
120
- bNodes = b.ancestors(),
121
- c = null;
122
- a = aNodes.pop();
123
- b = bNodes.pop();
124
- while (a === b) {
125
- c = a;
126
- a = aNodes.pop();
127
- b = bNodes.pop();
82
+ const r = n(i);
83
+ return _(r, t);
128
84
  }
129
- return c;
85
+ if (xt(e))
86
+ return document.createTextNode(`${e}`);
87
+ if (yt(e)) {
88
+ let n;
89
+ const {
90
+ type: i,
91
+ props: r
92
+ } = e;
93
+ if (!t.isSvg && i === "svg" && (t = Object.assign({}, t, {
94
+ isSvg: !0
95
+ })), t.isSvg ? n = document.createElementNS(gt, i) : n = document.createElement(i), kt(n, r, t), r.children) {
96
+ let c = t;
97
+ t.isSvg && i === "foreignObject" && (c = Object.assign({}, c, {
98
+ isSvg: !1
99
+ }));
100
+ const s = D(r.children, c);
101
+ s != null && V(n, s);
102
+ }
103
+ const {
104
+ ref: a
105
+ } = r;
106
+ return typeof a == "function" && a(n), n;
107
+ }
108
+ throw new Error("mount: Invalid Vnode!");
109
+ }
110
+ function $(e) {
111
+ return _(e);
112
+ }
113
+ function wt(e) {
114
+ var t = 0, n = e.children, i = n && n.length;
115
+ if (!i)
116
+ t = 1;
117
+ else
118
+ for (; --i >= 0; )
119
+ t += n[i].value;
120
+ e.value = t;
121
+ }
122
+ function Xt() {
123
+ return this.eachAfter(wt);
124
+ }
125
+ function jt(e) {
126
+ var t = this, n, i = [t], r, a, c;
127
+ do
128
+ for (n = i.reverse(), i = []; t = n.pop(); )
129
+ if (e(t), r = t.children, r)
130
+ for (a = 0, c = r.length; a < c; ++a)
131
+ i.push(r[a]);
132
+ while (i.length);
133
+ return this;
130
134
  }
131
-
132
- function node_ancestors () {
133
- var node = this,
134
- nodes = [node];
135
- while (node = node.parent) {
136
- nodes.push(node);
137
- }
138
- return nodes;
135
+ function Nt(e) {
136
+ for (var t = this, n = [t], i, r; t = n.pop(); )
137
+ if (e(t), i = t.children, i)
138
+ for (r = i.length - 1; r >= 0; --r)
139
+ n.push(i[r]);
140
+ return this;
139
141
  }
140
-
141
- function node_descendants () {
142
- var nodes = [];
143
- this.each(function (node) {
144
- nodes.push(node);
145
- });
146
- return nodes;
142
+ function Rt(e) {
143
+ for (var t = this, n = [t], i = [], r, a, c; t = n.pop(); )
144
+ if (i.push(t), r = t.children, r)
145
+ for (a = 0, c = r.length; a < c; ++a)
146
+ n.push(r[a]);
147
+ for (; t = i.pop(); )
148
+ e(t);
149
+ return this;
147
150
  }
148
-
149
- function node_leaves () {
150
- var leaves = [];
151
- this.eachBefore(function (node) {
152
- if (!node.children) {
153
- leaves.push(node);
154
- }
151
+ function Tt(e) {
152
+ return this.eachAfter(function(t) {
153
+ for (var n = +e(t.data) || 0, i = t.children, r = i && i.length; --r >= 0; )
154
+ n += i[r].value;
155
+ t.value = n;
155
156
  });
156
- return leaves;
157
157
  }
158
-
159
- function node_links () {
160
- var root = this,
161
- links = [];
162
- root.each(function (node) {
163
- if (node !== root) {
164
- // Don’t include the root’s parent, if any.
165
- links.push({
166
- source: node.parent,
167
- target: node
168
- });
169
- }
158
+ function Mt(e) {
159
+ return this.eachBefore(function(t) {
160
+ t.children && t.children.sort(e);
170
161
  });
171
- return links;
172
- }
173
-
174
- function hierarchy(data, children) {
175
- var root = new Node$1(data),
176
- valued = +data.value && (root.value = data.value),
177
- node,
178
- nodes = [root],
179
- child,
180
- childs,
181
- i,
182
- n;
183
- if (children == null) children = defaultChildren;
184
- while (node = nodes.pop()) {
185
- if (valued) node.value = +node.data.value;
186
- if ((childs = children(node.data)) && (n = childs.length)) {
187
- node.children = new Array(n);
188
- for (i = n - 1; i >= 0; --i) {
189
- nodes.push(child = node.children[i] = new Node$1(childs[i]));
190
- child.parent = node;
191
- child.depth = node.depth + 1;
192
- }
193
- }
194
- }
195
- return root.eachBefore(computeHeight);
196
- }
197
- function node_copy() {
198
- return hierarchy(this).eachBefore(copyData);
199
162
  }
200
- function defaultChildren(d) {
201
- return d.children;
202
- }
203
- function copyData(node) {
204
- node.data = node.data.data;
205
- }
206
- function computeHeight(node) {
207
- var height = 0;
208
- do node.height = height; while ((node = node.parent) && node.height < ++height);
209
- }
210
- function Node$1(data) {
211
- this.data = data;
212
- this.depth = this.height = 0;
213
- this.parent = null;
214
- }
215
- Node$1.prototype = hierarchy.prototype = {
216
- constructor: Node$1,
217
- count: node_count,
218
- each: node_each,
219
- eachAfter: node_eachAfter,
220
- eachBefore: node_eachBefore,
221
- sum: node_sum,
222
- sort: node_sort,
223
- path: node_path,
224
- ancestors: node_ancestors,
225
- descendants: node_descendants,
226
- leaves: node_leaves,
227
- links: node_links,
228
- copy: node_copy
229
- };
230
-
231
- var name = "d3-flextree";
232
- var version$1 = "2.1.2";
233
- var main = "build/d3-flextree.js";
234
- var module = "index";
235
- var author = {
236
- name: "Chris Maloney",
237
- url: "http://chrismaloney.org"
238
- };
239
- var description = "Flexible tree layout algorithm that allows for variable node sizes.";
240
- var keywords = [
241
- "d3",
242
- "d3-module",
243
- "layout",
244
- "tree",
245
- "hierarchy",
246
- "d3-hierarchy",
247
- "plugin",
248
- "d3-plugin",
249
- "infovis",
250
- "visualization",
251
- "2d"
252
- ];
253
- var homepage = "https://github.com/klortho/d3-flextree";
254
- var license = "WTFPL";
255
- var repository = {
256
- type: "git",
257
- url: "https://github.com/klortho/d3-flextree.git"
163
+ function At(e) {
164
+ for (var t = this, n = Ot(t, e), i = [t]; t !== n; )
165
+ t = t.parent, i.push(t);
166
+ for (var r = i.length; e !== n; )
167
+ i.splice(r, 0, e), e = e.parent;
168
+ return i;
169
+ }
170
+ function Ot(e, t) {
171
+ if (e === t)
172
+ return e;
173
+ var n = e.ancestors(), i = t.ancestors(), r = null;
174
+ for (e = n.pop(), t = i.pop(); e === t; )
175
+ r = e, e = n.pop(), t = i.pop();
176
+ return r;
177
+ }
178
+ function Ht() {
179
+ for (var e = this, t = [e]; e = e.parent; )
180
+ t.push(e);
181
+ return t;
182
+ }
183
+ function $t() {
184
+ var e = [];
185
+ return this.each(function(t) {
186
+ e.push(t);
187
+ }), e;
188
+ }
189
+ function Bt() {
190
+ var e = [];
191
+ return this.eachBefore(function(t) {
192
+ t.children || e.push(t);
193
+ }), e;
194
+ }
195
+ function Dt() {
196
+ var e = this, t = [];
197
+ return e.each(function(n) {
198
+ n !== e && t.push({ source: n.parent, target: n });
199
+ }), t;
200
+ }
201
+ function L(e, t) {
202
+ var n = new R(e), i = +e.value && (n.value = e.value), r, a = [n], c, s, l, f;
203
+ for (t == null && (t = _t); r = a.pop(); )
204
+ if (i && (r.value = +r.data.value), (s = t(r.data)) && (f = s.length))
205
+ for (r.children = new Array(f), l = f - 1; l >= 0; --l)
206
+ a.push(c = r.children[l] = new R(s[l])), c.parent = r, c.depth = r.depth + 1;
207
+ return n.eachBefore(It);
208
+ }
209
+ function Ft() {
210
+ return L(this).eachBefore(Lt);
211
+ }
212
+ function _t(e) {
213
+ return e.children;
214
+ }
215
+ function Lt(e) {
216
+ e.data = e.data.data;
217
+ }
218
+ function It(e) {
219
+ var t = 0;
220
+ do
221
+ e.height = t;
222
+ while ((e = e.parent) && e.height < ++t);
223
+ }
224
+ function R(e) {
225
+ this.data = e, this.depth = this.height = 0, this.parent = null;
226
+ }
227
+ R.prototype = L.prototype = {
228
+ constructor: R,
229
+ count: Xt,
230
+ each: jt,
231
+ eachAfter: Rt,
232
+ eachBefore: Nt,
233
+ sum: Tt,
234
+ sort: Mt,
235
+ path: At,
236
+ ancestors: Ht,
237
+ descendants: $t,
238
+ leaves: Bt,
239
+ links: Dt,
240
+ copy: Ft
258
241
  };
259
- var scripts = {
260
- clean: "rm -rf build demo test",
261
- "build:demo": "rollup -c --environment BUILD:demo",
262
- "build:dev": "rollup -c --environment BUILD:dev",
263
- "build:prod": "rollup -c --environment BUILD:prod",
264
- "build:test": "rollup -c --environment BUILD:test",
265
- build: "rollup -c",
266
- lint: "eslint index.js src",
267
- "test:main": "node test/bundle.js",
268
- "test:browser": "node test/browser-tests.js",
269
- test: "npm-run-all test:*",
270
- prepare: "npm-run-all clean build lint test"
271
- };
272
- var dependencies = {
273
- "d3-hierarchy": "^1.1.5"
274
- };
275
- var devDependencies = {
276
- "babel-plugin-external-helpers": "^6.22.0",
277
- "babel-preset-es2015-rollup": "^3.0.0",
278
- d3: "^4.13.0",
279
- "d3-selection-multi": "^1.0.1",
280
- eslint: "^4.19.1",
281
- jsdom: "^11.6.2",
282
- "npm-run-all": "^4.1.2",
283
- rollup: "^0.55.3",
284
- "rollup-plugin-babel": "^2.7.1",
285
- "rollup-plugin-commonjs": "^8.0.2",
286
- "rollup-plugin-copy": "^0.2.3",
287
- "rollup-plugin-json": "^2.3.0",
288
- "rollup-plugin-node-resolve": "^3.0.2",
289
- "rollup-plugin-uglify": "^3.0.0",
290
- "uglify-es": "^3.3.9"
291
- };
292
- var packageInfo = {
293
- name: name,
294
- version: version$1,
295
- main: main,
296
- module: module,
297
- "jsnext:main": "index",
298
- author: author,
299
- description: description,
300
- keywords: keywords,
301
- homepage: homepage,
302
- license: license,
303
- repository: repository,
304
- scripts: scripts,
305
- dependencies: dependencies,
306
- devDependencies: devDependencies
307
- };
308
-
309
- const {
310
- version
311
- } = packageInfo;
312
- const defaults = Object.freeze({
313
- children: data => data.children,
314
- nodeSize: node => node.data.size,
242
+ const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index", Pt = {
243
+ name: "Chris Maloney",
244
+ url: "http://chrismaloney.org"
245
+ }, Ut = "Flexible tree layout algorithm that allows for variable node sizes.", Gt = [
246
+ "d3",
247
+ "d3-module",
248
+ "layout",
249
+ "tree",
250
+ "hierarchy",
251
+ "d3-hierarchy",
252
+ "plugin",
253
+ "d3-plugin",
254
+ "infovis",
255
+ "visualization",
256
+ "2d"
257
+ ], Zt = "https://github.com/klortho/d3-flextree", Jt = "WTFPL", qt = {
258
+ type: "git",
259
+ url: "https://github.com/klortho/d3-flextree.git"
260
+ }, Qt = {
261
+ clean: "rm -rf build demo test",
262
+ "build:demo": "rollup -c --environment BUILD:demo",
263
+ "build:dev": "rollup -c --environment BUILD:dev",
264
+ "build:prod": "rollup -c --environment BUILD:prod",
265
+ "build:test": "rollup -c --environment BUILD:test",
266
+ build: "rollup -c",
267
+ lint: "eslint index.js src",
268
+ "test:main": "node test/bundle.js",
269
+ "test:browser": "node test/browser-tests.js",
270
+ test: "npm-run-all test:*",
271
+ prepare: "npm-run-all clean build lint test"
272
+ }, te = {
273
+ "d3-hierarchy": "^1.1.5"
274
+ }, ee = {
275
+ "babel-plugin-external-helpers": "^6.22.0",
276
+ "babel-preset-es2015-rollup": "^3.0.0",
277
+ d3: "^4.13.0",
278
+ "d3-selection-multi": "^1.0.1",
279
+ eslint: "^4.19.1",
280
+ jsdom: "^11.6.2",
281
+ "npm-run-all": "^4.1.2",
282
+ rollup: "^0.55.3",
283
+ "rollup-plugin-babel": "^2.7.1",
284
+ "rollup-plugin-commonjs": "^8.0.2",
285
+ "rollup-plugin-copy": "^0.2.3",
286
+ "rollup-plugin-json": "^2.3.0",
287
+ "rollup-plugin-node-resolve": "^3.0.2",
288
+ "rollup-plugin-uglify": "^3.0.0",
289
+ "uglify-es": "^3.3.9"
290
+ }, ne = {
291
+ name: Wt,
292
+ version: Vt,
293
+ main: Yt,
294
+ module: Kt,
295
+ "jsnext:main": "index",
296
+ author: Pt,
297
+ description: Ut,
298
+ keywords: Gt,
299
+ homepage: Zt,
300
+ license: Jt,
301
+ repository: qt,
302
+ scripts: Qt,
303
+ dependencies: te,
304
+ devDependencies: ee
305
+ }, { version: ie } = ne, oe = Object.freeze({
306
+ children: (e) => e.children,
307
+ nodeSize: (e) => e.data.size,
315
308
  spacing: 0
316
309
  });
317
-
318
- // Create a layout function with customizable options. Per D3-style, the
319
- // options can be set at any time using setter methods. The layout function
320
- // will compute the tree node positions based on the options in effect at the
321
- // time it is called.
322
- function flextree(options) {
323
- const opts = Object.assign({}, defaults, options);
324
- function accessor(name) {
325
- const opt = opts[name];
326
- return typeof opt === 'function' ? opt : () => opt;
327
- }
328
- function layout(tree) {
329
- const wtree = wrap(getWrapper(), tree, node => node.children);
330
- wtree.update();
331
- return wtree.data;
332
- }
333
- function getFlexNode() {
334
- const nodeSize = accessor('nodeSize');
335
- const spacing = accessor('spacing');
336
- return class FlexNode extends hierarchy.prototype.constructor {
337
- constructor(data) {
338
- super(data);
310
+ function Q(e) {
311
+ const t = Object.assign({}, oe, e);
312
+ function n(s) {
313
+ const l = t[s];
314
+ return typeof l == "function" ? l : () => l;
315
+ }
316
+ function i(s) {
317
+ const l = c(a(), s, (f) => f.children);
318
+ return l.update(), l.data;
319
+ }
320
+ function r() {
321
+ const s = n("nodeSize"), l = n("spacing");
322
+ return class q extends L.prototype.constructor {
323
+ constructor(h) {
324
+ super(h);
339
325
  }
340
326
  copy() {
341
- const c = wrap(this.constructor, this, node => node.children);
342
- c.each(node => node.data = node.data.data);
343
- return c;
327
+ const h = c(this.constructor, this, (p) => p.children);
328
+ return h.each((p) => p.data = p.data.data), h;
344
329
  }
345
330
  get size() {
346
- return nodeSize(this);
331
+ return s(this);
347
332
  }
348
- spacing(oNode) {
349
- return spacing(this, oNode);
333
+ spacing(h) {
334
+ return l(this, h);
350
335
  }
351
336
  get nodes() {
352
337
  return this.descendants();
@@ -370,8 +355,8 @@ function flextree(options) {
370
355
  return this.x + this.xSize / 2;
371
356
  }
372
357
  get root() {
373
- const ancs = this.ancestors();
374
- return ancs[ancs.length - 1];
358
+ const h = this.ancestors();
359
+ return h[h.length - 1];
375
360
  }
376
361
  get numChildren() {
377
362
  return this.hasChildren ? this.children.length : 0;
@@ -389,7 +374,10 @@ function flextree(options) {
389
374
  return this.hasChildren ? this.children[this.numChildren - 1] : null;
390
375
  }
391
376
  get extents() {
392
- return (this.children || []).reduce((acc, kid) => FlexNode.maxExtents(acc, kid.extents), this.nodeExtents);
377
+ return (this.children || []).reduce(
378
+ (h, p) => q.maxExtents(h, p.extents),
379
+ this.nodeExtents
380
+ );
393
381
  }
394
382
  get nodeExtents() {
395
383
  return {
@@ -399,24 +387,21 @@ function flextree(options) {
399
387
  right: this.right
400
388
  };
401
389
  }
402
- static maxExtents(e0, e1) {
390
+ static maxExtents(h, p) {
403
391
  return {
404
- top: Math.min(e0.top, e1.top),
405
- bottom: Math.max(e0.bottom, e1.bottom),
406
- left: Math.min(e0.left, e1.left),
407
- right: Math.max(e0.right, e1.right)
392
+ top: Math.min(h.top, p.top),
393
+ bottom: Math.max(h.bottom, p.bottom),
394
+ left: Math.min(h.left, p.left),
395
+ right: Math.max(h.right, p.right)
408
396
  };
409
397
  }
410
398
  };
411
399
  }
412
- function getWrapper() {
413
- const FlexNode = getFlexNode();
414
- const nodeSize = accessor('nodeSize');
415
- const spacing = accessor('spacing');
416
- return class extends FlexNode {
417
- constructor(data) {
418
- super(data);
419
- Object.assign(this, {
400
+ function a() {
401
+ const s = r(), l = n("nodeSize"), f = n("spacing");
402
+ return class extends s {
403
+ constructor(h) {
404
+ super(h), Object.assign(this, {
420
405
  x: 0,
421
406
  y: 0,
422
407
  relX: 0,
@@ -432,866 +417,501 @@ function flextree(options) {
432
417
  });
433
418
  }
434
419
  get size() {
435
- return nodeSize(this.data);
420
+ return l(this.data);
436
421
  }
437
- spacing(oNode) {
438
- return spacing(this.data, oNode.data);
422
+ spacing(h) {
423
+ return f(this.data, h.data);
439
424
  }
440
425
  get x() {
441
426
  return this.data.x;
442
427
  }
443
- set x(v) {
444
- this.data.x = v;
428
+ set x(h) {
429
+ this.data.x = h;
445
430
  }
446
431
  get y() {
447
432
  return this.data.y;
448
433
  }
449
- set y(v) {
450
- this.data.y = v;
434
+ set y(h) {
435
+ this.data.y = h;
451
436
  }
452
437
  update() {
453
- layoutChildren(this);
454
- resolveX(this);
455
- return this;
438
+ return tt(this), et(this), this;
456
439
  }
457
440
  };
458
441
  }
459
- function wrap(FlexClass, treeData, children) {
460
- const _wrap = (data, parent) => {
461
- const node = new FlexClass(data);
462
- Object.assign(node, {
463
- parent,
464
- depth: parent === null ? 0 : parent.depth + 1,
442
+ function c(s, l, f) {
443
+ const h = (p, m) => {
444
+ const d = new s(p);
445
+ Object.assign(d, {
446
+ parent: m,
447
+ depth: m === null ? 0 : m.depth + 1,
465
448
  height: 0,
466
449
  length: 1
467
450
  });
468
- const kidsData = children(data) || [];
469
- node.children = kidsData.length === 0 ? null : kidsData.map(kd => _wrap(kd, node));
470
- if (node.children) {
471
- Object.assign(node, node.children.reduce((hl, kid) => ({
472
- height: Math.max(hl.height, kid.height + 1),
473
- length: hl.length + kid.length
474
- }), node));
475
- }
476
- return node;
451
+ const S = f(p) || [];
452
+ return d.children = S.length === 0 ? null : S.map((x) => h(x, d)), d.children && Object.assign(d, d.children.reduce(
453
+ (x, g) => ({
454
+ height: Math.max(x.height, g.height + 1),
455
+ length: x.length + g.length
456
+ }),
457
+ d
458
+ )), d;
477
459
  };
478
- return _wrap(treeData, null);
460
+ return h(l, null);
479
461
  }
480
- Object.assign(layout, {
481
- nodeSize(arg) {
482
- return arguments.length ? (opts.nodeSize = arg, layout) : opts.nodeSize;
462
+ return Object.assign(i, {
463
+ nodeSize(s) {
464
+ return arguments.length ? (t.nodeSize = s, i) : t.nodeSize;
483
465
  },
484
- spacing(arg) {
485
- return arguments.length ? (opts.spacing = arg, layout) : opts.spacing;
466
+ spacing(s) {
467
+ return arguments.length ? (t.spacing = s, i) : t.spacing;
486
468
  },
487
- children(arg) {
488
- return arguments.length ? (opts.children = arg, layout) : opts.children;
469
+ children(s) {
470
+ return arguments.length ? (t.children = s, i) : t.children;
489
471
  },
490
- hierarchy(treeData, children) {
491
- const kids = typeof children === 'undefined' ? opts.children : children;
492
- return wrap(getFlexNode(), treeData, kids);
472
+ hierarchy(s, l) {
473
+ const f = typeof l > "u" ? t.children : l;
474
+ return c(r(), s, f);
493
475
  },
494
- dump(tree) {
495
- const nodeSize = accessor('nodeSize');
496
- const _dump = i0 => node => {
497
- const i1 = i0 + ' ';
498
- const i2 = i0 + ' ';
499
- const {
500
- x,
501
- y
502
- } = node;
503
- const size = nodeSize(node);
504
- const kids = node.children || [];
505
- const kdumps = kids.length === 0 ? ' ' : `,${i1}children: [${i2}${kids.map(_dump(i2)).join(i2)}${i1}],${i0}`;
506
- return `{ size: [${size.join(', ')}],${i1}x: ${x}, y: ${y}${kdumps}},`;
476
+ dump(s) {
477
+ const l = n("nodeSize"), f = (h) => (p) => {
478
+ const m = h + " ", d = h + " ", { x: S, y: x } = p, g = l(p), y = p.children || [], v = y.length === 0 ? " " : `,${m}children: [${d}${y.map(f(d)).join(d)}${m}],${h}`;
479
+ return `{ size: [${g.join(", ")}],${m}x: ${S}, y: ${x}${v}},`;
507
480
  };
508
- return _dump('\n')(tree);
481
+ return f(`
482
+ `)(s);
509
483
  }
510
- });
511
- return layout;
512
- }
513
- flextree.version = version;
514
- const layoutChildren = (w, y = 0) => {
515
- w.y = y;
516
- (w.children || []).reduce((acc, kid) => {
517
- const [i, lastLows] = acc;
518
- layoutChildren(kid, w.y + w.ySize);
519
- // The lowest vertical coordinate while extreme nodes still point
520
- // in current subtree.
521
- const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom;
522
- if (i !== 0) separate(w, i, lastLows);
523
- const lows = updateLows(lowY, i, lastLows);
524
- return [i + 1, lows];
525
- }, [0, null]);
526
- shiftChange(w);
527
- positionRoot(w);
528
- return w;
529
- };
530
-
531
- // Resolves the relative coordinate properties - relX and prelim --
532
- // to set the final, absolute x coordinate for each node. This also sets
533
- // `prelim` to 0, so that `relX` for each node is its x-coordinate relative
534
- // to its parent.
535
- const resolveX = (w, prevSum, parentX) => {
536
- // A call to resolveX without arguments is assumed to be for the root of
537
- // the tree. This will set the root's x-coord to zero.
538
- if (typeof prevSum === 'undefined') {
539
- prevSum = -w.relX - w.prelim;
540
- parentX = 0;
541
- }
542
- const sum = prevSum + w.relX;
543
- w.relX = sum + w.prelim - parentX;
544
- w.prelim = 0;
545
- w.x = parentX + w.relX;
546
- (w.children || []).forEach(k => resolveX(k, sum, w.x));
547
- return w;
548
- };
549
-
550
- // Process shift and change for all children, to add intermediate spacing to
551
- // each child's modifier.
552
- const shiftChange = w => {
553
- (w.children || []).reduce((acc, child) => {
554
- const [lastShiftSum, lastChangeSum] = acc;
555
- const shiftSum = lastShiftSum + child.shift;
556
- const changeSum = lastChangeSum + shiftSum + child.change;
557
- child.relX += changeSum;
558
- return [shiftSum, changeSum];
484
+ }), i;
485
+ }
486
+ Q.version = ie;
487
+ const tt = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
488
+ const [r, a] = n;
489
+ tt(i, e.y + e.ySize);
490
+ const c = (r === 0 ? i.lExt : i.rExt).bottom;
491
+ r !== 0 && se(e, r, a);
492
+ const s = fe(c, r, a);
493
+ return [r + 1, s];
494
+ }, [0, null]), re(e), pe(e), e), et = (e, t, n) => {
495
+ typeof t > "u" && (t = -e.relX - e.prelim, n = 0);
496
+ const i = t + e.relX;
497
+ return e.relX = i + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((r) => et(r, i, e.x)), e;
498
+ }, re = (e) => {
499
+ (e.children || []).reduce((t, n) => {
500
+ const [i, r] = t, a = i + n.shift, c = r + a + n.change;
501
+ return n.relX += c, [a, c];
559
502
  }, [0, 0]);
560
- };
561
-
562
- // Separates the latest child from its previous sibling
563
- /* eslint-disable complexity */
564
- const separate = (w, i, lows) => {
565
- const lSib = w.children[i - 1];
566
- const curSubtree = w.children[i];
567
- let rContour = lSib;
568
- let rSumMods = lSib.relX;
569
- let lContour = curSubtree;
570
- let lSumMods = curSubtree.relX;
571
- let isFirst = true;
572
- while (rContour && lContour) {
573
- if (rContour.bottom > lows.lowY) lows = lows.next;
574
- // How far to the left of the right side of rContour is the left side
575
- // of lContour? First compute the center-to-center distance, then add
576
- // the "spacing"
577
- const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour);
578
- if (dist > 0 || dist < 0 && isFirst) {
579
- lSumMods += dist;
580
- // Move subtree by changing relX.
581
- moveSubtree(curSubtree, dist);
582
- distributeExtra(w, i, lows.index, dist);
583
- }
584
- isFirst = false;
585
- // Advance highest node(s) and sum(s) of modifiers
586
- const rightBottom = rContour.bottom;
587
- const leftBottom = lContour.bottom;
588
- if (rightBottom <= leftBottom) {
589
- rContour = nextRContour(rContour);
590
- if (rContour) rSumMods += rContour.relX;
591
- }
592
- if (rightBottom >= leftBottom) {
593
- lContour = nextLContour(lContour);
594
- if (lContour) lSumMods += lContour.relX;
595
- }
596
- }
597
- // Set threads and update extreme nodes. In the first case, the
598
- // current subtree is taller than the left siblings.
599
- if (!rContour && lContour) setLThr(w, i, lContour, lSumMods);
600
- // In the next case, the left siblings are taller than the current subtree
601
- else if (rContour && !lContour) setRThr(w, i, rContour, rSumMods);
602
- };
603
- /* eslint-enable complexity */
604
-
605
- // Move subtree by changing relX.
606
- const moveSubtree = (subtree, distance) => {
607
- subtree.relX += distance;
608
- subtree.lExtRelX += distance;
609
- subtree.rExtRelX += distance;
610
- };
611
- const distributeExtra = (w, curSubtreeI, leftSibI, dist) => {
612
- const curSubtree = w.children[curSubtreeI];
613
- const n = curSubtreeI - leftSibI;
614
- // Are there intermediate children?
615
- if (n > 1) {
616
- const delta = dist / n;
617
- w.children[leftSibI + 1].shift += delta;
618
- curSubtree.shift -= delta;
619
- curSubtree.change -= dist - delta;
620
- }
621
- };
622
- const nextLContour = w => {
623
- return w.hasChildren ? w.firstChild : w.lThr;
624
- };
625
- const nextRContour = w => {
626
- return w.hasChildren ? w.lastChild : w.rThr;
627
- };
628
- const setLThr = (w, i, lContour, lSumMods) => {
629
- const firstChild = w.firstChild;
630
- const lExt = firstChild.lExt;
631
- const curSubtree = w.children[i];
632
- lExt.lThr = lContour;
633
- // Change relX so that the sum of modifier after following thread is correct.
634
- const diff = lSumMods - lContour.relX - firstChild.lExtRelX;
635
- lExt.relX += diff;
636
- // Change preliminary x coordinate so that the node does not move.
637
- lExt.prelim -= diff;
638
- // Update extreme node and its sum of modifiers.
639
- firstChild.lExt = curSubtree.lExt;
640
- firstChild.lExtRelX = curSubtree.lExtRelX;
641
- };
642
-
643
- // Mirror image of setLThr.
644
- const setRThr = (w, i, rContour, rSumMods) => {
645
- const curSubtree = w.children[i];
646
- const rExt = curSubtree.rExt;
647
- const lSib = w.children[i - 1];
648
- rExt.rThr = rContour;
649
- const diff = rSumMods - rContour.relX - curSubtree.rExtRelX;
650
- rExt.relX += diff;
651
- rExt.prelim -= diff;
652
- curSubtree.rExt = lSib.rExt;
653
- curSubtree.rExtRelX = lSib.rExtRelX;
654
- };
655
-
656
- // Position root between children, taking into account their modifiers
657
- const positionRoot = w => {
658
- if (w.hasChildren) {
659
- const k0 = w.firstChild;
660
- const kf = w.lastChild;
661
- const prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2;
662
- Object.assign(w, {
663
- prelim,
664
- lExt: k0.lExt,
665
- lExtRelX: k0.lExtRelX,
666
- rExt: kf.rExt,
667
- rExtRelX: kf.rExtRelX
503
+ }, se = (e, t, n) => {
504
+ const i = e.children[t - 1], r = e.children[t];
505
+ let a = i, c = i.relX, s = r, l = r.relX, f = !0;
506
+ for (; a && s; ) {
507
+ a.bottom > n.lowY && (n = n.next);
508
+ const h = c + a.prelim - (l + s.prelim) + a.xSize / 2 + s.xSize / 2 + a.spacing(s);
509
+ (h > 0 || h < 0 && f) && (l += h, ae(r, h), le(e, t, n.index, h)), f = !1;
510
+ const p = a.bottom, m = s.bottom;
511
+ p <= m && (a = he(a), a && (c += a.relX)), p >= m && (s = ce(s), s && (l += s.relX));
512
+ }
513
+ !a && s ? de(e, t, s, l) : a && !s && ue(e, t, a, c);
514
+ }, ae = (e, t) => {
515
+ e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
516
+ }, le = (e, t, n, i) => {
517
+ const r = e.children[t], a = t - n;
518
+ if (a > 1) {
519
+ const c = i / a;
520
+ e.children[n + 1].shift += c, r.shift -= c, r.change -= i - c;
521
+ }
522
+ }, ce = (e) => e.hasChildren ? e.firstChild : e.lThr, he = (e) => e.hasChildren ? e.lastChild : e.rThr, de = (e, t, n, i) => {
523
+ const r = e.firstChild, a = r.lExt, c = e.children[t];
524
+ a.lThr = n;
525
+ const s = i - n.relX - r.lExtRelX;
526
+ a.relX += s, a.prelim -= s, r.lExt = c.lExt, r.lExtRelX = c.lExtRelX;
527
+ }, ue = (e, t, n, i) => {
528
+ const r = e.children[t], a = r.rExt, c = e.children[t - 1];
529
+ a.rThr = n;
530
+ const s = i - n.relX - r.rExtRelX;
531
+ a.relX += s, a.prelim -= s, r.rExt = c.rExt, r.rExtRelX = c.rExtRelX;
532
+ }, pe = (e) => {
533
+ if (e.hasChildren) {
534
+ const t = e.firstChild, n = e.lastChild, i = (t.prelim + t.relX - t.xSize / 2 + n.relX + n.prelim + n.xSize / 2) / 2;
535
+ Object.assign(e, {
536
+ prelim: i,
537
+ lExt: t.lExt,
538
+ lExtRelX: t.lExtRelX,
539
+ rExt: n.rExt,
540
+ rExtRelX: n.rExtRelX
668
541
  });
669
542
  }
670
- };
671
-
672
- // Make/maintain a linked list of the indexes of left siblings and their
673
- // lowest vertical coordinate.
674
- const updateLows = (lowY, index, lastLows) => {
675
- // Remove siblings that are hidden by the new subtree.
676
- while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next;
677
- // Prepend the new subtree.
678
- return {
679
- lowY,
680
- index,
681
- next: lastLows
682
- };
683
- };
684
-
685
- /*! @gera2ld/jsx-dom v2.2.2 | ISC License */
686
- const VTYPE_ELEMENT = 1;
687
- const VTYPE_FUNCTION = 2;
688
- const SVG_NS = 'http://www.w3.org/2000/svg';
689
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
690
- const NS_ATTRS = {
691
- show: XLINK_NS,
692
- actuate: XLINK_NS,
693
- href: XLINK_NS
694
- };
695
- const isLeaf = c => typeof c === 'string' || typeof c === 'number';
696
- const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
697
- const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
698
- function jsx(type, props) {
699
- let vtype;
700
- if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
543
+ }, fe = (e, t, n) => {
544
+ for (; n !== null && e >= n.lowY; )
545
+ n = n.next;
701
546
  return {
702
- vtype,
703
- type,
704
- props
547
+ lowY: e,
548
+ index: t,
549
+ next: n
705
550
  };
551
+ }, nt = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:#555;background-color:#f0f0f0;border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:#ffeaa7}", ge = ".markmap-container{position:absolute;width:0;height:0;top:-100px;left:-100px;overflow:hidden}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child :not(pre){white-space:nowrap}.markmap-container>.markmap-foreign>div:last-child code{white-space:inherit}", ze = nt;
552
+ function Y(e) {
553
+ const t = e.data;
554
+ return Math.max(4 - 2 * t.depth, 1.5);
706
555
  }
707
- function Fragment(props) {
708
- return props.children;
709
- }
710
- const DEFAULT_ENV = {
711
- isSvg: false
712
- };
713
- function insertDom(parent, nodes) {
714
- if (!Array.isArray(nodes)) nodes = [nodes];
715
- nodes = nodes.filter(Boolean);
716
- if (nodes.length) parent.append(...nodes);
556
+ function K(e, t) {
557
+ const n = ft(e, t);
558
+ return e[n];
717
559
  }
718
- function mountAttributes(domElement, props, env) {
719
- for (const key in props) {
720
- if (key === 'key' || key === 'children' || key === 'ref') continue;
721
- if (key === 'dangerouslySetInnerHTML') {
722
- domElement.innerHTML = props[key].__html;
723
- } else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
724
- const value = props[key];
725
- if (value != null) domElement[key] = value;
726
- } else if (key.startsWith('on')) {
727
- domElement[key.toLowerCase()] = props[key];
728
- } else {
729
- setDOMAttribute(domElement, key, props[key], env.isSvg);
730
- }
731
- }
732
- }
733
- const attrMap = {
734
- className: 'class',
735
- labelFor: 'for'
736
- };
737
- function setDOMAttribute(el, attr, value, isSVG) {
738
- attr = attrMap[attr] || attr;
739
- if (value === true) {
740
- el.setAttribute(attr, '');
741
- } else if (value === false) {
742
- el.removeAttribute(attr);
743
- } else {
744
- const namespace = isSVG ? NS_ATTRS[attr] : undefined;
745
- if (namespace !== undefined) {
746
- el.setAttributeNS(namespace, attr, value);
747
- } else {
748
- el.setAttribute(attr, value);
749
- }
750
- }
751
- }
752
- function flatten(arr) {
753
- return arr.reduce((prev, item) => prev.concat(item), []);
754
- }
755
- function mountChildren(children, env) {
756
- return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
757
- }
758
- function mount(vnode, env = DEFAULT_ENV) {
759
- if (vnode == null || typeof vnode === 'boolean') {
760
- return null;
761
- }
762
- if (vnode instanceof Node) {
763
- return vnode;
764
- }
765
- if (isRenderFunction(vnode)) {
766
- const {
767
- type,
768
- props
769
- } = vnode;
770
- if (type === Fragment) {
771
- const node = document.createDocumentFragment();
772
- if (props.children) {
773
- const children = mountChildren(props.children, env);
774
- insertDom(node, children);
775
- }
776
- return node;
777
- }
778
- const childVNode = type(props);
779
- return mount(childVNode, env);
780
- }
781
- if (isLeaf(vnode)) {
782
- return document.createTextNode(`${vnode}`);
783
- }
784
- if (isElement(vnode)) {
785
- let node;
786
- const {
787
- type,
788
- props
789
- } = vnode;
790
- if (!env.isSvg && type === 'svg') {
791
- env = Object.assign({}, env, {
792
- isSvg: true
793
- });
794
- }
795
- if (!env.isSvg) {
796
- node = document.createElement(type);
797
- } else {
798
- node = document.createElementNS(SVG_NS, type);
799
- }
800
- mountAttributes(node, props, env);
801
- if (props.children) {
802
- let childEnv = env;
803
- if (env.isSvg && type === 'foreignObject') {
804
- childEnv = Object.assign({}, childEnv, {
805
- isSvg: false
806
- });
807
- }
808
- const children = mountChildren(props.children, childEnv);
809
- if (children != null) insertDom(node, children);
810
- }
811
- const {
812
- ref
813
- } = props;
814
- if (typeof ref === 'function') ref(node);
815
- return node;
816
- }
817
- throw new Error('mount: Invalid Vnode!');
818
- }
819
-
820
- /**
821
- * Mount vdom as real DOM nodes.
822
- */
823
- function mountDom(vnode) {
824
- return mount(vnode);
825
- }
826
-
827
- var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px);padding:.25em}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:#ffeaa7}";
828
-
829
- var css_248z = ".markmap-container{height:0;left:-100px;overflow:hidden;position:absolute;top:-100px;width:0}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child *{white-space:nowrap}";
830
-
831
- const globalCSS = css_248z$1;
832
- function linkWidth(nodeData) {
833
- const data = nodeData.data;
834
- return Math.max(4 - 2 * data.depth, 1.5);
835
- }
836
- function minBy(numbers, by) {
837
- const index = minIndex(numbers, by);
838
- return numbers[index];
839
- }
840
- function stopPropagation(e) {
560
+ function B(e) {
841
561
  e.stopPropagation();
842
562
  }
843
- function createViewHooks() {
563
+ function me() {
844
564
  return {
845
- transformHtml: new Hook()
565
+ transformHtml: new U()
846
566
  };
847
567
  }
848
-
849
- /**
850
- * A global hook to refresh all markmaps when called.
851
- */
852
- const refreshHook = new Hook();
853
- const defaultColorFn = scaleOrdinal(schemeCategory10);
854
- const isMacintosh = typeof navigator !== 'undefined' && navigator.userAgent.includes('Macintosh');
855
- class Markmap {
856
- constructor(svg, opts) {
857
- this.options = Markmap.defaultOptions;
858
- this.revokers = [];
859
- this.handleZoom = e => {
860
- const {
861
- transform
862
- } = e;
863
- this.g.attr('transform', transform);
864
- };
865
- this.handlePan = e => {
866
- e.preventDefault();
867
- const transform = zoomTransform(this.svg.node());
868
- const newTransform = transform.translate(-e.deltaX / transform.k, -e.deltaY / transform.k);
869
- this.svg.call(this.zoom.transform, newTransform);
870
- };
871
- this.handleClick = (e, d) => {
872
- let recursive = this.options.toggleRecursively;
873
- if (isMacintosh ? e.metaKey : e.ctrlKey) recursive = !recursive;
874
- this.toggleNode(d.data, recursive);
875
- };
876
- this.viewHooks = createViewHooks();
877
- this.svg = svg.datum ? svg : select(svg);
878
- this.styleNode = this.svg.append('style');
879
- this.zoom = zoom().filter(event => {
880
- if (this.options.scrollForPan) {
881
- // Pan with wheels, zoom with ctrl+wheels
882
- if (event.type === 'wheel') return event.ctrlKey && !event.button;
883
- }
884
- return (!event.ctrlKey || event.type === 'wheel') && !event.button;
885
- }).on('zoom', this.handleZoom);
886
- this.setOptions(opts);
887
- this.state = {
888
- id: this.options.id || this.svg.attr('id') || getId(),
568
+ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), C = class C {
569
+ constructor(t, n) {
570
+ this.options = C.defaultOptions, this.revokers = [], this.handleZoom = (i) => {
571
+ const { transform: r } = i;
572
+ this.g.attr("transform", r);
573
+ }, this.handlePan = (i) => {
574
+ i.preventDefault();
575
+ const r = O(this.svg.node()), a = r.translate(
576
+ -i.deltaX / r.k,
577
+ -i.deltaY / r.k
578
+ );
579
+ this.svg.call(this.zoom.transform, a);
580
+ }, this.handleClick = (i, r) => {
581
+ let a = this.options.toggleRecursively;
582
+ (P ? i.metaKey : i.ctrlKey) && (a = !a), this.toggleNode(r.data, a);
583
+ }, this.viewHooks = me(), this.svg = t.datum ? t : ht(t), this.styleNode = this.svg.append("style"), this.zoom = dt().filter((i) => this.options.scrollForPan && i.type === "wheel" ? i.ctrlKey && !i.button : (!i.ctrlKey || i.type === "wheel") && !i.button).on("zoom", this.handleZoom), this.setOptions(n), this.state = {
584
+ id: this.options.id || this.svg.attr("id") || at(),
889
585
  minX: 0,
890
586
  maxX: 0,
891
587
  minY: 0,
892
588
  maxY: 0
893
- };
894
- this.g = this.svg.append('g');
895
- this.revokers.push(refreshHook.tap(() => {
896
- this.setData();
897
- }));
589
+ }, this.g = this.svg.append("g"), this.revokers.push(
590
+ xe.tap(() => {
591
+ this.setData();
592
+ })
593
+ );
898
594
  }
899
595
  getStyleContent() {
900
- const {
901
- style
902
- } = this.options;
903
- const {
904
- id
905
- } = this.state;
906
- const styleText = typeof style === 'function' ? style(id) : '';
907
- return [this.options.embedGlobalCSS && css_248z$1, styleText].filter(Boolean).join('\n');
596
+ const { style: t } = this.options, { id: n } = this.state, i = typeof t == "function" ? t(n) : "";
597
+ return [this.options.embedGlobalCSS && nt, i].filter(Boolean).join(`
598
+ `);
908
599
  }
909
600
  updateStyle() {
910
- this.svg.attr('class', addClass(this.svg.attr('class'), 'markmap', this.state.id));
911
- const style = this.getStyleContent();
912
- this.styleNode.text(style);
913
- }
914
- toggleNode(data, recursive = false) {
915
- var _data$payload;
916
- const fold = (_data$payload = data.payload) != null && _data$payload.fold ? 0 : 1;
917
- if (recursive) {
918
- // recursively
919
- walkTree(data, (item, next) => {
920
- item.payload = _extends({}, item.payload, {
921
- fold
922
- });
923
- next();
924
- });
925
- } else {
926
- var _data$payload2;
927
- data.payload = _extends({}, data.payload, {
928
- fold: (_data$payload2 = data.payload) != null && _data$payload2.fold ? 0 : 1
929
- });
930
- }
931
- this.renderData(data);
932
- }
933
- initializeData(node) {
934
- let nodeId = 0;
935
- const {
936
- color,
937
- nodeMinHeight,
938
- maxWidth,
939
- initialExpandLevel
940
- } = this.options;
941
- const {
942
- id
943
- } = this.state;
944
- const container = mountDom(jsx("div", {
945
- className: `markmap-container markmap ${id}-g`
946
- }));
947
- const style = mountDom(jsx("style", {
948
- children: [this.getStyleContent(), css_248z].join('\n')
949
- }));
950
- document.body.append(container, style);
951
- const groupStyle = maxWidth ? `max-width: ${maxWidth}px` : '';
952
- let foldRecursively = 0;
953
- walkTree(node, (item, next, parent) => {
954
- var _item$children, _parent$state, _item$payload;
955
- item.children = (_item$children = item.children) == null ? void 0 : _item$children.map(child => _extends({}, child));
956
- nodeId += 1;
957
- const group = mountDom(jsx("div", {
958
- className: "markmap-foreign",
959
- style: groupStyle,
960
- children: jsx("div", {
961
- dangerouslySetInnerHTML: {
962
- __html: item.content
963
- }
964
- })
965
- }));
966
- container.append(group);
967
- item.state = _extends({}, item.state, {
968
- id: nodeId,
969
- el: group.firstChild
970
- });
971
- item.state.path = [parent == null || (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.');
972
- color(item); // preload colors
973
-
974
- const isFoldRecursively = ((_item$payload = item.payload) == null ? void 0 : _item$payload.fold) === 2;
975
- if (isFoldRecursively) {
976
- foldRecursively += 1;
977
- } else if (foldRecursively || initialExpandLevel >= 0 && item.depth >= initialExpandLevel) {
978
- item.payload = _extends({}, item.payload, {
979
- fold: 1
980
- });
981
- }
982
- next();
983
- if (isFoldRecursively) foldRecursively -= 1;
601
+ this.svg.attr(
602
+ "class",
603
+ lt(this.svg.attr("class"), "markmap", this.state.id)
604
+ );
605
+ const t = this.getStyleContent();
606
+ this.styleNode.text(t);
607
+ }
608
+ toggleNode(t, n = !1) {
609
+ var r, a;
610
+ const i = (r = t.payload) != null && r.fold ? 0 : 1;
611
+ n ? M(t, (c, s) => {
612
+ c.payload = {
613
+ ...c.payload,
614
+ fold: i
615
+ }, s();
616
+ }) : t.payload = {
617
+ ...t.payload,
618
+ fold: (a = t.payload) != null && a.fold ? 0 : 1
619
+ }, this.renderData(t);
620
+ }
621
+ initializeData(t) {
622
+ let n = 0;
623
+ const { color: i, nodeMinHeight: r, maxWidth: a, initialExpandLevel: c } = this.options, { id: s } = this.state, l = $(
624
+ /* @__PURE__ */ N("div", { className: `markmap-container markmap ${s}-g` })
625
+ ), f = $(
626
+ /* @__PURE__ */ N("style", { children: [this.getStyleContent(), ge].join(`
627
+ `) })
628
+ );
629
+ document.body.append(l, f);
630
+ const h = a ? `max-width: ${a}px` : "";
631
+ let p = 0;
632
+ M(t, (d, S, x) => {
633
+ var v, k, w;
634
+ d.children = (v = d.children) == null ? void 0 : v.map((E) => ({ ...E })), n += 1;
635
+ const g = $(
636
+ /* @__PURE__ */ N("div", { className: "markmap-foreign", style: h, children: /* @__PURE__ */ N("div", { dangerouslySetInnerHTML: { __html: d.content } }) })
637
+ );
638
+ l.append(g), d.state = {
639
+ ...d.state,
640
+ id: n,
641
+ el: g.firstChild
642
+ }, d.state.path = [(k = x == null ? void 0 : x.state) == null ? void 0 : k.path, d.state.id].filter(Boolean).join("."), i(d);
643
+ const y = ((w = d.payload) == null ? void 0 : w.fold) === 2;
644
+ y ? p += 1 : (p || c >= 0 && d.depth >= c) && (d.payload = { ...d.payload, fold: 1 }), S(), y && (p -= 1);
984
645
  });
985
- const nodes = Array.from(container.childNodes).map(group => group.firstChild);
986
- this.viewHooks.transformHtml.call(this, nodes);
987
- // Clone the rendered HTML and set `white-space: nowrap` to it to detect its max-width.
988
- // The parent node will have a width of the max-width and the original content without
989
- // `white-space: nowrap` gets re-layouted, then we will get the expected layout, with
990
- // content in one line as much as possible, and subjecting to the given max-width.
991
- nodes.forEach(node => {
992
- var _node$parentNode;
993
- (_node$parentNode = node.parentNode) == null || _node$parentNode.append(node.cloneNode(true));
994
- });
995
- walkTree(node, (item, next, parent) => {
996
- var _parent$state2;
997
- const state = item.state;
998
- const rect = state.el.getBoundingClientRect();
999
- item.content = state.el.innerHTML;
1000
- state.size = [Math.ceil(rect.width) + 1, Math.max(Math.ceil(rect.height), nodeMinHeight)];
1001
- state.key = [parent == null || (_parent$state2 = parent.state) == null ? void 0 : _parent$state2.id, state.id].filter(Boolean).join('.') +
1002
- // FIXME: find a way to check content hash
1003
- item.content;
1004
- next();
1005
- });
1006
- container.remove();
1007
- style.remove();
1008
- }
1009
- setOptions(opts) {
1010
- this.options = _extends({}, this.options, opts);
1011
- if (this.options.zoom) {
1012
- this.svg.call(this.zoom);
1013
- } else {
1014
- this.svg.on('.zoom', null);
1015
- }
1016
- if (this.options.pan) {
1017
- this.svg.on('wheel', this.handlePan);
1018
- } else {
1019
- this.svg.on('wheel', null);
1020
- }
1021
- }
1022
- setData(data, opts) {
1023
- if (opts) this.setOptions(opts);
1024
- if (data) this.state.data = data;
1025
- if (!this.state.data) return;
1026
- this.initializeData(this.state.data);
1027
- this.updateStyle();
1028
- this.renderData();
1029
- }
1030
- renderData(originData) {
1031
- var _origin$data$state$x, _origin$data$state$y;
1032
- if (!this.state.data) return;
1033
- const {
1034
- spacingHorizontal,
1035
- paddingX,
1036
- spacingVertical,
1037
- autoFit,
1038
- color
1039
- } = this.options;
1040
- const layout = flextree({}).children(d => {
1041
- var _d$payload;
1042
- if (!((_d$payload = d.payload) != null && _d$payload.fold)) return d.children;
1043
- }).nodeSize(node => {
1044
- const [width, height] = node.data.state.size;
1045
- return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
1046
- }).spacing((a, b) => {
1047
- return a.parent === b.parent ? spacingVertical : spacingVertical * 2;
1048
- });
1049
- const tree = layout.hierarchy(this.state.data);
1050
- layout(tree);
1051
- const descendants = tree.descendants().reverse();
1052
- const links = tree.links();
1053
- const linkShape = linkHorizontal();
1054
- const minX = min(descendants, d => d.x - d.xSize / 2);
1055
- const maxX = max(descendants, d => d.x + d.xSize / 2);
1056
- const minY = min(descendants, d => d.y);
1057
- const maxY = max(descendants, d => d.y + d.ySize - spacingHorizontal);
646
+ const m = Array.from(l.childNodes).map(
647
+ (d) => d.firstChild
648
+ );
649
+ this.viewHooks.transformHtml.call(this, m), m.forEach((d) => {
650
+ var S;
651
+ (S = d.parentNode) == null || S.append(d.cloneNode(!0));
652
+ }), M(t, (d, S, x) => {
653
+ var v;
654
+ const g = d.state, y = g.el.getBoundingClientRect();
655
+ d.content = g.el.innerHTML, g.size = [
656
+ Math.ceil(y.width) + 1,
657
+ Math.max(Math.ceil(y.height), r)
658
+ ], g.key = [(v = x == null ? void 0 : x.state) == null ? void 0 : v.id, g.id].filter(Boolean).join(".") + // FIXME: find a way to check content hash
659
+ d.content, S();
660
+ }), l.remove(), f.remove();
661
+ }
662
+ setOptions(t) {
663
+ this.options = {
664
+ ...this.options,
665
+ ...t
666
+ }, this.options.zoom ? this.svg.call(this.zoom) : this.svg.on(".zoom", null), this.options.pan ? this.svg.on("wheel", this.handlePan) : this.svg.on("wheel", null);
667
+ }
668
+ setData(t, n) {
669
+ n && this.setOptions(n), t && (this.state.data = t), this.state.data && (this.initializeData(this.state.data), this.updateStyle(), this.renderData());
670
+ }
671
+ renderData(t) {
672
+ if (!this.state.data)
673
+ return;
674
+ const { spacingHorizontal: n, paddingX: i, spacingVertical: r, autoFit: a, color: c } = this.options, s = Q({}).children((o) => {
675
+ var u;
676
+ if (!((u = o.payload) != null && u.fold))
677
+ return o.children;
678
+ }).nodeSize((o) => {
679
+ const [u, z] = o.data.state.size;
680
+ return [z, u + (u ? i * 2 : 0) + n];
681
+ }).spacing((o, u) => o.parent === u.parent ? r : r * 2), l = s.hierarchy(this.state.data);
682
+ s(l);
683
+ const f = l.descendants().reverse(), h = l.links(), p = ut(), m = I(f, (o) => o.x - o.xSize / 2), d = W(f, (o) => o.x + o.xSize / 2), S = I(f, (o) => o.y), x = W(f, (o) => o.y + o.ySize - n);
1058
684
  Object.assign(this.state, {
1059
- minX,
1060
- maxX,
1061
- minY,
1062
- maxY
1063
- });
1064
- if (autoFit) this.fit();
1065
- const origin = originData && descendants.find(item => item.data === originData) || tree;
1066
- const x0 = (_origin$data$state$x = origin.data.state.x0) != null ? _origin$data$state$x : origin.x;
1067
- const y0 = (_origin$data$state$y = origin.data.state.y0) != null ? _origin$data$state$y : origin.y;
1068
-
1069
- // Update the nodes
1070
- const node = this.g.selectAll(childSelector('g')).data(descendants, d => d.data.state.key);
1071
- const nodeEnter = node.enter().append('g').attr('data-depth', d => d.data.depth).attr('data-path', d => d.data.state.path).attr('transform', d => `translate(${y0 + origin.ySize - d.ySize},${x0 + origin.xSize / 2 - d.xSize})`);
1072
- const nodeExit = this.transition(node.exit());
1073
- nodeExit.select('line').attr('x1', d => d.ySize - spacingHorizontal).attr('x2', d => d.ySize - spacingHorizontal);
1074
- nodeExit.select('foreignObject').style('opacity', 0);
1075
- nodeExit.attr('transform', d => `translate(${origin.y + origin.ySize - d.ySize},${origin.x + origin.xSize / 2 - d.xSize})`).remove();
1076
- const nodeMerge = node.merge(nodeEnter).attr('class', d => {
1077
- var _d$data$payload;
1078
- return ['markmap-node', ((_d$data$payload = d.data.payload) == null ? void 0 : _d$data$payload.fold) && 'markmap-fold'].filter(Boolean).join(' ');
1079
- });
1080
- this.transition(nodeMerge).attr('transform', d => `translate(${d.y},${d.x - d.xSize / 2})`);
1081
-
1082
- // Update lines under the content
1083
- const line = nodeMerge.selectAll(childSelector('line')).data(d => [d], d => d.data.state.key).join(enter => {
1084
- return enter.append('line').attr('x1', d => d.ySize - spacingHorizontal).attr('x2', d => d.ySize - spacingHorizontal);
1085
- }, update => update, exit => exit.remove());
1086
- this.transition(line).attr('x1', -1).attr('x2', d => d.ySize - spacingHorizontal + 2).attr('y1', d => d.xSize).attr('y2', d => d.xSize).attr('stroke', d => color(d.data)).attr('stroke-width', linkWidth);
1087
-
1088
- // Circle to link to children of the node
1089
- const circle = nodeMerge.selectAll(childSelector('circle')).data(d => {
1090
- var _d$data$children;
1091
- return (_d$data$children = d.data.children) != null && _d$data$children.length ? [d] : [];
1092
- }, d => d.data.state.key).join(enter => {
1093
- return enter.append('circle').attr('stroke-width', '1.5').attr('cx', d => d.ySize - spacingHorizontal).attr('cy', d => d.xSize).attr('r', 0).on('click', (e, d) => this.handleClick(e, d)).on('mousedown', stopPropagation);
1094
- }, update => update, exit => exit.remove());
1095
- this.transition(circle).attr('r', 6).attr('cx', d => d.ySize - spacingHorizontal).attr('cy', d => d.xSize).attr('stroke', d => color(d.data)).attr('fill', d => {
1096
- var _d$data$payload2;
1097
- return (_d$data$payload2 = d.data.payload) != null && _d$data$payload2.fold && d.data.children ? color(d.data) : '#fff';
1098
- });
1099
- const foreignObject = nodeMerge.selectAll(childSelector('foreignObject')).data(d => [d], d => d.data.state.key).join(enter => {
1100
- const fo = enter.append('foreignObject').attr('class', 'markmap-foreign').attr('x', paddingX).attr('y', 0).style('opacity', 0).on('mousedown', stopPropagation).on('dblclick', stopPropagation);
1101
- fo.append('xhtml:div').select(function select(d) {
1102
- const clone = d.data.state.el.cloneNode(true);
1103
- this.replaceWith(clone);
1104
- return clone;
1105
- }).attr('xmlns', 'http://www.w3.org/1999/xhtml');
1106
- return fo;
1107
- }, update => update, exit => exit.remove()).attr('width', d => Math.max(0, d.ySize - spacingHorizontal - paddingX * 2)).attr('height', d => d.xSize);
1108
- this.transition(foreignObject).style('opacity', 1);
1109
-
1110
- // Update the links
1111
- const path = this.g.selectAll(childSelector('path')).data(links, d => d.target.data.state.key).join(enter => {
1112
- const source = [y0 + origin.ySize - spacingHorizontal, x0 + origin.xSize / 2];
1113
- return enter.insert('path', 'g').attr('class', 'markmap-link').attr('data-depth', d => d.target.data.depth).attr('data-path', d => d.target.data.state.path).attr('d', linkShape({
1114
- source,
1115
- target: source
1116
- }));
1117
- }, update => update, exit => {
1118
- const source = [origin.y + origin.ySize - spacingHorizontal, origin.x + origin.xSize / 2];
1119
- return this.transition(exit).attr('d', linkShape({
1120
- source,
1121
- target: source
1122
- })).remove();
1123
- });
1124
- this.transition(path).attr('stroke', d => color(d.target.data)).attr('stroke-width', d => linkWidth(d.target)).attr('d', d => {
1125
- const origSource = d.source;
1126
- const origTarget = d.target;
1127
- const source = [origSource.y + origSource.ySize - spacingHorizontal, origSource.x + origSource.xSize / 2];
1128
- const target = [origTarget.y, origTarget.x + origTarget.xSize / 2];
1129
- return linkShape({
1130
- source,
1131
- target
1132
- });
1133
- });
1134
- descendants.forEach(d => {
1135
- d.data.state.x0 = d.x;
1136
- d.data.state.y0 = d.y;
685
+ minX: m,
686
+ maxX: d,
687
+ minY: S,
688
+ maxY: x
689
+ }), a && this.fit();
690
+ const g = t && f.find((o) => o.data === t) || l, y = g.data.state.x0 ?? g.x, v = g.data.state.y0 ?? g.y, k = this.g.selectAll(
691
+ b("g")
692
+ ).data(f, (o) => o.data.state.key), w = k.enter().append("g").attr("data-depth", (o) => o.data.depth).attr("data-path", (o) => o.data.state.path).attr(
693
+ "transform",
694
+ (o) => `translate(${v + g.ySize - o.ySize},${y + g.xSize / 2 - o.xSize})`
695
+ ), E = this.transition(k.exit());
696
+ E.select("line").attr("x1", (o) => o.ySize - n).attr("x2", (o) => o.ySize - n), E.select("foreignObject").style("opacity", 0), E.attr(
697
+ "transform",
698
+ (o) => `translate(${g.y + g.ySize - o.ySize},${g.x + g.xSize / 2 - o.xSize})`
699
+ ).remove();
700
+ const X = k.merge(w).attr(
701
+ "class",
702
+ (o) => {
703
+ var u;
704
+ return ["markmap-node", ((u = o.data.payload) == null ? void 0 : u.fold) && "markmap-fold"].filter(Boolean).join(" ");
705
+ }
706
+ );
707
+ this.transition(X).attr(
708
+ "transform",
709
+ (o) => `translate(${o.y},${o.x - o.xSize / 2})`
710
+ );
711
+ const it = X.selectAll(
712
+ b("line")
713
+ ).data(
714
+ (o) => [o],
715
+ (o) => o.data.state.key
716
+ ).join(
717
+ (o) => o.append("line").attr("x1", (u) => u.ySize - n).attr("x2", (u) => u.ySize - n),
718
+ (o) => o,
719
+ (o) => o.remove()
720
+ );
721
+ this.transition(it).attr("x1", -1).attr("x2", (o) => o.ySize - n + 2).attr("y1", (o) => o.xSize).attr("y2", (o) => o.xSize).attr("stroke", (o) => c(o.data)).attr("stroke-width", Y);
722
+ const ot = X.selectAll(
723
+ b("circle")
724
+ ).data(
725
+ (o) => {
726
+ var u;
727
+ return (u = o.data.children) != null && u.length ? [o] : [];
728
+ },
729
+ (o) => o.data.state.key
730
+ ).join(
731
+ (o) => o.append("circle").attr("stroke-width", "1.5").attr("cx", (u) => u.ySize - n).attr("cy", (u) => u.xSize).attr("r", 0).on("click", (u, z) => this.handleClick(u, z)).on("mousedown", B),
732
+ (o) => o,
733
+ (o) => o.remove()
734
+ );
735
+ this.transition(ot).attr("r", 6).attr("cx", (o) => o.ySize - n).attr("cy", (o) => o.xSize).attr("stroke", (o) => c(o.data)).attr(
736
+ "fill",
737
+ (o) => {
738
+ var u;
739
+ return (u = o.data.payload) != null && u.fold && o.data.children ? c(o.data) : "#fff";
740
+ }
741
+ );
742
+ const rt = X.selectAll(
743
+ b("foreignObject")
744
+ ).data(
745
+ (o) => [o],
746
+ (o) => o.data.state.key
747
+ ).join(
748
+ (o) => {
749
+ const u = o.append("foreignObject").attr("class", "markmap-foreign").attr("x", i).attr("y", 0).style("opacity", 0).on("mousedown", B).on("dblclick", B);
750
+ return u.append("xhtml:div").select(function(T) {
751
+ const j = T.data.state.el.cloneNode(!0);
752
+ return this.replaceWith(j), j;
753
+ }).attr("xmlns", "http://www.w3.org/1999/xhtml"), u;
754
+ },
755
+ (o) => o,
756
+ (o) => o.remove()
757
+ ).attr(
758
+ "width",
759
+ (o) => Math.max(0, o.ySize - n - i * 2)
760
+ ).attr("height", (o) => o.xSize);
761
+ this.transition(rt).style("opacity", 1);
762
+ const st = this.g.selectAll(
763
+ b("path")
764
+ ).data(h, (o) => o.target.data.state.key).join(
765
+ (o) => {
766
+ const u = [
767
+ v + g.ySize - n,
768
+ y + g.xSize / 2
769
+ ];
770
+ return o.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (z) => z.target.data.depth).attr("data-path", (z) => z.target.data.state.path).attr("d", p({ source: u, target: u }));
771
+ },
772
+ (o) => o,
773
+ (o) => {
774
+ const u = [
775
+ g.y + g.ySize - n,
776
+ g.x + g.xSize / 2
777
+ ];
778
+ return this.transition(o).attr("d", p({ source: u, target: u })).remove();
779
+ }
780
+ );
781
+ this.transition(st).attr("stroke", (o) => c(o.target.data)).attr("stroke-width", (o) => Y(o.target)).attr("d", (o) => {
782
+ const u = o.source, z = o.target, T = [
783
+ u.y + u.ySize - n,
784
+ u.x + u.xSize / 2
785
+ ], j = [
786
+ z.y,
787
+ z.x + z.xSize / 2
788
+ ];
789
+ return p({ source: T, target: j });
790
+ }), f.forEach((o) => {
791
+ o.data.state.x0 = o.x, o.data.state.y0 = o.y;
1137
792
  });
1138
793
  }
1139
- transition(sel) {
1140
- const {
1141
- duration
1142
- } = this.options;
1143
- return sel.transition().duration(duration);
794
+ transition(t) {
795
+ const { duration: n } = this.options;
796
+ return t.transition().duration(n);
1144
797
  }
1145
-
1146
798
  /**
1147
799
  * Fit the content to the viewport.
1148
800
  */
1149
801
  async fit() {
1150
- const svgNode = this.svg.node();
1151
- const {
1152
- width: offsetWidth,
1153
- height: offsetHeight
1154
- } = svgNode.getBoundingClientRect();
1155
- const {
1156
- fitRatio
1157
- } = this.options;
1158
- const {
1159
- minX,
1160
- maxX,
1161
- minY,
1162
- maxY
1163
- } = this.state;
1164
- const naturalWidth = maxY - minY;
1165
- const naturalHeight = maxX - minX;
1166
- const scale = Math.min(offsetWidth / naturalWidth * fitRatio, offsetHeight / naturalHeight * fitRatio, 2);
1167
- const initialZoom = zoomIdentity.translate((offsetWidth - naturalWidth * scale) / 2 - minY * scale, (offsetHeight - naturalHeight * scale) / 2 - minX * scale).scale(scale);
1168
- return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop);
802
+ const t = this.svg.node(), { width: n, height: i } = t.getBoundingClientRect(), { fitRatio: r } = this.options, { minX: a, maxX: c, minY: s, maxY: l } = this.state, f = l - s, h = c - a, p = Math.min(
803
+ n / f * r,
804
+ i / h * r,
805
+ 2
806
+ ), m = pt.translate(
807
+ (n - f * p) / 2 - s * p,
808
+ (i - h * p) / 2 - a * p
809
+ ).scale(p);
810
+ return this.transition(this.svg).call(this.zoom.transform, m).end().catch(A);
1169
811
  }
1170
-
1171
812
  /**
1172
813
  * Pan the content to make the provided node visible in the viewport.
1173
814
  */
1174
- async ensureView(node, padding) {
1175
- let itemData;
1176
- this.g.selectAll(childSelector('g')).each(function walk(d) {
1177
- if (d.data === node) {
1178
- itemData = d;
1179
- }
1180
- });
1181
- if (!itemData) return;
1182
- const svgNode = this.svg.node();
1183
- const {
1184
- spacingHorizontal
1185
- } = this.options;
1186
- const relRect = svgNode.getBoundingClientRect();
1187
- const transform = zoomTransform(svgNode);
1188
- const [left, right] = [itemData.y, itemData.y + itemData.ySize - spacingHorizontal + 2].map(x => x * transform.k + transform.x);
1189
- const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y);
1190
- // Skip if the node includes or is included in the container.
1191
- const pd = _extends({
815
+ async ensureView(t, n) {
816
+ let i;
817
+ if (this.g.selectAll(
818
+ b("g")
819
+ ).each(function(v) {
820
+ v.data === t && (i = v);
821
+ }), !i)
822
+ return;
823
+ const r = this.svg.node(), { spacingHorizontal: a } = this.options, c = r.getBoundingClientRect(), s = O(r), [l, f] = [
824
+ i.y,
825
+ i.y + i.ySize - a + 2
826
+ ].map((y) => y * s.k + s.x), [h, p] = [
827
+ i.x - i.xSize / 2,
828
+ i.x + i.xSize / 2
829
+ ].map((y) => y * s.k + s.y), m = {
1192
830
  left: 0,
1193
831
  right: 0,
1194
832
  top: 0,
1195
- bottom: 0
1196
- }, padding);
1197
- const dxs = [pd.left - left, relRect.width - pd.right - right];
1198
- const dys = [pd.top - top, relRect.height - pd.bottom - bottom];
1199
- const dx = dxs[0] * dxs[1] > 0 ? minBy(dxs, Math.abs) / transform.k : 0;
1200
- const dy = dys[0] * dys[1] > 0 ? minBy(dys, Math.abs) / transform.k : 0;
1201
- if (dx || dy) {
1202
- const newTransform = transform.translate(dx, dy);
1203
- return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
833
+ bottom: 0,
834
+ ...n
835
+ }, d = [m.left - l, c.width - m.right - f], S = [m.top - h, c.height - m.bottom - p], x = d[0] * d[1] > 0 ? K(d, Math.abs) / s.k : 0, g = S[0] * S[1] > 0 ? K(S, Math.abs) / s.k : 0;
836
+ if (x || g) {
837
+ const y = s.translate(x, g);
838
+ return this.transition(this.svg).call(this.zoom.transform, y).end().catch(A);
1204
839
  }
1205
840
  }
1206
-
1207
841
  /**
1208
842
  * Scale content with it pinned at the center of the viewport.
1209
843
  */
1210
- async rescale(scale) {
1211
- const svgNode = this.svg.node();
1212
- const {
1213
- width: offsetWidth,
1214
- height: offsetHeight
1215
- } = svgNode.getBoundingClientRect();
1216
- const halfWidth = offsetWidth / 2;
1217
- const halfHeight = offsetHeight / 2;
1218
- const transform = zoomTransform(svgNode);
1219
- const newTransform = transform.translate((halfWidth - transform.x) * (1 - scale) / transform.k, (halfHeight - transform.y) * (1 - scale) / transform.k).scale(scale);
1220
- return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
844
+ async rescale(t) {
845
+ const n = this.svg.node(), { width: i, height: r } = n.getBoundingClientRect(), a = i / 2, c = r / 2, s = O(n), l = s.translate(
846
+ (a - s.x) * (1 - t) / s.k,
847
+ (c - s.y) * (1 - t) / s.k
848
+ ).scale(t);
849
+ return this.transition(this.svg).call(this.zoom.transform, l).end().catch(A);
1221
850
  }
1222
851
  destroy() {
1223
- this.svg.on('.zoom', null);
1224
- this.svg.html(null);
1225
- this.revokers.forEach(fn => {
1226
- fn();
852
+ this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
853
+ t();
1227
854
  });
1228
855
  }
1229
- static create(svg, opts, data = null) {
1230
- const mm = new Markmap(svg, opts);
1231
- if (data) {
1232
- mm.setData(data);
1233
- mm.fit(); // always fit for the first render
1234
- }
1235
-
1236
- return mm;
856
+ static create(t, n, i = null) {
857
+ const r = new C(t, n);
858
+ return i && (r.setData(i), r.fit()), r;
1237
859
  }
1238
- }
1239
- Markmap.defaultOptions = {
1240
- autoFit: false,
1241
- color: node => {
1242
- var _node$state;
1243
- return defaultColorFn(`${((_node$state = node.state) == null ? void 0 : _node$state.path) || ''}`);
860
+ };
861
+ C.defaultOptions = {
862
+ autoFit: !1,
863
+ color: (t) => {
864
+ var n;
865
+ return ye(`${((n = t.state) == null ? void 0 : n.path) || ""}`);
1244
866
  },
1245
867
  duration: 500,
1246
- embedGlobalCSS: true,
868
+ embedGlobalCSS: !0,
1247
869
  fitRatio: 0.95,
1248
870
  maxWidth: 0,
1249
871
  nodeMinHeight: 16,
1250
872
  paddingX: 8,
1251
- scrollForPan: isMacintosh,
873
+ scrollForPan: P,
1252
874
  spacingHorizontal: 80,
1253
875
  spacingVertical: 5,
1254
876
  initialExpandLevel: -1,
1255
- zoom: true,
1256
- pan: true,
1257
- toggleRecursively: false
877
+ zoom: !0,
878
+ pan: !0,
879
+ toggleRecursively: !1
880
+ };
881
+ let F = C;
882
+ function ke(e) {
883
+ const t = {}, n = { ...e }, { color: i, colorFreezeLevel: r } = n;
884
+ if ((i == null ? void 0 : i.length) === 1) {
885
+ const s = i[0];
886
+ t.color = () => s;
887
+ } else if (i != null && i.length) {
888
+ const s = G(i);
889
+ t.color = (l) => s(`${l.state.path}`);
890
+ }
891
+ if (r) {
892
+ const s = t.color || F.defaultOptions.color;
893
+ t.color = (l) => (l = {
894
+ ...l,
895
+ state: {
896
+ ...l.state,
897
+ path: l.state.path.split(".").slice(0, r).join(".")
898
+ }
899
+ }, s(l));
900
+ }
901
+ return ["duration", "maxWidth", "initialExpandLevel"].forEach((s) => {
902
+ const l = n[s];
903
+ typeof l == "number" && (t[s] = l);
904
+ }), ["zoom", "pan"].forEach((s) => {
905
+ const l = n[s];
906
+ l != null && (t[s] = !!l);
907
+ }), t;
908
+ }
909
+ export {
910
+ F as Markmap,
911
+ ye as defaultColorFn,
912
+ ke as deriveOptions,
913
+ ze as globalCSS,
914
+ Ce as loadCSS,
915
+ we as loadJS,
916
+ xe as refreshHook
1258
917
  };
1259
- function deriveOptions(jsonOptions) {
1260
- const derivedOptions = {};
1261
- const options = _extends({}, jsonOptions);
1262
- const {
1263
- color,
1264
- colorFreezeLevel
1265
- } = options;
1266
- if ((color == null ? void 0 : color.length) === 1) {
1267
- const solidColor = color[0];
1268
- derivedOptions.color = () => solidColor;
1269
- } else if (color != null && color.length) {
1270
- const colorFn = scaleOrdinal(color);
1271
- derivedOptions.color = node => colorFn(`${node.state.path}`);
1272
- }
1273
- if (colorFreezeLevel) {
1274
- const color = derivedOptions.color || Markmap.defaultOptions.color;
1275
- derivedOptions.color = node => {
1276
- node = _extends({}, node, {
1277
- state: _extends({}, node.state, {
1278
- path: node.state.path.split('.').slice(0, colorFreezeLevel).join('.')
1279
- })
1280
- });
1281
- return color(node);
1282
- };
1283
- }
1284
- const numberKeys = ['duration', 'maxWidth', 'initialExpandLevel'];
1285
- numberKeys.forEach(key => {
1286
- const value = options[key];
1287
- if (typeof value === 'number') derivedOptions[key] = value;
1288
- });
1289
- const booleanKeys = ['zoom', 'pan'];
1290
- booleanKeys.forEach(key => {
1291
- const value = options[key];
1292
- if (value != null) derivedOptions[key] = !!value;
1293
- });
1294
- return derivedOptions;
1295
- }
1296
-
1297
- export { Markmap, defaultColorFn, deriveOptions, globalCSS, refreshHook };