Files
discord-decomp/_bundle/DepGraph.js
T
2026-11-01 12:12:55 +02:00

283 lines
7.3 KiB
JavaScript

// Metro module 656 (f657).
function $mk66844($env) {
return function DFS(a0) {
let length;
const r7 = $env;
r7[5][a0] = true;
r7[4].push(a0);
r7[7][a0] = true;
let r25 = r7[0];
const r4 = 0 < r25[a0].length;
let r0 = 0;
if (r4) {
do {
const r11 = r7[0];
const r12 = r11[a0][r0];
const r30 = r7[5][r12];
const r1 = r0;
if (r30) {
if (r7[7][r12]) {
const cyclePath = r7[4];
cyclePath.push(r12);
if (!r7[3]) {
const r14 = $env.$parent[1];
const r18 = Object.create(r14.prototype);
const error = new Error("Dependency Cycle Found: " + cyclePath.join(" -> "));
error.cyclePath = cyclePath;
Object.setPrototypeOf(error, Object.getPrototypeOf(r18));
if (Error.captureStackTrace) {
Error.captureStackTrace(error, r14);
}
throw error;
}
}
} else {
(0, r7[8])(r12);
}
r0 = r1 + 1;
length = r11[a0].length;
r25 = r11;
} while (r0 < length);
}
r7[4].pop();
delete r7[7][a0];
if (!(r7[1] && r25[a0].length !== 0 || r7[6][a0])) {
r7[2].push(a0);
r7[6][a0] = true;
}
};
}
let DepGraph, c578_1;
let env578 = {};
const DepGraph2 = function DepGraph(a0) {
this.nodes = {};
this.outgoingEdges = {};
this.incomingEdges = {};
this.circular = a0 ? !!a0.circular : a0;
};
export { DepGraph2 as DepGraph };
DepGraph = DepGraph2;
DepGraph2.prototype = {
size: function size() {
return Object.keys(this.nodes).length;
},
addNode: function addNode(a0, a1) {
if (!this.hasNode(a0)) {
this.nodes[a0] = arguments.length === 2 ? a1 : a0;
this.outgoingEdges[a0] = [];
this.incomingEdges[a0] = [];
}
},
removeNode: function removeNode(a0) {
let c12431_0 = a0;
if (this.hasNode(a0)) {
delete this.nodes[a0];
delete this.outgoingEdges[a0];
delete this.incomingEdges[a0];
[this.incomingEdges, this.outgoingEdges].forEach(function(a0) {
Object.keys(a0).forEach(function(item) {
const r9 = a0[item].indexOf(c12431_0);
if (r9 >= 0) {
a0[item].splice(r9, 1);
}
}, this);
});
}
},
hasNode: function hasNode(a0) {
return this.nodes.hasOwnProperty(a0);
},
getNodeData: function getNodeData(a0) {
if (this.hasNode(a0)) {
return this.nodes[a0];
}
throw new Error("Node does not exist: " + a0);
},
setNodeData: function setNodeData(a0, a1) {
if (this.hasNode(a0)) {
this.nodes[a0] = a1;
return void 0;
}
throw new Error("Node does not exist: " + a0);
},
addDependency: function addDependency(a0, a1) {
if (this.hasNode(a0)) {
if (this.hasNode(a1)) {
if (this.outgoingEdges[a0].indexOf(a1) === -1) {
this.outgoingEdges[a0].push(a1);
}
if (this.incomingEdges[a1].indexOf(a0) === -1) {
this.incomingEdges[a1].push(a0);
}
return true;
}
throw new Error("Node does not exist: " + a1);
}
throw new Error("Node does not exist: " + a0);
},
removeDependency: function removeDependency(a0, a1) {
let r6 = this.hasNode(a0);
let r10 = void 0;
if (r6) {
const r12 = this.outgoingEdges[a0].indexOf(a1);
r6 = r12 >= 0;
r10 = r12;
}
if (r6) {
this.outgoingEdges[a0].splice(r10, 1);
}
let r19 = this.hasNode(a1);
if (r19) {
const r23 = this.incomingEdges[a1].indexOf(a0);
r19 = r23 >= 0;
r10 = r23;
}
if (r19) {
this.incomingEdges[a1].splice(r10, 1);
}
},
clone: function clone() {
const _this = this;
const r7 = Object.create(DepGraph.prototype);
r7.nodes = {};
r7.outgoingEdges = {};
r7.incomingEdges = {};
r7.circular = void 0;
let c12432_1 = r7;
Object.keys(this.nodes).forEach(function(item) {
c12432_1.nodes[item] = _this.nodes[item];
c12432_1.outgoingEdges[item] = _this.outgoingEdges[item].slice(0);
c12432_1.incomingEdges[item] = _this.incomingEdges[item].slice(0);
});
return r7;
},
dependenciesOf: function dependenciesOf(a0, a1) {
if (this.hasNode(a0)) {
let env12433;
const r17 = [];
const outgoingEdges = this.outgoingEdges;
const circular = this.circular;
const r19 = env12433 = {
$parent: env578
};
env12433[0] = outgoingEdges;
env12433[1] = a1;
env12433[2] = r17;
env12433[3] = circular;
env12433[4] = [];
env12433[5] = {};
env12433[6] = {};
env12433[7] = {};
const r24 = $mk66844(r19);
env12433[8] = r24;
r24(a0);
const r27 = r17.indexOf(a0);
if (r27 >= 0) {
r17.splice(r27, 1);
}
return r17;
}
throw new Error("Node does not exist: " + a0);
},
dependantsOf: function dependantsOf(a0, a1) {
if (this.hasNode(a0)) {
let env12434;
const r17 = [];
const incomingEdges = this.incomingEdges;
const circular = this.circular;
const r19 = env12434 = {
$parent: env578
};
env12434[0] = incomingEdges;
env12434[1] = a1;
env12434[2] = r17;
env12434[3] = circular;
env12434[4] = [];
env12434[5] = {};
env12434[6] = {};
env12434[7] = {};
const r24 = $mk66844(r19);
env12434[8] = r24;
r24(a0);
const r27 = r17.indexOf(a0);
if (r27 >= 0) {
r17.splice(r27, 1);
}
return r17;
}
throw new Error("Node does not exist: " + a0);
},
overallOrder: function overallOrder(a0) {
let DFS3;
const _this2 = this;
const r2 = [];
const r11 = Object.keys(this.nodes);
if (r11.length === 0) {
return r2;
}
let env12436;
let env12437;
const outgoingEdges = this.outgoingEdges;
const circular = this.circular;
const r8 = env12436 = {
$parent: env578
};
env12436[0] = outgoingEdges;
env12436[1] = false;
env12436[2] = [];
env12436[3] = circular;
env12436[4] = [];
env12436[5] = {};
env12436[6] = {};
env12436[7] = {};
const r20 = $mk66844(r8);
env12436[8] = r20;
const DFS2 = r20;
r11.forEach(function(item) {
DFS2(item);
});
const outgoingEdges2 = this.outgoingEdges;
const circular2 = this.circular;
const r26 = env12437 = {
$parent: env578
};
env12437[0] = outgoingEdges2;
env12437[1] = a0;
env12437[2] = r2;
env12437[3] = circular2;
env12437[4] = [];
env12437[5] = {};
env12437[6] = {};
env12437[7] = {};
const r31 = $mk66844(r26);
env12437[8] = r31;
DFS3 = r31;
r11.filter(function(item) {
return _this2.incomingEdges[item].length === 0;
}).forEach(function(item) {
DFS3(item);
});
return r2;
}
};
const r20 = function(a0) {
const error = new Error("Dependency Cycle Found: " + a0.join(" -> "));
error.cyclePath = a0;
Object.setPrototypeOf(error, Object.getPrototypeOf(this));
if (Error.captureStackTrace) {
Error.captureStackTrace(error, c578_1);
}
return error;
};
export { r20 as DepGraphCycleError };
c578_1 = r20;
r20.prototype = Object.create(Error.prototype, {
constructor: {
value: Error,
enumerable: false,
writable: true,
configurable: true
}
});
Object.setPrototypeOf(r20, Error);