"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAvatar = useAvatar;
const react_1 = require("react");
const useAuthor_1 = require("./useAuthor");
const useAvatars_1 = require("./useAvatars");
// Surfaces the author's avatar URL for whatever the player is currently
// showing, switching on the player's mode via useAuthor. In both modes we
// prefer the hydrated ProfileViewDetailed avatar (fetched through the profile
// cache) and fall back to whatever the basic profile/author view carried.
// Returns undefined when no avatar is known yet.
function useAvatar() {
    const author = (0, useAuthor_1.useAuthor)();
    const did = author?.did;
    // memoized so useAvatars' effect doesn't refire on every render
    const dids = (0, react_1.useMemo)(() => (did ? [did] : []), [did]);
    const detailed = (0, useAvatars_1.useAvatars)(dids);
    if (!did)
        return undefined;
    return detailed[did]?.avatar ?? author?.avatar;
}
//# sourceMappingURL=useAvatar.js.map