markmap-view 0.15.8 → 0.15.9-alpha.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/dist/index.js CHANGED
@@ -1,18 +1,65 @@
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";
1
+ import { Hook as st, getId as at, debounce as lt, addClass as ct, walkTree as T, childSelector as E, noop as M } from "markmap-common";
2
+ import { loadCSS as Ee, loadJS as we } from "markmap-common";
3
+ import { scaleOrdinal as V, schemeCategory10 as ht, zoomTransform as A, select as dt, zoom as ut, linkHorizontal as pt, min as H, max as L, zoomIdentity as ft, minIndex as mt } from "d3";
4
+ const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt = V(ht), P = {
5
+ autoFit: !1,
6
+ color: (e) => {
7
+ var t;
8
+ return gt(`${((t = e.state) == null ? void 0 : t.path) || ""}`);
9
+ },
10
+ duration: 500,
11
+ embedGlobalCSS: !0,
12
+ fitRatio: 0.95,
13
+ maxWidth: 0,
14
+ nodeMinHeight: 16,
15
+ paddingX: 8,
16
+ scrollForPan: K,
17
+ spacingHorizontal: 80,
18
+ spacingVertical: 5,
19
+ initialExpandLevel: -1,
20
+ zoom: !0,
21
+ pan: !0,
22
+ toggleRecursively: !1
23
+ };
24
+ function Se(e) {
25
+ const t = {}, n = { ...e }, { color: i, colorFreezeLevel: o } = n;
26
+ if ((i == null ? void 0 : i.length) === 1) {
27
+ const s = i[0];
28
+ t.color = () => s;
29
+ } else if (i != null && i.length) {
30
+ const s = V(i);
31
+ t.color = (l) => s(`${l.state.path}`);
32
+ }
33
+ if (o) {
34
+ const s = t.color || P.color;
35
+ t.color = (l) => (l = {
36
+ ...l,
37
+ state: {
38
+ ...l.state,
39
+ path: l.state.path.split(".").slice(0, o).join(".")
40
+ }
41
+ }, s(l));
42
+ }
43
+ return ["duration", "maxWidth", "initialExpandLevel"].forEach((s) => {
44
+ const l = n[s];
45
+ typeof l == "number" && (t[s] = l);
46
+ }), ["zoom", "pan"].forEach((s) => {
47
+ const l = n[s];
48
+ l != null && (t[s] = !!l);
49
+ }), t;
50
+ }
4
51
  /*! @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) {
52
+ const U = 1, G = 2, xt = "http://www.w3.org/2000/svg", _ = "http://www.w3.org/1999/xlink", yt = {
53
+ show: _,
54
+ actuate: _,
55
+ href: _
56
+ }, kt = (e) => typeof e == "string" || typeof e == "number", vt = (e) => (e == null ? void 0 : e.vtype) === U, St = (e) => (e == null ? void 0 : e.vtype) === G;
57
+ function j(e, t) {
11
58
  let n;
12
59
  if (typeof e == "string")
13
- n = Z;
60
+ n = U;
14
61
  else if (typeof e == "function")
15
- n = J;
62
+ n = G;
16
63
  else
17
64
  throw new Error("Invalid VNode type");
18
65
  return {
@@ -21,47 +68,47 @@ function N(e, t) {
21
68
  props: t
22
69
  };
23
70
  }
24
- function vt(e) {
71
+ function bt(e) {
25
72
  return e.children;
26
73
  }
27
74
  const zt = {
28
75
  isSvg: !1
29
76
  };
30
- function V(e, t) {
77
+ function I(e, t) {
31
78
  Array.isArray(t) || (t = [t]), t = t.filter(Boolean), t.length && e.append(...t);
32
79
  }
33
- function kt(e, t, n) {
80
+ function Ct(e, t, n) {
34
81
  for (const i in t)
35
82
  if (!(i === "key" || i === "children" || i === "ref"))
36
83
  if (i === "dangerouslySetInnerHTML")
37
84
  e.innerHTML = t[i].__html;
38
85
  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);
86
+ const o = t[i];
87
+ o != null && (e[i] = o);
41
88
  } else
42
- i.startsWith("on") ? e[i.toLowerCase()] = t[i] : Et(e, i, t[i], n.isSvg);
89
+ i.startsWith("on") ? e[i.toLowerCase()] = t[i] : wt(e, i, t[i], n.isSvg);
43
90
  }
44
- const bt = {
91
+ const Et = {
45
92
  className: "class",
46
93
  labelFor: "for"
47
94
  };
48
- function Et(e, t, n, i) {
49
- if (t = bt[t] || t, n === !0)
95
+ function wt(e, t, n, i) {
96
+ if (t = Et[t] || t, n === !0)
50
97
  e.setAttribute(t, "");
51
98
  else if (n === !1)
52
99
  e.removeAttribute(t);
53
100
  else {
54
- const r = i ? mt[t] : void 0;
55
- r !== void 0 ? e.setAttributeNS(r, t, n) : e.setAttribute(t, n);
101
+ const o = i ? yt[t] : void 0;
102
+ o !== void 0 ? e.setAttributeNS(o, t, n) : e.setAttribute(t, n);
56
103
  }
57
104
  }
58
- function Ct(e) {
105
+ function Xt(e) {
59
106
  return e.reduce((t, n) => t.concat(n), []);
60
107
  }
61
- function D(e, t) {
62
- return Array.isArray(e) ? Ct(e.map((n) => D(n, t))) : _(e, t);
108
+ function $(e, t) {
109
+ return Array.isArray(e) ? Xt(e.map((n) => $(n, t))) : B(e, t);
63
110
  }
64
- function _(e, t = zt) {
111
+ function B(e, t = zt) {
65
112
  if (e == null || typeof e == "boolean")
66
113
  return null;
67
114
  if (e instanceof Node)
@@ -71,46 +118,46 @@ function _(e, t = zt) {
71
118
  type: n,
72
119
  props: i
73
120
  } = e;
74
- if (n === vt) {
121
+ if (n === bt) {
75
122
  const a = document.createDocumentFragment();
76
123
  if (i.children) {
77
- const c = D(i.children, t);
78
- V(a, c);
124
+ const c = $(i.children, t);
125
+ I(a, c);
79
126
  }
80
127
  return a;
81
128
  }
82
- const r = n(i);
83
- return _(r, t);
129
+ const o = n(i);
130
+ return B(o, t);
84
131
  }
85
- if (xt(e))
132
+ if (kt(e))
86
133
  return document.createTextNode(`${e}`);
87
- if (yt(e)) {
134
+ if (vt(e)) {
88
135
  let n;
89
136
  const {
90
137
  type: i,
91
- props: r
138
+ props: o
92
139
  } = e;
93
140
  if (!t.isSvg && i === "svg" && (t = Object.assign({}, t, {
94
141
  isSvg: !0
95
- })), t.isSvg ? n = document.createElementNS(gt, i) : n = document.createElement(i), kt(n, r, t), r.children) {
142
+ })), t.isSvg ? n = document.createElementNS(xt, i) : n = document.createElement(i), Ct(n, o, t), o.children) {
96
143
  let c = t;
97
144
  t.isSvg && i === "foreignObject" && (c = Object.assign({}, c, {
98
145
  isSvg: !1
99
146
  }));
100
- const s = D(r.children, c);
101
- s != null && V(n, s);
147
+ const s = $(o.children, c);
148
+ s != null && I(n, s);
102
149
  }
103
150
  const {
104
151
  ref: a
105
- } = r;
152
+ } = o;
106
153
  return typeof a == "function" && a(n), n;
107
154
  }
108
155
  throw new Error("mount: Invalid Vnode!");
109
156
  }
110
- function $(e) {
111
- return _(e);
157
+ function O(e) {
158
+ return B(e);
112
159
  }
113
- function wt(e) {
160
+ function jt(e) {
114
161
  var t = 0, n = e.children, i = n && n.length;
115
162
  if (!i)
116
163
  t = 1;
@@ -119,130 +166,130 @@ function wt(e) {
119
166
  t += n[i].value;
120
167
  e.value = t;
121
168
  }
122
- function Xt() {
123
- return this.eachAfter(wt);
169
+ function Nt() {
170
+ return this.eachAfter(jt);
124
171
  }
125
- function jt(e) {
126
- var t = this, n, i = [t], r, a, c;
172
+ function Rt(e) {
173
+ var t = this, n, i = [t], o, a, c;
127
174
  do
128
175
  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]);
176
+ if (e(t), o = t.children, o)
177
+ for (a = 0, c = o.length; a < c; ++a)
178
+ i.push(o[a]);
132
179
  while (i.length);
133
180
  return this;
134
181
  }
135
- function Nt(e) {
136
- for (var t = this, n = [t], i, r; t = n.pop(); )
182
+ function Tt(e) {
183
+ for (var t = this, n = [t], i, o; t = n.pop(); )
137
184
  if (e(t), i = t.children, i)
138
- for (r = i.length - 1; r >= 0; --r)
139
- n.push(i[r]);
185
+ for (o = i.length - 1; o >= 0; --o)
186
+ n.push(i[o]);
140
187
  return this;
141
188
  }
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]);
189
+ function Mt(e) {
190
+ for (var t = this, n = [t], i = [], o, a, c; t = n.pop(); )
191
+ if (i.push(t), o = t.children, o)
192
+ for (a = 0, c = o.length; a < c; ++a)
193
+ n.push(o[a]);
147
194
  for (; t = i.pop(); )
148
195
  e(t);
149
196
  return this;
150
197
  }
151
- function Tt(e) {
198
+ function At(e) {
152
199
  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;
200
+ for (var n = +e(t.data) || 0, i = t.children, o = i && i.length; --o >= 0; )
201
+ n += i[o].value;
155
202
  t.value = n;
156
203
  });
157
204
  }
158
- function Mt(e) {
205
+ function _t(e) {
159
206
  return this.eachBefore(function(t) {
160
207
  t.children && t.children.sort(e);
161
208
  });
162
209
  }
163
- function At(e) {
164
- for (var t = this, n = Ot(t, e), i = [t]; t !== n; )
210
+ function Ot(e) {
211
+ for (var t = this, n = Dt(t, e), i = [t]; t !== n; )
165
212
  t = t.parent, i.push(t);
166
- for (var r = i.length; e !== n; )
167
- i.splice(r, 0, e), e = e.parent;
213
+ for (var o = i.length; e !== n; )
214
+ i.splice(o, 0, e), e = e.parent;
168
215
  return i;
169
216
  }
170
- function Ot(e, t) {
217
+ function Dt(e, t) {
171
218
  if (e === t)
172
219
  return e;
173
- var n = e.ancestors(), i = t.ancestors(), r = null;
220
+ var n = e.ancestors(), i = t.ancestors(), o = null;
174
221
  for (e = n.pop(), t = i.pop(); e === t; )
175
- r = e, e = n.pop(), t = i.pop();
176
- return r;
222
+ o = e, e = n.pop(), t = i.pop();
223
+ return o;
177
224
  }
178
- function Ht() {
225
+ function $t() {
179
226
  for (var e = this, t = [e]; e = e.parent; )
180
227
  t.push(e);
181
228
  return t;
182
229
  }
183
- function $t() {
230
+ function Bt() {
184
231
  var e = [];
185
232
  return this.each(function(t) {
186
233
  e.push(t);
187
234
  }), e;
188
235
  }
189
- function Bt() {
236
+ function Ft() {
190
237
  var e = [];
191
238
  return this.eachBefore(function(t) {
192
239
  t.children || e.push(t);
193
240
  }), e;
194
241
  }
195
- function Dt() {
242
+ function Ht() {
196
243
  var e = this, t = [];
197
244
  return e.each(function(n) {
198
245
  n !== e && t.push({ source: n.parent, target: n });
199
246
  }), t;
200
247
  }
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);
248
+ function F(e, t) {
249
+ var n = new N(e), i = +e.value && (n.value = e.value), o, a = [n], c, s, l, p;
250
+ for (t == null && (t = It); o = a.pop(); )
251
+ if (i && (o.value = +o.data.value), (s = t(o.data)) && (p = s.length))
252
+ for (o.children = new Array(p), l = p - 1; l >= 0; --l)
253
+ a.push(c = o.children[l] = new N(s[l])), c.parent = o, c.depth = o.depth + 1;
254
+ return n.eachBefore(Yt);
208
255
  }
209
- function Ft() {
210
- return L(this).eachBefore(Lt);
256
+ function Lt() {
257
+ return F(this).eachBefore(Wt);
211
258
  }
212
- function _t(e) {
259
+ function It(e) {
213
260
  return e.children;
214
261
  }
215
- function Lt(e) {
262
+ function Wt(e) {
216
263
  e.data = e.data.data;
217
264
  }
218
- function It(e) {
265
+ function Yt(e) {
219
266
  var t = 0;
220
267
  do
221
268
  e.height = t;
222
269
  while ((e = e.parent) && e.height < ++t);
223
270
  }
224
- function R(e) {
271
+ function N(e) {
225
272
  this.data = e, this.depth = this.height = 0, this.parent = null;
226
273
  }
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
274
+ N.prototype = F.prototype = {
275
+ constructor: N,
276
+ count: Nt,
277
+ each: Rt,
278
+ eachAfter: Mt,
279
+ eachBefore: Tt,
280
+ sum: At,
281
+ sort: _t,
282
+ path: Ot,
283
+ ancestors: $t,
284
+ descendants: Bt,
285
+ leaves: Ft,
286
+ links: Ht,
287
+ copy: Lt
241
288
  };
242
- const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index", Pt = {
289
+ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index", Gt = {
243
290
  name: "Chris Maloney",
244
291
  url: "http://chrismaloney.org"
245
- }, Ut = "Flexible tree layout algorithm that allows for variable node sizes.", Gt = [
292
+ }, Zt = "Flexible tree layout algorithm that allows for variable node sizes.", qt = [
246
293
  "d3",
247
294
  "d3-module",
248
295
  "layout",
@@ -254,10 +301,10 @@ const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index
254
301
  "infovis",
255
302
  "visualization",
256
303
  "2d"
257
- ], Zt = "https://github.com/klortho/d3-flextree", Jt = "WTFPL", qt = {
304
+ ], Jt = "https://github.com/klortho/d3-flextree", Qt = "WTFPL", te = {
258
305
  type: "git",
259
306
  url: "https://github.com/klortho/d3-flextree.git"
260
- }, Qt = {
307
+ }, ee = {
261
308
  clean: "rm -rf build demo test",
262
309
  "build:demo": "rollup -c --environment BUILD:demo",
263
310
  "build:dev": "rollup -c --environment BUILD:dev",
@@ -269,9 +316,9 @@ const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index
269
316
  "test:browser": "node test/browser-tests.js",
270
317
  test: "npm-run-all test:*",
271
318
  prepare: "npm-run-all clean build lint test"
272
- }, te = {
319
+ }, ne = {
273
320
  "d3-hierarchy": "^1.1.5"
274
- }, ee = {
321
+ }, ie = {
275
322
  "babel-plugin-external-helpers": "^6.22.0",
276
323
  "babel-preset-es2015-rollup": "^3.0.0",
277
324
  d3: "^4.13.0",
@@ -287,45 +334,45 @@ const Wt = "d3-flextree", Vt = "2.1.2", Yt = "build/d3-flextree.js", Kt = "index
287
334
  "rollup-plugin-node-resolve": "^3.0.2",
288
335
  "rollup-plugin-uglify": "^3.0.0",
289
336
  "uglify-es": "^3.3.9"
290
- }, ne = {
291
- name: Wt,
292
- version: Vt,
293
- main: Yt,
294
- module: Kt,
337
+ }, re = {
338
+ name: Vt,
339
+ version: Kt,
340
+ main: Pt,
341
+ module: Ut,
295
342
  "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({
343
+ author: Gt,
344
+ description: Zt,
345
+ keywords: qt,
346
+ homepage: Jt,
347
+ license: Qt,
348
+ repository: te,
349
+ scripts: ee,
350
+ dependencies: ne,
351
+ devDependencies: ie
352
+ }, { version: oe } = re, se = Object.freeze({
306
353
  children: (e) => e.children,
307
354
  nodeSize: (e) => e.data.size,
308
355
  spacing: 0
309
356
  });
310
- function Q(e) {
311
- const t = Object.assign({}, oe, e);
357
+ function q(e) {
358
+ const t = Object.assign({}, se, e);
312
359
  function n(s) {
313
360
  const l = t[s];
314
361
  return typeof l == "function" ? l : () => l;
315
362
  }
316
363
  function i(s) {
317
- const l = c(a(), s, (f) => f.children);
364
+ const l = c(a(), s, (p) => p.children);
318
365
  return l.update(), l.data;
319
366
  }
320
- function r() {
367
+ function o() {
321
368
  const s = n("nodeSize"), l = n("spacing");
322
- return class q extends L.prototype.constructor {
369
+ return class Z extends F.prototype.constructor {
323
370
  constructor(h) {
324
371
  super(h);
325
372
  }
326
373
  copy() {
327
- const h = c(this.constructor, this, (p) => p.children);
328
- return h.each((p) => p.data = p.data.data), h;
374
+ const h = c(this.constructor, this, (u) => u.children);
375
+ return h.each((u) => u.data = u.data.data), h;
329
376
  }
330
377
  get size() {
331
378
  return s(this);
@@ -375,7 +422,7 @@ function Q(e) {
375
422
  }
376
423
  get extents() {
377
424
  return (this.children || []).reduce(
378
- (h, p) => q.maxExtents(h, p.extents),
425
+ (h, u) => Z.maxExtents(h, u.extents),
379
426
  this.nodeExtents
380
427
  );
381
428
  }
@@ -387,18 +434,18 @@ function Q(e) {
387
434
  right: this.right
388
435
  };
389
436
  }
390
- static maxExtents(h, p) {
437
+ static maxExtents(h, u) {
391
438
  return {
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)
439
+ top: Math.min(h.top, u.top),
440
+ bottom: Math.max(h.bottom, u.bottom),
441
+ left: Math.min(h.left, u.left),
442
+ right: Math.max(h.right, u.right)
396
443
  };
397
444
  }
398
445
  };
399
446
  }
400
447
  function a() {
401
- const s = r(), l = n("nodeSize"), f = n("spacing");
448
+ const s = o(), l = n("nodeSize"), p = n("spacing");
402
449
  return class extends s {
403
450
  constructor(h) {
404
451
  super(h), Object.assign(this, {
@@ -420,7 +467,7 @@ function Q(e) {
420
467
  return l(this.data);
421
468
  }
422
469
  spacing(h) {
423
- return f(this.data, h.data);
470
+ return p(this.data, h.data);
424
471
  }
425
472
  get x() {
426
473
  return this.data.x;
@@ -435,27 +482,27 @@ function Q(e) {
435
482
  this.data.y = h;
436
483
  }
437
484
  update() {
438
- return tt(this), et(this), this;
485
+ return J(this), Q(this), this;
439
486
  }
440
487
  };
441
488
  }
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,
489
+ function c(s, l, p) {
490
+ const h = (u, g) => {
491
+ const y = new s(u);
492
+ Object.assign(y, {
493
+ parent: g,
494
+ depth: g === null ? 0 : g.depth + 1,
448
495
  height: 0,
449
496
  length: 1
450
497
  });
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
498
+ const f = p(u) || [];
499
+ return y.children = f.length === 0 ? null : f.map((k) => h(k, y)), y.children && Object.assign(y, y.children.reduce(
500
+ (k, m) => ({
501
+ height: Math.max(k.height, m.height + 1),
502
+ length: k.length + m.length
456
503
  }),
457
- d
458
- )), d;
504
+ y
505
+ )), y;
459
506
  };
460
507
  return h(l, null);
461
508
  }
@@ -470,66 +517,66 @@ function Q(e) {
470
517
  return arguments.length ? (t.children = s, i) : t.children;
471
518
  },
472
519
  hierarchy(s, l) {
473
- const f = typeof l > "u" ? t.children : l;
474
- return c(r(), s, f);
520
+ const p = typeof l > "u" ? t.children : l;
521
+ return c(o(), s, p);
475
522
  },
476
523
  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}},`;
524
+ const l = n("nodeSize"), p = (h) => (u) => {
525
+ const g = h + " ", y = h + " ", { x: f, y: k } = u, m = l(u), x = u.children || [], v = x.length === 0 ? " " : `,${g}children: [${y}${x.map(p(y)).join(y)}${g}],${h}`;
526
+ return `{ size: [${m.join(", ")}],${g}x: ${f}, y: ${k}${v}},`;
480
527
  };
481
- return f(`
528
+ return p(`
482
529
  `)(s);
483
530
  }
484
531
  }), i;
485
532
  }
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) => {
533
+ q.version = oe;
534
+ const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
535
+ const [o, a] = n;
536
+ J(i, e.y + e.ySize);
537
+ const c = (o === 0 ? i.lExt : i.rExt).bottom;
538
+ o !== 0 && le(e, o, a);
539
+ const s = ge(c, o, a);
540
+ return [o + 1, s];
541
+ }, [0, null]), ae(e), me(e), e), Q = (e, t, n) => {
495
542
  typeof t > "u" && (t = -e.relX - e.prelim, n = 0);
496
543
  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) => {
544
+ return e.relX = i + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((o) => Q(o, i, e.x)), e;
545
+ }, ae = (e) => {
499
546
  (e.children || []).reduce((t, n) => {
500
- const [i, r] = t, a = i + n.shift, c = r + a + n.change;
547
+ const [i, o] = t, a = i + n.shift, c = o + a + n.change;
501
548
  return n.relX += c, [a, c];
502
549
  }, [0, 0]);
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;
550
+ }, le = (e, t, n) => {
551
+ const i = e.children[t - 1], o = e.children[t];
552
+ let a = i, c = i.relX, s = o, l = o.relX, p = !0;
506
553
  for (; a && s; ) {
507
554
  a.bottom > n.lowY && (n = n.next);
508
555
  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));
556
+ (h > 0 || h < 0 && p) && (l += h, ce(o, h), he(e, t, n.index, h)), p = !1;
557
+ const u = a.bottom, g = s.bottom;
558
+ u <= g && (a = ue(a), a && (c += a.relX)), u >= g && (s = de(s), s && (l += s.relX));
512
559
  }
513
- !a && s ? de(e, t, s, l) : a && !s && ue(e, t, a, c);
514
- }, ae = (e, t) => {
560
+ !a && s ? pe(e, t, s, l) : a && !s && fe(e, t, a, c);
561
+ }, ce = (e, t) => {
515
562
  e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
516
- }, le = (e, t, n, i) => {
517
- const r = e.children[t], a = t - n;
563
+ }, he = (e, t, n, i) => {
564
+ const o = e.children[t], a = t - n;
518
565
  if (a > 1) {
519
566
  const c = i / a;
520
- e.children[n + 1].shift += c, r.shift -= c, r.change -= i - c;
567
+ e.children[n + 1].shift += c, o.shift -= c, o.change -= i - c;
521
568
  }
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];
569
+ }, de = (e) => e.hasChildren ? e.firstChild : e.lThr, ue = (e) => e.hasChildren ? e.lastChild : e.rThr, pe = (e, t, n, i) => {
570
+ const o = e.firstChild, a = o.lExt, c = e.children[t];
524
571
  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];
572
+ const s = i - n.relX - o.lExtRelX;
573
+ a.relX += s, a.prelim -= s, o.lExt = c.lExt, o.lExtRelX = c.lExtRelX;
574
+ }, fe = (e, t, n, i) => {
575
+ const o = e.children[t], a = o.rExt, c = e.children[t - 1];
529
576
  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) => {
577
+ const s = i - n.relX - o.rExtRelX;
578
+ a.relX += s, a.prelim -= s, o.rExt = c.rExt, o.rExtRelX = c.rExtRelX;
579
+ }, me = (e) => {
533
580
  if (e.hasChildren) {
534
581
  const t = e.firstChild, n = e.lastChild, i = (t.prelim + t.relX - t.xSize / 2 + n.relX + n.prelim + n.xSize / 2) / 2;
535
582
  Object.assign(e, {
@@ -540,7 +587,7 @@ const tt = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
540
587
  rExtRelX: n.rExtRelX
541
588
  });
542
589
  }
543
- }, fe = (e, t, n) => {
590
+ }, ge = (e, t, n) => {
544
591
  for (; n !== null && e >= n.lowY; )
545
592
  n = n.next;
546
593
  return {
@@ -548,67 +595,63 @@ const tt = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
548
595
  index: t,
549
596
  next: n
550
597
  };
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) {
598
+ }, xe = ".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}", tt = ".markmap{--markmap-max-width: none;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;font:var(--markmap-font)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);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:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign-testing-max{max-width:var(--markmap-max-width)}.markmap-foreign-testing-max img{max-width:var(--markmap-max-width);max-height:none}", be = tt;
599
+ function W(e) {
553
600
  const t = e.data;
554
- return Math.max(4 - 2 * t.depth, 1.5);
601
+ return Math.max(4 - 2 * t.state.depth, 1.5);
555
602
  }
556
- function K(e, t) {
557
- const n = ft(e, t);
603
+ function Y(e, t) {
604
+ const n = mt(e, t);
558
605
  return e[n];
559
606
  }
560
- function B(e) {
607
+ function D(e) {
561
608
  e.stopPropagation();
562
609
  }
563
- function me() {
564
- return {
565
- transformHtml: new U()
566
- };
567
- }
568
- const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), C = class C {
610
+ const ye = new st();
611
+ class et {
569
612
  constructor(t, n) {
570
- this.options = C.defaultOptions, this.revokers = [], this.handleZoom = (i) => {
571
- const { transform: r } = i;
572
- this.g.attr("transform", r);
613
+ this.options = P, this.revokers = [], this.imgCache = {}, this.handleZoom = (i) => {
614
+ const { transform: o } = i;
615
+ this.g.attr("transform", o);
573
616
  }, this.handlePan = (i) => {
574
617
  i.preventDefault();
575
- const r = O(this.svg.node()), a = r.translate(
576
- -i.deltaX / r.k,
577
- -i.deltaY / r.k
618
+ const o = A(this.svg.node()), a = o.translate(
619
+ -i.deltaX / o.k,
620
+ -i.deltaY / o.k
578
621
  );
579
622
  this.svg.call(this.zoom.transform, a);
580
- }, this.handleClick = (i, r) => {
623
+ }, this.handleClick = (i, o) => {
581
624
  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 = {
625
+ (K ? i.metaKey : i.ctrlKey) && (a = !a), this.toggleNode(o.data, a);
626
+ }, this.svg = t.datum ? t : dt(t), this.styleNode = this.svg.append("style"), this.zoom = ut().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
627
  id: this.options.id || this.svg.attr("id") || at(),
585
628
  minX: 0,
586
629
  maxX: 0,
587
630
  minY: 0,
588
631
  maxY: 0
589
- }, this.g = this.svg.append("g"), this.revokers.push(
590
- xe.tap(() => {
632
+ }, this.g = this.svg.append("g"), this.debouncedRefresh = lt(() => this.setData(), 200), this.revokers.push(
633
+ ye.tap(() => {
591
634
  this.setData();
592
635
  })
593
636
  );
594
637
  }
595
638
  getStyleContent() {
596
639
  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(`
640
+ return [this.options.embedGlobalCSS && tt, i].filter(Boolean).join(`
598
641
  `);
599
642
  }
600
643
  updateStyle() {
601
644
  this.svg.attr(
602
645
  "class",
603
- lt(this.svg.attr("class"), "markmap", this.state.id)
646
+ ct(this.svg.attr("class"), "markmap", this.state.id)
604
647
  );
605
648
  const t = this.getStyleContent();
606
649
  this.styleNode.text(t);
607
650
  }
608
651
  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) => {
652
+ var o, a;
653
+ const i = (o = t.payload) != null && o.fold ? 0 : 1;
654
+ n ? T(t, (c, s) => {
612
655
  c.payload = {
613
656
  ...c.payload,
614
657
  fold: i
@@ -620,44 +663,67 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
620
663
  }
621
664
  initializeData(t) {
622
665
  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(`
666
+ const { color: i, nodeMinHeight: o, maxWidth: a, initialExpandLevel: c } = this.options, { id: s } = this.state, l = O(
667
+ /* @__PURE__ */ j("div", { className: `markmap-container markmap ${s}-g` })
668
+ ), p = O(
669
+ /* @__PURE__ */ j("style", { children: [this.getStyleContent(), xe].join(`
627
670
  `) })
628
671
  );
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 } }) })
672
+ document.body.append(l, p);
673
+ const h = a ? `--markmap-max-width: ${a}px` : "";
674
+ let u = 0, g = 0;
675
+ T(t, (f, k, m) => {
676
+ var b, w, z;
677
+ g += 1, f.children = (b = f.children) == null ? void 0 : b.map((C) => ({ ...C })), n += 1;
678
+ const x = O(
679
+ /* @__PURE__ */ j(
680
+ "div",
681
+ {
682
+ className: "markmap-foreign markmap-foreign-testing-max",
683
+ style: h,
684
+ children: /* @__PURE__ */ j("div", { dangerouslySetInnerHTML: { __html: f.content } })
685
+ }
686
+ )
637
687
  );
638
- l.append(g), d.state = {
639
- ...d.state,
688
+ l.append(x), f.state = {
689
+ ...f.state,
690
+ depth: g,
640
691
  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);
692
+ el: x.firstChild
693
+ }, f.state.path = [(w = m == null ? void 0 : m.state) == null ? void 0 : w.path, f.state.id].filter(Boolean).join("."), i(f);
694
+ const v = ((z = f.payload) == null ? void 0 : z.fold) === 2;
695
+ v ? u += 1 : (u || c >= 0 && f.state.depth >= c) && (f.payload = { ...f.payload, fold: 1 }), k(), v && (u -= 1), g -= 1;
645
696
  });
