"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SigmaGraphContainer = void 0;
var react_1 = __importStar(require("react"));
var graphology_1 = require("graphology");
var ramda_1 = require("ramda");
var core_1 = require("@react-sigma/core");
var node_1 = require("sigma/rendering/webgl/programs/common/node");
var edge_1 = require("sigma/rendering/webgl/programs/common/edge");
var edge_2 = __importDefault(require("sigma/rendering/webgl/programs/edge"));
var SigmaCustomRenderersContainer_1 = require("../SigmaCustomRenderersContainer");
var SigmaGraphResizer_1 = require("../SigmaGraphResizer");
var hover_1 = require("../rendering/canvas/hover");
var label_1 = require("../rendering/canvas/label");
var node_dashed_border_1 = require("../rendering/webgl/node.dashed.border");
var node_image_1 = require("../rendering/webgl/node.image");
var edge_arrowHead_1 = __importDefault(require("../rendering/webgl/edge.arrowHead"));
var edge_reversedArrowHead_1 = __importDefault(require("../rendering/webgl/edge.reversedArrowHead"));
var edge_clamped_1 = __importDefault(require("../rendering/webgl/edge.clamped"));
var edge_dashed_1 = __importDefault(require("../rendering/webgl/edge.dashed"));
var styles_1 = require("./styles");
var SigmaGraphContainer = function (_a) {
    var children = _a.children, initialSettingsProp = _a.initialSettings;
    (0, styles_1.useStyles)();
    var initialSettings = (0, react_1.useMemo)(function () {
        return (0, ramda_1.mergeDeepRight)({
            allowInvalidContainer: true,
            defaultNodeType: 'image',
            hoverRenderer: hover_1.drawHover,
            labelRenderer: label_1.drawLabel,
            nodeProgramClasses: {
                image: (0, node_1.createNodeCompoundProgram)([node_image_1.NodeImageProgram, node_dashed_border_1.NodeDashedBorderProgram])
            },
            edgeProgramClasses: {
                line: edge_2.default,
                arrow: (0, edge_1.createEdgeCompoundProgram)([edge_clamped_1.default, edge_arrowHead_1.default]),
                doubleArrow: (0, edge_1.createEdgeCompoundProgram)([
                    edge_clamped_1.default,
                    edge_arrowHead_1.default,
                    edge_reversedArrowHead_1.default
                ]),
                dashed: edge_dashed_1.default
            },
            labelFont: 'Roboto',
            labelSize: 13,
            labelColor: {
                color: 'rgba(0, 0, 0, 0.87)',
                attribute: 'labelColor'
            },
            secondaryLabelColor: {
                color: 'rgba(0, 0, 0, 0.54)',
                attribute: 'secondaryLabelColor'
            }
        }, initialSettingsProp || {});
    }, [initialSettingsProp]);
    return (react_1.default.createElement(core_1.SigmaContainer, { graph: graphology_1.MultiGraph, style: { background: 'transparent' }, settings: initialSettings },
        react_1.default.createElement(SigmaCustomRenderersContainer_1.SigmaCustomRenderersContainer, null,
            react_1.default.createElement(SigmaGraphResizer_1.SigmaGraphResizer, null),
            children)));
};
exports.SigmaGraphContainer = SigmaGraphContainer;
