import { r as e } from "./chunk-5PVQY5BW-De02jDY6.js";
import { i as t, r as n } from "./src-CiYEh6Gu.js";
import "./chunk-K5T4RW27-CzBtr0Ks.js";
import "./chunk-7N4EOEYR-BbPw2hS_.js";
import "./chunk-67CJDMHE-PGSmTm_M.js";
import "./chunk-KGLVRYIC-CbMfGKJX.js";
import "./chunk-FOC6F5B3-DpuZaDQS.js";
import "./chunk-AA7GKIK3-CKwz6-T8.js";
import "./chunk-2KRD3SAO-DKnKXPSd.js";
import "./chunk-ORNJ4GCN-CKmTk0BP.js";
import "./chunk-LIHQZDEY-C7OIL7L5.js";
import "./chunk-CIAEETIT-O0r6nuB9.js";
import { B as r, C as i, V as a, W as o, _ as s, a as c, c as l, d as u, v as d, y as f } from "./chunk-ICPOFSXX-BGDNDwyb.js";
import { t as p } from "./chunk-426QAEUC-Bz08yDpF.js";
import "./dist-6KEP7Sv7.js";
import { t as m } from "./chunk-4BX2VUAB-YOQntefC.js";
import { t as h } from "./mermaid-parser.core-BHMInq3c.js";
import { t as g } from "./chunk-QZHKN3VN-U60-lvk-.js";
//#region ../../node_modules/.pnpm/mermaid@11.14.0/node_modules/mermaid/dist/chunks/mermaid.core/diagram-5BDNPKRD.mjs
var _ = new g(() => ({
	cnt: 1,
	stack: [{
		id: 0,
		level: -1,
		name: "/",
		children: []
	}]
})), v = /* @__PURE__ */ n(() => {
	_.reset(), c();
}, "clear"), y = /* @__PURE__ */ n(() => _.records.stack[0], "getRoot"), b = /* @__PURE__ */ n(() => _.records.cnt, "getCount"), x = u.treeView, S = {
	clear: v,
	addNode: /* @__PURE__ */ n((e, t) => {
		for (; e <= _.records.stack[_.records.stack.length - 1].level;) _.records.stack.pop();
		let n = {
			id: _.records.cnt++,
			level: e,
			name: t,
			children: []
		};
		_.records.stack[_.records.stack.length - 1].children.push(n), _.records.stack.push(n);
	}, "addNode"),
	getRoot: y,
	getCount: b,
	getConfig: /* @__PURE__ */ n(() => e(x, f().treeView), "getConfig"),
	getAccTitle: d,
	getAccDescription: s,
	getDiagramTitle: i,
	setAccDescription: r,
	setAccTitle: a,
	setDiagramTitle: o
}, C = /* @__PURE__ */ n((e) => {
	m(e, S), e.nodes.map((e) => S.addNode(e.indent ? parseInt(e.indent) : 0, e.name));
}, "populate"), w = { parse: /* @__PURE__ */ n(async (e) => {
	let n = await h("treeView", e);
	t.debug(n), C(n);
}, "parse") }, T = /* @__PURE__ */ n((e, t, n, r, i) => {
	let a = r.append("text").text(n.name).attr("dominant-baseline", "middle").attr("class", "treeView-node-label"), { height: o, width: s } = a.node().getBBox(), c = o + i.paddingY * 2, l = s + i.paddingX * 2;
	a.attr("x", e + i.paddingX), a.attr("y", t + c / 2), n.BBox = {
		x: e,
		y: t,
		width: l,
		height: c
	};
}, "positionLabel"), E = /* @__PURE__ */ n((e, t, n, r, i, a) => e.append("line").attr("x1", t).attr("y1", n).attr("x2", r).attr("y2", i).attr("stroke-width", a).attr("class", "treeView-node-line"), "positionLine"), D = /* @__PURE__ */ n((e, t, r) => {
	let i = 0, a = 0, o = /* @__PURE__ */ n((e, t, n, r) => {
		let o = r * (n.rowIndent + n.paddingX);
		T(o, i, t, e, n);
		let { height: s, width: c } = t.BBox;
		E(e, o - n.rowIndent, i + s / 2, o, i + s / 2, n.lineThickness), a = Math.max(a, o + c), i += s;
	}, "drawNode"), s = /* @__PURE__ */ n((t, n = 0) => {
		o(e, t, r, n), t.children.forEach((e) => {
			s(e, n + 1);
		});
		let { x: i, y: a, height: c } = t.BBox;
		if (t.children.length) {
			let { y: n, height: o } = t.children[t.children.length - 1].BBox;
			E(e, i + r.paddingX, a + c, i + r.paddingX, n + o / 2 + r.lineThickness / 2, r.lineThickness);
		}
	}, "processNode");
	return s(t), {
		totalHeight: i,
		totalWidth: a
	};
}, "drawTree"), O = { draw: /* @__PURE__ */ n((e, n, r, i) => {
	t.debug("Rendering treeView diagram\n" + e);
	let a = i.db, o = a.getRoot(), s = a.getConfig(), c = p(n), u = c.append("g");
	u.attr("class", "tree-view");
	let { totalHeight: d, totalWidth: f } = D(u, o, s);
	c.attr("viewBox", `-${s.lineThickness / 2} 0 ${f} ${d}`), l(c, d, f, s.useMaxWidth);
}, "draw") }, k = {
	labelFontSize: "16px",
	labelColor: "black",
	lineColor: "black"
}, A = {
	db: S,
	renderer: O,
	parser: w,
	styles: /* @__PURE__ */ n(({ treeView: t }) => {
		let { labelFontSize: n, labelColor: r, lineColor: i } = e(k, t);
		return `
    .treeView-node-label {
        font-size: ${n};
        fill: ${r};
    }
    .treeView-node-line {
        stroke: ${i};
    }
    `;
	}, "styles")
};
//#endregion
export { A as diagram };
