BetterDiscordApp-rauenzi/js/main.min.js

52 lines
85 KiB
JavaScript

(function(){let a=window.require("fs"),o=window.require("process"),d=o.platform,l=("win32"===d?o.env.APPDATA:"darwin"===d?o.env.HOME+"/Library/Preferences":process.env.HOME+"/.config")+"/BetterDiscord/",u="localStorage.json",h={};if(a.existsSync(`${l}${u}`))try{h=JSON.parse(a.readFileSync(`${l}${u}`))}catch(f){console.log(f)}else if(a.existsSync(u))try{h=JSON.parse(a.readFileSync(u))}catch(f){console.log(f)}var g=h;g.setItem=function(f,y){g[f]=y,this.save()},g.getItem=function(f){return g[f]||null},g.save=function(){a.writeFileSync(`${l}${u}`,JSON.stringify(this),null,4)};var b=new Proxy(g,{set:function(f,y,E){g[y]=E,g.save()},get:function(f,y){return g[y]||null}});window.localStorage=b})(),(()=>{let a=document.createElement("div");a.className="bd-loaderv2",a.title="BetterDiscord is loading...",document.body.appendChild(a)})(),window.bdStorage={},window.bdStorage.get=function(a){return betterDiscordIPC.sendSync("synchronous-message",{arg:"storage",cmd:"get","var":a})},window.bdStorage.set=function(a,o){betterDiscordIPC.sendSync("synchronous-message",{arg:"storage",cmd:"set","var":a,data:o})},window.bdPluginStorage={},window.bdPluginStorage.get=function(a,o){return betterDiscordIPC.sendSync("synchronous-message",{arg:"pluginstorage",cmd:"get",pn:a,"var":o})},window.bdPluginStorage.set=function(a,o,d){betterDiscordIPC.sendSync("synchronous-message",{arg:"pluginstorage",cmd:"set",pn:a,"var":o,data:d})};var bdSettings={},bdSettingsStorage={};bdSettingsStorage.initialize=function(){let a=require("fs"),o={};if(a.existsSync(bdConfig.dataPath+"/bdsettings.json"))try{o=JSON.parse(a.readFileSync(bdConfig.dataPath+"/bdsettings.json"))}catch(d){o={}}bdSettings=o?o:{}},bdSettingsStorage.get=function(a){return bdSettings[a]?bdSettings[a]:null},bdSettingsStorage.set=function(a,o){let d=require("fs");bdSettings[a]=o;try{return d.writeFileSync(bdConfig.dataPath+"/bdsettings.json",JSON.stringify(bdSettings,null,4)),!0}catch(l){return utils.err(l),!1}};var settingsPanel,emoteModule,utils,quickEmoteMenu,voiceMode,pluginModule,themeModule,dMode,publicServersModule,jsVersion=1.792,supportedVersion="0.2.81",bbdVersion="0.1.0",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(a){window.bdConfig=a}var classNormalizer;Core.prototype.init=async function(){function a(){0<document.querySelectorAll(`.${BDV2.guildClasses.guilds} .${BDV2.guildClasses.guild}`).length?(bdConfig.deferLoaded=!0,o.injectExternals(),utils.log("Updating Settings"),settingsPanel=new V2_SettingsPanel,settingsPanel.updateSettings(),!bdpluginErrors&&(bdpluginErrors=[]),!bdthemeErrors&&(bdthemeErrors=[]),utils.log("Loading Plugins"),pluginModule=new PluginModule,pluginModule.loadPlugins(),settingsCookie["fork-ps-4"]&&(utils.log("Loading Themes"),classNormalizer.start()),utils.log("Loading Themes"),themeModule=new ThemeModule,themeModule.loadThemes(),$("#customcss").detach().appendTo(document.head),utils.log("Initializing QuickEmoteMenu"),quickEmoteMenu.init(),window.addEventListener("beforeunload",function(){settingsCookie["bda-dc-0"]&&document.querySelector(".btn.btn-disconnect").click()}),publicServersModule.initialize(),emoteModule.autoCapitalize(),settingsCookie.version<jsVersion&&(settingsCookie.version=jsVersion,o.saveSettings()),utils.log("Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2")[0].remove(),utils.log("Initializing Main Observer"),o.initObserver(),settingsCookie["fork-ps-1"]&&(utils.log("Collecting Startup Errors"),o.showStartupErrors())):setTimeout(a,100)}var o=this;bdConfig.deferLoaded=!1;var d="undefined"==typeof version?bdVersion:version;return d<supportedVersion?void this.alert("Not Supported","BetterDiscord v"+d+"(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=new Utils,await utils.getHash(),utils.log("Initializing Settings"),this.initSettings(),classNormalizer=new ClassNormalizer,emoteModule=new EmoteModule,utils.log("Initializing EmoteModule"),emoteModule.init().then(()=>{emoteModule.initialized=!0}),publicServersModule=new V2_PublicServers,quickEmoteMenu=new QuickEmoteMenu,voiceMode=new VoiceMode,dMode=new devMode,$(document).ready(function(){setTimeout(a,1e3)}))},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(),$.cookie("better-discord"))return settingsCookie=JSON.parse($.cookie("better-discord")),this.saveSettings(),void $.removeCookie("better-discord",{path:"/"});if(!bdSettingsStorage.get("settings"))settingsCookie=defaultCookie,this.saveSettings();else for(var a in this.loadSettings(),$("<style id=\"customcss\">").html(atob(window.bdStorage.get("bdcustomcss"))).appendTo(document.head),defaultCookie)void 0==settingsCookie[a]&&(settingsCookie[a]=defaultCookie[a],this.saveSettings())},Core.prototype.saveSettings=function(){bdSettingsStorage.set("settings",settingsCookie)},Core.prototype.loadSettings=function(){settingsCookie=bdSettingsStorage.get("settings")},Core.prototype.initObserver=function(){const a=new MutationObserver(o=>{for(let u,d=0,l=o.length;d<l;d++)if(u=o[d],"undefined"!=typeof pluginModule&&pluginModule.rawObserver(u),u.addedNodes.length&&u.addedNodes[0]instanceof Element){let g=u.addedNodes[0];g.classList.contains("layer-3QrUeG")&&(g.getElementsByClassName("guild-settings-base-section").length&&g.setAttribute("layer-id","server-settings"),g.getElementsByClassName("socialLinks-3jqNFy").length&&(g.setAttribute("layer-id","user-settings"),g.setAttribute("id","user-settings"),!document.getElementById("bd-settings-sidebar")&&settingsPanel.renderSidebar())),g.classList.contains("popout-3sVMXz")&&!g.classList.contains("popoutLeft-30WmrD")&&g.getElementsByClassName("emojiPicker-3m1S-j").length&&quickEmoteMenu.obsCallback(g)}});a.observe(document,{childList:!0,subtree:!0})},Core.prototype.inject24Hour=function(){this.cancel24Hour||(this.cancel24Hour=Utils.monkeyPatch(BDV2.TimeFormatter,"calendarFormat",{before:({methodArguments:o})=>{settingsCookie["bda-gs-6"]&&(o[0]._locale._abbr="en-GB")}}))},Core.prototype.injectColoredText=function(){this.cancelColoredText||(this.cancelColoredText=Utils.monkeyPatch(BDV2.MessageContentComponent.prototype,"render",{after:o=>{if(settingsCookie["bda-gs-7"]){const d=o.returnValue.props.children[1],l=o.thisObject.props.message.colorString;return d&&l&&(d.props.style={color:l}),o.returnValue}}}))},Core.prototype.removeColoredText=function(){document.querySelectorAll(".markup-2BOw-j").forEach(o=>{o.style.setProperty("color","")})},Core.prototype.alert=function(a,o){let d=$(`<div class="bd-modal-wrapper theme-dark">
<div class="bd-backdrop backdrop-1ocfXc"></div>
<div class="bd-modal modal-1UGdnR">
<div class="bd-modal-inner inner-1JeGVc">
<div class="header header-1R_AjF">
<div class="title">${a}</div>
</div>
<div class="bd-modal-body">
<div class="scroller-wrap fade">
<div class="scroller">
${o}
</div>
</div>
</div>
<div class="footer footer-2yfCgX">
<button type="button">Okay</button>
</div>
</div>
</div>
</div>`);d.find(".footer button").on("click",()=>{d.addClass("closing"),setTimeout(()=>{d.remove()},300)}),d.find(".bd-backdrop").on("click",()=>{d.addClass("closing"),setTimeout(()=>{d.remove()},300)}),d.appendTo("#app-mount")},Core.prototype.showStartupErrors=function(){function a(l){let u=$(`<div class="errors">`);for(let h of l){let g=$(`<div class="error">
<div class="table-column column-name">${h.name?h.name:h.file}</div>
<div class="table-column column-reason">${h.reason}</div>
<div class="table-column column-error"><a class="error-link" href="">${h.error?h.error.message:""}</a></div>
</div>`);u.append(g),h.error&&g.find("a").on("click",b=>{b.preventDefault(),utils.err(`Error details for ${h.name?h.name:h.file}.`,h.error)})}return u}if(bdpluginErrors&&bdthemeErrors&&(bdpluginErrors.length||bdthemeErrors.length)){let o=$(`<div class="bd-modal-wrapper theme-dark">
<div class="bd-backdrop backdrop-1ocfXc"></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>`),d=[a(bdpluginErrors),a(bdthemeErrors)];o.find(".tab-bar-item").on("click",l=>{l.preventDefault(),o.find(".tab-bar-item").removeClass("selected"),$(l.target).addClass("selected"),o.find(".scroller").empty().append(d[$(l.target).index()])}),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"),o.find(".tab-bar-item")[0].click()}},Core.prototype.showToast=function(a,o={}){if(bdConfig.deferLoaded){if(!document.querySelector(".bd-toasts")){let g=document.createElement("div");g.classList.add("bd-toasts");let b=document.querySelector(".chat-3bRxxu form, #friends, .noChannel-Z1DQK7, .activityFeed-28jde9");g.style.setProperty("left",b?b.getBoundingClientRect().left+"px":"0px"),g.style.setProperty("width",b?b.offsetWidth+"px":"100%"),g.style.setProperty("bottom",(document.querySelector(".chat-3bRxxu form")?document.querySelector(".chat-3bRxxu form").offsetHeight:80)+"px"),document.querySelector(".app").appendChild(g)}const{type:d="",icon:l=!0,timeout:u=3e3}=o;let h=document.createElement("div");h.classList.add("bd-toast"),d&&h.classList.add("toast-"+d),d&&l&&h.classList.add("icon"),h.innerText=a,document.querySelector(".bd-toasts").appendChild(h),setTimeout(()=>{h.classList.add("closing"),setTimeout(()=>{h.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},u)}};var emotesFfz={},emotesBTTV={},emotesBTTV2={},emotesTwitch={},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 a={TwitchGlobal:{url:"https://twitchemotes.com/api_cache/v3/global.json",backup:"https://"+bdConfig.updater.CDN+"/"+bdConfig.repo+"/BetterDiscordApp/"+bdConfig.hash+"/data/emotedata_twitch_global.json",variable:"TwitchGlobal",oldVariable:"emotesTwitch",getEmoteURL:o=>`https://static-cdn.jtvnw.net/emoticons/v1/${o.id}/1.0`,getOldData:(o,d)=>{return{id:o.match(/\/([0-9]+)\//)[1],code:d,emoticon_set:0,description:null}}},TwitchSubscriber:{url:"https://twitchemotes.com/api_cache/v3/subscriber.json",backup:"https://"+bdConfig.updater.CDN+"/"+bdConfig.repo+"/BetterDiscordApp/"+bdConfig.hash+"/data/emotedata_twitch_subscriber.json",variable:"TwitchSubscriber",oldVariable:"subEmotesTwitch",parser:o=>{let d={};for(let l in o){let u=o[l];for(let b,h=0,g=u.emotes.length;h<g;h++)b=u.emotes[h],d[b.code]=b.id}return d},backupParser:o=>{return o},getEmoteURL:o=>`https://static-cdn.jtvnw.net/emoticons/v1/${o}/1.0`,getOldData:o=>o.match(/\/([0-9]+)\//)[1]},FrankerFaceZ:{url:"https://"+bdConfig.updater.CDN+"/"+bdConfig.repo+"/BetterDiscordApp/"+bdConfig.hash+"/data/emotedata_ffz.json",variable:"FrankerFaceZ",oldVariable:"emotesFfz",getEmoteURL:o=>`https://cdn.frankerfacez.com/emoticon/${o}/1`,getOldData:o=>o.match(/\/([0-9]+)\//)[1]},BTTV:{url:"https://api.betterttv.net/emotes",variable:"BTTV",oldVariable:"emotesBTTV",parser:o=>{let d={};for(let h,l=0,u=o.emotes.length;l<u;l++)h=o.emotes[l],d[h.regex]=h.url;return d},getEmoteURL:o=>`${o}`,getOldData:o=>o},BTTV2:{url:"https://"+bdConfig.updater.CDN+"/"+bdConfig.repo+"/BetterDiscordApp/"+bdConfig.hash+"/data/emotedata_bttv.json",variable:"BTTV2",oldVariable:"emotesBTTV2",getEmoteURL:o=>`https://cdn.betterttv.net/emote/${o}/1x`,getOldData:o=>o.match(/emote\/(.+)\//)[1]}};for(this.loadEmoteData(a),this.getBlacklist();!BDV2.MessageContentComponent;)await new Promise(o=>setTimeout(o,100));this.cancelEmoteRender||(this.cancelEmoteRender=Utils.monkeyPatch(BDV2.MessageContentComponent.prototype,"render",{after:({thisObject:o,returnValue:d})=>{const l=d.props.children[1];if(l.props.children){const u=l.props.children[1];if(u&&u.length){for(let g=0;g<u.length;g++){const b=u[g];if("string"==typeof b){const F=b.split(/([^\s]+)([\s]|$)/g);for(let M=0,I=this.categories.length;M<I;M++)for(let q=0,G=F.length;q<G;q++){let R=F[q],z=R.split(":"),V=z[0],U=z[1]?z[1]:"",H=U.slice(0);if(!(bemotes.includes(V)||4>V.length)){this.modifiers.includes(U)&&settingsCookie["bda-es-8"]||(U=""),this.overrides.includes(H)?U=H:H="";let W=this.categories[M];if("twitch"===H?bdEmotes.TwitchGlobal[V]?W="TwitchGlobal":bdEmotes.TwitchSubscriber[V]&&(W="TwitchSubscriber"):"bttv"===H?bdEmotes.BTTV[V]?W="BTTV":bdEmotes.BTTV2[V]&&(W="BTTV2"):"ffz"==H&&bdEmotes.FrankerFaceZ[V]&&(W="FrankerFaceZ"),bdEmotes[W][V]&&settingsCookie[bdEmoteSettingIDs[W]]){const Z=u[g].match(new RegExp(`([\\s]|^)${utils.escape(U?V+":"+U:V)}([\\s]|$)`));if(Z){const J=u[g].substring(0,Z.index+Z[1].length),K=u[g].substring(Z.index+Z[0].length-Z[2].length);u[g]=J;const Q=BDV2.react.createElement(BDEmote,{name:V,url:bdEmotes[W][V],modifier:U});u.splice(g+1,0,K),u.splice(g+1,0,Q),g+=2}}}}}}const h=u.every(g=>{return"string"==typeof g&&""==g.replace(/\s*/,"")||g.type&&"BDEmote"==g.type.name||g.props&&g.props.children&&g.props.children.props&&g.props.children.props.emojiName});if(h)for(let g of u)"object"==typeof g&&("BDEmote"==g.type.name?g.props.jumboable=!0:g.props&&g.props.children&&g.props.children.props&&g.props.children.props.emojiName&&(g.props.children.props.jumboable=!0))}}}}))},EmoteModule.prototype.clearEmoteData=async function(){let a=require("fs"),d=bdConfig.dataPath+"emote_data.json",l=a.existsSync(d);l&&a.unlinkSync(d),window.bdEmotes={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}}},EmoteModule.prototype.goBack=async function(a){for(let o in a)for(let d in bdEmotes[a[o].variable])window[a[o].oldVariable][d]=a[o].getOldData(bdEmotes[a[o].variable][d],d)},EmoteModule.prototype.loadEmoteData=async function(a){let o=require("fs"),l=bdConfig.dataPath+"emote_data.json",u=o.existsSync(l);if(u&&!bdConfig.cache.expired){settingsCookie["fork-ps-2"]&&mainCore.showToast("Loading emotes from cache.",{type:"info"}),utils.log("[Emotes] Loading emotes from local cache.");let h=await new Promise(b=>{o.readFile(l,"utf8",(y,E)=>{utils.log("[Emotes] Emotes loaded from cache."),y&&(E={}),b(E)})}),g=Utils.testJSON(h);for(let b in g&&(bdEmotes=JSON.parse(h)),a)g=0<Object.keys(bdEmotes[a[b].variable]).length;if(g)return await this.goBack(a),void(settingsCookie["fork-ps-2"]&&mainCore.showToast("Emotes successfully loaded.",{type:"success"}));utils.log("[Emotes] Cache was corrupt, downloading..."),o.unlinkSync(l)}if(!settingsCookie["fork-es-3"])return quickEmoteMenu.init();for(let h in settingsCookie["fork-ps-2"]&&mainCore.showToast("Downloading emotes in the background do not reload.",{type:"info"}),a){let g=await this.downloadEmotes(a[h]);bdEmotes[a[h].variable]=g}await this.goBack(a),settingsCookie["fork-ps-2"]&&mainCore.showToast("All emotes successfully downloaded.",{type:"success"});try{o.writeFileSync(l,JSON.stringify(bdEmotes),"utf8")}catch(h){utils.err("[Emotes] Could not save emote data.",h)}quickEmoteMenu.init()},EmoteModule.prototype.downloadEmotes=function(a){let o=require("request"),d={url:a.url,timeout:a.timeout?a.timeout:5e3};return utils.log("[Emotes] Downloading: "+a.variable),new Promise((l,u)=>{o(d,(h,g,b)=>{if(h)return utils.err("[Emotes] Could not download "+a.variable,h),a.backup?(a.url=a.backup,a.backup=null,a.backupParser&&(a.parser=a.backupParser),l(this.downloadEmotes(a))):u({});let f={};try{f=JSON.parse(b)}catch(y){return utils.err("[Emotes] Could not download "+a.variable,h),a.backup?(a.url=a.backup,a.backup=null,a.backupParser&&(a.parser=a.backupParser),l(this.downloadEmotes(a))):u({})}for(let y in"function"==typeof a.parser&&(f=a.parser(f)),f)f[y]=a.getEmoteURL(f[y]);l(f),utils.log("[Emotes] Downloaded: "+a.variable)})})},EmoteModule.prototype.getBlacklist=function(){$.getJSON("https://cdn.rawgit.com/rauenzi/betterDiscordApp/"+_hash+"/data/emotefilter.json",function(a){bemotes=a.blacklist})};var bemotes=[];EmoteModule.prototype.autoCapitalize=function(){$("body").delegate($(".channelTextArea-1LDbYG textarea:first"),"keyup change paste",()=>{if(settingsCookie["bda-es-4"]){var a=$(".channelTextArea-1LDbYG textarea:first").val();if(void 0!=a){var o=a.split(" ").pop();if(3<o.length){if("danSgame"==o)return;var d=this.capitalize(o.toLowerCase());null!==d&&void 0!==d&&utils.insertText(utils.getTextArea()[0],a.replace(o,d))}}}})},EmoteModule.prototype.capitalize=function(a){var o=bdEmotes.TwitchGlobal;for(var d in o)if(o.hasOwnProperty(d)&&a==(d+"").toLowerCase())return d};function QuickEmoteMenu(){}QuickEmoteMenu.prototype.init=function(){$(document).on("mousedown",function(h){"rmenu"!=h.target.id&&$("#rmenu").remove()}),this.favoriteEmotes={};var a=window.bdStorage.get("bdfavemotes");""!==a&&null!==a&&(this.favoriteEmotes=JSON.parse(atob(a)));var o="";o+="<div id=\"bda-qem\">",o+=" <button class=\"active\" id=\"bda-qem-twitch\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Twitch</button>",o+=" <button id=\"bda-qem-favourite\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Favourite</button>",o+=" <button id=\"bda-qem-emojis\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Emojis</buttond>",o+="</div>",this.qmeHeader=o;var d="";for(let h in d+="<div id=\"bda-qem-twitch-container\">",d+=" <div class=\"scroller-wrap fade\">",d+=" <div class=\"scroller\">",d+=" <div class=\"emote-menu-inner\">",bdEmotes.TwitchGlobal)if(bdEmotes.TwitchGlobal.hasOwnProperty(h)){var l=bdEmotes.TwitchGlobal[h];d+="<div class=\"emote-container\">",d+=" <img class=\"emote-icon\" alt=\"\" src=\""+l+"\" title=\""+h+"\">",d+=" </img>",d+="</div>"}d+=" </div>",d+=" </div>",d+=" </div>",d+="</div>",this.teContainer=d;var u="";for(let h in u+="<div id=\"bda-qem-favourite-container\">",u+=" <div class=\"scroller-wrap fade\">",u+=" <div class=\"scroller\">",u+=" <div class=\"emote-menu-inner\">",this.favoriteEmotes){var l=this.favoriteEmotes[h];u+="<div class=\"emote-container\">",u+=" <img class=\"emote-icon\" alt=\"\" src=\""+l+"\" title=\""+h+"\" oncontextmenu='quickEmoteMenu.favContext(event, this);'>",u+=" </img>",u+="</div>"}u+=" </div>",u+=" </div>",u+=" </div>",u+="</div>",this.faContainer=u},QuickEmoteMenu.prototype.favContext=function(a,o){a.stopPropagation();var d=$("<div>",{id:"rmenu","data-emoteid":$(o).prop("title"),text:"Remove",class:"context-menu theme-dark"});return d.css({top:a.pageY-$("#bda-qem-favourite-container").offset().top,left:a.pageX-$("#bda-qem-favourite-container").offset().left}),$(o).parent().append(d),d.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(a){this.switchQem($(a).attr("id"))},QuickEmoteMenu.prototype.switchQem=function(a){var o=$("#bda-qem-twitch"),d=$("#bda-qem-favourite"),l=$("#bda-qem-emojis");o.removeClass("active"),d.removeClass("active"),l.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide();"bda-qem-twitch"===a?(o.addClass("active"),$("#bda-qem-twitch-container").show()):"bda-qem-favourite"===a?(d.addClass("active"),$("#bda-qem-favourite-container").show()):"bda-qem-emojis"===a?(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=a;var u=$(".emote-icon");u.off(),u.on("click",function(){var h=$(this).attr("title"),g=utils.getTextArea();utils.insertText(g[0]," "==g.val().slice(-1)?g.val()+h:g.val()+" "+h)})},QuickEmoteMenu.prototype.obsCallback=function(a){var o=$(a);settingsCookie["bda-es-9"]?o.removeClass("bda-qme-hidden"):o.addClass("bda-qme-hidden");settingsCookie["bda-es-0"]&&(o.prepend(this.qmeHeader),o.append(this.teContainer),o.append(this.faContainer),this.lastTab==void 0&&(this.lastTab="bda-qem-favourite"),this.switchQem(this.lastTab))},QuickEmoteMenu.prototype.favorite=function(a,o){this.favoriteEmotes.hasOwnProperty(a)||(this.favoriteEmotes[a]=o),this.updateFavorites()},QuickEmoteMenu.prototype.updateFavorites=function(){var a="";for(var o in a+="<div id=\"bda-qem-favourite-container\">",a+=" <div class=\"scroller-wrap fade\">",a+=" <div class=\"scroller\">",a+=" <div class=\"emote-menu-inner\">",this.favoriteEmotes){var d=this.favoriteEmotes[o];a+="<div class=\"emote-container\">",a+=" <img class=\"emote-icon\" alt=\"\" src=\""+d+"\" title=\""+o+"\" oncontextmenu=\"quickEmoteMenu.favContext(event, this);\">",a+=" </img>",a+="</div>"}a+=" </div>",a+=" </div>",a+=" </div>",a+="</div>",this.faContainer=a,$("#bda-qem-favourite-container").replaceWith(a),window.bdStorage.set("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))};var _hash;function Utils(){}Utils.prototype.getTextArea=function(){return $(".channelTextArea-1LDbYG textarea")},Utils.prototype.insertText=function(a,o){a.focus(),a.selectionStart=0,a.selectionEnd=a.value.length,document.execCommand("insertText",!1,o)},Utils.prototype.jqDefer=function(a){window.jQuery?a():setTimeout(function(){this.jqDefer(a)},100)},Utils.prototype.getHash=function(){return new Promise(a=>{$.getJSON("https://api.github.com/repos/rauenzi/BetterDiscordApp/commits/master").done(function(o){_hash=o.sha,bdConfig.hash=_hash,a(_hash)}).fail(()=>{_hash=_bdhash||"48844445d65c6fb5a019eff14d7dcffcc1744071",a(_hash)})})},Utils.prototype.loadHtml=function(a,o){var d=$("<div/>",{class:"bd-container"}).appendTo("body");a="//cdn.rawgit.com/Jiiks/BetterDiscordApp/"+_hash+"/html/"+a+".html",d.load(a,o())},Utils.prototype.injectJs=function(a){$("<script/>",{type:"text/javascript",src:a}).appendTo($("body"))},Utils.prototype.injectCss=function(a){$("<link/>",{type:"text/css",rel:"stylesheet",href:a}).appendTo($("head"))},Utils.prototype.escapeID=function(a){return a.replace(/^[^a-z]+|[^\w-]+/gi,"")},Utils.prototype.log=function(a){console.log("%c[BetterDiscord] %c"+a+"","color: #3a71c1; font-weight: 700;","")},Utils.prototype.err=function(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())},Utils.prototype.escape=function(a){return a.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")},Utils.prototype.insertElement=function(a,o,d){for(var l=a.firstChild;l;){if(l.nodeType!=Node.TEXT_NODE){l=l.nextSibling;continue}var u=0;l.data.replace(o,function(h){var g=[].slice.call(arguments),b=g[g.length-2],f=g[1]?l.splitText(b+g[1].length+u):l.splitText(b+u);u-=l.data.length+h.length,f.data=f.data.substr(h.trim().length),l.parentNode.insertBefore(d,f),l=f}),o.lastIndex=0,l=l.nextSibling}return a},Utils.prototype.getTextNodes=function(a){var o=[];if(!a)return o;for(var l,d=0;d<a.childNodes.length;d++)l=a.childNodes[d],l.nodeType===Node.TEXT_NODE&&o.push(l);return o},Utils.testJSON=function(a){try{JSON.parse(a);return!0}catch(o){return!1}return!1},Utils.suppressErrors=(a,o)=>(...d)=>{try{return a(...d)}catch(l){console.error("Error occurred in "+o,l)}},Utils.monkeyPatch=(a,o,d)=>{const{before:l,after:u,instead:h,once:g=!1,silent:b=!1,force:f=!1}=d,y=d.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 x={thisObject:this,methodArguments:arguments,cancelPatch:C,originalMethod:E,callOriginalMethod:()=>x.returnValue=x.originalMethod.apply(x.thisObject,x.methodArguments)};if(h){const S=Utils.suppressErrors(h,"`instead` callback of "+a[o].displayName)(x);void 0!==S&&(x.returnValue=S)}else l&&Utils.suppressErrors(l,"`before` callback of "+a[o].displayName)(x),x.callOriginalMethod(),u&&Utils.suppressErrors(u,"`after` callback of "+a[o].displayName)(x);return g&&C(),x.returnValue},a[o].__monkeyPatched=!0,a[o].displayName="patched "+(a[o].displayName||o),C};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 a=Object.keys(bdplugins),o=0;o<a.length;o++){var d,l;try{d=bdplugins[a[o]].plugin,l=d.getName(),d.load()}catch(u){pluginCookie[l]=!1,utils.err("Plugin "+l+" could not be loaded.",u),bdpluginErrors.push({name:l,file:bdplugins[a[o]].filename,reason:"load() could not be fired.",error:{message:u.message,stack:u.stack}});continue}if(pluginCookie[l]||(pluginCookie[l]=!1),pluginCookie[l])try{d.start(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${d.getName()} v${d.getVersion()} has started.`)}catch(u){pluginCookie[l]=!1,utils.err("Plugin "+l+" could not be started.",u),bdpluginErrors.push({name:l,file:bdplugins[a[o]].filename,reason:"start() could not be fired.",error:{message:u.message,stack:u.stack}})}}for(let u in pluginCookie)bdplugins[u]||delete pluginCookie[u];this.savePluginData(),require("electron").remote.getCurrentWebContents().on("did-navigate-in-page",this.channelSwitch.bind(this))},PluginModule.prototype.startPlugin=function(a){try{bdplugins[a].plugin.start(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdplugins[a].plugin.getName()} v${bdplugins[a].plugin.getVersion()} has started.`)}catch(o){pluginCookie[a]=!1,this.savePluginData(),utils.err("Plugin "+name+" could not be started.",o)}},PluginModule.prototype.stopPlugin=function(a){try{bdplugins[a].plugin.stop(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdplugins[a].plugin.getName()} v${bdplugins[a].plugin.getVersion()} has stopped.`)}catch(o){utils.err("Plugin "+name+" could not be stopped.",o)}},PluginModule.prototype.enablePlugin=function(a){pluginCookie[a]=!0,this.savePluginData(),this.startPlugin(a)},PluginModule.prototype.disablePlugin=function(a){pluginCookie[a]=!1,this.savePluginData(),this.stopPlugin(a)},PluginModule.prototype.togglePlugin=function(a){pluginCookie[a]?this.disablePlugin(a):this.enablePlugin(a)},PluginModule.prototype.loadPluginData=function(){if($.cookie("bd-plugins"))return pluginCookie=JSON.parse($.cookie("bd-plugins")),this.savePluginData(),void $.removeCookie("bd-plugins",{path:"/"});let a=bdSettingsStorage.get("plugins");a&&(pluginCookie=a)},PluginModule.prototype.savePluginData=function(){bdSettingsStorage.set("plugins",pluginCookie)},PluginModule.prototype.newMessage=function(){for(var d,a=Object.keys(bdplugins),o=0;o<a.length;o++)if(d=bdplugins[a[o]].plugin,pluginCookie[d.getName()]&&"function"==typeof d.onMessage)try{d.onMessage()}catch(Y){utils.err("Unable to fire onMessage for "+d.getName()+".",Y)}},PluginModule.prototype.channelSwitch=function(){for(var d,a=Object.keys(bdplugins),o=0;o<a.length;o++)if(d=bdplugins[a[o]].plugin,pluginCookie[d.getName()]&&"function"==typeof d.onSwitch)try{d.onSwitch()}catch(X){utils.err("Unable to fire onSwitch for "+d.getName()+".",X)}},PluginModule.prototype.rawObserver=function(a){for(var l,o=Object.keys(bdplugins),d=0;d<o.length;d++)if(l=bdplugins[o[d]].plugin,pluginCookie[l.getName()]&&"function"==typeof l.observer)try{l.observer(a)}catch(ee){utils.err("Unable to fire observer for "+l.getName()+".",ee)}};var themeCookie={};function ThemeModule(){}ThemeModule.prototype.loadThemes=function(){this.loadThemeData();for(var d,a=Object.keys(bdthemes),o=0;o<a.length;o++)d=bdthemes[a[o]].name,themeCookie[d]||(themeCookie[d]=!1),themeCookie[d]&&$("head").append($("<style>",{id:utils.escapeID(d),html:unescape(bdthemes[d].css)}));for(let l in themeCookie)bdthemes[l]||delete themeCookie[l];this.saveThemeData()},ThemeModule.prototype.enableTheme=function(a){themeCookie[a]=!0,this.saveThemeData(),$("head").append(`<style id="${utils.escapeID(bdthemes[a].name)}">${unescape(bdthemes[a].css)}</style>`),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdthemes[a].name} v${bdthemes[a].version} has been applied.`)},ThemeModule.prototype.disableTheme=function(a){themeCookie[a]=!1,this.saveThemeData(),$(`#${utils.escapeID(bdthemes[a].name)}`).remove(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdthemes[a].name} v${bdthemes[a].version} has been removed.`)},ThemeModule.prototype.toggleTheme=function(a){themeCookie[a]?this.disableTheme(a):this.enableTheme(a)},ThemeModule.prototype.loadThemeData=function(){if($.cookie("bd-themes"))return themeCookie=JSON.parse($.cookie("bd-themes")),this.saveThemeData(),void $.removeCookie("bd-themes",{path:"/"});let a=bdSettingsStorage.get("themes");a&&(themeCookie=a)},ThemeModule.prototype.saveThemeData=function(){bdSettingsStorage.set("themes",themeCookie)};function BdApi(){}BdApi.injectCSS=function(a,o){$("head").append($("<style>",{id:utils.escapeID(a),html:o}))},BdApi.clearCSS=function(a){$("#"+utils.escapeID(a)).remove()},BdApi.linkJS=function(a,o){$("head").append($("<script>",{id:utils.escapeID(a),src:o,type:"text/javascript"}))},BdApi.unlinkJS=function(a){$("#"+utils.escapeID(a)).remove()},BdApi.getPlugin=function(a){return bdplugins.hasOwnProperty(a)?bdplugins[a].plugin:null},BdApi.getIpc=function(){return betterDiscordIPC},BdApi.getCore=function(){return mainCore},BdApi.alert=function(a,o){mainCore.alert(a,o)},BdApi.showToast=function(a,o={}){mainCore.showToast(a,o)};function devMode(){}devMode.prototype.enable=function(a){var o=this;this.disable(),$(window).on("keydown.bdDevmode",function(d){if(119===d.which){console.log("%c[%cDevMode%c] %cBreak/Resume","color: red;","color: #303030; font-weight:700;","color:red;","");debugger}});a&&$(document).on("contextmenu.bdDevmode",function(d){var u=[];$(d.toElement).parents().addBack().not("html").each(function(){var h="";this.classList&&this.classList.length&&(h+="."+Array.prototype.join.call(this.classList,"."),u.push(h))}),o.lastSelector=u.join(" ").trim(),setImmediate(function(){var h=$(".contextMenu-HLZMGh");0>=h.length&&(h=$("<div class=\"contextMenu-HLZMGh bd-context-menu\"></div>"),h.addClass($(".app").hasClass("theme-dark")?"theme-dark":"theme-light"),h.appendTo(".app"),h.css("top",d.clientY),h.css("left",d.clientX),$(document).on("click.bdDevModeCtx",()=>{h.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("contextmenu.bdDevModeCtx",()=>{h.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("keyup.bdDevModeCtx",f=>{27===f.keyCode&&(h.remove(),$(document).off(".bdDevModeCtx"))}));var g=$("<div/>",{class:"itemGroup-1tL0uz"}),b=$("<div/>",{class:"item-1Yvehc",click:function(){var f=$("<textarea/>",{text:o.lastSelector}).appendTo("body");f.select(),document.execCommand("copy"),f.remove(),h.hide()}}).append($("<span/>",{text:"Copy Selector"}));g.append(b),h.append(g),h.hasClass("undefined")&&h.css("top","-="+g.outerHeight())}),d.stopPropagation()})},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(o=>{for(let d=0;d<o.length;d++){const l=o[d],u=l.addedNodes;if(u)for(let te=0;te<u.length;te++)u[te]instanceof Element&&u[te].classList&&this.normalizeClasses(u[te])}}),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(o){return o.split("-").map((d,l)=>l?d[0].toUpperCase()+d.slice(1):d).join("")}isRandomizedClass(o){return this.classFormat.test(o)}isNormalClass(o){return this.normFormat.test(o)}normalizeClasses(o){if(o instanceof Element){o.children&&o.children.length&&this.normalizeClasses(o.children[0]),o.nextElementSibling&&this.normalizeClasses(o.nextElementSibling);const d=o.classList,l=[];for(let u=0;u<d.length;u++)if(this.cache[d[u]])l.push(this.cache[d[u]]);else if(this.isNormalClass(d[u])){const h="da-"+this.toCamelCase(d[u]);l.push(h),this.cache[d[u]]=h}else if(this.isRandomizedClass(d[u])){const h="da-"+d[u].split("-")[0];l.push(h),this.cache[d[u]]=h}o.classList.add(...l)}}revertClasses(o){if(o instanceof Element){o.children&&o.children.length&&this.revertClasses(o.children[0]),o.nextElementSibling&&this.revertClasses(o.nextElementSibling);const d=o.classList,l=[];for(let u=0;u<d.length;u++)d[u].startsWith("da-")&&l.push(d[u]);o.classList.remove(...l)}}};class V2{constructor(){this.editorDetached=!1,this.WebpackModules=(()=>{const a="function"==typeof webpackJsonp?webpackJsonp([],{__extra_id__:(u,h,g)=>h.default=g},["__extra_id__"]).default:webpackJsonp.push([[],{__extra_id__:(u,h,g)=>u.exports=g},[["__extra_id__"]]]);delete a.m.__extra_id__,delete a.c.__extra_id__;const o=(u,h={})=>{const{cacheOnly:g=!0}=h;for(let b in a.c)if(a.c.hasOwnProperty(b)){let f=a.c[b].exports;if(f&&f.__esModule&&f.default&&u(f.default))return f.default;if(f&&u(f))return f}if(g)return console.warn("Cannot find loaded module in cache"),null;console.warn("Cannot find loaded module in cache. Loading all modules may have unexpected side effects");for(let b=0;b<a.m.length;++b)try{let f=a(b);if(f&&f.__esModule&&f.default&&u(f.default))return f.default;if(f&&u(f))return f}catch(f){console.error(f)}return console.warn("Cannot find module"),null};return{find:o,findByUniqueProperties:(u,h)=>o(g=>u.every(b=>g[b]!==void 0),h),findByDisplayName:(u,h)=>o(g=>g.displayName===u,h)}})(),this.internal={react:this.WebpackModules.findByUniqueProperties(["Component","PureComponent","Children","createElement","cloneElement"]),"react-dom":this.WebpackModules.findByUniqueProperties(["findDOMNode"])},this.getInternalInstance=a=>a[Object.keys(a).find(o=>o.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(a=>a.defaultProps&&a.defaultProps.hasOwnProperty("disableButtons"))}get TimeFormatter(){return BDV2.WebpackModules.findByUniqueProperties(["dateFormat"])}get TooltipWrapper(){return BDV2.WebpackModules.find(a=>a.prototype&&a.prototype.showDelayed)}get reactComponent(){return this.internal.react.Component}get react(){return this.internal.react}get reactDom(){return this.internal["react-dom"]}parseSettings(a){return Object.keys(settings).reduce((o,d)=>{let l=settings[d];return l.cat===a&&l.implemented&&!l.hidden&&(l.text=d,o.push(l)),o},[])}}var BDV2=new V2;class BDEmote extends BDV2.reactComponent{constructor(a){super(a),this.props.label=this.props.modifier?`${this.props.name}:${this.props.modifier}`:this.props.name,this.props.modifierClass=this.props.modifier?` emote${this.props.modifier}`:"",this.props.animateOnHover=bdSettings.settings["fork-es-2"];const o=quickEmoteMenu&&quickEmoteMenu.favoriteEmotes&&quickEmoteMenu.favoriteEmotes[this.props.label];this.state={shouldAnimate:!this.props.animateOnHover,isFavorite:o},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this)}onMouseEnter(){!this.state.shouldAnimate&&this.props.animateOnHover&&this.setState({shouldAnimate:!0}),!this.state.isFavorite&&quickEmoteMenu.favoriteEmotes[this.props.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!quickEmoteMenu.favoriteEmotes[this.props.label]&&this.setState({isFavorite:!1})}onMouseLeave(){this.state.shouldAnimate&&this.props.animateOnHover&&this.setState({shouldAnimate:!1})}render(){return BDV2.react.createElement(BDV2.TooltipWrapper,{color:"black",position:"top",text:this.props.label,delay:750},BDV2.react.createElement("div",{className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave},BDV2.react.createElement("img",{draggable:!1,className:"emote"+this.props.modifierClass+(this.props.jumboable?" jumboable":"")+(this.state.shouldAnimate?"":" stop-animation"),dataModifier:this.props.modifier,alt:this.props.label,src:this.props.url}),BDV2.react.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),this.state.isFavorite?(delete quickEmoteMenu.favoriteEmotes[this.props.label],quickEmoteMenu.updateFavorites()):quickEmoteMenu.favorite(this.props.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}class V2C_SettingsPanel extends BDV2.reactComponent{constructor(a){super(a)}render(){let{settings:a}=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),a.map(o=>{return BDV2.react.createElement(V2Components.Switch,{id:o.id,key:o.id,data:o,checked:settingsCookie[o.id],onChange:(d,l)=>{this.props.onChange(d,l)}})}))}}class V2C_Switch extends BDV2.reactComponent{constructor(a){super(a),this.setInitialState(),this.onChange=this.onChange.bind(this)}setInitialState(){this.state={checked:this.props.checked}}render(){let{text:a,info:o}=this.props.data,{checked:d}=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"},a),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:d,onChange:l=>this.onChange(l)}),BDV2.react.createElement("div",{className:`ui-switch ${d?"checked":""}`}))),BDV2.react.createElement("div",{className:"ui-form-text style-description margin-top-4",style:{flex:"1 1 auto"}},o))}onChange(){this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked})}}class V2C_Scroller extends BDV2.reactComponent{constructor(a){super(a)}render(){let a=`scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d${this.props.fade?" scrollerFade-1Ijw5y":""}`,o="scroller-2FKFPG scroller";this.props.sidebar&&(o="scroller-2FKFPG sidebar-region-scroller scroller scroller-2FKFPG"),this.props.contentColumn&&(o="scroller-2FKFPG content-region-scroller scroller scroller-2FKFPG",a="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:d}=this.props;return BDV2.react.createElement("div",{key:"scrollerwrap",className:a},BDV2.react.createElement("div",{key:"scroller",ref:"scroller",className:o},d))}}class V2C_TabBarItem extends BDV2.reactComponent{constructor(a){super(a),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(a){super(a)}render(){return BDV2.react.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class V2C_TabBarHeader extends BDV2.reactComponent{constructor(a){super(a)}render(){return BDV2.react.createElement("div",{className:"ui-tab-bar-header"},this.props.text)}}class V2C_SideBar extends BDV2.reactComponent{constructor(a){super(a);let o=this;const d=$("[class*=side] > [class*=selected]");d.length&&(o.scn=d.attr("class"));const l=$("[class*=side] > [class*=notSelected]");l.length&&(o.nscn=l.attr("class")),$("[class*='side-'] > [class*='item-']").on("click",()=>{o.setState({selected:null})}),o.setInitialState(),o.onClick=o.onClick.bind(o)}setInitialState(){let a=this;a.state={selected:null,items:a.props.items};let o=a.props.items.find(d=>{return d.selected});o&&(a.state.selected=o.id)}render(){let a=this,{headerText:o}=a.props,{items:d,selected:l}=a.state;return BDV2.react.createElement("div",null,BDV2.react.createElement(V2Components.TabBar.Separator,null),BDV2.react.createElement(V2Components.TabBar.Header,{text:o}),d.map(u=>{let{id:h,text:g}=u;return BDV2.react.createElement(V2Components.TabBar.Item,{key:h,selected:l===h,text:g,id:h,onClick:a.onClick})}))}onClick(a){let o=this;const d=$("[class*=side] > [class*=selected]");d.length&&(d.off("click.bdsb").on("click.bsb",l=>{$(l.target).attr("class",o.scn)}),d.attr("class",o.nscn)),o.setState({selected:null}),o.setState({selected:a}),o.props.onClick&&o.props.onClick(a)}}class V2C_XSvg extends BDV2.reactComponent{constructor(a){super(a)}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(a){super(a),this.onClick=this.onClick.bind(this)}render(){return BDV2.react.createElement("div",{className:"tools"},BDV2.react.createElement("div",{className:"btn-close",onClick:this.onClick},BDV2.react.createElement(V2Components.XSvg,null)),BDV2.react.createElement("div",{className:"esc-text"},"ESC"))}onClick(){this.props.onClick&&this.props.onClick(),$(".btn-close").first().click()}}class V2C_SettingsTitle extends BDV2.reactComponent{constructor(a){super(a)}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(a){super(a),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(a){super(a);let o=this;o.onClick=o.onClick.bind(o),o.updateCss=o.updateCss.bind(o),o.saveCss=o.saveCss.bind(o),o.onChange=o.onChange.bind(o)}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 a=this.refs.editor.value.split("\n").length;a==this.props.lines||(this.refs.lines.textContent=Array.from(Array(a),(o,d)=>d+1).join(".\n")+".",this.props.lines=a)}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){let a=window.bdStorage.get("bdcustomcss"),o="";return a&&""!==a&&(o=atob(a)),o}get root(){let a=$("#bd-customcss-detach-container");return a.length?a[0]:this.injectRoot()?this.detachedRoot:null}injectRoot(){return!!$(".app").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app")),!0)}render(){let a=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"},a.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:a.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:()=>{a.onClick("update")}},"Update"),BDV2.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{a.onClick("save")}},"Save"),BDV2.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{a.onClick("attach")}},"Attach"),BDV2.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on attach")))))}onChange(a,o){"live-update"===a?(settingsCookie["bda-css-0"]=o,mainCore.saveSettings()):void 0}onClick(a){let o=this;"attach"===a?($("#editor-detached").length&&o.props.attach(),BDV2.reactDom.unmountComponentAtNode(o.root),o.root.remove()):"update"===a?o.updateCss():"save"===a?o.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(a){super(a);let o=this;o.props.lines=0,o.setInitialState(),o.attach=o.attach.bind(o),o.detachedEditor=BDV2.react.createElement(V2C_CssEditorDetached,{attach:o.attach}),o.onClick=o.onClick.bind(o),o.updateCss=o.updateCss.bind(o),o.saveCss=o.saveCss.bind(o),o.detach=o.detach.bind(o)}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(a,o){let d=this;o.detached&&!d.state.detached&&BDV2.reactDom.unmountComponentAtNode(d.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){let a=window.bdStorage.get("bdcustomcss"),o="";return a&&""!==a&&(o=atob(a)),o}updateLineCount(){let a=this.refs.editor.value.split("\n").length;a==this.props.lines||(this.refs.lines.textContent=Array.from(Array(a),(o,d)=>d+1).join(".\n")+".",this.props.lines=a)}render(){let a=this,{detached:o}=a.state;return BDV2.react.createElement("div",{className:"content-column default",style:{padding:"60px 40px 0px"}},o&&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:()=>{a.attach()}},"Attach")),!o&&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"},a.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:()=>{a.onClick("update")}},"Update"),BDV2.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{a.onClick("save")}},"Save"),BDV2.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{a.onClick("detach")}},"Detach"),BDV2.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach")))))}onClick(a){let o=this;"update"===a?o.updateCss():"save"===a?o.saveCss():"detach"===a?o.detach():void 0}onChange(a,o){"live-update"===a?(settingsCookie["bda-css-0"]=o,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 a=this;a.setState({detached:!0});let o=a.detachedRoot;return o?void BDV2.reactDom.render(a.detachedEditor,o):void console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){let a=$("#bd-customcss-detach-container");return a.length?a[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app")),!0)}attach(){let a=this;a.setState({detached:!1})}}class V2C_List extends BDV2.reactComponent{constructor(a){super(a)}render(){return BDV2.react.createElement("ul",{className:this.props.className},this.props.children)}}class V2C_ContentColumn extends BDV2.reactComponent{constructor(a){super(a)}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(a){super(a);let o=this;o.onChange=o.onChange.bind(o),o.showSettings=o.showSettings.bind(o),o.setInitialState(),o.hasSettings="function"==typeof o.props.plugin.getSettingsPanel,o.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 a=(l,u)=>{let h=l.scrollTop,g=h+l.clientHeight,b=u.offsetTop,f=b+u.clientHeight;return b<h||f>g};let o=$(BDV2.reactDom.findDOMNode(this)),d=o.parents(".scroller");if(!a(d[0],o[0]))return;d.animate({scrollTop:o.offset().top-d.offset().top+d.scrollTop()-30},300)}}render(){let a=this,{plugin:o}=this.props,d=o.getName(),l=o.getAuthor(),u=o.getDescription(),h=o.getVersion(),g=bdplugins[d].website,b=bdplugins[d].source;if(this.state.settings){try{a.settingsPanel=o.getSettingsPanel()}catch(f){utils.err("Unable to get settings panel for "+o.getName()+".",f)}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="",a.setState({settings:!1})}},BDV2.react.createElement(V2Components.XSvg,null)),"object"==typeof a.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${d}`,className:"plugin-settings",ref:"settingspanel"}),"object"!=typeof a.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${d}`,className:"plugin-settings",ref:"settingspanel",dangerouslySetInnerHTML:{__html:a.settingsPanel}}))}return BDV2.react.createElement("li",{"data-name":d,"data-version":h,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"},d)," v",BDV2.react.createElement("span",{className:"bda-version"},h)," 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"},u)),(g||b||this.hasSettings)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},g&&BDV2.react.createElement("a",{className:"bda-link bda-link-website",href:g,target:"_blank"},"Website"),g&&b&&" | ",b&&BDV2.react.createElement("a",{className:"bda-link bda-link-source",href:b,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(a){super(a),this.setInitialState(),this.onChange=this.onChange.bind(this)}setInitialState(){this.state={checked:themeCookie[this.props.theme.name]}}render(){let{theme:a}=this.props,o=a.name,d=a.description,l=a.version,u=a.author,h=bdthemes[o].website,g=bdthemes[o].source;return BDV2.react.createElement("li",{"data-name":o,"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"},o)," v",BDV2.react.createElement("span",{className:"bda-version"},l)," by ",BDV2.react.createElement("span",{className:"bda-author"},u)),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)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},h&&BDV2.react.createElement("a",{className:"bda-link",href:h,target:"_blank"},"Website"),h&&g&&" | ",g&&BDV2.react.createElement("a",{className:"bda-link",href:g,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(a){this.onClick=a}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 a=$("#bd-settings-sidebar");return a.length?a[0]:this.injectRoot()?this.root:null}injectRoot(){let a=$("[class*='side-'] > [class*='item-']:not([class*=Danger])").last();return!!a.length&&($("<span/>",{id:"bd-settings-sidebar"}).insertBefore(a.prev()),!0)}render(){let a=this.root;return a?void BDV2.reactDom.render(this.component,a):void console.log("FAILED TO LOCATE ROOT: [class*='side-'] > [class*='item-']:not([class*=Danger])")}}class V2_SettingsPanel{constructor(){let a=this;a.sideBarOnClick=a.sideBarOnClick.bind(a),a.onChange=a.onChange.bind(a),a.updateSettings=this.updateSettings.bind(a),a.sidebar=new V2_SettingsPanel_Sidebar(a.sideBarOnClick)}get root(){let a=$("#bd-settingspane-container");return a.length?a[0]:this.injectRoot()?this.root:null}injectRoot(){return!!$(".layer-3QrUeG .ui-standard-sidebar-view, .layer-3QrUeG .ui-standard-sidebar-view").length&&($(".layer-3QrUeG .ui-standard-sidebar-view, .layer-3QrUeG .ui-standard-sidebar-view").append($("<div/>",{class:"content-region",id:"bd-settingspane-container"})),!0)}get coreSettings(){return this.getSettings("core")}get forkSettings(){return this.getSettings("fork")}get emoteSettings(){return this.getSettings("emote")}getSettings(a){return Object.keys(settings).reduce((o,d)=>{let l=settings[d];return l.cat===a&&l.implemented&&!l.hidden&&(l.text=d,o.push(l)),o},[])}sideBarOnClick(a){let o=this;$(".content-region").first().hide(),$(o.root).show();"core"===a?o.renderCoreSettings():"fork"===a?o.renderForkSettings():"emotes"===a?o.renderEmoteSettings():"customcss"===a?o.renderCustomCssEditor():"plugins"===a?o.renderPluginPane():"themes"===a?o.renderThemePane():void 0}onClick(){}onChange(a,o){settingsCookie[a]=o,this.updateSettings()}updateSettings(){let a=settingsCookie;a["bda-es-0"]?$("#twitchcord-button-container").show():$("#twitchcord-button-container").hide(),a["bda-gs-b"]?$("body").addClass("bd-blue"):$("body").removeClass("bd-blue"),a["bda-gs-2"]?$("body").addClass("bd-minimal"):$("body").removeClass("bd-minimal"),a["bda-gs-3"]?$("body").addClass("bd-minimal-chan"):$("body").removeClass("bd-minimal-chan"),a["bda-gs-1"]?$("#bd-pub-li").show():$("#bd-pub-li").hide(),a["bda-gs-4"]?voiceMode.enable():voiceMode.disable(),a["bda-gs-5"]?$("#app-mount").addClass("bda-dark"):$("#app-mount").removeClass("bda-dark"),a["bda-gs-6"]&&mainCore.inject24Hour(),a["bda-gs-7"]?mainCore.injectColoredText():mainCore.removeColoredText(),a["fork-ps-4"]?classNormalizer.start():classNormalizer.stop(),a["bda-gs-8"]?dMode.enable(a["fork-dm-1"]):dMode.disable(),mainCore.saveSettings()}renderSidebar(){let a=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{BDV2.reactDom.unmountComponentAtNode(a.root),$(a.root).hide(),$(".content-region").first().show()}),a.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 a=Object.keys(bdplugins).reduce((u,h)=>{return u.push(BDV2.react.createElement(V2Components.PluginCard,{key:h,plugin:bdplugins[h].plugin})),u},[]),o=BDV2.react.createElement(V2Components.List,{key:"plugin-list",className:"bda-slist",children:a}),d=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:[d,o]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[l,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get themesComponent(){let a=Object.keys(bdthemes).reduce((u,h)=>{return u.push(BDV2.react.createElement(V2Components.ThemeCard,{key:h,theme:bdthemes[h]})),u},[]),o=BDV2.react.createElement(V2Components.List,{key:"theme-list",className:"bda-slist",children:a}),d=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:[d,o]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[l,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}renderCoreSettings(){let a=this.root;return a?void BDV2.reactDom.render(this.coreComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderForkSettings(){let a=this.root;return a?void BDV2.reactDom.render(this.forkComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderEmoteSettings(){let a=this.root;return a?void BDV2.reactDom.render(this.emoteComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderCustomCssEditor(){let a=this.root;return a?void BDV2.reactDom.render(this.customCssComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderPluginPane(){let a=this.root;return a?void BDV2.reactDom.render(this.pluginsComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderThemePane(){let a=this.root;return a?void BDV2.reactDom.render(this.themesComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}}class V2C_Layer extends BDV2.reactComponent{constructor(a){super(a)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,a=>{27===a.which&&BDV2.reactDom.unmountComponentAtNode(this.refs.root.parentNode)}),$(`#${this.props.id}`).animate({opacity:1},{step:function(a){$(this).css("transform",`scale(${1.1-0.1*a}) 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(a){$(this).css("transform",`scale(${1.1-0.1*a}) translateZ(0px)`)},duration:200,done:()=>{$(`#${this.props.rootId}`).remove()}}),$("[class*=\"layer-\"]").removeClass("publicServersOpen").animate({opacity:1},{step:function(a){$(this).css("transform",`scale(${0.07*a+0.93}) translateZ(0px)`)},duration:200,done:()=>{$("[class*=\"layer-\"]").css("opacity","").css("transform","")}})}componentWillMount(){$("[class*=\"layer-\"]").addClass("publicServersOpen").animate({opacity:0},{step:function(a){$(this).css("transform",`scale(${0.07*a+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(a){super(a)}render(){let{sidebar:a,content:o,tools:d}=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:a.fade||!0,dark:a.dark||!0,children:a.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"},o.component),d.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 a=document.getElementById("pubslayerroot");return a?a:this.injectRoot()?this.root:null}injectRoot(){return!!$(".layers, .layers-3iHuyZ").length&&($(".layers, .layers-3iHuyZ").append($("<div/>",{id:"pubslayerroot"})),!0)}render(){let a=this.root;return a?void BDV2.reactDom.render(this.component,a):void console.log("FAILED TO LOCATE ROOT: .layers")}get button(){let a=$("<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 a}initialize(){let a=$(`.${BDV2.guildClasses.guilds}>:first-child`);a.after(this.button)}}class V2C_ServerCard extends BDV2.reactComponent{constructor(a){super(a),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:a}=this.props;return BDV2.react.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${a.pinned?" bd-server-card-pinned":""}`},BDV2.react.createElement("img",{ref:"img",className:"bd-server-image",src:a.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"},a.name),BDV2.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},a.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"},a.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"}},a.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")),a.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")),!a.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(a){super(a),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(a,o){let d=this;$.ajax({method:"GET",url:`${d.endPoint}${a}${a?"&schema=new":"?schema=new"}`,success:l=>{let u=l.results.reduce((f,y)=>{return y.joined=!1,f.push(y),f},[]);o||(u=d.state.servers.concat(u));let g=l.size+l.from;l.next=`?from=${g}`,d.state.term&&(l.next+=`&term=${d.state.term}`),d.state.selectedCategory&&(l.next+=`&category=${d.categoryButtons[d.state.selectedCategory]}`),g>=l.total&&(g=l.total,l.next=null);let b=`Showing 1-${g} of ${l.total} results in ${d.categoryButtons[d.state.selectedCategory]}`;d.state.term&&(b+=` for ${d.state.term}`),d.setState({loading:!1,title:b,servers:u,next:l.next}),o&&(d.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{d.setState({loading:!1,title:"Failed to load servers. Check console for details"})}})}join(a){return a.props.pinned?this.InviteActions.acceptInvite(a.props.invite_code):void $.ajax({method:"GET",url:`${this.joinEndPoint}/${a.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:()=>{a.setState({joined:!0})}})}connect(){let a=this,o=a.windowOptions;o.x=Math.round(window.screenX+window.innerWidth/2-o.width/2),o.y=Math.round(window.screenY+window.innerHeight/2-o.height/2),a.joinWindow=new(window.require("electron").remote.BrowserWindow)(o);let d=window.location.hostname.split(".")[0],l=a.connectEndPoint+("canary"===d||"ptb"===d?`/${d}`:"")+"?betterDiscord";a.joinWindow.webContents.on("did-navigate",(u,h)=>{"https://join.discordservers.com/session"!=h||(a.joinWindow.close(),a.checkConnection())}),a.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 o=this.SortedGuildStore.guildPositions,d=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:o,fallback:d[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 a=this;try{$.ajax({method:"GET",url:`${a.joinEndPoint}/session`,headers:{Accept:"application/json;","Content-Type":"application/json;"},crossDomain:!0,xhrFields:{withCredentials:!0},success:o=>{a.setState({selectedCategory:0,connection:{state:2,user:o}}),a.search("",!0)},error:o=>{if(403===o.status||404===o.status)return void a.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}})}catch(o){a.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((a,o)=>{return BDV2.react.createElement(V2Components.TabBar.Item,{id:o,onClick:this.changeCategory,key:o,text:a,selected:this.state.selectedCategory===o})}),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(a){let o=this;if(!(o.state.loading||13!==a.which)){o.setState({loading:!0,title:"Loading...",term:a.target.value});let d=`?term=${a.target.value}`;0!==o.state.selectedCategory&&(d+=`&category=${o.categoryButtons[o.state.selectedCategory]}`),o.search(d,!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(a){let o=this;if(!o.state.loading)return o.refs.searchinput.value="",o.setState({loading:!0,selectedCategory:a,title:"Loading...",term:null}),0===a?void o.search("",!0):void o.search(`?category=${o.categoryButtons[a]}`,!0)}get content(){let a=this,o=this.SortedGuildStore.guildPositions,d=this.AvatarDefaults.DEFAULT_AVATARS;return 1===a.state.connection.state?a.notConnected:[BDV2.react.createElement("div",{ref:"content",key:"pc",className:"content-column default"},BDV2.react.createElement(V2Components.SettingsTitle,{text:a.state.title}),a.bdServer,a.state.servers.map(l=>{return BDV2.react.createElement(V2Components.ServerCard,{key:l.identifier,server:l,join:a.join,guildList:o,fallback:d[Math.floor(5*Math.random())]})}),a.state.next&&BDV2.react.createElement("button",{type:"button",onClick:()=>{a.state.loading||(a.setState({loading:!0}),a.search(a.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"},a.state.loading?"Loading":"Load More")),0<a.state.servers.length&&BDV2.react.createElement(V2Components.SettingsTitle,{text:a.state.title}))]}get notConnected(){let a=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:a.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"))),a.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 a=this,{connection:o}=a.state;return 2===o.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: ",`${o.user.username}#${o.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:a.connect},"Reconnect")))):BDV2.react.createElement("span",null)}}