"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSelectedNodeRenderer = void 0;
var react_1 = require("react");
var core_1 = require("@react-sigma/core");
var nodeArc_1 = require("../../rendering/canvas/nodeArc");
var useSigmaCustomRenderers_1 = require("../../hooks/useSigmaCustomRenderers");
var useEdgeLabelsRenderer_1 = require("./useEdgeLabelsRenderer");
var useSelectedNodeRenderer = function (graph) {
    var sigma = (0, core_1.useSigma)();
    var addCustomRenderers = (0, useSigmaCustomRenderers_1.useSigmaCustomRenderers)().addRenderers;
    (0, react_1.useEffect)(function () {
        addCustomRenderers({
            selectedNodeBorder: {
                renderer: function (context) {
                    graph.forEachNode(function (nodeId) {
                        var data = sigma.getNodeDisplayData(nodeId);
                        if (!data.selected)
                            return;
                        var scaledData = __assign(__assign(__assign({}, data), sigma.framedGraphToViewport(data)), { size: sigma.scaleSize(data.size) });
                        (0, nodeArc_1.drawTwoArcs)(context, scaledData);
                    });
                },
                // we need to have "selected" node renderer layer before 'labels' layer to have labels of other nodes on top of it in case of overlapping
                insertBefore: useEdgeLabelsRenderer_1.CUSTOM_EDGE_LABELS_CANVAS_NAME
            }
        });
    }, [addCustomRenderers, graph, sigma]);
};
exports.useSelectedNodeRenderer = useSelectedNodeRenderer;
