// Metro module 14978 (f14979).
import { useMemo } from "react";
import { View } from "react-native";
import GuildChannelStore, { GUILD_VOCAL_CHANNELS_KEY } from "../../../stores/GuildChannelStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import UserGuildSettingsStore from "../../../stores/UserGuildSettingsStore";
import SortedVoiceStateStore from "../../../stores/views/SortedVoiceStateStore";
import { ChannelTypes } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { AvatarPile } from "../../../design/components/Pile/native/AvatarPile.native";
import { AvatarSizes, Avatar } from "../../../design/void/native";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import useFetchStreamPreview from "../../go_live/useFetchStreamPreview";
import FastImage from "../../../components_native/common/FastImage";
import Module4611 from "../../../_bundle/Module4611";
import { useIsHomeDrawerChannelInChannelList } from "./isHomeDrawerChannelInChannelList";
import { useStateFromStoresArray, useStateFromStores } from "../../../_bundle/Module589";
import Module12 from "../../../_bundle/Module12";
import { filterOutBlockedOrIgnoredUsers } from "../../blocking/BlockedUserUtils";
let useStyles, useStyles2, LiveTag;
const VoiceUsers = function VoiceUsers(props) {
const { voiceUsers, guildId } = props;
const r11 = voiceUsers.length > 3 ? voiceUsers.slice(0, 3) : voiceUsers;
return voiceUsers.length !== 0 ?
item.username)} totalCount={r11.length}>
{r11.map((item) => )}
: null;
};
LiveTag = function LiveTag() {
const styles2 = useStyles2();
return
{intl.string(t.dI3q4h).toUpperCase()}
;
};
useStyles = createStyles({
voiceContainer: {
paddingRight: 8,
height: 40,
gap: 4,
justifyContent: "center"
},
streamPreviewShadow: {
borderRadius: Module712.radii.sm,
...Module712.shadows.SHADOW_MEDIUM
},
streamPreview: {
width: 72,
height: 44,
borderRadius: Module712.radii.sm,
overflow: "hidden"
},
streamPreviewDarkGradient: {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
opacity: 0.8
},
streamPreviewGradient: {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
opacity: 0.2
},
streamPreviewBorder: {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
borderWidth: 1,
borderColor: Module712.colors.BORDER_SUBTLE,
borderRadius: Module712.radii.sm
}
});
useStyles2 = createStyles({
tag: {
paddingHorizontal: 4,
paddingVertical: 1,
borderBottomRightRadius: Module712.radii.xs,
overflow: "hidden",
justifyContent: "center",
alignItems: "center",
backgroundColor: Module712.unsafe_rawColors.RED_400,
position: "absolute",
top: 0,
left: 0
},
tagText: {
textAlign: "center",
color: Module712.unsafe_rawColors.WHITE,
includeFontPadding: false
}
});
export function GuildVoiceState(props) {
const voiceUsers = props.voiceUsers;
let streamingChannelId2 = props.streamingChannelId;
const { streamingUser, guildId: guildId2 } = props;
const styles = useStyles();
const r4 = voiceUsers.length > 0;
if (streamingChannelId2 == null) {
streamingChannelId2 = void 0;
}
const previewUrl = useFetchStreamPreview(guildId2, streamingChannelId2, streamingUser?.id).previewUrl;
return r4 ?
{previewUrl == null ? :
}
: null;
}
export function useVoiceUsers(a0) {
let stateFromStores, stateFromStoresArray2;
let c21498_0 = a0;
const id = a0.id;
const isHomeDrawerChannelInChannelList = useIsHomeDrawerChannelInChannelList();
const stateFromStoresArray = useStateFromStoresArray([GuildChannelStore, UserGuildSettingsStore], () => GuildChannelStore.getChannels(id)[GUILD_VOCAL_CHANNELS_KEY].filter(({ channel }) => channel.type === ChannelTypes.GUILD_VOICE && !UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(id, channel.id) && isHomeDrawerChannelInChannelList(channel)).map((item) => item.channel.id), [id, isHomeDrawerChannelInChannelList]);
stateFromStores = useStateFromStores([SortedVoiceStateStore], () => SortedVoiceStateStore.getVoiceStates(id), [id]);
stateFromStoresArray2 = useStateFromStoresArray([RelationshipStore], () => RelationshipStore.getBlockedOrIgnoredIDs());
const memo = useMemo(() => Module12.flatMap(stateFromStoresArray, (a0) => {
if (a0 === c21498_0.afkChannelId) {
return [];
}
let r4 = stateFromStores[a0];
if (r4 == null) {
r4 = [];
}
return filterOutBlockedOrIgnoredUsers(r4.map((item) => item.user), stateFromStoresArray2);
}), [stateFromStoresArray, stateFromStores, a0.afkChannelId, stateFromStoresArray2]);
const memo2 = useMemo(() => {
const user = null;
let streamingChannelId = null;
Object.keys(stateFromStores).forEach((a0) => {
if (a0 !== c21498_0.afkChannelId && stateFromStoresArray.includes(a0)) {
let r6 = stateFromStores[a0];
if (r6 == null) {
r6 = [];
}
const r14 = r6.find((item) => item.voiceState.selfStream);
if (r14 != null && user == null) {
user = r14.user;
streamingChannelId = a0;
}
}
});
return {
streamingUser: user,
streamingChannelId
};
}, [stateFromStores, a0.afkChannelId, stateFromStoresArray]);
return {
voiceUsers: memo,
streamingUser: memo2.streamingUser,
streamingChannelId: memo2.streamingChannelId
};
}