import e from "../../../lodash-es/now.js";
import t from "../../../lodash-es/forEach.js";
import n from "../../../lodash-es/map.js";
import r from "../../../lodash-es/has.js";
import i from "../../../lodash-es/isUndefined.js";
import a from "../../../lodash-es/max.js";
import o from "../../../lodash-es/min.js";
import s from "../../../lodash-es/range.js";
import c from "../../../lodash-es/uniqueId.js";
import { Graph as l } from "../graphlib/graph.js";
import "../graphlib/index.js";
//#region ../../node_modules/dagre-d3-es/src/dagre/util.js
function u(e, t, n, r) {
	var i;
	do
		i = c(r);
	while (e.hasNode(i));
	return n.dummy = t, e.setNode(i, n), i;
}
function d(e) {
	var n = new l().setGraph(e.graph());
	return t(e.nodes(), function(t) {
		n.setNode(t, e.node(t));
	}), t(e.edges(), function(t) {
		var r = n.edge(t.v, t.w) || {
			weight: 0,
			minlen: 1
		}, i = e.edge(t);
		n.setEdge(t.v, t.w, {
			weight: r.weight + i.weight,
			minlen: Math.max(r.minlen, i.minlen)
		});
	}), n;
}
function f(e) {
	var n = new l({ multigraph: e.isMultigraph() }).setGraph(e.graph());
	return t(e.nodes(), function(t) {
		e.children(t).length || n.setNode(t, e.node(t));
	}), t(e.edges(), function(t) {
		n.setEdge(t, e.edge(t));
	}), n;
}
function p(e, t) {
	var n = e.x, r = e.y, i = t.x - n, a = t.y - r, o = e.width / 2, s = e.height / 2;
	if (!i && !a) throw Error("Not possible to find intersection inside of the rectangle");
	var c, l;
	return Math.abs(a) * o > Math.abs(i) * s ? (a < 0 && (s = -s), c = s * i / a, l = s) : (i < 0 && (o = -o), c = o, l = o * a / i), {
		x: n + c,
		y: r + l
	};
}
function m(e) {
	var r = n(s(v(e) + 1), function() {
		return [];
	});
	return t(e.nodes(), function(t) {
		var n = e.node(t), a = n.rank;
		i(a) || (r[a][n.order] = t);
	}), r;
}
function h(e) {
	var i = o(n(e.nodes(), function(t) {
		return e.node(t).rank;
	}));
	t(e.nodes(), function(t) {
		var n = e.node(t);
		r(n, "rank") && (n.rank -= i);
	});
}
function g(e) {
	var r = o(n(e.nodes(), function(t) {
		return e.node(t).rank;
	})), a = [];
	t(e.nodes(), function(t) {
		var n = e.node(t).rank - r;
		a[n] || (a[n] = []), a[n].push(t);
	});
	var s = 0, c = e.graph().nodeRankFactor;
	t(a, function(n, r) {
		i(n) && r % c !== 0 ? --s : s && t(n, function(t) {
			e.node(t).rank += s;
		});
	});
}
function _(e, t, n, r) {
	var i = {
		width: 0,
		height: 0
	};
	return arguments.length >= 4 && (i.rank = n, i.order = r), u(e, "border", i, t);
}
function v(e) {
	return a(n(e.nodes(), function(t) {
		var n = e.node(t).rank;
		if (!i(n)) return n;
	}));
}
function y(e, n) {
	var r = {
		lhs: [],
		rhs: []
	};
	return t(e, function(e) {
		n(e) ? r.lhs.push(e) : r.rhs.push(e);
	}), r;
}
function b(t, n) {
	var r = e();
	try {
		return n();
	} finally {
		console.log(t + " time: " + (e() - r) + "ms");
	}
}
function x(e, t) {
	return t();
}
//#endregion
export { _ as addBorderNode, u as addDummyNode, f as asNonCompoundGraph, m as buildLayerMatrix, p as intersectRect, v as maxRank, h as normalizeRanks, x as notime, y as partition, g as removeEmptyRanks, d as simplify, b as time };

//# sourceMappingURL=util.js.map