import e from "../../../lodash-es/forEach.js";
import t from "../../../lodash-es/uniqueId.js";
import { greedyFAS as n } from "./greedy-fas.js";
//#region ../../node_modules/dagre-d3-es/src/dagre/acyclic.js
function r(r) {
	e(r.graph().acyclicer === "greedy" ? n(r, a(r)) : i(r), function(e) {
		var n = r.edge(e);
		r.removeEdge(e), n.forwardName = e.name, n.reversed = !0, r.setEdge(e.w, e.v, n, t("rev"));
	});
	function a(e) {
		return function(t) {
			return e.edge(t).weight;
		};
	}
}
function i(t) {
	var n = [], r = {}, i = {};
	function a(o) {
		Object.prototype.hasOwnProperty.call(i, o) || (i[o] = !0, r[o] = !0, e(t.outEdges(o), function(e) {
			Object.prototype.hasOwnProperty.call(r, e.w) ? n.push(e) : a(e.w);
		}), delete r[o]);
	}
	return e(t.nodes(), a), n;
}
function a(t) {
	e(t.edges(), function(e) {
		var n = t.edge(e);
		if (n.reversed) {
			t.removeEdge(e);
			var r = n.forwardName;
			delete n.reversed, delete n.forwardName, t.setEdge(e.w, e.v, n, r);
		}
	});
}
//#endregion
export { r as run, a as undo };
