BetterDiscordApp-v1/js/main.min.js

1 line
119 KiB
JavaScript

var Core=function(e){var t={};function n(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(s,o,function(t){return e[t]}.bind(null,o));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("electron")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("module")},function(e,t){e.exports=require("request")},function(e,t,n){"use strict";n.r(t);var s={};n.r(s),n.d(s,"minSupportedVersion",(function(){return o})),n.d(s,"bbdVersion",(function(){return r})),n.d(s,"bbdChangelog",(function(){return a})),n.d(s,"settings",(function(){return i})),n.d(s,"defaultCookie",(function(){return c})),n.d(s,"settingsCookie",(function(){return l})),n.d(s,"bdpluginErrors",(function(){return d})),n.d(s,"bdthemeErrors",(function(){return u})),n.d(s,"bdConfig",(function(){return h})),n.d(s,"bemotes",(function(){return p})),n.d(s,"emotesFfz",(function(){return m})),n.d(s,"emotesBTTV",(function(){return g})),n.d(s,"emotesBTTV2",(function(){return f})),n.d(s,"emotesTwitch",(function(){return b})),n.d(s,"subEmotesTwitch",(function(){return v})),n.d(s,"bdEmotes",(function(){return y})),n.d(s,"bdEmoteSettingIDs",(function(){return C})),n.d(s,"bdthemes",(function(){return k})),n.d(s,"bdplugins",(function(){return w})),n.d(s,"pluginCookie",(function(){return E})),n.d(s,"themeCookie",(function(){return x}));const o="0.3.0",r="0.2.25-beta",a={description:"Mostly behind the scenes changes again.",changes:[{title:"What's New?",items:["**Changes for plugin developers!** There are some new items in the `BdApi` that you may want to check out."]},{title:"Fixes",type:"fixed",items:["**Modal Footers** are no longer blank hopefully!"]},{title:"Minor Stuff",type:"improved",items:["**Injector Version** is now included in the version list to try and quell the confusion."]}]},i={"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"},"BetterDiscord Blue":{id:"bda-gs-b",info:"Replace Discord blue with BD Blue",implemented:!1,hidden:!1,cat:"core"},"Public Servers":{id:"bda-gs-1",info:"Display public servers button",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Minimal Mode":{id:"bda-gs-2",info:"Hide elements and reduce the size of elements.",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Voice Mode":{id:"bda-gs-4",info:"Only show voice chat",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Hide Channels":{id:"bda-gs-3",info:"Hide channels in minimal mode",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Dark Mode":{id:"bda-gs-5",info:"Make certain elements dark by default(wip)",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Voice Disconnect":{id:"bda-dc-0",info:"Disconnect from voice server when closing Discord",implemented:!0,hidden:!1,cat:"core",category:"modules"},"24 Hour Timestamps":{id:"bda-gs-6",info:"Replace 12hr timestamps with proper ones",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Colored Text":{id:"bda-gs-7",info:"Make text color the same as role color",implemented:!0,hidden:!1,cat:"core",category:"modules"},"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:"core",category:"modules"},"Content Error Modal":{id:"fork-ps-1",info:"Shows a modal with plugin/theme errors",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Show Toasts":{id:"fork-ps-2",info:"Shows a small notification for important information",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"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:"core",category:"content manager"},"Automatic Loading":{id:"fork-ps-5",info:"Automatically loads, reloads, and unloads plugins and themes",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"BBD Beta":{id:"fork-beta",info:"Gives access to BBD beta. (Requires full restart after changing.)",implemented:!0,hidden:!1,cat:"core",category:"beta"},"Developer Mode":{id:"bda-gs-8",info:"Developer Mode",implemented:!0,hidden:!1,cat:"core",category:"developer settings"},"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:"core",category:"developer settings"},"Enable Transparency":{id:"fork-wp-1",info:"Enables the main window to be see-through (requires restart)",implemented:!0,hidden:!1,cat:"core",category:"window preferences"},"Window Frame":{id:"fork-wp-2",info:"Adds the native os window frame to the main window",implemented:!1,hidden:!0,cat:"core",category:"window preferences"},"Download Emotes":{id:"fork-es-3",info:"Download emotes when the cache is expired",implemented:!0,hidden:!1,cat:"emote"},"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 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"},"Animate On Hover":{id:"fork-es-2",info:"Only animate the emote modifiers on hover",implemented:!0,hidden:!1,cat:"emote"}},c={"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-4":!1,"bda-es-6":!0,"bda-es-7":!0,"bda-gs-b":!1,"bda-es-8":!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-ps-5":!0,"fork-es-2":!1,"fork-es-3":!0,"fork-wp-1":!1,"fork-wp-2":!1,"fork-beta":!0},l={},d=[],u=[],h={},p=[],m={},g={},f={},b={},v={},y={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},C={TwitchGlobal:"bda-es-7",TwitchSubscriber:"bda-es-7",BTTV:"bda-es-2",FrankerFaceZ:"bda-es-1",BTTV2:"bda-es-2"},k={},w={},E={},x={};class S{static get screenWidth(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)}static get screenHeight(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}static stripBOM(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}static getTextArea(){return $(".channelTextArea-rNsIhG textarea")}static insertText(e,t){e.focus(),e.selectionStart=0,e.selectionEnd=e.value.length,document.execCommand("insertText",!1,t)}static injectCss(e){$("<link/>",{type:"text/css",rel:"stylesheet",href:e}).appendTo($("head"))}static injectJs(e){return new Promise(t=>{$("<script/>",{type:"text/javascript",src:e,onload:t}).appendTo($("body"))})}static escapeID(e){return e.replace(/^[^a-z]+|[^\w-]+/gi,"-")}static log(e,t){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: #3a71c1; font-weight: 700;","color: #3a71c1;","")}static warn(e,t){console.warn(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: #E8A400; font-weight: 700;","color: #E8A400;","")}static err(e,t,n){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: red; font-weight: 700;","color: red;",""),n&&(console.groupCollapsed("%cError: "+n.message,"color: red;"),console.error(n.stack),console.groupEnd())}static escape(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}static testJSON(e){try{return JSON.parse(e)}catch(e){return!1}}static isEmpty(e){if(null==e||null==e||""==e)return!0;if("object"!=typeof e)return!1;if(Array.isArray(e))return 0==e.length;for(const t in e)if(e.hasOwnProperty(t))return!1;return!0}static suppressErrors(e,t){return(...n)=>{try{return e(...n)}catch(e){this.err("SuppressedError","Error occurred in "+t,e)}}}static monkeyPatch(e,t,n){const{before:s,after:o,instead:r,once:a=!1,silent:i=!1,force:c=!1}=n,l=n.displayName||e.displayName||e[t].displayName||e.name||e.constructor.displayName||e.constructor.name;if(i||console.log("patch",t,"of",l),!e[t]){if(!c)return console.error(t,"does not exist for",l);e[t]=function(){}}const d=e[t],u=()=>{i||console.log("unpatch",t,"of",l),e[t]=d};return e[t]=function(){const n={thisObject:this,methodArguments:arguments,cancelPatch:u,originalMethod:d,callOriginalMethod:()=>n.returnValue=n.originalMethod.apply(n.thisObject,n.methodArguments)};if(r){const s=S.suppressErrors(r,"`instead` callback of "+e[t].displayName)(n);void 0!==s&&(n.returnValue=s)}else s&&S.suppressErrors(s,"`before` callback of "+e[t].displayName)(n),n.callOriginalMethod(),o&&S.suppressErrors(o,"`after` callback of "+e[t].displayName)(n);return a&&u(),n.returnValue},Object.assign(e[t],d),e[t].__monkeyPatched=!0,e[t].displayName=l,e[t].__originalMethod||(e[t].__originalMethod=d,e[t].toString=function(){return d.toString()}),u}static onRemoved(e,t){const n=new MutationObserver(s=>{for(let o=0;o<s.length;o++){const r=s[o],a=Array.from(r.removedNodes),i=a.indexOf(e)>-1,c=a.some(t=>t.contains(e));(i||c)&&(n.disconnect(),t())}});n.observe(document.body,{subtree:!0,childList:!0})}static getNestedProp(e,t){return t.split(/\s?\.\s?/).reduce((function(e,t){return e&&e[t]}),e)}static showToast(e,t={}){if(!document.querySelector(".bd-toasts")){const e=document.createElement("div");e.classList.add("bd-toasts");const t=document.querySelector(".chat-3bRxxu form, #friends, .noChannel-Z1DQK7, .activityFeed-28jde9");e.style.setProperty("left",t?t.getBoundingClientRect().left+"px":"0px"),e.style.setProperty("width",t?t.offsetWidth+"px":"100%"),e.style.setProperty("bottom",(document.querySelector(".chat-3bRxxu form")?document.querySelector(".chat-3bRxxu form").offsetHeight:80)+"px"),document.querySelector(".app, .app-2rEoOp").appendChild(e)}const{type:n="",icon:s=!0,timeout:o=3e3}=t,r=document.createElement("div");r.classList.add("bd-toast"),n&&r.classList.add("toast-"+n),n&&s&&r.classList.add("icon"),r.innerText=e,document.querySelector(".bd-toasts").appendChild(r),setTimeout(()=>{r.classList.add("closing"),setTimeout(()=>{r.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},o)}static alert(e,t){const n=$(`<div class="bd-modal-wrapper theme-dark">\n <div class="bd-backdrop backdrop-1wrmKB"></div>\n <div class="bd-modal modal-1UGdnR">\n <div class="bd-modal-inner inner-1JeGVc">\n <div class="header header-1R_AjF">\n <div class="title">${e}</div>\n </div>\n <div class="bd-modal-body">\n <div class="scroller-wrap fade">\n <div class="scroller">\n ${t}\n </div>\n </div>\n </div>\n <div class="footer footer-2yfCgX footer-3rDWdC footer-2gL1pp">\n <button type="button">Okay</button>\n </div>\n </div>\n </div>\n </div>`);n.find(".footer button").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.find(".bd-backdrop").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.appendTo("#app-mount")}static showContentErrors({plugins:e=[],themes:t=[]}){if(!e||!t)return;if(!e.length&&!t.length)return;const n=$('<div class="bd-modal-wrapper theme-dark">\n <div class="bd-backdrop backdrop-1wrmKB"></div>\n <div class="bd-modal bd-content-modal modal-1UGdnR">\n <div class="bd-modal-inner inner-1JeGVc">\n <div class="header header-1R_AjF"><div class="title">Content Errors</div></div>\n <div class="bd-modal-body">\n <div class="tab-bar-container">\n <div class="tab-bar TOP">\n <div class="tab-bar-item">Plugins</div>\n <div class="tab-bar-item">Themes</div>\n </div>\n </div>\n <div class="table-header">\n <div class="table-column column-name">Name</div>\n <div class="table-column column-message">Message</div>\n <div class="table-column column-error">Error</div>\n </div>\n <div class="scroller-wrap fade">\n <div class="scroller">\n \n </div>\n </div>\n </div>\n <div class="footer footer-2yfCgX">\n <button type="button">Okay</button>\n </div>\n </div>\n </div>\n </div>');function s(e){const t=$('<div class="errors">');for(const n of e){const e=$(`<div class="error">\n <div class="table-column column-name">${n.name?n.name:n.file}</div>\n <div class="table-column column-message">${n.message}</div>\n <div class="table-column column-error"><a class="error-link" href="">${n.error?n.error.message:""}</a></div>\n </div>`);t.append(e),n.error&&e.find("a").on("click",e=>{e.preventDefault(),S.err("ContentManager",`Error details for ${n.name?n.name:n.file}.`,n.error)})}return t}const o=[s(e),s(t)];n.find(".tab-bar-item").on("click",e=>{e.preventDefault(),n.find(".tab-bar-item").removeClass("selected"),$(e.target).addClass("selected"),n.find(".scroller").empty().append(o[$(e.target).index()])}),n.find(".footer button").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.find(".bd-backdrop").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.appendTo("#app-mount"),e.length?n.find(".tab-bar-item")[0].click():n.find(".tab-bar-item")[1].click()}}const D=n(3);var T=new class extends D{dispatch(e,...t){this.emit(e,...t)}off(e,t){this.removeListener(e,t)}};function N(){}N.prototype.loadPlugins=function(){this.loadPluginData(),d.concat(q.loadPlugins());const e=Object.keys(w);for(let t=0;t<e.length;t++){let n,s;try{n=w[e[t]].plugin,s=n.getName(),n.load&&"function"==typeof n.load&&n.load()}catch(n){E[s]=!1,S.err("Plugins",s+" could not be loaded.",n),d.push({name:s,file:w[e[t]].filename,message:"load() could not be fired.",error:{message:n.message,stack:n.stack}});continue}if(E[s]||(E[s]=!1),E[s])try{n.start(),l["fork-ps-2"]&&S.showToast(`${n.getName()} v${n.getVersion()} has started.`)}catch(n){E[s]=!1,S.err("Plugins",s+" could not be started.",n),d.push({name:s,file:w[e[t]].filename,message:"start() could not be fired.",error:{message:n.message,stack:n.stack}})}}this.savePluginData(),n(1).remote.getCurrentWebContents().on("did-navigate-in-page",this.channelSwitch.bind(this))},N.prototype.startPlugin=function(e,t=!1){try{w[e].plugin.start(),l["fork-ps-2"]&&!t&&S.showToast(`${w[e].plugin.getName()} v${w[e].plugin.getVersion()} has started.`)}catch(n){l["fork-ps-2"]&&!t&&S.showToast(`${w[e].plugin.getName()} v${w[e].plugin.getVersion()} could not be started.`,{type:"error"}),E[e]=!1,this.savePluginData(),S.err("Plugins",e+" could not be started.",n)}},N.prototype.stopPlugin=function(e,t=!1){try{w[e].plugin.stop(),l["fork-ps-2"]&&!t&&S.showToast(`${w[e].plugin.getName()} v${w[e].plugin.getVersion()} has stopped.`)}catch(n){l["fork-ps-2"]&&!t&&S.showToast(`${w[e].plugin.getName()} v${w[e].plugin.getVersion()} could not be stopped.`,{type:"error"}),S.err("Plugins",w[e].plugin.getName()+" could not be stopped.",n)}},N.prototype.enablePlugin=function(e,t=!1){E[e]||(E[e]=!0,this.savePluginData(),this.startPlugin(e,t))},N.prototype.enable=function(e,t=!1){return this.enablePlugin(e,t)},N.prototype.disablePlugin=function(e,t=!1){E[e]&&(E[e]=!1,this.savePluginData(),this.stopPlugin(e,t))},N.prototype.disable=function(e,t=!1){return this.disablePlugin(e,t)},N.prototype.togglePlugin=function(e){E[e]?this.disablePlugin(e):this.enablePlugin(e)},N.prototype.loadPlugin=function(e){const t=q.loadContent(e,"plugin");if(t)return l["fork-ps-1"]&&S.showContentErrors({plugins:[t]}),l["fork-ps-2"]&&S.showToast(`${e} could not be loaded.`,{type:"error"}),S.err("ContentManager",`${e} could not be loaded.`,t);const n=Object.values(w).find(t=>t.filename==e).plugin;try{n.load&&"function"==typeof n.load&&n.load()}catch(e){l["fork-ps-1"]&&S.showContentErrors({plugins:[e]})}S.log("ContentManager",`${n.getName()} v${n.getVersion()} was loaded.`),l["fork-ps-2"]&&S.showToast(`${n.getName()} v${n.getVersion()} was loaded.`,{type:"success"}),T.dispatch("plugin-loaded",n.getName())},N.prototype.unloadPlugin=function(e){const t=Object.values(w).find(t=>t.filename==e)||w[e];if(!t)return;const n=t.plugin.getName();E[n]&&this.disablePlugin(n,!0);const s=q.unloadContent(w[n].filename,"plugin");if(delete w[n],s)return l["fork-ps-1"]&&S.showContentErrors({plugins:[s]}),l["fork-ps-2"]&&S.showToast(`${n} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),S.err("ContentManager",`${n} could not be unloaded. It may have not been loaded yet.`,s);S.log("ContentManager",`${n} was unloaded.`),l["fork-ps-2"]&&S.showToast(`${n} was unloaded.`,{type:"success"}),T.dispatch("plugin-unloaded",n)},N.prototype.reloadPlugin=function(e){const t=Object.values(w).find(t=>t.filename==e)||w[e];if(!t)return this.loadPlugin(e);const n=t.plugin.getName(),s=E[n];s&&this.stopPlugin(n,!0);const o=q.reloadContent(w[n].filename,"plugin");if(o)return l["fork-ps-1"]&&S.showContentErrors({plugins:[o]}),l["fork-ps-2"]&&S.showToast(`${n} could not be reloaded.`,{type:"error"}),S.err("ContentManager",`${n} could not be reloaded.`,o);w[n].plugin.load&&"function"==typeof w[n].plugin.load&&w[n].plugin.load(),s&&this.startPlugin(n,!0),S.log("ContentManager",`${n} v${w[n].plugin.getVersion()} was reloaded.`),l["fork-ps-2"]&&S.showToast(`${n} v${w[n].plugin.getVersion()} was reloaded.`,{type:"success"}),T.dispatch("plugin-reloaded",n)},N.prototype.updatePluginList=function(){const e=q.loadNewContent("plugin");for(const t of e.added)this.loadPlugin(t);for(const t of e.removed)this.unloadPlugin(t)},N.prototype.loadPluginData=function(){const e=V.getSettingGroup("plugins");e&&Object.assign(E,e)},N.prototype.savePluginData=function(){V.setSettingGroup("plugins",E)},N.prototype.newMessage=function(){const e=Object.keys(w);for(let t=0;t<e.length;t++){const n=w[e[t]].plugin;if(E[n.getName()]&&"function"==typeof n.onMessage)try{n.onMessage()}catch(e){S.err("Plugins","Unable to fire onMessage for "+n.getName()+".",e)}}},N.prototype.channelSwitch=function(){const e=Object.keys(w);for(let t=0;t<e.length;t++){const n=w[e[t]].plugin;if(E[n.getName()]&&"function"==typeof n.onSwitch)try{n.onSwitch()}catch(e){S.err("Plugins","Unable to fire onSwitch for "+n.getName()+".",e)}}},N.prototype.rawObserver=function(e){const t=Object.keys(w);for(let n=0;n<t.length;n++){const s=w[t[n]].plugin;if(E[s.getName()]&&"function"==typeof s.observer)try{s.observer(e)}catch(e){S.err("Plugins","Unable to fire observer for "+s.getName()+".",e)}}};var P=new N;function M(){}M.prototype.loadThemes=function(){this.loadThemeData(),u.concat(q.loadThemes());const e=Object.keys(k);for(let t=0;t<e.length;t++){const n=k[e[t]];x[n.name]||(x[n.name]=!1),x[n.name]&&$("head").append($("<style>",{id:n.id,text:unescape(n.css)}))}for(const e in x)k[e]||delete x[e];this.saveThemeData()},M.prototype.enableTheme=function(e,t=!1){x[e]=!0,this.saveThemeData();const n=k[e];$("head").append($("<style>",{id:n.id,text:unescape(n.css)})),l["fork-ps-2"]&&!t&&S.showToast(`${n.name} v${n.version} has been applied.`)},M.prototype.enable=function(e,t=!1){return this.enableTheme(e,t)},M.prototype.disableTheme=function(e,t=!1){x[e]=!1,this.saveThemeData();const n=k[e];$(`#${n.id}`).remove(),l["fork-ps-2"]&&!t&&S.showToast(`${n.name} v${n.version} has been disabled.`)},M.prototype.disable=function(e,t=!1){return this.disableTheme(e,t)},M.prototype.toggleTheme=function(e){x[e]?this.disableTheme(e):this.enableTheme(e)},M.prototype.loadTheme=function(e){const t=q.loadContent(e,"theme");if(t)return l["fork-ps-1"]&&S.showContentErrors({themes:[t]}),l["fork-ps-2"]&&S.showToast(`${e} could not be loaded. It may not have been loaded.`,{type:"error"}),S.err("ContentManager",`${e} could not be loaded.`,t);const n=Object.values(k).find(t=>t.filename==e);S.log("ContentManager",`${n.name} v${n.version} was loaded.`),l["fork-ps-2"]&&S.showToast(`${n.name} v${n.version} was loaded.`,{type:"success"}),T.dispatch("theme-loaded",n.name)},M.prototype.unloadTheme=function(e){const t=Object.values(k).find(t=>t.filename==e)||k[e];if(!t)return;const n=t.name;x[n]&&this.disableTheme(n,!0);const s=q.unloadContent(k[n].filename,"theme");if(delete k[n],s)return l["fork-ps-1"]&&S.showContentErrors({themes:[s]}),l["fork-ps-2"]&&S.showToast(`${n} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),S.err("ContentManager",`${n} could not be unloaded. It may have not been loaded yet.`,s);S.log("ContentManager",`${n} was unloaded.`),l["fork-ps-2"]&&S.showToast(`${n} was unloaded.`,{type:"success"}),T.dispatch("theme-unloaded",n)},M.prototype.reloadTheme=function(e){const t=Object.values(k).find(t=>t.filename==e)||k[e];if(!t)return this.loadTheme(e);const n=t.name,s=q.reloadContent(k[n].filename,"theme");if(x[n]&&(this.disableTheme(n,!0),this.enableTheme(n,!0)),s)return l["fork-ps-1"]&&S.showContentErrors({themes:[s]}),l["fork-ps-2"]&&S.showToast(`${n} could not be reloaded.`,{type:"error"}),S.err("ContentManager",`${n} could not be reloaded.`,s);S.log("ContentManager",`${n} v${k[n].version} was reloaded.`),l["fork-ps-2"]&&S.showToast(`${n} v${k[n].version} was reloaded.`,{type:"success"}),T.dispatch("theme-reloaded",n)},M.prototype.updateThemeList=function(){const e=q.loadNewContent("theme");for(const t of e.added)this.loadTheme(t);for(const t of e.removed)this.unloadTheme(t)},M.prototype.loadThemeData=function(){const e=V.getSettingGroup("themes");e&&Object.assign(x,e)},M.prototype.saveThemeData=function(){V.setSettingGroup("themes",x)};var B=new M;const j=n(2),O=n(0),F=n(4).Module;F.globalPaths.push(j.resolve(n(1).remote.app.getAppPath(),"node_modules"));class L extends Error{constructor(e){super(e),this.name="MetaError"}}const A=F._extensions[".js"],I=F._extensions[".css"]?F._extensions[".css"]:()=>null,R=/[^\S\r\n]*?(?:\r\n|\n)[^\S\r\n]*?\*[^\S\r\n]?/,_=/^\\@/;var q=new class{constructor(){this.timeCache={},this.watchers={},F._extensions[".js"]=this.getContentRequire("plugin"),F._extensions[".css"]=this.getContentRequire("theme")}get pluginsFolder(){return this._pluginsFolder||(this._pluginsFolder=O.realpathSync(j.resolve(h.dataPath+"plugins/")))}get themesFolder(){return this._themesFolder||(this._themesFolder=O.realpathSync(j.resolve(h.dataPath+"themes/")))}watchContent(e){if(this.watchers[e])return;const t="plugin"===e,n=t?this.pluginsFolder:this.themesFolder,s=t?".plugin.js":".theme.css";this.watchers[e]=O.watch(n,{persistent:!1},async(e,o)=>{if(!e||!o||!o.endsWith(s))return;await new Promise(e=>setTimeout(e,50));try{O.statSync(j.resolve(n,o))}catch(e){if("ENOENT"!==e.code)return;return delete this.timeCache[o],t?P.unloadPlugin(o):B.unloadTheme(o)}if(!O.statSync(j.resolve(n,o)).isFile())return;const r=O.statSync(j.resolve(n,o));r&&r.mtime&&r.mtime.getTime()&&"number"==typeof r.mtime.getTime()&&this.timeCache[o]!=r.mtime.getTime()&&(this.timeCache[o]=r.mtime.getTime(),"rename"==e&&(t?P.loadPlugin(o):B.loadTheme(o)),"change"==e&&(t?P.reloadPlugin(o):B.reloadTheme(o)))})}unwatchContent(e){this.watchers[e]&&(this.watchers[e].close(),delete this.watchers[e])}extractMeta(e){const t=e.split("\n")[0];if(t.includes("//META"))return this.parseOldMeta(e);if(t.includes("/**"))return this.parseNewMeta(e);throw new L("META was not found.")}parseOldMeta(e){const t=e.split("\n")[0],n=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//"));if(t.indexOf("META")<0)throw new L("META was not found.");const s=S.testJSON(n);if(!s)throw new L("META could not be parsed.");if(!s.name)throw new L("META missing name data.");return s.format="json",s}parseNewMeta(e){const t=e.split("/**",2)[1].split("*/",1)[0],n={};let s="",o="";for(const e of t.split(R))if(0!==e.length)if("@"===e.charAt(0)&&" "!==e.charAt(1)){n[s]=o;const t=e.indexOf(" ");s=e.substr(1,t-1),o=e.substr(t+1)}else o+=" "+e.replace("\\n","\n").replace(_,"@");return n[s]=o.trim(),delete n[""],n.format="jsdoc",n}getContentRequire(e){const t="plugin"===e,n=this,s=t?A:I;return function(e,o){const r=t?n.pluginsFolder:n.themesFolder,a=j.resolve(r,j.basename(o));if(!O.existsSync(a)||o!==O.realpathSync(a))return Reflect.apply(s,this,arguments);let i=O.readFileSync(o,"utf8");i=S.stripBOM(i);const c=n.extractMeta(i);if(c.filename=j.basename(o),t||(c.css=i,"json"==c.format&&(c.css=c.css.split("\n").slice(1).join("\n")),i=`module.exports = ${JSON.stringify(c)};`),t){e._compile(i,e.filename),!S.isEmpty(e.exports)?(c.type=e.exports,e.exports=c,i=""):i+=`\nmodule.exports = ${JSON.stringify(c)};\nmodule.exports.type = ${c.exports||c.name};`}e._compile(i,o)}}makePlaceholderPlugin(e){return{plugin:{start:()=>{},getName:()=>e.name||e.filename,getAuthor:()=>"???",getDescription:()=>e.message?e.message:"This plugin was unable to be loaded. Check the author's page for updates.",getVersion:()=>"???"},name:e.name||e.filename,filename:e.filename,source:e.source?e.source:"",website:e.website?e.website:""}}loadContent(e,t){if(void 0===e||void 0===t)return;const n="plugin"===t,s=n?this.pluginsFolder:this.themesFolder;try{require(j.resolve(s,e))}catch(t){return{name:e,file:e,message:"Could not be compiled.",error:{message:t.message,stack:t.stack}}}const o=require(j.resolve(s,e));if(o.id=S.escapeID(o.name),n){if(!o.type)return;try{o.plugin=new o.type,delete w[o.plugin.getName()],w[o.plugin.getName()]=o}catch(t){return{name:e,file:e,message:"Could not be constructed.",error:{message:t.message,stack:t.stack}}}}else delete k[o.name],k[o.name]=o}unloadContent(e,t){if(void 0===e||void 0===t)return;const n="plugin"===t?this.pluginsFolder:this.themesFolder;try{delete require.cache[require.resolve(j.resolve(n,e))]}catch(t){return{name:e,file:e,message:"Could not be unloaded.",error:{message:t.message,stack:t.stack}}}}isLoaded(e,t){const n="plugin"===t?this.pluginsFolder:this.themesFolder;try{require.cache[require.resolve(j.resolve(n,e))]}catch(e){return!1}return!0}reloadContent(e,t){const n=this.unloadContent(e,t);return n||this.loadContent(e,t)}loadNewContent(e){const t="plugin"===e,n=t?".plugin.js":".theme.css",s=t?this.pluginsFolder:this.themesFolder,o=O.readdirSync(s),r=Object.values(t?w:k),a=r.filter(e=>!o.includes(e.filename)).map(e=>t?e.plugin.getName():e.name);return{added:o.filter(e=>!r.find(t=>t.filename==e)&&e.endsWith(n)&&O.statSync(j.resolve(s,e)).isFile()),removed:a}}loadAllContent(e){const t="plugin"===e,n=t?".plugin.js":".theme.css",s=t?this.pluginsFolder:this.themesFolder,o=[],r=O.readdirSync(s);for(const t of r){if(!O.statSync(j.resolve(s,t)).isFile()||!t.endsWith(n))continue;const r=this.loadContent(t,e);r&&o.push(r)}return o}loadPlugins(){return this.loadAllContent("plugin")}loadThemes(){return this.loadAllContent("theme")}};const G=n(0),W=n(2),U=DiscordNative.globals.releaseChannel;var V=new class{constructor(){this.data={settings:{stable:{},canary:{},ptb:{}}},this.pluginData={}}initialize(){try{G.existsSync(this.BDFile)||G.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4));const e=require(this.BDFile);if(e.hasOwnProperty("settings")&&(this.data=e),!G.existsSync(this.settingsFile))return;let t=require(this.settingsFile);G.unlinkSync(this.settingsFile),t=t.hasOwnProperty("settings")?Object.assign({stable:{},canary:{},ptb:{}},{[U]:t}):Object.assign({stable:{},canary:{},ptb:{}},t),this.setBDData("settings",t)}catch(e){console.error(e),S.alert("Corrupt Storage","The bd storage has somehow become corrupt. You may either try to salvage the file or delete it then reload.")}}get BDFile(){return this._BDFile||(this._BDFile=W.resolve(h.dataPath,"bdstorage.json"))}get settingsFile(){return this._settingsFile||(this._settingsFile=W.resolve(h.dataPath,"bdsettings.json"))}getPluginFile(e){return W.resolve(q.pluginsFolder,e+".config.json")}getSettingGroup(e){return this.data.settings[U][e]||null}setSettingGroup(e,t){this.data.settings[U][e]=t,G.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4))}getBDData(e){return this.data[e]||""}setBDData(e,t){this.data[e]=t,G.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4))}getPluginData(e,t){return void 0!==this.pluginData[e]?this.pluginData[e][t]||void 0:G.existsSync(this.getPluginFile(e))?(this.pluginData[e]=JSON.parse(G.readFileSync(this.getPluginFile(e))),this.pluginData[e][t]||void 0):void 0}setPluginData(e,t,n){void 0!==n&&(void 0===this.pluginData[e]&&(this.pluginData[e]={}),this.pluginData[e][t]=n,G.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4)))}deletePluginData(e,t){void 0===this.pluginData[e]&&(this.pluginData[e]={}),delete this.pluginData[e][t],G.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4))}},z=new class{constructor(){this.editorDetached=!1,this.WebpackModules=(()=>{const e=webpackJsonp.push([[],{__extra_id__:(e,t,n)=>e.exports=n},[["__extra_id__"]]]);delete e.m.__extra_id__,delete e.c.__extra_id__;const t=t=>{for(const n in e.c)if(e.c.hasOwnProperty(n)){const s=e.c[n].exports;if(s&&s.__esModule&&s.default&&t(s.default))return s.default;if(s&&t(s))return s}return null};return{find:t,findAll:t=>{const n=[];for(const s in e.c)if(e.c.hasOwnProperty(s)){const o=e.c[s].exports;o&&o.__esModule&&o.default&&t(o.default)?n.push(o.default):o&&t(o)&&n.push(o)}return n},findByUniqueProperties:e=>t(t=>e.every(e=>void 0!==t[e])),findByPrototypes:e=>t(t=>t.prototype&&e.every(e=>void 0!==t.prototype[e])),findByDisplayName:e=>t(t=>t.displayName===e)}})(),this.internal={react:this.WebpackModules.findByUniqueProperties(["Component","PureComponent","Children","createElement","cloneElement"]),reactDom:this.WebpackModules.findByUniqueProperties(["findDOMNode"])},this.getInternalInstance=e=>e[Object.keys(e).find(e=>e.startsWith("__reactInternalInstance"))]}initialize(){}joinBD1(){this.InviteActions.acceptInviteAndTransitionToInviteChannel("0Tmfo5ZbORCRqbAd")}leaveBD1(){this.GuildActions.leaveGuild("86004744966914048")}joinBD2(){this.InviteActions.acceptInviteAndTransitionToInviteChannel("2HScm8j")}leaveBD2(){this.GuildActions.leaveGuild("280806472928198656")}get react(){return this.internal.react}get React(){return this.internal.react}get reactDom(){return this.internal.reactDom}get ReactDom(){return this.internal.reactDom}get reactComponent(){return this.internal.react.Component}get ReactComponent(){return this.internal.react.Component}get anchorClasses(){return this.WebpackModules.findByUniqueProperties(["anchorUnderlineOnHover"])||{anchor:"anchor-3Z-8Bb",anchorUnderlineOnHover:"anchorUnderlineOnHover-2ESHQB"}}get slateEditorClasses(){return this.WebpackModules.findByUniqueProperties(["slateTextArea"])}get messageClasses(){return this.WebpackModules.findByUniqueProperties(["message","containerCozy"])}get guildClasses(){const e=this.WebpackModules.findByUniqueProperties(["wrapper","unreadMentionsBar"]),t=this.WebpackModules.findByUniqueProperties(["guildsError","selected"]),n=this.WebpackModules.findByUniqueProperties(["blobContainer"]);return Object.assign({},e,t,n)}get MessageContentComponent(){return this.WebpackModules.find(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get MessageComponent(){return this.WebpackModules.find(e=>e.default&&e.default.displayName&&"Message"==e.default.displayName)}get TimeFormatter(){return this.WebpackModules.findByUniqueProperties(["dateFormat"])}get TooltipWrapper(){return this.WebpackModules.findByDisplayName("Tooltip")}get NativeModule(){return this.WebpackModules.findByUniqueProperties(["setBadge"])}get InviteActions(){return this.WebpackModules.findByUniqueProperties(["acceptInvite"])}get GuildActions(){return this.WebpackModules.findByUniqueProperties(["leaveGuild"])}get Tooltips(){return this.WebpackModules.find(e=>e.hide&&e.show&&!e.search&&!e.submit&&!e.search&&!e.activateRagingDemon&&!e.dismiss)}get KeyGenerator(){return this.WebpackModules.find(e=>e.toString&&/"binary"/.test(e.toString()))}get LayerStack(){return this.WebpackModules.findByUniqueProperties(["popLayer"])}get UserStore(){return this.WebpackModules.findByUniqueProperties(["getCurrentUser"])}get ChannelStore(){return this.WebpackModules.findByUniqueProperties(["getChannel"])}get ChannelActions(){return this.WebpackModules.findByUniqueProperties(["openPrivateChannel"])}get PrivateChannelActions(){return this.WebpackModules.findByUniqueProperties(["selectPrivateChannel"])}openDM(e){const t=this.UserStore.getCurrentUser().id;if(t==e)return;const n=this.ChannelStore.getDMFromUserId(e);if(n)return this.PrivateChannelActions.selectPrivateChannel(n);this.ChannelActions.openPrivateChannel(t,e)}parseSettings(e){return Object.keys(i).reduce((t,n)=>{const s=i[n];return s.cat===e&&s.implemented&&!s.hidden&&(s.text=n,t.push(s)),t},[])}};function H(){}H.prototype.init=function(){this.initialized=!0,$(document).on("mousedown",(function(e){"rmenu"!=e.target.id&&$("#rmenu").remove()})),this.favoriteEmotes={};const e=V.getBDData("bdfavemotes");""!==e&&null!==e&&(this.favoriteEmotes=JSON.parse(atob(e)));let t="";t+='<div id="bda-qem">',t+=' <button class="active" id="bda-qem-twitch" onclick=\'quickEmoteMenu.switchHandler(this); return false;\'>Twitch</button>',t+=" <button id=\"bda-qem-favourite\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Favourite</button>",t+=" <button id=\"bda-qem-emojis\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Emojis</buttond>",t+="</div>",this.qmeHeader='<div id="bda-qem"> <button class="active" id="bda-qem-twitch" onclick=\'quickEmoteMenu.switchHandler(this); return false;\'>Twitch</button> <button id="bda-qem-favourite" onclick=\'quickEmoteMenu.switchHandler(this); return false;\'>Favourite</button> <button id="bda-qem-emojis" onclick=\'quickEmoteMenu.switchHandler(this); return false;\'>Emojis</buttond></div>';let n="";n+='<div id="bda-qem-twitch-container">',n+=' <div class="scroller-wrap scrollerWrap-2lJEkd fade">',n+=' <div class="scroller scroller-2FKFPG">',n+=' <div class="emote-menu-inner">';let s="";for(const e in y.TwitchGlobal)y.TwitchGlobal.hasOwnProperty(e)&&(s=y.TwitchGlobal[e],n+='<div class="emote-container">',n+=' <img class="emote-icon" alt="" src="'+s+'" title="'+e+'">',n+=" </img>",n+="</div>");n+=" </div>",n+=" </div>",n+=" </div>",n+="</div>",this.teContainer=n;let o="";o+='<div id="bda-qem-favourite-container">',o+=' <div class="scroller-wrap scrollerWrap-2lJEkd fade">',o+=' <div class="scroller scroller-2FKFPG">',o+=' <div class="emote-menu-inner">';for(const e in this.favoriteEmotes)s=this.favoriteEmotes[e],o+='<div class="emote-container">',o+=' <img class="emote-icon" alt="" src="'+s+'" title="'+e+"\" oncontextmenu='quickEmoteMenu.favContext(event, this);'>",o+=" </img>",o+="</div>";o+=" </div>",o+=" </div>",o+=" </div>",o+="</div>",this.faContainer=o},H.prototype.favContext=function(e,t){e.stopPropagation();const n=$("<div>",{id:"removemenu","data-emoteid":$(t).prop("title"),text:"Remove",class:"bd-context-menu context-menu theme-dark"});n.css({top:e.pageY-$("#bda-qem-favourite-container").offset().top,left:e.pageX-$("#bda-qem-favourite-container").offset().left}),$(t).parent().append(n);const s=this;return n.on("click",(function(e){return e.preventDefault(),e.stopPropagation(),$(this).remove(),delete s.favoriteEmotes[$(this).data("emoteid")],s.updateFavorites(),!1})),!1},H.prototype.switchHandler=function(e){this.switchQem($(e).attr("id"))},H.prototype.switchQem=function(e){const t=$("#bda-qem-twitch"),n=$("#bda-qem-favourite"),s=$("#bda-qem-emojis");switch(t.removeClass("active"),n.removeClass("active"),s.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide(),e){case"bda-qem-twitch":t.addClass("active"),$("#bda-qem-twitch-container").show();break;case"bda-qem-favourite":n.addClass("active"),$("#bda-qem-favourite-container").show();break;case"bda-qem-emojis":s.addClass("active"),$(".emojiPicker-3m1S-j").show(),$(".emojiPicker-3m1S-j input").focus()}this.lastTab=e;const o=$(".emote-icon");o.off(),o.on("click",(function(){const e=$(this).attr("title"),t=document.querySelector(`.${z.slateEditorClasses.slateTextArea.split(" ")[0]}`);if(t){const n=z.getInternalInstance(t),s=S.getNestedProp(n,"memoizedProps.children.props.editor.insertText");s&&s(` ${e} `)}else{const t=S.getTextArea();S.insertText(t[0]," "==t.val().slice(-1)?t.val()+e:t.val()+" "+e)}}))},H.prototype.obsCallback=function(e){if(!this.initialized)return;const t=$(e);l["bda-es-9"]?t.removeClass("bda-qme-hidden"):t.addClass("bda-qme-hidden"),l["bda-es-0"]&&(t.prepend(this.qmeHeader),t.append(this.teContainer),t.append(this.faContainer),null==this.lastTab&&(this.lastTab="bda-qem-emojis"),this.switchQem(this.lastTab))},H.prototype.favorite=function(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.updateFavorites()},H.prototype.updateFavorites=function(){let e="";e+='<div id="bda-qem-favourite-container">',e+=' <div class="scroller-wrap scrollerWrap-2lJEkd fade">',e+=' <div class="scroller scroller-2FKFPG">',e+=' <div class="emote-menu-inner">';for(const t in this.favoriteEmotes){e+='<div class="emote-container">',e+=' <img class="emote-icon" alt="" src="'+this.favoriteEmotes[t]+'" title="'+t+'" oncontextmenu="quickEmoteMenu.favContext(event, this);">',e+=" </img>",e+="</div>"}e+=" </div>",e+=" </div>",e+=" </div>",e+="</div>",this.faContainer=e,$("#bda-qem-favourite-container").replaceWith(e),V.setBDData("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))};var J=new H;class Z extends z.reactComponent{constructor(e){super(e);const t=!!(J&&J.favoriteEmotes&&J.favoriteEmotes[this.label]);this.state={shouldAnimate:!this.animateOnHover,isFavorite:t},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onClick=this.onClick.bind(this)}get animateOnHover(){return l["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&&J.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!J.favoriteEmotes[this.label]&&this.setState({isFavorite:!1})}onMouseLeave(){this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!1})}onClick(e){this.props.onClick&&this.props.onClick(e)}render(){return z.react.createElement(z.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},e=>z.react.createElement("div",Object.assign({className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},e),z.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}),z.react.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.state.isFavorite?(delete J.favoriteEmotes[this.label],J.updateFavorites()):J.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}function Y(){Object.defineProperty(this,"categories",{get:function(){const e=[];for(const t in C)l[C[t]]&&e.push(t);return e}})}Y.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"];const e={TwitchGlobal:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_global.json",variable:"TwitchGlobal",oldVariable:"emotesTwitch",getEmoteURL:e=>`https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`},TwitchSubscriber:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_subscriber.json",variable:"TwitchSubscriber",oldVariable:"subEmotesTwitch",getEmoteURL:e=>`https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`},FrankerFaceZ:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_ffz.json",variable:"FrankerFaceZ",oldVariable:"emotesFfz",getEmoteURL:e=>`https://cdn.frankerfacez.com/emoticon/${e}/1`},BTTV:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv.json",variable:"BTTV",oldVariable:"emotesBTTV",getEmoteURL:e=>`https://cdn.betterttv.net/emote/${e}/1x`},BTTV2:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv2.json",variable:"BTTV2",oldVariable:"emotesBTTV2",getEmoteURL:e=>`https://cdn.betterttv.net/emote/${e}/1x`}};for(await this.getBlacklist(),await this.loadEmoteData(e);!z.MessageComponent;)await new Promise(e=>setTimeout(e,100));this.cancelEmoteRender||(this.cancelEmoteRender=S.monkeyPatch(z.MessageComponent,"default",{before:({methodArguments:e})=>{const t=e[0].childrenMessageContent.props.content;if(t&&t.length){for(let e=0;e<t.length;e++){const n=t[e];if("string"!=typeof n)continue;const s=n.split(/([^\s]+)([\s]|$)/g);for(let n=0,o=this.categories.length;n<o;n++)for(let o=0,r=s.length;o<r;o++){const r=s[o].split(":"),a=r[0];let i=r[1]?r[1]:"",c=i.slice(0);if(a.length<4||p.includes(a))continue;this.modifiers.includes(i)&&l["bda-es-8"]||(i=""),this.overrides.includes(c)?i=c:c="";let d=this.categories[n];if("twitch"===c?y.TwitchGlobal[a]?d="TwitchGlobal":y.TwitchSubscriber[a]&&(d="TwitchSubscriber"):"bttv"===c?y.BTTV[a]?d="BTTV":y.BTTV2[a]&&(d="BTTV2"):"ffz"===c&&y.FrankerFaceZ[a]&&(d="FrankerFaceZ"),!y[d][a]||!l[C[d]])continue;const u=t[e].match(new RegExp(`([\\s]|^)${S.escape(i?a+":"+i:a)}([\\s]|$)`));if(!u)continue;const h=t[e].substring(0,u.index+u[1].length),m=t[e].substring(u.index+u[0].length-u[2].length);t[e]=h;const g=z.react.createElement(Z,{name:a,url:y[d][a],modifier:i});t.splice(e+1,0,m),t.splice(e+1,0,g)}}if(t.every(e=>"string"==typeof e&&""==e.replace(/\s*/,"")||(!(!e.type||"BDEmote"!=e.type.name)||!!(e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName))))for(const e of t)"object"==typeof e&&("BDEmote"==e.type.name?e.props.jumboable=!0:e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName&&(e.props.children.props.jumboable=!0))}}}))},Y.prototype.disable=function(){this.disableAutoCapitalize(),this.cancelEmoteRender||(this.cancelEmoteRender(),this.cancelEmoteRender=null)},Y.prototype.clearEmoteData=async function(){const e=n(0),t=h.dataPath+"emote_data.json";e.existsSync(t)&&e.unlinkSync(t),V.setBDData("emoteCacheDate",(new Date).toJSON()),Object.assign(y,{TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}})},Y.prototype.isCacheValid=function(){const e=V.getBDData("emoteCacheDays")||V.setBDData("emoteCacheDays",7)||7,t=new Date(V.getBDData("emoteCacheDate")||null),n=new Date;return!(Math.round(Math.abs((n.getTime()-t.getTime())/864e5))>e)||(V.setBDData("emoteCacheDate",n.toJSON()),!1)},Y.prototype.loadEmoteData=async function(e){const t=n(0),s=h.dataPath+"emote_data.json";if(await new Promise(e=>t.exists(s,e))&&this.isCacheValid()){l["fork-ps-2"]&&S.showToast("Loading emotes from cache.",{type:"info"}),S.log("Emotes","Loading emotes from local cache.");const n=await new Promise(e=>{t.readFile(s,"utf8",(t,n)=>{S.log("Emotes","Emote file read."),t&&(n={}),e(n)})}),o=S.testJSON(n);let r=!!o;r&&Object.assign(y,o);for(const t in e)r=Object.keys(y[e[t].variable]).length>0;if(r)return void(l["fork-ps-2"]&&S.showToast("Emotes successfully loaded.",{type:"success"}));S.log("Emotes","Cache was corrupt, downloading..."),await new Promise(e=>t.unlink(s,e))}if(l["fork-es-3"]){l["fork-ps-2"]&&S.showToast("Downloading emotes in the background do not reload.",{type:"info"});for(const t in e){await new Promise(e=>setTimeout(e,1e3));const n=await this.downloadEmotes(e[t]);y[e[t].variable]=n}l["fork-ps-2"]&&S.showToast("All emotes successfully downloaded.",{type:"success"});try{await new Promise(e=>t.writeFile(s,JSON.stringify(y),"utf8",e))}catch(e){S.err("Emotes","Could not save emote data.",e)}}},Y.prototype.downloadEmotes=function(e){const t=n(5),s={url:e.url,timeout:e.timeout?e.timeout:5e3,json:!0};return S.log("Emotes",`Downloading: ${e.variable} (${e.url})`),new Promise((n,o)=>{t(s,(t,s,r)=>{if(t)return S.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),n(this.downloadEmotes(e))):o({});"function"==typeof e.parser&&(r=e.parser(r));for(const t in r)t.length<4||p.includes(t)?delete r[t]:r[t]=e.getEmoteURL(r[t]);n(r),S.log("Emotes","Downloaded: "+e.variable)})})},Y.prototype.getBlacklist=function(){return new Promise(e=>{$.getJSON("https://rauenzi.github.io/BetterDiscordApp/data/emotefilter.json",(function(t){e(p.concat(t.blacklist))}))})},Y.prototype.autoCapitalize=function(){l["bda-es-4"]&&!this.autoCapitalizeActive&&($("body").on("keyup.bdac change.bdac paste.bdac",$(".channelTextArea-rNsIhG textarea:first"),()=>{const e=$(".channelTextArea-rNsIhG textarea:first").val();if(null==e)return;const t=e.split(" ").pop();if(t.length>3){if("danSgame"==t)return;const n=this.capitalize(t.toLowerCase());null!=n&&S.insertText(S.getTextArea()[0],e.replace(t,n))}}),this.autoCapitalizeActive=!0)},Y.prototype.capitalize=function(e){const t=y.TwitchGlobal;for(const n in t)if(t.hasOwnProperty(n)&&e==(n+"").toLowerCase())return n},Y.prototype.disableAutoCapitalize=function(){this.autoCapitalizeActive=!1,$("body").off(".bdac")};var Q=new Y;class K extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class X extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("div",{className:"ui-tab-bar-header"},this.props.text)}}class ee extends z.reactComponent{constructor(e){super(e),this.setInitialState(),this.onClick=this.onClick.bind(this)}setInitialState(){this.state={selected:this.props.selected||!1}}render(){return z.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 te extends z.reactComponent{constructor(e){super(e);const t=this,n=$("[class*=side-] > [class*=selected]");n.length&&(t.scn=n.attr("class"));const s=$("[class*=side-] > [class*='item-']:not([class*=selected])");s.length&&(t.nscn=s.attr("class")),$("[class*='side-'] > [class*='item-']").on("click",()=>{t.setState({selected:null})}),t.setInitialState(),t.onClick=t.onClick.bind(t)}setInitialState(){const e=this;e.state={selected:null,items:e.props.items};const t=e.props.items.find(e=>e.selected);t&&(e.state.selected=t.id)}render(){const e=this,{headerText:t}=e.props,{items:n,selected:s}=e.state;return z.react.createElement("div",null,z.react.createElement(K,null),z.react.createElement(X,{text:t}),n.map(t=>{const{id:n,text:o}=t;return z.react.createElement(ee,{key:n,selected:s===n,text:o,id:n,onClick:e.onClick})}))}onClick(e){const t=this,n=$("[class*=side] > [class*=selected]");n.length&&(n.off("click.bdsb").on("click.bsb",e=>{$(e.target).attr("class",t.scn)}),n.attr("class",t.nscn)),t.setState({selected:null}),t.setState({selected:e}),t.props.onClick&&t.props.onClick(e)}}class ne{constructor(e){this.onClick=e}get items(){return[{text:"Settings",id:"core"},{text:"Emotes",id:"emotes"},{text:"Plugins",id:"plugins"},{text:"Themes",id:"themes"},{text:"Custom CSS",id:"customcss"}]}get component(){return z.react.createElement("span",null,z.react.createElement(te,{onClick:this.onClick,headerText:"Bandaged BD",items:this.items}))}get root(){const e=$("#bd-settings-sidebar");return e.length?e[0]:this.injectRoot()?this.root:null}injectRoot(){const e=$("[class*='side-'] > [class*='item-']:not([class*=Danger])").last();return!!e.length&&($("<span/>",{id:"bd-settings-sidebar"}).insertBefore(e.prev()),!0)}render(){const e=this.root;e?(z.reactDom.render(this.component,e),S.onRemoved(e,()=>{z.reactDom.unmountComponentAtNode(e)})):console.log("FAILED TO LOCATE ROOT: [class*='side-'] > [class*='item-']:not([class*=Danger])")}}var se=new class{injectColoredText(){this.cancelColoredText||z.MessageComponent&&(this.cancelColoredText=S.monkeyPatch(z.MessageComponent,"default",{before:e=>{const t=e.methodArguments[0];if(!t||!t.childrenMessageContent)return;const n=t.childrenMessageContent;if(!n.type||!n.type.type||"MessageContent"!=n.type.type.displayName)return;const s=n.type.type;s.__originalMethod||(n.type.type=function(e){const t=s(e),n=l["bda-gs-7"]&&e.message.colorString||"";return t.props.style={color:n},t},n.type.type.__originalMethod=s,Object.assign(n.type.type,s))}}))}removeColoredText(){document.querySelectorAll(".markup-2BOw-j").forEach(e=>{e.style.setProperty("color","")})}},oe=new class{inject24Hour(){if(this.cancel24Hour)return;const e=new RegExp("([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)"),t=t=>{if(!l["bda-gs-6"])return;const n=t.returnValue.match(e);return n&&4===n.length?"AM"===n[3]?t.returnValue=t.returnValue.replace(n[0],`${"12"===n[1]?"00":n[1].padStart(2,"0")}:${n[2]}`):t.returnValue=t.returnValue.replace(n[0],`${"12"===n[1]?"12":parseInt(n[1])+12}:${n[2]}`):void 0},n=S.monkeyPatch(z.TimeFormatter,"calendarFormat",{after:t}),s=S.monkeyPatch(z.TimeFormatter,"dateFormat",{after:t});this.cancel24Hour=()=>{n(),s()}}remove24Hour(){this.cancel24Hour&&this.cancel24Hour()}};const re=webpackJsonp.push([[],{__extra_id__:(e,t,n)=>e.exports=n},[["__extra_id__"]]]);delete re.m.__extra_id__,delete re.c.__extra_id__;const ae=e=>{for(const t in re.c)if(re.c.hasOwnProperty(t)){const n=re.c[t].exports;if(n&&n.__esModule&&n.default&&e(n.default))return n.default;if(n&&e(n))return n}return null};var ie=ae,ce=e=>{const t=[];for(const n in re.c)if(re.c.hasOwnProperty(n)){const s=re.c[n].exports;s&&s.__esModule&&s.default&&e(s.default)?t.push(s.default):s&&e(s)&&t.push(s)}return t},le=(...e)=>ae(t=>e.every(e=>void 0!==t[e])),de=e=>ae(t=>t.displayName===e);class ue extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},z.react.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},z.react.createElement("path",{d:"M0 0h12v12H0"}),z.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 he extends z.reactComponent{constructor(e){super(e),this.onClick=this.onClick.bind(this)}render(){return z.react.createElement("div",{className:"tools-container toolsContainer-1edPuj"},z.react.createElement("div",{className:"tools tools-3-3s-N"},z.react.createElement("div",{className:"container-1sFeqf"},z.react.createElement("div",{className:"btn-close closeButton-1tv5uR",onClick:this.onClick},z.react.createElement(ue,null)),z.react.createElement("div",{className:"esc-text keybind-KpFkfr"},"ESC"))))}onClick(){this.props.onClick&&this.props.onClick(),$(".closeButton-1tv5uR").first().click()}}class pe extends z.reactComponent{constructor(e){super(e),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(){const{server:e}=this.props;return z.react.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${e.pinned?" bd-server-card-pinned":""}`},z.react.createElement("img",{ref:"img",className:"bd-server-image",src:e.iconUrl,onError:this.handleError.bind(this)}),z.react.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},z.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},z.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},e.name),z.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},e.members," Members")),z.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},z.react.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},z.react.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},e.description))),z.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},z.react.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},e.categories.join(", ")),this.state.joined&&z.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"}},z.react.createElement("div",{className:"ui-button-contents"},"Joined")),e.error&&z.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"}},z.react.createElement("div",{className:"ui-button-contents"},"Error")),!e.error&&!this.state.joined&&z.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},z.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 me extends z.reactComponent{constructor(e){super(e)}render(){let e=`scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d${this.props.fade?" scrollerFade-1Ijw5y":""}`,t="scroller-2FKFPG scroller";this.props.sidebar&&(t="scroller-2FKFPG firefoxFixScrollFlex-cnI2ix sidebarRegionScroller-3MXcoP sidebar-region-scroller scroller"),this.props.contentColumn&&(t="scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",e="scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv");const{children:n}=this.props;return z.react.createElement("div",{key:"scrollerwrap",className:e},z.react.createElement("div",{key:"scroller",ref:"scroller",className:t},n))}}class ge extends z.reactComponent{constructor(e){super(e)}render(){const{sidebar:e,content:t,tools:n}=this.props.children;return z.react.createElement("div",{className:"standardSidebarView-3F1I7i ui-standard-sidebar-view"},z.react.createElement("div",{className:"sidebarRegion-VFTUkN sidebar-region"},z.react.createElement(me,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:e.fade||!0,dark:e.dark||!0,children:e.component})),z.react.createElement("div",{className:"contentRegion-3nDuYy content-region"},z.react.createElement("div",{className:"contentTransitionWrap-3hqOEW content-transition-wrap"},z.react.createElement("div",{className:"scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},z.react.createElement("div",{className:"scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",ref:"contentScroller"},z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},t.component),n.component)))))}}class fe extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20 marginTop60-3PGbtK da-marginTop6"},this.props.text)}}class be extends z.reactComponent{constructor(e){super(e),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=z.WebpackModules.findByUniqueProperties(["getGuilds"]),this.AvatarDefaults=z.WebpackModules.findByUniqueProperties(["getUserAvatarURL","DEFAULT_AVATARS"]),this.InviteActions=z.WebpackModules.findByUniqueProperties(["acceptInvite"]),this.SortedGuildStore=z.WebpackModules.findByUniqueProperties(["getSortedGuilds"])}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){z.reactDom.unmountComponentAtNode(document.getElementById(this.props.rootId))}search(e,t){const n=this;$.ajax({method:"GET",url:`${n.endPoint}${e}${e?"&schema=new":"?schema=new"}`,success:e=>{let s=e.results.reduce((e,t)=>(t.joined=!1,e.push(t),e),[]);t||(s=n.state.servers.concat(s));let o=e.size+e.from;e.next=`?from=${o}`,n.state.term&&(e.next+=`&term=${n.state.term}`),n.state.selectedCategory&&(e.next+=`&category=${n.categoryButtons[n.state.selectedCategory]}`),o>=e.total&&(o=e.total,e.next=null);let r=`Showing 1-${o} of ${e.total} results in ${n.categoryButtons[n.state.selectedCategory]}`;n.state.term&&(r+=` for ${n.state.term}`),n.setState({loading:!1,title:r,servers:s,next:e.next}),t&&(n.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{n.setState({loading:!1,title:"Failed to load servers. Check console for details"})}})}join(e){if(e.props.pinned)return this.InviteActions.acceptInvite(e.props.invite_code);$.ajax({method:"GET",url:`${this.joinEndPoint}/${e.props.server.identifier}`,headers:{Accept:"application/json;","Content-Type":"application/json;","x-discord-token":this.state.connection.user.accessToken},crossDomain:!0,xhrFields:{withCredentials:!0},success:()=>{e.setState({joined:!0})}})}connect(){const e=this,t=e.windowOptions;t.x=Math.round(window.screenX+window.innerWidth/2-t.width/2),t.y=Math.round(window.screenY+window.innerHeight/2-t.height/2),e.joinWindow=new(window.require("electron").remote.BrowserWindow)(t);e.joinWindow.webContents.on("did-navigate",(t,n)=>{"https://auth.discordservers.com/info"==n&&(e.joinWindow.close(),e.checkConnection())}),e.joinWindow.loadURL("https://auth.discordservers.com/connect?scopes=guilds.join&previousUrl=https://auth.discordservers.com/info")}get windowOptions(){return{width:500,height:550,backgroundColor:"#282b30",show:!0,resizable:!1,maximizable:!1,minimizable:!1,alwaysOnTop:!0,frame:!1,center:!1,webPreferences:{nodeIntegration:!1}}}get bdServer(){const e=this.SortedGuildStore.getFlattenedGuildIds(),t=this.AvatarDefaults.DEFAULT_AVATARS;return z.react.createElement(pe,{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:e,fallback:t[Math.floor(5*Math.random())]})}get endPoint(){return"https://search.discordservers.com"}get joinEndPoint(){return"https://j.discordservers.com"}get connectEndPoint(){return"https://join.discordservers.com/connect"}checkConnection(){const e=this;try{$.ajax({method:"GET",url:"https://auth.discordservers.com/info",headers:{Accept:"application/json;","Content-Type":"application/json;"},crossDomain:!0,xhrFields:{withCredentials:!0},success:t=>{e.setState({selectedCategory:0,connection:{state:2,user:t}}),e.search("",!0)},error:()=>{e.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}})}catch(t){e.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}}render(){return z.react.createElement(ge,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:z.react.createElement(he,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return z.react.createElement("div",{className:"sidebar",key:"ps"},z.react.createElement("div",{className:"ui-tab-bar SIDE"},z.react.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),z.react.createElement(K,null),this.searchInput,z.react.createElement(K,null),z.react.createElement(X,{text:"Categories"}),this.categoryButtons.map((e,t)=>z.react.createElement(ee,{id:t,onClick:this.changeCategory,key:t,text:e,selected:this.state.selectedCategory===t})),z.react.createElement(K,null),this.footer,this.connection))}get searchInput(){return z.react.createElement("div",{className:"ui-form-item"},z.react.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},z.react.createElement("input",{ref:"searchinput",onKeyDown:this.searchKeyDown,onChange:()=>{},type:"text",className:"input default",placeholder:"Search...",maxLength:"50"})))}searchKeyDown(e){const t=this;if(t.state.loading||13!==e.which)return;t.setState({loading:!0,title:"Loading...",term:e.target.value});let n=`?term=${e.target.value}`;0!==t.state.selectedCategory&&(n+=`&category=${t.categoryButtons[t.state.selectedCategory]}`),t.search(n,!0)}get categoryButtons(){return["All","FPS Games","MMO Games","Strategy Games","MOBA Games","RPG Games","Tabletop Games","Sandbox Games","Simulation Games","Music","Community","Language","Programming","Other"]}changeCategory(e){const t=this;t.state.loading||(t.refs.searchinput.value="",t.setState({loading:!0,selectedCategory:e,title:"Loading...",term:null}),0!==e?t.search(`?category=${t.categoryButtons[e]}`,!0):t.search("",!0))}get content(){const e=this,t=this.SortedGuildStore.getFlattenedGuildIds(),n=this.AvatarDefaults.DEFAULT_AVATARS;return 1===e.state.connection.state?e.notConnected:[z.react.createElement("div",{ref:"content",key:"pc",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},z.react.createElement(fe,{text:e.state.title}),e.bdServer,e.state.servers.map(s=>z.react.createElement(pe,{key:s.identifier,server:s,join:e.join,guildList:t,fallback:n[Math.floor(5*Math.random())]})),e.state.next&&z.react.createElement("button",{type:"button",onClick:()=>{e.state.loading||(e.setState({loading:!0}),e.search(e.state.next,!1))},className:"ui-button filled brand small grow",style:{width:"100%",marginTop:"10px",marginBottom:"10px"}},z.react.createElement("div",{className:"ui-button-contents"},e.state.loading?"Loading":"Load More")),e.state.servers.length>0&&z.react.createElement(fe,{text:e.state.title}))]}get notConnected(){return[z.react.createElement("div",{key:"ncc",ref:"content",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},z.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},"Not connected to discordservers.com!",z.react.createElement("button",{onClick:this.connect,type:"button",className:"ui-button filled brand small grow",style:{display:"inline-block",minHeight:"18px",marginLeft:"10px",lineHeight:"14px"}},z.react.createElement("div",{className:"ui-button-contents"},"Connect"))),this.bdServer)]}get footer(){return z.react.createElement("div",{className:"ui-tab-bar-header"},z.react.createElement("a",{href:"https://discordservers.com",target:"_blank"},"Discordservers.com"))}get connection(){const{connection:e}=this.state;return 2!==e.state?z.react.createElement("span",null):z.react.createElement("span",null,z.react.createElement(K,null),z.react.createElement("span",{style:{color:"#b9bbbe",fontSize:"10px",marginLeft:"10px"}},"Connected as: ",`${e.user.username}#${e.user.discriminator}`),z.react.createElement("div",{style:{padding:"5px 10px 0 10px"}},z.react.createElement("button",{style:{width:"100%",minHeight:"20px"},type:"button",className:"ui-button filled brand small grow"},z.react.createElement("div",{className:"ui-button-contents",onClick:this.connect},"Reconnect"))))}}class ve extends z.reactComponent{constructor(e){super(e)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,e=>{27===e.which&&z.reactDom.unmountComponentAtNode(this.refs.root.parentNode)}),$(`#${this.props.id}`).animate({opacity:1},{step:function(e){$(this).css("transform",`scale(${1.1-.1*e}) 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(e){$(this).css("transform",`scale(${1.1-.1*e}) translateZ(0px)`)},duration:200,done:()=>{$(`#${this.props.rootId}`).remove()}}),$('[class*="layer-"]').removeClass("publicServersOpen").animate({opacity:1},{step:function(e){$(this).css("transform",`scale(${.07*e+.93}) translateZ(0px)`)},duration:200,done:()=>{$('[class*="layer-"]').css("opacity","").css("transform","")}})}componentWillMount(){$('[class*="layer-"]').addClass("publicServersOpen").animate({opacity:0},{step:function(e){$(this).css("transform",`scale(${.07*e+.93}) translateZ(0px)`)},duration:200})}render(){return z.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)}}var ye=new class{constructor(){this._appendButton=this._appendButton.bind(this)}get component(){return z.react.createElement(ve,{rootId:"pubslayerroot",id:"pubslayer",children:z.react.createElement(be,{rootId:"pubslayerroot"})})}get root(){const e=document.getElementById("pubslayerroot");return e||(this.injectRoot()?this.root:null)}injectRoot(){return!!$(".layers, .layers-3iHuyZ").length&&($(".layers, .layers-3iHuyZ").append($("<div/>",{id:"pubslayerroot"})),!0)}render(){const e=this.root;e?z.reactDom.render(this.component,e):console.log("FAILED TO LOCATE ROOT: .layers")}get button(){return $("<div/>",{class:z.guildClasses.listItem,id:"bd-pub-li",style:l["bda-gs-1"]?"":"display: none;"}).append($("<div/>",{class:"wrapper-25eVIn "+z.guildClasses.circleButtonMask,text:"public",id:"bd-pub-button",click:()=>{this.render()}}))}_appendButton(){if($("#bd-pub-li").length)return;const e=z.guildClasses.wrapper.split(" ")[0];$(`.${e} .scroller-2FKFPG >:first-child`).after(this.button)}addButton(){if(this.guildPatch)return;const e=de("Guilds");this.guildPatch=S.monkeyPatch(e.prototype,"render",{after:this._appendButton}),this._appendButton()}removeButton(){this.guildPatch(),delete this.guildPatch,$("#bd-pub-li").remove()}};function Ce(){}Ce.prototype.enable=function(){$(".scroller.guild-channels ul").first().css("display","none"),$(".scroller.guild-channels header").first().css("display","none"),$(".app.flex-vertical, .app-2rEoOp").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")},Ce.prototype.disable=function(){$(".scroller.guild-channels ul").first().css("display",""),$(".scroller.guild-channels header").first().css("display",""),$(".app.flex-vertical, .app-2rEoOp").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 ke=new Ce;const we=new RegExp("^(?!da-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$");var Ee=new class{stop(){this.hasPatched&&(this.unpatchClassModules(ce(this.moduleFilter.bind(this))),this.revertElement(document.querySelector("#app-mount")),this.hasPatched=!1)}start(){this.hasPatched||(this.patchClassModules(ce(this.moduleFilter.bind(this))),this.normalizeElement(document.querySelector("#app-mount")),this.hasPatched=!0,this.patchDOMMethods())}patchClassModules(e){for(const t of e)this.patchClassModule("da",t)}unpatchClassModules(e){for(const t of e)this.unpatchClassModule("da",t)}shouldIgnore(e){return!isNaN(e)||(!!(e.endsWith("px")||e.endsWith("ch")||e.endsWith("em")||e.endsWith("ms"))||(!!e.startsWith("layerContainer-")||(!(!e.startsWith("#")||7!=e.length&&4!=e.length)||!(!e.includes("calc(")&&!e.includes("rgba")))))}moduleFilter(e){if("object"!=typeof e||Array.isArray(e))return!1;if(e.__esModule)return!1;if(!Object.keys(e).length)return!1;for(const t in e){const n=e[t];if("string"!=typeof n)return!1;if(!this.shouldIgnore(n)){if(1===n.split("-").length)return!1;if(!we.test(n.split(" ")[0]))return!1}}return!0}patchClassModule(e,t){for(const n in t){const s=t[n];if(this.shouldIgnore(s))continue;const o=s.split(" ");for(const s of o){const o=s.match(we);if(!o||!o.length||o.length<2)continue;const r=o[1].split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");t[n]+=` ${e}-${r}`}}}unpatchClassModule(e,t){for(const n in t){const s=t[n];if(this.shouldIgnore(s))continue;let o="";const r=s.split(" ");for(const t of r)t.startsWith(`${e}-`)||(o+=` ${t}`);t[n]=o.trim()}}normalizeElement(e){if(!(e instanceof Element))return;const t=e.classList;for(let n=0,s=t.length;n<s;n++){if(!we.test(t[n]))continue;const s=t[n].match(we)[1].split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");e.classList.add(`da-${s}`)}for(const t of e.children)this.normalizeElement(t)}revertElement(e){if(!(e instanceof Element))return;e.children&&e.children.length&&this.revertElement(e.children[0]),e.nextElementSibling&&this.revertElement(e.nextElementSibling);const t=e.classList,n=[];for(let e=0;e<t.length;e++)t[e].startsWith("da-")&&n.push(t[e]);e.classList.remove(...n)}patchDOMMethods(){const e=DOMTokenList.prototype.contains;DOMTokenList.prototype.contains=function(t){return t.split(" ").every(t=>e.call(this,t))}}};function xe(){}xe.prototype.enable=function(e){const t=this;this.disable(),$(document).on("keydown.bdDevmode",(function(e){119!==e.which&&118!=e.which||(console.log("%c[%cDevMode%c] %cBreak/Resume","color: red;","color: #303030; font-weight:700;","color:red;",""),e.preventDefault(),e.stopImmediatePropagation())})),e&&$(document).on("contextmenu.bdDevmode",(function(e){t.lastSelector=t.getSelector(e.toElement),setImmediate((function(){let n=$(".contextMenu-HLZMGh");n.length<=0&&(n=$('<div class="contextMenu-HLZMGh bd-context-menu"></div>'),n.addClass($(".app, .app-2rEoOp").hasClass("theme-dark")?"theme-dark":"theme-light"),n.appendTo(".app, .app-2rEoOp"),n.css("top",e.clientY),n.css("left",e.clientX),$(document).on("click.bdDevModeCtx",()=>{n.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("contextmenu.bdDevModeCtx",()=>{n.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("keyup.bdDevModeCtx",e=>{27===e.keyCode&&(n.remove(),$(document).off(".bdDevModeCtx"))}));const s=$("<div/>",{class:"itemGroup-1tL0uz"}),o=$("<div/>",{class:"item-1Yvehc",click:function(){z.NativeModule.copy(t.lastSelector),n.hide()}}).append($("<span/>",{text:"Copy Selector"}));s.append(o),n.append(s),n.hasClass("undefined")&&n.css("top","-="+s.outerHeight())})),e.stopPropagation()}))},xe.prototype.getRules=function(e,t=e.ownerDocument.styleSheets){return[...t].filter(e=>!e.href||!e.href.includes("BetterDiscordApp")).map(e=>[...e.cssRules||[]]).flat().filter(t=>t&&t.selectorText&&e.matches(t.selectorText)&&t.style.length&&t.selectorText.split(", ").length<8&&!t.selectorText.split(", ").includes("*"))},xe.prototype.getSelector=function(e){if(e.id)return`#${e.id}`;const t=this.getRules(e),n=t[t.length-1];return n?n.selectorText:e.classList.length?`.${Array.from(e.classList).join(".")}`:`.${Array.from(e.parentElement.classList).join(".")}`},xe.prototype.disable=function(){$(document).off("keydown.bdDevmode"),$(document).off("contextmenu.bdDevmode"),$(document).off("contextmenu.bdDevModeCtx")};var Se=new xe;class $e extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#dcddde",className:"bd-reload "+this.props.className,onClick:this.props.onClick,style:{width:this.props.size||"24px",height:this.props.size||"24px"}},z.react.createElement("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}),z.react.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}))}}var De=function(e,t){const{style:n="black",side:s="top",text:o=""}=t,r=z.KeyGenerator();return class extends z.reactComponent{constructor(e){super(e),this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this)}componentDidMount(){this.node=z.reactDom.findDOMNode(this),this.node.addEventListener("mouseenter",this.onMouseEnter),this.node.addEventListener("mouseleave",this.onMouseLeave)}componentWillUnmount(){this.node.removeEventListener("mouseenter",this.onMouseEnter),this.node.removeEventListener("mouseleave",this.onMouseLeave)}onMouseEnter(){if(!z.Tooltips)return;const{left:e,top:t,width:a,height:i}=this.node.getBoundingClientRect();z.Tooltips.show(r,{position:s,text:o,color:n,targetWidth:a,targetHeight:i,windowWidth:S.screenWidth,windowHeight:S.screenHeight,x:e,y:t});const c=new MutationObserver(e=>{e.forEach(e=>{const t=Array.from(e.removedNodes),n=t.indexOf(this.node)>-1,s=t.some(e=>e.contains(this.node));(n||s)&&(this.onMouseLeave(),c.disconnect())})});c.observe(document.body,{subtree:!0,childList:!0})}onMouseLeave(){z.Tooltips&&z.Tooltips.hide(r)}render(){return z.react.createElement(e,this.props)}}};class Te extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("ul",{className:this.props.className},this.props.children)}}class Ne extends z.reactComponent{constructor(e){super(e);this.onChange=this.onChange.bind(this),this.showSettings=this.showSettings.bind(this),this.setInitialState(),this.hasSettings="function"==typeof this.props.plugin.getSettingsPanel,this.settingsPanel="",this.reload=this.reload.bind(this),this.onReload=this.onReload.bind(this)}setInitialState(){this.state={checked:E[this.props.plugin.getName()],settings:!1,reloads:0}}onReload(e){e===this.props.plugin.getName()&&this.setState({reloads:this.state.reloads+1})}componentDidUpdate(){if(this.state.settings){if("object"==typeof this.settingsPanel&&this.refs.settingspanel.appendChild(this.settingsPanel),!l["fork-ps-3"])return;const e=(e,t)=>{const n=e.scrollTop,s=n+e.clientHeight,o=t.offsetTop,r=o+t.clientHeight;return o<n||r>s},t=$(z.reactDom.findDOMNode(this)),n=t.parents(".scroller");if(!e(n[0],t[0]))return;n.animate({scrollTop:t.offset().top-n.offset().top+n.scrollTop()-30},300)}}reload(){const e=this.props.plugin.getName();P.reloadPlugin(e),this.props.plugin=w[e].plugin,this.onReload(this.props.plugin.getName())}getString(e){return"string"==typeof e?e:e.toString()}makeLink(e,t){const n={className:"bda-link bda-link-website",target:"_blank"};return"string"==typeof t&&(n.href=t),"function"==typeof t&&(n.onClick=e=>{e.preventDefault(),e.stopPropagation(),t()}),z.react.createElement("a",n,e)}render(){const e=this,{plugin:t}=this.props,n=this.getString(t.getName()),s=this.getString(t.getAuthor()),o=this.getString(t.getDescription()),r=this.getString(t.getVersion()),a=w[n];if(this.state.settings){try{e.settingsPanel=t.getSettingsPanel()}catch(e){S.err("Plugins","Unable to get settings panel for "+t.getName()+".",e)}return z.react.createElement("li",{className:"settings-open ui-switch-item"},z.react.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.refs.settingspanel.innerHTML="",e.setState({settings:!1})}},z.react.createElement(ue,null)),"object"==typeof e.settingsPanel&&z.react.createElement("div",{id:`plugin-settings-${n}`,className:"plugin-settings",ref:"settingspanel"}),"object"!=typeof e.settingsPanel&&z.react.createElement("div",{id:`plugin-settings-${n}`,className:"plugin-settings",ref:"settingspanel",dangerouslySetInnerHTML:{__html:e.settingsPanel}}))}const i=[];a.website&&i.push(this.makeLink("Website",a.website)),a.source&&i.push(this.makeLink("Source",a.source)),a.invite&&i.push(this.makeLink("Support Server",()=>{const e=/\.gg\/(.*)$/;let t=a.invite;e.test(t)&&(t=t.match(e)[1]),z.LayerStack.popLayer(),z.InviteActions.acceptInviteAndTransitionToInviteChannel(t)})),a.donate&&i.push(this.makeLink("Donate",a.donate)),a.patreon&&i.push(this.makeLink("Patreon",a.patreon));const c={className:"bda-author"};return(a.authorLink||a.authorId)&&(c.className+=` ${z.anchorClasses.anchor} ${z.anchorClasses.anchorUnderlineOnHover}`,c.target="_blank",a.authorLink&&(c.href=a.authorLink),a.authorId&&(c.onClick=()=>{z.LayerStack.popLayer(),z.openDM(a.authorId)})),z.react.createElement("li",{"data-name":n,"data-version":r,className:"settings-closed ui-switch-item"},z.react.createElement("div",{className:"bda-header"},z.react.createElement("span",{className:"bda-header-title"},z.react.createElement("span",{className:"bda-name"},n)," v",z.react.createElement("span",{className:"bda-version"},r)," by ",z.react.createElement(a.authorLink||a.authorId?"a":"span",c,s)),z.react.createElement("div",{className:"bda-controls"},!l["fork-ps-5"]&&z.react.createElement(De($e,{color:"black",side:"top",text:"Reload"}),{className:"bd-reload-card",onClick:this.reload}),z.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},z.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),z.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),z.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},z.react.createElement("div",{className:"bda-description scroller"},o)),(i.length||this.hasSettings)&&z.react.createElement("div",{className:"bda-footer"},z.react.createElement("span",{className:"bda-links"},...i.map((e,t)=>t<i.length-1?[e," | "]:e).flat()),this.hasSettings&&z.react.createElement("button",{onClick:this.showSettings,className:"bda-settings-button",disabled:!this.state.checked},"Settings")))}onChange(){this.setState({checked:!this.state.checked}),P.togglePlugin(this.props.plugin.getName())}showSettings(){this.hasSettings&&this.setState({settings:!0})}}class Pe extends z.reactComponent{constructor(e){super(e),this.setInitialState(),this.onChange=this.onChange.bind(this),this.reload=this.reload.bind(this)}setInitialState(){this.state={checked:x[this.props.theme.name],reloads:0}}onReload(e){e===this.props.theme.name&&this.setState({reloads:this.state.reloads+1})}reload(){const e=this.props.theme.name;B.reloadTheme(e)?S.showToast(`Could not reload ${k[e].name}. Check console for details.`,{type:"error"}):S.showToast(`${k[e].name} v${k[e].version} has been reloaded.`,{type:"success"}),this.props.theme=k[e],this.onReload(this.props.theme.name)}makeLink(e,t){const n={className:"bda-link bda-link-website",target:"_blank"};return"string"==typeof t&&(n.href=t),"function"==typeof t&&(n.onClick=e=>{e.preventDefault(),e.stopPropagation(),t()}),z.react.createElement("a",n,e)}render(){const{theme:e}=this.props,t=e.name,n=e.description,s=e.version,o=e.author,r=k[t],a=[];r.website&&a.push(this.makeLink("Website",r.website)),r.source&&a.push(this.makeLink("Source",r.source)),r.invite&&a.push(this.makeLink("Support Server",()=>{const e=/\.gg\/(.*)$/;let t=r.invite;e.test(t)&&(t=t.match(e)[1]),z.LayerStack.popLayer(),z.InviteActions.acceptInviteAndTransitionToInviteChannel(t)})),r.donate&&a.push(this.makeLink("Donate",r.donate)),r.patreon&&a.push(this.makeLink("Patreon",r.patreon));const i={className:"bda-author"};return(r.authorLink||r.authorId)&&(i.className+=` ${z.anchorClasses.anchor} ${z.anchorClasses.anchorUnderlineOnHover}`,i.target="_blank",r.authorLink&&(i.href=r.authorLink),r.authorId&&(i.onClick=()=>{z.LayerStack.popLayer(),z.openDM(r.authorId)})),z.react.createElement("li",{"data-name":t,"data-version":s,className:"settings-closed ui-switch-item"},z.react.createElement("div",{className:"bda-header"},z.react.createElement("span",{className:"bda-header-title"},z.react.createElement("span",{className:"bda-name"},t)," v",z.react.createElement("span",{className:"bda-version"},s)," by ",z.react.createElement(r.authorLink||r.authorId?"a":"span",i,o)),z.react.createElement("div",{className:"bda-controls"},!l["fork-ps-5"]&&z.react.createElement(De($e,{color:"black",side:"top",text:"Reload"}),{className:"bd-reload-card",onClick:this.reload}),z.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},z.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),z.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),z.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},z.react.createElement("div",{className:"bda-description scroller"},n)),!!a.length&&z.react.createElement("div",{className:"bda-footer"},z.react.createElement("span",{className:"bda-links"},...a.map((e,t)=>t<a.length-1?[e," | "]:e).flat())))}onChange(){this.setState({checked:!this.state.checked}),B.toggleTheme(this.props.theme.name)}}class Me extends z.reactComponent{constructor(e){super(e),this.setInitialState(),this.onChange=this.onChange.bind(this)}setInitialState(){this.state={checked:this.props.checked}}render(){const{text:e,info:t}=this.props.data,{checked:n}=this.state;return z.react.createElement("div",{className:"ui-flex flex-vertical flex-justify-start flex-align-stretch flex-nowrap ui-switch-item"},z.react.createElement("div",{className:"ui-flex flex-horizontal flex-justify-start flex-align-stretch flex-nowrap"},z.react.createElement("h3",{className:"ui-form-title h3 margin-reset margin-reset ui-flex-child"},e),z.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},z.react.createElement("input",{className:"ui-switch-checkbox",type:"checkbox",checked:n,onChange:e=>this.onChange(e)}),z.react.createElement("div",{className:`ui-switch ${n?"checked":""}`}))),z.react.createElement("div",{className:"ui-form-text style-description margin-top-4",style:{flex:"1 1 auto"}},t))}onChange(){this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked})}}class Be extends z.reactComponent{constructor(e){super(e)}render(){const{title:e,settings:t,button:n}=this.props,s=n?z.react.createElement("button",{key:"title-button",className:"bd-pfbtn",onClick:n.onClick},n.title):null;return[z.react.createElement(fe,{text:e}),s,t.map(e=>z.react.createElement(Me,{id:e.id,key:e.id,data:e,checked:l[e.id],onChange:(e,t)=>{this.props.onChange(e,t)}}))]}}class je extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},this.props.sections.map(e=>z.react.createElement(Be,Object.assign({},e,{onChange:this.props.onChange}))))}}class Oe extends z.reactComponent{constructor(e){super(e)}render(){const{settings:e}=this.props;return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},z.react.createElement(fe,{text:this.props.title}),this.props.button&&z.react.createElement("button",{key:"title-button",className:"bd-pfbtn",onClick:this.props.button.onClick},this.props.button.title),e.map(e=>z.react.createElement(Me,{id:e.id,key:e.id,data:e,checked:l[e.id],onChange:(e,t)=>{this.props.onChange(e,t)}})))}}class Fe extends z.reactComponent{constructor(e){super(e),this.onClick=this.onClick.bind(this),this.setInitialState()}setInitialState(){this.state={checked:this.props.checked||!1}}render(){return z.react.createElement("li",null,z.react.createElement("div",{className:"checkbox checkbox-3kaeSU da-checkbox",onClick:this.onClick},z.react.createElement("div",{className:"checkbox-inner checkboxInner-3yjcPe da-checkboxInner"},z.react.createElement("input",{className:"checkboxElement-1qV33p da-checkboxElement",checked:this.state.checked,onChange:()=>{},type:"checkbox"}),z.react.createElement("span",null)),z.react.createElement("span",null,this.props.text)))}onClick(){this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked})}}class Le extends z.reactComponent{constructor(e){super(e);this.onClick=this.onClick.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.onChange=this.onChange.bind(this)}componentDidMount(){$("#app-mount").addClass("bd-detached-editor"),z.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",()=>{l["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){$("#app-mount").removeClass("bd-detached-editor"),z.editorDetached=!1,this.editor.destroy()}updateLineCount(){const e=this.refs.editor.value.split("\n").length;e!=this.props.lines&&(this.refs.lines.textContent=Array.from(new Array(e),(e,t)=>t+1).join(".\n")+".",this.props.lines=e)}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){const e=V.getBDData("bdcustomcss");let t="";return e&&""!==e&&(t=atob(e)),t}get root(){const e=$("#bd-customcss-detach-container");return e.length?e[0]:this.injectRoot()?this.detachedRoot:null}injectRoot(){return!!$(".app, .app-2rEoOp").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app, .app-2rEoOp")),!0)}render(){const e=this;return z.react.createElement("div",{className:"bd-detached-css-editor",id:"bd-customcss-detach-editor"},z.react.createElement("div",{id:"bd-customcss-innerpane"},z.react.createElement("div",{className:"editor-wrapper"},z.react.createElement("div",{id:"bd-customcss-editor-detached",className:"editor",ref:"editor"},e.css)),z.react.createElement("div",{id:"bd-customcss-attach-controls"},z.react.createElement("ul",{className:"checkbox-group"},z.react.createElement(Fe,{id:"live-update",text:"Live Update",onChange:e.onChange,checked:l["bda-css-0"]})),z.react.createElement("div",{id:"bd-customcss-detach-controls-button"},z.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("update")}},"Update"),z.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{e.onClick("save")}},"Save"),z.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("attach")}},"Attach"),z.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on attach")))))}onChange(e,t){switch(e){case"live-update":l["bda-css-0"]=t,Re.saveSettings()}}onClick(e){const t=this;switch(e){case"attach":$("#editor-detached").length&&t.props.attach(),z.reactDom.unmountComponentAtNode(t.root),t.root.remove();break;case"update":t.updateCss();break;case"save":t.saveCss()}}updateCss(){0==$("#customcss").length&&$("head").append('<style id="customcss"></style>'),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){V.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}}class Ae extends z.reactComponent{constructor(e){super(e);this.props.lines=0,this.setInitialState(),this.attach=this.attach.bind(this),this.detachedEditor=z.react.createElement(Le,{attach:this.attach}),this.onClick=this.onClick.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.detach=this.detach.bind(this)}setInitialState(){this.state={detached:this.props.detached||z.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",()=>{l["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){this.editor.destroy()}componentDidUpdate(e,t){const n=this;t.detached&&!n.state.detached&&z.reactDom.unmountComponentAtNode(n.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){const e=V.getBDData("bdcustomcss");let t="";return e&&""!==e&&(t=atob(e)),t}updateLineCount(){const e=this.refs.editor.value.split("\n").length;e!=this.props.lines&&(this.refs.lines.textContent=Array.from(new Array(e),(e,t)=>t+1).join(".\n")+".",this.props.lines=e)}render(){const e=this,{detached:t}=e.state;return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default",style:{padding:"60px 40px 0px"}},t&&z.react.createElement("div",{id:"editor-detached"},z.react.createElement(fe,{text:"Custom CSS Editor"}),z.react.createElement("h3",null,"Editor Detached"),z.react.createElement("button",{className:"btn btn-primary",onClick:()=>{e.attach()}},"Attach")),!t&&z.react.createElement("div",null,z.react.createElement(fe,{text:"Custom CSS Editor"}),z.react.createElement("div",{className:"editor-wrapper"},z.react.createElement("div",{id:"bd-customcss-editor",className:"editor",ref:"editor"},e.css)),z.react.createElement("div",{id:"bd-customcss-attach-controls"},z.react.createElement("ul",{className:"checkbox-group"},z.react.createElement(Fe,{id:"live-update",text:"Live Update",onChange:this.onChange,checked:l["bda-css-0"]})),z.react.createElement("div",{id:"bd-customcss-detach-controls-button"},z.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("update")}},"Update"),z.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{e.onClick("save")}},"Save"),z.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("detach")}},"Detach"),z.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach"),z.react.createElement("div",{className:"help-text"},"Press ",z.react.createElement("code",{className:"inline"},"ctrl"),"+",z.react.createElement("span",{className:"inline"},",")," with the editor focused to access the editor's settings.")))))}onClick(e){const t=this;switch(e){case"update":t.updateCss();break;case"save":t.saveCss();break;case"detach":t.detach()}}onChange(e,t){switch(e){case"live-update":l["bda-css-0"]=t,Re.saveSettings()}}updateCss(){0==$("#customcss").length&&$("head").append('<style id="customcss"></style>'),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){V.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}detach(){this.setState({detached:!0});const e=this.detachedRoot;e?z.reactDom.render(this.detachedEditor,e):console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){const e=$("#bd-customcss-detach-container");return e.length?e[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app, .app-2rEoOp").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app, .app-2rEoOp")),!0)}attach(){this.setState({detached:!1})}}class Ie extends z.reactComponent{constructor(e){super(e)}static get displayName(){return"ContentColumn"}render(){return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},z.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}var Re=new class{constructor(){this.sideBarOnClick=this.sideBarOnClick.bind(this),this.onChange=this.onChange.bind(this),this.updateSettings=this.updateSettings.bind(this),this.sidebar=new ne(this.sideBarOnClick)}get root(){const e=$("#bd-settingspane-container");return e.length?e[0]:this.injectRoot()?this.root:null}injectRoot(){if(!$(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").length)return!1;const e=$("<div/>",{class:"contentRegion-3nDuYy content-region",id:"bd-settingspane-container"});return $(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").append(e),S.onRemoved(e[0],()=>{z.reactDom.unmountComponentAtNode(e[0])}),!0}get coreSettings(){const e=this.getSettings("core");return[...new Set(e.map(e=>e.category))].map(t=>({title:t,settings:e.filter(e=>e.category==t)}))}get emoteSettings(){return this.getSettings("emote")}getSettings(e){const t=z.WebpackModules.findByUniqueProperties(["getSortedGuilds"]),n=z.WebpackModules.findByUniqueProperties(["getMember"]),s=z.UserStore.getCurrentUser().id,o=async(e,o)=>{if(!t||!n)return!1;const r=t.getFlattenedGuildIds().includes(e),a=n.getMember(e,s);return!(!r||!a)&&a.roles.includes(o)},r=(async()=>{if("197435711476072449"===s)return!1;const e=o("292141134614888448","452687773678436354"),t=o("86004744966914048","125166040689803264")||o("280806472928198656","357242595950329857");return e||t})();return Object.keys(i).reduce((t,n)=>{const s=i[n];return s.cat===e&&s.implemented&&!s.hidden&&("beta"!==i.category||"beta"===i.category&&r)&&(s.text=n,t.push(s)),t},[])}sideBarOnClick(e){const t=this;switch($(".contentRegion-3nDuYy, .content-region").first().hide(),$(t.root).show(),e){case"core":t.renderCoreSettings();break;case"emotes":t.renderEmoteSettings();break;case"customcss":t.renderCustomCssEditor();break;case"plugins":t.renderPluginPane();break;case"themes":t.renderThemePane()}}onClick(){}onChange(e,t){this.updateSettings(e,t)}updateSettings(e,t){if(l[e]=t,"fork-beta"==e){try{const e=n(0),s=n(2).join(DiscordNative.process.remote.resourcesPath,"app","betterdiscord","config.json"),o=require(s);t?(o.branch="modularize",o.minified=!1):(o.branch="master",o.minified=!0),e.writeFileSync(s,JSON.stringify(o,null,4))}catch(e){console.error(e)}(()=>{const e=z.WebpackModules.findByUniqueProperties(["push","update","pop","popWithKey"]),t=z.WebpackModules.findByPrototypes(["handleCancel","handleSubmit","handleMinorConfirm"]);e&&t&&e.push((function(e){return z.React.createElement(t,Object.assign({title:"Restart Required",body:"Please FULLY restart Discord in order for these changes to take effect."},e))}))})()}"bda-gs-2"==e&&(t?$("body").addClass("bd-minimal"):$("body").removeClass("bd-minimal")),"bda-gs-3"==e&&(t?$("body").addClass("bd-minimal-chan"):$("body").removeClass("bd-minimal-chan")),"bda-gs-1"==e&&(t?ye.addButton():ye.removeButton()),"bda-gs-4"==e&&(t?ke.enable():ke.disable()),"bda-gs-5"==e&&(t?$("#app-mount").addClass("bda-dark"):$("#app-mount").removeClass("bda-dark")),t&&"bda-gs-6"==e&&oe.inject24Hour(),"bda-gs-7"==e&&(t?se.injectColoredText():se.removeColoredText()),"bda-es-4"==e&&(t?Q.autoCapitalize():Q.disableAutoCapitalize()),"fork-ps-4"==e&&(t?Ee.start():Ee.stop()),"fork-ps-5"==e&&(t?(q.watchContent("plugin"),q.watchContent("theme")):(q.unwatchContent("plugin"),q.unwatchContent("theme"))),"bda-gs-8"==e&&(t?Se.enable(l["fork-dm-1"]):Se.disable()),"fork-dm-1"==e&&l["bda-gs-8"]&&Se.enable(t),this.saveSettings()}async initializeSettings(){l["bda-gs-2"]&&$("body").addClass("bd-minimal"),l["bda-gs-3"]&&$("body").addClass("bd-minimal-chan"),l["bda-gs-1"]&&ye.addButton(),l["bda-gs-4"]&&ke.enable(),l["bda-gs-5"]&&$("#app-mount").addClass("bda-dark"),l["bda-gs-6"]&&oe.inject24Hour(),l["bda-gs-7"]&&se.injectColoredText(),l["bda-es-4"]&&Q.autoCapitalize(),l["fork-ps-4"]&&Ee.start(),l["fork-ps-5"]&&(q.watchContent("plugin"),q.watchContent("theme")),l["bda-gs-8"]&&Se.enable(l["fork-dm-1"]),(async()=>{const e=z.WebpackModules.findByUniqueProperties(["getSortedGuilds"]),t=z.WebpackModules.findByUniqueProperties(["getMember"]),n=e.getFlattenedGuildIds().includes("292141134614888448"),s=z.UserStore.getCurrentUser().id,o=t.getMember("292141134614888448",s);!(!n||!o)&&o.roles.includes("452687773678436354")&&(i["BBD Beta"].hidden=!1)})(),this.saveSettings()}saveSettings(){V.setSettingGroup("settings",l)}loadSettings(){Object.assign(l,V.getSettingGroup("settings"))}renderSidebar(){const e=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{z.reactDom.unmountComponentAtNode(e.root),$(e.root).hide(),$(".contentRegion-3nDuYy, .content-region").first().show()}),e.sidebar.render()}get coreComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(je,{key:"cspanel",onChange:this.onChange,sections:this.coreSettings}),z.react.createElement(he,{key:"tools"})]})}get emoteComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(Oe,{key:"espanel",title:"Emote Settings",onChange:this.onChange,settings:this.emoteSettings,button:{title:"Clear Emote Cache",onClick:()=>{Q.clearEmoteData(),Q.init(),J.init()}}}),z.react.createElement(he,{key:"tools"})]})}get customCssComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(Ae,{key:"csseditor"}),z.react.createElement(he,{key:"tools"})]})}contentComponent(e){const t="plugins"==e?this.pluginsComponent:this.themesComponent,n=e.replace("s",""),s=this;class o extends z.react.Component{constructor(e){super(e),this.onChange=this.onChange.bind(this)}componentDidMount(){T.on(`${n}-reloaded`,this.onChange),T.on(`${n}-loaded`,this.onChange),T.on(`${n}-unloaded`,this.onChange)}componentWillUnmount(){T.off(`${n}-reloaded`,this.onChange),T.off(`${n}-loaded`,this.onChange),T.off(`${n}-unloaded`,this.onChange)}onChange(){s.sideBarOnClick(e)}render(){return t}}return z.react.createElement(o)}get pluginsComponent(){const e=Object.keys(w).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(z.react.createElement(Ne,{key:t,plugin:w[t].plugin})),e),[]),t=z.react.createElement(Te,{key:"plugin-list",className:"bda-slist",children:e}),s=!l["fork-ps-5"]&&z.react.createElement(De($e,{color:"black",side:"top",text:"Reload Plugin List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{P.updatePluginList(),this.sideBarOnClick("plugins")}}),o=z.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{n(1).shell.openItem(q.pluginsFolder)}},"Open Plugin Folder"),r=z.react.createElement(Ie,{key:"pcolumn",title:"Plugins",children:[s,o,t]});return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[r,z.react.createElement(he,{key:"tools"})]})}get themesComponent(){const e=Object.keys(k).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(z.react.createElement(Pe,{key:t,theme:k[t]})),e),[]),t=z.react.createElement(Te,{key:"theme-list",className:"bda-slist",children:e}),s=!l["fork-ps-5"]&&z.react.createElement(De($e,{color:"black",side:"top",text:"Reload Theme List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{B.updateThemeList(),this.sideBarOnClick("themes")}}),o=z.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{n(1).shell.openItem(q.themesFolder)}},"Open Theme Folder"),r=z.react.createElement(Ie,{key:"tcolumn",title:"Themes",children:[s,o,t]});return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[r,z.react.createElement(he,{key:"tools"})]})}renderCoreSettings(){const e=this.root;e?z.reactDom.render(this.coreComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderEmoteSettings(){const e=this.root;e?z.reactDom.render(this.emoteComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderCustomCssEditor(){const e=this.root;e?z.reactDom.render(this.customCssComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderPluginPane(){const e=this.root;e?z.reactDom.render(this.contentComponent("plugins"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderThemePane(){const e=this.root;e?z.reactDom.render(this.contentComponent("themes"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}};class _e extends z.reactComponent{render(){return z.react.createElement("svg",{height:"100%",width:this.props.size||"16px",className:"bd-logo "+this.props.className,style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},viewBox:"0 0 2000 2000"},z.react.createElement("metadata",null),z.react.createElement("defs",null,z.react.createElement("filter",{id:"shadow1"},z.react.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"})),z.react.createElement("filter",{id:"shadow2"},z.react.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20","flood-color":"rgba(255,255,255,0.15)"})),z.react.createElement("filter",{id:"shadow3"},z.react.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"}))),z.react.createElement("g",null,z.react.createElement("path",{style:{filter:"url(#shadow3)"},d:"M1195.44+135.442L1195.44+135.442L997.6+136.442C1024.2+149.742+1170.34+163.542+1193.64+179.742C1264.34+228.842+1319.74+291.242+1358.24+365.042C1398.14+441.642+1419.74+530.642+1422.54+629.642L1422.54+630.842L1422.54+632.042C1422.54+773.142+1422.54+1228.14+1422.54+1369.14L1422.54+1370.34L1422.54+1371.54C1419.84+1470.54+1398.24+1559.54+1358.24+1636.14C1319.74+1709.94+1264.44+1772.34+1193.64+1821.44C1171.04+1837.14+1025.7+1850.54+1000+1863.54L1193.54+1864.54C1539.74+1866.44+1864.54+1693.34+1864.54+1296.64L1864.54+716.942C1866.44+312.442+1541.64+135.442+1195.44+135.442Z",fill:"#171717",opacity:"1"}),z.react.createElement("path",{style:{filter:"url(#shadow2)"},d:"M1695.54+631.442C1685.84+278.042+1409.34+135.442+1052.94+135.442L361.74+136.442L803.74+490.442L1060.74+490.442C1335.24+490.442+1335.24+835.342+1060.74+835.342L1060.74+1164.84C1150.22+1164.84+1210.53+1201.48+1241.68+1250.87C1306.07+1353+1245.76+1509.64+1060.74+1509.64L361.74+1863.54L1052.94+1864.54C1409.24+1864.54+1685.74+1721.94+1695.54+1368.54C1695.54+1205.94+1651.04+1084.44+1572.64+999.942C1651.04+915.542+1695.54+794.042+1695.54+631.442Z",fill:"#3E82E5",opacity:"1"}),z.react.createElement("path",{style:{filter:"url(#shadow1)"},d:"M1469.25+631.442C1459.55+278.042+1183.05+135.442+826.65+135.442L135.45+135.442L135.45+1004C135.45+1004+135.427+1255.21+355.626+1255.21C575.825+1255.21+575.848+1004+575.848+1004L577.45+490.442L834.45+490.442C1108.95+490.442+1108.95+835.342+834.45+835.342L664.65+835.342L664.65+1164.84L834.45+1164.84C923.932+1164.84+984.244+1201.48+1015.39+1250.87C1079.78+1353+1019.47+1509.64+834.45+1509.64L135.45+1509.64L135.45+1864.54L826.65+1864.54C1182.95+1864.54+1459.45+1721.94+1469.25+1368.54C1469.25+1205.94+1424.75+1084.44+1346.35+999.942C1424.75+915.542+1469.25+794.042+1469.25+631.442Z",fill:"#FFFFFF",opacity:"1"})))}}function qe(e){Object.assign(h,e)}qe.prototype.init=async function(){if(h.version<o)return void S.alert("Not Supported","BetterDiscord v"+h.version+" (your version) is not supported by the latest js ("+r+").<br><br> Please download the latest version from <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>GitHub</a>");if(window.ED)return void S.alert("Not Supported","BandagedBD does not work with EnhancedDiscord. Please uninstall one of them.");if(window.WebSocket&&window.WebSocket.name&&window.WebSocket.name.includes("Patched"))return void S.alert("Not Supported","BandagedBD does not work with Powercord. Please uninstall one of them.");const e=h.updater?h.updater.LatestVersion:h.latestVersion;e>h.version&&S.alert("Update Available",`\n An update for BandagedBD is available (${e})! Please Reinstall!<br /><br />\n <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>Download Installer</a>\n `);const t=z.WebpackModules.findByUniqueProperties(["getSortedGuilds"]),n=z.WebpackModules.findByUniqueProperties(["getMember"]),s=z.UserStore.getCurrentUser().id,i=async(e,o)=>{if(!t||!n)return!1;const r=t.getFlattenedGuildIds().includes(e),a=n.getMember(e,s);return!(!r||!a)&&a.roles.includes(o)};(async()=>{if("197435711476072449"===s)return!1;const e=i("292141134614888448","452687773678436354"),t=i("86004744966914048","125166040689803264")||i("280806472928198656","357242595950329857");return e||t})()||S.alert("Beta Access","You don't seem like you should have Beta Access... how did you get here?"),S.log("Startup","Initializing Settings"),this.initSettings(),S.log("Startup","Initializing EmoteModule"),window.emotePromise=Q.init().then(()=>{Q.initialized=!0,S.log("Startup","Initializing QuickEmoteMenu"),J.init()}),this.injectExternals(),await this.checkForGuilds(),z.initialize(),S.log("Startup","Updating Settings"),Re.initializeSettings(),S.log("Startup","Loading Plugins"),P.loadPlugins(),S.log("Startup","Loading Themes"),B.loadThemes(),$("#customcss").detach().appendTo(document.head),window.addEventListener("beforeunload",(function(){l["bda-dc-0"]&&document.querySelector(".btn.btn-disconnect").click()})),Q.autoCapitalize(),S.log("Startup","Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2").length&&document.getElementsByClassName("bd-loaderv2")[0].remove(),S.log("Startup","Initializing Main Observer"),this.initObserver(),l["fork-ps-1"]&&(S.log("Startup","Collecting Startup Errors"),S.showContentErrors({plugins:d,themes:u}));const c=V.getBDData("version");r>c&&(a&&this.showChangelogModal(a),V.setBDData("version",r)),S.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),S.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),S.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),S.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")()},qe.prototype.checkForGuilds=function(){let e=0;return new Promise(t=>{const n=function(){const s=z.guildClasses.wrapper.split(" ")[0];document.querySelectorAll(`.${s}`).length>0&&e++;const o=z.guildClasses.listItem.split(" ")[0],r=z.guildClasses.blobContainer.split(" ")[0];return document.querySelectorAll(`.${s} .${o} .${r}`).length>0||e>=50?t(h.deferLoaded=!0):void setTimeout(n,100)};$(document).ready((function(){setTimeout(n,100)}))})},qe.prototype.injectExternals=async function(){await S.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"),window.require.original&&(window.require=window.require.original)},qe.prototype.initSettings=function(){if(V.initialize(),V.getSettingGroup("settings")){Re.loadSettings(),$('<style id="customcss">').text(atob(V.getBDData("bdcustomcss"))).appendTo(document.head);for(const e in c)null==l[e]&&(l[e]=c[e],Re.saveSettings())}else Object.assign(l,c),Re.saveSettings()},qe.prototype.initObserver=function(){new MutationObserver(e=>{for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==P&&P.rawObserver(n),!(n.addedNodes.length&&n.addedNodes[0]instanceof Element))continue;const s=n.addedNodes[0];s.classList.contains("layer-3QrUeG")&&(s.getElementsByClassName("guild-settings-base-section").length&&s.setAttribute("layer-id","server-settings"),s.getElementsByClassName("socialLinks-3jqNFy").length&&(s.setAttribute("layer-id","user-settings"),s.setAttribute("id","user-settings"),document.getElementById("bd-settings-sidebar")||Re.renderSidebar())),s.parentElement==document.body&&s.querySelector("#ace_settingsmenu")&&(s.id="ace_settingsmenu_container"),s.classList.contains("layer-v9HyYc")&&s.getElementsByClassName("emojiPicker-3m1S-j").length&&!s.querySelector(".emojiPicker-3m1S-j").parentElement.classList.contains("animatorLeft-1EQxU0")&&J.obsCallback(s)}}).observe(document,{childList:!0,subtree:!0})},qe.prototype.showChangelogModal=function(e={}){const t=le("push","update","pop","popWithKey"),n=le("fixed","improved"),s=le("Sizes","Weights"),o=le("Child"),a=le("Tags","default"),i=ie(e=>e.defaultProps&&0==e.defaultProps.selectable),c=le("defaultRules","parse");if(!(i&&t&&n&&s&&o&&a&&c))return;const{image:l="https://repository-images.githubusercontent.com/105473537/957b5480-7c26-11e9-8401-50fa820cbae5",description:d="",changes:u=[],title:h="BandagedBD",subtitle:p=`v${r}`,footer:m}=e,g=z.React.createElement,f=[g("img",{src:l})];d&&f.push(g("p",null,c.parse(d)));for(let e=0;e<u.length;e++){const t=u[e],s=n[t.type]?n[t.type]:n.added,o=0==e?n.marginTop:"";f.push(g("h1",{className:`${s} ${o}`},t.title));const r=g("ul",null,t.items.map(e=>g("li",null,c.parse(e))));f.push(r)}const b=function(){return g(o.Child,{grow:1,shrink:1},g(a.default,{tag:a.Tags.H4},h),g(s,{size:s.Sizes.SMALL,color:s.Colors.PRIMARY,className:n.date},p))},v=()=>{const e=ie(e=>"Anchor"==e.displayName),n=le("anchorUnderlineOnHover")||{anchor:"anchor-3Z-8Bb",anchorUnderlineOnHover:"anchorUnderlineOnHover-2ESHQB"},r=e=>{e.preventDefault(),e.stopPropagation(),t.pop(),z.joinBD2()},a=e?g(e,{onClick:r},"Join our Discord Server."):g("a",{className:`${n.anchor} ${n.anchorUnderlineOnHover}`,onClick:r},"Join our Discord Server."),i=g(s,{size:s.Sizes.SMALL,color:s.Colors.PRIMARY},"Need support? ",a);return g(o.Child,{grow:1,shrink:1},m||i)};t.push((function(e){return g(i,Object.assign({className:n.container,selectable:!0,onScroll:e=>e,onClose:e=>e,renderHeader:b,renderFooter:v,children:f},e))}))},qe.prototype.patchSocial=function(){if(this.socialPatch)return;const e=ie(e=>"TabBar"==e.displayName),t=ie(e=>"Anchor"==e.displayName);e&&t&&(this.socialPatch=S.monkeyPatch(e.prototype,"render",{after:e=>{const n=e.returnValue.props.children;if(!n||!n.length||n.length<3)return;if("Separator"!==n[n.length-3].type.displayName)return;if(!n[n.length-2].type.toString().includes("socialLinks"))return;const s=n[n.length-2].type;n[n.length-2].type=function(){const e=s(...arguments);return e.props.children.push(z.React.createElement(t,{className:"bd-social-link",href:"https://github.com/rauenzi/BetterDiscordApp",title:"BandagedBD",target:"_blank"},z.React.createElement(_e,{size:"16px",className:"bd-social-logo"}))),e};const o=z.React.createElement(t,{className:"bd-social-link",href:"https://twitter.com/BandagedBD",title:"BandagedBD",target:"_blank"},"BandagedBD"),a=z.React.createElement(t,{className:"bd-social-link",href:"https://twitter.com/ZackRauen",title:"Zerebos",target:"_blank"},"Zerebos"),i=z.react.createElement("div",{className:"colorMuted-HdFt4q size12-3cLvbJ"},[o,` ${r} by `,a]),c=z.react.createElement("div",{className:"colorMuted-HdFt4q size12-3cLvbJ"},["BBD Injector",` ${r} by `,a]),l=n[n.length-1].type;n[n.length-1].type=function(){const e=l(...arguments);return e.props.children.push(c),e.props.children.push(i),e}}}))};qe.prototype.patchGuildListItems=function(){if(this.guildListItemsPatch)return;const e=function(){const e=le("wrapper","unreadMentionsBar"),t=le("guildsError","selected"),n=le("blobContainer");return Object.assign({},e,t,n)}(),t=e.listItem.split(" ")[0],n=e.blobContainer.split(" ")[0],s=z.getInternalInstance(document.querySelector(`.${t} .${n}`).parentElement).return.type;s&&(this.guildListItemsPatch=S.monkeyPatch(s.prototype,"render",{after:e=>{if(e.returnValue&&e.thisObject){const t=e.returnValue,n=e.thisObject.props;return t.props.className+=" bd-guild",n.unread&&(t.props.className+=" bd-unread"),n.selected&&(t.props.className+=" bd-selected"),n.audio&&(t.props.className+=" bd-audio"),n.video&&(t.props.className+=" bd-video"),n.badge&&(t.props.className+=" bd-badge"),n.animatable&&(t.props.className+=" bd-animatable"),t}}}))},qe.prototype.patchGuildPills=function(){if(this.guildPillPatch)return;const e=ie(e=>e.default&&!e.default.displayName&&e.default.toString&&e.default.toString().includes("translate3d"));e&&(this.guildPillPatch=S.monkeyPatch(e,"default",{after:e=>{const t=e.methodArguments[0];return t.unread&&(e.returnValue.props.className+=" bd-unread"),t.selected&&(e.returnValue.props.className+=" bd-selected"),t.hovered&&(e.returnValue.props.className+=" bd-hovered"),e.returnValue}}))},qe.prototype.patchGuildSeparator=function(){if(this.guildSeparatorPatch)return;const e=de("Guilds"),t=le("renderListItem");if(!t||!e)return;const n=function(){const e=t.Separator(...arguments);return e.props.className+=" bd-guild-separator",e};this.guildSeparatorPatch=S.monkeyPatch(e.prototype,"render",{after:e=>{e.returnValue.props.children[1].props.children[3].type=n}})};var Ge=qe;const We={get React(){return z.React},get ReactDOM(){return z.ReactDom},get ReactComponent(){return z.ReactComponent},get WindowConfigFile(){if(this._windowConfigFile)return this._windowConfigFile;const e=n(1).remote.app,t=n(2),s=e.getAppPath(),o=e.getPath("userData"),r=t.resolve(o,e.getVersion(),"modules","discord_desktop_core","injector","config.json"),a=t.resolve(s,"..","app","config.json"),i=n(0),c=i.existsSync(a)?a:i.existsSync(r)?r:null;return this._windowConfigFile=c||null},get bdSettings(){return i},get emotes(){return y},get screenWidth(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)},get screenHeight(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)},getAllWindowPreferences:function(){return this.WindowConfigFile?require(this.WindowConfigFile):{}},getWindowPreference:function(e){if(this.WindowConfigFile)return this.getAllWindowPreferences()[e]},setWindowPreference:function(e,t){if(!this.WindowConfigFile)return;const s=n(0),o=this.getAllWindowPreferences();o[e]=t,delete require.cache[this.WindowConfigFile],s.writeFileSync(this.WindowConfigFile,JSON.stringify(o,null,4))},injectCSS:function(e,t){$("head").append($("<style>",{id:S.escapeID(e),text:t}))},clearCSS:function(e){$("#"+S.escapeID(e)).remove()},linkJS:function(e,t){$("head").append($("<script>",{id:S.escapeID(e),src:t,type:"text/javascript"}))},unlinkJS:function(e){$("#"+S.escapeID(e)).remove()},getPlugin:function(e){return w.hasOwnProperty(e)?w[e].plugin:null},getCore:function(){return Ge},alert:function(e,t){const n=We.findModuleByProps("push","update","pop","popWithKey"),s=We.findModuleByPrototypes("handleCancel","handleSubmit","handleMinorConfirm");if(!n||!s)return Ge.alert(e,t);n.push((function(n){return We.React.createElement(s,Object.assign({title:e,body:t},n))}))},showConfirmationModal:function(e,t,n={}){const s=We.findModuleByProps("push","update","pop","popWithKey"),o=We.findModuleByProps("Sizes","Weights"),r=We.findModule(e=>e.defaultProps&&e.key&&"confirm-modal"==e.key());if(!s||!r||!o)return Ge.alert(e,t);const{onConfirm:a,onCancel:i,confirmText:c,cancelText:l,danger:d=!1}=n;"string"==typeof t?t=o({color:o.Colors.PRIMARY,children:[t]}):Array.isArray(t)&&(t=o({color:o.Colors.PRIMARY,children:t})),t=[t];const u=()=>{};s.push((function(n){return We.React.createElement(r,Object.assign({header:e,children:t,red:d,confirmText:c||"Okay",cancelText:l||"Cancel",onConfirm:a||u,onCancel:i||u},n))}))},showToast:function(e,t={}){S.showToast(e,t)},findModule:function(e){return z.WebpackModules.find(e)},findAllModules:function(e){return z.WebpackModules.findAll(e)},findModuleByProps:function(...e){return z.WebpackModules.findByUniqueProperties(e)},findModuleByPrototypes:function(...e){return z.WebpackModules.findByPrototypes(e)},findModuleByDisplayName:function(e){return z.WebpackModules.findByDisplayName(e)},getInternalInstance:function(e){if(e instanceof window.jQuery||e instanceof Element)return e instanceof jQuery&&(e=e[0]),z.getInternalInstance(e)},loadData:function(e,t){return V.getPluginData(e,t)}};We.getData=We.loadData,We.saveData=function(e,t,n){return V.setPluginData(e,t,n)},We.setData=We.saveData,We.deleteData=function(e,t){return V.deletePluginData(e,t)},We.monkeyPatch=function(e,t,n){return S.monkeyPatch(e,t,n)},We.onRemoved=function(e,t){return S.onRemoved(e,t)},We.suppressErrors=function(e,t){return S.suppressErrors(e,t)},We.testJSON=function(e){return S.testJSON(e)},We.isPluginEnabled=function(e){return!!E[e]},We.isThemeEnabled=function(e){return!!x[e]},We.isSettingEnabled=function(e){return!!l[e]},We.enableSetting=function(e){return Re.onChange(e,!0)},We.disableSetting=function(e){return Re.onChange(e,!1)},We.toggleSetting=function(e){return Re.onChange(e,!l[e])},We.getBDData=function(e){return V.getBDData(e)},We.setBDData=function(e,t){return V.setBDData(e,t)};class Ue{constructor(e,t,n){this.manager=n,this.cookie=e,this.list=t}isEnabled(e){return!!this.cookie[e]}enable(e){return this.manager.enable(e)}disable(e){return this.manager.disable(e)}toggle(e){this.cookie[e]?this.disable(e):this.enable(e)}get(e){return this.list.hasOwnProperty(e)?this.list[e].plugin?this.list[e].plugin:this.list[e]:null}getAll(){return Object.keys(this.list).map(e=>this.get(e)).filter(e=>e)}}We.Plugins=new Ue(E,w,P),We.Themes=new Ue(x,k,B);var Ve=We;n.d(t,"default",(function(){return Je})),function(){const e=window.require("fs"),t=window.require("process"),n=t.platform,s=("win32"===n?t.env.APPDATA:"darwin"===n?t.env.HOME+"/Library/Preferences":process.env.HOME+"/.config")+"/BetterDiscord/";let o={};if(e.existsSync(`${s}localStorage.json`))try{o=JSON.parse(e.readFileSync(`${s}localStorage.json`))}catch(e){console.log(e)}else if(e.existsSync("localStorage.json"))try{o=JSON.parse(e.readFileSync("localStorage.json"))}catch(e){console.log(e)}const r=o;r.setItem=function(e,t){r[e]=t,this.save()},r.getItem=function(e){return r[e]||null},r.save=function(){e.writeFileSync(`${s}localStorage.json`,JSON.stringify(this),null,4)};const a=new Proxy(r,{set:function(e,t,n){r[t]=n,r.save()},get:function(e,t){return r[t]||null}});window.localStorage=a}(),(()=>{const e=document.createElement("div");e.className="bd-loaderv2",e.title="BandagedBD is loading...",document.body.appendChild(e)})();const ze=(e,t)=>{Object.defineProperty(window,e,{get:()=>(S.warn("Deprecation Notice",`"${e}" may be removed in future versions. Please only use BdApi.`),t)})},He=Object.keys(s);for(const e of He)ze(e,s[e]);ze("BDV2",z),ze("pluginModule",P),ze("themeModule",B),ze("Utils",S),ze("BDEvents",T),ze("settingsPanel",Re),ze("DataStore",V),ze("emoteModule",Q),ze("ContentManager",q),ze("ClassNormalizer",Ee),window.BdApi=Ve;class Je{constructor(e){this.mainCore=new Ge(e)}init(){this.mainCore.init()}}}]).default;