646
- const m = Array.from(l.childNodes).map(
647
- (d) => d.firstChild
697
+ const y = Array.from(l.childNodes).map(
698
+ (f) => f.firstChild
648
699
  );
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();
700
+ this._checkImages(l), y.forEach((f) => {
701
+ var k;
702
+ (k = f.parentNode) == null || k.append(f.cloneNode(!0));
703
+ }), T(t, (f, k, m) => {
704
+ var b;
705
+ const x = f.state, v = x.el.getBoundingClientRect();
706
+ f.content = x.el.innerHTML, x.size = [
707
+ Math.ceil(v.width) + 1,
708
+ Math.max(Math.ceil(v.height), o)
709
+ ], x.key = [(b = m == null ? void 0 : m.state) == null ? void 0 : b.id, x.id].filter(Boolean).join(".") + // FIXME: find a way to check content hash
710
+ f.content, k();
711
+ }), l.remove(), p.remove();
712
+ }
713
+ _checkImages(t) {
714
+ t.querySelectorAll("img").forEach((n) => {
715
+ if (n.width)
716
+ return;
717
+ const i = this.imgCache[n.src];
718
+ i != null && i[0] ? [n.width, n.height] = i : i || this._loadImage(n.src);
719
+ });
720
+ }
721
+ _loadImage(t) {
722
+ this.imgCache[t] = [0, 0];
723
+ const n = new Image();
724
+ n.src = t, n.onload = () => {
725
+ this.imgCache[t] = [n.naturalWidth, n.naturalHeight], this.debouncedRefresh();
726
+ };
661
727
  }
