"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LinkTransitions_1 = require("./LinkTransitions");
var findBackboneBundleNodes_1 = require("../Utils/findBackboneBundleNodes");
function nodeTransitions(xOffset, yOffset, clusterOffset, backboneOffset, duration, nodeList, nodeMap, annotationOpen, annotationHeight, bundleMap) {
    if (duration === void 0) { duration = 500; }
    xOffset = -xOffset;
    backboneOffset = -backboneOffset;
    var start = function () {
        return { x: 0, y: 0, opacity: 0 };
    };
    var enter = function (data) {
        var backboneBundleNodes = findBackboneBundleNodes_1.default(nodeMap, bundleMap);
        var clusteredNodesInFront = 0;
        for (var i = 0; i < nodeList.length; i++) {
            if (data.width === 0 &&
                nodeList[i].width === 0 &&
                nodeList[i].depth <= data.depth &&
                backboneBundleNodes.includes(nodeList[i].id)) {
                clusteredNodesInFront++;
            }
        }
        var x = LinkTransitions_1.getX(data.width, xOffset, backboneOffset);
        clusteredNodesInFront =
            clusteredNodesInFront === 0 ? clusteredNodesInFront : clusteredNodesInFront - 1;
        var y = yOffset * data.depth - (yOffset - clusterOffset) * clusteredNodesInFront;
        if (annotationOpen !== -1 && data.depth > annotationOpen && data.width === 0) {
            y += annotationHeight;
        }
        return {
            x: [x],
            y: [y],
            opactiy: 1,
            timing: { duration: duration }
        };
    };
    var update = function (data) {
        var backboneBundleNodes = findBackboneBundleNodes_1.default(nodeMap, bundleMap);
        var clusteredNodesInFront = 0;
        for (var i = 0; i < nodeList.length; i++) {
            if (data.width === 0 &&
                nodeList[i].width === 0 &&
                nodeList[i].depth <= data.depth &&
                backboneBundleNodes.includes(nodeList[i].id)) {
                clusteredNodesInFront++;
            }
        }
        var x = LinkTransitions_1.getX(data.width, xOffset, backboneOffset);
        clusteredNodesInFront =
            clusteredNodesInFront === 0 ? clusteredNodesInFront : clusteredNodesInFront - 1;
        var y = yOffset * data.depth - (yOffset - clusterOffset) * clusteredNodesInFront;
        if (annotationOpen !== -1 && data.depth > annotationOpen && data.width === 0) {
            y += annotationHeight;
        }
        return {
            x: [x],
            y: [y],
            opactiy: 1,
            timing: { duration: duration }
        };
    };
    return { enter: enter, leave: start, update: update, start: start };
}
exports.default = nodeTransitions;
//# sourceMappingURL=NodeTransitions.js.map