import { useEffect } from 'react';
import { useSigma } from '@react-sigma/core';
import { DataModelGraphNodeType } from '../../types/graphDataTypes';
export var FAKE_CENTER_NODE_ID = 'fakeCenterNodeId';
export var useFakeCenterNode = function (_a) {
    var graph = _a.graph, timeout = _a.timeout;
    var sigma = useSigma();
    useEffect(function () {
        graph.addNode(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 === DataModelGraphNodeType.entityType) {
                graph.addEdge(node, FAKE_CENTER_NODE_ID, {
                    hidden: true
                });
            }
        });
        var timer = setTimeout(function () {
            graph.dropNode(FAKE_CENTER_NODE_ID);
            sigma.getGraph().dropNode(FAKE_CENTER_NODE_ID);
        }, timeout);
        return function () {
            clearTimeout(timer);
        };
    }, [sigma, graph, timeout]);
};
