",{id:"removemenu","data-emoteid":$(e).prop("title"),text:"Remove",class:"bd-context-menu context-menu theme-dark"});return a.css({top:t.pageY-$("#bda-qem-favourite-container").offset().top,left:t.pageX-$("#bda-qem-favourite-container").offset().left}),$(e).parent().append(a),a.on("click",function(t){return t.preventDefault(),t.stopPropagation(),$(this).remove(),delete quickEmoteMenu.favoriteEmotes[$(this).data("emoteid")],quickEmoteMenu.updateFavorites(),!1}),!1},QuickEmoteMenu.prototype.switchHandler=function(t){this.switchQem($(t).attr("id"))},QuickEmoteMenu.prototype.switchQem=function(e){var t=$("#bda-qem-twitch"),a=$("#bda-qem-favourite"),n=$("#bda-qem-emojis");t.removeClass("active"),a.removeClass("active"),n.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide();"bda-qem-twitch"===e?(t.addClass("active"),$("#bda-qem-twitch-container").show()):"bda-qem-favourite"===e?(a.addClass("active"),$("#bda-qem-favourite-container").show()):"bda-qem-emojis"===e?(n.addClass("active"),$(".emojiPicker-3m1S-j").show(),$(".emojiPicker-3m1S-j .search-bar-inner input, .emojiPicker-3m1S-j .search-bar-inner input").focus()):void 0;this.lastTab=e;var o=$(".emote-icon");o.off(),o.on("click",function(){var e=$(this).attr("title"),t=Utils.getTextArea();Utils.insertText(t[0]," "==t.val().slice(-1)?t.val()+e:t.val()+" "+e)})},QuickEmoteMenu.prototype.obsCallback=function(t){if(this.initialized){var a=$(t);settingsCookie["bda-es-9"]?a.removeClass("bda-qme-hidden"):a.addClass("bda-qme-hidden"),settingsCookie["bda-es-0"]&&(a.prepend(this.qmeHeader),a.append(this.teContainer),a.append(this.faContainer),null==this.lastTab&&(this.lastTab="bda-qem-emojis"),this.switchQem(this.lastTab))}},QuickEmoteMenu.prototype.favorite=function(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.updateFavorites()},QuickEmoteMenu.prototype.updateFavorites=function(){var e="";for(var t in e+="
",this.faContainer=e,$("#bda-qem-favourite-container").replaceWith(e),DataStore.setBDData("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))};var Utils=class{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-1LDbYG textarea")}static insertText(e,t){e.focus(),e.selectionStart=0,e.selectionEnd=e.value.length,document.execCommand("insertText",!1,t)}static injectCss(e){$("
",{type:"text/css",rel:"stylesheet",href:e}).appendTo($("head"))}static injectJs(e){return new Promise(t=>{$("",{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,a){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: red; font-weight: 700;","color: red;",""),a&&(console.groupCollapsed("%cError: "+a.message,"color: red;"),console.error(a.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||e==null||""==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(...a)=>{try{return e(...a)}catch(a){this.err("SuppressedError","Error occurred in "+t,a)}}}static monkeyPatch(e,t,a){const{before:n,after:o,instead:s,once:r=!1,silent:i=!1,force:l=!1}=a,d=a.displayName||e.displayName||e.name||e.constructor.displayName||e.constructor.name;if(i||console.log("patch",t,"of",d),!e[t])if(l)e[t]=function(){};else return console.error(t,"does not exist for",d);const c=e[t],p=()=>{i||console.log("unpatch",t,"of",d),e[t]=c};return e[t]=function(){const a={thisObject:this,methodArguments:arguments,cancelPatch:p,originalMethod:c,callOriginalMethod:()=>a.returnValue=a.originalMethod.apply(a.thisObject,a.methodArguments)};if(s){const n=Utils.suppressErrors(s,"`instead` callback of "+e[t].displayName)(a);void 0!==n&&(a.returnValue=n)}else n&&Utils.suppressErrors(n,"`before` callback of "+e[t].displayName)(a),a.callOriginalMethod(),o&&Utils.suppressErrors(o,"`after` callback of "+e[t].displayName)(a);return r&&p(),a.returnValue},e[t].__monkeyPatched=!0,e[t].__originalMethod||(e[t].__originalMethod=c),e[t].displayName="patched "+(e[t].displayName||t),p}static onRemoved(e,t){const a=new MutationObserver(n=>{for(let o=0;o
t.contains(e));(i||l)&&(a.disconnect(),t())}});a.observe(document.body,{subtree:!0,childList:!0})}};function VoiceMode(){}VoiceMode.prototype.enable=function(){$(".scroller.guild-channels ul").first().css("display","none"),$(".scroller.guild-channels header").first().css("display","none"),$(".app.flex-vertical, .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")},VoiceMode.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","")},window.bdthemes={},window.bdplugins={};var ContentManager=(()=>{const e=require("path"),t=require("fs"),a=require("module").Module;a.globalPaths.push(e.resolve(require("electron").remote.app.getAppPath(),"node_modules"));class MetaError extends Error{constructor(e){super(e),this.name="MetaError"}}const n=a._extensions[".js"],o=a._extensions[".css"]?a._extensions[".css"]:()=>null,s=/[^\S\r\n]*?\n[^\S\r\n]*?\*[^\S\r\n]?/,r=/^\\@/;return new class{constructor(){this.timeCache={},this.watchers={},a._extensions[".js"]=this.getContentRequire("plugin"),a._extensions[".css"]=this.getContentRequire("theme")}get pluginsFolder(){return this._pluginsFolder||(this._pluginsFolder=t.realpathSync(e.resolve(bdConfig.dataPath+"plugins/")))}get themesFolder(){return this._themesFolder||(this._themesFolder=t.realpathSync(e.resolve(bdConfig.dataPath+"themes/")))}watchContent(a){if(this.watchers[a])return;const n="plugin"===a,o=n?this.pluginsFolder:this.themesFolder,s=n?".plugin.js":".theme.css";this.watchers[a]=t.watch(o,{persistent:!1},async(a,r)=>{if(a&&r&&r.endsWith(s)){await new Promise(e=>setTimeout(e,50));try{t.statSync(e.resolve(o,r))}catch(e){return"ENOENT"===e.code?(delete this.timeCache[r],n?pluginModule.unloadPlugin(r):themeModule.unloadTheme(r)):void 0}if(t.statSync(e.resolve(o,r)).isFile()){const s=t.statSync(e.resolve(o,r));s&&s.mtime&&s.mtime.getTime()&&"number"==typeof s.mtime.getTime()&&this.timeCache[r]!=s.mtime.getTime()&&(this.timeCache[r]=s.mtime.getTime(),"rename"==a&&(n?pluginModule.loadPlugin(r):themeModule.loadTheme(r)),"change"==a&&(n?pluginModule.reloadPlugin(r):themeModule.reloadTheme(r)))}}})}unwatchContent(e){this.watchers[e]&&(this.watchers[e].close(),delete this.watchers[e])}extractMeta(e){const t=e.split("\n")[0],a=t.includes("//META");if(a)return this.parseOldMeta(e);const n=t.includes("/**");if(n)return this.parseNewMeta(e);throw new MetaError("META was not found.")}parseOldMeta(e){const t=e.split("\n")[0],a=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//"));if(0>t.indexOf("META"))throw new MetaError("META was not found.");const n=Utils.testJSON(a);if(!n)throw new MetaError("META could not be parsed.");if(!n.name)throw new MetaError("META missing name data.");return n}parseNewMeta(e){const t=e.split("/**",2)[1].split("*/",1)[0],a={};let n="",o="";for(const i of t.split(s))if(0!==i.length)if("@"===i.charAt(0)&&" "!==i.charAt(1)){a[n]=o;const e=i.indexOf(" ");n=i.substr(1,e-1),o=i.substr(e+1)}else o+=" "+i.replace("\\n","\n").replace(r,"@");return a[n]=o.trim(),delete a[""],a}getContentRequire(a){const s="plugin"===a,r=this,i=s?n:o;return function(a,n){const o=s?r.pluginsFolder:r.themesFolder,l=e.resolve(o,e.basename(n));if(!t.existsSync(l)||n!==t.realpathSync(l))return Reflect.apply(i,this,arguments);let d=t.readFileSync(n,"utf8");d=Utils.stripBOM(d);const c=r.extractMeta(d);if(c.filename=e.basename(n),s||(c.css=d.split("\n").slice(1).join("\n"),d=`module.exports = ${JSON.stringify(c)};`),s){a._compile(d,a.filename);const e=!Utils.isEmpty(a.exports);e?(c.type=a.exports,a.exports=c,d=""):d+=`\nmodule.exports = ${JSON.stringify(c)};\nmodule.exports.type = ${c.exports||c.name};`}a._compile(d,n)}}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(t,a){if("undefined"==typeof t||"undefined"==typeof a)return;const n="plugin"===a,o=n?this.pluginsFolder:this.themesFolder;try{require(e.resolve(o,t))}catch(e){return{name:t,file:t,message:"Could not be compiled.",error:{message:e.message,stack:e.stack}}}const s=require(e.resolve(o,t));if(s.id=Utils.escapeID(s.name),n){if(!s.type)return;try{s.plugin=new s.type,delete bdplugins[s.plugin.getName()],bdplugins[s.plugin.getName()]=s}catch(e){return{name:t,file:t,message:"Could not be constructed.",error:{message:e.message,stack:e.stack}}}}else delete bdthemes[s.name],bdthemes[s.name]=s}unloadContent(t,a){if("undefined"==typeof t||"undefined"==typeof a)return;const n="plugin"===a?this.pluginsFolder:this.themesFolder;try{delete require.cache[require.resolve(e.resolve(n,t))]}catch(e){return{name:t,file:t,message:"Could not be unloaded.",error:{message:e.message,stack:e.stack}}}}isLoaded(t,a){const n="plugin"===a?this.pluginsFolder:this.themesFolder;try{require.cache[require.resolve(e.resolve(n,t))]}catch(e){return!1}return!0}reloadContent(e,t){const a=this.unloadContent(e,t);return a?a:this.loadContent(e,t)}loadNewContent(a){const n="plugin"===a,o=n?".plugin.js":".theme.css",s=n?this.pluginsFolder:this.themesFolder,r=t.readdirSync(s),i=Object.values(n?bdplugins:bdthemes),l=i.filter(e=>!r.includes(e.filename)).map(e=>n?e.plugin.getName():e.name),d=r.filter(a=>!i.find(e=>e.filename==a)&&a.endsWith(o)&&t.statSync(e.resolve(s,a)).isFile());return{added:d,removed:l}}loadAllContent(a){const n="plugin"===a,o=n?".plugin.js":".theme.css",s=n?this.pluginsFolder:this.themesFolder,r=[],i=t.readdirSync(s);for(const n of i){if(!t.statSync(e.resolve(s,n)).isFile()||!n.endsWith(o))continue;const i=this.loadContent(n,a);i&&r.push(i)}return r}loadPlugins(){return this.loadAllContent("plugin")}loadThemes(){return this.loadAllContent("theme")}}})(),pluginCookie={};function PluginModule(){}PluginModule.prototype.loadPlugins=function(){this.loadPluginData(),bdpluginErrors=ContentManager.loadPlugins();for(var e=Object.keys(bdplugins),t=0;tt.filename==e).plugin;try{a.load&&"function"==typeof a.load&&a.load()}catch(e){settingsCookie["fork-ps-1"]&&mainCore.showContentErrors({plugins:[e]})}Utils.log("ContentManager",`${a.getName()} v${a.getVersion()} was loaded.`),settingsCookie["fork-ps-2"]&&BdApi.showToast(`${a.getName()} v${a.getVersion()} was loaded.`,{type:"success"}),BDEvents.dispatch("plugin-loaded",a.getName())},PluginModule.prototype.unloadPlugin=function(e){const t=Object.values(bdplugins).find(t=>t.filename==e)||bdplugins[e];if(t){const e=t.plugin.getName();pluginCookie[e]&&this.disablePlugin(e,!0);const a=ContentManager.unloadContent(bdplugins[e].filename,"plugin");return delete bdplugins[e],a?(settingsCookie["fork-ps-1"]&&mainCore.showContentErrors({plugins:[a]}),settingsCookie["fork-ps-2"]&&BdApi.showToast(`${e} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),Utils.err("ContentManager",`${e} could not be unloaded. It may have not been loaded yet.`,a)):void(Utils.log("ContentManager",`${e} was unloaded.`),settingsCookie["fork-ps-2"]&&BdApi.showToast(`${e} was unloaded.`,{type:"success"}),BDEvents.dispatch("plugin-unloaded",e))}},PluginModule.prototype.reloadPlugin=function(e){const t=Object.values(bdplugins).find(t=>t.filename==e)||bdplugins[e];if(!t)return this.loadPlugin(e);const a=t.plugin.getName(),n=pluginCookie[a];n&&this.stopPlugin(a,!0);const o=ContentManager.reloadContent(bdplugins[a].filename,"plugin");return o?(settingsCookie["fork-ps-1"]&&mainCore.showContentErrors({plugins:[o]}),settingsCookie["fork-ps-2"]&&BdApi.showToast(`${a} could not be reloaded.`,{type:"error"}),Utils.err("ContentManager",`${a} could not be reloaded.`,o)):void(bdplugins[a].plugin.load&&"function"==typeof bdplugins[a].plugin.load&&bdplugins[a].plugin.load(),n&&this.startPlugin(a,!0),Utils.log("ContentManager",`${a} v${bdplugins[a].plugin.getVersion()} was reloaded.`),settingsCookie["fork-ps-2"]&&BdApi.showToast(`${a} v${bdplugins[a].plugin.getVersion()} was reloaded.`,{type:"success"}),BDEvents.dispatch("plugin-reloaded",a))},PluginModule.prototype.updatePluginList=function(){const e=ContentManager.loadNewContent("plugin");for(const t of e.added)this.loadPlugin(t);for(const t of e.removed)this.unloadPlugin(t)},PluginModule.prototype.loadPluginData=function(){let e=DataStore.getSettingGroup("plugins");e&&(pluginCookie=e)},PluginModule.prototype.savePluginData=function(){DataStore.setSettingGroup("plugins",pluginCookie)},PluginModule.prototype.newMessage=function(){for(var e,t=Object.keys(bdplugins),a=0;a",{id:e.id,text:unescape(e.css)}));for(let e in themeCookie)bdthemes[e]||delete themeCookie[e];this.saveThemeData()},ThemeModule.prototype.enableTheme=function(e,t=!1){themeCookie[e]=!0,this.saveThemeData();const a=bdthemes[e];$("head").append($(""),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){DataStore.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}}class V2C_CssEditor extends BDV2.reactComponent{constructor(e){super(e);let t=this;t.props.lines=0,t.setInitialState(),t.attach=t.attach.bind(t),t.detachedEditor=BDV2.react.createElement(V2C_CssEditorDetached,{attach:t.attach}),t.onClick=t.onClick.bind(t),t.updateCss=t.updateCss.bind(t),t.saveCss=t.saveCss.bind(t),t.detach=t.detach.bind(t)}setInitialState(){this.state={detached:this.props.detached||BDV2.editorDetached}}componentDidMount(){this.editor=ace.edit("bd-customcss-editor"),this.editor.setTheme("ace/theme/monokai"),this.editor.session.setMode("ace/mode/css"),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(14),this.editor.on("change",()=>{settingsCookie["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){this.editor.destroy()}componentDidUpdate(e,t){let a=this;t.detached&&!a.state.detached&&BDV2.reactDom.unmountComponentAtNode(a.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){let e=DataStore.getBDData("bdcustomcss"),t="";return e&&""!==e&&(t=atob(e)),t}updateLineCount(){let e=this.refs.editor.value.split("\n").length;e==this.props.lines||(this.refs.lines.textContent=Array.from(Array(e),(e,t)=>t+1).join(".\n")+".",this.props.lines=e)}render(){let e=this,{detached:t}=e.state;return BDV2.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default",style:{padding:"60px 40px 0px"}},t&&BDV2.react.createElement("div",{id:"editor-detached"},BDV2.react.createElement(V2Components.SettingsTitle,{text:"Custom CSS Editor"}),BDV2.react.createElement("h3",null,"Editor Detached"),BDV2.react.createElement("button",{className:"btn btn-primary",onClick:()=>{e.attach()}},"Attach")),!t&&BDV2.react.createElement("div",null,BDV2.react.createElement(V2Components.SettingsTitle,{text:"Custom CSS Editor"}),BDV2.react.createElement("div",{className:"editor-wrapper"},BDV2.react.createElement("div",{id:"bd-customcss-editor",className:"editor",ref:"editor"},e.css)),BDV2.react.createElement("div",{id:"bd-customcss-attach-controls"},BDV2.react.createElement("ul",{className:"checkbox-group"},BDV2.react.createElement(V2Components.Checkbox,{id:"live-update",text:"Live Update",onChange:this.onChange,checked:settingsCookie["bda-css-0"]})),BDV2.react.createElement("div",{id:"bd-customcss-detach-controls-button"},BDV2.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("update")}},"Update"),BDV2.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{e.onClick("save")}},"Save"),BDV2.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("detach")}},"Detach"),BDV2.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach"),BDV2.react.createElement("div",{className:"help-text"},"Press ",BDV2.react.createElement("code",{className:"inline"},"ctrl"),"+",BDV2.react.createElement("span",{className:"inline"},",")," with the editor focused to access the editor's settings.")))))}onClick(e){let t=this;"update"===e?t.updateCss():"save"===e?t.saveCss():"detach"===e?t.detach():void 0}onChange(e,t){"live-update"===e?(settingsCookie["bda-css-0"]=t,mainCore.saveSettings()):void 0}updateCss(){0==$("#customcss").length&&$("head").append(""),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){DataStore.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}detach(){let e=this;e.setState({detached:!0});let t=e.detachedRoot;return t?void BDV2.reactDom.render(e.detachedEditor,t):void console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){let e=$("#bd-customcss-detach-container");return e.length?e[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app, .app-2rEoOp").length&&($("",{id:"bd-customcss-detach-container"}).insertAfter($(".app, .app-2rEoOp")),!0)}attach(){let e=this;e.setState({detached:!1})}}class V2C_List extends BDV2.reactComponent{constructor(e){super(e)}render(){return BDV2.react.createElement("ul",{className:this.props.className},this.props.children)}}class V2C_ContentColumn extends BDV2.reactComponent{constructor(e){super(e)}render(){return BDV2.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},BDV2.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}class V2C_PluginCard extends BDV2.reactComponent{constructor(e){super(e);let t=this;t.onChange=t.onChange.bind(t),t.showSettings=t.showSettings.bind(t),t.setInitialState(),t.hasSettings="function"==typeof t.props.plugin.getSettingsPanel,t.settingsPanel="",this.reload=this.reload.bind(this),this.onReload=this.onReload.bind(this)}setInitialState(){this.state={checked:pluginCookie[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),!settingsCookie["fork-ps-3"])return;var e=(e,t)=>{let a=e.scrollTop,n=a+e.clientHeight,o=t.offsetTop,s=o+t.clientHeight;return on};let t=$(BDV2.reactDom.findDOMNode(this)),a=t.parents(".scroller");if(!e(a[0],t[0]))return;a.animate({scrollTop:t.offset().top-a.offset().top+a.scrollTop()-30},300)}}reload(){const e=this.props.plugin.getName();pluginModule.reloadPlugin(e),this.props.plugin=bdplugins[e].plugin,this.onReload(this.props.plugin.getName())}getString(e){return"string"==typeof e?e:e.toString()}render(){let e=this,{plugin:t}=this.props,a=this.getString(t.getName()),n=this.getString(t.getAuthor()),o=this.getString(t.getDescription()),s=this.getString(t.getVersion()),r=bdplugins[a].website,i=bdplugins[a].source;if(this.state.settings){try{e.settingsPanel=t.getSettingsPanel()}catch(e){Utils.err("Plugins","Unable to get settings panel for "+t.getName()+".",e)}return BDV2.react.createElement("li",{className:"settings-open ui-switch-item"},BDV2.react.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.refs.settingspanel.innerHTML="",e.setState({settings:!1})}},BDV2.react.createElement(V2Components.XSvg,null)),"object"==typeof e.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${a}`,className:"plugin-settings",ref:"settingspanel"}),"object"!=typeof e.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${a}`,className:"plugin-settings",ref:"settingspanel",dangerouslySetInnerHTML:{__html:e.settingsPanel}}))}return BDV2.react.createElement("li",{"data-name":a,"data-version":s,className:"settings-closed ui-switch-item"},BDV2.react.createElement("div",{className:"bda-header"},BDV2.react.createElement("span",{className:"bda-header-title"},BDV2.react.createElement("span",{className:"bda-name"},a)," v",BDV2.react.createElement("span",{className:"bda-version"},s)," by ",BDV2.react.createElement("span",{className:"bda-author"},n)),BDV2.react.createElement("div",{className:"bda-controls"},!settingsCookie["fork-ps-5"]&&BDV2.react.createElement(V2Components.TooltipWrap(V2Components.ReloadIcon,{color:"black",side:"top",text:"Reload"}),{className:"bd-reload-card",onClick:this.reload}),BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),BDV2.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},BDV2.react.createElement("div",{className:"bda-description scroller"},o)),(r||i||this.hasSettings)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},r&&BDV2.react.createElement("a",{className:"bda-link bda-link-website",href:r,target:"_blank"},"Website"),r&&i&&" | ",i&&BDV2.react.createElement("a",{className:"bda-link bda-link-source",href:i,target:"_blank"},"Source")),this.hasSettings&&BDV2.react.createElement("button",{onClick:this.showSettings,className:"bda-settings-button",disabled:!this.state.checked},"Settings")))}onChange(){this.setState({checked:!this.state.checked}),pluginModule.togglePlugin(this.props.plugin.getName())}showSettings(){this.hasSettings&&this.setState({settings:!0})}}class V2C_ThemeCard extends BDV2.reactComponent{constructor(e){super(e),this.setInitialState(),this.onChange=this.onChange.bind(this),this.reload=this.reload.bind(this)}setInitialState(){this.state={checked:themeCookie[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,t=themeModule.reloadTheme(e);t?mainCore.showToast(`Could not reload ${bdthemes[e].name}. Check console for details.`,{type:"error"}):mainCore.showToast(`${bdthemes[e].name} v${bdthemes[e].version} has been reloaded.`,{type:"success"}),this.props.theme=bdthemes[e],this.onReload(this.props.theme.name)}render(){let{theme:e}=this.props,t=e.name,a=e.description,n=e.version,o=e.author,s=bdthemes[t].website,r=bdthemes[t].source;return BDV2.react.createElement("li",{"data-name":t,"data-version":n,className:"settings-closed ui-switch-item"},BDV2.react.createElement("div",{className:"bda-header"},BDV2.react.createElement("span",{className:"bda-header-title"},BDV2.react.createElement("span",{className:"bda-name"},t)," v",BDV2.react.createElement("span",{className:"bda-version"},n)," by ",BDV2.react.createElement("span",{className:"bda-author"},o)),BDV2.react.createElement("div",{className:"bda-controls"},!settingsCookie["fork-ps-5"]&&BDV2.react.createElement(V2Components.TooltipWrap(V2Components.ReloadIcon,{color:"black",side:"top",text:"Reload"}),{className:"bd-reload-card",onClick:this.reload}),BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),BDV2.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},BDV2.react.createElement("div",{className:"bda-description scroller"},a)),(s||r)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},s&&BDV2.react.createElement("a",{className:"bda-link",href:s,target:"_blank"},"Website"),s&&r&&" | ",r&&BDV2.react.createElement("a",{className:"bda-link",href:r,target:"_blank"},"Source"))))}onChange(){this.setState({checked:!this.state.checked}),themeModule.toggleTheme(this.props.theme.name)}}class V2Cs_TabBar{static get Item(){return V2C_TabBarItem}static get Header(){return V2C_TabBarHeader}static get Separator(){return V2C_TabBarSeparator}}class V2Components{static get SettingsGroup(){return V2C_SettingsGroup}static get SectionedSettingsPanel(){return V2C_SectionedSettingsPanel}static get SettingsPanel(){return V2C_SettingsPanel}static get Switch(){return V2C_Switch}static get Scroller(){return V2C_Scroller}static get TabBar(){return V2Cs_TabBar}static get SideBar(){return V2C_SideBar}static get Tools(){return V2C_Tools}static get SettingsTitle(){return V2C_SettingsTitle}static get CssEditor(){return V2C_CssEditor}static get Checkbox(){return V2C_Checkbox}static get List(){return V2C_List}static get PluginCard(){return V2C_PluginCard}static get ThemeCard(){return V2C_ThemeCard}static get ContentColumn(){return V2C_ContentColumn}static get ReloadIcon(){return V2C_ReloadIcon}static get XSvg(){return V2C_XSvg}static get Layer(){return V2C_Layer}static get SidebarView(){return V2C_SidebarView}static get ServerCard(){return V2C_ServerCard}static TooltipWrap(e,t){const{style:a="black",side:n="top",text:o=""}=t,s=BDV2.KeyGenerator();return class extends BDV2.reactComponent{constructor(e){super(e),this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this)}componentDidMount(){this.node=BDV2.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(!BDV2.Tooltips)return;const{left:e,top:t,width:r,height:i}=this.node.getBoundingClientRect();BDV2.Tooltips.show(s,{position:n,text:o,color:a,targetWidth:r,targetHeight:i,windowWidth:Utils.screenWidth,windowHeight:Utils.screenHeight,x:e,y:t});const l=new MutationObserver(e=>{e.forEach(e=>{const t=Array.from(e.removedNodes),a=-1e.contains(this.node));(a||n)&&(this.onMouseLeave(),l.disconnect())})});l.observe(document.body,{subtree:!0,childList:!0})}onMouseLeave(){BDV2.Tooltips&&BDV2.Tooltips.hide(s)}render(){return BDV2.react.createElement(e,this.props)}}}}class V2_SettingsPanel_Sidebar{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 BDV2.react.createElement("span",null,BDV2.react.createElement(V2Components.SideBar,{onClick:this.onClick,headerText:"Bandaged BD",items:this.items}),BDV2.react.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BD v${bdConfig.version} by `,BDV2.react.createElement("a",{href:"https://github.com/Jiiks/",target:"_blank"},"Jiiks")),BDV2.react.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${bbdVersion} by `,BDV2.react.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos")))}get root(){let e=$("#bd-settings-sidebar");return e.length?e[0]:this.injectRoot()?this.root:null}injectRoot(){let e=$("[class*='side-'] > [class*='item-']:not([class*=Danger])").last();return!!e.length&&($("",{id:"bd-settings-sidebar"}).insertBefore(e.prev()),!0)}render(){let e=this.root;return e?void(BDV2.reactDom.render(this.component,e),Utils.onRemoved(e,()=>{BDV2.reactDom.unmountComponentAtNode(e)})):void console.log("FAILED TO LOCATE ROOT: [class*='side-'] > [class*='item-']:not([class*=Danger])")}}class V2_SettingsPanel{constructor(){let e=this;e.sideBarOnClick=e.sideBarOnClick.bind(e),e.onChange=e.onChange.bind(e),e.updateSettings=this.updateSettings.bind(e),e.sidebar=new V2_SettingsPanel_Sidebar(e.sideBarOnClick)}get root(){let 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=$("",{class:"contentRegion-3nDuYy content-region",id:"bd-settingspane-container"});return $(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").append(e),Utils.onRemoved(e[0],()=>{BDV2.reactDom.unmountComponentAtNode(e[0])}),!0}get coreSettings(){const e=this.getSettings("core"),t=[...new Set(e.map(e=>e.category))],a=t.map(t=>({title:t,settings:e.filter(e=>e.category==t)}));return a}get emoteSettings(){return this.getSettings("emote")}getSettings(e){return Object.keys(settings).reduce((t,a)=>{let n=settings[a];return n.cat===e&&n.implemented&&!n.hidden&&(n.text=a,t.push(n)),t},[])}sideBarOnClick(e){let t=this;$(".contentRegion-3nDuYy, .content-region").first().hide(),$(t.root).show();"core"===e?t.renderCoreSettings():"emotes"===e?t.renderEmoteSettings():"customcss"===e?t.renderCustomCssEditor():"plugins"===e?t.renderPluginPane():"themes"===e?t.renderThemePane():void 0}onClick(){}onChange(e,t){this.updateSettings(e,t)}updateSettings(e,t){settingsCookie[e]=t,"bda-es-0"==e&&(t?$("#twitchcord-button-container").show():$("#twitchcord-button-container").hide()),"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?publicServersModule.addButton():publicServersModule.removeButton()),"bda-gs-4"==e&&(t?voiceMode.enable():voiceMode.disable()),"bda-gs-5"==e&&(t?$("#app-mount").addClass("bda-dark"):$("#app-mount").removeClass("bda-dark")),t&&"bda-gs-6"==e&&mainCore.inject24Hour(),"bda-gs-7"==e&&(t?mainCore.injectColoredText():mainCore.removeColoredText()),"bda-es-4"==e&&(t?emoteModule.autoCapitalize():emoteModule.disableAutoCapitalize()),"fork-ps-4"==e&&(t?ClassNormalizer.start():ClassNormalizer.stop()),"fork-ps-5"==e&&(t?(ContentManager.watchContent("plugin"),ContentManager.watchContent("theme")):(ContentManager.unwatchContent("plugin"),ContentManager.unwatchContent("theme"))),"fork-wp-1"==e&&(BdApi.setWindowPreference("transparent",t),t?BdApi.setWindowPreference("backgroundColor",null):BdApi.setWindowPreference("backgroundColor","#2f3136")),"bda-gs-8"==e&&(t?dMode.enable(settingsCookie["fork-dm-1"]):dMode.disable()),"fork-dm-1"==e&&settingsCookie["bda-gs-8"]&&dMode.enable(t),mainCore.saveSettings()}initializeSettings(){settingsCookie["bda-es-0"]&&$("#twitchcord-button-container").show(),settingsCookie["bda-gs-2"]&&$("body").addClass("bd-minimal"),settingsCookie["bda-gs-3"]&&$("body").addClass("bd-minimal-chan"),settingsCookie["bda-gs-1"]&&publicServersModule.addButton(),settingsCookie["bda-gs-4"]&&voiceMode.enable(),settingsCookie["bda-gs-5"]&&$("#app-mount").addClass("bda-dark"),settingsCookie["bda-gs-6"]&&mainCore.inject24Hour(),settingsCookie["bda-gs-7"]&&mainCore.injectColoredText(),settingsCookie["bda-es-4"]&&emoteModule.autoCapitalize(),settingsCookie["fork-ps-4"]&&ClassNormalizer.start(),settingsCookie["fork-ps-5"]&&(ContentManager.watchContent("plugin"),ContentManager.watchContent("theme")),settingsCookie["bda-gs-8"]&&dMode.enable(settingsCookie["fork-dm-1"]),mainCore.saveSettings()}renderSidebar(){let e=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{BDV2.reactDom.unmountComponentAtNode(e.root),$(e.root).hide(),$(".contentRegion-3nDuYy, .content-region").first().show()}),e.sidebar.render()}get coreComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SectionedSettingsPanel,{key:"cspanel",onChange:this.onChange,sections:this.coreSettings}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get emoteComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SettingsPanel,{key:"espanel",title:"Emote Settings",onChange:this.onChange,settings:this.emoteSettings,button:{title:"Clear Emote Cache",onClick:()=>{emoteModule.clearEmoteData(),emoteModule.init(),quickEmoteMenu.init()}}}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get customCssComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.CssEditor,{key:"csseditor"}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}contentComponent(e){const t="plugins"==e?this.pluginsComponent:this.themesComponent,a=e.replace("s",""),n=this;class ContentList extends BDV2.react.Component{constructor(e){super(e),this.onChange=this.onChange.bind(this)}componentDidMount(){BDEvents.on(`${a}-reloaded`,this.onChange),BDEvents.on(`${a}-loaded`,this.onChange),BDEvents.on(`${a}-unloaded`,this.onChange)}componentWillUnmount(){BDEvents.off(`${a}-reloaded`,this.onChange),BDEvents.off(`${a}-loaded`,this.onChange),BDEvents.off(`${a}-unloaded`,this.onChange)}onChange(){n.sideBarOnClick(e)}render(){return t}}return BDV2.react.createElement(ContentList)}get pluginsComponent(){let e=Object.keys(bdplugins).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(BDV2.react.createElement(V2Components.PluginCard,{key:t,plugin:bdplugins[t].plugin})),e),[]),t=BDV2.react.createElement(V2Components.List,{key:"plugin-list",className:"bda-slist",children:e}),a=!settingsCookie["fork-ps-5"]&&BDV2.react.createElement(V2Components.TooltipWrap(V2Components.ReloadIcon,{color:"black",side:"top",text:"Reload Plugin List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{pluginModule.updatePluginList(),this.sideBarOnClick("plugins")}}),n=BDV2.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{require("electron").shell.openItem(ContentManager.pluginsFolder)}},"Open Plugin Folder"),o=BDV2.react.createElement(V2Components.ContentColumn,{key:"pcolumn",title:"Plugins",children:[a,n,t]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[o,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get themesComponent(){let e=Object.keys(bdthemes).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(BDV2.react.createElement(V2Components.ThemeCard,{key:t,theme:bdthemes[t]})),e),[]),t=BDV2.react.createElement(V2Components.List,{key:"theme-list",className:"bda-slist",children:e}),a=!settingsCookie["fork-ps-5"]&&BDV2.react.createElement(V2Components.TooltipWrap(V2Components.ReloadIcon,{color:"black",side:"top",text:"Reload Theme List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{themeModule.updateThemeList(),this.sideBarOnClick("themes")}}),n=BDV2.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{require("electron").shell.openItem(ContentManager.themesFolder)}},"Open Theme Folder"),o=BDV2.react.createElement(V2Components.ContentColumn,{key:"tcolumn",title:"Themes",children:[a,n,t]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[o,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}renderCoreSettings(){let e=this.root;return e?void BDV2.reactDom.render(this.coreComponent,e):void console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderEmoteSettings(){let e=this.root;return e?void BDV2.reactDom.render(this.emoteComponent,e):void console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderCustomCssEditor(){let e=this.root;return e?void BDV2.reactDom.render(this.customCssComponent,e):void console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderPluginPane(){let e=this.root;return e?void BDV2.reactDom.render(this.contentComponent("plugins"),e):void console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderThemePane(){let e=this.root;return e?void BDV2.reactDom.render(this.contentComponent("themes"),e):void console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}}class V2C_Layer extends BDV2.reactComponent{constructor(e){super(e)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,t=>{27===t.which&&BDV2.reactDom.unmountComponentAtNode(this.refs.root.parentNode)}),$(`#${this.props.id}`).animate({opacity:1},{step:function(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 BDV2.react.createElement("div",{className:"layer bd-layer layer-3QrUeG",id:this.props.id,ref:"root",style:{opacity:0,transform:"scale(1.1) translateZ(0px)"}},this.props.children)}}class V2C_SidebarView extends BDV2.reactComponent{constructor(e){super(e)}render(){let{sidebar:e,content:t,tools:a}=this.props.children;return BDV2.react.createElement("div",{className:"standardSidebarView-3F1I7i ui-standard-sidebar-view"},BDV2.react.createElement("div",{className:"sidebarRegion-VFTUkN sidebar-region"},BDV2.react.createElement(V2Components.Scroller,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:e.fade||!0,dark:e.dark||!0,children:e.component})),BDV2.react.createElement("div",{className:"contentRegion-3nDuYy content-region"},BDV2.react.createElement("div",{className:"contentTransitionWrap-3hqOEW content-transition-wrap"},BDV2.react.createElement("div",{className:"scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},BDV2.react.createElement("div",{className:"scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",ref:"contentScroller"},BDV2.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},t.component),a.component)))))}}class V2_PublicServers{constructor(){this._appendButton=this._appendButton.bind(this)}get component(){return BDV2.react.createElement(V2Components.Layer,{rootId:"pubslayerroot",id:"pubslayer",children:BDV2.react.createElement(V2C_PublicServers,{rootId:"pubslayerroot"})})}get root(){let e=document.getElementById("pubslayerroot");return e?e:this.injectRoot()?this.root:null}injectRoot(){return!!$(".layers, .layers-3iHuyZ").length&&($(".layers, .layers-3iHuyZ").append($("",{id:"pubslayerroot"})),!0)}render(){let e=this.root;return e?void BDV2.reactDom.render(this.component,e):void console.log("FAILED TO LOCATE ROOT: .layers")}get button(){let e=$("",{class:BDV2.guildClasses.listItem,id:"bd-pub-li",style:settingsCookie["bda-gs-1"]?"":"display: none;"}).append($("",{class:"wrapper-25eVIn "+BDV2.guildClasses.circleButtonMask,text:"public",id:"bd-pub-button",click:()=>{this.render()}}));return e}_appendButton(){if($("#bd-pub-li").length)return;const e=BDV2.guildClasses.wrapper.split(" ")[0],t=$(`.${e} .scroller-2FKFPG >:first-child`);t.after(this.button)}addButton(){if(!this.guildPatch){const e=BdApi.findModuleByDisplayName("Guilds");this.guildPatch=BdApi.monkeyPatch(e.prototype,"render",{after:this._appendButton}),this._appendButton()}}removeButton(){this.guildPatch(),delete this.guildPatch,$("#bd-pub-li").remove()}}class V2C_ServerCard extends BDV2.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(){let{server:e}=this.props;return BDV2.react.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${e.pinned?" bd-server-card-pinned":""}`},BDV2.react.createElement("img",{ref:"img",className:"bd-server-image",src:e.iconUrl,onError:this.handleError.bind(this)}),BDV2.react.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},BDV2.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},e.name),BDV2.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},e.members," Members")),BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},BDV2.react.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},BDV2.react.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},e.description))),BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},BDV2.react.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},e.categories.join(", ")),this.state.joined&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Joined")),e.error&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Error")),!e.error&&!this.state.joined&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Join")))))}handleError(){this.props.server.iconUrl=this.props.fallback,this.setState({imageError:!0})}join(){this.props.join(this)}}class V2C_PublicServers extends BDV2.reactComponent{constructor(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=BDV2.WebpackModules.findByUniqueProperties(["getGuilds"]),this.AvatarDefaults=BDV2.WebpackModules.findByUniqueProperties(["getUserAvatarURL","DEFAULT_AVATARS"]),this.InviteActions=BDV2.WebpackModules.findByUniqueProperties(["acceptInvite"]),this.SortedGuildStore=BDV2.WebpackModules.findByUniqueProperties(["getSortedGuilds"])}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){BDV2.reactDom.unmountComponentAtNode(document.getElementById(this.props.rootId))}search(e,t){let a=this;$.ajax({method:"GET",url:`${a.endPoint}${e}${e?"&schema=new":"?schema=new"}`,success:e=>{let n=e.results.reduce((e,t)=>(t.joined=!1,e.push(t),e),[]);t||(n=a.state.servers.concat(n));let o=e.size+e.from;e.next=`?from=${o}`,a.state.term&&(e.next+=`&term=${a.state.term}`),a.state.selectedCategory&&(e.next+=`&category=${a.categoryButtons[a.state.selectedCategory]}`),o>=e.total&&(o=e.total,e.next=null);let s=`Showing 1-${o} of ${e.total} results in ${a.categoryButtons[a.state.selectedCategory]}`;a.state.term&&(s+=` for ${a.state.term}`),a.setState({loading:!1,title:s,servers:n,next:e.next}),t&&(a.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{a.setState({loading:!1,title:"Failed to load servers. Check console for details"})}})}join(e){return e.props.pinned?this.InviteActions.acceptInvite(e.props.invite_code):void $.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(){var e=Math.round;let t=this,a=t.windowOptions;a.x=e(window.screenX+window.innerWidth/2-a.width/2),a.y=e(window.screenY+window.innerHeight/2-a.height/2),t.joinWindow=new(window.require("electron").remote.BrowserWindow)(a);t.joinWindow.webContents.on("did-navigate",(e,a)=>{"https://auth.discordservers.com/info"!=a||(t.joinWindow.close(),t.checkConnection())}),t.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(){let e=this.SortedGuildStore.guildPositions,t=this.AvatarDefaults.DEFAULT_AVATARS;return BDV2.react.createElement(V2Components.ServerCard,{server:{name:"BetterDiscord",online:"7500+",members:"20000+",categories:["community","programming","support"],description:"Official BetterDiscord server for support etc",identifier:"86004744966914048",iconUrl:"https://cdn.discordapp.com/icons/86004744966914048/292e7f6bfff2b71dfd13e508a859aedd.webp",nativejoin:!0,invite_code:"0Tmfo5ZbORCRqbAd",pinned:!0},pinned:!0,join:this.join,guildList: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(){let 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 BDV2.react.createElement(V2Components.SidebarView,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:BDV2.react.createElement(V2Components.Tools,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return BDV2.react.createElement("div",{className:"sidebar",key:"ps"},BDV2.react.createElement("div",{className:"ui-tab-bar SIDE"},BDV2.react.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),BDV2.react.createElement(V2Components.TabBar.Separator,null),this.searchInput,BDV2.react.createElement(V2Components.TabBar.Separator,null),BDV2.react.createElement(V2Components.TabBar.Header,{text:"Categories"}),this.categoryButtons.map((e,t)=>BDV2.react.createElement(V2Components.TabBar.Item,{id:t,onClick:this.changeCategory,key:t,text:e,selected:this.state.selectedCategory===t})),BDV2.react.createElement(V2Components.TabBar.Separator,null),this.footer,this.connection))}get searchInput(){return BDV2.react.createElement("div",{className:"ui-form-item"},BDV2.react.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},BDV2.react.createElement("input",{ref:"searchinput",onKeyDown:this.searchKeyDown,onChange:()=>{},type:"text",className:"input default",placeholder:"Search...",maxLength:"50"})))}searchKeyDown(t){let e=this;if(e.state.loading||13!==t.which)return;e.setState({loading:!0,title:"Loading...",term:t.target.value});let a=`?term=${t.target.value}`;0!==e.state.selectedCategory&&(a+=`&category=${e.categoryButtons[e.state.selectedCategory]}`),e.search(a,!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){let t=this;if(!t.state.loading)return t.refs.searchinput.value="",t.setState({loading:!0,selectedCategory:e,title:"Loading...",term:null}),0===e?void t.search("",!0):void t.search(`?category=${t.categoryButtons[e]}`,!0)}get content(){var e=Math.floor;let t=this,a=this.SortedGuildStore.guildPositions,n=this.AvatarDefaults.DEFAULT_AVATARS;return 1===t.state.connection.state?t.notConnected:[BDV2.react.createElement("div",{ref:"content",key:"pc",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},BDV2.react.createElement(V2Components.SettingsTitle,{text:t.state.title}),t.bdServer,t.state.servers.map(o=>BDV2.react.createElement(V2Components.ServerCard,{key:o.identifier,server:o,join:t.join,guildList:a,fallback:n[e(5*Math.random())]})),t.state.next&&BDV2.react.createElement("button",{type:"button",onClick:()=>{t.state.loading||(t.setState({loading:!0}),t.search(t.state.next,!1))},className:"ui-button filled brand small grow",style:{width:"100%",marginTop:"10px",marginBottom:"10px"}},BDV2.react.createElement("div",{className:"ui-button-contents"},t.state.loading?"Loading":"Load More")),0