Build 541864stable
Module 458294
10,428 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>em}),n(938796);var i=n(735438),r=n.n(i);n(252431);var s=n(395504),a=n(135978),o=n(695633),l=n(152007),u=n(882733),c=n(95701),d=n(935208),_=n(495544),f=n(734057),h=n(71393),p=n(536802),E=n(576705),m=n(222823),g=n(309010),A=n(543465),I=n(287809),T=n(652215),S=n(746080),N=n(790782);let y=T.eGj,C={},v=new Set,O=0;function R(e){let t=C[e??y];return{unread:!1,unreadByType:{},unreadChannelId:null,lowImportanceMentionCount:0,highImportanceMentionCount:0,mentionCounts:{},ncMentionCount:0,sentinel:t?.sentinel??0}}function b(e){return C[e??y]=C[e??y]??R(e)}function D(e){let t=b(e);t.sentinel++,O++}function L(e,t,n){return null!=e.guild_id&&n&&!((0,c.fT)(e.type)||A.Ay.isChannelRecordOrParentOptedIn(e))&&0===t}function w(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!(null==e||e.isGuildVocal()&&0===t||e.hasFlag(S.lx.IS_GUILD_RESOURCE_CHANNEL)||(0===t||n)&&(e.isThread()?l.A.isMuted(e.id)||A.Ay.isGuildOrCategoryOrChannelMuted(e.guild_id,e.parent_id):A.Ay.isGuildOrCategoryOrChannelMuted(e.guild_id,e.id))||!e.isPrivate()&&(L(e,t,(0,s.WW)(e.guild_id))||!E.A.can(e.accessPermissions,e)))&&(t>0||A.Ay.resolveUnreadSetting(e)===N.e.ALL_MESSAGES)}function M(e){switch(e){case y:case null:case void 0:return null;default:return e}}function P(e,t){let n=m.Ay.hasUnread(e,t);return t!==N.P.GUILD_EVENT?n:!(A.Ay.isMuted(e)||A.Ay.isMuteScheduledEventsEnabled(e))&&n}function x(e,t){let n=R(e);return n.mentionCounts={...t.mentionCounts},n.unreadByType={...t.unreadByType},n}function U(e){return e.unread=Object.values(e.unreadByType).some(e=>e),e}function k(e,t){}function G(e,t,n){return U(t),t.lowImportanceMentionCount=0,t.highImportanceMentionCount=0,d.default.forEach(t.mentionCounts,e=>{let{count:n,isMentionLowImportance:i}=e;i?t.lowImportanceMentionCount+=n:t.highImportanceMentionCount+=n}),(t.unread!==n.unread||t.lowImportanceMentionCount!==n.lowImportanceMentionCount||t.highImportanceMentionCount!==n.highImportanceMentionCount)&&(C[e??y]=t,null!=e&&(t.unread?v.add(e):v.delete(e)),O++,D(e??y),k(t,n),!0)}function F(e,t){let n=M(e),i=b(n),r=x(n,i),s=!1;if(t.forEach(e=>{let t=f.A.getChannel(e);if(null==t)return void delete r.mentionCounts[e];if(t.getGuildId()!==n)return;let i=m.Ay.getMentionCount(e);null!==n&&!s&&m.Ay.hasUnread(t.id)&&w(t,i,!0)&&(s=!0,r.unreadChannelId=t.id),i>0&&w(t,i)?r.mentionCounts[t.id]={count:i,isMentionLowImportance:m.Ay.getIsMentionLowImportance(e)}:delete r.mentionCounts[t.id]}),r.unreadByType[N.P.CHANNEL]=s,r.unreadByType[N.P.CHANNEL]!==i.unreadByType[N.P.CHANNEL]&&!r.unreadByType[N.P.CHANNEL]){let e=f.A.getChannel(i.unreadChannelId);if(!(null!=e&&!t.includes(e.id)&&m.Ay.hasUnread(e.id)&&w(e)))return B(n);null!=n&&v.add(n),r.unreadByType[N.P.CHANNEL]=!0}return G(n,r,i)}function V(e,t){if(null==e)return;let n=b(e),i=x(e,n);return i.unreadByType[N.P.GUILD_EVENT]=P(e,t),G(e,i,n)}function B(e,t){let n=M(e),i=R(n);if(null==n){let e=f.A.getMutablePrivateChannels();for(let t in e){let n=e[t],r=m.Ay.getMentionCount(t);r>0&&w(n,r)&&(i.highImportanceMentionCount+=r,i.mentionCounts[n.id]={count:r,isMentionLowImportance:!1})}}else{let e=A.Ay.isMuted(n);if(e&&!1===t)return!1;let d=A.Ay.getMutedChannels(n),_=A.Ay.getChannelOverrides(n),h=(0,s.WW)(n),p=f.A.getMutableBasicGuildChannelsForGuild(n);for(let t in p){var r,a,u;let n=p[t],s=e||d.has(t)||null!=n.parent_id&&d.has(n.parent_id),o=i.unreadByType[N.P.CHANNEL],{mentionCount:l,unread:f,isMentionLowImportance:g}=m.Ay.getGuildChannelUnreadState(n,h,_,s,o),I=l>0;if(!I&&s)continue;let T=!o&&(!s||I)&&f;(T||I)&&(r=n,a=l,u=h,!((0,c.ay)(r.type)&&0===a||!E.A.canBasicChannel((0,c.pd)(r.type),r)||L(r,a,u))&&!("flags"in r&&r.hasFlag(S.lx.IS_GUILD_RESOURCE_CHANNEL))&&(a>0||A.Ay.resolveUnreadSetting(r)===N.e.ALL_MESSAGES))&&(T&&(i.unreadByType[N.P.CHANNEL]=!0,i.unreadChannelId=t),I&&(g?i.lowImportanceMentionCount+=l:i.highImportanceMentionCount+=l,i.mentionCounts[n.id]={count:l,isMentionLowImportance:g}))}let g=o.A.getActiveJoinedThreadsForGuild(n);for(let t in g)for(let n in g[t]){!i.unreadByType[N.P.CHANNEL]&&m.Ay.hasUnread(n)&&!l.A.isMuted(n)&&!e&&(i.unreadByType[N.P.CHANNEL]=!0,i.unreadChannelId=n);let t=m.Ay.getMentionCount(n),r=m.Ay.getIsMentionLowImportance(n);t>0&&(r?i.lowImportanceMentionCount+=t:i.highImportanceMentionCount+=t,i.mentionCounts[n]={count:t,isMentionLowImportance:r})}!i.unreadByType[N.P.GUILD_EVENT]&&P(n,N.P.GUILD_EVENT)&&(i.unreadByType[N.P.GUILD_EVENT]=!0)}U(i);let d=b(n);return(i.unread!==d.unread||i.highImportanceMentionCount!==d.highImportanceMentionCount||i.lowImportanceMentionCount!==d.lowImportanceMentionCount)&&(C[n??y]=i,null!=n&&(i.unread?v.add(n):v.delete(n)),O++,D(n??y),k(i,d),!0)}function H(e){let{guilds:t}=e;C={},O=0,v=new Set,B(null);let{length:n}=t;for(let e=0;e<n;e++){let n=t[e];null!=n&&B(n.properties.id)}}function j(e){let{guilds:t,readState:n}=e;C={},O=0,v=new Set;let i=n.entries.length<500,r=new Set;for(let e of(i&&n.entries.forEach(e=>{null!=e.mention_count&&e.mention_count>0&&(null==e.read_state_type||e.read_state_type===N.P.CHANNEL?r.add(f.A.getChannel(e.id)?.guild_id):r.add(e.id))}),B(null),t))B(e.id,i?r.has(e.id):void 0)}function Y(){for(let e of(C={},v=new Set,B(null),Object.values(h.A.getGuildIds())))B(e)}function W(e){let{guild:t}=e;return B(t.id)}function K(e){let{guild:t}=e;return null!=C[t.id]&&(delete C[t.id],v.delete(t.id),O++,!0)}function z(e){let{channel:{id:t,guild_id:n}}=e;return F(n,[t])}function $(){let e=f.A.getChannel(g.A.getChannelId());return null!=e&&F(e.getGuildId(),[e.id])}function q(e){let{user:t,guildId:n}=e;return t.id===_.default.getId()&&B(n)}function Z(e){let{channelId:t}=e,n=f.A.getChannel(t);return null!=n&&F(n.getGuildId(),[n.id])}function X(e){let{channelId:t}=e,n=f.A.getChannel(t);if(null==n)return!1;if(null!=n.guild_id){let e=b(n.guild_id);if(((n.isThread()?!l.A.hasJoined(n.id)||l.A.isMuted(n.id):A.Ay.isGuildOrCategoryOrChannelMuted(n.guild_id,n.id))||e.unreadByType[N.P.CHANNEL])&&0===m.Ay.getMentionCount(t))return!1}return F(n.getGuildId(),[n.id])}function Q(e){let{channelId:t,guildId:n}=e;return n!==T.YYv&&null!=t&&F(n,[t])}function J(e){let{channel:t}=e;return F(t.getGuildId(),[t.id])}function ee(e){let{channels:t}=e;return r()(t).groupBy(e=>e.getGuildId()).reduce((e,t,n)=>F(n,t.map(e=>e.id))||e,!1)}function et(e){let{channels:t}=e;return r()(t).map(e=>{let{channelId:t}=e;return t}).filter(e=>null!=f.A.getChannel(e)).groupBy(e=>f.A.getChannel(e)?.getGuildId()).reduce((e,t,n)=>F(n,t)||e,!1)}function en(e){let{channel:t}=e;return F(t.getGuildId(),[t.id,t.parent_id])}function ei(e){let{guildScheduledEvent:t}=e;return V(t.guild_id,N.P.GUILD_EVENT)}function er(e){let{guildScheduledEvent:t}=e;return V(t.guild_id,N.P.GUILD_EVENT)}function es(e){let{id:t,ackType:n}=e;return V(t,n)}function ea(e){let{id:t,guildId:n}=e;return F(n,[t])}function eo(e){return(0,u.k)(e)&&F(e.guildId,[e.id])}function el(e){let{threads:t,guildId:n}=e;return F(n,t.filter(e=>l.A.hasJoined(e.id)).map(e=>e.id))}function eu(e){return e.channels.length>0&&F(e.guildId,e.channels.map(e=>e.id))}function ec(e){let{guildId:t}=e;return B(t)}function ed(e){let{guildId:t}=e;return B(t)}function e_(e){let{userGuildSettings:t}=e,n=new Set(t.map(e=>e.guild_id??y));return d.default.keys(C).reduce((e,t)=>n.has(t)&&B(t)||e,!1)}function ef(){for(let e in C)C[e].ncMentionCount=0}function eh(e){let{guildId:t}=e;return B(t)}function ep(e){let{messages:t}=e;new Set(t.map(e=>e.channel_id)).forEach(e=>{let t=f.A.getChannel(e);null!=t&&F(t.getGuildId(),[e])})}class eE extends p.A{static displayName="GuildReadStateStore";static LATEST_SNAPSHOT_VERSION=1;constructor(){super({CONNECTION_OPEN:j,OVERLAY_INITIALIZE:H,CACHE_LOADED_LAZY:()=>this.loadCache(),GUILD_CREATE:W,GUILD_DELETE:K,MESSAGE_CREATE:X,MESSAGE_ACK:Z,BULK_ACK:et,UPDATE_CHANNEL_DIMENSIONS:Z,CHANNEL_SELECT:Q,CHANNEL_DELETE:z,WINDOW_FOCUS:$,GUILD_ACK:ec,GUILD_ROLE_CREATE:ed,GUILD_ROLE_DELETE:ed,GUILD_ROLE_UPDATE:ed,CHANNEL_CREATE:J,CHANNEL_UPDATES:ee,THREAD_CREATE:en,THREAD_UPDATE:en,THREAD_DELETE:en,THREAD_LIST_SYNC:el,THREAD_MEMBER_UPDATE:ea,THREAD_MEMBERS_UPDATE:eo,PASSIVE_UPDATE_V2:eu,GUILD_MEMBER_UPDATE:q,USER_GUILD_SETTINGS_FULL_UPDATE:e_,USER_GUILD_SETTINGS_CHANNEL_UPDATE:eh,USER_GUILD_SETTINGS_CHANNEL_UPDATE_BULK:eh,USER_GUILD_SETTINGS_GUILD_UPDATE:eh,USER_GUILD_SETTINGS_GUILD_AND_CHANNELS_UPDATE:eh,GUILD_FEATURE_ACK:es,GUILD_SCHEDULED_EVENT_CREATE:ei,GUILD_SCHEDULED_EVENT_UPDATE:ei,GUILD_SCHEDULED_EVENT_DELETE:er,CHANNEL_RTC_UPDATE_CHAT_OPEN:Z,LOAD_MESSAGES_SUCCESS:Z,CHANNEL_ACK:Z,CHANNEL_LOCAL_ACK:Z,NOTIFICATION_SETTINGS_UPDATE:Y,RECOMPUTE_READ_STATES:Y,VOICE_CHANNEL_SELECT:Z,ENABLE_AUTOMATIC_ACK:Z,RESORT_THREADS:Z,NOTIFICATION_CENTER_CLEAR_GUILD_MENTIONS:ef,TRY_ACK:Z,LOAD_RECENT_MENTIONS_SUCCESS:ep})}initialize(){this.waitFor(f.A,g.A,m.Ay,E.A,_.default,I.default,A.Ay,o.A,l.A,a.Ay)}loadCache(){let e=this.readSnapshot(eE.LATEST_SNAPSHOT_VERSION);null!=e&&(C=e.guilds,v=new Set(e.unreadGuilds))}takeSnapshot(){return{version:eE.LATEST_SNAPSHOT_VERSION,data:{guilds:C,unreadGuilds:Array.from(v)}}}hasAnyUnread(){return v.size>0}getStoreChangeSentinel(){return O}getMutableUnreadGuilds(){return v}getMutableGuildStates(){return C}shouldCountChannelUnread(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return w(e,t,!0)}hasUnread(e){return v.has(e)}getMentionCount(e){let t=b(e);return t.highImportanceMentionCount+t.lowImportanceMentionCount}getIsMentionLowImportance(e){return 0===b(e).highImportanceMentionCount}getGuildHasUnreadIgnoreMuted(e){let t=f.A.getMutableGuildChannelsForGuild(e);for(let e in t){let n=t[e];if(null!=n&&(!n.isGuildVocal()||0!==m.Ay.getMentionCount(e))&&E.A.can(n.accessPermissions,n)&&m.Ay.hasUnreadOrMentions(e))return!0}let n=o.A.getActiveJoinedThreadsForGuild(e);for(let e in n)if(null!=f.A.getChannel(e)){for(let t in n[e])if(m.Ay.hasUnreadOrMentions(t))return!0}return!!m.Ay.hasUnreadOrMentions(e,N.P.GUILD_EVENT)}getTotalMentionCount(e){let t=0;for(let n in C){let i=C[n];(!0!==e||n!==y)&&(t+=i.highImportanceMentionCount)}return t}getTotalNotificationsMentionCount(e){let t=0;for(let n in C){let i=C[n];(!0!==e||n!==y)&&(t+=i.ncMentionCount)}return t}getPrivateChannelMentionCount(){let e=C[y];return e?.highImportanceMentionCount??0}getMentionCountForPrivateChannel(e){return C[y]?.mentionCounts[e]??0}getGuildChangeSentinel(e){return b(e).sentinel}}let em=new eE}