BetterDiscordApp-rauenzi/js/main.min.js

52 lines
86 KiB
JavaScript

(function(){let t=window.require("fs"),a=window.require("process"),o=a.platform,l=("win32"===o?a.env.APPDATA:"darwin"===o?a.env.HOME+"/Library/Preferences":process.env.HOME+"/.config")+"/BetterDiscord/",d="localStorage.json",u={};if(t.existsSync(`${l}${d}`))try{u=JSON.parse(t.readFileSync(`${l}${d}`))}catch(b){console.log(b)}else if(t.existsSync(d))try{u=JSON.parse(t.readFileSync(d))}catch(b){console.log(b)}var h=u;h.setItem=function(b,f){h[b]=f,this.save()},h.getItem=function(b){return h[b]||null},h.save=function(){t.writeFileSync(`${l}${d}`,JSON.stringify(this),null,4)};var g=new Proxy(h,{set:function(b,f,y){h[f]=y,h.save()},get:function(b,f){return h[f]||null}});window.localStorage=g})(),(()=>{let t=document.createElement("div");t.className="bd-loaderv2",t.title="BetterDiscord is loading...",document.body.appendChild(t)})(),window.bdStorage={},window.bdStorage.get=function(t){return betterDiscordIPC.sendSync("synchronous-message",{arg:"storage",cmd:"get","var":t})},window.bdStorage.set=function(t,a){betterDiscordIPC.sendSync("synchronous-message",{arg:"storage",cmd:"set","var":t,data:a})},window.bdPluginStorage={},window.bdPluginStorage.get=function(t,a){return betterDiscordIPC.sendSync("synchronous-message",{arg:"pluginstorage",cmd:"get",pn:t,"var":a})},window.bdPluginStorage.set=function(t,a,o){betterDiscordIPC.sendSync("synchronous-message",{arg:"pluginstorage",cmd:"set",pn:t,"var":a,data:o})};var bdSettings={},bdSettingsStorage={},releaseChannel=DiscordNative.globals.releaseChannel;bdSettingsStorage.initialize=function(){let t=require("fs"),a={stable:{},canary:{},ptb:{}};if(t.existsSync(bdConfig.dataPath+"/bdsettings.json"))try{a=JSON.parse(t.readFileSync(bdConfig.dataPath+"/bdsettings.json")),a.hasOwnProperty("settings")&&(a={[releaseChannel]:a})}catch(o){a={stable:{},canary:{},ptb:{}}}bdSettings=a?a:{stable:{},canary:{},ptb:{}}},bdSettingsStorage.get=function(t){return bdSettings[releaseChannel][t]?bdSettings[releaseChannel][t]:null},bdSettingsStorage.set=function(t,a){let o=require("fs");bdSettings[releaseChannel][t]=a;try{return o.writeFileSync(bdConfig.dataPath+"/bdsettings.json",JSON.stringify(bdSettings,null,4)),!0}catch(l){return Utils.err(l),!1}};var settingsPanel,emoteModule,quickEmoteMenu,voiceMode,pluginModule,themeModule,dMode,publicServersModule,jsVersion=1.792,supportedVersion="0.2.81",bbdVersion="0.1.1",mainCore,settings={"Save logs locally":{id:"bda-gs-0",info:"Saves chat logs locally",implemented:!1,hidden:!1,cat:"core"},"Public Servers":{id:"bda-gs-1",info:"Display public servers button",implemented:!0,hidden:!1,cat:"core"},"Minimal Mode":{id:"bda-gs-2",info:"Hide elements and reduce the size of elements.",implemented:!0,hidden:!1,cat:"core"},"Voice Mode":{id:"bda-gs-4",info:"Only show voice chat",implemented:!0,hidden:!1,cat:"core"},"Hide Channels":{id:"bda-gs-3",info:"Hide channels in minimal mode",implemented:!0,hidden:!1,cat:"core"},"Dark Mode":{id:"bda-gs-5",info:"Make certain elements dark by default(wip)",implemented:!0,hidden:!1,cat:"core"},"Override Default Emotes":{id:"bda-es-5",info:"Override default emotes",implemented:!1,hidden:!1,cat:"core"},"Voice Disconnect":{id:"bda-dc-0",info:"Disconnect from voice server when closing Discord",implemented:!0,hidden:!1,cat:"core"},"Custom css live update":{id:"bda-css-0",info:"",implemented:!0,hidden:!0,cat:"core"},"Custom css auto udpate":{id:"bda-css-1",info:"",implemented:!0,hidden:!0,cat:"core"},"24 Hour Timestamps":{id:"bda-gs-6",info:"Replace 12hr timestamps with proper ones",implemented:!0,hidden:!1,cat:"core"},"Coloured Text":{id:"bda-gs-7",info:"Make text colour the same as role colour",implemented:!0,hidden:!1,cat:"core"},"BetterDiscord Blue":{id:"bda-gs-b",info:"Replace Discord blue with BD Blue",implemented:!0,hidden:!1,cat:"core"},"Developer Mode":{id:"bda-gs-8",info:"Developer Mode",implemented:!0,hidden:!1,cat:"core"},"Startup Error Modal":{id:"fork-ps-1",info:"Show a modal with plugin/theme errors on startup",implemented:!0,hidden:!1,cat:"fork"},"Show Toasts":{id:"fork-ps-2",info:"Shows a small notification for starting and stopping plugins & themes",implemented:!0,hidden:!1,cat:"fork"},"Scroll To Settings":{id:"fork-ps-3",info:"Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)",implemented:!0,hidden:!1,cat:"fork"},"Animate On Hover":{id:"fork-es-2",info:"Only animate the emote modifiers on hover",implemented:!0,hidden:!1,cat:"fork"},"Copy Selector":{id:"fork-dm-1",info:"Adds a \"Copy Selector\" option to context menus when developer mode is active",implemented:!0,hidden:!1,cat:"fork"},"Download Emotes":{id:"fork-es-3",info:"Download emotes when the cache is expired",implemented:!0,hidden:!1,cat:"fork"},"Normalize Classes":{id:"fork-ps-4",info:"Adds stable classes to elements to help themes. (e.g. adds .da-channels to .channels-Ie2l6A)",implemented:!0,hidden:!1,cat:"fork"},"Twitch Emotes":{id:"bda-es-7",info:"Show Twitch emotes",implemented:!0,hidden:!1,cat:"emote"},"FrankerFaceZ Emotes":{id:"bda-es-1",info:"Show FrankerFaceZ Emotes",implemented:!0,hidden:!1,cat:"emote"},"BetterTTV Emotes":{id:"bda-es-2",info:"Show BetterTTV Emotes",implemented:!0,hidden:!1,cat:"emote"},"Emote Menu":{id:"bda-es-0",info:"Show Twitch/Favourite emotes in emote menu",implemented:!0,hidden:!1,cat:"emote"},"Emoji Menu":{id:"bda-es-9",info:"Show Discord emoji menu",implemented:!0,hidden:!1,cat:"emote"},"Emote Autocomplete":{id:"bda-es-3",info:"Autocomplete emote commands",implemented:!1,hidden:!1,cat:"emote"},"Emote Auto Capitalization":{id:"bda-es-4",info:"Autocapitalize emote commands",implemented:!0,hidden:!1,cat:"emote"},"Show Names":{id:"bda-es-6",info:"Show emote names on hover",implemented:!0,hidden:!1,cat:"emote"},"Show emote modifiers":{id:"bda-es-8",info:"Enable emote mods (flip, spin, pulse, spin2, spin3, 1spin, 2spin, 3spin, tr, bl, br, shake, shake2, shake3, flap)",implemented:!0,hidden:!1,cat:"emote"}},defaultCookie={version:jsVersion,"bda-gs-0":!1,"bda-gs-1":!0,"bda-gs-2":!1,"bda-gs-3":!1,"bda-gs-4":!1,"bda-gs-5":!0,"bda-gs-6":!1,"bda-gs-7":!1,"bda-gs-8":!1,"bda-es-0":!0,"bda-es-1":!0,"bda-es-2":!0,"bda-es-3":!1,"bda-es-4":!1,"bda-es-5":!0,"bda-es-6":!0,"bda-es-7":!0,"bda-gs-b":!1,"bda-es-8":!0,"bda-jd":!0,"bda-dc-0":!1,"bda-css-0":!1,"bda-css-1":!1,"bda-es-9":!0,"fork-dm-1":!1,"fork-ps-1":!0,"fork-ps-2":!0,"fork-ps-3":!0,"fork-ps-4":!0,"fork-es-2":!1,"fork-es-3":!0},settingsCookie={},bdpluginErrors,bdthemeErrors,bdConfig=null;function Core(t){window.bdConfig=t}var classNormalizer;Core.prototype.init=async function(){function t(){0<document.querySelectorAll(`.${BDV2.guildClasses.guilds} .${BDV2.guildClasses.guild}`).length?(bdConfig.deferLoaded=!0,a.injectExternals(),Utils.log("Updating Settings"),settingsPanel=new V2_SettingsPanel,settingsPanel.updateSettings(),!bdpluginErrors&&(bdpluginErrors=[]),!bdthemeErrors&&(bdthemeErrors=[]),Utils.log("Loading Plugins"),pluginModule=new PluginModule,pluginModule.loadPlugins(),Utils.log("Loading Themes"),themeModule=new ThemeModule,themeModule.loadThemes(),$("#customcss").detach().appendTo(document.head),window.addEventListener("beforeunload",function(){settingsCookie["bda-dc-0"]&&document.querySelector(".btn.btn-disconnect").click()}),publicServersModule.initialize(),emoteModule.autoCapitalize(),settingsCookie.version<jsVersion&&(settingsCookie.version=jsVersion,a.saveSettings()),Utils.log("Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2")[0].remove(),Utils.log("Initializing Main Observer"),a.initObserver(),settingsCookie["fork-ps-1"]&&(Utils.log("Collecting Startup Errors"),a.showStartupErrors())):setTimeout(t,100)}var a=this;bdConfig.deferLoaded=!1;var o="undefined"==typeof version?bdVersion:version;return o<supportedVersion?void this.alert("Not Supported","BetterDiscord v"+o+"(your version) is not supported by the latest js("+jsVersion+").<br><br> Please download the latest version from <a href='https://betterdiscord.net' target='_blank'>BetterDiscord.net</a>"):void(Utils.log("Initializing Settings"),this.initSettings(),classNormalizer=new ClassNormalizer,emoteModule=new EmoteModule,quickEmoteMenu=new QuickEmoteMenu,Utils.log("Initializing EmoteModule"),window.emotePromise=emoteModule.init().then(()=>{emoteModule.initialized=!0,Utils.log("Initializing QuickEmoteMenu"),quickEmoteMenu.init()}),publicServersModule=new V2_PublicServers,voiceMode=new VoiceMode,dMode=new devMode,$(document).ready(function(){setTimeout(t,100)}))},Core.prototype.injectExternals=function(){Utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js")},Core.prototype.initSettings=function(){if(bdSettingsStorage.initialize(),!bdSettingsStorage.get("settings"))settingsCookie=defaultCookie,this.saveSettings();else for(var t in this.loadSettings(),$("<style id=\"customcss\">").html(atob(window.bdStorage.get("bdcustomcss"))).appendTo(document.head),defaultCookie)void 0==settingsCookie[t]&&(settingsCookie[t]=defaultCookie[t],this.saveSettings())},Core.prototype.saveSettings=function(){bdSettingsStorage.set("settings",settingsCookie)},Core.prototype.loadSettings=function(){settingsCookie=bdSettingsStorage.get("settings")},Core.prototype.initObserver=function(){const t=new MutationObserver(a=>{for(let d,o=0,l=a.length;o<l;o++)if(d=a[o],"undefined"!=typeof pluginModule&&pluginModule.rawObserver(d),d.addedNodes.length&&d.addedNodes[0]instanceof Element){let h=d.addedNodes[0];h.classList.contains("layer-3QrUeG")&&(h.getElementsByClassName("guild-settings-base-section").length&&h.setAttribute("layer-id","server-settings"),h.getElementsByClassName("socialLinks-3jqNFy").length&&(h.setAttribute("layer-id","user-settings"),h.setAttribute("id","user-settings"),!document.getElementById("bd-settings-sidebar")&&settingsPanel.renderSidebar())),h.classList.contains("popout-3sVMXz")&&!h.classList.contains("popoutLeft-30WmrD")&&h.getElementsByClassName("emojiPicker-3m1S-j").length&&quickEmoteMenu.obsCallback(h)}});t.observe(document,{childList:!0,subtree:!0})},Core.prototype.inject24Hour=function(){if(!this.cancel24Hour){const t=/([0-9]{1,2}):([0-9]{1,2})\s(AM|PM)/;this.cancel24Hour=Utils.monkeyPatch(BDV2.TimeFormatter,"calendarFormat",{after:a=>{if(settingsCookie["bda-gs-6"]){const o=a.returnValue.match(t);return o&&4===o.length?"AM"===o[3]?a.returnValue=a.returnValue.replace(o[0],`${"12"===o[1]?"00":o[1].padStart(2,"0")}:${o[2]}`):a.returnValue=a.returnValue.replace(o[0],`${parseInt(o[1])+12}:${o[2]}`):void 0}}})}},Core.prototype.injectColoredText=function(){this.cancelColoredText||(this.cancelColoredText=Utils.monkeyPatch(BDV2.MessageContentComponent.prototype,"render",{after:t=>{settingsCookie["bda-gs-7"]&&Utils.monkeyPatch(t.returnValue.props,"children",{silent:!0,after:({returnValue:a})=>{const o=a.props.children[1],l=t.thisObject.props.message.colorString;return o&&l&&(o.props.style={color:l}),a}})}}))},Core.prototype.removeColoredText=function(){document.querySelectorAll(".markup-2BOw-j").forEach(t=>{t.style.setProperty("color","")})},Core.prototype.alert=function(t,a){let o=$(`<div class="bd-modal-wrapper theme-dark">
<div class="bd-backdrop backdrop-1wrmKB"></div>
<div class="bd-modal modal-1UGdnR">
<div class="bd-modal-inner inner-1JeGVc">
<div class="header header-1R_AjF">
<div class="title">${t}</div>
</div>
<div class="bd-modal-body">
<div class="scroller-wrap fade">
<div class="scroller">
${a}
</div>
</div>
</div>
<div class="footer footer-2yfCgX">
<button type="button">Okay</button>
</div>
</div>
</div>
</div>`);o.find(".footer button").on("click",()=>{o.addClass("closing"),setTimeout(()=>{o.remove()},300)}),o.find(".bd-backdrop").on("click",()=>{o.addClass("closing"),setTimeout(()=>{o.remove()},300)}),o.appendTo("#app-mount")},Core.prototype.showStartupErrors=function(){function t(l){let d=$(`<div class="errors">`);for(let u of l){let h=$(`<div class="error">
<div class="table-column column-name">${u.name?u.name:u.file}</div>
<div class="table-column column-reason">${u.reason}</div>
<div class="table-column column-error"><a class="error-link" href="">${u.error?u.error.message:""}</a></div>
</div>`);d.append(h),u.error&&h.find("a").on("click",g=>{g.preventDefault(),Utils.err(`Error details for ${u.name?u.name:u.file}.`,u.error)})}return d}if(bdpluginErrors&&bdthemeErrors&&(bdpluginErrors.length||bdthemeErrors.length)){let a=$(`<div class="bd-modal-wrapper theme-dark">
<div class="bd-backdrop backdrop-1wrmKB"></div>
<div class="bd-modal bd-startup-modal modal-1UGdnR">
<div class="bd-modal-inner inner-1JeGVc">
<div class="header header-1R_AjF"><div class="title">Startup Errors</div></div>
<div class="bd-modal-body">
<div class="tab-bar-container">
<div class="tab-bar TOP">
<div class="tab-bar-item">Plugins</div>
<div class="tab-bar-item">Themes</div>
</div>
</div>
<div class="table-header">
<div class="table-column column-name">Name</div>
<div class="table-column column-reason">Reason</div>
<div class="table-column column-error">Error</div>
</div>
<div class="scroller-wrap fade">
<div class="scroller">
</div>
</div>
</div>
<div class="footer footer-2yfCgX">
<button type="button">Okay</button>
</div>
</div>
</div>
</div>`),o=[t(bdpluginErrors),t(bdthemeErrors)];a.find(".tab-bar-item").on("click",l=>{l.preventDefault(),a.find(".tab-bar-item").removeClass("selected"),$(l.target).addClass("selected"),a.find(".scroller").empty().append(o[$(l.target).index()])}),a.find(".footer button").on("click",()=>{a.addClass("closing"),setTimeout(()=>{a.remove()},300)}),a.find(".bd-backdrop").on("click",()=>{a.addClass("closing"),setTimeout(()=>{a.remove()},300)}),a.appendTo("#app-mount"),a.find(".tab-bar-item")[0].click()}},Core.prototype.showToast=function(t,a={}){if(bdConfig.deferLoaded){if(!document.querySelector(".bd-toasts")){let h=document.createElement("div");h.classList.add("bd-toasts");let g=document.querySelector(".chat-3bRxxu form, #friends, .noChannel-Z1DQK7, .activityFeed-28jde9");h.style.setProperty("left",g?g.getBoundingClientRect().left+"px":"0px"),h.style.setProperty("width",g?g.offsetWidth+"px":"100%"),h.style.setProperty("bottom",(document.querySelector(".chat-3bRxxu form")?document.querySelector(".chat-3bRxxu form").offsetHeight:80)+"px"),document.querySelector(".app").appendChild(h)}const{type:o="",icon:l=!0,timeout:d=3e3}=a;let u=document.createElement("div");u.classList.add("bd-toast"),o&&u.classList.add("toast-"+o),o&&l&&u.classList.add("icon"),u.innerText=t,document.querySelector(".bd-toasts").appendChild(u),setTimeout(()=>{u.classList.add("closing"),setTimeout(()=>{u.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},d)}},window.emotesFfz={},window.emotesBTTV={},window.emotesBTTV2={},window.emotesTwitch={},window.subEmotesTwitch={},window.bdEmotes={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},window.bdEmoteSettingIDs={TwitchGlobal:"bda-es-7",TwitchSubscriber:"bda-es-7",BTTV:"bda-es-2",FrankerFaceZ:"bda-es-1",BTTV2:"bda-es-2"};function EmoteModule(){}EmoteModule.prototype.init=async function(){this.modifiers=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"],this.overrides=["twitch","bttv","ffz"],this.categories=["TwitchGlobal","TwitchSubscriber","BTTV","BTTV2","FrankerFaceZ"];let t={TwitchGlobal:{url:"https://twitchemotes.com/api_cache/v3/global.json",backup:"https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/master/data/emotedata_twitch_global.json",variable:"TwitchGlobal",oldVariable:"emotesTwitch",getEmoteURL:a=>`https://static-cdn.jtvnw.net/emoticons/v1/${a.id}/1.0`,getOldData:(a,o)=>{return{id:a.match(/\/([0-9]+)\//)[1],code:o,emoticon_set:0,description:null}}},TwitchSubscriber:{url:"https://twitchemotes.com/api_cache/v3/subscriber.json",backup:"https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/master/data/emotedata_twitch_subscriber.json",variable:"TwitchSubscriber",oldVariable:"subEmotesTwitch",parser:a=>{let o={};for(let l in a){let d=a[l];for(let g,u=0,h=d.emotes.length;u<h;u++)g=d.emotes[u],o[g.code]=g.id}return o},backupParser:a=>{return a},getEmoteURL:a=>`https://static-cdn.jtvnw.net/emoticons/v1/${a}/1.0`,getOldData:a=>a.match(/\/([0-9]+)\//)[1]},FrankerFaceZ:{url:"https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/master/data/emotedata_ffz.json",variable:"FrankerFaceZ",oldVariable:"emotesFfz",getEmoteURL:a=>`https://cdn.frankerfacez.com/emoticon/${a}/1`,getOldData:a=>a.match(/\/([0-9]+)\//)[1]},BTTV:{url:"https://api.betterttv.net/emotes",variable:"BTTV",oldVariable:"emotesBTTV",parser:a=>{let o={};for(let u,l=0,d=a.emotes.length;l<d;l++)u=a.emotes[l],o[u.regex]=u.url;return o},getEmoteURL:a=>`${a}`,getOldData:a=>a},BTTV2:{url:"https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/master/data/emotedata_bttv.json",variable:"BTTV2",oldVariable:"emotesBTTV2",getEmoteURL:a=>`https://cdn.betterttv.net/emote/${a}/1x`,getOldData:a=>a.match(/emote\/(.+)\//)[1]}};for(await this.getBlacklist(),await this.loadEmoteData(t);!BDV2.MessageContentComponent;)await new Promise(a=>setTimeout(a,100));this.cancelEmoteRender||(this.cancelEmoteRender=Utils.monkeyPatch(BDV2.MessageContentComponent.prototype,"render",{after:({returnValue:a})=>{Utils.monkeyPatch(a.props,"children",{silent:!0,after:({returnValue:o})=>{const l=o.props.children[1];if(l.props.children){const d=l.props.children[1];if(d&&d.length){for(let h=0;h<d.length;h++){const g=d[h];if("string"==typeof g){const O=g.split(/([^\s]+)([\s]|$)/g);for(let A=0,F=this.categories.length;A<F;A++)for(let I=0,R=O.length;I<R;I++){let q=O[I],G=q.split(":"),z=G[0],V=G[1]?G[1]:"",U=V.slice(0);if(!(bemotes.includes(z)||4>z.length)){this.modifiers.includes(V)&&settingsCookie["bda-es-8"]||(V=""),this.overrides.includes(U)?V=U:U="";let W=this.categories[A];if("twitch"===U?window.bdEmotes.TwitchGlobal[z]?W="TwitchGlobal":window.bdEmotes.TwitchSubscriber[z]&&(W="TwitchSubscriber"):"bttv"===U?window.bdEmotes.BTTV[z]?W="BTTV":window.bdEmotes.BTTV2[z]&&(W="BTTV2"):"ffz"==U&&window.bdEmotes.FrankerFaceZ[z]&&(W="FrankerFaceZ"),window.bdEmotes[W][z]&&settingsCookie[window.bdEmoteSettingIDs[W]]){const H=d[h].match(new RegExp(`([\\s]|^)${Utils.escape(V?z+":"+V:z)}([\\s]|$)`));if(H){const Z=d[h].substring(0,H.index+H[1].length),J=d[h].substring(H.index+H[0].length-H[2].length);d[h]=Z;const K=BDV2.react.createElement(BDEmote,{name:z,url:window.bdEmotes[W][z],modifier:V});d.splice(h+1,0,J),d.splice(h+1,0,K)}}}}}}const u=d.every(h=>{return"string"==typeof h&&""==h.replace(/\s*/,"")||h.type&&"BDEmote"==h.type.name||h.props&&h.props.children&&h.props.children.props&&h.props.children.props.emojiName});if(u)for(let h of d)"object"==typeof h&&("BDEmote"==h.type.name?h.props.jumboable=!0:h.props&&h.props.children&&h.props.children.props&&h.props.children.props.emojiName&&(h.props.children.props.jumboable=!0))}}}})}}))},EmoteModule.prototype.clearEmoteData=async function(){let t=require("fs"),o=bdConfig.dataPath+"emote_data.json",l=t.existsSync(o);l&&t.unlinkSync(o),window.bdStorage.set("emoteCacheDate",new Date().toJSON()),window.bdEmotes={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}}},EmoteModule.prototype.goBack=async function(t){for(let a in t)for(let o in window.bdEmotes[t[a].variable])window[t[a].oldVariable][o]=t[a].getOldData(window.bdEmotes[t[a].variable][o],o)},EmoteModule.prototype.isCacheValid=function(){const t=new Date(window.bdStorage.get("emoteCacheDate")||null),a=new Date,o=Math.round(Math.abs((a.getTime()-t.getTime())/86400000));return!(o>bdConfig.cache.days)||(window.bdStorage.set("emoteCacheDate",a.toJSON()),!1)},EmoteModule.prototype.loadEmoteData=async function(t){const a=require("fs"),l=bdConfig.dataPath+"emote_data.json",d=a.existsSync(l);if(d&&this.isCacheValid()){settingsCookie["fork-ps-2"]&&mainCore.showToast("Loading emotes from cache.",{type:"info"}),Utils.log("[Emotes] Loading emotes from local cache.");const u=await new Promise(g=>{a.readFile(l,"utf8",(b,f)=>{Utils.log("[Emotes] Emotes loaded from cache."),b&&(f={}),g(f)})});let h=Utils.testJSON(u);for(const g in h&&(window.bdEmotes=JSON.parse(u)),t)h=0<Object.keys(window.bdEmotes[t[g].variable]).length;if(h)return void(settingsCookie["fork-ps-2"]&&mainCore.showToast("Emotes successfully loaded.",{type:"success"}));Utils.log("[Emotes] Cache was corrupt, downloading..."),a.unlinkSync(l)}if(!settingsCookie["fork-es-3"])return quickEmoteMenu.init();for(let u in settingsCookie["fork-ps-2"]&&mainCore.showToast("Downloading emotes in the background do not reload.",{type:"info"}),t){await new Promise(g=>setTimeout(g,1e3));let h=await this.downloadEmotes(t[u]);window.bdEmotes[t[u].variable]=h}settingsCookie["fork-ps-2"]&&mainCore.showToast("All emotes successfully downloaded.",{type:"success"});try{a.writeFileSync(l,JSON.stringify(window.bdEmotes),"utf8")}catch(u){Utils.err("[Emotes] Could not save emote data.",u)}quickEmoteMenu.init()},EmoteModule.prototype.downloadEmotes=function(t){let a=require("request"),o={url:t.url,timeout:t.timeout?t.timeout:5e3};return Utils.log("[Emotes] Downloading: "+t.variable),new Promise((l,d)=>{a(o,(u,h,g)=>{if(u)return Utils.err("[Emotes] Could not download "+t.variable,u),t.backup?(t.url=t.backup,t.backup=null,t.backupParser&&(t.parser=t.backupParser),l(this.downloadEmotes(t))):d({});let b={};try{b=JSON.parse(g)}catch(f){return Utils.err("[Emotes] Could not download "+t.variable,u),t.backup?(t.url=t.backup,t.backup=null,t.backupParser&&(t.parser=t.backupParser),l(this.downloadEmotes(t))):d({})}for(let f in"function"==typeof t.parser&&(b=t.parser(b)),b)b[f]=t.getEmoteURL(b[f]);l(b),Utils.log("[Emotes] Downloaded: "+t.variable)})})},EmoteModule.prototype.getBlacklist=function(){return new Promise(t=>{$.getJSON("https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/master/data/emotefilter.json",function(a){t(bemotes=a.blacklist)})})};var bemotes=[];EmoteModule.prototype.autoCapitalize=function(){$("body").delegate($(".channelTextArea-1LDbYG textarea:first"),"keyup change paste",()=>{if(settingsCookie["bda-es-4"]){var t=$(".channelTextArea-1LDbYG textarea:first").val();if(void 0!=t){var a=t.split(" ").pop();if(3<a.length){if("danSgame"==a)return;var o=this.capitalize(a.toLowerCase());null!==o&&void 0!==o&&Utils.insertText(Utils.getTextArea()[0],t.replace(a,o))}}}})},EmoteModule.prototype.capitalize=function(t){var a=window.bdEmotes.TwitchGlobal;for(var o in a)if(a.hasOwnProperty(o)&&t==(o+"").toLowerCase())return o};function QuickEmoteMenu(){}QuickEmoteMenu.prototype.init=function(){$(document).on("mousedown",function(u){"rmenu"!=u.target.id&&$("#rmenu").remove()}),this.favoriteEmotes={};var t=window.bdStorage.get("bdfavemotes");""!==t&&null!==t&&(this.favoriteEmotes=JSON.parse(atob(t)));var a="";a+="<div id=\"bda-qem\">",a+=" <button class=\"active\" id=\"bda-qem-twitch\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Twitch</button>",a+=" <button id=\"bda-qem-favourite\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Favourite</button>",a+=" <button id=\"bda-qem-emojis\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Emojis</buttond>",a+="</div>",this.qmeHeader=a;var o="";o+="<div id=\"bda-qem-twitch-container\">",o+=" <div class=\"scroller-wrap fade\">",o+=" <div class=\"scroller\">",o+=" <div class=\"emote-menu-inner\">";var l="";for(let u in window.bdEmotes.TwitchGlobal)window.bdEmotes.TwitchGlobal.hasOwnProperty(u)&&(l=window.bdEmotes.TwitchGlobal[u],o+="<div class=\"emote-container\">",o+=" <img class=\"emote-icon\" alt=\"\" src=\""+l+"\" title=\""+u+"\">",o+=" </img>",o+="</div>");o+=" </div>",o+=" </div>",o+=" </div>",o+="</div>",this.teContainer=o;var d="";for(let u in d+="<div id=\"bda-qem-favourite-container\">",d+=" <div class=\"scroller-wrap fade\">",d+=" <div class=\"scroller\">",d+=" <div class=\"emote-menu-inner\">",this.favoriteEmotes)l=this.favoriteEmotes[u],d+="<div class=\"emote-container\">",d+=" <img class=\"emote-icon\" alt=\"\" src=\""+l+"\" title=\""+u+"\" oncontextmenu='quickEmoteMenu.favContext(event, this);'>",d+=" </img>",d+="</div>";d+=" </div>",d+=" </div>",d+=" </div>",d+="</div>",this.faContainer=d},QuickEmoteMenu.prototype.favContext=function(t,a){t.stopPropagation();var o=$("<div>",{id:"rmenu","data-emoteid":$(a).prop("title"),text:"Remove","class":"context-menu theme-dark"});return o.css({top:t.pageY-$("#bda-qem-favourite-container").offset().top,left:t.pageX-$("#bda-qem-favourite-container").offset().left}),$(a).parent().append(o),o.on("click",function(l){return l.preventDefault(),l.stopPropagation(),$(this).remove(),delete quickEmoteMenu.favoriteEmotes[$(this).data("emoteid")],quickEmoteMenu.updateFavorites(),!1}),!1},QuickEmoteMenu.prototype.switchHandler=function(t){this.switchQem($(t).attr("id"))},QuickEmoteMenu.prototype.switchQem=function(t){var a=$("#bda-qem-twitch"),o=$("#bda-qem-favourite"),l=$("#bda-qem-emojis");a.removeClass("active"),o.removeClass("active"),l.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide();"bda-qem-twitch"===t?(a.addClass("active"),$("#bda-qem-twitch-container").show()):"bda-qem-favourite"===t?(o.addClass("active"),$("#bda-qem-favourite-container").show()):"bda-qem-emojis"===t?(l.addClass("active"),$(".emojiPicker-3m1S-j").show(),$(".emojiPicker-3m1S-j .search-bar-inner input, .emojiPicker-3m1S-j .search-bar-inner input").focus()):void 0;this.lastTab=t;var d=$(".emote-icon");d.off(),d.on("click",function(){var u=$(this).attr("title"),h=Utils.getTextArea();Utils.insertText(h[0]," "==h.val().slice(-1)?h.val()+u:h.val()+" "+u)})},QuickEmoteMenu.prototype.obsCallback=function(t){var a=$(t);settingsCookie["bda-es-9"]?a.removeClass("bda-qme-hidden"):a.addClass("bda-qme-hidden");settingsCookie["bda-es-0"]&&(a.prepend(this.qmeHeader),a.append(this.teContainer),a.append(this.faContainer),this.lastTab==void 0&&(this.lastTab="bda-qem-favourite"),this.switchQem(this.lastTab))},QuickEmoteMenu.prototype.favorite=function(t,a){this.favoriteEmotes.hasOwnProperty(t)||(this.favoriteEmotes[t]=a),this.updateFavorites()},QuickEmoteMenu.prototype.updateFavorites=function(){var t="";for(var a in t+="<div id=\"bda-qem-favourite-container\">",t+=" <div class=\"scroller-wrap fade\">",t+=" <div class=\"scroller\">",t+=" <div class=\"emote-menu-inner\">",this.favoriteEmotes){var o=this.favoriteEmotes[a];t+="<div class=\"emote-container\">",t+=" <img class=\"emote-icon\" alt=\"\" src=\""+o+"\" title=\""+a+"\" oncontextmenu=\"quickEmoteMenu.favContext(event, this);\">",t+=" </img>",t+="</div>"}t+=" </div>",t+=" </div>",t+=" </div>",t+="</div>",this.faContainer=t,$("#bda-qem-favourite-container").replaceWith(t),window.bdStorage.set("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))};var Utils=class t{static getTextArea(){return $(".channelTextArea-1LDbYG textarea")}static insertText(a,o){a.focus(),a.selectionStart=0,a.selectionEnd=a.value.length,document.execCommand("insertText",!1,o)}static jqDefer(a){window.jQuery?a():setTimeout(function(){this.jqDefer(a)},100)}static injectCss(a){$("<link/>",{type:"text/css",rel:"stylesheet",href:a}).appendTo($("head"))}static injectJs(a){$("<script/>",{type:"text/javascript",src:a}).appendTo($("body"))}static escapeID(a){return a.replace(/^[^a-z]+|[^\w-]+/gi,"")}static log(a){console.log("%c[BetterDiscord] %c"+a+"","color: #3a71c1; font-weight: 700;","")}static err(a,o){console.log("%c[BetterDiscord] %c"+a+"","color: red; font-weight: 700;",""),o&&(console.groupCollapsed("%cError: "+o.message,"color: red;"),console.error(o.stack),console.groupEnd())}static escape(a){return a.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}static insertElement(a,o,l){for(var d=a.firstChild;d;){if(d.nodeType!=Node.TEXT_NODE){d=d.nextSibling;continue}var u=0;d.data.replace(o,function(h){var g=[].slice.call(arguments),b=g[g.length-2],f=g[1]?d.splitText(b+g[1].length+u):d.splitText(b+u);u-=d.data.length+h.length,f.data=f.data.substr(h.trim().length),d.parentNode.insertBefore(l,f),d=f}),o.lastIndex=0,d=d.nextSibling}return a}static getTextNodes(a){var o=[];if(!a)return o;for(var d,l=0;l<a.childNodes.length;l++)d=a.childNodes[l],d.nodeType===Node.TEXT_NODE&&o.push(d);return o}static testJSON(a){try{return JSON.parse(a),!0}catch(o){return!1}}static suppressErrors(a,o){return(...l)=>{try{return a(...l)}catch(d){console.error("Error occurred in "+o,d)}}}static monkeyPatch(a,o,l){const{before:d,after:u,instead:h,once:g=!1,silent:b=!1,force:f=!1}=l,y=l.displayName||a.displayName||a.name||a.constructor.displayName||a.constructor.name;if(b||console.log("patch",o,"of",y),!a[o])if(f)a[o]=function(){};else return console.error(o,"does not exist for",y);const E=a[o],C=()=>{b||console.log("unpatch",o,"of",y),a[o]=E};return a[o]=function(){const S={thisObject:this,methodArguments:arguments,cancelPatch:C,originalMethod:E,callOriginalMethod:()=>S.returnValue=S.originalMethod.apply(S.thisObject,S.methodArguments)};if(h){const x=t.suppressErrors(h,"`instead` callback of "+a[o].displayName)(S);void 0!==x&&(S.returnValue=x)}else d&&t.suppressErrors(d,"`before` callback of "+a[o].displayName)(S),S.callOriginalMethod(),u&&t.suppressErrors(u,"`after` callback of "+a[o].displayName)(S);return g&&C(),S.returnValue},a[o].__monkeyPatched=!0,a[o].displayName="patched "+(a[o].displayName||o),C}static onRemoved(a,o){const l=new MutationObserver(d=>{for(let u=0;u<d.length;u++){const h=d[u],g=Array.from(h.removedNodes),b=-1<g.indexOf(a),f=g.some(y=>y.contains(a));(b||f)&&(l.disconnect(),o())}});l.observe(document.body,{subtree:!0,childList:!0})}};function VoiceMode(){}VoiceMode.prototype.enable=function(){$(".scroller.guild-channels ul").first().css("display","none"),$(".scroller.guild-channels header").first().css("display","none"),$(".app.flex-vertical").first().css("overflow","hidden"),$(".chat-3bRxxu").first().css("visibility","hidden").css("min-width","0px"),$(".flex-vertical.channels-wrap").first().css("flex-grow","100000"),$(".guild-header .btn.btn-hamburger").first().css("visibility","hidden")},VoiceMode.prototype.disable=function(){$(".scroller.guild-channels ul").first().css("display",""),$(".scroller.guild-channels header").first().css("display",""),$(".app.flex-vertical").first().css("overflow",""),$(".chat-3bRxxu").first().css("visibility","").css("min-width",""),$(".flex-vertical.channels-wrap").first().css("flex-grow",""),$(".guild-header .btn.btn-hamburger").first().css("visibility","")};var pluginCookie={};function PluginModule(){}PluginModule.prototype.loadPlugins=function(){this.loadPluginData();for(var t=Object.keys(bdplugins),a=0;a<t.length;a++){var o,l;try{o=bdplugins[t[a]].plugin,l=o.getName(),o.load&&"function"==typeof o.load&&o.load()}catch(d){pluginCookie[l]=!1,Utils.err("Plugin "+l+" could not be loaded.",d),bdpluginErrors.push({name:l,file:bdplugins[t[a]].filename,reason:"load() could not be fired.",error:{message:d.message,stack:d.stack}});continue}if(pluginCookie[l]||(pluginCookie[l]=!1),pluginCookie[l])try{o.start(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${o.getName()} v${o.getVersion()} has started.`)}catch(d){pluginCookie[l]=!1,Utils.err("Plugin "+l+" could not be started.",d),bdpluginErrors.push({name:l,file:bdplugins[t[a]].filename,reason:"start() could not be fired.",error:{message:d.message,stack:d.stack}})}}for(let d in pluginCookie)bdplugins[d]||delete pluginCookie[d];this.savePluginData(),require("electron").remote.getCurrentWebContents().on("did-navigate-in-page",this.channelSwitch.bind(this))},PluginModule.prototype.startPlugin=function(t){try{bdplugins[t].plugin.start(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdplugins[t].plugin.getName()} v${bdplugins[t].plugin.getVersion()} has started.`)}catch(a){pluginCookie[t]=!1,this.savePluginData(),Utils.err("Plugin "+name+" could not be started.",a)}},PluginModule.prototype.stopPlugin=function(t){try{bdplugins[t].plugin.stop(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdplugins[t].plugin.getName()} v${bdplugins[t].plugin.getVersion()} has stopped.`)}catch(a){Utils.err("Plugin "+name+" could not be stopped.",a)}},PluginModule.prototype.enablePlugin=function(t){pluginCookie[t]=!0,this.savePluginData(),this.startPlugin(t)},PluginModule.prototype.disablePlugin=function(t){pluginCookie[t]=!1,this.savePluginData(),this.stopPlugin(t)},PluginModule.prototype.togglePlugin=function(t){pluginCookie[t]?this.disablePlugin(t):this.enablePlugin(t)},PluginModule.prototype.loadPluginData=function(){let t=bdSettingsStorage.get("plugins");t&&(pluginCookie=t)},PluginModule.prototype.savePluginData=function(){bdSettingsStorage.set("plugins",pluginCookie)},PluginModule.prototype.newMessage=function(){for(var o,t=Object.keys(bdplugins),a=0;a<t.length;a++)if(o=bdplugins[t[a]].plugin,pluginCookie[o.getName()]&&"function"==typeof o.onMessage)try{o.onMessage()}catch(Q){Utils.err("Unable to fire onMessage for "+o.getName()+".",Q)}},PluginModule.prototype.channelSwitch=function(){for(var o,t=Object.keys(bdplugins),a=0;a<t.length;a++)if(o=bdplugins[t[a]].plugin,pluginCookie[o.getName()]&&"function"==typeof o.onSwitch)try{o.onSwitch()}catch(Y){Utils.err("Unable to fire onSwitch for "+o.getName()+".",Y)}},PluginModule.prototype.rawObserver=function(t){for(var l,a=Object.keys(bdplugins),o=0;o<a.length;o++)if(l=bdplugins[a[o]].plugin,pluginCookie[l.getName()]&&"function"==typeof l.observer)try{l.observer(t)}catch(X){Utils.err("Unable to fire observer for "+l.getName()+".",X)}};var themeCookie={};function ThemeModule(){}ThemeModule.prototype.loadThemes=function(){this.loadThemeData();for(var o,t=Object.keys(bdthemes),a=0;a<t.length;a++)o=bdthemes[t[a]].name,themeCookie[o]||(themeCookie[o]=!1),themeCookie[o]&&$("head").append($("<style>",{id:Utils.escapeID(o),html:unescape(bdthemes[o].css)}));for(let l in themeCookie)bdthemes[l]||delete themeCookie[l];this.saveThemeData()},ThemeModule.prototype.enableTheme=function(t){themeCookie[t]=!0,this.saveThemeData(),$("head").append(`<style id="${Utils.escapeID(bdthemes[t].name)}">${unescape(bdthemes[t].css)}</style>`),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdthemes[t].name} v${bdthemes[t].version} has been applied.`)},ThemeModule.prototype.disableTheme=function(t){themeCookie[t]=!1,this.saveThemeData(),$(`#${Utils.escapeID(bdthemes[t].name)}`).remove(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdthemes[t].name} v${bdthemes[t].version} has been removed.`)},ThemeModule.prototype.toggleTheme=function(t){themeCookie[t]?this.disableTheme(t):this.enableTheme(t)},ThemeModule.prototype.loadThemeData=function(){let t=bdSettingsStorage.get("themes");t&&(themeCookie=t)},ThemeModule.prototype.saveThemeData=function(){bdSettingsStorage.set("themes",themeCookie)};var BdApi={get React(){return BDV2.react},get ReactDOM(){return BDV2.reactDom},injectCSS:function(t,a){$("head").append($("<style>",{id:Utils.escapeID(t),html:a}))},clearCSS:function(t){$("#"+Utils.escapeID(t)).remove()},linkJS:function(t,a){$("head").append($("<script>",{id:Utils.escapeID(t),src:a,type:"text/javascript"}))},unlinkJS:function(t){$("#"+Utils.escapeID(t)).remove()},getPlugin:function(t){return bdplugins.hasOwnProperty(t)?bdplugins[t].plugin:null},getIpc:function(){return betterDiscordIPC},getCore:function(){return mainCore},alert:function(t,a){mainCore.alert(t,a)},showToast:function(t,a={}){mainCore.showToast(t,a)},findModule:function(t){return BDV2.WebpackModules.find(t)},findAllModules:function(t){return BDV2.WebpackModules.findAll(t)},findModuleByProps:function(...t){return BDV2.WebpackModules.findByUniqueProperties(t)},getInternalInstance:function(t){if(t instanceof window.jQuery||t instanceof Element)return t instanceof jQuery&&(t=t[0]),BDV2.getInternalInstance(t)},loadData:function(t,a){return window.bdPluginStorage.get(t,a)},saveData:function(t,a,o){return window.bdPluginStorage.set(t,a,o)}};function devMode(){}devMode.prototype.enable=function(t){var a=this;this.disable(),$(window).on("keydown.bdDevmode",function(o){if(119===o.which||118==o.which){console.log("%c[%cDevMode%c] %cBreak/Resume","color: red;","color: #303030; font-weight:700;","color:red;","");debugger}});t&&$(document).on("contextmenu.bdDevmode",function(o){a.lastSelector=a.getSelector(o.toElement),setImmediate(function(){var d=$(".contextMenu-HLZMGh");0>=d.length&&(d=$("<div class=\"contextMenu-HLZMGh bd-context-menu\"></div>"),d.addClass($(".app").hasClass("theme-dark")?"theme-dark":"theme-light"),d.appendTo(".app"),d.css("top",o.clientY),d.css("left",o.clientX),$(document).on("click.bdDevModeCtx",()=>{d.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("contextmenu.bdDevModeCtx",()=>{d.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("keyup.bdDevModeCtx",g=>{27===g.keyCode&&(d.remove(),$(document).off(".bdDevModeCtx"))}));var u=$("<div/>",{"class":"itemGroup-1tL0uz"}),h=$("<div/>",{"class":"item-1Yvehc",click:function(){BDV2.NativeModule.copy(a.lastSelector),d.hide()}}).append($("<span/>",{text:"Copy Selector"}));u.append(h),d.append(u),d.hasClass("undefined")&&d.css("top","-="+u.outerHeight())}),o.stopPropagation()})},devMode.prototype.getRules=function(t,a=t.ownerDocument.styleSheets){return[].concat(...[...a].map(o=>[...(o.cssRules||[])])).filter(o=>o&&o.selectorText&&t.matches(o.selectorText)&&o.style.length&&8>o.selectorText.split(", ").length)},devMode.prototype.getSelector=function(t){if(t.id)return`#${t.id}`;const a=this.getRules(t),o=a[a.length-1];if(o)return o.selectorText;return t.classList.length?`.${Array.from(t.classList).join(".")}`:`.${Array.from(t.parentElement.classList).join(".")}`},devMode.prototype.disable=function(){$(window).off("keydown.bdDevmode"),$(document).off("contextmenu.bdDevmode"),$(document).off("contextmenu.bdDevModeCtx")};var ClassNormalizer=class{constructor(){this.classFormat=/^(?!da-)[A-Za-z]+-([A-Za-z]|[0-9]|-|_){6}$/,this.normFormat=/^(?!da-)(?:-?[a-z])+$/,this.mainObserver=new MutationObserver(a=>{for(let o=0;o<a.length;o++){const l=a[o],d=l.addedNodes;if(d)for(let ee=0;ee<d.length;ee++)d[ee]instanceof Element&&d[ee].classList&&this.normalizeClasses(d[ee])}}),this.cache={},this.isActive=!1}stop(){this.isActive&&(this.isActive=!1,this.mainObserver.disconnect(),this.revertClasses(document.querySelector("#app-mount")))}start(){this.isActive||(this.isActive=!0,this.normalizeClasses(document.querySelector("#app-mount")),this.mainObserver.observe(document.querySelector("#app-mount"),{childList:!0,subtree:!0}))}toCamelCase(a){return a.split("-").map((o,l)=>l?o[0].toUpperCase()+o.slice(1):o).join("")}isRandomizedClass(a){return this.classFormat.test(a)}isNormalClass(a){return this.normFormat.test(a)}normalizeClasses(a){if(a instanceof Element){a.children&&a.children.length&&this.normalizeClasses(a.children[0]),a.nextElementSibling&&this.normalizeClasses(a.nextElementSibling);const o=a.classList,l=[];for(let d=0;d<o.length;d++)if(this.cache[o[d]])l.push(this.cache[o[d]]);else if(this.isNormalClass(o[d])){const u="da-"+this.toCamelCase(o[d]);l.push(u),this.cache[o[d]]=u}else if(this.isRandomizedClass(o[d])){const u="da-"+o[d].split("-")[0];l.push(u),this.cache[o[d]]=u}a.classList.add(...l)}}revertClasses(a){if(a instanceof Element){a.children&&a.children.length&&this.revertClasses(a.children[0]),a.nextElementSibling&&this.revertClasses(a.nextElementSibling);const o=a.classList,l=[];for(let d=0;d<o.length;d++)o[d].startsWith("da-")&&l.push(o[d]);a.classList.remove(...l)}}};class V2{constructor(){this.editorDetached=!1,this.WebpackModules=(()=>{const t=webpackJsonp.push([[],{__extra_id__:(u,h,g)=>u.exports=g},[["__extra_id__"]]]);delete t.m.__extra_id__,delete t.c.__extra_id__;const a=u=>{for(let h in t.c)if(t.c.hasOwnProperty(h)){let g=t.c[h].exports;if(g&&g.__esModule&&g.default&&u(g.default))return g.default;if(g&&u(g))return g}return console.warn("Cannot find loaded module in cache"),null};return{find:a,findAll:u=>{const h=[];for(let g in t.c)if(t.c.hasOwnProperty(g)){let b=t.c[g].exports;b&&b.__esModule&&b.default&&u(b.default)?h.push(b.default):b&&u(b)&&h.push(b)}return h},findByUniqueProperties:u=>a(h=>u.every(g=>h[g]!==void 0)),findByDisplayName:u=>a(h=>h.displayName===u)}})(),this.internal={react:this.WebpackModules.findByUniqueProperties(["Component","PureComponent","Children","createElement","cloneElement"]),reactDom:this.WebpackModules.findByUniqueProperties(["findDOMNode"])},this.getInternalInstance=t=>t[Object.keys(t).find(a=>a.startsWith("__reactInternalInstance"))]}get messageClasses(){return this.WebpackModules.findByUniqueProperties(["message","containerCozy"])||{}}get guildClasses(){return this.WebpackModules.findByUniqueProperties(["guildsWrapper"])||{guildsWrapper:"guilds-wrapper",scrollerWrap:"scroller-wrap",guilds:"guilds",friendsIcon:"friends-icon",homeIcon:"home-icon",guildPlaceholder:"guild-placeholder",guild:"guild",selected:"selected",unread:"unread",guildInner:"guild-inner",audio:"audio",video:"video",guildIcon:"guild-icon",badge:"badge",dms:"dms",guildSeparator:"guild-separator",guildsError:"guilds-error",guildsAdd:"guilds-add",guildsAddInner:"guilds-add-inner",unreadMentionsIndicatorBottom:"unread-mentions-indicator-bottom",unreadMentionsIndicatorTop:"unread-mentions-indicator-top",unreadMentionsBar:"unread-mentions-bar",unreadMentionBar:"unread-mention-bar"}}get MessageContentComponent(){return BDV2.WebpackModules.find(t=>t.defaultProps&&t.defaultProps.hasOwnProperty("disableButtons"))}get TimeFormatter(){return BDV2.WebpackModules.findByUniqueProperties(["dateFormat"])}get TooltipWrapper(){return BDV2.WebpackModules.find(t=>t.prototype&&t.prototype.showDelayed)}get NativeModule(){return BDV2.WebpackModules.findByUniqueProperties(["setBadge"])}get reactComponent(){return this.internal.react.Component}get react(){return this.internal.react}get reactDom(){return this.internal.reactDom}parseSettings(t){return Object.keys(settings).reduce((a,o)=>{let l=settings[o];return l.cat===t&&l.implemented&&!l.hidden&&(l.text=o,a.push(l)),a},[])}}var BDV2=new V2;class BDEmote extends BDV2.reactComponent{constructor(t){super(t);const a=quickEmoteMenu&&quickEmoteMenu.favoriteEmotes&&quickEmoteMenu.favoriteEmotes[this.label];this.state={shouldAnimate:!this.animateOnHover,isFavorite:a},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onClick=this.onClick.bind(this)}get animateOnHover(){return settingsCookie["fork-es-2"]}get label(){return this.props.modifier?`${this.props.name}:${this.props.modifier}`:this.props.name}get modifierClass(){return this.props.modifier?` emote${this.props.modifier}`:""}onMouseEnter(){!this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!0}),!this.state.isFavorite&&quickEmoteMenu.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!quickEmoteMenu.favoriteEmotes[this.label]&&this.setState({isFavorite:!1})}onMouseLeave(){this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!1})}onClick(t){this.props.onClick&&this.props.onClick(t)}render(){return BDV2.react.createElement(BDV2.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},BDV2.react.createElement("div",{className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},BDV2.react.createElement("img",{draggable:!1,className:"emote"+this.modifierClass+(this.props.jumboable?" jumboable":"")+(this.state.shouldAnimate?"":" stop-animation"),dataModifier:this.props.modifier,alt:this.label,src:this.props.url}),BDV2.react.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.state.isFavorite?(delete quickEmoteMenu.favoriteEmotes[this.label],quickEmoteMenu.updateFavorites()):quickEmoteMenu.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}class V2C_SettingsPanel extends BDV2.reactComponent{constructor(t){super(t)}render(){let{settings:t}=this.props;return BDV2.react.createElement("div",{className:"content-column default"},BDV2.react.createElement(V2Components.SettingsTitle,{text:this.props.title}),this.props.button&&BDV2.react.createElement("button",{key:"title-button",className:"bd-pfbtn",onClick:this.props.button.onClick},this.props.button.title),t.map(a=>{return BDV2.react.createElement(V2Components.Switch,{id:a.id,key:a.id,data:a,checked:settingsCookie[a.id],onChange:(o,l)=>{this.props.onChange(o,l)}})}))}}class V2C_Switch extends BDV2.reactComponent{constructor(t){super(t),this.setInitialState(),this.onChange=this.onChange.bind(this)}setInitialState(){this.state={checked:this.props.checked}}render(){let{text:t,info:a}=this.props.data,{checked:o}=this.state;return BDV2.react.createElement("div",{className:"ui-flex flex-vertical flex-justify-start flex-align-stretch flex-nowrap ui-switch-item"},BDV2.react.createElement("div",{className:"ui-flex flex-horizontal flex-justify-start flex-align-stretch flex-nowrap"},BDV2.react.createElement("h3",{className:"ui-form-title h3 margin-reset margin-reset ui-flex-child"},t),BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},BDV2.react.createElement("input",{className:"ui-switch-checkbox",type:"checkbox",checked:o,onChange:l=>this.onChange(l)}),BDV2.react.createElement("div",{className:`ui-switch ${o?"checked":""}`}))),BDV2.react.createElement("div",{className:"ui-form-text style-description margin-top-4",style:{flex:"1 1 auto"}},a))}onChange(){this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked})}}class V2C_Scroller extends BDV2.reactComponent{constructor(t){super(t)}render(){let t=`scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d${this.props.fade?" scrollerFade-1Ijw5y":""}`,a="scroller-2FKFPG scroller";this.props.sidebar&&(a="scroller-2FKFPG sidebar-region-scroller scroller scroller-2FKFPG"),this.props.contentColumn&&(a="scroller-2FKFPG content-region-scroller scroller scroller-2FKFPG",t="scrollerWrap-2lJEkd content-region-scroller-wrap scrollerThemed-2oenus themeGhost-10fio9 scrollerTrack-3hhmU0 scrollerWrap-2lJEkd content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv");let{children:o}=this.props;return BDV2.react.createElement("div",{key:"scrollerwrap",className:t},BDV2.react.createElement("div",{key:"scroller",ref:"scroller",className:a},o))}}class V2C_TabBarItem extends BDV2.reactComponent{constructor(t){super(t),this.setInitialState(),this.onClick=this.onClick.bind(this)}setInitialState(){this.state={selected:this.props.selected||!1}}render(){return BDV2.react.createElement("div",{className:`ui-tab-bar-item${this.props.selected?" selected":""}`,onClick:this.onClick},this.props.text)}onClick(){this.props.onClick&&this.props.onClick(this.props.id)}}class V2C_TabBarSeparator extends BDV2.reactComponent{constructor(t){super(t)}render(){return BDV2.react.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class V2C_TabBarHeader extends BDV2.reactComponent{constructor(t){super(t)}render(){return BDV2.react.createElement("div",{className:"ui-tab-bar-header"},this.props.text)}}class V2C_SideBar extends BDV2.reactComponent{constructor(t){super(t);let a=this;const o=$("[class*=side] > [class*=selected]");o.length&&(a.scn=o.attr("class"));const l=$("[class*=side] > [class*=notSelected]");l.length&&(a.nscn=l.attr("class")),$("[class*='side-'] > [class*='item-']").on("click",()=>{a.setState({selected:null})}),a.setInitialState(),a.onClick=a.onClick.bind(a)}setInitialState(){let t=this;t.state={selected:null,items:t.props.items};let a=t.props.items.find(o=>{return o.selected});a&&(t.state.selected=a.id)}render(){let t=this,{headerText:a}=t.props,{items:o,selected:l}=t.state;return BDV2.react.createElement("div",null,BDV2.react.createElement(V2Components.TabBar.Separator,null),BDV2.react.createElement(V2Components.TabBar.Header,{text:a}),o.map(d=>{let{id:u,text:h}=d;return BDV2.react.createElement(V2Components.TabBar.Item,{key:u,selected:l===u,text:h,id:u,onClick:t.onClick})}))}onClick(t){let a=this;const o=$("[class*=side] > [class*=selected]");o.length&&(o.off("click.bdsb").on("click.bsb",l=>{$(l.target).attr("class",a.scn)}),o.attr("class",a.nscn)),a.setState({selected:null}),a.setState({selected:t}),a.props.onClick&&a.props.onClick(t)}}class V2C_XSvg extends BDV2.reactComponent{constructor(t){super(t)}render(){return BDV2.react.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},BDV2.react.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},BDV2.react.createElement("path",{d:"M0 0h12v12H0"}),BDV2.react.createElement("path",{className:"fill",fill:"#dcddde",d:"M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"})))}}class V2C_Tools extends BDV2.reactComponent{constructor(t){super(t),this.onClick=this.onClick.bind(this)}render(){return BDV2.react.createElement("div",{className:"tools-container"},BDV2.react.createElement("div",{className:"tools"},BDV2.react.createElement("div",{className:"btn-close closeButton-1tv5uR",onClick:this.onClick},BDV2.react.createElement(V2Components.XSvg,null)),BDV2.react.createElement("div",{className:"esc-text keybind-KpFkfr"},"ESC")))}onClick(){this.props.onClick&&this.props.onClick(),$(".closeButton-1tv5uR").first().click()}}class V2C_SettingsTitle extends BDV2.reactComponent{constructor(t){super(t)}render(){return BDV2.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.text)}}class V2C_Checkbox extends BDV2.reactComponent{constructor(t){super(t),this.onClick=this.onClick.bind(this),this.setInitialState()}setInitialState(){this.state={checked:this.props.checked||!1}}render(){return BDV2.react.createElement("li",null,BDV2.react.createElement("div",{className:"checkbox",onClick:this.onClick},BDV2.react.createElement("div",{className:"checkbox-inner"},BDV2.react.createElement("input",{checked:this.state.checked,onChange:()=>{},type:"checkbox"}),BDV2.react.createElement("span",null)),BDV2.react.createElement("span",null,this.props.text)))}onClick(){this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked})}}class V2C_CssEditorDetached extends BDV2.reactComponent{constructor(t){super(t);let a=this;a.onClick=a.onClick.bind(a),a.updateCss=a.updateCss.bind(a),a.saveCss=a.saveCss.bind(a),a.onChange=a.onChange.bind(a)}componentDidMount(){$("#app-mount").addClass("bd-detached-editor"),BDV2.editorDetached=!0,this.editor=ace.edit("bd-customcss-editor-detached"),this.editor.setTheme("ace/theme/monokai"),this.editor.session.setMode("ace/mode/css"),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(14),this.editor.on("change",()=>{settingsCookie["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){$("#app-mount").removeClass("bd-detached-editor"),BDV2.editorDetached=!1,this.editor.destroy()}updateLineCount(){let t=this.refs.editor.value.split("\n").length;t==this.props.lines||(this.refs.lines.textContent=Array.from(Array(t),(a,o)=>o+1).join(".\n")+".",this.props.lines=t)}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){let t=window.bdStorage.get("bdcustomcss"),a="";return t&&""!==t&&(a=atob(t)),a}get root(){let t=$("#bd-customcss-detach-container");return t.length?t[0]:this.injectRoot()?this.detachedRoot:null}injectRoot(){return!!$(".app").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app")),!0)}render(){let t=this;return BDV2.react.createElement("div",{className:"bd-detached-css-editor",id:"bd-customcss-detach-editor"},BDV2.react.createElement("div",{id:"bd-customcss-innerpane"},BDV2.react.createElement("div",{className:"editor-wrapper"},BDV2.react.createElement("div",{id:"bd-customcss-editor-detached",className:"editor",ref:"editor"},t.css)),BDV2.react.createElement("div",{id:"bd-customcss-attach-controls"},BDV2.react.createElement("ul",{className:"checkbox-group"},BDV2.react.createElement(V2Components.Checkbox,{id:"live-update",text:"Live Update",onChange:t.onChange,checked:settingsCookie["bda-css-0"]})),BDV2.react.createElement("div",{id:"bd-customcss-detach-controls-button"},BDV2.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{t.onClick("update")}},"Update"),BDV2.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{t.onClick("save")}},"Save"),BDV2.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{t.onClick("attach")}},"Attach"),BDV2.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on attach")))))}onChange(t,a){"live-update"===t?(settingsCookie["bda-css-0"]=a,mainCore.saveSettings()):void 0}onClick(t){let a=this;"attach"===t?($("#editor-detached").length&&a.props.attach(),BDV2.reactDom.unmountComponentAtNode(a.root),a.root.remove()):"update"===t?a.updateCss():"save"===t?a.saveCss():void 0}updateCss(){0==$("#customcss").length&&$("head").append("<style id=\"customcss\"></style>"),$("#customcss").html(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){window.bdStorage.set("bdcustomcss",btoa(this.editor.session.getValue()))}}class V2C_CssEditor extends BDV2.reactComponent{constructor(t){super(t);let a=this;a.props.lines=0,a.setInitialState(),a.attach=a.attach.bind(a),a.detachedEditor=BDV2.react.createElement(V2C_CssEditorDetached,{attach:a.attach}),a.onClick=a.onClick.bind(a),a.updateCss=a.updateCss.bind(a),a.saveCss=a.saveCss.bind(a),a.detach=a.detach.bind(a)}setInitialState(){this.state={detached:this.props.detached||BDV2.editorDetached}}componentDidMount(){this.editor=ace.edit("bd-customcss-editor"),this.editor.setTheme("ace/theme/monokai"),this.editor.session.setMode("ace/mode/css"),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(14),this.editor.on("change",()=>{settingsCookie["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){this.editor.destroy()}componentDidUpdate(t,a){let o=this;a.detached&&!o.state.detached&&BDV2.reactDom.unmountComponentAtNode(o.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){let t=window.bdStorage.get("bdcustomcss"),a="";return t&&""!==t&&(a=atob(t)),a}updateLineCount(){let t=this.refs.editor.value.split("\n").length;t==this.props.lines||(this.refs.lines.textContent=Array.from(Array(t),(a,o)=>o+1).join(".\n")+".",this.props.lines=t)}render(){let t=this,{detached:a}=t.state;return BDV2.react.createElement("div",{className:"content-column default",style:{padding:"60px 40px 0px"}},a&&BDV2.react.createElement("div",{id:"editor-detached"},BDV2.react.createElement(V2Components.SettingsTitle,{text:"Custom CSS Editor"}),BDV2.react.createElement("h3",null,"Editor Detached"),BDV2.react.createElement("button",{className:"btn btn-primary",onClick:()=>{t.attach()}},"Attach")),!a&&BDV2.react.createElement("div",null,BDV2.react.createElement(V2Components.SettingsTitle,{text:"Custom CSS Editor"}),BDV2.react.createElement("div",{className:"editor-wrapper"},BDV2.react.createElement("div",{id:"bd-customcss-editor",className:"editor",ref:"editor"},t.css)),BDV2.react.createElement("div",{id:"bd-customcss-attach-controls"},BDV2.react.createElement("ul",{className:"checkbox-group"},BDV2.react.createElement(V2Components.Checkbox,{id:"live-update",text:"Live Update",onChange:this.onChange,checked:settingsCookie["bda-css-0"]})),BDV2.react.createElement("div",{id:"bd-customcss-detach-controls-button"},BDV2.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{t.onClick("update")}},"Update"),BDV2.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{t.onClick("save")}},"Save"),BDV2.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{t.onClick("detach")}},"Detach"),BDV2.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach")))))}onClick(t){let a=this;"update"===t?a.updateCss():"save"===t?a.saveCss():"detach"===t?a.detach():void 0}onChange(t,a){"live-update"===t?(settingsCookie["bda-css-0"]=a,mainCore.saveSettings()):void 0}updateCss(){0==$("#customcss").length&&$("head").append("<style id=\"customcss\"></style>"),$("#customcss").html(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){window.bdStorage.set("bdcustomcss",btoa(this.editor.session.getValue()))}detach(){let t=this;t.setState({detached:!0});let a=t.detachedRoot;return a?void BDV2.reactDom.render(t.detachedEditor,a):void console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){let t=$("#bd-customcss-detach-container");return t.length?t[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app")),!0)}attach(){let t=this;t.setState({detached:!1})}}class V2C_List extends BDV2.reactComponent{constructor(t){super(t)}render(){return BDV2.react.createElement("ul",{className:this.props.className},this.props.children)}}class V2C_ContentColumn extends BDV2.reactComponent{constructor(t){super(t)}render(){return BDV2.react.createElement("div",{className:"content-column default"},BDV2.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}class V2C_PluginCard extends BDV2.reactComponent{constructor(t){super(t);let a=this;a.onChange=a.onChange.bind(a),a.showSettings=a.showSettings.bind(a),a.setInitialState(),a.hasSettings="function"==typeof a.props.plugin.getSettingsPanel,a.settingsPanel=""}setInitialState(){this.state={checked:pluginCookie[this.props.plugin.getName()],settings:!1}}componentDidUpdate(){if(this.state.settings){if("object"==typeof this.settingsPanel&&this.refs.settingspanel.appendChild(this.settingsPanel),!settingsCookie["fork-ps-3"])return;var t=(l,d)=>{let u=l.scrollTop,h=u+l.clientHeight,g=d.offsetTop,b=g+d.clientHeight;return g<u||b>h};let a=$(BDV2.reactDom.findDOMNode(this)),o=a.parents(".scroller");if(!t(o[0],a[0]))return;o.animate({scrollTop:a.offset().top-o.offset().top+o.scrollTop()-30},300)}}render(){let t=this,{plugin:a}=this.props,o=a.getName(),l=a.getAuthor(),d=a.getDescription(),u=a.getVersion(),h=bdplugins[o].website,g=bdplugins[o].source;if(this.state.settings){try{t.settingsPanel=a.getSettingsPanel()}catch(b){Utils.err("Unable to get settings panel for "+a.getName()+".",b)}return BDV2.react.createElement("li",{className:"settings-open ui-switch-item"},BDV2.react.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.refs.settingspanel.innerHTML="",t.setState({settings:!1})}},BDV2.react.createElement(V2Components.XSvg,null)),"object"==typeof t.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${o}`,className:"plugin-settings",ref:"settingspanel"}),"object"!=typeof t.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${o}`,className:"plugin-settings",ref:"settingspanel",dangerouslySetInnerHTML:{__html:t.settingsPanel}}))}return BDV2.react.createElement("li",{"data-name":o,"data-version":u,className:"settings-closed ui-switch-item"},BDV2.react.createElement("div",{className:"bda-header"},BDV2.react.createElement("span",{className:"bda-header-title"},BDV2.react.createElement("span",{className:"bda-name"},o)," v",BDV2.react.createElement("span",{className:"bda-version"},u)," by ",BDV2.react.createElement("span",{className:"bda-author"},l)),BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"}))),BDV2.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},BDV2.react.createElement("div",{className:"bda-description scroller"},d)),(h||g||this.hasSettings)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},h&&BDV2.react.createElement("a",{className:"bda-link bda-link-website",href:h,target:"_blank"},"Website"),h&&g&&" | ",g&&BDV2.react.createElement("a",{className:"bda-link bda-link-source",href:g,target:"_blank"},"Source")),this.hasSettings&&BDV2.react.createElement("button",{onClick:this.showSettings,className:"bda-settings-button",disabled:!this.state.checked},"Settings")))}onChange(){this.setState({checked:!this.state.checked}),pluginModule.togglePlugin(this.props.plugin.getName())}showSettings(){this.hasSettings&&this.setState({settings:!0})}}class V2C_ThemeCard extends BDV2.reactComponent{constructor(t){super(t),this.setInitialState(),this.onChange=this.onChange.bind(this)}setInitialState(){this.state={checked:themeCookie[this.props.theme.name]}}render(){let{theme:t}=this.props,a=t.name,o=t.description,l=t.version,d=t.author,u=bdthemes[a].website,h=bdthemes[a].source;return BDV2.react.createElement("li",{"data-name":a,"data-version":l,className:"settings-closed ui-switch-item"},BDV2.react.createElement("div",{className:"bda-header"},BDV2.react.createElement("span",{className:"bda-header-title"},BDV2.react.createElement("span",{className:"bda-name"},a)," v",BDV2.react.createElement("span",{className:"bda-version"},l)," by ",BDV2.react.createElement("span",{className:"bda-author"},d)),BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"}))),BDV2.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},BDV2.react.createElement("div",{className:"bda-description scroller"},o)),(u||h)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},u&&BDV2.react.createElement("a",{className:"bda-link",href:u,target:"_blank"},"Website"),u&&h&&" | ",h&&BDV2.react.createElement("a",{className:"bda-link",href:h,target:"_blank"},"Source"))))}onChange(){this.setState({checked:!this.state.checked}),themeModule.toggleTheme(this.props.theme.name)}}class V2Cs_TabBar{static get Item(){return V2C_TabBarItem}static get Header(){return V2C_TabBarHeader}static get Separator(){return V2C_TabBarSeparator}}class V2Components{static get SettingsPanel(){return V2C_SettingsPanel}static get Switch(){return V2C_Switch}static get Scroller(){return V2C_Scroller}static get TabBar(){return V2Cs_TabBar}static get SideBar(){return V2C_SideBar}static get Tools(){return V2C_Tools}static get SettingsTitle(){return V2C_SettingsTitle}static get CssEditor(){return V2C_CssEditor}static get Checkbox(){return V2C_Checkbox}static get List(){return V2C_List}static get PluginCard(){return V2C_PluginCard}static get ThemeCard(){return V2C_ThemeCard}static get ContentColumn(){return V2C_ContentColumn}static get XSvg(){return V2C_XSvg}static get Layer(){return V2C_Layer}static get SidebarView(){return V2C_SidebarView}static get ServerCard(){return V2C_ServerCard}}class V2_SettingsPanel_Sidebar{constructor(t){this.onClick=t}get items(){return[{text:"Core",id:"core"},{text:"Zere's Fork",id:"fork"},{text:"Emotes",id:"emotes"},{text:"Custom CSS",id:"customcss"},{text:"Plugins",id:"plugins"},{text:"Themes",id:"themes"}]}get component(){return BDV2.react.createElement("span",null,BDV2.react.createElement(V2Components.SideBar,{onClick:this.onClick,headerText:"Bandaged BD",items:this.items}),BDV2.react.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BD v${bdVersion} by `,BDV2.react.createElement("a",{href:"https://github.com/Jiiks/",target:"_blank"},"Jiiks")),BDV2.react.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${bbdVersion} by `,BDV2.react.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos")))}get root(){let t=$("#bd-settings-sidebar");return t.length?t[0]:this.injectRoot()?this.root:null}injectRoot(){let t=$("[class*='side-'] > [class*='item-']:not([class*=Danger])").last();return!!t.length&&($("<span/>",{id:"bd-settings-sidebar"}).insertBefore(t.prev()),!0)}render(){let t=this.root;return t?void(BDV2.reactDom.render(this.component,t),Utils.onRemoved(t,()=>{BDV2.reactDom.unmountComponentAtNode(t)})):void console.log("FAILED TO LOCATE ROOT: [class*='side-'] > [class*='item-']:not([class*=Danger])")}}class V2_SettingsPanel{constructor(){let t=this;t.sideBarOnClick=t.sideBarOnClick.bind(t),t.onChange=t.onChange.bind(t),t.updateSettings=this.updateSettings.bind(t),t.sidebar=new V2_SettingsPanel_Sidebar(t.sideBarOnClick)}get root(){let t=$("#bd-settingspane-container");return t.length?t[0]:this.injectRoot()?this.root:null}injectRoot(){if(!$(".layer-3QrUeG .ui-standard-sidebar-view, .layer-3QrUeG .ui-standard-sidebar-view").length)return!1;const t=$("<div/>",{"class":"content-region",id:"bd-settingspane-container"});return $(".layer-3QrUeG .ui-standard-sidebar-view, .layer-3QrUeG .ui-standard-sidebar-view").append(t),Utils.onRemoved(t[0],()=>{BDV2.reactDom.unmountComponentAtNode(t[0])}),!0}get coreSettings(){return this.getSettings("core")}get forkSettings(){return this.getSettings("fork")}get emoteSettings(){return this.getSettings("emote")}getSettings(t){return Object.keys(settings).reduce((a,o)=>{let l=settings[o];return l.cat===t&&l.implemented&&!l.hidden&&(l.text=o,a.push(l)),a},[])}sideBarOnClick(t){let a=this;$(".content-region").first().hide(),$(a.root).show();"core"===t?a.renderCoreSettings():"fork"===t?a.renderForkSettings():"emotes"===t?a.renderEmoteSettings():"customcss"===t?a.renderCustomCssEditor():"plugins"===t?a.renderPluginPane():"themes"===t?a.renderThemePane():void 0}onClick(){}onChange(t,a){settingsCookie[t]=a,this.updateSettings()}updateSettings(){let t=settingsCookie;t["bda-es-0"]?$("#twitchcord-button-container").show():$("#twitchcord-button-container").hide(),t["bda-gs-b"]?$("body").addClass("bd-blue"):$("body").removeClass("bd-blue"),t["bda-gs-2"]?$("body").addClass("bd-minimal"):$("body").removeClass("bd-minimal"),t["bda-gs-3"]?$("body").addClass("bd-minimal-chan"):$("body").removeClass("bd-minimal-chan"),t["bda-gs-1"]?$("#bd-pub-li").show():$("#bd-pub-li").hide(),t["bda-gs-4"]?voiceMode.enable():voiceMode.disable(),t["bda-gs-5"]?$("#app-mount").addClass("bda-dark"):$("#app-mount").removeClass("bda-dark"),t["bda-gs-6"]&&mainCore.inject24Hour(),t["bda-gs-7"]?mainCore.injectColoredText():mainCore.removeColoredText(),t["fork-ps-4"]?classNormalizer.start():classNormalizer.stop(),t["bda-gs-8"]?dMode.enable(t["fork-dm-1"]):dMode.disable(),mainCore.saveSettings()}renderSidebar(){let t=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{BDV2.reactDom.unmountComponentAtNode(t.root),$(t.root).hide(),$(".content-region").first().show()}),t.sidebar.render()}get coreComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SettingsPanel,{key:"cspanel",title:"Core Settings",onChange:this.onChange,settings:this.coreSettings}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get forkComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SettingsPanel,{key:"fspanel",title:"Zere's Fork Settings",onChange:this.onChange,settings:this.forkSettings,button:{title:"Clear Emote Cache",onClick:()=>{emoteModule.clearEmoteData(),emoteModule.init(),quickEmoteMenu.init()}}}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get emoteComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SettingsPanel,{key:"espanel",title:"Emote Settings",onChange:this.onChange,settings:this.emoteSettings}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get customCssComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.CssEditor,{key:"csseditor"}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get pluginsComponent(){let t=Object.keys(bdplugins).reduce((d,u)=>{return d.push(BDV2.react.createElement(V2Components.PluginCard,{key:u,plugin:bdplugins[u].plugin})),d},[]),a=BDV2.react.createElement(V2Components.List,{key:"plugin-list",className:"bda-slist",children:t}),o=BDV2.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{betterDiscordIPC.send("asynchronous-message",{arg:"opendir",path:"plugindir"})}},"Open Plugin Folder"),l=BDV2.react.createElement(V2Components.ContentColumn,{key:"pcolumn",title:"Plugins",children:[o,a]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[l,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get themesComponent(){let t=Object.keys(bdthemes).reduce((d,u)=>{return d.push(BDV2.react.createElement(V2Components.ThemeCard,{key:u,theme:bdthemes[u]})),d},[]),a=BDV2.react.createElement(V2Components.List,{key:"theme-list",className:"bda-slist",children:t}),o=BDV2.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{betterDiscordIPC.send("asynchronous-message",{arg:"opendir",path:"themedir"})}},"Open Theme Folder"),l=BDV2.react.createElement(V2Components.ContentColumn,{key:"tcolumn",title:"Themes",children:[o,a]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[l,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}renderCoreSettings(){let t=this.root;return t?void BDV2.reactDom.render(this.coreComponent,t):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderForkSettings(){let t=this.root;return t?void BDV2.reactDom.render(this.forkComponent,t):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderEmoteSettings(){let t=this.root;return t?void BDV2.reactDom.render(this.emoteComponent,t):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderCustomCssEditor(){let t=this.root;return t?void BDV2.reactDom.render(this.customCssComponent,t):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderPluginPane(){let t=this.root;return t?void BDV2.reactDom.render(this.pluginsComponent,t):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderThemePane(){let t=this.root;return t?void BDV2.reactDom.render(this.themesComponent,t):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}}class V2C_Layer extends BDV2.reactComponent{constructor(t){super(t)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,t=>{27===t.which&&BDV2.reactDom.unmountComponentAtNode(this.refs.root.parentNode)}),$(`#${this.props.id}`).animate({opacity:1},{step:function(t){$(this).css("transform",`scale(${1.1-0.1*t}) translateZ(0px)`)},duration:200,done:()=>{$(`#${this.props.id}`).css("opacity","").css("transform","")}})}componentWillUnmount(){$(window).off(`keyup.${this.props.id}`),$(`#${this.props.id}`).animate({opacity:0},{step:function(t){$(this).css("transform",`scale(${1.1-0.1*t}) translateZ(0px)`)},duration:200,done:()=>{$(`#${this.props.rootId}`).remove()}}),$("[class*=\"layer-\"]").removeClass("publicServersOpen").animate({opacity:1},{step:function(t){$(this).css("transform",`scale(${0.07*t+0.93}) translateZ(0px)`)},duration:200,done:()=>{$("[class*=\"layer-\"]").css("opacity","").css("transform","")}})}componentWillMount(){$("[class*=\"layer-\"]").addClass("publicServersOpen").animate({opacity:0},{step:function(t){$(this).css("transform",`scale(${0.07*t+0.93}) translateZ(0px)`)},duration:200})}render(){return BDV2.react.createElement("div",{className:"layer bd-layer layer-3QrUeG",id:this.props.id,ref:"root",style:{opacity:0,transform:"scale(1.1) translateZ(0px)"}},this.props.children)}}class V2C_SidebarView extends BDV2.reactComponent{constructor(t){super(t)}render(){let{sidebar:t,content:a,tools:o}=this.props.children;return BDV2.react.createElement("div",{className:"ui-standard-sidebar-view"},BDV2.react.createElement("div",{className:"sidebar-region"},BDV2.react.createElement(V2Components.Scroller,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:t.fade||!0,dark:t.dark||!0,children:t.component})),BDV2.react.createElement("div",{className:"content-region"},BDV2.react.createElement("div",{className:"content-transition-wrap"},BDV2.react.createElement("div",{className:"scrollerWrap-2lJEkd content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},BDV2.react.createElement("div",{className:"scroller-2FKFPG content-region-scroller scroller",ref:"contentScroller"},BDV2.react.createElement("div",{className:"content-column default"},a.component),o.component)))))}}class V2_PublicServers{constructor(){}get component(){return BDV2.react.createElement(V2Components.Layer,{rootId:"pubslayerroot",id:"pubslayer",children:BDV2.react.createElement(V2C_PublicServers,{rootId:"pubslayerroot"})})}get root(){let t=document.getElementById("pubslayerroot");return t?t:this.injectRoot()?this.root:null}injectRoot(){return!!$(".layers, .layers-3iHuyZ").length&&($(".layers, .layers-3iHuyZ").append($("<div/>",{id:"pubslayerroot"})),!0)}render(){let t=this.root;return t?void BDV2.reactDom.render(this.component,t):void console.log("FAILED TO LOCATE ROOT: .layers")}get button(){let t=$("<div/>",{"class":BDV2.guildClasses.guild,id:"bd-pub-li",css:{height:"20px",display:settingsCookie["bda-gs-1"]?"":"none"}}).append($("<div/>",{"class":BDV2.guildClasses.guildInner,css:{height:"20px","border-radius":"4px"}}).append($("<a/>",{}).append($("<div/>",{text:"public",id:"bd-pub-button",css:{"line-height":"20px","font-size":"12px"},click:()=>{this.render()}}))));return t}initialize(){let t=$(`.${BDV2.guildClasses.guilds}>:first-child`);t.after(this.button)}}class V2C_ServerCard extends BDV2.reactComponent{constructor(t){super(t),this.props.server.iconUrl||(this.props.server.iconUrl=this.props.fallback),this.state={imageError:!1,joined:this.props.guildList.includes(this.props.server.identifier)}}render(){let{server:t}=this.props;return BDV2.react.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${t.pinned?" bd-server-card-pinned":""}`},BDV2.react.createElement("img",{ref:"img",className:"bd-server-image",src:t.iconUrl,onError:this.handleError.bind(this)}),BDV2.react.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},BDV2.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},t.name),BDV2.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},t.members," Members")),BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},BDV2.react.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},BDV2.react.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},t.description))),BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},BDV2.react.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},t.categories.join(", ")),this.state.joined&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Joined")),t.error&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Error")),!t.error&&!this.state.joined&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Join")))))}handleError(){this.props.server.iconUrl=this.props.fallback,this.setState({imageError:!0})}join(){this.props.join(this)}}class V2C_PublicServers extends BDV2.reactComponent{constructor(t){super(t),this.setInitialState(),this.close=this.close.bind(this),this.changeCategory=this.changeCategory.bind(this),this.search=this.search.bind(this),this.searchKeyDown=this.searchKeyDown.bind(this),this.checkConnection=this.checkConnection.bind(this),this.join=this.join.bind(this),this.connect=this.connect.bind(this),this.GuildStore=BDV2.WebpackModules.findByUniqueProperties(["getGuilds"]),this.AvatarDefaults=BDV2.WebpackModules.findByUniqueProperties(["getUserAvatarURL","DEFAULT_AVATARS"]),this.InviteActions=BDV2.WebpackModules.findByUniqueProperties(["acceptInvite"]),this.SortedGuildStore=BDV2.WebpackModules.findByUniqueProperties(["getSortedGuilds"])}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){BDV2.reactDom.unmountComponentAtNode(document.getElementById(this.props.rootId))}search(t,a){let o=this;$.ajax({method:"GET",url:`${o.endPoint}${t}${t?"&schema=new":"?schema=new"}`,success:l=>{let d=l.results.reduce((g,b)=>{return b.joined=!1,g.push(b),g},[]);a||(d=o.state.servers.concat(d));let u=l.size+l.from;l.next=`?from=${u}`,o.state.term&&(l.next+=`&term=${o.state.term}`),o.state.selectedCategory&&(l.next+=`&category=${o.categoryButtons[o.state.selectedCategory]}`),u>=l.total&&(u=l.total,l.next=null);let h=`Showing 1-${u} of ${l.total} results in ${o.categoryButtons[o.state.selectedCategory]}`;o.state.term&&(h+=` for ${o.state.term}`),o.setState({loading:!1,title:h,servers:d,next:l.next}),a&&(o.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{o.setState({loading:!1,title:"Failed to load servers. Check console for details"})}})}join(t){return t.props.pinned?this.InviteActions.acceptInvite(t.props.invite_code):void $.ajax({method:"GET",url:`${this.joinEndPoint}/${t.props.server.identifier}`,headers:{Accept:"application/json;","Content-Type":"application/json;","x-discord-id":this.state.connection.user.id,"x-discord-token":this.state.connection.user.accessToken},crossDomain:!0,xhrFields:{withCredentials:!0},success:()=>{t.setState({joined:!0})}})}connect(){let t=this,a=t.windowOptions;a.x=Math.round(window.screenX+window.innerWidth/2-a.width/2),a.y=Math.round(window.screenY+window.innerHeight/2-a.height/2),t.joinWindow=new(window.require("electron").remote.BrowserWindow)(a);let o=window.location.hostname.split(".")[0],l=t.connectEndPoint+("canary"===o||"ptb"===o?`/${o}`:"")+"?betterDiscord";t.joinWindow.webContents.on("did-navigate",(d,u)=>{"https://join.discordservers.com/session"!=u||(t.joinWindow.close(),t.checkConnection())}),t.joinWindow.loadURL(l)}get windowOptions(){return{width:500,height:550,backgroundColor:"#282b30",show:!0,resizable:!1,maximizable:!1,minimizable:!1,alwaysOnTop:!0,frame:!1,center:!1}}get bdServer(){let a=this.SortedGuildStore.guildPositions,o=this.AvatarDefaults.DEFAULT_AVATARS;return BDV2.react.createElement(V2Components.ServerCard,{server:{name:"BetterDiscord",online:"7500+",members:"20000+",categories:["community","programming","support"],description:"Official BetterDiscord server for support etc",identifier:"86004744966914048",iconUrl:"https://cdn.discordapp.com/icons/86004744966914048/292e7f6bfff2b71dfd13e508a859aedd.webp",nativejoin:!0,invite_code:"0Tmfo5ZbORCRqbAd",pinned:!0},pinned:!0,join:this.join,guildList:a,fallback:o[Math.floor(5*Math.random())]})}get endPoint(){return"https://search.discordservers.com"}get joinEndPoint(){return"https://join.discordservers.com"}get connectEndPoint(){return"https://join.discordservers.com/connect"}checkConnection(){let t=this;try{$.ajax({method:"GET",url:`${t.joinEndPoint}/session`,headers:{Accept:"application/json;","Content-Type":"application/json;"},crossDomain:!0,xhrFields:{withCredentials:!0},success:a=>{t.setState({selectedCategory:0,connection:{state:2,user:a}}),t.search("",!0)},error:a=>{if(403===a.status||404===a.status)return void t.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}})}catch(a){t.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}}render(){return BDV2.react.createElement(V2Components.SidebarView,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:BDV2.react.createElement(V2Components.Tools,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return BDV2.react.createElement("div",{className:"sidebar",key:"ps"},BDV2.react.createElement("div",{className:"ui-tab-bar SIDE"},BDV2.react.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),BDV2.react.createElement(V2Components.TabBar.Separator,null),this.searchInput,BDV2.react.createElement(V2Components.TabBar.Separator,null),BDV2.react.createElement(V2Components.TabBar.Header,{text:"Categories"}),this.categoryButtons.map((t,a)=>{return BDV2.react.createElement(V2Components.TabBar.Item,{id:a,onClick:this.changeCategory,key:a,text:t,selected:this.state.selectedCategory===a})}),BDV2.react.createElement(V2Components.TabBar.Separator,null),this.footer,this.connection))}get searchInput(){return BDV2.react.createElement("div",{className:"ui-form-item"},BDV2.react.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},BDV2.react.createElement("input",{ref:"searchinput",onKeyDown:this.searchKeyDown,onChange:()=>{},type:"text",className:"input default",placeholder:"Search...",maxLength:"50"})))}searchKeyDown(t){let a=this;if(!(a.state.loading||13!==t.which)){a.setState({loading:!0,title:"Loading...",term:t.target.value});let o=`?term=${t.target.value}`;0!==a.state.selectedCategory&&(o+=`&category=${a.categoryButtons[a.state.selectedCategory]}`),a.search(o,!0)}}get categoryButtons(){return["All","FPS Games","MMO Games","Strategy Games","Sports Games","Puzzle Games","Retro Games","Party Games","Tabletop Games","Sandbox Games","Simulation Games","Community","Language","Programming","Other"]}changeCategory(t){let a=this;if(!a.state.loading)return a.refs.searchinput.value="",a.setState({loading:!0,selectedCategory:t,title:"Loading...",term:null}),0===t?void a.search("",!0):void a.search(`?category=${a.categoryButtons[t]}`,!0)}get content(){let t=this,a=this.SortedGuildStore.guildPositions,o=this.AvatarDefaults.DEFAULT_AVATARS;return 1===t.state.connection.state?t.notConnected:[BDV2.react.createElement("div",{ref:"content",key:"pc",className:"content-column default"},BDV2.react.createElement(V2Components.SettingsTitle,{text:t.state.title}),t.bdServer,t.state.servers.map(l=>{return BDV2.react.createElement(V2Components.ServerCard,{key:l.identifier,server:l,join:t.join,guildList:a,fallback:o[Math.floor(5*Math.random())]})}),t.state.next&&BDV2.react.createElement("button",{type:"button",onClick:()=>{t.state.loading||(t.setState({loading:!0}),t.search(t.state.next,!1))},className:"ui-button filled brand small grow",style:{width:"100%",marginTop:"10px",marginBottom:"10px"}},BDV2.react.createElement("div",{className:"ui-button-contents"},t.state.loading?"Loading":"Load More")),0<t.state.servers.length&&BDV2.react.createElement(V2Components.SettingsTitle,{text:t.state.title}))]}get notConnected(){let t=this;return[BDV2.react.createElement("div",{key:"ncc",ref:"content",className:"content-column default"},BDV2.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},"Not connected to discordservers.com!",BDV2.react.createElement("button",{onClick:t.connect,type:"button",className:"ui-button filled brand small grow",style:{display:"inline-block",minHeight:"18px",marginLeft:"10px",lineHeight:"14px"}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Connect"))),t.bdServer)]}get footer(){return BDV2.react.createElement("div",{className:"ui-tab-bar-header"},BDV2.react.createElement("a",{href:"https://discordservers.com",target:"_blank"},"Discordservers.com"))}get connection(){let t=this,{connection:a}=t.state;return 2===a.state?BDV2.react.createElement("span",null,BDV2.react.createElement(V2Components.TabBar.Separator,null),BDV2.react.createElement("span",{style:{color:"#b9bbbe",fontSize:"10px",marginLeft:"10px"}},"Connected as: ",`${a.user.username}#${a.user.discriminator}`),BDV2.react.createElement("div",{style:{padding:"5px 10px 0 10px"}},BDV2.react.createElement("button",{style:{width:"100%",minHeight:"20px"},type:"button",className:"ui-button filled brand small grow"},BDV2.react.createElement("div",{className:"ui-button-contents",onClick:t.connect},"Reconnect")))):BDV2.react.createElement("span",null)}}