Build 576754stable
Module 90924
5,752 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{BB:()=>X,B_:()=>W,D2:()=>ee,Gc:()=>B,IR:()=>j,LP:()=>H,SK:()=>Y,SN:()=>k,Ub:()=>Q,Yj:()=>F,e2:()=>q,hk:()=>G,lG:()=>J,px:()=>K,qG:()=>V,sq:()=>Z,uM:()=>z}),n(321073),n(938796),n(735438);var i=n(567243),r=n(179771),a=n(636537),s=n(898467),l=n(493336),o=n(956518),d=n(587895),c=n(46054),u=n(763754),_=n(395671),E=n(95701),A=n(889227),h=n(734057),I=n(71393),f=n(451409),p=n(232835),T=n(290863),m=n(287809),g=n(977997),S=n(927813),N=n(562153),C=n(257120),R=n(998218),O=n(636401),L=n(639621),D=n(613057),y=n(652215);let v=R.A.toURLSafe(window.GLOBAL_ENV.API_ENDPOINT)?.host??"localhost",b=function(){let e=v.split(":")[0];if(!e.includes("."))return e;let t=e.split("."),n=t[t.length-1];return/^\d+$/.test(n)?e:t.slice(-2).join(".")}(),M=RegExp(`^${C.A.escape("https://")}(?:[a-z]+\\.)?(${C.A.escape(b)}|discordapp.com|discord.com)$`),P=+S.A.Millis.MINUTE,U={};function w(e){return"customEmoji"===e.type&&(e.type="emoji"),"emoji"===e.type&&e.src&&(e.src=G(e.src)),Array.isArray(e.content)&&(e.content=e.content.map(w)),e}function G(e){return/^http/.test(e)?e:`${location.protocol}//${location.host}${"/"===e.charAt(0)?"":"/"}${e}`}function x(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return t.indexOf(e)>-1}function k(e,t){let n=[],i=e.getGuildId();return[y.rbe.GUILD_CATEGORY,...E.OU].includes(e.type)||n.push(new Promise(t=>{p.A.whenReady(e.id,()=>t()),l.A.fetchMessages({channelId:e.id,limit:y.EMb})})),Promise.all(n).then(()=>{let n=(!e.isNSFW()||m.default.getCurrentUser()?.nsfwAllowed===!0)&&t?p.A.getMessages(e.id).toArray().map(F):[],r=Object.values(g.A.getVoiceStatesForChannel(e.id)).map(t=>V(i,e.id,t));return{id:e.id,name:e.name,type:e.type,topic:e.topic,bitrate:e.bitrate,user_limit:e.userLimit,guild_id:i,position:e.position,messages:n,voice_states:r}})}function F(e){let t=c.A.parseToAST(e.content,!0,{channelId:e.channel_id}).map(w),n=h.A.getChannel(e.channel_id),i=null!=e.author?new A.A(e.author):void 0,r=null!=e.author?(0,u.FT)(i,n):void 0;return{id:e.id,blocked:e.blocked,bot:e.bot,content:e.content,content_parsed:t.length?t:void 0,nick:r?.nick,author_color:r?.colorString,edited_timestamp:e.edited_timestamp||e.editedTimestamp,timestamp:e.timestamp,tts:e.tts,mentions:e.mentions,mention_everyone:e.mention_everyone||e.mentionEveryone,mention_roles:e.mention_roles||e.mentionRoles,embeds:e.embeds,attachments:e.attachments,author:null!=i?(0,L.A)(i):void 0,pinned:e.pinned,type:e.type}}function V(e,t,n){let{mute:i,deaf:r,selfMute:a,selfDeaf:s,suppress:l,userId:o}=n,d=m.default.getUser(o);if(null==d)throw Error(`Invalid user id: ${o}`);return{nick:N.Ay.getName(e,t,d),mute:f.Ay.isLocalMute(d.id),volume:f.Ay.getLocalVolume(d.id),pan:f.Ay.getLocalPan(d.id),voice_state:{mute:i,deaf:r,self_mute:a,self_deaf:s,suppress:l},user:(0,L.A)(d)}}function B(e,t){return{type:e,user:(0,L.A)(t),presence:{status:T.A.getStatus(t.id,null),activity:null}}}function H(e,t){return null==t?e:{...e,presence:{...e.presence,activity:T.A.getApplicationActivity(e.user.id,t)??null}}}function j(e){let t;if(null==e)return!1;let n=window.location.origin;if(e===n)return!0;try{t=i.parse(e).hostname}catch(e){return!1}return window.location.hostname===t&&"localhost"===t||null==e.match("staging")&&!!(M.test(e)&&M.test(n))}function W(e,t,n){let i=I.A.getGuild(e.getGuildId());return(null!=i?i.application_id:e.getApplicationId())===t||n.indexOf(r.F.MESSAGES_READ)>-1}function Y(e){switch(e){case y.S7L.RTC_CONNECTED:case y.S7L.RTC_CONNECTING:case y.S7L.RTC_DISCONNECTED:return e.replace(/^RTC_/,"VOICE_");default:return e}}function K(e,t,n){return e===y.xL.JOIN&&null!=t&&null!=t.id&&null!=n.join}function $(e){return a.Bo.get({url:y.Rsh.APPLICATION_RPC(e),oldFormErrors:!0,retries:3,rejectWithError:!0}).then(e=>{let{body:t}=e;return t},()=>{throw new O.A({closeCode:y.YI$.INVALID_CLIENTID},"Invalid Client ID")})}async function z(e,t,n){let i=d.A.getApplication(t);if("string"==typeof n)if(e.transport===D.z4.POST_MESSAGE){let e=(0,o.Ay)(t);if(null==e||!x(n,[e]))throw new O.A({closeCode:y.YI$.INVALID_ORIGIN},"Invalid Origin")}else{let e=await $(t);if(i=_.Ay.createFromServer(e),!x(n,e.rpc_origins))throw new O.A({closeCode:y.YI$.INVALID_ORIGIN},"Invalid Origin")}null==i&&(i=_.Ay.createFromServer(await $(t)));let{id:r,name:a,icon:s,coverImage:l,flags:c,parentId:u}=i;e.application={id:r,parentId:u,name:a,icon:s,coverImage:l,flags:c}}async function q(e,t,n){let i=U[e];null==i&&(i=new s.A(t?2:60,P),U[e]=i);try{await i.process(n)}catch(e){throw new O.A({closeCode:y.YI$.CLOSE_ABNORMAL},"Socket closed during throttle")}}function Z(e,t){null==t&&(e.authorization.scopes=[D.hj])}function X(e){let t=f.Ay.getSettings();function n(e){return Object.values(e).sort((e,t)=>e.index-t.index).map(e=>({id:e.id,name:e.name}))}let i=e(t);return{input:{available_devices:n(f.Ay.getInputDevices()),device_id:t.inputDeviceId,volume:t.inputVolume},output:{available_devices:n(f.Ay.getOutputDevices()),device_id:t.outputDeviceId,volume:t.outputVolume},mode:{type:t.mode,auto_threshold:t.modeOptions.autoThreshold,threshold:t.modeOptions.threshold,shortcut:i,delay:t.modeOptions.delay},automatic_gain_control:t.automaticGainControl,echo_cancellation:t.echoCancellation,noise_suppression:t.noiseSuppression,qos:t.qos,silence_warning:t.silenceWarning,deaf:t.deaf,mute:t.mute}}function Q(e,t){let n=f.Ay.getSettings(e),i=t(n);return{input_mode:{type:n.mode,shortcut:i},local_mutes:Object.keys(n.localMutes),local_volumes:n.localVolumes,self_mute:n.mute,self_deaf:n.deaf}}function J(e){if(e!==D.z4.POST_MESSAGE)throw new O.A({errorCode:y.Lw6.INVALID_COMMAND},`command not available from "${e} transport`)}function ee(e){if(null==e.id)throw new O.A({errorCode:y.Lw6.INVALID_COMMAND},"Invalid application");return e.id}}