662
728
  setOptions(t) {
663
729
  this.options = {
@@ -671,124 +737,124 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
671
737
  renderData(t) {
672
738
  if (!this.state.data)
673
739
  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);
740
+ const { spacingHorizontal: n, paddingX: i, spacingVertical: o, autoFit: a, color: c } = this.options, s = q({}).children((r) => {
741
+ var d;
742
+ if (!((d = r.payload) != null && d.fold))
743
+ return r.children;
744
+ }).nodeSize((r) => {
745
+ const [d, S] = r.data.state.size;
746
+ return [S, d + (d ? i * 2 : 0) + n];
747
+ }).spacing((r, d) => r.parent === d.parent ? o : o * 2), l = s.hierarchy(this.state.data);
682
748
  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);
749
+ const p = l.descendants().reverse(), h = l.links(), u = pt(), g = H(p, (r) => r.x - r.xSize / 2), y = L(p, (r) => r.x + r.xSize / 2), f = H(p, (r) => r.y), k = L(p, (r) => r.y + r.ySize - n);
684
750
  Object.assign(this.state, {
685
- minX: m,
686
- maxX: d,
687
- minY: S,
688
- maxY: x
751
+ minX: g,
752
+ maxX: y,
753
+ minY: f,
754
+ maxY: k
689
755
  }), 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(
756
+ const m = t && p.find((r) => r.data === t) || l, x = m.data.state.x0 ?? m.x, v = m.data.state.y0 ?? m.y, b = this.g.selectAll(
757
+ E("g")
758
+ ).data(p, (r) => r.data.state.key), w = b.enter().append("g").attr("data-depth", (r) => r.data.state.depth).attr("data-path", (r) => r.data.state.path).attr(
693
759
  "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(
760
+ (r) => `translate(${v + m.ySize - r.ySize},${x + m.xSize / 2 - r.xSize})`
761
+ ), z = this.transition(b.exit());
762
+ z.select("line").attr("x1", (r) => r.ySize - n).attr("x2", (r) => r.ySize - n), z.select("foreignObject").style("opacity", 0), z.attr(
697
763
  "transform",
698
- (o) => `translate(${g.y + g.ySize - o.ySize},${g.x + g.xSize / 2 - o.xSize})`
764
+ (r) => `translate(${m.y + m.ySize - r.ySize},${m.x + m.xSize / 2 - r.xSize})`
699
765
  ).remove();
700
- const X = k.merge(w).attr(
766
+ const C = b.merge(w).attr(
701
767
  "class",
702
- (o) => {
703
- var u;
704
- return ["markmap-node", ((u = o.data.payload) == null ? void 0 : u.fold) && "markmap-fold"].filter(Boolean).join(" ");
768
+ (r) => {
769
+ var d;
770
+ return ["markmap-node", ((d = r.data.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
705
771
  }
706
772
  );
707
- this.transition(X).attr(
773
+ this.transition(C).attr(
708
774
  "transform",
709
- (o) => `translate(${o.y},${o.x - o.xSize / 2})`
775
+ (r) => `translate(${r.y},${r.x - r.xSize / 2})`
710
776
  );
711
- const it = X.selectAll(
712
- b("line")
777
+ const nt = C.selectAll(
778
+ E("line")
713
779
  ).data(
714
- (o) => [o],
715
- (o) => o.data.state.key
780
+ (r) => [r],
781
+ (r) => r.data.state.key
716
782
  ).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()
783
+ (r) => r.append("line").attr("x1", (d) => d.ySize - n).attr("x2", (d) => d.ySize - n),
784
+ (r) => r,
785
+ (r) => r.remove()
720
786
  );
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")
787
+ this.transition(nt).attr("x1", -1).attr("x2", (r) => r.ySize - n + 2).attr("y1", (r) => r.xSize).attr("y2", (r) => r.xSize).attr("stroke", (r) => c(r.data)).attr("stroke-width", W);
788
+ const it = C.selectAll(
789
+ E("circle")
724
790
  ).data(
725
- (o) => {
726
- var u;
727
- return (u = o.data.children) != null && u.length ? [o] : [];
791
+ (r) => {
792
+ var d;
793
+ return (d = r.data.children) != null && d.length ? [r] : [];
728
794
  },
729
- (o) => o.data.state.key
795
+ (r) => r.data.state.key
730
796
  ).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()
797
+ (r) => r.append("circle").attr("stroke-width", "1.5").attr("cx", (d) => d.ySize - n).attr("cy", (d) => d.xSize).attr("r", 0).on("click", (d, S) => this.handleClick(d, S)).on("mousedown", D),
798
+ (r) => r,
799
+ (r) => r.remove()
734
800
  );
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(
801
+ this.transition(it).attr("r", 6).attr("cx", (r) => r.ySize - n).attr("cy", (r) => r.xSize).attr("stroke", (r) => c(r.data)).attr(
736
802
  "fill",
737
- (o) => {
738
- var u;
739
- return (u = o.data.payload) != null && u.fold && o.data.children ? c(o.data) : "#fff";
803
+ (r) => {
804
+ var d;
805
+ return (d = r.data.payload) != null && d.fold && r.data.children ? c(r.data) : "#fff";
740
806
  }
741
807
  );
742
- const rt = X.selectAll(
743
- b("foreignObject")
808
+ const rt = C.selectAll(
809
+ E("foreignObject")
744
810
  ).data(
745
- (o) => [o],
746
- (o) => o.data.state.key
811
+ (r) => [r],
812
+ (r) => r.data.state.key
747
813
  ).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;
814
+ (r) => {
815
+ const d = r.append("foreignObject").attr("class", "markmap-foreign").attr("x", i).attr("y", 0).style("opacity", 0).on("mousedown", D).on("dblclick", D);
816
+ return d.append("xhtml:div").select(function(R) {
817
+ const X = R.data.state.el.cloneNode(!0);
818
+ return this.replaceWith(X), X;
819
+ }).attr("xmlns", "http://www.w3.org/1999/xhtml"), d;
754
820
  },
755
- (o) => o,
756
- (o) => o.remove()
821
+ (r) => r,
822
+ (r) => r.remove()
757
823
  ).attr(
758
824
  "width",
759
- (o) => Math.max(0, o.ySize - n - i * 2)
760
- ).attr("height", (o) => o.xSize);
825
+ (r) => Math.max(0, r.ySize - n - i * 2)
826
+ ).attr("height", (r) => r.xSize);
761
827
  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
828
+ const ot = this.g.selectAll(
829
+ E("path")
830
+ ).data(h, (r) => r.target.data.state.key).join(
831
+ (r) => {
832
+ const d = [
833
+ v + m.ySize - n,
834
+ x + m.xSize / 2
769
835
  ];
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 }));
836
+ return r.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (S) => S.target.data.state.depth).attr("data-path", (S) => S.target.data.state.path).attr("d", u({ source: d, target: d }));
771
837
  },
772
- (o) => o,
773
- (o) => {
774
- const u = [
775
- g.y + g.ySize - n,
776
- g.x + g.xSize / 2
838
+ (r) => r,
839
+ (r) => {
840
+ const d = [
841
+ m.y + m.ySize - n,
842
+ m.x + m.xSize / 2
777
843
  ];
778
- return this.transition(o).attr("d", p({ source: u, target: u })).remove();
844
+ return this.transition(r).attr("d", u({ source: d, target: d })).remove();
779
845
  }
780
846
  );
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
847
+ this.transition(ot).attr("stroke", (r) => c(r.target.data)).attr("stroke-width", (r) => W(r.target)).attr("d", (r) => {
848
+ const d = r.source, S = r.target, R = [
849
+ d.y + d.ySize - n,
850
+ d.x + d.xSize / 2
851
+ ], X = [
852
+ S.y,
853
+ S.x + S.xSize / 2
788
854
  ];
789
- return p({ source: T, target: j });
790
- }), f.forEach((o) => {
791
- o.data.state.x0 = o.x, o.data.state.y0 = o.y;
855
+ return u({ source: R, target: X });
856
+ }), p.forEach((r) => {
857
+ r.data.state.x0 = r.x, r.data.state.y0 = r.y;
792
858
  });
793
859
  }
794
860
  transition(t) {
@@ -799,15 +865,15 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
799
865
  * Fit the content to the viewport.
800
866
  */
801
867
  async fit() {
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,
868
+ const t = this.svg.node(), { width: n, height: i } = t.getBoundingClientRect(), { fitRatio: o } = this.options, { minX: a, maxX: c, minY: s, maxY: l } = this.state, p = l - s, h = c - a, u = Math.min(
869
+ n / p * o,
870
+ i / h * o,
805
871
  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);
872
+ ), g = ft.translate(
873
+ (n - p * u) / 2 - s * u,
874
+ (i - h * u) / 2 - a * u
875
+ ).scale(u);
876
+ return this.transition(this.svg).call(this.zoom.transform, g).end().catch(M);
811
877
  }
812
878
  /**
813
879
  * Pan the content to make the provided node visible in the viewport.
@@ -815,38 +881,38 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
815
881
  async ensureView(t, n) {
816
882
  let i;
817
883
  if (this.g.selectAll(
818
- b("g")
884
+ E("g")
819
885
  ).each(function(v) {
820
886
  v.data === t && (i = v);
821
887
  }), !i)
822
888
  return;
823
- const r = this.svg.node(), { spacingHorizontal: a } = this.options, c = r.getBoundingClientRect(), s = O(r), [l, f] = [
889
+ const o = this.svg.node(), { spacingHorizontal: a } = this.options, c = o.getBoundingClientRect(), s = A(o), [l, p] = [
824
890
  i.y,
825
891
  i.y + i.ySize - a + 2
826
- ].map((y) => y * s.k + s.x), [h, p] = [
892
+ ].map((x) => x * s.k + s.x), [h, u] = [
827
893
  i.x - i.xSize / 2,
828
894
  i.x + i.xSize / 2
829
- ].map((y) => y * s.k + s.y), m = {
895
+ ].map((x) => x * s.k + s.y), g = {
830
896
  left: 0,
831
897
  right: 0,
832
898
  top: 0,
833
899
  bottom: 0,
834
900
  ...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);
901
+ }, y = [g.left - l, c.width - g.right - p], f = [g.top - h, c.height - g.bottom - u], k = y[0] * y[1] > 0 ? Y(y, Math.abs) / s.k : 0, m = f[0] * f[1] > 0 ? Y(f, Math.abs) / s.k : 0;
902
+ if (k || m) {
903
+ const x = s.translate(k, m);
904
+ return this.transition(this.svg).call(this.zoom.transform, x).end().catch(M);
839
905
  }
840
906
  }
841
907
  /**
842
908
  * Scale content with it pinned at the center of the viewport.
843
909
  */
844
910
  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(
911
+ const n = this.svg.node(), { width: i, height: o } = n.getBoundingClientRect(), a = i / 2, c = o / 2, s = A(n), l = s.translate(
846
912
  (a - s.x) * (1 - t) / s.k,
847
913
  (c - s.y) * (1 - t) / s.k
848
914
  ).scale(t);
849
- return this.transition(this.svg).call(this.zoom.transform, l).end().catch(A);
915
+ return this.transition(this.svg).call(this.zoom.transform, l).end().catch(M);
850
916
  }
851
917
  destroy() {
852
918
  this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
@@ -854,64 +920,18 @@ const xe = new U(), ye = G(ct), P = typeof navigator < "u" && navigator.userAgen
854
920
  });
855
921
  }
856
922
  static create(t, n, i = null) {
857
- const r = new C(t, n);
858
- return i && (r.setData(i), r.fit()), r;
859
- }
860
- };
861
- C.defaultOptions = {
862
- autoFit: !1,
863
- color: (t) => {
864
- var n;
865
- return ye(`${((n = t.state) == null ? void 0 : n.path) || ""}`);
866
- },
867
- duration: 500,
868
- embedGlobalCSS: !0,
869
- fitRatio: 0.95,
870
- maxWidth: 0,
871
- nodeMinHeight: 16,
872
- paddingX: 8,
873
- scrollForPan: P,
874
- spacingHorizontal: 80,
875
- spacingVertical: 5,
876
- initialExpandLevel: -1,
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));
923
+ const o = new et(t, n);
924
+ return i && (o.setData(i), o.fit()), o;
900
925
  }
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
926
  }
909
927
  export {
910
- F as Markmap,
911
- ye as defaultColorFn,
912
- ke as deriveOptions,
913
- ze as globalCSS,
914
- Ce as loadCSS,
928
+ et as Markmap,
929
+ gt as defaultColorFn,
930
+ P as defaultOptions,
931
+ Se as deriveOptions,
932
+ be as globalCSS,
933
+ K as isMacintosh,
934
+ Ee as loadCSS,
915
935
  we as loadJS,
916
- xe as refreshHook
936
+ ye as refreshHook
917
937
  };