"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.canEditEvent = canEditEvent;
const get_prop_1 = require("../objects/get-prop");
const util_1 = require("../util");
const has_base_priv_1 = require("./has-base-priv");
/**
 * Checks if user has access to edit an event in Hub
 * @param {IEventModel} model consolidated event model as consumed by Hub, contains the event feature, related initiative model, and attendees group
 * @param {IUser} user
 * @returns {boolean}
 */
function canEditEvent(model, user) {
    let res = false;
    if ((0, has_base_priv_1.hasBasePriv)(user)) {
        const coreTeamId = model.initiative
            ? (0, get_prop_1.getProp)(model, "initiative.item.properties.collaborationGroupId")
            : (0, get_prop_1.getProp)(model, "site.properties.collaborationGroupId");
        const { groups = [] } = user;
        res = !!coreTeamId && !!(0, util_1.findBy)(groups, "id", coreTeamId);
    }
    return res;
}
//# sourceMappingURL=can-edit-event.js.map