import forEach_default from "../../../../lodash-es/forEach.js";
import size_default from "../../../../lodash-es/size.js";
topsort.CycleException = CycleException;
function topsort(r) {
	var i = {}, a = {}, o = [];
	function s(n) {
		if (Object.prototype.hasOwnProperty.call(a, n)) throw new CycleException();
		Object.prototype.hasOwnProperty.call(i, n) || (a[n] = !0, i[n] = !0, forEach_default(r.predecessors(n), s), delete a[n], o.push(n));
	}
	if (forEach_default(r.sinks(), s), size_default(i) !== r.nodeCount()) throw new CycleException();
	return o;
}
function CycleException() {}
CycleException.prototype = /* @__PURE__ */ Error();
export { topsort };
