"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useFakeCenterNode = exports.FAKE_CENTER_NODE_ID = void 0;
var react_1 = require("react");
var core_1 = require("@react-sigma/core");
var graphDataTypes_1 = require("../../types/graphDataTypes");
exports.FAKE_CENTER_NODE_ID = 'fakeCenterNodeId';
var useFakeCenterNode = function (_a) {
    var graph = _a.graph, timeout = _a.timeout;
    var sigma = (0, core_1.useSigma)();
    (0, react_1.useEffect)(function () {
        graph.addNode(exports.FAKE_CENTER_NODE_ID, {
            type: 'circle',
            hidden: true,
            size: 0,
            x: 1,
            y: 1
        });
        graph.forEachNode(function (node) {
            var nodeData = graph.getNodeAttributes(node);
            if (nodeData.nodeType === graphDataTypes_1.DataModelGraphNodeType.entityType) {
                graph.addEdge(node, exports.FAKE_CENTER_NODE_ID, {
                    hidden: true
                });
            }
        });
        var timer = setTimeout(function () {
            graph.dropNode(exports.FAKE_CENTER_NODE_ID);
            sigma.getGraph().dropNode(exports.FAKE_CENTER_NODE_ID);
        }, timeout);
        return function () {
            clearTimeout(timer);
        };
    }, [sigma, graph, timeout]);
};
exports.useFakeCenterNode = useFakeCenterNode;
