"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shareEntityWithGroups = shareEntityWithGroups;
const shareEventWithGroups_1 = require("../events/_internal/shareEventWithGroups");
const getTypeFromEntity_1 = require("./getTypeFromEntity");
const share_item_to_groups_1 = require("../items/share-item-to-groups");
/**
 * Shares an entity to one or more groups
 * @param entity An IHubItemEntity object
 * @param groupIds An array of group IDs to share the entity to
 * @param context An IArcGISContext object
 * @returns a promise that resolves the updated entity
 */
async function shareEntityWithGroups(entity, groupIds, context) {
    const type = (0, getTypeFromEntity_1.getTypeFromEntity)(entity);
    let results;
    switch (type) {
        case "event":
            results = await (0, shareEventWithGroups_1.shareEventWithGroups)(groupIds, entity, context);
            break;
        default:
            results = entity;
            await (0, share_item_to_groups_1.shareItemToGroups)(entity.id, groupIds, context.requestOptions, entity.owner);
            break;
    }
    return results;
}
//# sourceMappingURL=shareEntityWithGroups.js.map