MindMap/frontend/node_modules/.vite/deps/mind-elixir.js

2502 lines
114 KiB
JavaScript
Raw Normal View History

import "./chunk-FOSKEDPS.js";
// node_modules/mind-elixir/dist/MindElixir.js
(function() {
"use strict";
try {
if (typeof document < "u") {
var i = document.createElement("style");
i.appendChild(document.createTextNode(".mind-elixir{--gap: 30px;--root-radius: 30px;--main-radius: 20px;--root-color: #ffffff;--root-bgcolor: #4c4f69;--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;position:relative;-webkit-tap-highlight-color:rgba(0,0,0,0);font-family:-apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif}.mind-elixir .hyper-link{text-decoration:none;margin-left:.3em}.map-container{-webkit-user-select:none;user-select:none;height:100%;width:100%;overflow:scroll;font-size:15px}.map-container::-webkit-scrollbar{width:0px;height:0px}.map-container .selected{box-shadow:0 0 0 2px var(--selected)}.map-container .lhs{direction:rtl}.map-container .lhs me-tpc{direction:ltr}.map-container .map-canvas{height:20000px;width:20000px;position:relative;-webkit-user-select:none;user-select:none;transition:transform .3s;transform:scale(1);background-color:var(--bgcolor)}.map-container .map-canvas me-nodes{position:absolute;display:flex;justify-content:center;align-items:center;height:fit-content;width:fit-content}.map-container .map-canvas me-root{position:relative}.map-container .map-canvas me-root me-tpc{display:block;font-size:25px;line-height:1.2em;color:var(--root-color);padding:10px var(--gap);border-radius:var(--root-radius);white-space:pre-wrap;background-color:var(--root-bgcolor)}.map-container .map-canvas me-root me-tpc #input-box{padding:10px var(--gap)}.map-container me-main>me-wrapper{position:relative;margin:20px 65px}.map-container me-main>me-wrapper>me-parent{margin:var(--gap);padding:0}.map-container me-main>me-wrapper>me-parent>me-tpc{border-radius:var(--main-radius);background-color:var(--main-bgcolor);border:2px solid var(--main-color);color:var(--main-color);padding:8px var(--gap)}.map-container me-main>me-wrapper>me-parent>me-tpc #input-box{padding:8px var(--gap)}.map-container me-wrapper{display:block;pointer-events:none;width:fit-content}.map-container me-children,.map-container me-parent{display:inline-block;vertical-align:middle}.map-container me-parent{position:relative;cursor:pointer;padding:6px var(--gap);margin-top:10px}.map-container me-parent me-tpc{position:relative;display:block;border-radius:3px;color:var(--color);pointer-events:all;max-width:35em;white-space:pre-wrap;padding:var(--topic-padding);line-height:1.2em}.map-container me-parent me-tpc .insert-preview{position:absolute;width:100%;left:0;z-index:9}.map-container me-parent me-tpc .show{background:#7ad5ff;pointer-events:none;opacity:.7}.map-container me-parent me-tpc .before{height:14px;top:-14px}.map-container me-parent me-tpc .in{height:100%;top:0}.map-container me-parent me-tpc .after{height:14px;bottom:-14px}.map-container me-parent me-epd{position:absolute;height:18px;width:18px;opacity:.8;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdD0iMTY1NjY1NDcxNzI0MiIgY2xhc3M9Imljb24iIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIKICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+CiAgICA8cGF0aCBkPSJNNTEyIDc0LjY2NjY2N0MyNzAuOTMzMzMzIDc0LjY2NjY2NyA3NC42NjY2NjcgMjcwLjkzMzMzMyA3NC42NjY2NjcgNTEyUzI3MC45MzMzMzMgOTQ5LjMzMzMzMyA1MTIgOTQ5LjMzMzMzMyA5NDkuMzMzMzMzIDc1My4wNjY2NjcgOTQ5LjMzMzMzMyA1MTIgNzUzLjA2NjY2NyA3NC42NjY2NjcgNTEyIDc0LjY2NjY2N3oiIHN0cm9rZS13aWR0aD0iNTQiIHN0cm9rZT0nYmxhY2snIGZpbGw9J3doaXRlJyA+PC9wYXRoPgogICAgPHBhdGggZD0iTTY4Mi42NjY2NjcgNDgwaC0xMzguNjY2NjY3VjM0MS4zMzMzMzNjMC0xNy4wNjY2NjctMTQuOTMzMzMzLTMyLTMyLTMycy0zMiAxNC45MzMzMzMtMzIgMzJ2MTM4LjY2NjY2N0gzNDEuMzMzMzMzYy0xNy4wNjY2NjcgMC0zMiAxNC45MzMzMzMtMzIgMzJzMTQuOTMzMzMzIDMyIDMyIDMyaDEzOC42NjY2NjdWNjgyLjY2NjY2N2MwIDE3LjA2NjY2NyAxNC45MzMzMzMgMzIgMzIgMz
}
} catch (e) {
console.error("vite-plugin-css-injected-by-js", e);
}
})();
(function(e) {
var t, n, o, i, s, r, l = '<svg><symbol id="icon-edit" viewBox="0 0 1024 1024"><path d="M423.765333 128a42.666667 42.666667 0 0 1 3.2 85.205333L423.765333 213.333333H234.666667a64 64 0 0 0-63.872 60.245334L170.666667 277.333333v512a64 64 0 0 0 60.245333 63.872L234.666667 853.333333h512a64 64 0 0 0 63.872-60.245333L810.666667 789.333333v-189.098666a42.666667 42.666667 0 0 1 85.205333-3.2l0.128 3.2V789.333333a149.333333 149.333333 0 0 1-144.213333 149.248L746.666667 938.666667h-512a149.333333 149.333333 0 0 1-149.248-144.213334L85.333333 789.333333v-512a149.333333 149.333333 0 0 1 144.213334-149.248L234.666667 128h189.098666z m324.949334-53.248a42.666667 42.666667 0 0 1 60.330666 0l150.869334 150.869333a42.666667 42.666667 0 0 1 0 60.330667l-329.386667 329.386667a42.666667 42.666667 0 0 1-29.44 12.458666l-153.386667 2.517334a42.666667 42.666667 0 0 1-43.349333-43.349334l2.56-153.386666a42.666667 42.666667 0 0 1 12.458667-29.44z m30.165333 90.496L491.946667 452.266667l-1.493334 91.989333 92.032-1.493333 286.976-286.976-90.538666-90.538667z" ></path></symbol><symbol id="icon-rising" viewBox="0 0 1024 1024"><path d="M553.173333 803.84h-64l0.021334-474.581333-224.021334 224-45.269333-45.226667L521.6 206.293333l301.717333 301.696-45.269333 45.269334-224.853333-224.896v475.477333z" ></path></symbol><symbol id="icon-falling" viewBox="0 0 1024 1024"><path d="M553.173333 238.314667h-64l0.021334 474.602666-224.021334-224-45.269333 45.226667L521.6 835.861333l301.717333-301.717333-45.269333-45.226667-224.853333 224.853334V238.336z" ></path></symbol><symbol id="icon-shanchu2" viewBox="0 0 1024 1024"><path d="M516.60601807 107.93026734c-82.64382935 0-149.71865844 65.51751709-152.5729065 147.77160644H171.37136841c-21.40603638 0-38.92044068 17.38504028-38.92044068 38.92126465 0 21.40686036 17.38504028 38.92208862 38.92126466 38.92208862h42.94308471v435.40136719c0 81.73498536 55.39828492 148.55026245 123.90106201 148.55026245h348.99444581c68.37341309 0 123.90106201-66.42553711 123.901062-148.55026245V333.80477906h38.92126465c21.40686036 0 38.92126464-17.38586426 38.92126465-38.92208863 0-21.40686036-17.38504028-38.92126464-38.92126465-38.92126465H668.91854859C666.45321656 173.44860839 599.24902344 107.93109131 516.60601807 107.93109131z m-79.65939331 147.77160644c2.85424805-42.16442872 37.2354126-74.85809326 79.78875732-74.85809326s76.93450927 32.82302857 79.39984131 74.85809326H436.94662476z m-98.86047364 589.01165771c-24.2611084 0-50.98754883-31.13717651-50.98754883-75.76693725V333.80477906h450.97036744V769.33551026c0 44.50039673-26.72644043 75.76776123-50.98754884 75.76776122H338.08615112v-0.38973999z m0 0" ></path><path d="M390.37063599 751.17263794c17.77313232 0 32.43411255-17.7739563 32.43411255-40.08883667V482.35504151c0-22.31488037-14.53079224-40.08966065-32.43411255-40.08966065-17.77478027 0-32.43493653 17.77478027-32.43493653 40.08966065v228.72875976c0 22.18469239 14.27124023 40.08883667 32.43493653 40.08883667z m117.41308594 0c17.7739563 0 32.43411255-17.7739563 32.43411255-40.08883667V482.35504151c0-22.31488037-14.53079224-40.08966065-32.43411255-40.08966065-17.7739563 0-32.43493653 17.77478027-32.43493653 40.08966065v228.72875976c0 22.18469239 14.66098023 40.08883667 32.43493653 40.08883667z m123.51049804 0c17.7739563 0 32.43493653-17.7739563 32.43493652-40.08883667V482.35504151c0-22.31488037-14.53079224-40.08966065-32.43493652-40.08966065-17.7739563 0-32.43411255 17.77478027-32.43411255 40.08966065v228.72875976c0 22.18469239 14.14105224 40.08883667 32.43411255 40.08883667z m0 0" ></path></symbol><symbol id="icon-zijiedian" viewBox="0 0 1024 1024"><path d="M312.208 472c19.568-157.856 153.432-280 315.656-280 175.68 0 318.112 143.272 318.112 320S803.552 832 627.864 832c-162.224 0-296.08-122.144-315.656-280H120a40 40 0 0 1 0-80h192.208zM632 752c132.552 0 240-107.448 240-240 0-132.552-107.448-240-240-240-132.552 0-240 107.448-240 240 0 132.552 107.448 240 240 240z m-40-280v-80a40 40 0 0 1 80 0v80h80a40 40 0 0 1 0 80h-80v80a40 40 0 0 1-80 0v-80h-80a40 40 0 0 1 0-80h80z" ></path></symbol><symbol id="icon-tongjijiedian-" vie
if (c && !e.__iconfont__svg__cssinject__) {
e.__iconfont__svg__cssinject__ = true;
try {
document.write(
"<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>"
);
} catch (a) {
console && console.log(a);
}
}
function h() {
s || (s = true, o());
}
t = function() {
var a, u, d, p;
(p = document.createElement("div")).innerHTML = l, l = null, (d = p.getElementsByTagName("svg")[0]) && (d.setAttribute("aria-hidden", "true"), d.style.position = "absolute", d.style.width = 0, d.style.height = 0, d.style.overflow = "hidden", a = d, (u = document.body).firstChild ? (p = a, (d = u.firstChild).parentNode.insertBefore(p, d)) : u.appendChild(a));
}, document.addEventListener ? ~["complete", "loaded", "interactive"].indexOf(document.readyState) ? setTimeout(t, 0) : (n = function() {
document.removeEventListener("DOMContentLoaded", n, false), t();
}, document.addEventListener("DOMContentLoaded", n, false)) : document.attachEvent && (o = t, i = e.document, s = false, (r = function() {
try {
i.documentElement.doScroll("left");
} catch {
return void setTimeout(r, 50);
}
h();
})(), i.onreadystatechange = function() {
i.readyState == "complete" && (i.onreadystatechange = null, h());
});
})(window);
var L = 0;
var z = 1;
var X = 2;
var T = 30;
var M = 8;
var Le = {
name: "Latte",
palette: ["#dd7878", "#ea76cb", "#8839ef", "#e64553", "#fe640b", "#df8e1d", "#40a02b", "#209fb5", "#1e66f5", "#7287fd"],
cssVar: {
"--main-color": "#444446",
"--main-bgcolor": "#ffffff",
"--color": "#777777",
"--bgcolor": "#f6f6f6",
"--panel-color": "#444446",
"--panel-bgcolor": "#ffffff",
"--panel-border-color": "#eaeaea"
}
};
var Me = {
name: "Dark",
palette: ["#848FA0", "#748BE9", "#D2F9FE", "#4145A5", "#789AFA", "#706CF4", "#EF987F", "#775DD5", "#FCEECF", "#DA7FBC"],
cssVar: {
"--main-color": "#ffffff",
"--main-bgcolor": "#4c4f69",
"--color": "#cccccc",
"--bgcolor": "#252526",
"--panel-color": "#ffffff",
"--panel-bgcolor": "#2d3748",
"--panel-border-color": "#696969"
}
};
function ne(e) {
return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
}
var Ye = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
var oe = function(e, t) {
if (t.id === e)
return t;
if (t.children && t.children.length) {
for (let n = 0; n < t.children.length; n++) {
const o = oe(e, t.children[n]);
if (o)
return o;
}
return null;
} else
return null;
};
var $ = (e, t) => {
if (e.parent = t, e.children)
for (let n = 0; n < e.children.length; n++)
$(e.children[n], e);
};
function Te(e) {
if (e.id = J(), e.children)
for (let t = 0; t < e.children.length; t++)
Te(e.children[t]);
}
var Ge = (e, t) => {
let n = Date.now();
return function(...o) {
Date.now() - n >= t && (e(...o), n = Date.now());
};
};
function $e(e, t, n, o) {
const i = o - t, s = e - n;
let r = Math.atan(Math.abs(i) / Math.abs(s)) / 3.14 * 180;
s < 0 && i > 0 && (r = 180 - r), s < 0 && i < 0 && (r = 180 + r), s > 0 && i < 0 && (r = 360 - r);
const l = 15, c = 30, h = r + c, a = r - c;
return {
x1: n + Math.cos(Math.PI * h / 180) * l,
y1: o - Math.sin(Math.PI * h / 180) * l,
x2: n + Math.cos(Math.PI * a / 180) * l,
y2: o - Math.sin(Math.PI * a / 180) * l
};
}
function J() {
return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16);
}
var Xe = function() {
const e = J();
return {
topic: this.newTopicName,
id: e
};
};
function Je(e, t) {
let n = true;
for (; t.parent; ) {
if (t.parent === e) {
n = false;
break;
}
t = t.parent;
}
return n;
}
function De(e) {
return JSON.parse(
JSON.stringify(e, (n, o) => {
if (n !== "parent")
return o;
})
);
}
var K = (e, t) => {
let n = 0, o = 0;
for (; t && t !== e; )
n += t.offsetLeft, o += t.offsetTop, t = t.offsetParent;
return { offsetLeft: n, offsetTop: o };
};
var C = (e, t) => {
for (const n in t)
e.setAttribute(n, t[n]);
};
var ae = (e) => e ? e.tagName === "ME-TPC" : false;
var S = {
moved: false,
// diffrentiate click and move
mousedown: false,
onMove(e, t) {
if (this.mousedown) {
this.moved = true;
const n = e.movementX, o = e.movementY;
t.scrollTo(t.scrollLeft - n, t.scrollTop - o);
}
},
clear() {
this.moved = false, this.mousedown = false;
}
};
function Qe(e) {
e.map.addEventListener("click", (t) => {
var o, i;
if (t.button !== 0)
return;
if ((o = e.helper1) != null && o.moved) {
e.helper1.clear();
return;
}
if ((i = e.helper2) != null && i.moved) {
e.helper2.clear();
return;
}
if (S.moved) {
S.clear();
return;
}
e.unselectNode(), e.unselectNodes(), e.unselectSummary(), e.unselectLink();
const n = t.target;
if (n.tagName === "ME-EPD")
e.expandNode(n.previousSibling);
else if (e.editable)
ae(n) ? e.selectNode(n, false, t) : n.tagName === "text" ? n.dataset.type === "custom-link" ? e.selectLink(n.parentElement) : e.selectSummary(n.parentElement) : n.className === "circle" || e.hideLinkController && e.hideLinkController();
else
return;
}), e.map.addEventListener("dblclick", (t) => {
if (t.preventDefault(), !e.editable)
return;
const n = t.target;
ae(n) ? e.beginEdit(n) : n.tagName === "text" && (n.dataset.type === "custom-link" ? e.editCutsomLinkLabel(n.parentElement) : e.editSummary(n.parentElement));
}), e.map.addEventListener("mousemove", (t) => {
t.target.contentEditable !== "true" && S.onMove(t, e.container);
}), e.map.addEventListener("mousedown", (t) => {
const n = e.mouseSelectionButton === 0 ? 2 : 0;
t.button === n && t.target.contentEditable !== "true" && (S.moved = false, S.mousedown = true);
}), e.map.addEventListener("mouseleave", (t) => {
const n = e.mouseSelectionButton === 0 ? 2 : 0;
t.button === n && S.clear();
}), e.map.addEventListener("mouseup", (t) => {
const n = e.mouseSelectionButton === 0 ? 2 : 0;
t.button === n && S.clear();
}), e.map.addEventListener("contextmenu", (t) => {
t.preventDefault();
});
}
var Ze = {
create() {
return {
handlers: {},
showHandler: function() {
console.log(this.handlers);
},
addListener: function(e, t) {
this.handlers[e] === void 0 && (this.handlers[e] = []), this.handlers[e].push(t);
},
fire: function(e, ...t) {
if (this.handlers[e] instanceof Array) {
const n = this.handlers[e];
for (let o = 0; o < n.length; o++)
n[o](...t);
}
},
removeListener: function(e, t) {
if (!this.handlers[e])
return;
const n = this.handlers[e];
if (!t)
n.length = 0;
else if (n.length)
for (let o = 0; o < n.length; o++)
n[o] === t && this.handlers[e].splice(o, 1);
}
};
}
};
var ie = document;
var et = function() {
console.time("layout"), this.nodes.innerHTML = "";
const e = this.createTopic(this.nodeData);
ue(e, this.nodeData), e.draggable = false;
const t = ie.createElement("me-root");
t.appendChild(e);
const n = this.nodeData.children || [];
if (this.direction === X) {
let o = 0, i = 0;
n.map((s) => {
s.direction === L ? o += 1 : s.direction === z ? i += 1 : o <= i ? (s.direction = L, o += 1) : (s.direction = z, i += 1);
});
}
tt(this, n, t), console.timeEnd("layout");
};
var tt = function(e, t, n) {
const o = ie.createElement("me-main");
o.className = "lhs";
const i = ie.createElement("me-main");
i.className = "rhs";
for (let s = 0; s < t.length; s++) {
const r = t[s], { grp: l } = e.createWrapper(r);
e.direction === X ? r.direction === L ? o.appendChild(l) : i.appendChild(l) : e.direction === L ? o.appendChild(l) : i.appendChild(l);
}
e.nodes.appendChild(o), e.nodes.appendChild(n), e.nodes.appendChild(i), e.nodes.appendChild(e.lines);
};
var nt = function(e, t) {
const n = ie.createElement("me-children");
for (let o = 0; o < t.length; o++) {
const i = t[o], { grp: s } = e.createWrapper(i);
n.appendChild(s);
}
return n;
};
var k = document;
var N = (e, t) => {
const o = (t ? t.mindElixirBox : k).querySelector(`[data-nodeid=me${e}]`);
if (!o)
throw new Error(`FindEle: Node ${e} not found, maybe it's collapsed.`);
return o;
};
var ue = function(e, t) {
if (e.innerHTML = "", t.style && (e.style.color = t.style.color || "", e.style.background = t.style.background || "", e.style.fontSize = t.style.fontSize + "px", e.style.fontWeight = t.style.fontWeight || "normal"), t.branchColor && (e.style.borderColor = t.branchColor), t.image) {
const n = t.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", e.appendChild(o), e.image = o;
} else
console.warn("image url/width/height are required");
} else
e.image && (e.image = void 0);
{
const n = k.createElement("span");
n.className = "text", n.textContent = t.topic, e.appendChild(n), e.text = n;
}
if (t.hyperLink) {
const n = k.createElement("a");
n.className = "hyper-link", n.target = "_blank", n.innerText = "🔗", n.href = t.hyperLink, e.appendChild(n), e.linkContainer = n;
} else
e.linkContainer && (e.linkContainer = void 0);
if (t.icons && t.icons.length) {
const n = k.createElement("span");
n.className = "icons", n.innerHTML = t.icons.map((o) => `<span>${ne(o)}</span>`).join(""), e.appendChild(n), e.icons = n;
} else
e.icons && (e.icons = void 0);
if (t.tags && t.tags.length) {
const n = k.createElement("div");
n.className = "tags", n.innerHTML = t.tags.map((o) => `<span>${ne(o)}</span>`).join(""), e.appendChild(n), e.tags = n;
} else
e.tags && (e.tags = void 0);
};
var ot = function(e, t) {
const n = k.createElement("me-wrapper"), { p: o, tpc: i } = this.createParent(e);
if (n.appendChild(o), !t && e.children && e.children.length > 0) {
const s = re(e.expanded);
if (o.appendChild(s), e.expanded !== false) {
const r = nt(this, e.children);
n.appendChild(r);
}
}
return { grp: n, top: o, tpc: i };
};
var it = function(e) {
const t = k.createElement("me-parent"), n = this.createTopic(e);
return ue(n, e), t.appendChild(n), { p: t, tpc: n };
};
var st = function(e) {
const t = k.createElement("me-children");
return t.append(...e), t;
};
var rt = function(e) {
const t = k.createElement("me-tpc");
return t.nodeObj = e, t.dataset.nodeid = "me" + e.id, t.draggable = this.draggable, t;
};
function je(e) {
const t = k.createRange();
t.selectNodeContents(e);
const n = window.getSelection();
n && (n.removeAllRanges(), n.addRange(t));
}
var lt = function(e) {
if (console.time("editTopic"), !e)
return;
const t = k.createElement("div"), n = e.text.textContent;
e.appendChild(t), t.id = "input-box", t.textContent = n, t.contentEditable = "true", t.spellcheck = false, t.style.cssText = `min-width:${e.offsetWidth - 8}px;`, this.direction === L && (t.style.right = "0"), t.focus(), je(t), this.bus.fire("operation", {
name: "beginEdit",
obj: e.nodeObj
}), t.addEventListener("keydown", (o) => {
o.stopPropagation();
const i = o.key;
if (i === "Enter" || i === "Tab") {
if (o.shiftKey)
return;
o.preventDefault(), t == null || t.blur(), this.map.focus();
}
}), t.addEventListener("blur", () => {
var s;
if (!t)
return;
const o = e.nodeObj, i = ((s = t.textContent) == null ? void 0 : s.trim()) || "";
console.log(i), i === "" ? o.topic = n : o.topic = i, t.remove(), i !== n && (e.text.textContent = o.topic, this.linkDiv(), this.bus.fire("operation", {
name: "finishEdit",
obj: o,
origin: n
}));
}), console.timeEnd("editTopic");
};
var re = function(e) {
const t = k.createElement("me-epd");
return t.expanded = e !== false, t.className = e !== false ? "minus" : "", t;
};
var q = document;
var F = "http://www.w3.org/2000/svg";
var ct = function(e, t) {
const n = q.createElementNS(F, "path");
return n.setAttribute("d", e), n.setAttribute("stroke", t || "#666"), n.setAttribute("fill", "none"), n.setAttribute("stroke-width", "3"), n;
};
var G = function(e) {
const t = q.createElementNS(F, "svg");
return t.setAttribute("class", e), t.setAttribute("overflow", "visible"), t;
};
var pe = function() {
const e = q.createElementNS(F, "line");
return e.setAttribute("stroke", "#bbb"), e.setAttribute("fill", "none"), e.setAttribute("stroke-width", "2"), e;
};
var at = function(e, t) {
const n = q.createElementNS(F, "path");
return n.setAttribute("d", e), n.setAttribute("stroke", t || "#555"), n.setAttribute("fill", "none"), n.setAttribute("stroke-linecap", "square"), n.setAttribute("stroke-width", "2"), n;
};
var dt = function(e, t) {
const n = {
stroke: "rgb(235, 95, 82)",
fill: "none",
"stroke-linecap": "cap",
"stroke-width": "2"
}, o = q.createElementNS(F, "g"), i = q.createElementNS(F, "path"), s = q.createElementNS(F, "path");
return C(s, {
d: t,
...n
}), C(i, {
d: e,
...n,
"stroke-dasharray": "8,2"
}), o.appendChild(i), o.appendChild(s), o;
};
var Oe = function(e, t, n) {
if (console.time("editSummary"), !t)
return;
const o = document.createElement("div");
e.nodes.appendChild(o);
const i = t.innerHTML;
o.id = "input-box", o.textContent = i, o.contentEditable = "true", o.spellcheck = false;
const s = t.getAttribute("x") + "px", r = t.getAttribute("y") + "px";
o.style.cssText = `min-width:${100 - 8}px;position:absolute;left:${s};top:${r};`;
const l = t.getAttribute("text-anchor");
l === "end" ? o.style.cssText += "transform: translate(-100%, -100%);" : l === "middle" ? o.style.cssText += "transform: translate(-50%, -100%);" : o.style.cssText += "transform: translate(0, -100%);", o.focus(), je(o), o.addEventListener("keydown", (c) => {
c.stopPropagation();
const h = c.key;
if (h === "Enter" || h === "Tab") {
if (c.shiftKey)
return;
c.preventDefault(), o.blur(), e.map.focus();
}
}), o.addEventListener("blur", () => {
o && n(o);
}), console.timeEnd("editSummary");
};
var Ae = He;
var ht = function(e) {
console.time("linkDiv");
const t = this.map.querySelector("me-root");
this.nodes.style.top = `${1e4 - this.nodes.offsetHeight / 2}px`, this.nodes.style.left = `${1e4 - t.offsetLeft - t.offsetWidth / 2}px`;
const n = this.map.querySelectorAll("me-main > me-wrapper");
this.lines.innerHTML = "", Ae = this.subLinkStyle === 2 ? pt : He;
for (let o = 0; o < n.length; o++) {
const i = n[o], s = i.querySelector("me-tpc"), r = i.firstChild, l = i.parentNode.className;
let c = t.offsetLeft + t.offsetWidth / 2;
const h = t.offsetTop + t.offsetHeight / 2;
let a;
const u = this.theme.palette, d = s.nodeObj.branchColor || u[o % u.length], { offsetLeft: p, offsetTop: g } = K(this.nodes, r);
l === "lhs" ? a = p + r.offsetWidth : a = p;
const m = g + r.offsetHeight / 2;
let f = "";
if (this.mainLinkStyle === 2)
this.direction === X && (l === "lhs" ? c = c - t.offsetWidth / 6 : c = c + t.offsetWidth / 6), f = ut({ x1: c, y1: h, x2: a, y2: m });
else {
const b = (1 - Math.abs(m - i.parentElement.offsetTop - i.parentElement.offsetHeight / 2) / i.parentElement.offsetHeight) * 0.25 * (t.offsetWidth / 2);
l === "lhs" ? c = c - t.offsetWidth / 10 - b : c = c + t.offsetWidth / 10 + b, f = ft({ x1: c, y1: h, x2: a, y2: m });
}
this.lines.appendChild(ct(f, d));
const v = i.children[0].children[1];
if (v && (v.style.top = (v.parentNode.offsetHeight - v.offsetHeight) / 2 + "px", l === "lhs" ? v.style.left = "-10px" : v.style.right = "-10px"), !(e && e !== i) && i.childElementCount) {
const y = G("subLines"), b = i.lastChild;
b.tagName === "svg" && b.remove(), i.appendChild(y);
const x = i.firstChild, w = i.children[1].children, _ = Pe(w, x, l, true);
y.appendChild(at(_, d));
}
}
this.renderCustomLink(), this.renderSummary(), console.timeEnd("linkDiv");
};
var Pe = function(e, t, n, o) {
let i = "";
const s = t.offsetTop, r = t.offsetLeft, l = t.offsetWidth, c = t.offsetHeight;
for (let h = 0; h < e.length; h++) {
const a = e[h], u = a.firstChild, d = u.offsetTop, p = u.offsetLeft, g = u.offsetWidth, m = u.offsetHeight;
i += Ae({ pT: s, pL: r, pW: l, pH: c, cT: d, cL: p, cW: g, cH: m, direction: n, isFirst: o });
const f = u.children[1];
if (f) {
if (f.style.bottom = -(f.offsetHeight / 2) + "px", n === "lhs" ? f.style.left = "10px" : n === "rhs" && (f.style.right = "10px"), !f.expanded)
continue;
} else
continue;
const v = a.children[1].children;
v.length > 0 && (i += Pe(v, u, n));
}
return i;
};
function ut({ x1: e, y1: t, x2: n, y2: o }) {
return `M ${e} ${t} V ${o > t ? o - 20 : o + 20} C ${e} ${o} ${e} ${o} ${n > e ? e + 20 : e - 20} ${o} H ${n}`;
}
function ft({ x1: e, y1: t, x2: n, y2: o }) {
return `M ${e} ${t} Q ${e} ${o} ${n} ${o}`;
}
function pt({ pT: e, pL: t, pW: n, pH: o, cT: i, cL: s, cW: r, cH: l, direction: c, isFirst: h }) {
let a;
h ? a = e + o / 2 : a = e + o;
const u = i + l;
let d = 0, p = 0, g = 0;
return c === "lhs" ? (d = t + T, p = s, g = s + r) : c === "rhs" && (d = t + n - T, p = s + r, g = s), u < a + 50 && u > a - 50 ? `M ${d} ${a} H ${g} V ${u} H ${p}` : u >= a ? `M ${d} ${a} H ${g} V ${u - M} A ${M} ${M} 0 0 ${d > p ? 1 : 0} ${d > p ? g - M : g + M} ${u} H ${p}` : `M ${d} ${a} H ${g} V ${u + M} A ${M} ${M} 0 0 ${d > p ? 0 : 1} ${d > p ? g - M : g + M} ${u} H ${p}`;
}
function He({ pT: e, pL: t, pW: n, pH: o, cT: i, cL: s, cW: r, cH: l, direction: c, isFirst: h }) {
let a = 0, u = 0;
h ? a = e + o / 2 : a = e + o;
const d = i + l;
let p = 0, g = 0, m = 0;
const f = Math.min(Math.abs(a - d) / 800, 1.2) * T;
return c === "lhs" ? (m = t, p = m + T, g = m - T, u = s + T, `M ${p} ${a} C ${m} ${a} ${m + f} ${d} ${g} ${d} H ${u}`) : (m = t + n, p = m - T, g = m + T, u = s + r - T, `M ${p} ${a} C ${m} ${a} ${m - f} ${d} ${g} ${d} H ${u}`);
}
var me = {
addChild: "插入子节点",
addParent: "插入父节点",
addSibling: "插入同级节点",
removeNode: "删除节点",
focus: "专注",
cancelFocus: "取消专注",
moveUp: "上移",
moveDown: "下移",
link: "连接",
clickTips: "请点击目标节点",
summary: "摘要"
};
var ge = {
cn: me,
zh_CN: me,
zh_TW: {
addChild: "插入子節點",
addParent: "插入父節點",
addSibling: "插入同級節點",
removeNode: "刪除節點",
focus: "專注",
cancelFocus: "取消專注",
moveUp: "上移",
moveDown: "下移",
link: "連接",
clickTips: "請點擊目標節點",
summary: "摘要"
},
en: {
addChild: "Add child",
addParent: "Add parent",
addSibling: "Add sibling",
removeNode: "Remove node",
focus: "Focus Mode",
cancelFocus: "Cancel Focus Mode",
moveUp: "Move up",
moveDown: "Move down",
link: "Link",
clickTips: "Please click the target node",
summary: "Summary"
},
ru: {
addChild: "Добавить дочерний элемент",
addParent: "Добавить родительский элемент",
addSibling: "Добавить на этом уровне",
removeNode: "Удалить узел",
focus: "Режим фокусировки",
cancelFocus: "Отменить режим фокусировки",
moveUp: "Поднять выше",
moveDown: "Опустить ниже",
link: "Ссылка",
clickTips: "Пожалуйста, нажмите на целевой узел",
summary: "Описание"
},
ja: {
addChild: "子ノードを追加する",
addParent: "親ノードを追加します",
addSibling: "兄弟ノードを追加する",
removeNode: "ノードを削除",
focus: "集中",
cancelFocus: "集中解除",
moveUp: "上へ移動",
moveDown: "下へ移動",
link: "コネクト",
clickTips: "ターゲットノードをクリックしてください",
summary: "概要"
},
pt: {
addChild: "Adicionar item filho",
addParent: "Adicionar item pai",
addSibling: "Adicionar item irmao",
removeNode: "Remover item",
focus: "Modo Foco",
cancelFocus: "Cancelar Modo Foco",
moveUp: "Mover para cima",
moveDown: "Mover para baixo",
link: "Link",
clickTips: "Favor clicar no item alvo",
summary: "Resumo"
}
};
function mt(e, t) {
const n = (b) => {
const x = document.createElement("div");
return x.innerText = b, x.className = "tips", x;
}, o = (b, x, w) => {
const _ = document.createElement("li");
return _.id = b, _.innerHTML = `<span>${ne(x)}</span><span>${ne(w)}</span>`, _;
}, i = ge[e.locale] ? e.locale : "en", s = ge[i], r = o("cm-add_child", s.addChild, "tab"), l = o("cm-add_parent", s.addParent, ""), c = o("cm-add_sibling", s.addSibling, "enter"), h = o("cm-remove_child", s.removeNode, "delete"), a = o("cm-fucus", s.focus, ""), u = o("cm-unfucus", s.cancelFocus, ""), d = o("cm-up", s.moveUp, "PgUp"), p = o("cm-down", s.moveDown, "Pgdn"), g = o("cm-down", s.link, ""), m = o("cm-down", s.summary, ""), f = document.createElement("ul");
if (f.className = "menu-list", f.appendChild(r), f.appendChild(l), f.appendChild(c), f.appendChild(h), (!t || t.focus) && (f.appendChild(a), f.appendChild(u)), f.appendChild(d), f.appendChild(p), f.appendChild(m), (!t || t.link) && f.appendChild(g), t && t.extend)
for (let b = 0; b < t.extend.length; b++) {
const x = t.extend[b], w = o(x.name, x.name, x.key || "");
f.appendChild(w), w.onclick = (_) => {
x.onclick(_);
};
}
const v = document.createElement("div");
v.className = "context-menu", v.appendChild(f), v.hidden = true, e.container.append(v);
let y = true;
e.container.oncontextmenu = function(b) {
if (b.preventDefault(), !e.editable)
return;
const x = b.target;
if (ae(x)) {
x.parentElement.tagName === "ME-ROOT" ? y = true : y = false, y ? (a.className = "disabled", d.className = "disabled", p.className = "disabled", l.className = "disabled", c.className = "disabled", h.className = "disabled") : (a.className = "", d.className = "", p.className = "", l.className = "", c.className = "", h.className = ""), e.currentNodes || e.selectNode(x), v.hidden = false, S.mousedown && (S.mousedown = false), f.style.top = "", f.style.bottom = "", f.style.left = "", f.style.right = "";
const w = f.getBoundingClientRect(), _ = f.offsetHeight, P = f.offsetWidth, U = b.clientY - w.top, H = b.clientX - w.left;
_ + U > window.innerHeight ? (f.style.top = "", f.style.bottom = "0px") : (f.style.bottom = "", f.style.top = U + 15 + "px"), P + H > window.innerWidth ? (f.style.left = "", f.style.right = "0px") : (f.style.right = "", f.style.left = H + 10 + "px");
}
}, v.onclick = (b) => {
b.target === v && (v.hidden = true);
}, r.onclick = () => {
e.addChild(), v.hidden = true;
}, l.onclick = () => {
e.insertParent(), v.hidden = true;
}, c.onclick = () => {
y || (e.insertSibling(), v.hidden = true);
}, h.onclick = () => {
y || (e.removeNode(), v.hidden = true);
}, a.onclick = () => {
y || (e.focusNode(e.currentNode), v.hidden = true);
}, u.onclick = () => {
e.cancelFocus(), v.hidden = true;
}, d.onclick = () => {
y || (e.moveUpNode(), v.hidden = true);
}, p.onclick = () => {
y || (e.moveDownNode(), v.hidden = true);
}, g.onclick = () => {
v.hidden = true;
const b = e.currentNode, x = n(s.clickTips);
e.container.appendChild(x), e.map.addEventListener(
"click",
(w) => {
w.preventDefault(), x.remove();
const _ = w.target;
_.parentElement.tagName === "ME-PARENT" || _.parentElement.tagName === "ME-ROOT" ? e.createLink(b, _) : console.log("link cancel");
},
{
once: true
}
);
}, m.onclick = () => {
v.hidden = true, e.createSummary(), e.unselectNodes();
};
}
var gt = (e) => {
const t = e.map.querySelectorAll(".lhs>me-wrapper>me-parent>me-tpc");
e.selectNode(t[Math.ceil(t.length / 2) - 1]);
};
var vt = (e) => {
const t = e.map.querySelectorAll(".rhs>me-wrapper>me-parent>me-tpc");
e.selectNode(t[Math.ceil(t.length / 2) - 1]);
};
var ve = (e) => {
e.selectNode(e.map.querySelector("me-root>me-tpc"));
};
function bt(e) {
const t = {
13: (n) => {
n.shiftKey ? e.insertBefore() : e.insertSibling();
},
9: () => {
e.addChild();
},
112: () => {
e.toCenter();
},
113: () => {
e.beginEdit();
},
38: (n) => {
if (n.altKey)
e.moveUpNode();
else {
if (n.metaKey || n.ctrlKey)
return e.initSide();
e.selectPrevSibling();
}
},
40: (n) => {
n.altKey ? e.moveDownNode() : e.selectNextSibling();
},
37: (n) => {
var s;
if (n.metaKey || n.ctrlKey)
return e.initLeft();
if (!e.currentNode)
return;
const o = e.currentNode.nodeObj, i = e.currentNode.offsetParent.offsetParent.parentElement;
e.currentNode.nodeObj.root ? gt(e) : i.className === "rhs" ? (s = o.parent) != null && s.root ? ve(e) : e.selectParent() : i.className === "lhs" && e.selectFirstChild();
},
39: (n) => {
var s;
if (n.metaKey || n.ctrlKey)
return e.initRight();
if (!e.currentNode)
return;
const o = e.currentNode.nodeObj, i = e.currentNode.offsetParent.offsetParent.parentElement;
o.root ? vt(e) : i.className === "lhs" ? (s = o.parent) != null && s.root ? ve(e) : e.selectParent() : i.className === "rhs" && e.selectFirstChild();
},
33() {
e.moveUpNode();
},
34() {
e.moveDownNode();
},
67: (n) => {
(n.metaKey || n.ctrlKey) && (e.waitCopy = e.currentNode);
},
86: (n) => {
!e.waitCopy || !e.currentNode || (n.metaKey || n.ctrlKey) && (e.copyNode(e.waitCopy, e.currentNode), e.waitCopy = null);
},
// ctrl +
187: (n) => {
if (n.metaKey || n.ctrlKey) {
if (e.scaleVal > 1.6)
return;
e.scale(e.scaleVal += 0.2);
}
},
// ctrl -
189: (n) => {
if (n.metaKey || n.ctrlKey) {
if (e.scaleVal < 0.6)
return;
e.scale(e.scaleVal -= 0.2);
}
},
// ctrl 0
48: (n) => {
(n.metaKey || n.ctrlKey) && e.scale(1);
}
};
e.map.onkeydown = (n) => {
if (n.preventDefault(), !!e.editable && n.target === n.currentTarget)
if (n.keyCode === 8 || n.keyCode === 46)
e.currentLink ? e.removeLink() : e.currentSummary ? e.removeSummary(e.currentSummary.summaryObj.id) : e.currentNode ? e.removeNode() : e.currentNodes && e.removeNodes(e.currentNodes);
else {
const o = t[n.keyCode];
o && o(n);
}
};
}
function yt(e, t) {
const n = (d, p) => {
const g = document.createElement("div");
return g.id = d, g.innerHTML = `<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-${p}"></use>
</svg>`, g;
}, o = n("cm-add_child", "zijiedian"), i = n("cm-add_sibling", "tongjijiedian-"), s = n("cm-remove_child", "shanchu2"), r = n("cm-up", "rising"), l = n("cm-down", "falling"), c = n("cm-edit", "edit"), h = document.createElement("ul");
if (h.className = "menu-list", t && t.extend)
for (let d = 0; d < t.extend.length; d++) {
const p = t.extend[d], g = n(p.name, p.name);
h.appendChild(g), g.onclick = (m) => {
p.onclick(m);
};
}
const a = document.createElement("mmenu");
a.className = "mobile-menu", a.appendChild(o), a.appendChild(i), a.appendChild(s), a.appendChild(r), a.appendChild(l), a.appendChild(c), a.hidden = true, e.container.append(a);
let u = true;
e.bus.addListener("unselectNode", function() {
a.hidden = true;
}), e.bus.addListener("selectNode", function(d) {
a.hidden = false, d.root ? u = true : u = false;
}), a.onclick = (d) => {
d.target === a && (a.hidden = true);
}, o.onclick = () => {
e.addChild();
}, i.onclick = () => {
u || e.insertSibling();
}, s.onclick = () => {
u || e.removeNode();
}, r.onclick = (d) => {
u || e.moveUpNode();
}, l.onclick = (d) => {
u || e.moveDownNode();
}, c.onclick = (d) => {
e.beginEdit();
};
}
var de = document;
var xt = function(e, t) {
if (!t)
return he(e), e;
const n = e.getElementsByClassName("insert-preview"), o = `insert-preview ${t} show`;
if (n.length > 0)
n[0].className = o;
else {
const i = de.createElement("div");
i.className = o, e.appendChild(i);
}
return e;
};
var he = function(e) {
if (!e)
return;
const t = e.getElementsByClassName("insert-preview");
for (const n of t || [])
n.remove();
};
var be = function(e, t) {
const n = t.parentElement.parentElement.contains(e);
return e && e.tagName === "ME-TPC" && e !== t && !n && e.nodeObj.root !== true;
};
var wt = function(e) {
const t = document.createElement("div");
return t.className = "mind-elixir-ghost", e.map.appendChild(t), t;
};
function Et(e) {
let t = null, n = null, o = null;
const i = wt(e), s = 12;
e.map.addEventListener("dragstart", (r) => {
var c;
const l = r.target;
if ((l == null ? void 0 : l.tagName) !== "ME-TPC") {
r.preventDefault();
return;
}
t = l, t.parentElement.parentElement.style.opacity = "0.5", i.innerHTML = t.innerHTML, (c = r.dataTransfer) == null || c.setDragImage(i, 0, 0), S.clear();
}), e.map.addEventListener("dragend", async (r) => {
if (!t)
return;
t.parentElement.parentElement.style.opacity = "1";
const l = r.target;
if (l.style.opacity = "", !o)
return;
he(o);
const c = t.nodeObj;
switch (n) {
case "before":
e.moveNodeBefore(t, o), e.selectNode(N(c.id));
break;
case "after":
e.moveNodeAfter(t, o), e.selectNode(N(c.id));
break;
case "in":
e.moveNode(t, o);
break;
}
t = null;
}), e.map.addEventListener(
"dragover",
Ge(function(r) {
if (!t)
return;
he(o);
const l = de.elementFromPoint(r.clientX, r.clientY - s);
if (be(l, t)) {
o = l;
const c = l.getBoundingClientRect().y;
r.clientY > c + l.clientHeight ? n = "after" : r.clientY > c + l.clientHeight / 2 && (n = "in");
} else {
const c = de.elementFromPoint(r.clientX, r.clientY + s);
if (be(c, t)) {
o = c;
const h = c.getBoundingClientRect().y;
r.clientY < h ? n = "before" : r.clientY < h + c.clientHeight / 2 && (n = "in");
} else
n = o = null;
}
o && xt(o, n);
}, 200)
);
}
var Nt = function(e) {
return ["createSummary", "removeSummary", "finishEditSummary"].includes(e.name) ? {
type: "summary",
value: e.obj.id
} : ["createCustomLink", "removeCustomLink", "finishEditCustomLinkLabel"].includes(e.name) ? {
type: "customLink",
value: e.obj.id
} : ["removeNodes"].includes(e.name) ? {
type: "nodes",
value: e.objs.map((t) => t.id)
} : {
type: "node",
value: e.obj.id
};
};
function Ct(e) {
let t = [], n = -1, o = e.getData();
e.bus.addListener("operation", (i) => {
if (i.name === "beginEdit")
return;
t = t.slice(0, n + 1);
const s = e.getData();
t.push({ prev: o, currentObject: Nt(i), next: s }), o = s, n = t.length - 1;
}), e.undo = function() {
if (n > -1) {
const i = t[n];
o = i.prev, e.refresh(i.prev), i.currentObject.type === "node" && e.selectNode(N(i.currentObject.value)), n--, console.log("current", o);
}
}, e.redo = function() {
if (n < t.length - 1) {
n++;
const i = t[n];
o = i.next, e.refresh(i.next), i.currentObject.type === "node" && e.selectNode(N(i.currentObject.value));
}
}, e.map.addEventListener("keydown", (i) => {
(i.metaKey || i.ctrlKey) && i.shiftKey && i.key === "Z" ? e.redo() : (i.metaKey || i.ctrlKey) && i.key === "z" && e.undo();
});
}
var R = (e, t) => {
const n = document.createElement("span");
return n.id = e, n.innerHTML = `<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-${t}"></use>
</svg>`, n;
};
function _t(e) {
const t = document.createElement("div"), n = R("fullscreen", "full"), o = R("toCenter", "living"), i = R("zoomout", "move"), s = R("zoomin", "add"), r = document.createElement("span");
return r.innerText = "100%", t.appendChild(n), t.appendChild(o), t.appendChild(i), t.appendChild(s), t.className = "mind-elixir-toolbar rb", n.onclick = () => {
e.container.requestFullscreen();
}, o.onclick = () => {
e.toCenter();
}, i.onclick = () => {
e.scaleVal < 0.6 || e.scale(e.scaleVal -= 0.2);
}, s.onclick = () => {
e.scaleVal > 1.6 || e.scale(e.scaleVal += 0.2);
}, t;
}
function kt(e) {
const t = document.createElement("div"), n = R("tbltl", "left"), o = R("tbltr", "right"), i = R("tblts", "side");
return t.appendChild(n), t.appendChild(o), t.appendChild(i), t.className = "mind-elixir-toolbar lt", n.onclick = () => {
e.initLeft();
}, o.onclick = () => {
e.initRight();
}, i.onclick = () => {
e.initSide();
}, t;
}
function St(e) {
e.container.append(_t(e)), e.container.append(kt(e));
}
var Lt = Object.defineProperty;
var Mt = (e, t, n) => t in e ? Lt(e, t, { enumerable: true, configurable: true, writable: true, value: n }) : e[t] = n;
var E = (e, t, n) => (Mt(e, typeof t != "symbol" ? t + "" : t, n), n);
var Tt = class {
constructor() {
E(this, "_listeners", /* @__PURE__ */ new Map()), E(this, "on", this.addEventListener), E(this, "off", this.removeEventListener), E(this, "emit", this.dispatchEvent);
}
addEventListener(t, n) {
const o = this._listeners.get(t) ?? /* @__PURE__ */ new Set();
return this._listeners.set(t, o), o.add(n), this;
}
removeEventListener(t, n) {
var o;
return (o = this._listeners.get(t)) == null || o.delete(n), this;
}
dispatchEvent(t, ...n) {
let o = true;
for (const i of this._listeners.get(t) ?? [])
o = i(...n) !== false && o;
return o;
}
unbindAllListeners() {
this._listeners.clear();
}
};
var ye = (e, t = "px") => typeof e == "number" ? e + t : e;
function j({ style: e }, t, n) {
if (typeof t == "object")
for (const [o, i] of Object.entries(t))
i !== void 0 && (e[o] = ye(i));
else
n !== void 0 && (e[t] = ye(n));
}
function Be(e) {
return (t, n, o, i = {}) => {
t instanceof HTMLCollection || t instanceof NodeList ? t = Array.from(t) : Array.isArray(t) || (t = [t]), Array.isArray(n) || (n = [n]);
for (const s of t)
for (const r of n)
s[e](r, o, { capture: false, ...i });
return [t, n, o, i];
};
}
var V = Be("addEventListener");
var O = Be("removeEventListener");
var ee = (e) => {
var t;
const { clientX: n, clientY: o, target: i } = ((t = e.touches) == null ? void 0 : t[0]) ?? e;
return { x: n, y: o, target: i };
};
function xe(e, t, n = "touch") {
switch (n) {
case "center": {
const o = t.left + t.width / 2, i = t.top + t.height / 2;
return o >= e.left && o <= e.right && i >= e.top && i <= e.bottom;
}
case "cover":
return t.left >= e.left && t.top >= e.top && t.right <= e.right && t.bottom <= e.bottom;
case "touch":
return e.right >= t.left && e.left <= t.right && e.bottom >= t.top && e.top <= t.bottom;
}
}
function W(e, t = document) {
const n = Array.isArray(e) ? e : [e];
let o = [];
for (let i = 0, s = n.length; i < s; i++) {
const r = n[i];
typeof r == "string" ? o = o.concat(Array.from(t.querySelectorAll(r))) : r instanceof Element && o.push(r);
}
return o;
}
var $t = () => matchMedia("(hover: none), (pointer: coarse)").matches;
var Dt = () => "safari" in window;
var jt = (e) => {
let t, n = -1, o = false;
return {
next(...i) {
t = i, o || (o = true, n = requestAnimationFrame(() => {
e(...t), o = false;
}));
},
cancel() {
cancelAnimationFrame(n), o = false;
}
};
};
var { abs: B, max: we, min: Ee, ceil: Ne } = Math;
var ze = class extends Tt {
constructor(t) {
var n, o, i, s, r;
super(), E(this, "_options"), E(this, "_selection", {
stored: [],
selected: [],
touched: [],
changed: {
added: [],
// Added elements since last selection
removed: []
// Removed elements since last selection
}
}), E(this, "_area"), E(this, "_clippingElement"), E(this, "_targetElement"), E(this, "_targetRect"), E(this, "_selectables", []), E(this, "_latestElement"), E(this, "_areaRect", new DOMRect()), E(this, "_areaLocation", { y1: 0, x2: 0, y2: 0, x1: 0 }), E(this, "_singleClick", true), E(this, "_frame"), E(this, "_scrollAvailable", true), E(this, "_scrollingActive", false), E(this, "_scrollSpeed", { x: 0, y: 0 }), E(this, "_scrollDelta", { x: 0, y: 0 }), E(this, "disable", this._bindStartEvents.bind(this, false)), E(this, "enable", this._bindStartEvents), this._options = {
selectionAreaClass: "selection-area",
selectionContainerClass: void 0,
selectables: [],
document: window.document,
startAreas: ["html"],
boundaries: ["html"],
container: "body",
...t,
behaviour: {
overlap: "invert",
intersect: "touch",
...t.behaviour,
startThreshold: (n = t.behaviour) != null && n.startThreshold ? typeof t.behaviour.startThreshold == "number" ? t.behaviour.startThreshold : { x: 10, y: 10, ...t.behaviour.startThreshold } : { x: 10, y: 10 },
scrolling: {
speedDivider: 10,
manualSpeed: 750,
...(o = t.behaviour) == null ? void 0 : o.scrolling,
startScrollMargins: {
x: 0,
y: 0,
...(s = (i = t.behaviour) == null ? void 0 : i.scrolling) == null ? void 0 : s.startScrollMargins
}
}
},
features: {
range: true,
touch: true,
...t.features,
singleTap: {
allow: true,
intersect: "native",
...(r = t.features) == null ? void 0 : r.singleTap
}
}
};
for (const a of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))
typeof this[a] == "function" && (this[a] = this[a].bind(this));
const { document: l, selectionAreaClass: c, selectionContainerClass: h } = this._options;
this._area = l.createElement("div"), this._clippingElement = l.createElement("div"), this._clippingElement.appendChild(this._area), this._area.classList.add(c), h && this._clippingElement.classList.add(h), j(this._area, {
willChange: "top, left, bottom, right, width, height",
top: 0,
left: 0,
position: "fixed"
}), j(this._clippingElement, {
overflow: "hidden",
position: "fixed",
transform: "translate3d(0, 0, 0)",
// https://stackoverflow.com/a/38268846
pointerEvents: "none",
zIndex: "1"
}), this._frame = jt((a) => {
this._recalculateSelectionAreaRect(), this._updateElementSelection(), this._emitEvent("move", a), this._redrawSelectionArea();
}), this.enable();
}
_bindStartEvents(t = true) {
const { document: n, features: o } = this._options, i = t ? V : O;
i(n, "mousedown", this._onTapStart), o.touch && i(n, "touchstart", this._onTapStart, {
passive: false
});
}
_onTapStart(t, n = false) {
const { x: o, y: i, target: s } = ee(t), { _options: r } = this, { document: l } = this._options, c = s.getBoundingClientRect(), h = W(r.startAreas, r.document), a = W(r.boundaries, r.document);
this._targetElement = a.find(
(p) => xe(p.getBoundingClientRect(), c)
);
const u = t.composedPath();
if (!this._targetElement || !h.find((p) => u.includes(p)) || !a.find((p) => u.includes(p)) || !n && this._emitEvent("beforestart", t) === false)
return;
this._areaLocation = { x1: o, y1: i, x2: 0, y2: 0 };
const d = l.scrollingElement ?? l.body;
this._scrollDelta = { x: d.scrollLeft, y: d.scrollTop }, this._singleClick = true, this.clearSelection(false, true), V(l, ["touchmove", "mousemove"], this._delayedTapMove, { passive: false }), V(l, ["mouseup", "touchcancel", "touchend"], this._onTapStop), V(l, "scroll", this._onScroll);
}
_onSingleTap(t) {
const { singleTap: { intersect: n }, range: o } = this._options.features, i = ee(t);
let s;
if (n === "native")
s = i.target;
else if (n === "touch") {
this.resolveSelectables();
const { x: l, y: c } = i;
s = this._selectables.find((h) => {
const { right: a, left: u, top: d, bottom: p } = h.getBoundingClientRect();
return l < a && l > u && c < p && c > d;
});
}
if (!s)
return;
for (this.resolveSelectables(); !this._selectables.includes(s); ) {
if (!s.parentElement)
return;
s = s.parentElement;
}
const { stored: r } = this._selection;
if (this._emitEvent("start", t), t.shiftKey && o && this._latestElement) {
const l = this._latestElement, [c, h] = l.compareDocumentPosition(s) & 4 ? [s, l] : [l, s], a = [...this._selectables.filter(
(u) => u.compareDocumentPosition(c) & 4 && u.compareDocumentPosition(h) & 2
), c, h];
this.select(a), this._latestElement = l;
} else
r.includes(s) && (r.length === 1 || t.ctrlKey || r.every((l) => this._selection.stored.includes(l))) ? this.deselect(s) : (this.select(s), this._latestElement = s);
this._emitEvent("stop", t);
}
_delayedTapMove(t) {
const { container: n, document: o, behaviour: { startThreshold: i } } = this._options, { x1: s, y1: r } = this._areaLocation, { x: l, y: c } = ee(t);
if (
// Single number for both coordinates
typeof i == "number" && B(l + c - (s + r)) >= i || // Different x and y threshold
typeof i == "object" && B(l - s) >= i.x || B(c - r) >= i.y
) {
if (O(o, ["mousemove", "touchmove"], this._delayedTapMove, { passive: false }), this._emitEvent("beforedrag", t) === false) {
O(o, ["mouseup", "touchcancel", "touchend"], this._onTapStop);
return;
}
V(o, ["mousemove", "touchmove"], this._onTapMove, { passive: false }), j(this._area, "display", "block"), W(n, o)[0].appendChild(this._clippingElement), this.resolveSelectables(), this._singleClick = false, this._targetRect = this._targetElement.getBoundingClientRect(), this._scrollAvailable = this._targetElement.scrollHeight !== this._targetElement.clientHeight || this._targetElement.scrollWidth !== this._targetElement.clientWidth, this._scrollAvailable && (V(o, "wheel", this._manualScroll, { passive: false }), this._selectables = this._selectables.filter((h) => this._targetElement.contains(h))), this._setupSelectionArea(), this._emitEvent("start", t), this._onTapMove(t);
}
this._handleMoveEvent(t);
}
_setupSelectionArea() {
const { _clippingElement: t, _targetElement: n, _area: o } = this, i = this._targetRect = n.getBoundingClientRect();
this._scrollAvailable ? (j(t, {
top: i.top,
left: i.left,
width: i.width,
height: i.height
}), j(o, {
marginTop: -i.top,
marginLeft: -i.left
})) : (j(t, {
top: 0,
left: 0,
width: "100%",
height: "100%"
}), j(o, {
marginTop: 0,
marginLeft: 0
}));
}
_onTapMove(t) {
const { x: n, y: o } = ee(t), { _scrollSpeed: i, _areaLocation: s, _options: r, _frame: l } = this, { speedDivider: c } = r.behaviour.scrolling, h = this._targetElement;
if (s.x2 = n, s.y2 = o, this._scrollAvailable && !this._scrollingActive && (i.y || i.x)) {
this._scrollingActive = true;
const a = () => {
if (!i.x && !i.y) {
this._scrollingActive = false;
return;
}
const { scrollTop: u, scrollLeft: d } = h;
i.y && (h.scrollTop += Ne(i.y / c), s.y1 -= h.scrollTop - u), i.x && (h.scrollLeft += Ne(i.x / c), s.x1 -= h.scrollLeft - d), l.next(t), requestAnimationFrame(a);
};
requestAnimationFrame(a);
} else
l.next(t);
this._handleMoveEvent(t);
}
_handleMoveEvent(t) {
const { features: n } = this._options;
(n.touch && $t() || this._scrollAvailable && Dt()) && t.preventDefault();
}
_onScroll() {
const { _scrollDelta: t, _options: { document: n } } = this, { scrollTop: o, scrollLeft: i } = n.scrollingElement ?? n.body;
this._areaLocation.x1 += t.x - i, this._areaLocation.y1 += t.y - o, t.x = i, t.y = o, this._setupSelectionArea(), this._frame.next(null);
}
_manualScroll(t) {
const { manualSpeed: n } = this._options.behaviour.scrolling, o = t.deltaY ? t.deltaY > 0 ? 1 : -1 : 0, i = t.deltaX ? t.deltaX > 0 ? 1 : -1 : 0;
this._scrollSpeed.y += o * n, this._scrollSpeed.x += i * n, this._onTapMove(t), t.preventDefault();
}
_recalculateSelectionAreaRect() {
const { _scrollSpeed: t, _areaLocation: n, _areaRect: o, _targetElement: i, _options: s } = this, { scrollTop: r, scrollHeight: l, clientHeight: c, scrollLeft: h, scrollWidth: a, clientWidth: u } = i, d = this._targetRect, { x1: p, y1: g } = n;
let { x2: m, y2: f } = n;
const { behaviour: { scrolling: { startScrollMargins: v } } } = s;
m < d.left + v.x ? (t.x = h ? -B(d.left - m + v.x) : 0, m = m < d.left ? d.left : m) : m > d.right - v.x ? (t.x = a - h - u ? B(d.left + d.width - m - v.x) : 0, m = m > d.right ? d.right : m) : t.x = 0, f < d.top + v.y ? (t.y = r ? -B(d.top - f + v.y) : 0, f = f < d.top ? d.top : f) : f > d.bottom - v.y ? (t.y = l - r - c ? B(d.top + d.height - f - v.y) : 0, f = f > d.bottom ? d.bottom : f) : t.y = 0;
const y = Ee(p, m), b = Ee(g, f), x = we(p, m), w = we(g, f);
o.x = y, o.y = b, o.width = x - y, o.height = w - b;
}
_redrawSelectionArea() {
const { x: t, y: n, width: o, height: i } = this._areaRect, { style: s } = this._area;
s.left = `${t}px`, s.top = `${n}px`, s.width = `${o}px`, s.height = `${i}px`;
}
_onTapStop(t, n) {
var o;
const { document: i, features: s } = this._options, { _singleClick: r } = this;
O(i, ["mousemove", "touchmove"], this._delayedTapMove), O(i, ["touchmove", "mousemove"], this._onTapMove), O(i, ["mouseup", "touchcancel", "touchend"], this._onTapStop), O(i, "scroll", this._onScroll), this._keepSelection(), t && r && s.singleTap.allow ? this._onSingleTap(t) : !r && !n && (this._updateElementSelection(), this._emitEvent("stop", t)), this._scrollSpeed.x = 0, this._scrollSpeed.y = 0, this._scrollAvailable && O(i, "wheel", this._manualScroll, { passive: true }), this._clippingElement.remove(), (o = this._frame) == null || o.cancel(), j(this._area, "display", "none");
}
_updateElementSelection() {
const { _selectables: t, _options: n, _selection: o, _areaRect: i } = this, { stored: s, selected: r, touched: l } = o, { intersect: c, overlap: h } = n.behaviour, a = h === "invert", u = [], d = [], p = [];
for (let m = 0; m < t.length; m++) {
const f = t[m];
if (xe(i, f.getBoundingClientRect(), c)) {
if (r.includes(f))
s.includes(f) && !l.includes(f) && l.push(f);
else if (a && s.includes(f)) {
p.push(f);
continue;
} else
d.push(f);
u.push(f);
}
}
a && d.push(...s.filter((m) => !r.includes(m)));
const g = h === "keep";
for (let m = 0; m < r.length; m++) {
const f = r[m];
!u.includes(f) && !// Check if user wants to keep previously selected elements, e.g.
// not make them part of the current selection as soon as they're touched.
(g && s.includes(f)) && p.push(f);
}
o.selected = u, o.changed = { added: d, removed: p }, this._latestElement = void 0;
}
_emitEvent(t, n) {
return this.emit(t, {
event: n,
store: this._selection,
selection: this
});
}
_keepSelection() {
const { _options: t, _selection: n } = this, { selected: o, changed: i, touched: s, stored: r } = n, l = o.filter((c) => !r.includes(c));
switch (t.behaviour.overlap) {
case "drop": {
n.stored = [
...l,
...r.filter((c) => !s.includes(c))
// Elements not touched
];
break;
}
case "invert": {
n.stored = [
...l,
...r.filter((c) => !i.removed.includes(c))
// Elements not removed from selection
];
break;
}
case "keep": {
n.stored = [
...r,
...o.filter((c) => !r.includes(c))
// Newly added
];
break;
}
}
}
/**
* Manually triggers the start of a selection
* @param evt A MouseEvent / TouchEvent -like object
* @param silent If beforestart should be fired,
*/
trigger(t, n = true) {
this._onTapStart(t, n);
}
/**
* Can be used if during a selection elements have been added.
* Will update everything which can be selected.
*/
resolveSelectables() {
this._selectables = W(this._options.selectables, this._options.document);
}
/**
* Same as deselect, but for all elements currently selected.
* @param includeStored If the store should also get cleared
* @param quiet If move / stop events should be fired
*/
clearSelection(t = true, n = false) {
const { selected: o, stored: i, changed: s } = this._selection;
s.added = [], s.removed.push(
...o,
...t ? i : []
), n || (this._emitEvent("move", null), this._emitEvent("stop", null)), this._selection = {
stored: t ? [] : i,
selected: [],
touched: [],
changed: { added: [], removed: [] }
};
}
/**
* @returns {Array} Selected elements
*/
getSelection() {
return this._selection.stored;
}
/**
* @returns {HTMLElement} The selection area element
*/
getSelectionArea() {
return this._area;
}
/**
* Cancel the current selection process.
* @param keepEvent {boolean} true to fire a stop event after cancel.
*/
cancel(t = false) {
this._onTapStop(null, !t);
}
/**
* Unbinds all events and removes the area-element.
*/
destroy() {
this.cancel(), this.disable(), this._clippingElement.remove(), super.unbindAllListeners();
}
/**
* Adds elements to the selection
* @param query - CSS Query, can be an array of queries
* @param quiet - If this should not trigger the move event
*/
select(t, n = false) {
const { changed: o, selected: i, stored: s } = this._selection, r = W(t, this._options.document).filter(
(l) => !i.includes(l) && !s.includes(l)
);
return s.push(...r), i.push(...r), o.added.push(...r), o.removed = [], this._latestElement = void 0, n || (this._emitEvent("move", null), this._emitEvent("stop", null)), r;
}
/**
* Removes a particular element from the selection.
* @param query - CSS Query, can be an array of queries
* @param quiet - If this should not trigger the move event
*/
deselect(t, n = false) {
const { selected: o, stored: i, changed: s } = this._selection, r = W(t, this._options.document).filter(
(l) => o.includes(l) || i.includes(l)
);
r.length && (this._selection.stored = i.filter((l) => !r.includes(l)), this._selection.selected = o.filter((l) => !r.includes(l)), this._selection.changed.added = [], this._selection.changed.removed.push(
...r.filter((l) => !s.removed.includes(l))
), this._latestElement = void 0, n || (this._emitEvent("move", null), this._emitEvent("stop", null)));
}
};
E(ze, "version", "3.3.1");
function Ot(e) {
const t = new ze({
selectables: [".map-container me-tpc"],
boundaries: [e.container],
container: "body",
behaviour: {
// Scroll configuration.
scrolling: {
// On scrollable areas the number on px per frame is devided by this amount.
// Default is 10 to provide a enjoyable scroll experience.
speedDivider: 10,
// Browsers handle mouse-wheel events differently, this number will be used as
// numerator to calculate the mount of px while scrolling manually: manualScrollSpeed / scrollSpeedDivider.
manualSpeed: 750,
// This property defines the virtual inset margins from the borders of the container
// component that, when crossed by the mouse/touch, trigger the scrolling. Useful for
// fullscreen containers.
startScrollMargins: { x: 10, y: 10 }
}
}
}).on("beforestart", ({ event: n }) => {
if (n.button !== e.mouseSelectionButton || n.target.tagName === "ME-TPC" || n.target.id === "input-box" || n.target.className === "circle")
return false;
const o = t.getSelectionArea();
return o.style.background = "#4f90f22d", o.style.border = "1px solid #4f90f2", o.parentElement && (o.parentElement.style.zIndex = "9999"), true;
}).on("start", ({ event: n }) => {
!n.ctrlKey && !n.metaKey && (e.unselectNode(), e.unselectNodes(), e.unselectSummary(), e.unselectLink(), t.clearSelection(true, true));
}).on(
"move",
({
store: {
changed: { added: n, removed: o }
}
}) => {
S.moved = true;
for (const i of n)
i.classList.add("selected");
for (const i of o)
i.classList.remove("selected");
}
).on("stop", ({ store: { stored: n } }) => {
e.selectNodes(n);
});
e.selection = t;
}
var At = function(e, t = true) {
this.theme = e;
const n = this.theme.cssVar, o = Object.keys(n);
for (let i = 0; i < o.length; i++) {
const s = o[i];
this.mindElixirBox.style.setProperty(s, n[s]);
}
t && this.refresh();
};
function Re(e) {
return {
nodeData: e.isFocusMode ? e.nodeDataBackup : e.nodeData,
linkData: e.linkData,
summaries: e.summaries,
direction: e.direction,
theme: e.theme
};
}
var Pt = function(e, t, n) {
if (e) {
if (console.time("selectNode"), typeof e == "string") {
const o = N(e);
return o ? this.selectNode(o) : void 0;
}
this.currentNode && (this.currentNode.className = ""), e.className = "selected", e.scrollIntoView({ block: "nearest", inline: "nearest" }), this.currentNode = e, t ? this.bus.fire("selectNewNode", e.nodeObj) : this.bus.fire("selectNode", e.nodeObj, n), console.timeEnd("selectNode");
}
};
var Ht = function() {
this.currentNode && (this.currentNode.className = ""), this.currentNode = null, this.bus.fire("unselectNode");
};
var Bt = function(e) {
if (e) {
console.time("selectNodes");
for (const t of e)
t.className = "selected";
this.currentNodes = e, this.bus.fire(
"selectNodes",
e.map((t) => t.nodeObj)
), console.timeEnd("selectNodes");
}
};
var zt = function() {
if (this.currentNodes)
for (const e of this.currentNodes)
e.classList.remove("selected");
this.currentNodes = null, this.bus.fire("unselectNodes");
};
var Rt = function() {
if (!this.currentNode || this.currentNode.dataset.nodeid === "meroot")
return false;
const e = this.currentNode.parentElement.parentElement.nextSibling;
let t;
if (e)
t = e.firstChild.firstChild;
else
return false;
return this.selectNode(t), true;
};
var qt = function() {
if (!this.currentNode || this.currentNode.dataset.nodeid === "meroot")
return false;
const e = this.currentNode.parentElement.parentElement.previousSibling;
let t;
if (e)
t = e.firstChild.firstChild;
else
return false;
return this.selectNode(t), true;
};
var Ft = function() {
if (!this.currentNode)
return;
const e = this.currentNode.parentElement.nextSibling;
if (e && e.firstChild) {
const t = e.firstChild.firstChild.firstChild;
this.selectNode(t);
}
};
var Vt = function() {
if (!this.currentNode || this.currentNode.dataset.nodeid === "meroot")
return;
const e = this.currentNode.parentElement.parentElement.parentElement.previousSibling;
if (e) {
const t = e.firstChild;
this.selectNode(t);
}
};
var Wt = function() {
const e = Re(this);
return JSON.stringify(e, (t, n) => {
if (!(t === "parent" && typeof n != "string"))
return n;
});
};
var It = function() {
return JSON.parse(this.getDataString());
};
var Kt = function() {
const e = Re(this).nodeData;
let t = "# " + e.topic + `
`;
function n(o, i) {
for (let s = 0; s < o.length; s++)
i <= 6 ? t += "".padStart(i, "#") + " " + o[s].topic + `
` : t += "".padStart(i - 7, " ") + "- " + o[s].topic + `
`, o[s].children && n(o[s].children || [], i + 1);
}
return n(e.children || [], 2), t;
};
var Ut = function() {
this.editable = true;
};
var Yt = function() {
this.editable = false;
};
var Gt = function(e) {
this.scaleVal = e, this.map.style.transform = "scale(" + e + ")";
};
var Xt = function() {
this.container.scrollTo(1e4 - this.container.offsetWidth / 2, 1e4 - this.container.offsetHeight / 2);
};
var Jt = function(e) {
e(this);
};
var Qt = function(e) {
e.nodeObj.root || (this.tempDirection === null && (this.tempDirection = this.direction), this.isFocusMode || (this.nodeDataBackup = this.nodeData, this.isFocusMode = true), this.nodeData = e.nodeObj, this.nodeData.root = true, this.initRight(), this.toCenter());
};
var Zt = function() {
this.isFocusMode = false, this.tempDirection !== null && (delete this.nodeData.root, this.nodeData = this.nodeDataBackup, this.direction = this.tempDirection, this.tempDirection = null, this.refresh(), this.toCenter());
};
var en = function() {
this.direction = 0, this.refresh();
};
var tn = function() {
this.direction = 1, this.refresh();
};
var nn = function() {
this.direction = 2, this.refresh();
};
var on = function(e) {
this.locale = e, this.refresh();
};
var sn = function(e, t) {
const n = e.nodeObj;
typeof t == "boolean" ? n.expanded = t : n.expanded !== false ? n.expanded = false : n.expanded = true, this.layout(), this.linkDiv(), this.bus.fire("expandNode", n);
};
var rn = function(e) {
e && (e = JSON.parse(JSON.stringify(e)), this.nodeData = e.nodeData, this.linkData = e.linkData || {}, this.summaries = e.summaries || []), $(this.nodeData), this.layout(), this.linkDiv();
};
var ln = Object.freeze(Object.defineProperty({
__proto__: null,
cancelFocus: Zt,
disableEdit: Yt,
enableEdit: Ut,
expandNode: sn,
focusNode: Qt,
getData: It,
getDataMd: Kt,
getDataString: Wt,
initLeft: en,
initRight: tn,
initSide: nn,
install: Jt,
refresh: rn,
scale: Gt,
selectFirstChild: Ft,
selectNextSibling: Rt,
selectNode: Pt,
selectNodes: Bt,
selectParent: Vt,
selectPrevSibling: qt,
setLocale: on,
toCenter: Xt,
unselectNode: Ht,
unselectNodes: zt
}, Symbol.toStringTag, { value: "Module" }));
var A = (e) => {
var o;
const t = (o = e.parent) == null ? void 0 : o.children, n = t.indexOf(e);
return { siblings: t, index: n };
};
function cn(e) {
const { siblings: t, index: n } = A(e), o = t[n];
n === 0 ? (t[n] = t[t.length - 1], t[t.length - 1] = o) : (t[n] = t[n - 1], t[n - 1] = o);
}
function an(e) {
const { siblings: t, index: n } = A(e), o = t[n];
n === t.length - 1 ? (t[n] = t[0], t[0] = o) : (t[n] = t[n + 1], t[n + 1] = o);
}
function Q(e) {
const { siblings: t, index: n } = A(e);
return t.splice(n, 1), t.length;
}
function dn(e, t) {
const { siblings: n, index: o } = A(e);
n.splice(o + 1, 0, t);
}
function hn(e, t) {
const { siblings: n, index: o } = A(e);
n.splice(o, 0, t);
}
function un(e, t) {
const { siblings: n, index: o } = A(e);
n[o] = t, t.children = [e];
}
function fn(e, t) {
Q(e), t.children ? t.children.push(e) : t.children = [e];
}
function pn(e, t) {
e.direction !== void 0 && (e.direction = t.direction), Q(e);
const { siblings: n, index: o } = A(t);
n.splice(o, 0, e);
}
function mn(e, t) {
e.direction !== void 0 && (e.direction = t.direction), Q(e);
const { siblings: n, index: o } = A(t);
n.splice(o + 1, 0, e);
}
var qe = function(e, t) {
var n, o;
if (e === L)
return L;
if (e === z)
return z;
if (e === X) {
const i = ((n = document.querySelector(".lhs")) == null ? void 0 : n.childElementCount) || 0, s = ((o = document.querySelector(".rhs")) == null ? void 0 : o.childElementCount) || 0;
return i <= s ? (t.direction = L, L) : (t.direction = z, z);
}
};
var Fe = function(e, t) {
var l, c;
if (!e)
return null;
const n = e.nodeObj;
n.expanded === false && (this.expandNode(e, true), e = N(n.id));
const o = t || this.generateNewObj();
n.children ? n.children.push(o) : n.children = [o], $(this.nodeData);
const i = e.parentElement, { grp: s, top: r } = this.createWrapper(o);
if (i.tagName === "ME-PARENT") {
if (i.children[1])
i.nextSibling.appendChild(s);
else {
const h = this.createChildren([s]);
i.appendChild(re(true)), i.insertAdjacentElement("afterend", h);
}
this.linkDiv(s.offsetParent);
} else
i.tagName === "ME-ROOT" && (qe(this.direction, o) === L ? (l = document.querySelector(".lhs")) == null || l.appendChild(s) : (c = document.querySelector(".rhs")) == null || c.appendChild(s), this.linkDiv());
return { newTop: r, newNodeObj: o };
};
var Ve = function(e, t) {
const n = e.parentNode;
if (t === 0) {
const o = n.parentNode.parentNode;
o.tagName !== "ME-MAIN" && o.previousSibling.children[1].remove();
}
n.parentNode.remove();
};
var le = function(e) {
const n = e.parentElement.parentElement.lastElementChild;
(n == null ? void 0 : n.tagName) === "svg" && (n == null || n.remove());
};
var gn = function(e, t) {
console.log(t);
const n = e.nodeObj, o = De(n);
o.style && t.style && (t.style = Object.assign(o.style, t.style));
const i = Object.assign(n, t);
ue(e, i), this.linkDiv(), this.bus.fire("operation", {
name: "reshapeNode",
obj: i,
origin: o
});
};
var vn = function(e, t) {
var h, a, u;
const n = e || this.currentNode;
if (!n)
return;
const o = n.nodeObj;
if (o.root === true) {
this.addChild();
return;
} else if (((h = o.parent) == null ? void 0 : h.root) === true && ((u = (a = o.parent) == null ? void 0 : a.children) == null ? void 0 : u.length) === 1) {
this.addChild(N(o.parent.id));
return;
}
const i = t || this.generateNewObj();
dn(o, i), $(this.nodeData);
const s = n.parentElement;
console.time("insertSibling_DOM");
const { grp: r, top: l } = this.createWrapper(i);
s.parentNode.parentNode.insertBefore(r, s.parentNode.nextSibling), this.linkDiv(r.offsetParent), t || this.editTopic(l.firstChild), this.selectNode(l.firstChild, true), console.timeEnd("insertSibling_DOM"), this.bus.fire("operation", {
name: "insertSibling",
obj: i
});
};
var bn = function(e, t) {
const n = e || this.currentNode;
if (!n)
return;
const o = n.nodeObj;
if (o.root === true) {
this.addChild();
return;
}
const i = t || this.generateNewObj();
hn(o, i), $(this.nodeData);
const s = n.parentElement;
console.time("insertSibling_DOM");
const { grp: r, top: l } = this.createWrapper(i);
s.parentNode.parentNode.insertBefore(r, s.parentNode), this.linkDiv(r.offsetParent), t || this.editTopic(l.firstChild), this.selectNode(l.firstChild, true), console.timeEnd("insertSibling_DOM"), this.bus.fire("operation", {
name: "insertBefore",
obj: i
});
};
var yn = function(e, t) {
const n = e || this.currentNode;
if (!n)
return;
le(n);
const o = n.nodeObj;
if (o.root === true)
return;
const i = t || this.generateNewObj();
un(o, i), $(this.nodeData);
const s = n.parentElement.parentElement;
console.time("insertParent_DOM");
const { grp: r, top: l } = this.createWrapper(i, true);
l.appendChild(re(true)), s.insertAdjacentElement("afterend", r);
const c = this.createChildren([s]);
l.insertAdjacentElement("afterend", c), this.linkDiv(), t || this.editTopic(l.firstChild), this.selectNode(l.firstChild, true), console.timeEnd("insertParent_DOM"), this.bus.fire("operation", {
name: "insertParent",
obj: i
});
};
var xn = function(e, t) {
console.time("addChild");
const n = e || this.currentNode;
if (!n)
return;
const o = Fe.call(this, n, t);
if (!o)
return;
const { newTop: i, newNodeObj: s } = o;
this.bus.fire("operation", {
name: "addChild",
obj: s
}), console.timeEnd("addChild"), t || this.editTopic(i.firstChild), this.selectNode(i.firstChild, true);
};
var wn = function(e, t) {
console.time("copyNode");
const n = De(e.nodeObj);
Te(n);
const o = Fe.call(this, t, n);
if (!o)
return;
const { newNodeObj: i } = o;
console.timeEnd("copyNode"), this.bus.fire("operation", {
name: "copyNode",
obj: i
});
};
var En = function(e) {
const t = e || this.currentNode;
if (!t)
return;
const n = t.nodeObj;
cn(n);
const o = t.parentNode.parentNode;
o.parentNode.insertBefore(o, o.previousSibling), this.linkDiv(), this.bus.fire("operation", {
name: "moveUpNode",
obj: n
});
};
var Nn = function(e) {
const t = e || this.currentNode;
if (!t)
return;
const n = t.nodeObj;
an(n);
const o = t.parentNode.parentNode;
o.nextSibling ? o.nextSibling.insertAdjacentElement("afterend", o) : o.parentNode.prepend(o), this.linkDiv(), this.bus.fire("operation", {
name: "moveDownNode",
obj: n
});
};
var Cn = function(e) {
var r;
const t = e || this.currentNode;
if (!t)
return;
const n = t.nodeObj;
if (n.root === true)
throw new Error("Can not remove root node");
const o = n.parent.children, i = o.findIndex((l) => l === n), s = Q(n);
if (Ve(t, s), o.length !== 0) {
const l = o[i] || o[i - 1];
this.selectNode(N(l.id));
} else
this.selectNode(N(n.parent.id));
this.linkDiv(), this.bus.fire("operation", {
name: "removeNode",
obj: n,
originIndex: i,
originParentId: (r = n == null ? void 0 : n.parent) == null ? void 0 : r.id
});
};
var _n = function(e) {
for (const t of e) {
const n = t.nodeObj;
if (n.root === true)
continue;
const o = Q(n);
Ve(t, o);
}
this.linkDiv(), this.bus.fire("operation", {
name: "removeNodes",
objs: e.map((t) => t.nodeObj)
});
};
var kn = function(e, t) {
var l;
const n = e.nodeObj, o = t.nodeObj, i = (l = n == null ? void 0 : n.parent) == null ? void 0 : l.id;
if (o.expanded === false && (this.expandNode(t, true), e = N(n.id), t = N(o.id)), !Je(n, o)) {
console.warn("Invalid move");
return;
}
console.time("moveNode"), fn(n, o), $(this.nodeData);
const s = e.parentElement, r = t.parentElement;
if (r.tagName === "ME-PARENT")
if (le(e), r.children[1])
r.nextSibling.appendChild(s.parentElement);
else {
const c = this.createChildren([s.parentElement]);
r.appendChild(re(true)), r.parentElement.insertBefore(c, r.nextSibling);
}
else
r.tagName === "ME-ROOT" && (qe(this.direction, n), r.nextSibling.appendChild(s.parentElement));
this.linkDiv(), this.bus.fire("operation", {
name: "moveNode",
obj: n,
toObj: o,
originParentId: i
}), console.timeEnd("moveNode");
};
var Sn = function(e, t) {
var l;
const n = e.nodeObj, o = t.nodeObj, i = (l = n.parent) == null ? void 0 : l.id;
pn(n, o), $(this.nodeData), le(e);
const s = e.parentElement.parentNode;
t.parentElement.parentNode.insertAdjacentElement("beforebegin", s), this.linkDiv(), this.bus.fire("operation", {
name: "moveNodeBefore",
obj: n,
toObj: o,
originParentId: i
});
};
var Ln = function(e, t) {
var l;
const n = e.nodeObj, o = t.nodeObj, i = (l = n.parent) == null ? void 0 : l.id;
mn(n, o), $(this.nodeData), le(e);
const s = e.parentElement.parentNode;
t.parentElement.parentNode.insertAdjacentElement("afterend", s), this.linkDiv(), this.bus.fire("operation", {
name: "moveNodeAfter",
obj: n,
toObj: o,
originParentId: i
});
};
var Mn = function(e) {
const t = e || this.currentNode;
t && this.editTopic(t);
};
var Tn = function(e, t) {
e.text.textContent = t, e.nodeObj.topic = t, this.linkDiv();
};
var We = Object.freeze(Object.defineProperty({
__proto__: null,
addChild: xn,
beginEdit: Mn,
copyNode: wn,
insertBefore: bn,
insertParent: yn,
insertSibling: vn,
moveDownNode: Nn,
moveNode: kn,
moveNodeAfter: Ln,
moveNodeBefore: Sn,
moveUpNode: En,
removeNode: Cn,
removeNodes: _n,
reshapeNode: gn,
setNodeTopic: Tn
}, Symbol.toStringTag, { value: "Module" }));
var $n = function(e) {
return {
dom: e,
moved: false,
// diffrentiate click and move
mousedown: false,
handleMouseMove(t) {
this.mousedown && (this.moved = true, this.cb && this.cb(t.movementX, t.movementY));
},
handleMouseDown(t) {
t.button === 0 && (this.mousedown = true);
},
handleClear(t) {
this.mousedown = false;
},
cb: null,
init(t, n) {
this.cb = n, this.handleClear = this.handleClear.bind(this), this.handleMouseMove = this.handleMouseMove.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), t.addEventListener("mousemove", this.handleMouseMove), t.addEventListener("mouseleave", this.handleClear), t.addEventListener("mouseup", this.handleClear), this.dom.addEventListener("mousedown", this.handleMouseDown);
},
destory(t) {
t.removeEventListener("mousemove", this.handleMouseMove), t.removeEventListener("mouseleave", this.handleClear), t.removeEventListener("mouseup", this.handleClear), this.dom.removeEventListener("mousedown", this.handleMouseDown);
},
clear() {
this.moved = false, this.mousedown = false;
}
};
};
var Ce = {
create: $n
};
function se(e, t, n) {
const { offsetLeft: o, offsetTop: i } = K(e.nodes, t), s = t.offsetWidth, r = t.offsetHeight, l = o + s / 2, c = i + r / 2, h = l + n.x, a = c + n.y;
return {
w: s,
h: r,
cx: l,
cy: c,
ctrlX: h,
ctrlY: a
};
}
function I(e) {
let t, n;
const o = (e.cy - e.ctrlY) / (e.ctrlX - e.cx);
return o > e.h / e.w || o < -e.h / e.w ? e.cy - e.ctrlY < 0 ? (t = e.cx - e.h / 2 / o, n = e.cy + e.h / 2) : (t = e.cx + e.h / 2 / o, n = e.cy - e.h / 2) : e.cx - e.ctrlX < 0 ? (t = e.cx + e.w / 2, n = e.cy - e.w * o / 2) : (t = e.cx - e.w / 2, n = e.cy + e.w * o / 2), {
x: t,
y: n
};
}
var Dn = function(e, t, n, o) {
const i = document.createElementNS("http://www.w3.org/2000/svg", "text");
return C(i, {
"text-anchor": "middle",
x: t + "",
y: n + "",
fill: o || "#666"
}), i.dataset.type = "custom-link", i.innerHTML = e, i;
};
var jn = function(e, t, n, o) {
if (!e || !t)
return;
const i = performance.now(), s = se(this, e, n.delta1), r = se(this, t, n.delta2), { x: l, y: c } = I(s), { ctrlX: h, ctrlY: a } = s, { ctrlX: u, ctrlY: d } = r, { x: p, y: g } = I(r), m = $e(u, d, p, g), f = dt(
`M ${l} ${c} C ${h} ${a} ${u} ${d} ${p} ${g}`,
`M ${m.x1} ${m.y1} L ${p} ${g} L ${m.x2} ${m.y2}`
), v = l / 8 + h * 3 / 8 + u * 3 / 8 + p / 8, y = c / 8 + a * 3 / 8 + d * 3 / 8 + g / 8, b = Dn(n.label, v, y, this.theme.cssVar["--color"]);
f.appendChild(b), f.linkObj = n, f.dataset.linkid = n.id, this.linkSvgGroup.appendChild(f), o || (this.linkData[n.id] = n, this.currentLink = f, this.showLinkController(n, s, r));
const x = performance.now();
console.log(`DrawCustomLink Execution time: ${x - i} ms`);
};
var On = function(e, t) {
const n = {
id: J(),
label: "Custom Link",
from: e.nodeObj.id,
to: t.nodeObj.id,
delta1: {
x: 0,
y: -200
},
delta2: {
x: 0,
y: -200
}
};
this.drawCustomLink(e, t, n), this.bus.fire("operation", {
name: "createCustomLink",
obj: n
});
};
var An = function(e) {
let t;
if (e ? t = e : t = this.currentLink, !t)
return;
this.hideLinkController();
const n = t.linkObj.id;
delete this.linkData[n], t.remove(), this.bus.fire("operation", {
name: "removeCustomLink",
obj: {
id: n
}
});
};
var Pn = function(e) {
this.currentLink = e;
const t = e.linkObj, n = N(t.from), o = N(t.to), i = se(this, n, t.delta1), s = se(this, o, t.delta2);
this.showLinkController(t, i, s);
};
var Hn = function() {
this.currentLink = null, this.hideLinkController();
};
var Bn = function() {
this.linkController.style.display = "none", this.P2.style.display = "none", this.P3.style.display = "none";
};
var zn = function(e, t, n) {
var u;
this.linkController.style.display = "initial", this.P2.style.display = "initial", this.P3.style.display = "initial", this.nodes.appendChild(this.linkController), this.nodes.appendChild(this.P2), this.nodes.appendChild(this.P3);
let { x: o, y: i } = I(t), { ctrlX: s, ctrlY: r } = t, { ctrlX: l, ctrlY: c } = n, { x: h, y: a } = I(n);
this.P2.style.cssText = `top:${r}px;left:${s}px;`, this.P3.style.cssText = `top:${c}px;left:${l}px;`, C(this.line1, {
x1: o + "",
y1: i + "",
x2: s + "",
y2: r + ""
}), C(this.line2, {
x1: l + "",
y1: c + "",
x2: h + "",
y2: a + ""
}), this.helper1 && (this.helper1.destory(this.map), (u = this.helper2) == null || u.destory(this.map)), this.helper1 = Ce.create(this.P2), this.helper2 = Ce.create(this.P3), this.helper1.init(this.map, (d, p) => {
var v;
s = s + d / this.scaleVal, r = r + p / this.scaleVal;
const g = I({ ...t, ctrlX: s, ctrlY: r });
o = g.x, i = g.y;
const m = o / 8 + s * 3 / 8 + l * 3 / 8 + h / 8, f = i / 8 + r * 3 / 8 + c * 3 / 8 + a / 8;
this.P2.style.top = r + "px", this.P2.style.left = s + "px", (v = this.currentLink) == null || v.children[0].setAttribute("d", `M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`), C(this.currentLink.children[2], {
x: m + "",
y: f + ""
}), C(this.line1, {
x1: o + "",
y1: i + "",
x2: s + "",
y2: r + ""
}), e.delta1.x = s - t.cx, e.delta1.y = r - t.cy;
}), this.helper2.init(this.map, (d, p) => {
var y, b;
l = l + d / this.scaleVal, c = c + p / this.scaleVal;
const g = I({ ...n, ctrlX: l, ctrlY: c });
h = g.x, a = g.y;
const m = o / 8 + s * 3 / 8 + l * 3 / 8 + h / 8, f = i / 8 + r * 3 / 8 + c * 3 / 8 + a / 8, v = $e(l, c, h, a);
this.P3.style.top = c + "px", this.P3.style.left = l + "px", (y = this.currentLink) == null || y.children[0].setAttribute("d", `M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`), (b = this.currentLink) == null || b.children[1].setAttribute("d", `M ${v.x1} ${v.y1} L ${h} ${a} L ${v.x2} ${v.y2}`), C(this.currentLink.children[2], {
x: m + "",
y: f + ""
}), C(this.line2, {
x1: l + "",
y1: c + "",
x2: h + "",
y2: a + ""
}), e.delta2.x = l - n.cx, e.delta2.y = c - n.cy;
});
};
function Rn() {
this.linkSvgGroup.innerHTML = "";
for (const e in this.linkData) {
const t = this.linkData[e];
try {
this.drawCustomLink(N(t.from), N(t.to), t, true);
} catch {
console.warn("Node may not be expanded");
}
}
this.nodes.appendChild(this.linkSvgGroup);
}
function qn(e) {
if (console.time("editSummary"), !e)
return;
const t = e.children[2];
console.log(t, e), Oe(this, t, (n) => {
var s;
const o = e.linkObj, i = ((s = n.textContent) == null ? void 0 : s.trim()) || "";
i === "" ? o.label = origin : o.label = i, n.remove(), i !== origin && (t.innerHTML = o.label, this.linkDiv(), this.bus.fire("operation", {
name: "finishEditCustomLinkLabel",
obj: o
}));
}), console.timeEnd("editSummary");
}
function Fn() {
for (const e in this.linkData) {
const t = this.linkData[e];
(!oe(t.from, this.nodeData) || !oe(t.to, this.nodeData)) && delete this.linkData[t.id];
}
}
var Vn = Object.freeze(Object.defineProperty({
__proto__: null,
createLink: On,
drawCustomLink: jn,
editCutsomLinkLabel: qn,
hideLinkController: Bn,
removeLink: An,
renderCustomLink: Rn,
selectLink: Pn,
showLinkController: zn,
tidyCustomLink: Fn,
unselectLink: Hn
}, Symbol.toStringTag, { value: "Module" }));
var Wn = function(e) {
var c, h;
if (e.length === 0)
throw new Error("No selected node.");
if (e.length === 1) {
const a = e[0].nodeObj, u = e[0].nodeObj.parent;
if (!u)
throw new Error("Can not select root node.");
const d = u.children.findIndex((p) => a === p);
return {
parent: u.id,
start: d,
end: d
};
}
let t = 0;
const n = e.map((a) => {
let u = a.nodeObj;
const d = [];
for (; u.parent; ) {
const p = u.parent, g = p.children, m = g == null ? void 0 : g.indexOf(u);
u = p, d.unshift({ node: u, index: m });
}
return d.length > t && (t = d.length), d;
});
let o = 0;
e:
for (; o < t; o++) {
const a = (c = n[0][o]) == null ? void 0 : c.node;
for (let u = 1; u < n.length; u++)
if (((h = n[u][o]) == null ? void 0 : h.node) !== a)
break e;
}
if (!o)
throw new Error("Can not select root node.");
const i = n.map((a) => a[o - 1].index).sort(), s = i[0] || 0, r = i[i.length - 1] || 0, l = n[0][o - 1].node;
if (l.root)
throw new Error("Please select nodes in the same main topic.");
return {
parent: l.id,
start: s,
end: r
};
};
var In = function(e) {
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
return t.setAttribute("id", e), t;
};
var _e = function(e, t) {
const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
return C(n, {
d: e,
stroke: t || "#666",
fill: "none",
"stroke-linecap": "round",
"stroke-width": "2"
}), n;
};
var ke = function(e, t, n, o, i) {
const s = document.createElementNS("http://www.w3.org/2000/svg", "text");
return C(s, {
"text-anchor": o,
x: t + "",
y: n + "",
fill: i || "#666"
}), s.innerHTML = e, s;
};
var Kn = (e) => N(e).parentElement.parentElement;
var Un = function({ parent: e, start: t }) {
var s, r;
const n = N(e), o = n.nodeObj;
let i;
return o.root === true ? i = (s = N(o.children[t].id).closest("me-main")) == null ? void 0 : s.className : i = (r = n.closest("me-main")) == null ? void 0 : r.className, i;
};
var Ie = function(e, t) {
var _;
const { id: n, text: o, parent: i, start: s, end: r } = t, l = e.nodes, h = N(i).nodeObj, a = Un(t);
let u = 1 / 0, d = 0, p = 0, g = 0;
for (let P = s; P <= r; P++) {
const U = (_ = h.children) == null ? void 0 : _[P];
if (!U)
return console.warn("Child not found"), e.removeSummary(n), null;
const H = Kn(U.id), { offsetLeft: Z, offsetTop: fe } = K(l, H);
P === s && (p = fe), P === r && (g = fe + H.offsetHeight), Z < u && (u = Z), H.offsetWidth + Z > d && (d = H.offsetWidth + Z);
}
let m, f;
const v = p + 10, y = g + 10, b = (v + y) / 2, x = e.theme.cssVar["--color"];
a === "lhs" ? (m = _e(`M ${u + 10} ${v} c -5 0 -10 5 -10 10 L ${u} ${y - 10} c 0 5 5 10 10 10 M ${u} ${b} h -10`, x), f = ke(o, u - 20, b + 6, "end", x)) : (m = _e(`M ${d - 10} ${v} c 5 0 10 5 10 10 L ${d} ${y - 10} c 0 5 -5 10 -10 10 M ${d} ${b} h 10`, x), f = ke(o, d + 20, b + 6, "start", x));
const w = In("s-" + n);
return w.appendChild(m), w.appendChild(f), w.summaryObj = t, e.summarySvg.appendChild(w), w;
};
var Yn = function() {
let e = [];
this.currentNode ? e = [this.currentNode] : this.currentNodes && (e = this.currentNodes);
const { parent: t, start: n, end: o } = Wn(e), i = { id: J(), parent: t, start: n, end: o, text: "summary" }, s = Ie(this, i);
this.summaries.push(i), this.editSummary(s), this.bus.fire("operation", {
name: "createSummary",
obj: i
});
};
var Gn = function(e) {
var n;
const t = this.summaries.findIndex((o) => o.id === e);
t > -1 && (this.summaries.splice(t, 1), (n = document.querySelector("#s-" + e)) == null || n.remove()), this.bus.fire("operation", {
name: "removeSummary",
obj: { id: e }
});
};
var Xn = function(e) {
const t = e.children[1].getBBox(), n = 6, o = 3, i = document.createElementNS("http://www.w3.org/2000/svg", "rect");
C(i, {
x: t.x - n + "",
y: t.y - n + "",
width: t.width + n * 2 + "",
height: t.height + n * 2 + "",
rx: o + "",
stroke: this.theme.cssVar["--selected"] || "#4dc4ff",
"stroke-width": "2",
fill: "none"
}), i.classList.add("selected"), e.appendChild(i), this.currentSummary = e;
};
var Jn = function() {
var e, t;
(t = (e = this.currentSummary) == null ? void 0 : e.querySelector("rect")) == null || t.remove(), this.currentSummary = null;
};
var Qn = function() {
this.summarySvg.innerHTML = "", this.summaries.forEach((e) => {
try {
Ie(this, e);
} catch {
console.warn("Node may not be expanded");
}
}), this.nodes.insertAdjacentElement("beforeend", this.summarySvg);
};
var Zn = function(e) {
if (console.time("editSummary"), !e)
return;
const t = e.childNodes[1];
Oe(this, t, (n) => {
var s;
const o = e.summaryObj, i = ((s = n.textContent) == null ? void 0 : s.trim()) || "";
i === "" ? o.text = origin : o.text = i, n.remove(), i !== origin && (t.innerHTML = o.text, this.linkDiv(), this.bus.fire("operation", {
name: "finishEditSummary",
obj: o
}));
}), console.timeEnd("editSummary");
};
var eo = Object.freeze(Object.defineProperty({
__proto__: null,
createSummary: Yn,
editSummary: Zn,
removeSummary: Gn,
renderSummary: Qn,
selectSummary: Xn,
unselectSummary: Jn
}, Symbol.toStringTag, { value: "Module" }));
function to(e, t) {
const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
return C(n, {
version: "1.1",
xmlns: "http://www.w3.org/2000/svg",
height: e,
width: t
}), n;
}
function no(e, t) {
return (parseInt(e) - parseInt(t)) / 2;
}
function oo(e, t, n, o) {
const i = document.createElementNS("http://www.w3.org/2000/svg", "g");
let s = "";
return e.text ? s = e.text.textContent : s = e.childNodes[0].textContent, s.split(`
`).forEach((l, c) => {
const h = document.createElementNS("http://www.w3.org/2000/svg", "text");
C(h, {
x: n + parseInt(t.paddingLeft) + "",
y: o + parseInt(t.paddingTop) + no(t.lineHeight, t.fontSize) * (c + 1) + parseFloat(t.fontSize) * (c + 1) + "",
"text-anchor": "start",
"font-family": t.fontFamily,
"font-size": `${t.fontSize}`,
"font-weight": `${t.fontWeight}`,
fill: `${t.color}`
}), h.innerHTML = l, i.appendChild(h);
}), i;
}
function io(e, t, n, o) {
let i = "";
e.text ? i = e.text.textContent : i = e.childNodes[0].textContent;
const s = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
C(s, {
x: n + parseInt(t.paddingLeft) + "",
y: o + parseInt(t.paddingTop) + "",
width: t.width,
height: t.height
});
const r = document.createElement("div");
return C(r, {
xmlns: "http://www.w3.org/1999/xhtml",
style: `font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`
}), r.innerHTML = i, s.appendChild(r), s;
}
function ce(e, t, n = false) {
const o = getComputedStyle(t), { offsetLeft: i, offsetTop: s } = K(e.nodes, t), r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
C(r, {
x: i + "",
y: s + "",
rx: o.borderRadius,
ry: o.borderRadius,
width: o.width,
height: o.height,
fill: o.backgroundColor,
stroke: o.borderColor,
"stroke-width": o.borderWidth
});
const l = document.createElementNS("http://www.w3.org/2000/svg", "g");
l.appendChild(r);
let c;
return n ? c = io(t, o, i, s) : c = oo(t, o, i, s), l.appendChild(c), l;
}
function so(e, t) {
const n = getComputedStyle(t), { offsetLeft: o, offsetTop: i } = K(e.nodes, t), s = document.createElementNS("http://www.w3.org/2000/svg", "a"), r = document.createElementNS("http://www.w3.org/2000/svg", "text");
return C(r, {
x: o + "",
y: i + parseInt(n.fontSize) + "",
"text-anchor": "start",
"font-family": n.fontFamily,
"font-size": `${n.fontSize}`,
"font-weight": `${n.fontWeight}`,
fill: `${n.color}`
}), r.innerHTML = t.textContent, s.appendChild(r), s.setAttribute("href", t.href), s;
}
var te = 100;
var ro = '<?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">';
var Ke = (e, t = false) => {
var u, d, p;
const n = e.nodes, o = n.offsetHeight + te * 2, i = n.offsetWidth + te * 2, s = to(o + "px", i + "px"), r = document.createElementNS("http://www.w3.org/2000/svg", "svg"), l = document.createElementNS("http://www.w3.org/2000/svg", "rect");
C(l, {
x: "0",
y: "0",
width: `${i}`,
height: `${o}`,
fill: e.theme.cssVar["--bgcolor"]
}), s.appendChild(l), n.querySelectorAll(".subLines").forEach((g) => {
const m = g.cloneNode(true), { offsetLeft: f, offsetTop: v } = K(n, g.parentElement);
m.setAttribute("x", `${f}`), m.setAttribute("y", `${v}`), r.appendChild(m);
});
const c = (u = n.querySelector(".lines")) == null ? void 0 : u.cloneNode(true);
c && r.appendChild(c);
const h = (d = n.querySelector(".topiclinks")) == null ? void 0 : d.cloneNode(true);
h && r.appendChild(h);
const a = (p = n.querySelector(".summary")) == null ? void 0 : p.cloneNode(true);
return a && r.appendChild(a), n.querySelectorAll("me-tpc").forEach((g) => {
r.appendChild(ce(e, g, !t));
}), n.querySelectorAll(".tags > span").forEach((g) => {
r.appendChild(ce(e, g));
}), n.querySelectorAll(".icons > span").forEach((g) => {
r.appendChild(ce(e, g));
}), n.querySelectorAll(".hyper-link").forEach((g) => {
r.appendChild(so(e, g));
}), C(r, {
x: te + "",
y: te + "",
overflow: "visible"
}), s.appendChild(r), ro + s.outerHTML;
};
function lo(e) {
return new Promise((t, n) => {
const o = new FileReader();
o.onload = (i) => {
t(i.target.result);
}, o.onerror = (i) => {
n(i);
}, o.readAsDataURL(e);
});
}
var co = function(e = false) {
const t = Ke(this, e);
return new Blob([t], { type: "image/svg+xml" });
};
var ao = async function(e = false) {
const t = Ke(this, e), n = new Blob([t], { type: "image/svg+xml" }), o = await lo(n);
return new Promise((i, s) => {
const r = new Image();
r.setAttribute("crossOrigin", "anonymous"), r.onload = () => {
const l = document.createElement("canvas");
l.width = r.width, l.height = r.height, l.getContext("2d").drawImage(r, 0, 0), l.toBlob(i, "image/png", 1);
}, r.src = o, r.onerror = s;
});
};
var ho = Object.freeze(Object.defineProperty({
__proto__: null,
exportPng: ao,
exportSvg: co
}, Symbol.toStringTag, { value: "Module" }));
function uo(e, t) {
return async function(...n) {
const o = this.before[t];
o && !await o.apply(this, n) || e.apply(this, n);
};
}
var Se = Object.keys(We);
var Ue = {};
for (let e = 0; e < Se.length; e++) {
const t = Se[e];
Ue[t] = uo(We[t], t);
}
var fo = {
getObjById: oe,
generateNewObj: Xe,
layout: et,
linkDiv: ht,
editTopic: lt,
createWrapper: ot,
createParent: it,
createChildren: st,
createTopic: rt,
findEle: N,
changeTheme: At,
...ln,
...Ue,
...Vn,
...eo,
...ho,
init(e) {
if (!e || !e.nodeData)
return new Error("MindElixir: `data` is required");
e.direction !== void 0 && (this.direction = e.direction), this.changeTheme(e.theme || this.theme, false), this.nodeData = e.nodeData, $(this.nodeData), this.linkData = e.linkData || {}, this.summaries = e.summaries || [], this.tidyCustomLink(), this.toolBar && St(this), this.keypress && bt(this), this.editable && Ot(this), Ye() && this.mobileMenu ? yt(this) : this.contextMenu && mt(this, this.contextMenuOption), this.draggable && Et(this), this.allowUndo && Ct(this), this.toCenter(), this.layout(), this.linkDiv();
}
};
var Y = document;
function D({
el: e,
direction: t,
locale: n,
draggable: o,
editable: i,
contextMenu: s,
contextMenuOption: r,
toolBar: l,
keypress: c,
mouseSelectionButton: h,
before: a,
newTopicName: u,
allowUndo: d,
mainLinkStyle: p,
subLinkStyle: g,
overflowHidden: m,
mobileMenu: f,
theme: v
}) {
console.log("ME_version " + D.version, this);
let y = null;
const b = Object.prototype.toString.call(e);
if (b === "[object HTMLDivElement]" ? y = e : b === "[object String]" && (y = document.querySelector(e)), !y)
throw new Error("MindElixir: el is not a valid element");
y.className += " mind-elixir", y.innerHTML = "", y.style.setProperty("--gap", T + "px"), this.mindElixirBox = y, this.before = a || {}, this.locale = n || "en", this.contextMenuOption = r, this.contextMenu = s === void 0 ? true : s, this.toolBar = l === void 0 ? true : l, this.keypress = c === void 0 ? true : c, this.mouseSelectionButton = h || 0, this.mobileMenu = f || false, this.direction = typeof t == "number" ? t : 1, this.draggable = o === void 0 ? true : o, this.newTopicName = u || "new node", this.editable = i === void 0 ? true : i, this.allowUndo = d === void 0 ? false : d, this.currentNode = null, this.currentLink = null, this.scaleVal = 1, this.tempDirection = null, this.mainLinkStyle = p || 0, this.subLinkStyle = g || 0, this.overflowHidden = m || false, this.bus = Ze.create(), this.container = Y.createElement("div"), this.container.className = "map-container";
const x = window.matchMedia("(prefers-color-scheme: dark)");
this.theme = v || (x.matches ? Me : Le);
const w = Y.createElement("div");
w.className = "map-canvas", this.map = w, this.map.setAttribute("tabindex", "0"), this.container.appendChild(this.map), this.mindElixirBox.appendChild(this.container), this.nodes = Y.createElement("me-nodes"), this.nodes.className = "main-node-container", this.lines = G("lines"), this.summarySvg = G("summary"), this.linkController = G("linkcontroller"), this.P2 = Y.createElement("div"), this.P3 = Y.createElement("div"), this.P2.className = this.P3.className = "circle", this.P2.style.display = this.P3.style.display = "none", this.line1 = pe(), this.line2 = pe(), this.linkController.appendChild(this.line1), this.linkController.appendChild(this.line2), this.linkSvgGroup = G("topiclinks"), this.map.appendChild(this.nodes), this.overflowHidden ? this.container.style.overflow = "hidden" : Qe(this);
}
D.prototype = fo;
D.LEFT = L;
D.RIGHT = z;
D.SIDE = X;
D.THEME = Le;
D.DARK_THEME = Me;
D.version = "3.3.2";
D.E = N;
D.new = (e) => ({
nodeData: {
id: J(),
topic: e || "new topic",
root: true,
children: []
},
linkData: {}
});
export {
D as default
};
/*! Bundled license information:
mind-elixir/dist/MindElixir.js:
(*! @viselect/vanilla v3.3.1 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla *)
*/
//# sourceMappingURL=mind-elixir.js.map