// Metro module 16202 (f16203). import _slicedToArray from "../../_bundle/_slicedToArray"; import ExperimentStore from "../experiments/ExperimentStore"; import ApexExperimentStore from "../experiments/apex/ApexExperimentStore"; import AuthenticationStore from "../../stores/AuthenticationStore"; import ChannelStore from "../../stores/ChannelStore"; import MediaEngineStore from "../../stores/MediaEngineStore"; import RTCConnectionStore from "../../stores/RTCConnectionStore"; import GuildRoomStore from "./GuildRoomStore"; import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager"; import AudioActionCreators from "../../actions/AudioActionCreators"; import GuildRoomsExperiment from "./GuildRoomsExperiment"; import { computeLivingRoomWorldPoints, livingRoomWorldPointToMediaEnginePoint } from "./GuildRoomSpatialAudio"; class GuildRoomSpatialAudioManager extends AutomaticLifecycleManager { actions = { AUDIO_SET_AUDIO_MIXER_SETTINGS: () => this.apply(), RTC_CONNECTION_STATE: () => this.apply(), RTC_CONNECTION_USERS_MERGED: () => this.apply(), MEDIA_SESSION_JOINED: () => this.apply(), GUILD_ROOM_CONNECT: () => this.apply(), GUILD_ROOM_UPDATE: () => this.apply(), GUILD_ROOM_LOCAL_UPDATE: () => this.apply(), GUILD_ROOM_DISCONNECT: () => this.apply() }; reapplyForExperimentUpdate = () => { AudioActionCreators.setAudioMixerSettings(MediaEngineStore.getAudioMixerSettings()); this.apply(); }; _initialize() { this.stores = new Map().set(ExperimentStore, this.reapplyForExperimentUpdate).set(ApexExperimentStore, this.reapplyForExperimentUpdate); } _terminate() {} isLivingRoomAvailable() { const guildId = RTCConnectionStore.getGuildId(); return guildId != null && GuildRoomsExperiment.getCurrentConfig({ guildId, location: "GuildRoomSpatialAudioManager" }, { autoTrackExposure: false }).interactionsEnabled; } apply() { if (MediaEngineStore.getAudioMixerSettings().enabled) { const channelId = RTCConnectionStore.getChannelId(); if (channelId != null && this.isLivingRoomAvailable()) { const channel = ChannelStore.getChannel(channelId); if (!(channel == null ? void 0 : channel.isGuildStageVoice())) { let c22882_0 = computeLivingRoomWorldPoints({ users: GuildRoomStore.getRoomUsers(channelId), currentUserId: AuthenticationStore.getId(), channelId }); MediaEngineStore.getMediaEngine().eachConnection((a0) => { for (const item of Object.entries(c22882_0)) { const r32 = _slicedToArray(item, 2); a0.setUserPosition(r32[0], livingRoomWorldPointToMediaEnginePoint(r32[1])); } }); } } } } } const guildRoomSpatialAudioManager = new GuildRoomSpatialAudioManager(); export default guildRoomSpatialAudioManager;