"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivityItem = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var activities_1 = require("../../../utils/activities");
var ActivitiesFactory_1 = require("../../../ActivitiesFactory");
var ErrorBoundary_1 = require("../../../../../ErrorBoundary");
var ActivityTitle_1 = require("../../../ActivityTitle");
var styles_1 = require("./styles");
var ActivityItem = function (_a) {
    var item = _a.item;
    var styles = (0, styles_1.useStyles)();
    var type = (0, activities_1.getActivityType)(item);
    var activities = (0, activities_1.splitActivityByType)(item);
    return (react_1.default.createElement("div", { className: styles.activityItem, "data-reltio-id": "activity-log-item" },
        react_1.default.createElement("div", { className: styles.activityIcon }, ActivitiesFactory_1.ActivitiesFactory.getIcon(type)),
        react_1.default.createElement("div", { className: styles.activityInfo },
            react_1.default.createElement("div", { className: styles.userContainer },
                react_1.default.createElement("span", { className: styles.activityUser }, item.user),
                react_1.default.createElement("span", { className: styles.date }, ui_i18n_1.default.date(item.timestamp, 'LT'))),
            activities.map(function (activity, index) {
                var activityType = (0, activities_1.getActivityType)(activity);
                return (react_1.default.createElement("div", { key: index, className: styles.activityEvent },
                    react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, { error: react_1.default.createElement(react_1.default.Fragment, null,
                            react_1.default.createElement(ActivityTitle_1.ActivityTitle, { type: activityType }),
                            ui_i18n_1.default.text("Can't render activity")) }, ActivitiesFactory_1.ActivitiesFactory.getComponent({
                        type: activityType,
                        data: activity
                    }))));
            }))));
};
exports.ActivityItem = ActivityItem;
