Build 574548stable
Module 458294
10,556 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(280450),h=n(734057),f=n(71393),E=n(536802),p=n(576705),m=n(568548),g=n(309010),A=n(543465),I=n(287809),T=n(652215),S=n(746080),N=n(790782);let C=T.eGj,y={},O=new Set,R=0;function v(e){let t=y[e??C];return{unread:!1,unreadByType:{},unreadChannelId:null,lowImportanceMentionCount:0,highImportanceMentionCount:0,mentionCounts:{},ncMentionCount:0,sentinel:t?.sentinel??0}}function b(e){return y[e??C]=y[e??C]??v(e)}function L(e){let t=b(e);t.sentinel++,R++}function D(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()&&(D(e,t,(0,s.WW)(e.guild_id))||!p.A.can(e.accessPermissions,e)))&&(t>0||A.Ay.resolveUnreadSetting(e)===N.e.ALL_MESSAGES)}function P(e){switch(e){case C:case null:case void 0:return null;default:return e}}function M(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=v(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)&&(y[e??C]=t,null!=e&&(t.unread?O.add(e):O.delete(e)),R++,L(e??C),k(t,n),!0)}function V(e,t){let n=P(e),i=b(n),r=x(n,i),s=!1;if(t.forEach(e=>{let t=h.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=h.A.getChannel(i.unreadChannelId);if(!(null!=e&&!t.includes(e.id)&&m.Ay.hasUnread(e.id)&&w(e)))return B(n);null!=n&&O.add(n),r.unreadByType[N.P.CHANNEL]=!0}return G(n,r,i)}function F(e,t){if(null==e)return;let n=b(e),i=x(e,n);return i.unreadByType[N.P.GUILD_EVENT]=M(e,t),G(e,i,n)}function B(e,t){let n=P(e),i=v(n);if(null==n){let e=h.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),f=(0,s.WW)(n),E=h.A.getMutableBasicGuildChannelsForGuild(n);for(let t in E){var r,a,u;let n=E[t],s=e||d.has(t)||null!=n.parent_id&&d.has(n.parent_id),o=i.unreadByType[N.P.CHANNEL],{mentionCount:l,unread:h,isMentionLowImportance:g}=m.Ay.getGuildChannelUnreadState(n,f,_,s,o),I=l>0;if(!I&&s)continue;let T=!o&&(!s||I)&&h;(T||I)&&(r=n,a=l,u=f,!((0,c.ay)(r.type)&&0===a||!p.A.canBasicChannel((0,c.pd)(r.type),r)||D(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]&&M(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)&&(y[n??C]=i,null!=n&&(i.unread?O.add(n):O.delete(n)),R++,L(n??C),k(i,d),!0)}function H(e){let{guilds:t}=e;y={},R=0,O=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;y={},R=0,O=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(h.A.getChannel(e.id)?.guild_id):r.add(e.id))}),B(null),t))B(e.id,i?r.has(e.id):void 0)}function W(){for(let e of(y={},O=new Set,B(null),Object.values(f.A.getGuildIds())))B(e)}function Y(e){let{guild:t}=e;return B(t.id)}function K(e){let{guild:t}=e;return null!=y[t.id]&&(delete y[t.id],O.delete(t.id),R++,!0)}function $(e){let{channel:{id:t,guild_id:n}}=e;return V(n,[t])}function z(){let e=h.A.getChannel(g.A.getChannelId());return null!=e&&V(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=h.A.getChannel(t);return null!=n&&V(n.getGuildId(),[n.id])}function X(e){let{channelId:t}=e,n=h.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 V(n.getGuildId(),[n.id])}function Q(e){let{channelId:t,guildId:n}=e;return n!==T.YYv&&null!=t&&V(n,[t])}function J(e){let{channel:t}=e;return V(t.getGuildId(),[t.id])}function ee(e){let{channels:t}=e;return r()(t).groupBy(e=>e.getGuildId()).reduce((e,t,n)=>V(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!=h.A.getChannel(e)).groupBy(e=>h.A.getChannel(e)?.getGuildId()).reduce((e,t,n)=>V(n,t)||e,!1)}function en(e){let{channel:t}=e;return V(t.getGuildId(),[t.id,t.parent_id])}function ei(e){let{guildScheduledEvent:t}=e;return F(t.guild_id,N.P.GUILD_EVENT)}function er(e){let{guildScheduledEvent:t}=e;return F(t.guild_id,N.P.GUILD_EVENT)}function es(e){let{id:t,ackType:n}=e;return F(t,n)}function ea(e){let{id:t,guildId:n}=e;return V(n,[t])}function eo(e){return(0,u.k)(e)&&V(e.guildId,[e.id])}function el(e){let{threads:t,guildId:n}=e;return V(n,t.filter(e=>l.A.hasJoined(e.id)).map(e=>e.id))}function eu(e){return e.channels.length>0&&V(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??C));return d.default.keys(y).reduce((e,t)=>n.has(t)&&B(t)||e,!1)}function eh(){for(let e in y)y[e].ncMentionCount=0}function ef(e){let{guildId:t}=e;return B(t)}function eE(e){let{messages:t}=e;new Set(t.map(e=>e.channel_id)).forEach(e=>{let t=h.A.getChannel(e);null!=t&&V(t.getGuildId(),[e])})}class ep extends E.A{static displayName="GuildReadStateStore";static LATEST_SNAPSHOT_VERSION=1;constructor(){super({CONNECTION_OPEN:j,OVERLAY_INITIALIZE:H,CACHE_LOADED_LAZY:()=>this.loadCache(),GUILD_CREATE:Y,GUILD_DELETE:K,MESSAGE_CREATE:X,MESSAGE_ACK:Z,BULK_ACK:et,UPDATE_CHANNEL_DIMENSIONS:Z,CHANNEL_SELECT:Q,CHANNEL_DELETE:$,WINDOW_FOCUS:z,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:ef,USER_GUILD_SETTINGS_CHANNEL_UPDATE_BULK:ef,USER_GUILD_SETTINGS_GUILD_UPDATE:ef,USER_GUILD_SETTINGS_GUILD_AND_CHANNELS_UPDATE:ef,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:W,RECOMPUTE_READ_STATES:W,VOICE_CHANNEL_SELECT:Z,ENABLE_AUTOMATIC_ACK:Z,RESORT_THREADS:Z,NOTIFICATION_CENTER_CLEAR_GUILD_MENTIONS:eh,TRY_ACK:Z,LOAD_RECENT_MENTIONS_SUCCESS:eE})}initialize(){this.waitFor(h.A,g.A,m.Ay,p.A,_.default,I.default,A.Ay,o.A,l.A,a.Ay)}loadCache(){let e=this.readSnapshot(ep.LATEST_SNAPSHOT_VERSION);null!=e&&(y=e.guilds,O=new Set(e.unreadGuilds))}takeSnapshot(){return{version:ep.LATEST_SNAPSHOT_VERSION,data:{guilds:y,unreadGuilds:Array.from(O)}}}hasAnyUnread(){return O.size>0}getStoreChangeSentinel(){return R}getMutableUnreadGuilds(){return O}getMutableGuildStates(){return y}shouldCountChannelUnread(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return w(e,t,!0)}hasUnread(e){return O.has(e)}getMentionCount(e){let t=b(e);return t.highImportanceMentionCount+t.lowImportanceMentionCount}getIsMentionLowImportance(e){return 0===b(e).highImportanceMentionCount}getGuildHasUnreadIgnoreMuted(e){let t=h.A.getMutableGuildChannelsForGuild(e);for(let e in t){let n=t[e];if(null!=n&&(!n.isGuildVocal()||0!==m.Ay.getMentionCount(e))&&p.A.can(n.accessPermissions,n)&&m.Ay.hasUnreadOrMentions(e))return!0}let n=o.A.getActiveJoinedThreadsForGuild(e);for(let e in n)if(null!=h.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 y){let i=y[n];(!0!==e||n!==C)&&(t+=i.highImportanceMentionCount)}return t}getTotalNotificationsMentionCount(e){let t=0;for(let n in y){let i=y[n];(!0!==e||n!==C)&&(t+=i.ncMentionCount)}return t}getPrivateChannelMentionCount(){let e=y[C];return e?.highImportanceMentionCount??0}getMentionCountForPrivateChannel(e){return y[C]?.mentionCounts[e]??0}getHighImportanceMentionCountForChannel(e,t){let n=y[e??C]?.mentionCounts[t];return null==n||n.isMentionLowImportance?0:n.count}getGuildChangeSentinel(e){return b(e).sentinel}}let em=new ep}