Build 555975stable
Module 313961
9,779 characters · in no known chunkDependencies
Required by (54)
13106155110142611340389673198398292960105225135635149741187548191701197808204651222823243612266297313998337371349230413528416528418838442679449571503509516311518960526369530804540462546871585250588224592982681281689035689874710637788318795816806911810845813730848362854182874739957292961974970048973937977851984894
Lazily required by (0)none
Requires (23)
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>ea}),n(321073);var i=n(284009),r=n.n(i),s=n(735438),a=n.n(s),o=n(17928),l=n(228366),u=n(933958),c=n(626584),d=n(643501),_=n(652896),h=n(164891),f=n(616356),p=n(495544),E=n(470710),m=n(734057),g=n(290863),A=n(309010),I=n(485296),T=n(287809),S=n(803301),y=n(977997),N=n(568598),v=n(806931),C=n(652215);let R=new c.A("ChannelRTCStore");R.enableNativeLogger(!0);let O=Object.freeze([]),b=[],D={},L={},w={},M={},P={},x={},k={},U={},G={},F={},V={};function B(e){let t=D[e];return null==t&&(t=new N.Ay(e),D[e]=t),t}function H(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;return t.reduce((t,n)=>e(B(n))?(function(e){let t=B(e);if(0===t.size())return;let n=ei(e)||z(t)?C._Of.VIDEO:C._Of.VOICE;if(n===C._Of.VOICE){let t=P[e]?.[C.BRT.APP];delete M[e],t!==C.DUB.HAVEN&&delete P[e]}else M[e]=n}(n),function(e){let t=p.default.getId(),n=B(e);if(0===n.size()||A.A.getVoiceChannelId()!==e)return $(e,null);let i=v.jd.NONE,s=n.toArray(N.r4.STREAM).find(e=>e.type===v.lp.STREAM&&f.A.getActiveStreamForStreamKey(e.id));if(null!=s)r()(s.type===v.lp.STREAM,"Impossible condition"),i=s.id;else if(1===n.size())i=t;else if(1===n.size(N.r4.VIDEO)){let[e]=n.toArray(N.r4.VIDEO);i=e.id}else{let e=n.toArray().find(e=>e.type===v.lp.USER&&e.id!==t&&!e.ringing);i=e?.id??t}let[a]=Y(e);if(a!==v.jd.AUTO&&a!==v.jd.NONE){let e=n.getParticipant(a);(null==e||e.type===v.lp.STREAM&&null==f.A.getActiveStreamForStreamKey(e.id))&&(a=v.jd.NONE)}$(e,[a,i])}(n),!0):t,!1)}function j(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;return H(t=>t.updateParticipant(e),t)}function Y(e){let t=m.A.getChannel(e),n=t?.isDM()&&1?v.jd.AUTO:v.jd.NONE;return L[e]??[n,v.jd.NONE]}function W(e){if(null==L[e])return!1;let[t]=L[e];return t!==v.jd.NONE}function K(e){null==w[e]&&(w[e]={gridDurationMs:0,focusDurationMs:0,toggleCount:0,lastUpdate:0});let t=w[e],n=performance.now(),i=W(e);if(t.lastUpdate>0){let e=n-t.lastUpdate;t[i?"focusDurationMs":"gridDurationMs"]+=e}t.lastUpdate=n}function $(e,t){K(e);let n=W(e);null==t?delete L[e]:L[e]=t,n!==W(e)&&w[e].toggleCount++}function z(e){return e.size(N.r4.STREAM)>0||e.size(N.r4.VIDEO)>0||e.hasEmbeddedActivity()}function q(e){delete D[e],delete L[e],delete M[e],delete P[e]}function X(){let e,t,n,i,r,s;return H(e=>e.rebuild(),(e=[],null!=(t=A.A.getChannelId())&&e.push(t),null==(n=A.A.getVoiceChannelId())||e.includes(n)||e.push(n),i=d.default.getRemoteSessionId(),r=y.A.getVoiceStateForSession(p.default.getId(),i),r?.channelId!=null&&e.push(r?.channelId),a().difference(b,e).forEach(q),s=a().difference(e,b),b=e,s))}function Z(){return H(e=>e.updateEmbeddedActivities())}function Q(e){let{userId:t}=e;return H(e=>e.updateParticipantSpeaking(t))}function J(e){let{user:t}=e;return j(t.id)}function ee(e){let{channelId:t}=e;return H(e=>e.rebuild(),[t])}function et(e){let{channel:{id:t}}=e;return delete U[t],delete G[t],delete V[t],q(t)}function en(e){let{streamKey:t}=e,{channelId:n,ownerId:i}=(0,_.Iy)(t);return j(i,[n])}function ei(e){return!!m.A.getChannel(e)?.isGuildVocalOrThread()}function er(e){return!!m.A.getChannel(e)?.isVocalThread()}class es extends o.Ay.PersistedStore{static displayName="ChannelRTCStore";static persistKey="ChannelRTCStore";initialize(e){this.waitFor(f.A,p.default,E.A,m.A,u.Ay,d.default,g.A,A.A,I.A,T.default,S.A,y.A),this.syncWith([u.Ay],Z),this.syncWith([d.default],X),e?.voiceParticipantsHidden!==void 0&&Object.assign(k,e?.voiceParticipantsHidden)}getState(){return{voiceParticipantsHidden:k}}getParticipantsVersion(e){return B(e).version}getParticipants(e){return B(e).toArray()??O}getSpeakingParticipants(e){return B(e).toArray(N.r4.SPEAKING)??O}getFilteredParticipants(e){let t=B(e);return k[e]?t.toArray(N.r4.FILTERED):t.toArray(N.r4.NOT_POPPED_OUT)}getVideoParticipants(e){return B(e).toArray(N.r4.VIDEO)??O}getStreamParticipants(e){return B(e).toArray(N.r4.STREAM)??O}getActivityParticipants(e){return B(e).toArray(N.r4.ACTIVITY)??O}getParticipant(e,t){return B(e).getParticipant(t)}getUserParticipantCount(e){let t=B(e);return t.size()-t.size(N.r4.STREAM)-t.size(N.r4.ACTIVITY)}getParticipantsOpen(e){return x[e]??!0}getVoiceParticipantsHidden(e){return k[e]??!1}getSelectedParticipantId(e){let[t,n]=Y(e);return t===v.jd.NONE?null:t!==v.jd.AUTO?t:n===v.jd.NONE||n===v.jd.AUTO?null:n}getSelectedParticipant(e){let t=this.getSelectedParticipantId(e);return null==t?null:B(e).getParticipant(t)}getSelectedParticipantStats(e){let t=w[e];return null==t?{}:{view_mode_grid_duration_ms:Math.floor(t.gridDurationMs),view_mode_focus_duration_ms:Math.floor(t.focusDurationMs),view_mode_toggle_count:t.toggleCount}}getGuildRingingUsers(e){return B(e).guildRingingUsers}getMode(e){return M[e]??(ei(e)?C._Of.VIDEO:C._Of.VOICE)}getLayout(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:C.BRT.APP;if(__OVERLAY__||V[e]&&er(e))return C.DUB.NORMAL;let n=this.getUserParticipantCount(e)>0,i=!!m.A.getChannel(e)?.isGuildVocal()||n&&er(e);return P[e]?.[t]??(i?C.DUB.NO_CHAT:C.DUB.NORMAL)}getChatOpen(e){return U[e]??m.A.getChannel(e)?.isVocalThread()??!1}getAllChatOpen(){return U}getForceTextView(e){return V[e]??!1}isFullscreenInContext(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:C.BRT.APP;return Object.values(P).some(t=>t[e]===C.DUB.FULL_SCREEN)}getStageStreamSize(e){return G[e]}getStageVideoLimitBoostUpsellDismissed(e){return F[e]}isParticipantPoppedOut(e,t){let n=this.getParticipant(e,t);return null!=n&&"isPoppedOut"in n&&n.isPoppedOut}}let ea=new es(l.h,{CONNECTION_OPEN:function(){for(let e of b)q(e);X()},CONNECTION_OPEN_SUPPLEMENTAL:X,THREAD_LIST_SYNC:X,OVERLAY_INITIALIZE:X,VOICE_CHANNEL_SELECT:function(e){let{channelId:t,currentVoiceChannelId:n}=e,i=!1;if(null!=t?delete w[t]:null!=n&&(delete U[n],delete G[n],delete V[n],K(n)),t!==n&&null!=n){let e=B(n);e.guildRingingUsers.forEach(t=>e.updateGuildRingingUsers(t,!1)),i=H(e=>e.rebuild(),[n])}let r=X();return i||r},CHANNEL_SELECT:function(e){let{channelId:t,messageId:n}=e,i=X();if(null==t||null==n||U[t])return i;let r=m.A.getChannel(t);return null!=r&&r.isGuildVocal()?(U[t]=!0,!0):i},CHANNEL_RTC_ACTIVE_CHANNELS:X,VOICE_STATE_UPDATES:function(e){let{voiceStates:t,initial:n}=e;return t.reduce((e,t)=>{let{userId:i,channelId:r,guildId:s}=t;return(null!=s&&null!=r&&h.A.getCurrentConfig({guildId:s,location:"voice_status_update"},{autoTrackExposure:!1}).enabled&&B(r).updateGuildRingingUsers(i,!1),n&&null!=r&&!b.includes(r))?e:j(i)||e},!1)},CHANNEL_CREATE:function(e){let{channel:t}=e;if(t.type===C.rbe.GROUP_DM){let e=t.originChannelId;if(null!=e)return P[t.id]={[C.BRT.APP]:P[e]?.[C.BRT.APP]??C.DUB.NORMAL},!0}return!1},CHANNEL_DELETE:et,THREAD_DELETE:et,CALL_CREATE:ee,CALL_UPDATE:ee,CALL_DELETE:function(e){let{channelId:t}=e;return q(t)},CHANNEL_RTC_SELECT_PARTICIPANT:function(e){let{channelId:t,id:n}=e,i=B(t);null==n&&i.toArray(N.r4.STREAM).forEach(e=>{(0,v.Ay)(e)&&i.updateParticipant(e.user.id)});let[,r]=Y(t);if($(t,[n??v.jd.NONE,r]),(0,_.wL)(n)){try{let{ownerId:e}=(0,_.Iy)(n);e===p.default.getId()&&j(e,[t])}catch(e){R.warn(`INVALID STREAM KEY FORMAT ${n}`,e)}z(i)||(x[t]=!1)}},CHANNEL_RTC_POPOUT_PARTICIPANT:function(e){let{channelId:t,participantId:n}=e,[i]=Y(t);i===n&&$(t,null);let r=B(t),s=r.getParticipant(n);null==s||s.type!==v.lp.ACTIVITY&&(r.updateParticipantPoppedOut(n,!0),j(s.user.id,[t]))},CHANNEL_RTC_RETURN_PARTICIPANT:function(e){let{channelId:t,participantId:n}=e,i=B(t);i.updateParticipantPoppedOut(n,!1);let r=i.getParticipant(n);null==r||r.type!==v.lp.ACTIVITY&&j(r.user.id,[t])},CHANNEL_RTC_UPDATE_LAYOUT:function(e){let{channelId:t,layout:n,appContext:i}=e;P[t]={...P[t],[i]:n}},CHANNEL_RTC_UPDATE_PARTICIPANTS_OPEN:function(e){let{channelId:t,participantsOpen:n}=e;x[t]=n},CHANNEL_RTC_UPDATE_VOICE_PARTICIPANTS_HIDDEN:function(e){let{channelId:t,voiceParticipantsHidden:n}=e;k[t]=n},CHANNEL_RTC_UPDATE_STAGE_STREAM_SIZE:function(e){let{channelId:t,large:n}=e;G[t]=n},CHANNEL_RTC_UPDATE_STAGE_VIDEO_LIMIT_BOOST_UPSELL_DISMISSED:function(e){let{channelId:t,dismissed:n}=e;F[t]=n},STREAM_UPDATE_SELF_HIDDEN:function(e){let{channelId:t,selfStreamHidden:n}=e,i=p.default.getId();if(n){let[e]=Y(t);(0,_.wL)(e)&&e.includes(i)&&$(t,null)}j(i,[t])},CHANNEL_RTC_UPDATE_CHAT_OPEN:function(e){let{channelId:t,chatOpen:n}=e;U[t]=n},CHANNEL_RTC_UPDATE_FORCE_TEXT_VIEW:function(e){let{channelId:t,forceTextView:n}=e;V[t]=n},RTC_CONNECTION_VIDEO:function(e){let{channelId:t,userId:n}=e;return j(n,[t])},RTC_CONNECTION_PLATFORM:function(e){let{channelId:t,userId:n}=e;return j(n,[t])},AUDIO_SET_LOCAL_VIDEO_DISABLED:function(e){let{userId:t}=e;return j(t)},MEDIA_ENGINE_VIDEO_SOURCE_QUALITY_CHANGED:function(e){let{channelId:t,senderUserId:n,maxResolution:i,maxFrameRate:r}=e;return H(e=>e.updateParticipantQuality(n,i,r),[t])},STREAM_CLOSE:en,STREAM_DELETE:en,STREAM_WATCH:function(e){let{streamKey:t}=e,{channelId:n,ownerId:i}=(0,_.Iy)(t);return j(i,[n])},SPEAKING:Q,GUILD_SOUNDBOARD_SOUND_PLAY_START:Q,GUILD_SOUNDBOARD_SOUND_PLAY_END:Q,PUSH_TO_TALK_STATE_CHANGE:function(){return H(e=>e.updateParticipantSpeaking(p.default.getId()))},GUILD_RING_START:function(e){let{channelId:t,guildId:n,ongoingRings:i}=e;if(!h.A.getCurrentConfig({guildId:n,location:"guild_ring_start"}).enabled)return!1;let r=B(t);return Object.keys(i).forEach(e=>r.updateGuildRingingUsers(e,!0)),H(e=>e.rebuild(),[t])},GUILD_RING_STOP:function(e){let{channelId:t,guildId:n,ringing:i}=e;if(!h.A.getCurrentConfig({guildId:n,location:"guild_ring_start"}).enabled)return!1;let r=B(t);return i.forEach(e=>r.updateGuildRingingUsers(e,!1)),H(e=>e.rebuild(),[t])},USER_UPDATE:J,GUILD_MEMBER_UPDATE:J,GUILD_DELETE:function(e){let{guild:t}=e,n=[];if(a().forEach(b,e=>{let i=m.A.getChannel(e);(null==i||i.getGuildId()===t.id)&&n.push(e)}),0===n.length)return!1;a().forEach(n,e=>q(e))}})}