// Metro module 5125 (f5126). import ChannelStore from "../../stores/ChannelStore"; import Module12 from "../../_bundle/Module12"; import { isNotNullish } from "../../utils/GlobalUtils"; import { useStateFromStoresArray } from "../../_bundle/Module589"; const getFlattenedChannels = function getFlattenedChannels(a0, c14672_0, a2) { let c14672_4, c14672_5; let r22 = arguments[3]; if (r22 === void 0) { r22 = false; } let c14672_2 = r22; c14672_4 = void 0; c14672_5 = void 0; let c14672_3 = Module12(ChannelStore.getMutableGuildChannelsForGuild(a0)).values().groupBy("parent_id").value(); const r60 = Module12(a2).map((item) => item.isCategory() ? item.id : item.parent_id).filter(isNotNullish).uniq().map((item) => ChannelStore.getChannel(item)).filter(isNotNullish).sortBy("position").value(); c14672_4 = new Set(r60.map((item) => item.id)); const r70 = a2.filter((item) => !(item.isCategory() || item.parent_id != null && c14672_4.has(item.parent_id))); c14672_5 = r70; const r75 = Module12.sortBy(r70, (a0) => { const isGuildVocal = a0.isGuildVocal(); const position = a0.position; return isGuildVocal ? position + 10000 : position; }); c14672_5 = r75; const _loop = function _loop(a0) { let c25356_0 = a0; if (!c14672_2) { c14672_5.push(a0); } let r20 = c14672_0.has(a0.id) ? c14672_3[a0.id] : a2.filter((item) => item.parent_id === c25356_0.id); if (r20 == null) { r20 = []; } const r10 = Module12.sortBy(r20, (a0) => { const isGuildVocal = a0.isGuildVocal(); const position = a0.position; return isGuildVocal ? position + 10000 : position; }); c14672_5.push.apply(c14672_5, [...r10]); }; for (const item of r60) { _loop(item); } return r75; }; export { getFlattenedChannels }; export function useFlattenedChannels(c14673_0, c14673_1, r4 = false) { let c14673_2 = r4; return useStateFromStoresArray([ChannelStore], () => { const r3 = Array; return getFlattenedChannels(c14673_0, c14673_1, r3.from(c14673_1).map((item) => ChannelStore.getChannel(item)).filter(isNotNullish), c14673_2); }); }