Module 808728

5,074 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ay:()=>Y,I6:()=>S,vM:()=>N}),n(321073);var i=n(735438),r=n.n(i),a=n(136722),s=n(17928),l=n(228366),o=n(717125),d=n(47167),c=n(181079),u=n(424345),_=n(95701),E=n(488926),A=n(280450),h=n(734057),I=n(696451),f=n(71393),p=n(576705),T=n(994500),m=n(287809),g=n(652215);let S="SELECTABLE",N="VOCAL",C=null,R={},O={},L={},D=null,y={},v={comparator:-1,channel:(0,_.createChannelRecord)({id:g._Ee,type:g.rbe.GUILD_CATEGORY,name:"Uncategorized"})},b=U(g.eGj),M=[],P={};function U(e){return{id:e,[S]:[],[N]:[],[g.rbe.GUILD_CATEGORY]:[v],count:0}}function w(e,t){let{comparator:n}=e,{comparator:i}=t;return n-i}function G(){R={},y={},O={},L={},null!=C&&x(C)}function x(e){var t,n;let i,a,s=U(e);return R[e]=s,y[e]=[],!function(e){let{id:t}=e,n=function(e){if(e===g.YYv)return function(){let e={},t=c.A.getFavoriteChannels();for(let n in t){let i=h.A.getChannel(n);if(null==i)continue;let r=t[n],a=(0,u.K)(t,r,i);e[n]={channel:a,comparator:a.position}}return e}();let t={},n=h.A.getMutableGuildChannelsForGuild(e);for(let e in n)t[e]={channel:n[e],comparator:n[e].position};return t}(t);r().forEach(n,n=>{var i;let r=n.channel;if(e.count+=1,_.JT.has(r.type)&&!p.A.can(g.xBc.VIEW_CHANNEL,r)&&!o.A.isChannelGated(r.guild_id,r.id)&&r.id!==D)return;let a=(i=r.type,(0,_.tr)(i)?S:(0,_.ay)(i)?N:i);r.type===g.rbe.GUILD_DIRECTORY&&(null==y[t]&&(y[t]=[]),y[t].push(n)),null!=e[a]&&e[a].push(n)})}(s),s[S].sort(w),s[N].sort(w),s[g.rbe.GUILD_CATEGORY].sort(w),i=O[(t=s).id]={},a={},t[S].forEach(e=>{let{channel:t}=e,n=(0,d.m1)(t,m.default,T.A),r=Object.prototype.hasOwnProperty.call(a,n)?a[n]:null;null==r?a[n]=1:(a[n]=r+1,n+=`~${r}`),i[t.id]={id:t.id,name:n}}),n=e,!function(e,t){let n=f.A.getGuild(t);if(null!=n&&B(e,n))return!0;let i=R[t];null==i&&(i=x(t));let{[S]:r,[N]:a}=i;for(let{channel:t}of r)if(B(e,t))return!0;for(let{channel:t}of a)if(B(e,t))return!0;return!1}(m.default.getCurrentUser(),n)?delete L[n]:L[n]=!0,s}function k(e){let{guild:{id:t}}=e;if(null==t)return!1;R[t]=void 0,C===t&&x(t)}function F(e){let{channel:{guild_id:t}}=e;if(null==t)return!1;R[t]=void 0,t===C&&x(t)}function V(e){let{guildId:t}=e;R[t]=void 0,t===C&&x(t)}function B(e,t){return a.X8(E.cc({user:e,context:t,checkElevated:!1}),g.Lti)}function H(e,t){D=t;let n=e?.getGuildId()??null;return null!=n&&(R[n]=void 0,n===C&&x(n),!0)}function j(){x(g.YYv)}class W extends s.Ay.Store{static displayName="GuildChannelStore";initialize(){this.waitFor(A.default,h.A,c.A,o.A,I.Ay,f.A,p.A,m.default),this.syncWith([c.A],j)}getAllGuilds(){return R}getChannels(e){let t;return null!=e?(null==(t=R[e])&&(t=x(e)),t):b}getFirstChannelOfType(e,t,n){let i=this.getChannels(e)[n].find(t);return null!=i?i.channel:null}getFirstChannel(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.getFirstChannelOfType(e,t,S)??(n?this.getFirstChannelOfType(e,t,N):null)}getDefaultChannel(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:g.xBc.VIEW_CHANNEL;return this.getFirstChannel(e,e=>p.A.can(n,e.channel),t)}getSFWDefaultChannel(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:g.xBc.VIEW_CHANNEL;return this.getFirstChannel(e,e=>p.A.can(n,e.channel)&&!e.channel.nsfw,t)}getSelectableChannelIds(e){return this.getChannels(e)[S].map(e=>{let{channel:t}=e;return t.id})}getSelectableChannels(e){return this.getChannels(e)[S]}getVocalChannelIds(e){return this.getChannels(e)[N].map(e=>{let{channel:t}=e;return t.id})}getDirectoryChannelIds(e){return y[e]?.map(e=>{let{channel:t}=e;return t.id})??M}hasSelectableChannel(e,t){return this.getSelectableChannelIds(e).includes(t)}hasElevatedPermissions(e){return L[e]||!1}hasChannels(e){return this.getChannels(e).count>0}hasCategories(e){return this.getChannels(e)[g.rbe.GUILD_CATEGORY].length>1}getTextChannelNameDisambiguations(e){return null!=e?O[e]??P:P}}let Y=new W(l.h,{BACKGROUND_SYNC:G,CHANNEL_SELECT:function(e){let{guildId:t}=e;if(C=t??null,null==t||null!=R[t])return!1;x(t)},CONNECTION_OPEN:G,OVERLAY_INITIALIZE:G,CACHE_LOADED_LAZY:G,GUILD_CREATE:k,GUILD_UPDATE:k,GUILD_DELETE:function(e){let{guild:{id:t}}=e;return delete R[t],delete O[t],delete L[t],delete y[t],!0},GUILD_MEMBER_UPDATE:function(e){let{guildId:t,user:n}=e;if(A.default.getId()!==n.id)return!1;R[t]=void 0,t===C&&x(t)},CHANNEL_CREATE:F,CHANNEL_DELETE:F,CHANNEL_UPDATES:function(e){let{channels:t}=e,n=!1;for(let e of t){let{guild_id:t}=e;null!=t&&(R[t]=void 0,n=!0,C===t&&x(t))}return n},GUILD_ROLE_CREATE:V,GUILD_ROLE_UPDATE:V,GUILD_ROLE_DELETE:V,IMPERSONATE_UPDATE:V,IMPERSONATE_STOP:V,VOICE_CHANNEL_SELECT:function(e){let{channelId:t}=e;return null==t&&null!=D?H(h.A.getChannel(D),null):H(h.A.getChannel(t),t)},VOICE_CHANNEL_STATUS_UPDATE:function(e){let t=h.A.getBasicChannel(e.id);null!=t&&null!=t.guild_id&&x(t.guild_id)},VOICE_STATE_UPDATES:function(e){let{voiceStates:t}=e;return t.reduce((e,t)=>{let{channelId:n,sessionId:i}=t;return A.default.getSessionId()!==i?e:H(h.A.getChannel(n),n)||e},!1)}})}