"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.eventAttendeeToSearchResult = eventAttendeeToSearchResult;
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
const getUserHomeUrl_1 = require("../../../urls/getUserHomeUrl");
const utils_1 = require("../../utils");
/**
 * Transforms a given event attendee into a IHubSearchResult
 * @param attendee
 * @returns
 */
async function eventAttendeeToSearchResult(attendee, options) {
    var _a;
    const [user, creator] = await Promise.all([
        (0, arcgis_rest_portal_1.getUser)(Object.assign({ username: attendee.userId }, options.requestOptions)),
        (0, arcgis_rest_portal_1.getUser)(Object.assign({ username: attendee.createdById }, options.requestOptions)),
    ]);
    return {
        id: attendee.id.toString(),
        access: user.access,
        name: user.fullName,
        createdDate: new Date(attendee.createdAt),
        createdDateSource: "attendee.createdAt",
        updatedDate: new Date(attendee.updatedAt),
        updatedDateSource: "attendee.updatedAt",
        type: "Event Attendee",
        family: "eventAttendee",
        owner: creator.username,
        rawResult: attendee,
        links: {
            self: (0, getUserHomeUrl_1.getUserHomeUrl)(user.username, options.requestOptions),
            siteRelative: `/people/${user.username}`,
            thumbnail: user.thumbnail
                ? (0, utils_1.getUserThumbnailUrl)(options.requestOptions.portal, user, (_a = options.requestOptions.authentication) === null || _a === void 0 ? void 0 : _a.token)
                : null,
        },
    };
}
//# sourceMappingURL=eventAttendeeToSearchResult.js.map