// render mermaid diagrams (emitted as
SOURCE
).
// render(id, src) is used directly and each block is processed once.
(function () {
var inited = false;
var seq = 0;
function boot() {
if (typeof mermaid === "undefined") return;
if (!inited) {
mermaid.initialize({ startOnLoad: false, theme: "dark", securityLevel: "loose" });
inited = true;
}
document.querySelectorAll("div.mermaid").forEach(function (el) {
if (el.dataset.mmdDone) return;
var src = el.textContent.trim();
if (!src) return;
el.dataset.mmdDone = "1";
mermaid.render("mmd-" + seq++, src).then(function (out) {
el.innerHTML = out.svg;
}).catch(function () {
delete el.dataset.mmdDone;
});
});
}
if (window.document$ && typeof window.document$.subscribe === "function") {
window.document$.subscribe(boot);
} else {
document.addEventListener("DOMContentLoaded", boot);
}
})();