/**
 * Retrieves the user's groups categorized by their membership type.
 *
 * @param user - The user object containing group information.
 * @returns An object categorizing the user's groups into `owner`, `admin`, and `member`.
 *
 * The function processes the user's groups and classifies them based on the membership type:
 * - `owner`: Groups where the user is an owner.
 * - `admin`: Groups where the user is an admin.
 * - `member`: Groups where the user is a member and the group is not view-only.
 *
 * Note: The `none` membership type is not considered as it is not expected to be present in the user's groups.
 */
export function getUserGroupsByMembership(user) {
    const response = {
        owner: [],
        member: [],
        admin: [],
    };
    // get the user's groups
    const userGroups = user.groups || [];
    // loop through the groups and determine if the user is an admin or normal member
    // and add into the response
    userGroups.forEach((group) => {
        var _a, _b, _c;
        if (((_a = group.userMembership) === null || _a === void 0 ? void 0 : _a.memberType) === "owner") {
            response.owner.push(group.id);
        }
        if (((_b = group.userMembership) === null || _b === void 0 ? void 0 : _b.memberType) === "admin") {
            response.admin.push(group.id);
        }
        // If user is just a member and the group is not view only
        if (((_c = group.userMembership) === null || _c === void 0 ? void 0 : _c.memberType) === "member" && !group.isViewOnly) {
            response.member.push(group.id);
        }
        // there is a `none` option in the userMembership but
        // that would never be returned in the user's groups
        // so we don't need to check for it
    });
    return response;
}
//# sourceMappingURL=getUserGroupsByMembership.js.map