mind-elixir
Version:
Mind elixir is a free open source mind map core.
1,108 lines • 59.2 kB
JavaScript
const K = {
name: "Latte",
type: "light",
palette: ["#dd7878", "#ea76cb", "#8839ef", "#e64553", "#fe640b", "#df8e1d", "#40a02b", "#209fb5", "#1e66f5", "#7287fd"],
cssVar: {
"--node-gap-x": "30px",
"--node-gap-y": "10px",
"--main-gap-x": "65px",
"--main-gap-y": "45px",
"--root-radius": "30px",
"--main-radius": "20px",
"--root-color": "#ffffff",
"--root-bgcolor": "#4c4f69",
"--root-border-color": "rgba(0, 0, 0, 0)",
"--main-color": "#444446",
"--main-bgcolor": "#ffffff",
"--topic-padding": "3px",
"--color": "#777777",
"--bgcolor": "#f6f6f6",
"--selected": "#4dc4ff",
"--panel-color": "#444446",
"--panel-bgcolor": "#ffffff",
"--panel-border-color": "#eaeaea",
"--map-padding": "50px"
}
}, J = {
name: "Dark",
type: "dark",
palette: ["#848FA0", "#748BE9", "#D2F9FE", "#4145A5", "#789AFA", "#706CF4", "#EF987F", "#775DD5", "#FCEECF", "#DA7FBC"],
cssVar: {
"--node-gap-x": "30px",
"--node-gap-y": "10px",
"--main-gap-x": "65px",
"--main-gap-y": "45px",
"--root-radius": "30px",
"--main-radius": "20px",
"--root-color": "#ffffff",
"--root-bgcolor": "#2d3748",
"--root-border-color": "rgba(255, 255, 255, 0.1)",
"--main-color": "#ffffff",
"--main-bgcolor": "#4c4f69",
"--topic-padding": "3px",
"--color": "#cccccc",
"--bgcolor": "#252526",
"--selected": "#4dc4ff",
"--panel-color": "#ffffff",
"--panel-bgcolor": "#2d3748",
"--panel-border-color": "#696969",
"--map-padding": "50px 80px"
}
};
function it(t) {
return t.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
}
const Y = function(t, e) {
if (e.id === t)
return e;
if (e.children && e.children.length) {
for (let n = 0; n < e.children.length; n++) {
const o = Y(t, e.children[n]);
if (o)
return o;
}
return null;
} else
return null;
}, Q = (t, e) => {
if (t.parent = e, t.children)
for (let n = 0; n < t.children.length; n++)
Q(t.children[n], t);
};
function R(t, e, n, o) {
const i = o - e, s = t - n;
let r = Math.atan(Math.abs(i) / Math.abs(s)) / 3.14 * 180;
if (isNaN(r))
return;
s < 0 && i > 0 && (r = 180 - r), s < 0 && i < 0 && (r = 180 + r), s > 0 && i < 0 && (r = 360 - r);
const a = 12, f = 30, d = r + f, p = r - f;
return {
x1: n + Math.cos(Math.PI * d / 180) * a,
y1: o - Math.sin(Math.PI * d / 180) * a,
x2: n + Math.cos(Math.PI * p / 180) * a,
y2: o - Math.sin(Math.PI * p / 180) * a
};
}
function W() {
return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16);
}
const St = function() {
const t = W();
return {
topic: this.newTopicName,
id: t
};
}, D = (t, e) => {
let n = 0, o = 0;
for (; e && e !== t; )
n += e.offsetLeft, o += e.offsetTop, e = e.offsetParent;
return { offsetLeft: n, offsetTop: o };
}, v = (t, e) => {
for (const n in e)
t.setAttribute(n, e[n]);
}, st = (t) => t ? t.tagName === "ME-TPC" : !1, ft = (t) => {
const e = /translate\(([^,]+),\s*([^)]+)\)/, n = t.match(e);
return n ? { x: parseFloat(n[1]), y: parseFloat(n[2]) } : { x: 0, y: 0 };
}, pt = function(t) {
for (let e = 0; e < t.length; e++) {
const { dom: n, evt: o, func: i } = t[e];
n.addEventListener(o, i);
}
return function() {
for (let n = 0; n < t.length; n++) {
const { dom: o, evt: i, func: s } = t[n];
o.removeEventListener(i, s);
}
};
};
var P = /* @__PURE__ */ ((t) => (t.LHS = "lhs", t.RHS = "rhs", t))(P || {});
const rt = function(t, e, n) {
const { scaleVal: o, scaleSensitivity: i } = t;
switch (e) {
case "in":
if (o > 1.6)
return;
t.scale(o + i, n);
break;
case "out":
if (o < 0.6)
return;
t.scale(o - i, n);
}
};
function Et(t) {
const { dragMoveHelper: e } = t, n = (l) => {
var m, w, x;
if (l.button !== 0)
return;
if ((m = t.helper1) != null && m.moved) {
t.helper1.clear();
return;
}
if ((w = t.helper2) != null && w.moved) {
t.helper2.clear();
return;
}
if (e.moved) {
e.clear();
return;
}
const c = l.target;
if (c.tagName === "ME-EPD")
l.ctrlKey || l.metaKey ? t.expandNodeAll(c.previousSibling) : t.expandNode(c.previousSibling);
else if (c.tagName === "ME-TPC" && t.currentNodes.length > 1)
t.selectNode(c);
else if (!t.editable)
return;
const h = (x = c.parentElement) == null ? void 0 : x.parentElement;
h.getAttribute("class") === "topiclinks" ? t.selectArrow(c.parentElement) : h.getAttribute("class") === "summary" && t.selectSummary(c.parentElement);
}, o = (l) => {
var m;
if (!t.editable)
return;
const c = l.target;
st(c) && t.beginEdit(c);
const h = (m = c.parentElement) == null ? void 0 : m.parentElement;
h.getAttribute("class") === "topiclinks" ? t.editArrowLabel(c.parentElement) : h.getAttribute("class") === "summary" && t.editSummary(c.parentElement);
};
let i = 0;
const s = (l) => {
if (l.pointerType === "mouse")
return;
const c = (/* @__PURE__ */ new Date()).getTime(), h = c - i;
h < 300 && h > 0 && o(l), i = c;
}, r = (l) => {
e.moved = !1;
const c = t.mouseSelectionButton === 0 ? 2 : 0;
if (l.button !== c && l.pointerType === "mouse")
return;
e.x = l.clientX, e.y = l.clientY;
const h = l.target;
h.className !== "circle" && h.contentEditable !== "plaintext-only" && (e.mousedown = !0, t.map.style.transition = "none", h.setPointerCapture(l.pointerId));
}, a = (l) => {
if (l.target.contentEditable !== "plaintext-only") {
const c = l.clientX - e.x, h = l.clientY - e.y;
e.onMove(c, h);
}
e.x = l.clientX, e.y = l.clientY;
}, f = (l) => {
const c = t.mouseSelectionButton === 0 ? 2 : 0;
if (l.button !== c && l.pointerType === "mouse")
return;
const h = l.target;
h.hasPointerCapture && h.hasPointerCapture(l.pointerId) && h.releasePointerCapture(l.pointerId), e.clear();
}, d = (l) => {
if (l.preventDefault(), l.button !== 2 || !t.editable)
return;
const c = l.target;
st(c) && !c.classList.contains("selected") && t.selectNode(c), setTimeout(() => {
t.dragMoveHelper.moved || t.bus.fire("showContextMenu", l);
}, 200);
}, p = (l) => {
l.stopPropagation(), l.preventDefault(), l.ctrlKey || l.metaKey ? l.deltaY < 0 ? rt(t, "in", t.dragMoveHelper) : t.scaleVal - t.scaleSensitivity > 0 && rt(t, "out", t.dragMoveHelper) : l.shiftKey ? t.move(-l.deltaY, 0) : (t.map.style.transition = "none", t.move(-l.deltaX, -l.deltaY), t.map.style.transition = "transform 0.3s");
}, { container: u } = t;
return pt([
{ dom: u, evt: "pointerdown", func: r },
{ dom: u, evt: "pointermove", func: a },
{ dom: u, evt: "pointerup", func: f },
{ dom: u, evt: "pointerup", func: s },
{ dom: u, evt: "click", func: n },
{ dom: u, evt: "dblclick", func: o },
{ dom: u, evt: "contextmenu", func: d },
{ dom: u, evt: "wheel", func: p }
]);
}
function Tt() {
return {
handlers: {},
addListener: function(t, e) {
this.handlers[t] === void 0 && (this.handlers[t] = []), this.handlers[t].push(e);
},
fire: function(t, ...e) {
if (this.handlers[t] instanceof Array) {
const n = this.handlers[t];
for (let o = 0; o < n.length; o++)
n[o](...e);
}
},
removeListener: function(t, e) {
if (!this.handlers[t])
return;
const n = this.handlers[t];
if (!e)
n.length = 0;
else if (n.length)
for (let o = 0; o < n.length; o++)
n[o] === e && this.handlers[t].splice(o, 1);
}
};
}
const X = document, Lt = function() {
this.nodes.innerHTML = "";
const t = this.createTopic(this.nodeData);
gt(t, this.nodeData), t.draggable = !1;
const e = X.createElement("me-root");
e.appendChild(t);
const n = this.nodeData.children || [];
if (this.direction === 2) {
let o = 0, i = 0;
n.map((s) => {
s.direction === 0 ? o += 1 : s.direction === 1 ? i += 1 : o <= i ? (s.direction = 0, o += 1) : (s.direction = 1, i += 1);
});
}
kt(this, n, e);
}, kt = function(t, e, n) {
const o = X.createElement("me-main");
o.className = P.LHS;
const i = X.createElement("me-main");
i.className = P.RHS;
for (let s = 0; s < e.length; s++) {
const r = e[s], { grp: a } = t.createWrapper(r);
t.direction === 2 ? r.direction === 0 ? o.appendChild(a) : i.appendChild(a) : t.direction === 0 ? o.appendChild(a) : i.appendChild(a);
}
t.nodes.appendChild(o), t.nodes.appendChild(n), t.nodes.appendChild(i), t.nodes.appendChild(t.lines);
}, $t = function(t, e) {
const n = X.createElement("me-children");
for (let o = 0; o < e.length; o++) {
const i = e[o], { grp: s } = t.createWrapper(i);
n.appendChild(s);
}
return n;
}, k = document, ut = function(t, e) {
const o = (this != null && this.el ? this.el : e || document).querySelector(`[data-nodeid="me${t}"]`);
if (!o)
throw new Error(`FindEle: Node ${t} not found, maybe it's collapsed.`);
return o;
}, gt = function(t, e) {
if (t.innerHTML = "", e.style) {
const n = e.style;
for (const o in n)
t.style[o] = n[o];
}
if (e.dangerouslySetInnerHTML) {
t.innerHTML = e.dangerouslySetInnerHTML;
return;
}
if (e.image) {
const n = e.image;
if (n.url && n.width && n.height) {
const o = k.createElement("img");
o.src = n.url, o.style.width = n.width + "px", o.style.height = n.height + "px", n.fit && (o.style.objectFit = n.fit), t.appendChild(o), t.image = o;
}
} else
t.image && (t.image = void 0);
{
const n = k.createElement("span");
n.className = "text", n.textContent = e.topic, t.appendChild(n), t.text = n;
}
if (e.hyperLink) {
const n = k.createElement("a");
n.className = "hyper-link", n.target = "_blank", n.innerText = "🔗", n.href = e.hyperLink, t.appendChild(n), t.link = n;
} else
t.link && (t.link = void 0);
if (e.icons && e.icons.length) {
const n = k.createElement("span");
n.className = "icons", n.innerHTML = e.icons.map((o) => `<span>${it(o)}</span>`).join(""), t.appendChild(n), t.icons = n;
} else
t.icons && (t.icons = void 0);
if (e.tags && e.tags.length) {
const n = k.createElement("div");
n.className = "tags", n.innerHTML = e.tags.map((o) => `<span>${it(o)}</span>`).join(""), t.appendChild(n), t.tags = n;
} else
t.tags && (t.tags = void 0);
}, At = function(t, e) {
const n = k.createElement("me-wrapper"), { p: o, tpc: i } = this.createParent(t);
if (n.appendChild(o), !e && t.children && t.children.length > 0) {
const s = Ht(t.expanded);
if (o.appendChild(s), t.expanded !== !1) {
const r = $t(this, t.children);
n.appendChild(r);
}
}
return { grp: n, top: o, tpc: i };
}, Dt = function(t) {
const e = k.createElement("me-parent"), n = this.createTopic(t);
return gt(n, t), e.appendChild(n), { p: e, tpc: n };
}, Mt = function(t) {
const e = k.createElement("me-children");
return e.append(...t), e;
}, Nt = function(t) {
const e = k.createElement("me-tpc");
return e.nodeObj = t, e.dataset.nodeid = "me" + t.id, e.draggable = this.draggable, e;
};
function mt(t) {
const e = k.createRange();
e.selectNodeContents(t);
const n = window.getSelection();
n && (n.removeAllRanges(), n.addRange(e));
}
const Pt = function(t) {
if (!t)
return;
const e = k.createElement("div"), n = t.text.textContent;
t.appendChild(e), e.id = "input-box", e.textContent = n, e.contentEditable = "plaintext-only", e.spellcheck = !1;
const o = getComputedStyle(t);
e.style.cssText = `min-width:${t.offsetWidth - 8}px;
color:${o.color};
padding:${o.padding};
margin:${o.margin};
font:${o.font};
background-color:${o.backgroundColor !== "rgba(0, 0, 0, 0)" && o.backgroundColor};
border-radius:${o.borderRadius};`, this.direction === 0 && (e.style.right = "0"), mt(e), this.bus.fire("operation", {
name: "beginEdit",
obj: t.nodeObj
}), e.addEventListener("keydown", (i) => {
i.stopPropagation();
const s = i.key;
if (s === "Enter" || s === "Tab") {
if (i.shiftKey)
return;
i.preventDefault(), e.blur(), this.container.focus();
}
}), e.addEventListener("blur", () => {
var r;
if (!e)
return;
const i = t.nodeObj, s = ((r = e.textContent) == null ? void 0 : r.trim()) || "";
s === "" ? i.topic = n : i.topic = s, e.remove(), s !== n && (t.text.textContent = i.topic, this.linkDiv(), this.bus.fire("operation", {
name: "finishEdit",
obj: i,
origin: n
}));
});
}, Ht = function(t) {
const e = k.createElement("me-epd");
return e.expanded = t !== !1, e.className = t !== !1 ? "minus" : "", e;
}, N = document, T = "http://www.w3.org/2000/svg", wt = function(t, e, n) {
const o = N.createElementNS(T, "path");
return v(o, {
d: t,
stroke: e || "#666",
fill: "none",
"stroke-width": n
}), o;
}, V = function(t) {
const e = N.createElementNS(T, "svg");
return e.setAttribute("class", t), e.setAttribute("overflow", "visible"), e;
}, ct = function() {
const t = N.createElementNS(T, "line");
return t.setAttribute("stroke", "#4dc4ff"), t.setAttribute("fill", "none"), t.setAttribute("stroke-width", "2"), t.setAttribute("opacity", "0.45"), t;
}, Bt = function(t, e, n, o) {
const i = N.createElementNS(T, "g");
return [
{
name: "line",
d: t
},
{
name: "arrow1",
d: e
},
{
name: "arrow2",
d: n
}
].forEach((r, a) => {
const f = r.d, d = N.createElementNS(T, "path"), p = {
d: f,
stroke: (o == null ? void 0 : o.stroke) || "rgb(235, 95, 82)",
fill: "none",
"stroke-linecap": (o == null ? void 0 : o.strokeLinecap) || "cap",
"stroke-width": String((o == null ? void 0 : o.strokeWidth) || "2")
};
(o == null ? void 0 : o.opacity) !== void 0 && (p.opacity = String(o.opacity)), v(d, p), a === 0 && d.setAttribute("stroke-dasharray", (o == null ? void 0 : o.strokeDasharray) || "8,2");
const u = N.createElementNS(T, "path");
v(u, {
d: f,
stroke: "transparent",
fill: "none",
"stroke-width": "15"
}), i.appendChild(u), i.appendChild(d), i[r.name] = d;
}), i;
}, xt = function(t, e, n) {
if (!e)
return;
const o = N.createElement("div");
t.nodes.appendChild(o);
const i = e.innerHTML;
o.id = "input-box", o.textContent = i, o.contentEditable = "plaintext-only", o.spellcheck = !1;
const s = e.getBBox();
o.style.cssText = `
min-width:${Math.max(88, s.width)}px;
position:absolute;
left:${s.x}px;
top:${s.y}px;
padding: 2px 4px;
margin: -2px -4px;
`, mt(o), t.scrollIntoView(o), o.addEventListener("keydown", (r) => {
r.stopPropagation();
const a = r.key;
if (a === "Enter" || a === "Tab") {
if (r.shiftKey)
return;
r.preventDefault(), o.blur(), t.container.focus();
}
}), o.addEventListener("blur", () => {
var a;
if (!o)
return;
const r = ((a = o.textContent) == null ? void 0 : a.trim()) || "";
r === "" ? n.label = i : n.label = r, o.remove(), r !== i && (e.innerHTML = n.label, t.linkDiv(), "parent" in n ? t.bus.fire("operation", {
name: "finishEditSummary",
obj: n
}) : t.bus.fire("operation", {
name: "finishEditArrowLabel",
obj: n
}));
});
}, Ot = function(t) {
const e = this.map.querySelector("me-root"), n = e.offsetTop, o = e.offsetLeft, i = e.offsetWidth, s = e.offsetHeight, r = this.map.querySelectorAll("me-main > me-wrapper");
this.lines.innerHTML = "";
for (let a = 0; a < r.length; a++) {
const f = r[a], d = f.querySelector("me-tpc"), { offsetLeft: p, offsetTop: u } = D(this.nodes, d), g = d.offsetWidth, l = d.offsetHeight, c = f.parentNode.className, h = this.generateMainBranch({ pT: n, pL: o, pW: i, pH: s, cT: u, cL: p, cW: g, cH: l, direction: c, containerHeight: this.nodes.offsetHeight }), m = this.theme.palette, w = d.nodeObj.branchColor || m[a % m.length];
if (d.style.borderColor = w, this.lines.appendChild(wt(h, w, "3")), t && t !== f)
continue;
const x = V("subLines"), y = f.lastChild;
y.tagName === "svg" && y.remove(), f.appendChild(x), yt(this, x, w, f, c, !0);
}
this.renderArrow(), this.renderSummary(), this.bus.fire("linkDiv");
}, yt = function(t, e, n, o, i, s) {
const r = o.firstChild, a = o.children[1].children;
if (a.length === 0)
return;
const f = r.offsetTop, d = r.offsetLeft, p = r.offsetWidth, u = r.offsetHeight;
for (let g = 0; g < a.length; g++) {
const l = a[g], c = l.firstChild, h = c.offsetTop, m = c.offsetLeft, w = c.offsetWidth, x = c.offsetHeight, y = c.firstChild.nodeObj.branchColor || n, b = t.generateSubBranch({ pT: f, pL: d, pW: p, pH: u, cT: h, cL: m, cW: w, cH: x, direction: i, isFirst: s });
e.appendChild(wt(b, y, "2"));
const C = c.children[1];
if (C) {
if (!C.expanded)
continue;
} else
continue;
yt(t, e, y, l, i);
}
};
const Vt = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169394918" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2021" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M851.91168 328.45312c-59.97056 0-108.6208 48.47104-108.91264 108.36992l-137.92768 38.4a109.14304 109.14304 0 0 0-63.46752-46.58688l1.39264-137.11872c47.29344-11.86816 82.31936-54.66624 82.31936-105.64096 0-60.15488-48.76288-108.91776-108.91776-108.91776s-108.91776 48.76288-108.91776 108.91776c0 49.18784 32.60928 90.75712 77.38368 104.27392l-1.41312 138.87488a109.19936 109.19936 0 0 0-63.50336 48.55808l-138.93632-39.48544 0.01024-0.72704c0-60.15488-48.76288-108.91776-108.91776-108.91776s-108.91776 48.75776-108.91776 108.91776c0 60.15488 48.76288 108.91264 108.91776 108.91264 39.3984 0 73.91232-20.92032 93.03552-52.2496l139.19232 39.552-0.00512 0.2304c0 25.8304 9.00096 49.5616 24.02816 68.23424l-90.14272 132.63872a108.7488 108.7488 0 0 0-34.2528-5.504c-60.15488 0-108.91776 48.768-108.91776 108.91776 0 60.16 48.76288 108.91776 108.91776 108.91776 60.16 0 108.92288-48.75776 108.92288-108.91776 0-27.14624-9.9328-51.968-26.36288-71.04l89.04704-131.03104a108.544 108.544 0 0 0 37.6832 6.70208 108.672 108.672 0 0 0 36.48512-6.272l93.13792 132.57216a108.48256 108.48256 0 0 0-24.69888 69.0688c0 60.16 48.768 108.92288 108.91776 108.92288 60.16 0 108.91776-48.76288 108.91776-108.92288 0-60.14976-48.75776-108.91776-108.91776-108.91776a108.80512 108.80512 0 0 0-36.69504 6.3488l-93.07136-132.48a108.48768 108.48768 0 0 0 24.79616-72.22784l136.09984-37.888c18.99008 31.93856 53.84192 53.3504 93.69088 53.3504 60.16 0 108.92288-48.75776 108.92288-108.91264-0.00512-60.15488-48.77312-108.92288-108.92288-108.92288z" p-id="2022"></path></svg>', Wt = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169375313" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1775" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M639 463.30000001L639 285.1c0-36.90000001-26.4-68.5-61.3-68.5l-150.2 0c-1.5 0-3 0.1-4.5 0.3-10.2-38.7-45.5-67.3-87.5-67.3-50 0-90.5 40.5-90.5 90.5s40.5 90.5 90.5 90.5c42 0 77.3-28.6 87.5-67.39999999 1.4 0.3 2.9 0.4 4.5 0.39999999L577.7 263.6c6.8 0 14.3 8.9 14.3 21.49999999l0 427.00000001c0 12.7-7.40000001 21.5-14.30000001 21.5l-150.19999999 0c-1.5 0-3 0.2-4.5 0.4-10.2-38.8-45.5-67.3-87.5-67.3-50 0-90.5 40.5-90.5 90.4 0 49.9 40.5 90.6 90.5 90.59999999 42 0 77.3-28.6 87.5-67.39999999 1.4 0.2 2.9 0.4 4.49999999 0.4L577.7 780.7c34.80000001 0 61.3-31.6 61.3-68.50000001L639 510.3l79.1 0c10.4 38.5 45.49999999 67 87.4 67 50 0 90.5-40.5 90.5-90.5s-40.5-90.5-90.5-90.5c-41.79999999 0-77.00000001 28.4-87.4 67L639 463.30000001z" fill="currentColor" p-id="1776"></path></svg>', Gt = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169667709" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3037" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M385 560.69999999L385 738.9c0 36.90000001 26.4 68.5 61.3 68.5l150.2 0c1.5 0 3-0.1 4.5-0.3 10.2 38.7 45.5 67.3 87.5 67.3 50 0 90.5-40.5 90.5-90.5s-40.5-90.5-90.5-90.5c-42 0-77.3 28.6-87.5 67.39999999-1.4-0.3-2.9-0.4-4.5-0.39999999L446.3 760.4c-6.8 0-14.3-8.9-14.3-21.49999999l0-427.00000001c0-12.7 7.40000001-21.5 14.30000001-21.5l150.19999999 0c1.5 0 3-0.2 4.5-0.4 10.2 38.8 45.5 67.3 87.5 67.3 50 0 90.5-40.5 90.5-90.4 0-49.9-40.5-90.6-90.5-90.59999999-42 0-77.3 28.6-87.5 67.39999999-1.4-0.2-2.9-0.4-4.49999999-0.4L446.3 243.3c-34.80000001 0-61.3 31.6-61.3 68.50000001L385 513.7l-79.1 0c-10.4-38.5-45.49999999-67-87.4-67-50 0-90.5 40.5-90.5 90.5s40.5 90.5 90.5 90.5c41.79999999 0 77.00000001-28.4 87.4-67L385 560.69999999z" fill="currentColor" p-id="3038"></path></svg>', It = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169402629" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2170" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M639.328 416c8.032 0 16.096-3.008 22.304-9.056l202.624-197.184-0.8 143.808c-0.096 17.696 14.144 32.096 31.808 32.192 0.064 0 0.128 0 0.192 0 17.6 0 31.904-14.208 32-31.808l1.248-222.208c0-0.672-0.352-1.248-0.384-1.92 0.032-0.512 0.288-0.896 0.288-1.408 0.032-17.664-14.272-32-31.968-32.032L671.552 96l-0.032 0c-17.664 0-31.968 14.304-32 31.968C639.488 145.632 653.824 160 671.488 160l151.872 0.224-206.368 200.8c-12.672 12.32-12.928 32.608-0.64 45.248C622.656 412.736 630.976 416 639.328 416z" p-id="2171"></path><path d="M896.032 639.552 896.032 639.552c-17.696 0-32 14.304-32.032 31.968l-0.224 151.872-200.832-206.4c-12.32-12.64-32.576-12.96-45.248-0.64-12.672 12.352-12.928 32.608-0.64 45.248l197.184 202.624-143.808-0.8c-0.064 0-0.128 0-0.192 0-17.6 0-31.904 14.208-32 31.808-0.096 17.696 14.144 32.096 31.808 32.192l222.24 1.248c0.064 0 0.128 0 0.192 0 0.64 0 1.12-0.32 1.76-0.352 0.512 0.032 0.896 0.288 1.408 0.288l0.032 0c17.664 0 31.968-14.304 32-31.968L928 671.584C928.032 653.952 913.728 639.584 896.032 639.552z" p-id="2172"></path><path d="M209.76 159.744l143.808 0.8c0.064 0 0.128 0 0.192 0 17.6 0 31.904-14.208 32-31.808 0.096-17.696-14.144-32.096-31.808-32.192L131.68 95.328c-0.064 0-0.128 0-0.192 0-0.672 0-1.248 0.352-1.888 0.384-0.448 0-0.8-0.256-1.248-0.256 0 0-0.032 0-0.032 0-17.664 0-31.968 14.304-32 31.968L96 352.448c-0.032 17.664 14.272 32 31.968 32.032 0 0 0.032 0 0.032 0 17.664 0 31.968-14.304 32-31.968l0.224-151.936 200.832 206.4c6.272 6.464 14.624 9.696 22.944 9.696 8.032 0 16.096-3.008 22.304-9.056 12.672-12.32 12.96-32.608 0.64-45.248L209.76 159.744z" p-id="2173"></path><path d="M362.368 617.056l-202.624 197.184 0.8-143.808c0.096-17.696-14.144-32.096-31.808-32.192-0.064 0-0.128 0-0.192 0-17.6 0-31.904 14.208-32 31.808l-1.248 222.24c0 0.704 0.352 1.312 0.384 2.016 0 0.448-0.256 0.832-0.256 1.312-0.032 17.664 14.272 32 31.968 32.032L352.448 928c0 0 0.032 0 0.032 0 17.664 0 31.968-14.304 32-31.968s-14.272-32-31.968-32.032l-151.936-0.224 206.4-200.832c12.672-12.352 12.96-32.608 0.64-45.248S375.008 604.704 362.368 617.056z" p-id="2174"></path></svg>', Ft = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169573443" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2883" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M514.133333 488.533333m-106.666666 0a106.666667 106.666667 0 1 0 213.333333 0 106.666667 106.666667 0 1 0-213.333333 0Z" fill="currentColor" p-id="2884"></path><path d="M512 64C264.533333 64 64 264.533333 64 512c0 236.8 183.466667 428.8 416 445.866667v-134.4c-53.333333-59.733333-200.533333-230.4-200.533333-334.933334 0-130.133333 104.533333-234.666667 234.666666-234.666666s234.666667 104.533333 234.666667 234.666666c0 61.866667-49.066667 153.6-145.066667 270.933334l-59.733333 68.266666V960C776.533333 942.933333 960 748.8 960 512c0-247.466667-200.533333-448-448-448z" fill="currentColor" p-id="2885"></path></svg>', jt = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169419447" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2480" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M863.328 482.56l-317.344-1.12L545.984 162.816c0-17.664-14.336-32-32-32s-32 14.336-32 32l0 318.4L159.616 480.064c-0.032 0-0.064 0-0.096 0-17.632 0-31.936 14.24-32 31.904C127.424 529.632 141.728 544 159.392 544.064l322.592 1.152 0 319.168c0 17.696 14.336 32 32 32s32-14.304 32-32l0-318.944 317.088 1.12c0.064 0 0.096 0 0.128 0 17.632 0 31.936-14.24 32-31.904C895.264 496.992 880.96 482.624 863.328 482.56z" p-id="2481"></path></svg>', zt = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169426515" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2730" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M863.744 544 163.424 544c-17.664 0-32-14.336-32-32s14.336-32 32-32l700.32 0c17.696 0 32 14.336 32 32S881.44 544 863.744 544z" p-id="2731"></path></svg>';
const Yt = {
side: Vt,
left: Wt,
right: Gt,
full: It,
living: Ft,
zoomin: jt,
zoomout: zt
}, M = (t, e) => {
const n = document.createElement("span");
return n.id = t, n.innerHTML = Yt[e], n;
};
function Rt(t) {
const e = document.createElement("div"), n = M("fullscreen", "full"), o = M("toCenter", "living"), i = M("zoomout", "zoomout"), s = M("zoomin", "zoomin"), r = document.createElement("span");
return r.innerText = "100%", e.appendChild(n), e.appendChild(o), e.appendChild(i), e.appendChild(s), e.className = "mind-elixir-toolbar rb", n.onclick = () => {
document.fullscreenElement === t.el ? document.exitFullscreen() : t.el.requestFullscreen();
}, o.onclick = () => {
t.toCenter();
}, i.onclick = () => {
t.scaleVal < 0.6 || t.scale(t.scaleVal - t.scaleSensitivity);
}, s.onclick = () => {
t.scaleVal > 1.6 || t.scale(t.scaleVal + t.scaleSensitivity);
}, e;
}
function Xt(t) {
const e = document.createElement("div"), n = M("tbltl", "left"), o = M("tbltr", "right"), i = M("tblts", "side");
return e.appendChild(n), e.appendChild(o), e.appendChild(i), e.className = "mind-elixir-toolbar lt", n.onclick = () => {
t.initLeft();
}, o.onclick = () => {
t.initRight();
}, i.onclick = () => {
t.initSide();
}, e;
}
function qt(t) {
t.container.append(Rt(t)), t.container.append(Xt(t));
}
const _t = function(t, e = !0) {
this.theme = t;
const o = {
...(t.type === "dark" ? J : K).cssVar,
...t.cssVar
}, i = Object.keys(o);
for (let s = 0; s < i.length; s++) {
const r = i[s];
this.container.style.setProperty(r, o[r]);
}
e && this.refresh();
}, Ut = function(t) {
const n = t.parentElement.parentElement.lastElementChild;
(n == null ? void 0 : n.tagName) === "svg" && (n == null || n.remove());
};
function Kt(t) {
return {
nodeData: t.isFocusMode ? t.nodeDataBackup : t.nodeData,
arrows: t.arrows,
summaries: t.summaries,
direction: t.direction,
theme: t.theme
};
}
const Jt = function(t) {
const e = this.container, n = t.getBoundingClientRect(), o = e.getBoundingClientRect();
if (n.top > o.bottom || n.bottom < o.top || n.left > o.right || n.right < o.left) {
const s = n.left + n.width / 2, r = n.top + n.height / 2, a = o.left + o.width / 2, f = o.top + o.height / 2, d = s - a, p = r - f;
this.move(-d, -p);
}
}, Qt = function(t, e, n) {
this.clearSelection(), this.scrollIntoView(t), this.selection.select(t), e && this.bus.fire("selectNewNode", t.nodeObj);
}, Zt = function(t) {
this.selection.select(t);
}, te = function(t) {
this.selection.deselect(t);
}, ee = function() {
this.unselectNodes(this.currentNodes), this.unselectSummary(), this.unselectArrow();
}, ne = function() {
const t = Kt(this);
return JSON.stringify(t, (e, n) => {
if (!(e === "parent" && typeof n != "string"))
return n;
});
}, oe = function() {
return JSON.parse(this.getDataString());
}, ie = function() {
this.editable = !0;
}, se = function() {
this.editable = !1;
}, re = function(t, e = { x: 0, y: 0 }) {
const n = this.container.getBoundingClientRect(), o = e.x ? e.x - n.left - n.width / 2 : 0, i = e.y ? e.y - n.top - n.height / 2 : 0, { dx: s, dy: r } = vt(this), a = this.map.style.transform, { x: f, y: d } = ft(a), p = f - s, u = d - r, g = this.scaleVal, l = (-o + p) * (1 - t / g), c = (-i + u) * (1 - t / g);
this.map.style.transform = `translate(${f - l}px, ${d - c}px) scale(${t})`, this.scaleVal = t, this.bus.fire("scale", t);
}, ce = function() {
const t = this.nodes.offsetHeight / this.container.offsetHeight, e = this.nodes.offsetWidth / this.container.offsetWidth, n = 1 / Math.max(1, Math.max(t, e));
this.scaleVal = n, this.map.style.transform = "scale(" + n + ")", this.bus.fire("scale", n);
}, le = function(t, e) {
const { map: n, scaleVal: o, bus: i } = this, s = n.style.transform;
let { x: r, y: a } = ft(s);
r += t, a += e, n.style.transform = `translate(${r}px, ${a}px) scale(${o})`, i.fire("move", { dx: t, dy: e });
}, vt = (t) => {
const { container: e, map: n, nodes: o } = t, i = n.querySelector("me-root"), s = i.offsetTop, r = i.offsetLeft, a = i.offsetWidth, f = i.offsetHeight;
let d, p;
return t.alignment === "root" ? (d = e.offsetWidth / 2 - r - a / 2, p = e.offsetHeight / 2 - s - f / 2, n.style.transformOrigin = `${r + a / 2}px 50%`) : (d = (e.offsetWidth - o.offsetWidth) / 2, p = (e.offsetHeight - o.offsetHeight) / 2, n.style.transformOrigin = "50% 50%"), { dx: d, dy: p };
}, ae = function() {
const { map: t } = this, { dx: e, dy: n } = vt(this);
t.style.transform = `translate(${e}px, ${n}px) scale(${this.scaleVal})`;
}, he = function(t) {
t(this);
}, de = function(t) {
t.nodeObj.parent && (this.clearSelection(), this.tempDirection === null && (this.tempDirection = this.direction), this.isFocusMode || (this.nodeDataBackup = this.nodeData, this.isFocusMode = !0), this.nodeData = t.nodeObj, this.initRight(), this.toCenter());
}, fe = function() {
this.isFocusMode = !1, this.tempDirection !== null && (this.nodeData = this.nodeDataBackup, this.direction = this.tempDirection, this.tempDirection = null, this.refresh(), this.toCenter());
}, pe = function() {
this.direction = 0, this.refresh(), this.toCenter();
}, ue = function() {
this.direction = 1, this.refresh(), this.toCenter();
}, ge = function() {
this.direction = 2, this.refresh(), this.toCenter();
}, me = function(t) {
this.locale = t, this.refresh();
}, we = function(t, e) {
const n = t.nodeObj;
typeof e == "boolean" ? n.expanded = e : n.expanded !== !1 ? n.expanded = !1 : n.expanded = !0;
const o = t.parentNode, i = o.children[1];
if (i.expanded = n.expanded, i.className = n.expanded ? "minus" : "", Ut(t), n.expanded) {
const f = this.createChildren(
n.children.map((d) => this.createWrapper(d).grp)
);
o.parentNode.appendChild(f);
} else
o.parentNode.children[1].remove();
this.linkDiv(t.closest("me-main > me-wrapper"));
const s = t.getBoundingClientRect(), r = this.container.getBoundingClientRect();
(s.bottom > r.bottom || s.top < r.top || s.right > r.right || s.left < r.left) && this.scrollIntoView(t), this.bus.fire("expandNode", n);
}, xe = function(t, e) {
const n = t.nodeObj, o = (i, s) => {
i.expanded = s, i.children && i.children.forEach((r) => {
o(r, s);
});
};
typeof e == "boolean" ? o(n, e) : n.expanded !== !1 ? o(n, !1) : o(n, !0), this.refresh();
}, ye = function(t) {
t && (t = JSON.parse(JSON.stringify(t)), this.nodeData = t.nodeData, this.arrows = t.arrows || [], this.summaries = t.summaries || []), Q(this.nodeData), this.layout(), this.linkDiv();
}, ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
cancelFocus: fe,
clearSelection: ee,
disableEdit: se,
enableEdit: ie,
expandNode: we,
expandNodeAll: xe,
focusNode: de,
getData: oe,
getDataString: ne,
initLeft: pe,
initRight: ue,
initSide: ge,
install: he,
move: le,
refresh: ye,
scale: re,
scaleFit: ce,
scrollIntoView: Jt,
selectNode: Qt,
selectNodes: Zt,
setLocale: me,
toCenter: ae,
unselectNodes: te
}, Symbol.toStringTag, { value: "Module" })), be = function(t) {
return {
dom: t,
moved: !1,
// differentiate click and move
pointerdown: !1,
lastX: 0,
lastY: 0,
handlePointerMove(e) {
if (this.pointerdown) {
this.moved = !0;
const n = e.clientX - this.lastX, o = e.clientY - this.lastY;
this.lastX = e.clientX, this.lastY = e.clientY, this.cb && this.cb(n, o);
}
},
handlePointerDown(e) {
e.button === 0 && (this.pointerdown = !0, this.lastX = e.clientX, this.lastY = e.clientY, this.dom.setPointerCapture(e.pointerId));
},
handleClear(e) {
this.pointerdown = !1, e.pointerId !== void 0 && this.dom.releasePointerCapture(e.pointerId);
},
cb: null,
init(e, n) {
this.cb = n, this.handleClear = this.handleClear.bind(this), this.handlePointerMove = this.handlePointerMove.bind(this), this.handlePointerDown = this.handlePointerDown.bind(this), this.destroy = pt([
{ dom: e, evt: "pointermove", func: this.handlePointerMove },
{ dom: e, evt: "pointerleave", func: this.handleClear },
{ dom: e, evt: "pointerup", func: this.handleClear },
{ dom: this.dom, evt: "pointerdown", func: this.handlePointerDown }
]);
},
destroy: null,
clear() {
this.moved = !1, this.pointerdown = !1;
}
};
}, lt = {
create: be
}, Ce = "#4dc4ff";
function bt(t, e, n, o, i, s, r, a) {
return {
x: t / 8 + n * 3 / 8 + i * 3 / 8 + r / 8,
y: e / 8 + o * 3 / 8 + s * 3 / 8 + a / 8
};
}
function Se(t, e, n) {
v(t, {
x: e + "",
y: n + ""
});
}
function F(t, e, n, o, i) {
v(t, {
x1: e + "",
y1: n + "",
x2: o + "",
y2: i + ""
});
}
function at(t, e, n, o, i, s, r, a, f, d) {
var l;
if (t.line.setAttribute("d", `M ${e} ${n} C ${o} ${i} ${s} ${r} ${a} ${f}`), d.style) {
const c = d.style;
c.stroke && t.line.setAttribute("stroke", c.stroke), c.strokeWidth && t.line.setAttribute("stroke-width", String(c.strokeWidth)), c.strokeDasharray && t.line.setAttribute("stroke-dasharray", c.strokeDasharray), c.strokeLinecap && t.line.setAttribute("stroke-linecap", c.strokeLinecap), c.opacity !== void 0 && t.line.setAttribute("opacity", String(c.opacity));
}
const p = R(s, r, a, f);
if (p && (t.arrow1.setAttribute("d", `M ${p.x1} ${p.y1} L ${a} ${f} L ${p.x2} ${p.y2}`), d.style)) {
const c = d.style;
c.stroke && t.arrow1.setAttribute("stroke", c.stroke), c.strokeWidth && t.arrow1.setAttribute("stroke-width", String(c.strokeWidth)), c.strokeLinecap && t.arrow1.setAttribute("stroke-linecap", c.strokeLinecap), c.opacity !== void 0 && t.arrow1.setAttribute("opacity", String(c.opacity));
}
if (d.bidirectional) {
const c = R(o, i, e, n);
if (c && (t.arrow2.setAttribute("d", `M ${c.x1} ${c.y1} L ${e} ${n} L ${c.x2} ${c.y2}`), d.style)) {
const h = d.style;
h.stroke && t.arrow2.setAttribute("stroke", h.stroke), h.strokeWidth && t.arrow2.setAttribute("stroke-width", String(h.strokeWidth)), h.strokeLinecap && t.arrow2.setAttribute("stroke-linecap", h.strokeLinecap), h.opacity !== void 0 && t.arrow2.setAttribute("opacity", String(h.opacity));
}
}
const { x: u, y: g } = bt(e, n, o, i, s, r, a, f);
Se(t.label, u, g), (l = d.style) != null && l.labelColor && t.label.setAttribute("fill", d.style.labelColor), Ne(t);
}
function q(t, e, n) {
const { offsetLeft: o, offsetTop: i } = D(t.nodes, e), s = e.offsetWidth, r = e.offsetHeight, a = o + s / 2, f = i + r / 2, d = a + n.x, p = f + n.y;
return {
w: s,
h: r,
cx: a,
cy: f,
ctrlX: d,
ctrlY: p
};
}
function H(t) {
let e, n;
const o = (t.cy - t.ctrlY) / (t.ctrlX - t.cx);
return o > t.h / t.w || o < -t.h / t.w ? t.cy - t.ctrlY < 0 ? (e = t.cx - t.h / 2 / o, n = t.cy + t.h / 2) : (e = t.cx + t.h / 2 / o, n = t.cy - t.h / 2) : t.cx - t.ctrlX < 0 ? (e = t.cx + t.w / 2, n = t.cy - t.w * o / 2) : (e = t.cx - t.w / 2, n = t.cy + t.w * o / 2), {
x: e,
y: n
};
}
const Ee = function(t, e, n, o) {
const i = document.createElementNS(T, "text");
return v(i, {
"text-anchor": "middle",
x: e + "",
y: n + "",
fill: o || "rgb(235, 95, 82)"
}), i.dataset.type = "custom-link", i.innerHTML = t, i;
}, Z = function(t, e, n, o, i) {
var E;
if (!e || !n)
return;
const s = q(t, e, o.delta1), r = q(t, n, o.delta2), { x: a, y: f } = H(s), { ctrlX: d, ctrlY: p } = s, { ctrlX: u, ctrlY: g } = r, { x: l, y: c } = H(r), h = R(u, g, l, c);
if (!h)
return;
const m = `M ${h.x1} ${h.y1} L ${l} ${c} L ${h.x2} ${h.y2}`;
let w = "";
if (o.bidirectional) {
const A = R(d, p, a, f);
if (!A)
return;
w = `M ${A.x1} ${A.y1} L ${a} ${f} L ${A.x2} ${A.y2}`;
}
const x = Bt(`M ${a} ${f} C ${d} ${p} ${u} ${g} ${l} ${c}`, m, w, o.style), { x: y, y: b } = bt(a, f, d, p, u, g, l, c), C = (E = o.style) == null ? void 0 : E.labelColor, S = Ee(o.label, y, b, C);
x.appendChild(S), x.label = S, x.arrowObj = o, x.dataset.linkid = o.id, t.linkSvgGroup.appendChild(x), i || (t.arrows.push(o), t.currentArrow = x, Ct(t, o, s, r));
}, Te = function(t, e, n = {}) {
const o = {
id: W(),
label: "Custom Link",
from: t.nodeObj.id,
to: e.nodeObj.id,
delta1: {
x: t.offsetWidth / 2 + 100,
y: 0
},
delta2: {
x: e.offsetWidth / 2 + 100,
y: 0
},
...n
};
Z(this, t, e, o), this.bus.fire("operation", {
name: "createArrow",
obj: o
});
}, Le = function(t) {
_(this);
const e = { ...t, id: W() };
Z(this, this.findEle(e.from), this.findEle(e.to), e), this.bus.fire("operation", {
name: "createArrow",
obj: e
});
}, ke = function(t) {
let e;
if (t ? e = t : e = this.currentArrow, !e)
return;
_(this);
const n = e.arrowObj.id;
this.arrows = this.arrows.filter((o) => o.id !== n), e.remove(), this.bus.fire("operation", {
name: "removeArrow",
obj: {
id: n
}
});
}, $e = function(t) {
this.currentArrow = t;
const e = t.arrowObj, n = this.findEle(e.from), o = this.findEle(e.to), i = q(this, n, e.delta1), s = q(this, o, e.delta2);
Ct(this, e, i, s);
}, Ae = function() {
_(this), this.currentArrow = null;
}, U = function(t, e) {
const n = document.createElementNS(T, "path");
return v(n, {
d: t,
stroke: e,
fill: "none",
"stroke-width": "6",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}), n;
}, De = function(t, e) {
const n = document.createElementNS(T, "g");
n.setAttribute("class", "arrow-highlight"), n.setAttribute("opacity", "0.45");
const o = U(t.line.getAttribute("d"), e);
n.appendChild(o);
const i = U(t.arrow1.getAttribute("d"), e);
if (n.appendChild(i), t.arrow2.getAttribute("d")) {
const s = U(t.arrow2.getAttribute("d"), e);
n.appendChild(s);
}
t.insertBefore(n, t.firstChild);
}, Me = function(t) {
const e = t.querySelector(".arrow-highlight");
e && e.remove();
}, Ne = function(t) {
const e = t.querySelector(".arrow-highlight");
if (!e)
return;
const n = e.querySelectorAll("path");
n.length >= 1 && n[0].setAttribute("d", t.line.getAttribute("d")), n.length >= 2 && n[1].setAttribute("d", t.arrow1.getAttribute("d")), n.length >= 3 && t.arrow2.getAttribute("d") && n[2].setAttribute("d", t.arrow2.getAttribute("d"));
}, _ = function(t) {
var e, n;
(e = t.helper1) == null || e.destroy(), (n = t.helper2) == null || n.destroy(), t.linkController.style.display = "none", t.P2.style.display = "none", t.P3.style.display = "none", t.currentArrow && Me(t.currentArrow);
}, Ct = function(t, e, n, o) {
const { linkController: i, P2: s, P3: r, line1: a, line2: f, nodes: d, map: p, currentArrow: u, bus: g } = t;
if (!u)
return;
i.style.display = "initial", s.style.display = "initial", r.style.display = "initial", d.appendChild(i), d.appendChild(s), d.appendChild(r), De(u, Ce);
let { x: l, y: c } = H(n), { ctrlX: h, ctrlY: m } = n, { ctrlX: w, ctrlY: x } = o, { x: y, y: b } = H(o);
s.style.cssText = `top:${m}px;left:${h}px;`, r.style.cssText = `top:${x}px;left:${w}px;`, F(a, l, c, h, m), F(f, w, x, y, b), t.helper1 = lt.create(s), t.helper2 = lt.create(r), t.helper1.init(p, (C, S) => {
h = h + C / t.scaleVal, m = m + S / t.scaleVal;
const E = H({ ...n, ctrlX: h, ctrlY: m });
l = E.x, c = E.y, s.style.top = m + "px", s.style.left = h + "px", at(u, l, c, h, m, w, x, y, b, e), F(a, l, c, h, m), e.delta1.x = h - n.cx, e.delta1.y = m - n.cy, g.fire("updateArrowDelta", e);
}), t.helper2.init(p, (C, S) => {
w = w + C / t.scaleVal, x = x + S / t.scaleVal;
const E = H({ ...o, ctrlX: w, ctrlY: x });
y = E.x, b = E.y, r.style.top = x + "px", r.style.left = w + "px", at(u, l, c, h, m, w, x, y, b, e), F(f, w, x, y, b), e.delta2.x = w - o.cx, e.delta2.y = x - o.cy, g.fire("updateArrowDelta", e);
});
};
function Pe() {
this.linkSvgGroup.innerHTML = "";
for (let t = 0; t < this.arrows.length; t++) {
const e = this.arrows[t];
try {
Z(this, this.findEle(e.from), this.findEle(e.to), e, !0);
} catch {
}
}
this.nodes.appendChild(this.linkSvgGroup);
}
function He(t) {
if (_(this), !t)
return;
const e = t.label;
xt(this, e, t.arrowObj);
}
function Be() {
this.arrows = this.arrows.filter((t) => Y(t.from, this.nodeData) && Y(t.to, this.nodeData));
}
const Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
createArrow: Te,
createArrowFrom: Le,
editArrowLabel: He,
removeArrow: ke,
renderArrow: Pe,
selectArrow: $e,
tidyArrow: Be,
unselectArrow: Ae
}, Symbol.toStringTag, { value: "Module" })), Ve = function(t) {
var f, d;
if (t.length === 0)
throw new Error("No selected node.");
if (t.length === 1) {
const p = t[0].nodeObj, u = t[0].nodeObj.parent;
if (!u)
throw new Error("Can not select root node.");
const g = u.children.findIndex((l) => p === l);
return {
parent: u.id,
start: g,
end: g
};
}
let e = 0;
const n = t.map((p) => {
let u = p.nodeObj;
const g = [];
for (; u.parent; ) {
const l = u.parent, c = l.children, h = c == null ? void 0 : c.indexOf(u);
u = l, g.unshift({ node: u, index: h });
}
return g.length > e && (e = g.length), g;
});
let o = 0;
t:
for (; o < e; o++) {
const p = (f = n[0][o]) == null ? void 0 : f.node;
for (let u = 1; u < n.length; u++)
if (((d = n[u][o]) == null ? void 0 : d.node) !== p)
break t;
}
if (!o)
throw new Error("Can not select root node.");
const i = n.map((p) => p[o - 1].index).sort(), s = i[0] || 0, r = i[i.length - 1] || 0, a = n[0][o - 1].node;
if (!a.parent)
throw new Error("Please select nodes in the same main topic.");
return {
parent: a.id,
start: s,
end: r
};
}, We = function(t) {
const e = document.createElementNS(T, "g");
return e.setAttribute("id", t), e;
}, ht = function(t, e) {
const n = document.createElementNS(T, "path");
return v(n, {
d: t,
stroke: e || "#666",
fill: "none",
"stroke-linecap": "round",
"stroke-width": "2"
}), n;
}, dt = function(t, e, n, o, i) {
const s = document.createElementNS(T, "text");
return v(s, {
"text-anchor": o,
x: e + "",
y: n + "",
fill: i || "#666"
}), s.innerHTML = t, s;
}, Ge = (t) => t.parentElement.parentElement, Ie = function(t, { parent: e, start: n }) {
const o = t.findEle(e), i = o.nodeObj;
let s;
return i.parent ? s = o.closest("me-main").className : s = t.findEle(i.children[n].id).closest("me-main").className, s;
}, tt = function(t, e) {
var A;
const { id: n, label: o, parent: i, start: s, end: r } = e, { nodes: a, theme: f, summarySvg: d } = t, u = t.findEle(i).nodeObj, g = Ie(t, e);
let l = 1 / 0, c = 0, h = 0, m = 0;
for (let B = s; B <= r; B++) {
const et = (A = u.children) == null ? void 0 : A[B];
if (!et)
return t.removeSummary(n), null;
const G = Ge(t.findEle(et.id)), { offsetLeft: I, offsetTop: nt } = D(a, G), ot = s === r ? 10 : 20;
B === s && (h = nt + ot), B === r && (m = nt + G.offsetHeight - ot), I < l && (l = I), G.offsetWidth + I > c && (c = G.offsetWidth + I);
}
let w, x;
const y = h + 10, b = m + 10, C = (y + b) / 2, S = f.cssVar["--color"];
g === P.LHS ? (w = ht(`M ${l + 10} ${y} c -5 0 -10 5 -10 10 L ${l} ${b - 10} c 0 5 5 10 10 10 M ${l} ${C} h -10`, S), x = dt(o, l - 20, C + 6, "end", S)) : (w = ht(`M ${c - 10} ${y} c 5 0 10 5 10 10 L ${c} ${b - 10} c 0 5 -5 10 -10 10 M ${c} ${C} h 10`, S), x = dt(o, c + 20, C + 6, "start", S));
const E = We("s-" + n);
return E.appendChild(w), E.appendChild(x), E.summaryObj = e, d.appendChild(E), E;
}, Fe = function() {
if (!this.currentNodes)
return;
const { currentNodes: t, summaries: e, bus: n } = this, { parent: o, start: i, end: s } = Ve(t), r = { id: W(), parent: o, start: i, end: s, label: "summary" }, a = tt(this, r);
e.push(r), this.editSummary(a), n.fire("operation", {
name: "createSummary",
obj: r
});
}, je = function(t) {
const e = W(), n = { ...t, id: e };
tt(this, n), this.summaries.push(n), this.bus.fire("operation", {
name: "createSummary",
obj: n
});
}, ze = function(t) {
var n;
const e = this.summaries.findIndex((o) => o.id === t);
e > -1 && (this.summaries.splice(e, 1), (n = document.querySelector("#s-" + t)) == null || n.remove()), this.bus.fire("operation", {
name: "removeSummary",
obj: { id: t }
});
}, Ye = function(t) {
const e = t.children[1].getBBox(), n = 6, o = 3, i = document.createElementNS(T, "rect");
v(i, {
x: e.x - n + "",
y: e.y - n + "",
width: e.width + n * 2 + "",
height: e.height + n * 2 + "",
rx: o + "",
stroke: this.theme.cssVar["--selected"] || "#4dc4ff",
"stroke-width": "2",
fill: "none"
}), t.appendChild(i), this.currentSummary = t;
}, Re = function() {
var t, e;
(e = (t = this.currentSummary) == null ? void 0 : t.querySelector("rect")) == null || e.remove(), this.currentSummary = null;
}, Xe = function() {
this.summarySvg.innerHTML = "", this.summaries.forEach((t) => {
try {
tt(this, t);
} catch {
}
}), this.nodes.insertAdjacentElement("beforeend", this.summarySvg);
}, qe = function(t) {
if (!t)
return;
const e = t.childNodes[1];
xt(this, e, t.summaryObj);
}, _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
createSummary: Fe,
createSummaryFrom: je,
editSummary: qe,
removeSummary: ze,
renderSummary: Xe,
selectSummary: Ye,
unselectSummary: Re
}, Symbol.toStringTag, { value: "Module" })), L = "http://www.w3.org/2000/svg";
function Ue(t, e) {
const n = document.createElementNS(L, "svg");
return v(n, {
version: "1.1",
xmlns: L,
height: t,
width: e
}), n;
}
function Ke(t, e) {
return (parseInt(t) - parseInt(e)) / 2;
}
function Je(t, e, n, o) {
const i = document.createElementNS(L, "g");
let s = "";
return t.text ? s = t.text.textContent : s = t.childNodes[0].textContent, s.split(`
`).forEach((a, f) => {
const d = document.createElementNS(L, "text");
v(d, {
x: n + parseInt(e.paddingLeft) + "",
y: o + parseInt(e.paddingTop) + Ke(e.lineHeight, e.fontSize) * (f + 1) + parseFloat(e.fontSize) * (f + 1) + "",
"text-anchor": "start",
"font-family": e.fontFamily,
"font-size": `${e.fontSize}`,
"font-weight": `${e.fontWeight}`,
fill: `${e.color}`
}), d.innerHTML = a, i.appendChild(d);
}), i;
}
function Qe(t, e, n, o) {
var a;
let i = "";
(a = t.nodeObj) != null && a.dangerouslySetInnerHTML ? i = t.nodeObj.dangerouslySetInnerHTML : t.text ? i = t.text.textContent : i = t.childNodes[0].textContent;
const s = document.createElementNS(L, "foreignObject");
v(s, {
x: n + parseInt(e.paddingLeft) + "",
y: o + parseInt(e.paddingTop) + "",
width: e.width,
height: e.height
});
const r = document.createElement("div");
return v(r, {
xmlns: "http://www.w3.org/1999/xhtml",
style: `font-family: ${e.fontFamily}; font-size: ${e.fontSize}; font-weight: ${e.fontWeight}; color: ${e.color}; white-space: pre-wrap;`
}), r.innerHTML = i, s.appendChild(r), s;
}
function Ze(t, e) {
const n = getComputedStyle(e), { offsetLeft: o, offsetTop: i } = D(t.nodes, e), s = document.createElementNS(L, "rect");
return v(s, {
x: o + "",
y: i + "",
rx: n.borderRadius,
ry: n.borderRadius,
width: n.width,
height: n.height,
fill: n.backgroundColor,
stroke: n.borderColor,
"stroke-width": n.borderWidth
}), s;
}
function j(t, e, n = !1) {
const o = getComputedStyle(e), { offsetLeft: i, offsetTop: s } = D(t.nodes, e), r = document.createElementNS(L, "rect");
v(r, {
x: i + "",
y: s + "",
rx: o.borderRadius,
ry: o.borderRadius,
wid