BetterDiscordApp-rauenzi/js/main.min.js

1 line
99 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("path")},function(e,t){e.exports=require("electron")},function(e,t){e.exports=require("module")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("request")},function(e,t,n){"use strict";n.r(t);var s={};n.r(s),n.d(s,"Menu",function(){return be}),n.d(s,"Card",function(){return fe}),n.d(s,"Layer",function(){return ye});var o={};n.r(o),n.d(o,"VoiceMode",function(){return $e}),n.d(o,"ClassNormalizer",function(){return Ne}),n.d(o,"DeveloperMode",function(){return je}),n.d(o,"PublicServers",function(){return Fe}),n.d(o,"DarkMode",function(){return Oe}),n.d(o,"MinimalMode",function(){return Ae}),n.d(o,"TwentyFourHour",function(){return Ie}),n.d(o,"ColoredText",function(){return Re}),n.d(o,"VoiceDisconnect",function(){return Ge}),n.d(o,"EmoteMenu",function(){return He}),n.d(o,"EmoteAutocaps",function(){return ze}),n.d(o,"EmoteModule",function(){return Ue});var r={emotesLoaded:!1},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"},"Coloured Text":{id:"bda-gs-7",info:"Make text colour the same as role colour",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"},"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"}},a={"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},l={local:!1,localServer:"//localhost:8080",minified:!0,version:"0.3.0",branch:"master",repo:"rauenzi",minSupportedVersion:"0.3.0",bbdVersion:"0.2.17"},c={},d={},u={},h={},p={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},m=[],g=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"],f=["twitch","bttv","ffz"];class b{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 getInternalInstance(e){return e[Object.keys(e).find(e=>e.startsWith("__reactInternalInstance"))]||null}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),!0}catch(e){return!1}}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:i=!1,silent:a=!1,force:l=!1}=n,c=n.displayName||e.displayName||e.name||e.constructor.displayName||e.constructor.name;if(a||console.log("patch",t,"of",c),!e[t]){if(!l)return console.error(t,"does not exist for",c);e[t]=function(){}}const d=e[t],u=()=>{a||console.log("unpatch",t,"of",c),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=b.suppressErrors(r,"`instead` callback of "+e[t].displayName)(n);void 0!==s&&(n.returnValue=s)}else s&&b.suppressErrors(s,"`before` callback of "+e[t].displayName)(n),n.callOriginalMethod(),o&&b.suppressErrors(o,"`after` callback of "+e[t].displayName)(n);return i&&u(),n.returnValue},e[t].__monkeyPatched=!0,e[t].__originalMethod||(e[t].__originalMethod=d),e[t].displayName="patched "+(e[t].displayName||t),u}static onRemoved(e,t){const n=new MutationObserver(s=>{for(let o=0;o<s.length;o++){const r=s[o],i=Array.from(r.removedNodes),a=i.indexOf(e)>-1,l=i.some(t=>t.contains(e));(a||l)&&(n.disconnect(),t())}});n.observe(document.body,{subtree:!0,childList:!0})}static memoizeObject(e){const t=new Proxy(e,{get:function(e,t){if(e.hasOwnProperty(t)){if(Object.getOwnPropertyDescriptor(e,t).get){const n=e[t];delete e[t],e[t]=n}return e[t]}},set:function(e,t,n){return e.hasOwnProperty(t)?this.err("MemoizedObject","Trying to overwrite existing property"):(e[t]=n,e[t])}});return Object.defineProperty(t,"hasOwnProperty",{value:function(e){return void 0!==this[e]}}),t}static className(){const e=[],t={}.hasOwnProperty;for(let n=0;n<arguments.length;n++){const s=arguments[n];if(!s)continue;const o=typeof s;if("string"===o||"number"===o)e.push(s);else if(Array.isArray(s)&&s.length){const t=this.classNames.apply(null,s);t&&e.push(t)}else if("object"===o)for(const n in s)t.call(s,n)&&s[n]&&e.push(n)}return e.join(" ")}}const y=b.memoizeObject({get React(){return w.getByProps("createElement","cloneElement")},get ReactDOM(){return w.getByProps("render","findDOMNode")},get Flux(){return w.getByProps("connectStores")},get Events(){return w.getByPrototypes("setMaxListeners","emit")},get GuildStore(){return w.getByProps("getGuild")},get SortedGuildStore(){return w.getByProps("getSortedGuilds")},get SelectedGuildStore(){return w.getByProps("getLastSelectedGuildId")},get GuildSync(){return w.getByProps("getSyncedGuilds")},get GuildInfo(){return w.getByProps("getAcronym")},get GuildChannelsStore(){return w.getByProps("getChannels","getDefaultChannel")},get GuildMemberStore(){return w.getByProps("getMember")},get MemberCountStore(){return w.getByProps("getMemberCounts")},get GuildEmojiStore(){return w.getByProps("getEmojis")},get GuildActions(){return w.getByProps("markGuildAsRead")},get GuildPermissions(){return w.getByProps("getGuildPermissions")},get ChannelStore(){return w.getByProps("getChannels","getDMFromUserId")},get SelectedChannelStore(){return w.getByProps("getLastSelectedChannelId")},get ChannelActions(){return w.getByProps("selectChannel")},get PrivateChannelActions(){return w.getByProps("openPrivateChannel")},get ChannelSelector(){return w.getByProps("selectGuild","selectChannel")},get UserInfoStore(){return w.getByProps("getToken")},get UserSettingsStore(){return w.getByProps("guildPositions")},get AccountManager(){return w.getByProps("register","login")},get UserSettingsUpdater(){return w.getByProps("updateRemoteSettings")},get OnlineWatcher(){return w.getByProps("isOnline")},get CurrentUserIdle(){return w.getByProps("getIdleTime")},get RelationshipStore(){return w.getByProps("isBlocked","getFriendIDs")},get RelationshipManager(){return w.getByProps("addRelationship")},get MentionStore(){return w.getByProps("getMentions")},get UserStore(){return w.getByProps("getCurrentUser")},get UserStatusStore(){return w.getByProps("getStatus","getState")},get UserTypingStore(){return w.getByProps("isTyping")},get UserActivityStore(){return w.getByProps("getActivity")},get UserNameResolver(){return w.getByProps("getName")},get UserNoteStore(){return w.getByProps("getNote")},get UserNoteActions(){return w.getByProps("updateNote")},get EmojiInfo(){return w.getByProps("isEmojiDisabled")},get EmojiUtils(){return w.getByProps("getGuildEmoji")},get EmojiStore(){return w.getByProps("getByCategory","EMOJI_NAME_RE")},get InviteStore(){return w.getByProps("getInvites")},get InviteResolver(){return w.getByProps("findInvite")},get InviteActions(){return w.getByProps("acceptInvite")},get DiscordConstants(){return w.getByProps("Permissions","ActivityTypes","StatusTypes")},get DiscordPermissions(){return w.getByProps("Permissions","ActivityTypes","StatusTypes").Permissions},get PermissionUtils(){return w.getByProps("getHighestRole")},get ColorConverter(){return w.getByProps("hex2int")},get ColorShader(){return w.getByProps("darken")},get TinyColor(){return w.getByPrototypes("toRgb")},get ClassResolver(){return w.getByProps("getClass")},get ButtonData(){return w.getByProps("ButtonSizes")},get IconNames(){return w.getByProps("IconNames")},get NavigationUtils(){return w.getByProps("transitionTo","replaceWith","getHistory")},get MessageStore(){return w.getByProps("getMessages")},get MessageActions(){return w.getByProps("jumpToMessage","_sendMessage")},get MessageQueue(){return w.getByProps("enqueue")},get MessageParser(){return w.getByProps("createMessage","parse","unparse")},get hljs(){return w.getByProps("highlight","highlightBlock")},get SimpleMarkdown(){return w.getByProps("parseBlock","parseInline","defaultOutput")},get ExperimentStore(){return w.getByProps("getExperimentOverrides")},get ExperimentsManager(){return w.getByProps("isDeveloper")},get CurrentExperiment(){return w.getByProps("getExperimentId")},get ImageResolver(){return w.getByProps("getUserAvatarURL","getGuildIconURL")},get ImageUtils(){return w.getByProps("getSizedImageSrc")},get AvatarDefaults(){return w.getByProps("getUserAvatarURL","DEFAULT_AVATARS")},get WindowInfo(){return w.getByProps("isFocused","windowSize")},get TagInfo(){return w.getByProps("VALID_TAG_NAMES")},get DOMInfo(){return w.getByProps("canUseDOM")},get LocaleManager(){return w.getByProps("setLocale")},get Moment(){return w.getByProps("parseZone")},get LocationManager(){return w.getByProps("createLocation")},get Timestamps(){return w.getByProps("fromTimestamp")},get TimeFormatter(){return w.getByProps("dateFormat")},get Strings(){return w.getByProps("Messages").Messages},get StringFormats(){return w.getByProps("a","z")},get StringUtils(){return w.getByProps("toASCII")},get URLParser(){return w.getByProps("Url","parse")},get ExtraURLs(){return w.getByProps("getArticleURL")},get DNDActions(){return w.getByProps("beginDrag")},get DNDSources(){return w.getByProps("addTarget")},get DNDObjects(){return w.getByProps("DragSource")},get MediaDeviceInfo(){return w.getByProps("Codecs","SUPPORTED_BROWSERS")},get MediaInfo(){return w.getByProps("getOutputVolume")},get MediaEngineInfo(){return w.getByProps("MediaEngineFeatures")},get VoiceInfo(){return w.getByProps("EchoCancellation")},get VideoStream(){return w.getByProps("getVideoStream")},get SoundModule(){return w.getByProps("playSound")},get ElectronModule(){return w.getByProps("setBadge")},get Dispatcher(){return w.getByProps("dirtyDispatch")},get PathUtils(){return w.getByProps("hasBasename")},get NotificationModule(){return w.getByProps("showNotification")},get RouterModule(){return w.getByProps("Router")},get APIModule(){return w.getByProps("getAPIBaseURL")},get AnalyticEvents(){return w.getByProps("AnalyticEventConfigs")},get KeyGenerator(){return w.getByRegex(/"binary"/)},get Buffers(){return w.getByProps("Buffer","kMaxLength")},get DeviceStore(){return w.getByProps("getDevices")},get SoftwareInfo(){return w.getByProps("os")},get CurrentContext(){return w.getByProps("setTagsContext")}});class v{static byProperties(e,t=(e=>e)){return n=>{const s=t(n);return!!s&&e.every(e=>void 0!==s[e])}}static byPrototypeFields(e,t=(e=>e)){return n=>{const s=t(n);return!!s&&(!!s.prototype&&e.every(e=>void 0!==s.prototype[e]))}}static byCode(e,t=(e=>e)){return n=>{const s=t(n);return!!s&&-1!==s.toString([]).search(e)}}static byString(...e){return t=>{const n=t.toString([]);for(const t of e)if(!n.includes(t))return!1;return!0}}static byDisplayName(e){return t=>t&&t.displayName===e}static combine(...e){return t=>e.every(e=>e(t))}}class w{static find(e,t=!0){return this.getModule(e,t)}static findAll(e){return this.getModule(e,!1)}static findByUniqueProperties(e,t=!0){return t?this.getByProps(...e):this.getAllByProps(...e)}static findByDisplayName(e){return this.getByDisplayName(e)}static getModule(e,t=!0){const n=this.getAllModules(),s=[];for(const o in n){if(!n.hasOwnProperty(o))continue;const r=n[o],{exports:i}=r;let a=null;if(i&&(i.__esModule&&i.default&&e(i.default)&&(a=i.default),e(i)&&(a=i),a)){if(t)return a;s.push(a)}}return t||0==s.length?void 0:s}static getModules(e){return this.getModule(e,!1)}static getModuleByName(e,t){if(y.hasOwnProperty(e))return y[e];if(!t)return;const n=this.getModule(t,!0);return n?y[e]=n:void 0}static getByDisplayName(e){return this.getModule(v.byDisplayName(e),!0)}static getByRegex(e,t=!0){return this.getModule(v.byCode(e),t)}static getByPrototypes(...e){return this.getModule(v.byPrototypeFields(e),!0)}static getAllByPrototypes(...e){return this.getModule(v.byPrototypeFields(e),!1)}static getByProps(...e){return this.getModule(v.byProperties(e),!0)}static getAllByProps(...e){return this.getModule(v.byProperties(e),!1)}static getByString(...e){return this.getModule(v.byString(...e),!0)}static getAllByString(...e){return this.getModule(v.byString(...e),!1)}static get require(){if(this._require)return this._require;const e="bbd-webpackmodules",t="function"==typeof window.webpackJsonp?window.webpackJsonp([],{[e]:(e,t,n)=>t.default=n},[e]).default:window.webpackJsonp.push([[],{[e]:(e,t,n)=>e.exports=n},[[e]]]);return delete t.m[e],delete t.c[e],this._require=t}static getAllModules(){return this.require.c}}const C=n(0),S=n(1),E=DiscordNative.globals.releaseChannel;var P=new class{constructor(){this.data={settings:{stable:{},canary:{},ptb:{}}},this.pluginData={}}initialize(){C.existsSync(this.BDFile)||C.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4));const e=require(this.BDFile);if(e.hasOwnProperty("settings")&&(this.data=e),!C.existsSync(this.settingsFile))return;let t=require(this.settingsFile);C.unlinkSync(this.settingsFile),t=t.hasOwnProperty("settings")?Object.assign({stable:{},canary:{},ptb:{}},{[E]:t}):Object.assign({stable:{},canary:{},ptb:{}},t),this.setBDData("settings",t)}get BDFile(){return this._BDFile||(this._BDFile=S.resolve(l.dataPath,"bdstorage.json"))}get settingsFile(){return this._settingsFile||(this._settingsFile=S.resolve(l.dataPath,"bdsettings.json"))}getPluginFile(e){return S.resolve(l.dataPath,"plugins",e+".config.json")}getSettingGroup(e){return this.data.settings[E][e]||null}setSettingGroup(e,t){this.data.settings[E][e]=t,C.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4))}getBDData(e){return this.data[e]||""}setBDData(e,t){this.data[e]=t,C.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4))}getPluginData(e,t){return void 0!==this.pluginData[e]?this.pluginData[e][t]||void 0:C.existsSync(this.getPluginFile(e))?(this.pluginData[e]=JSON.parse(C.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,C.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],C.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4))}};const x=n(4);var k=new class extends x{constructor(){super(),this.setMaxListeners(20)}dispatch(e,...t){this.emit(e,...t)}};function D(){}D.prototype.loadPlugins=function(){this.loadPluginData();const e=L.loadPlugins(),t=Object.keys(h);for(let n=0;n<t.length;n++){let s,o;try{o=(s=h[t[n]].plugin).getName(),s.load&&"function"==typeof s.load&&s.load()}catch(s){c[o]=!1,b.err("Plugins",o+" could not be loaded.",s),e.push({name:o,file:h[t[n]].filename,message:"load() could not be fired.",error:{message:s.message,stack:s.stack}});continue}if(c[o]||(c[o]=!1),c[o])try{s.start(),Ce.show(`${s.getName()} v${s.getVersion()} has started.`)}catch(s){c[o]=!1,b.err("Plugins",o+" could not be started.",s),e.push({name:o,file:h[t[n]].filename,message:"start() could not be fired.",error:{message:s.message,stack:s.stack}})}}return this.savePluginData(),n(2).remote.getCurrentWebContents().on("did-navigate-in-page",this.channelSwitch.bind(this)),e},D.prototype.startPlugin=function(e,t=!1){try{h[e].plugin.start(),t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} has started.`)}catch(n){t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} could not be started.`,{type:"error"}),c[e]=!1,this.savePluginData(),b.err("Plugins",e+" could not be started.",n)}},D.prototype.stopPlugin=function(e,t=!1){try{h[e].plugin.stop(),t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} has stopped.`)}catch(n){t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} could not be stopped.`,{type:"error"}),b.err("Plugins",h[e].plugin.getName()+" could not be stopped.",n)}},D.prototype.enablePlugin=function(e,t=!1){c[e]||(c[e]=!0,this.savePluginData(),this.startPlugin(e,t))},D.prototype.disablePlugin=function(e,t=!1){c[e]&&(c[e]=!1,this.savePluginData(),this.stopPlugin(e,t))},D.prototype.togglePlugin=function(e){c[e]?this.disablePlugin(e):this.enablePlugin(e)},D.prototype.loadPlugin=function(e){const t=L.loadContent(e,"plugin");if(t)return Se.showContentErrors({plugins:[t]}),Ce.show(`${e} could not be loaded.`,{type:"error"}),b.err("ContentManager",`${e} could not be loaded.`,t);const n=Object.values(h).find(t=>t.filename==e).plugin;try{n.load&&"function"==typeof n.load&&n.load()}catch(e){Se.showContentErrors({plugins:[e]})}b.log("ContentManager",`${n.getName()} v${n.getVersion()} was loaded.`),Ce.show(`${n.getName()} v${n.getVersion()} was loaded.`,{type:"success"}),k.dispatch("plugin-loaded",n.getName())},D.prototype.unloadPlugin=function(e){const t=Object.values(h).find(t=>t.filename==e)||h[e];if(!t)return;const n=t.plugin.getName();c[n]&&this.disablePlugin(n,!0);const s=L.unloadContent(h[n].filename,"plugin");if(delete h[n],s)return Se.showContentErrors({plugins:[s]}),Ce.show(`${n} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),b.err("ContentManager",`${n} could not be unloaded. It may have not been loaded yet.`,s);b.log("ContentManager",`${n} was unloaded.`),Ce.show(`${n} was unloaded.`,{type:"success"}),k.dispatch("plugin-unloaded",n)},D.prototype.reloadPlugin=function(e){const t=Object.values(h).find(t=>t.filename==e)||h[e];if(!t)return this.loadPlugin(e);const n=t.plugin.getName(),s=c[n];s&&this.stopPlugin(n,!0);const o=L.reloadContent(h[n].filename,"plugin");if(o)return Se.showContentErrors({plugins:[o]}),Ce.show(`${n} could not be reloaded.`,{type:"error"}),b.err("ContentManager",`${n} could not be reloaded.`,o);h[n].plugin.load&&"function"==typeof h[n].plugin.load&&h[n].plugin.load(),s&&this.startPlugin(n,!0),b.log("ContentManager",`${n} v${h[n].plugin.getVersion()} was reloaded.`),Ce.show(`${n} v${h[n].plugin.getVersion()} was reloaded.`,{type:"success"}),k.dispatch("plugin-reloaded",n)},D.prototype.updatePluginList=function(){const e=L.loadNewContent("plugin");for(const t of e.added)this.loadPlugin(t);for(const t of e.removed)this.unloadPlugin(t)},D.prototype.loadPluginData=function(){const e=P.getSettingGroup("plugins");e&&Object.assign(c,e)},D.prototype.savePluginData=function(){P.setSettingGroup("plugins",c)},D.prototype.newMessage=function(){const e=Object.keys(h);for(let t=0;t<e.length;t++){const n=h[e[t]].plugin;if(c[n.getName()]&&"function"==typeof n.onMessage)try{n.onMessage()}catch(e){b.err("Plugins","Unable to fire onMessage for "+n.getName()+".",e)}}},D.prototype.channelSwitch=function(){const e=Object.keys(h);for(let t=0;t<e.length;t++){const n=h[e[t]].plugin;if(c[n.getName()]&&"function"==typeof n.onSwitch)try{n.onSwitch()}catch(e){b.err("Plugins","Unable to fire onSwitch for "+n.getName()+".",e)}}},D.prototype.rawObserver=function(e){const t=Object.keys(h);for(let n=0;n<t.length;n++){const s=h[t[n]].plugin;if(c[s.getName()]&&"function"==typeof s.observer)try{s.observer(e)}catch(e){b.err("Plugins","Unable to fire observer for "+s.getName()+".",e)}}};var M=new D;function B(){}B.prototype.loadThemes=function(){this.loadThemeData();const e=L.loadThemes(),t=Object.keys(u);for(let e=0;e<t.length;e++){const n=u[t[e]].name;d[n]||(d[n]=!1),d[n]&&$("head").append($("<style>",{id:b.escapeID(n),text:unescape(u[n].css)}))}for(const e in d)u[e]||delete d[e];return this.saveThemeData(),e},B.prototype.enableTheme=function(e,t=!1){d[e]=!0,this.saveThemeData(),$("head").append($("<style>",{id:b.escapeID(e),text:unescape(u[e].css)})),t||Ce.show(`${u[e].name} v${u[e].version} has been applied.`)},B.prototype.disableTheme=function(e,t=!1){d[e]=!1,this.saveThemeData(),$(`#${b.escapeID(u[e].name)}`).remove(),t||Ce.show(`${u[e].name} v${u[e].version} has been disabled.`)},B.prototype.toggleTheme=function(e){d[e]?this.disableTheme(e):this.enableTheme(e)},B.prototype.loadTheme=function(e){const t=L.loadContent(e,"theme");if(t)return Se.showContentErrors({themes:[t]}),Ce.show(`${e} could not be loaded. It may not have been loaded.`,{type:"error"}),b.err("ContentManager",`${e} could not be loaded.`,t);const n=Object.values(u).find(t=>t.filename==e);b.log("ContentManager",`${n.name} v${n.version} was loaded.`),Ce.show(`${n.name} v${n.version} was loaded.`,{type:"success"}),k.dispatch("theme-loaded",n.name)},B.prototype.unloadTheme=function(e){const t=Object.values(u).find(t=>t.filename==e)||u[e];if(!t)return;const n=t.name;d[n]&&this.disableTheme(n,!0);const s=L.unloadContent(u[n].filename,"theme");if(delete u[n],s)return Se.showContentErrors({themes:[s]}),Ce.show(`${n} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),b.err("ContentManager",`${n} could not be unloaded. It may have not been loaded yet.`,s);b.log("ContentManager",`${n} was unloaded.`),Ce.show(`${n} was unloaded.`,{type:"success"}),k.dispatch("theme-unloaded",n)},B.prototype.reloadTheme=function(e){const t=Object.values(u).find(t=>t.filename==e)||u[e];if(!t)return this.loadTheme(e);const n=t.name,s=L.reloadContent(u[n].filename,"theme");if(d[n]&&(this.disableTheme(n,!0),this.enableTheme(n,!0)),s)return Se.showContentErrors({themes:[s]}),Ce.show(`${n} could not be reloaded.`,{type:"error"}),b.err("ContentManager",`${n} could not be reloaded.`,s);b.log("ContentManager",`${n} v${u[n].version} was reloaded.`),Ce.show(`${n} v${u[n].version} was reloaded.`,{type:"success"}),k.dispatch("theme-reloaded",n)},B.prototype.updateThemeList=function(){const e=L.loadNewContent("theme");for(const t of e.added)this.loadTheme(t);for(const t of e.removed)this.unloadTheme(t)},B.prototype.loadThemeData=function(){const e=P.getSettingGroup("themes");e&&Object.assign(d,e)},B.prototype.saveThemeData=function(){P.setSettingGroup("themes",d)};var T=new B;const N=n(1),j=n(0),F=n(3).Module;F.globalPaths.push(N.resolve(n(2).remote.app.getAppPath(),"node_modules"));class O extends Error{constructor(e){super(e),this.name="MetaError"}}const A=F._extensions[".js"],I=F._extensions[".css"]?F._extensions[".css"]:()=>null;var L=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=j.realpathSync(N.resolve(l.dataPath+"plugins/")))}get themesFolder(){return this._themesFolder||(this._themesFolder=j.realpathSync(N.resolve(l.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]=j.watch(n,{persistent:!1},async(e,o)=>{if(!e||!o||!o.endsWith(s))return;await new Promise(e=>setTimeout(e,50));try{j.statSync(N.resolve(n,o))}catch(e){if("ENOENT"!==e.code)return;return delete this.timeCache[o],t?M.unloadPlugin(o):T.unloadTheme(o)}if(!j.statSync(N.resolve(n,o)).isFile())return;const r=j.statSync(N.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?M.loadPlugin(o):T.loadTheme(o)),"change"==e&&(t?M.reloadPlugin(o):T.reloadTheme(o)))})}unwatchContent(e){this.watchers[e]&&(this.watchers[e].close(),delete this.watchers[e])}extractMeta(e){const t=e.split("\n")[0],n=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//"));if(t.indexOf("META")<0)throw new O("META was not found.");if(!b.testJSON(n))throw new O("META could not be parsed.");const s=JSON.parse(n);if(!s.name)throw new O("META missing name data.");return s}getContentRequire(e){const t="plugin"===e,n=this,s=t?A:I;return function(e,o){const r=t?n.pluginsFolder:n.themesFolder,i=N.resolve(r,N.basename(o));if(!j.existsSync(i)||o!==j.realpathSync(i))return Reflect.apply(s,this,arguments);let a=j.readFileSync(o,"utf8");a=b.stripBOM(a);const l=n.extractMeta(a);l.filename=N.basename(o),t||(l.css=a.split("\n").slice(1).join("\n"),a=`module.exports = ${JSON.stringify(l)};`),t&&(a+=`\nmodule.exports = ${JSON.stringify(l)};\nmodule.exports.type = ${l.name};`),e._compile(a,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(N.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(N.resolve(s,e));if(n){if(!o.type)return;try{o.plugin=new o.type,delete h[o.plugin.getName()],h[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 u[o.name],u[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(N.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(N.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=j.readdirSync(s),r=Object.values(t?h:u),i=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)&&j.statSync(N.resolve(s,e)).isFile()),removed:i}}loadAllContent(e){const t="plugin"===e,n=t?".plugin.js":".theme.css",s=t?this.pluginsFolder:this.themesFolder,o=[],r=j.readdirSync(s);for(const t of r){if(!j.statSync(N.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 R=y.React,G=y.ReactDOM,V="bd-settings-title h2-2gWE-o title-3sZWYQ size16-14cGz5 height20-mO2eIN weightSemiBold-NJexzi defaultColor-1_ajX0 defaultMarginh2-2LTaUL marginBottom20-32qID7";class H extends R.Component{constructor(e){super(e)}render(){const e=this.props.className?`${V} ${this.props.className}`:V;return R.createElement("h2",{className:e,onClick:()=>{this.props.onClick&&this.props.onClick()}},this.props.text,this.props.button&&R.createElement("button",{className:"bd-title-button",onClick:this.props.button.onClick},this.props.button.title))}}class z extends R.Component{render(){return R.createElement("div",{className:"bd-divider divider-3573oO marginTop8-1DLZ1n marginBottom40-2vIwTv"})}}const W="flex-1xMQg5 flex-1O1GKY vertical-V37hAW flex-1O1GKY directionColumn-35P_nr justifyStart-2NDFzi alignStretch-DpGPf3 noWrap-3jynv6 switchItem-2hKKKK",q="flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY flex-1O1GKY directionRow-3v3tfG justifyStart-2NDFzi alignStart-H-X2h- noWrap-3jynv6",U="flexChild-faoVW3",_="titleDefault-a8-ZSr title-31JmR4 da-titleDefault da-title",J="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",Z="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",Y="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",K="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",X="checkboxEnabled-CtinEn checkbox-2tyjJg",Q="checkboxDisabled-1MA81A checkbox-2tyjJg",ee="description-3_Ncsb formText-3fs7AJ note-1V3kyJ modeDefault-3a2Ph1 primary-jw0I4K",te="divider-3573oO dividerDefault-3rvLe-";class ne extends R.Component{constructor(e){super(e),this.state={checked:this.props.checked}}onChange(){this.props.disabled||(this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked}))}render(){const e=this.props.disabled?this.state.checked?Z:J:this.state.checked?K:Y;return R.createElement("div",{className:W,style:{flex:"1 1 auto"}},R.createElement("div",{className:q,style:{flex:"1 1 auto"}},R.createElement("div",{className:U,style:{flex:"1 1 auto"}},R.createElement("label",{htmlFor:this.props.id,className:_},this.props.name||this.props.data.text)),R.createElement("div",{className:e,tabIndex:"0",style:{flex:"0 0 auto"}},R.createElement("input",{id:this.props.id,className:this.props.disabled?Q:X,type:"checkbox",tabIndex:"-1",checked:this.state.checked,onChange:e=>this.onChange(e)}))),R.createElement("div",{className:ee,style:{flex:"1 1 auto"}},this.props.note||this.props.data.info),R.createElement("div",{className:te}))}}const se="bd-settings-group";class oe extends R.Component{constructor(e){if(super(e),this.props.button&&this.props.collapsible){const e=this.props.button.onClick;this.props.button.onClick=t=>{t.stopPropagation(),e(...arguments)}}this.props.hasOwnProperty("shown")||(this.props.shown=!0),this.container=R.createRef(),this.state={collapsed:this.props.collapsible&&!this.props.shown},this.onChange=this.onChange.bind(this)}toggleCollapse(){const e=this.container.current,t=this.state.collapsed?300:1;e.style.setProperty("height",e.scrollHeight+"px"),this.setState({collapsed:!this.state.collapsed},()=>setTimeout(()=>e.style.setProperty("height",""),t))}onChange(e,t){this.props.onChange&&(this.props.id?this.props.onChange(this.props.id,e,t):this.props.onChange(e,t),this.forceUpdate())}render(){const{settings:e}=this.props,t=this.props.collapsible?`collapsible ${this.state.collapsed&&"collapsed"}`:"",n=`${se} ${t}`;return R.createElement("div",{className:n},R.createElement(H,{text:this.props.title||this.props.name,collapsible:this.props.collapsible,onClick:()=>this.toggleCollapse(),button:this.props.button}),R.createElement("div",{className:"bd-settings-container",ref:this.container},e.map(e=>{const t=R.createElement(ne,{disabled:e.disabled,id:e.id,key:e.id,name:e.text||e.name,note:e.info||e.note,checked:e.value||a[e.id],onChange:this.onChange});if(!(!!e.shouldHide&&e.shouldHide()))return t})),this.props.showDivider&&R.createElement(z,null))}}var re=[{type:"category",id:"modules",name:"Modules",collapsible:!0,settings:[{type:"switch",id:"publicServers",name:"Public Servers",note:"Display public servers button",value:!1},{type:"switch",id:"voiceDisconnect",name:"Voice Disconnect",note:"Disconnect from voice server when closing Discord",value:!0},{type:"switch",id:"twentyFourHour",name:"24 Hour Timestamps",note:"Hides channels when in minimal mode",value:!0,depends:"minimalMode"},{type:"switch",id:"classNormalizer",name:"Normalize Classes",note:"Adds stable classes to elements to help themes. (e.g. adds .da-channels to .channels-Ie2l6A)",value:!1},{type:"switch",id:"showToasts",name:"Show Toasts",note:"Shows a small notification for important information",value:!1}]},{type:"category",id:"appearance",name:"Appearance",collapsible:!0,settings:[{type:"switch",id:"minimalMode",name:"Minimal Mode",note:"Hide elements and reduce the size of elements.",value:!0},{type:"switch",id:"hideChannels",name:"Hide Channels",note:"Hides channels when in minimal mode",value:!0,enableWith:"minimalMode"},{type:"switch",id:"darkMode",name:"Dark Mode",note:"Make certain elements dark by default",value:!1},{type:"switch",id:"coloredText",name:"Colored Text",note:"Make text colour the same as role color",value:!1}]},{type:"category",id:"content",name:"Content Manager",collapsible:!0,settings:[{type:"switch",id:"contentErrors",name:"Show Content Errors",note:"Shows a modal with plugin/theme errors",value:!0},{type:"switch",id:"autoScroll",name:"Scroll To Settings",note:"Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)",value:!0},{type:"switch",id:"autoReload",name:"Automatic Loading",note:"Automatically loads, reloads, and unloads plugins and themes",value:!1}]},{type:"category",id:"developer",name:"Developer Settings",collapsible:!0,shown:!1,settings:[{type:"switch",id:"developerMode",name:"Developer Mode",note:"Allows activating debugger when pressing F8",value:!0},{type:"switch",id:"copySelector",name:"Copy Selector",note:'Adds a "Copy Selector" option to context menus when developer mode is active',value:!0,enableWith:"developerMode"}]},{type:"category",id:"window",name:"Window Preferences",collapsible:!0,shown:!1,settings:[{type:"switch",id:"transparency",name:"Enable Transparency",note:"Enables the main window to be see-through (requires restart)",value:!1},{type:"switch",id:"frame",name:"Window Frame",note:"Adds the native os window frame to the main window",value:!1}]}],ie={};class ae{constructor({onChange:e}){this.onChange=e}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){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},[])}get core3(){return re.map((e,t)=>(0==t&&(e.button={title:"Call to Action!",onClick:()=>{Ce.success("You did it!",{forceShow:!0})}}),e.settings.forEach(t=>t.value=ie[e.id][t.id]),R.createElement(oe,Object.assign({},e,{onChange:this.onChange}))))}get core2(){return this.coreSettings.map((e,t)=>(0==t&&(e.button={title:"Call to Action!",onClick:()=>{Ce.success("You did it!",{forceShow:!0})}}),console.log(e),e.settings.find(e=>"Hide Channels"==e.text)&&(e.settings.find(e=>"Hide Channels"==e.text).shouldHide=()=>!a["bda-gs-2"]),R.createElement(oe,Object.assign({},e,{onChange:this.onChange,collapsible:!0,collapsed:t>1}))))}get attribution(){return R.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${l.bbdVersion} by `,R.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos"))}}class le extends R.Component{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 R.createElement("div",{key:"scrollerwrap",className:e},R.createElement("div",{key:"scroller",ref:"scroller",className:t},n))}}class ce extends R.Component{constructor(e){super(e)}render(){const{sidebar:e,content:t,tools:n}=this.props.children;return R.createElement("div",{className:"standardSidebarView-3F1I7i ui-standard-sidebar-view"},R.createElement("div",{className:"sidebarRegion-VFTUkN sidebar-region"},R.createElement(le,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:e.fade||!0,dark:e.dark||!0,children:e.component})),R.createElement("div",{className:"contentRegion-3nDuYy content-region"},R.createElement("div",{className:"contentTransitionWrap-3hqOEW content-transition-wrap"},R.createElement("div",{className:"scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},R.createElement("div",{className:"scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",ref:"contentScroller"},R.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},t.component),n.component)))))}}class de extends R.Component{constructor(e){super(e)}render(){return R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},R.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},R.createElement("path",{d:"M0 0h12v12H0"}),R.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 ue extends R.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this)}render(){return R.createElement("div",{className:"tools-container toolsContainer-1edPuj"},R.createElement("div",{className:"tools tools-3-3s-N"},R.createElement("div",{className:"container-1sFeqf"},R.createElement("div",{className:"btn-close closeButton-1tv5uR",onClick:this.onClick},R.createElement(de,null)),R.createElement("div",{className:"esc-text keybind-KpFkfr"},"ESC"))))}onClick(){this.props.onClick&&this.props.onClick(),$(".closeButton-1tv5uR").first().click()}}class he extends R.Component{constructor(e){super(e),this.setInitialState(),this.onClick=this.onClick.bind(this)}setInitialState(){this.state={selected:this.props.selected||!1}}render(){return R.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 pe extends R.Component{constructor(e){super(e)}render(){return R.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class me extends R.Component{constructor(e){super(e)}render(){return R.createElement("div",{className:"ui-tab-bar-header"},this.props.text)}}class ge{static get Item(){return he}static get Header(){return me}static get Separator(){return pe}}class fe extends R.Component{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 R.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${e.pinned?" bd-server-card-pinned":""}`},R.createElement("img",{ref:"img",className:"bd-server-image",src:e.iconUrl,onError:this.handleError.bind(this)}),R.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},R.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},R.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},e.name),R.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},e.members," Members")),R.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},R.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},R.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},e.description))),R.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},R.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},e.categories.join(", ")),this.state.joined&&R.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},R.createElement("div",{className:"ui-button-contents"},"Joined")),e.error&&R.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},R.createElement("div",{className:"ui-button-contents"},"Error")),!e.error&&!this.state.joined&&R.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},R.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 be extends R.Component{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=w.getByProps("getGuilds"),this.AvatarDefaults=w.getByProps("getUserAvatarURL","DEFAULT_AVATARS"),this.InviteActions=w.getByProps("acceptInvite"),this.SortedGuildStore=w.getByProps("getSortedGuilds")}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){G.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.windowOptions;e.x=Math.round(window.screenX+window.innerWidth/2-e.width/2),e.y=Math.round(window.screenY+window.innerHeight/2-e.height/2),this.joinWindow=new(window.require("electron").remote.BrowserWindow)(e);this.joinWindow.webContents.on("did-navigate",(e,t)=>{"https://auth.discordservers.com/info"==t&&(this.joinWindow.close(),this.checkConnection())}),this.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.guildPositions,t=this.AvatarDefaults.DEFAULT_AVATARS;return R.createElement(fe,{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 R.createElement(ce,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:R.createElement(ue,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return R.createElement("div",{className:"sidebar",key:"ps"},R.createElement("div",{className:"ui-tab-bar SIDE"},R.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),R.createElement(ge.Separator,null),this.searchInput,R.createElement(ge.Separator,null),R.createElement(ge.Header,{text:"Categories"}),this.categoryButtons.map((e,t)=>R.createElement(ge.Item,{id:t,onClick:this.changeCategory,key:t,text:e,selected:this.state.selectedCategory===t})),R.createElement(ge.Separator,null),this.footer,this.connection))}get searchInput(){return R.createElement("div",{className:"ui-form-item"},R.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},R.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.guildPositions,n=this.AvatarDefaults.DEFAULT_AVATARS;return 1===e.state.connection.state?e.notConnected:[R.createElement("div",{ref:"content",key:"pc",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},R.createElement(H,{text:e.state.title}),e.bdServer,e.state.servers.map(s=>R.createElement(fe,{key:s.identifier,server:s,join:e.join,guildList:t,fallback:n[Math.floor(5*Math.random())]})),e.state.next&&R.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"}},R.createElement("div",{className:"ui-button-contents"},e.state.loading?"Loading":"Load More")),e.state.servers.length>0&&R.createElement(H,{text:e.state.title}))]}get notConnected(){return[R.createElement("div",{key:"ncc",ref:"content",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},R.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},"Not connected to discordservers.com!",R.createElement("button",{onClick:this.connect,type:"button",className:"ui-button filled brand small grow",style:{display:"inline-block",minHeight:"18px",marginLeft:"10px",lineHeight:"14px"}},R.createElement("div",{className:"ui-button-contents"},"Connect"))),this.bdServer)]}get footer(){return R.createElement("div",{className:"ui-tab-bar-header"},R.createElement("a",{href:"https://discordservers.com",target:"_blank"},"Discordservers.com"))}get connection(){const{connection:e}=this.state;return 2!==e.state?R.createElement("span",null):R.createElement("span",null,R.createElement(ge.Separator,null),R.createElement("span",{style:{color:"#b9bbbe",fontSize:"10px",marginLeft:"10px"}},"Connected as: ",`${e.user.username}#${e.user.discriminator}`),R.createElement("div",{style:{padding:"5px 10px 0 10px"}},R.createElement("button",{style:{width:"100%",minHeight:"20px"},type:"button",className:"ui-button filled brand small grow"},R.createElement("div",{className:"ui-button-contents",onClick:this.connect},"Reconnect"))))}}class ye extends R.Component{constructor(e){super(e)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,e=>{27===e.which&&G.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 R.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)}}const ve=w.getByProps("channels").channels.split(" ")[0],we=w.getByProps("membersWrap").membersWrap.split(" ")[0];class Ce{static get shouldShowToasts(){return a["fork-ps-2"]}static async success(e,t={}){return this.show(e,Object.assign(t,{type:"success"}))}static async info(e,t={}){return this.show(e,Object.assign(t,{type:"info"}))}static async warning(e,t={}){return this.show(e,Object.assign(t,{type:"warning"}))}static async error(e,t={}){return this.show(e,Object.assign(t,{type:"error"}))}static async default(e,t={}){return this.show(e,Object.assign(t,{type:""}))}static show(e,t={}){const{type:n="",icon:s=!0,timeout:o=3e3,forceShow:r=!1}=t;if(!this.shouldShowToasts&&!r)return;this.ensureContainer();const i=document.createElement("div");i.classList.add("bd-toast"),n&&i.classList.add("toast-"+n),n&&s&&i.classList.add("icon"),i.innerText=e,document.querySelector(".bd-toasts").appendChild(i),setTimeout(()=>{i.classList.add("closing"),setTimeout(()=>{i.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},o)}static ensureContainer(){if(document.querySelector(".bd-toasts"))return;const e=document.querySelector(`.${ve} + div`),t=e.querySelector(`.${we}`),n=e?e.querySelector("form"):null,s=e?e.getBoundingClientRect().left:310,o=t?t.getBoundingClientRect().left:0,r=o?o-e.getBoundingClientRect().left:e.offsetWidth,i=n?n.offsetHeight:80,a=document.createElement("div");a.classList.add("bd-toasts"),a.style.setProperty("left",s+"px"),a.style.setProperty("width",r+"px"),a.style.setProperty("bottom",i+"px"),document.querySelector("#app-mount").appendChild(a)}}class Se{static get shouldShowContentErrors(){return a["fork-ps-1"]}static get ModalStack(){return w.getByProps("push","update","pop","popWithKey")}static get AlertModal(){return w.getByPrototypes("handleCancel","handleSubmit","handleMinorConfirm")}static get TextElement(){return w.getByProps("Sizes","Weights")}static get ConfirmationModal(){return w.getModule(e=>e.defaultProps&&e.key&&"confirm-modal"==e.key())}static default(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">\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 alert(e,t){if(this.ModalStack&&this.AlertModal)return this.default(e,t);this.ModalStack.push(function(n){return R.createElement(this.AlertModal,Object.assign({title:e,body:t},n))})}static showConfirmationModal(e,t,n={}){const s=this.TextElement,o=this.ConfirmationModal,r=this.ModalStack;if(!this.ModalStack||!this.ConfirmationModal||!this.TextElement)return this.alert(e,t);const{onConfirm:i,onCancel:a,confirmText:l,cancelText:c,danger:d=!1}=n;"string"==typeof t?t=s({color:s.Colors.PRIMARY,children:[t]}):Array.isArray(t)&&(t=s({color:s.Colors.PRIMARY,children:t})),t=[t];const u=()=>{};r.push(function(n){return R.createElement(o,Object.assign({header:e,children:t,red:d,confirmText:l||"Okay",cancelText:c||"Cancel",onConfirm:i||u,onCancel:a||u},n))})}static showContentErrors({plugins:e=[],themes:t=[]}){if(!e||!t||!this.shouldShowContentErrors)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>'),s=function(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(),b.err("ContentManager",`Error details for ${n.name?n.name:n.file}.`,n.error)})}return t},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 Ee={get React(){return y.React},get ReactDOM(){return y.ReactDOM},get WindowConfigFile(){if(this._windowConfigFile)return this._windowConfigFile;const e=n(2).remote.app,t=n(1),s=e.getAppPath(),o=e.getPath("userData"),r=t.resolve(o,e.getVersion(),"modules","discord_desktop_core","injector","config.json"),i=t.resolve(s,"..","app","config.json"),a=n(0),l=a.existsSync(i)?i:a.existsSync(r)?r:null;return this._windowConfigFile=l||null},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 n.c[this.WindowConfigFile],s.writeFileSync(this.WindowConfigFile,JSON.stringify(o,null,4))},injectCSS:function(e,t){$("head").append($("<style>",{id:b.escapeID(e),text:t}))},clearCSS:function(e){$("#"+b.escapeID(e)).remove()},linkJS:function(e,t){$("head").append($("<script>",{id:b.escapeID(e),src:t,type:"text/javascript"}))},unlinkJS:function(e){$("#"+b.escapeID(e)).remove()},getPlugin:function(e){return h.hasOwnProperty(e)?h[e].plugin:null},alert:function(e,t){Se.alert(e,t)},showConfirmationModal:function(e,t,n={}){return Se.showConfirmationModal(e,t,n)},showToast:function(e,t={}){Ce.show(e,t)},findModule:function(e){return w.getModule(e)},findAllModules:function(e){return w.getModule(e,!1)},findModuleByProps:function(...e){return w.getByProps(...e)},findModuleByPrototypes:function(...e){return w.getByPrototypes(...e)},findModuleByDisplayName:function(e){return w.getByDisplayName(e)},getInternalInstance:function(e){if(e instanceof window.jQuery||e instanceof Element)return e instanceof jQuery&&(e=e[0]),b.getInternalInstance(e)},loadData:function(e,t){return P.getPluginData(e,t)}};Ee.getData=Ee.loadData,Ee.saveData=function(e,t,n){return P.setPluginData(e,t,n)},Ee.setData=Ee.saveData,Ee.deleteData=function(e,t){return P.deletePluginData(e,t)},Ee.monkeyPatch=function(e,t,n){return b.monkeyPatch(e,t,n)},Ee.onRemoved=function(e,t){return b.onRemoved(e,t)},Ee.suppressErrors=function(e,t){return b.suppressErrors(e,t)},Ee.testJSON=function(e){return b.testJSON(e)},Ee.isPluginEnabled=function(e){return!!c[e]},Ee.isThemeEnabled=function(e){return!!d[e]},Ee.isSettingEnabled=function(e){return!!a[e]},Ee.getBDData=function(e){return P.getBDData(e)},Ee.setBDData=function(e,t){return P.setBDData(e,t)};var Pe=Ee;class xe extends R.Component{render(){return R.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"},R.createElement("metadata",null),R.createElement("defs",null,R.createElement("filter",{id:"shadow1"},R.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"})),R.createElement("filter",{id:"shadow2"},R.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20","flood-color":"rgba(255,255,255,0.15)"})),R.createElement("filter",{id:"shadow3"},R.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"}))),R.createElement("g",null,R.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"}),R.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"}),R.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"})))}}var ke=new class{constructor(){this.editorDetached=!1}initialize(){Pe.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),Pe.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),Pe.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),Pe.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")()}get messageClasses(){return w.getByProps("message","containerCozy")}get guildClasses(){const e=w.getByProps("wrapper","unreadMentionsBar"),t=w.getByProps("guildsError","selected"),n=w.getByProps("blobContainer");return Object.assign({},e,t,n)}get MessageContentComponent(){return w.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get TimeFormatter(){return w.getByProps("dateFormat")}get TooltipWrapper(){return w.getByDisplayName("TooltipDeprecated")}get NativeModule(){return w.getByProps("setBadge")}get Tooltips(){return w.getModule(e=>e.hide&&e.show&&!e.search&&!e.submit&&!e.search&&!e.activateRagingDemon&&!e.dismiss)}get KeyGenerator(){return w.getModule(e=>e.toString&&/"binary"/.test(e.toString()))}patchSocial(){if(this.socialPatch)return;const e=Pe.findModule(e=>"TabBar"==e.displayName),t=Pe.findModule(e=>"Anchor"==e.displayName);e&&t&&(this.socialPatch=Pe.monkeyPatch(e.prototype,"render",{after:e=>{const n=e.returnValue.props.children;if(!n||!n.length)return;if("Separator"!==n[n.length-2].type.displayName)return;if(!n[n.length-1].type.toString().includes("socialLinks"))return;const s=n[n.length-1].type;n[n.length-1].type=function(){const e=s(...arguments);return e.props.children.push(Pe.React.createElement(t,{className:"bd-social-link",href:"https://github.com/rauenzi/BetterDiscordApp",rel:"author",title:"BandagedBD",target:"_blank"},Pe.React.createElement(xe,{size:"16px",className:"bd-social-logo"}))),e}}}))}patchGuildListItems(){if(this.guildListItemsPatch)return;const e=this.guildClasses.listItem.split(" ")[0],t=this.guildClasses.blobContainer.split(" ")[0],n=Pe.getInternalInstance(document.querySelector(`.${e} .${t}`).parentElement).return.type;n&&(this.guildListItemsPatch=Pe.monkeyPatch(n.prototype,"render",{after:e=>{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}}))}patchGuildPills(){if(this.guildPillPatch)return;const e=Pe.findModule(e=>e.default&&e.default.toString&&e.default.toString().includes("translate3d"));e&&(this.guildPillPatch=Pe.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}}))}patchGuildSeparator(){if(this.guildSeparatorPatch)return;const e=Pe.findModuleByDisplayName("Guilds"),t=Pe.findModuleByProps("renderListItem");if(!t||!e)return;const n=function(){const e=t.Separator(...arguments);return e.props.className+=" bd-guild-separator",e};this.guildSeparatorPatch=Pe.monkeyPatch(e.prototype,"render",{after:e=>{e.returnValue.props.children[1].props.children[3].type=n}})}},De=new class{constructor(){this.renderer=new ae({onChange:this.updateSettings.bind(this)})}initialize(){if(P.initialize(),!P.getSettingGroup("settings"))return this.saveSettings();const e=this.loadSettings();$('<style id="customcss">').text(atob(P.getBDData("bdcustomcss"))).appendTo(document.head);for(const t in e)void 0!==e[t]&&(a[t]=e[t]);this.saveSettings(),this.patchSections(),this.defaultSettings={};for(let e=0;e<re.length;e++){const t=re[e];if("category"!=t.type)this.defaultSettings[t.id]=t.value;else{this.defaultSettings[t.id]={};for(let e=0;e<t.settings.length;e++){const n=t.settings[e];this.defaultSettings[t.id][n.id]=n.value,n.enableWith&&Object.defineProperty(n,"disabled",{get:()=>!ie[t.id][n.enableWith]})}}}console.log(re),console.log(this.defaultSettings),Object.assign(ie,this.defaultSettings)}async patchSections(){const e=await this.getUserSettings();b.monkeyPatch(e.prototype,"generateSections",{after:e=>{e.returnValue.splice(23,0,{section:"DIVIDER"}),e.returnValue.splice(24,0,{section:"HEADER",label:"BandagedBD"}),e.returnValue.splice(25,0,{section:"BBD Settings",label:"Settings",element:()=>this.renderer.core2}),e.returnValue.splice(26,0,{section:"BBD Settings 2",label:"Settings 2",element:()=>this.renderer.core3}),e.returnValue.splice(27,0,{section:"BBD Test",label:"Test Tab",onClick:function(){Ce.success("This can just be a click listener!",{forceShow:!0})}}),e.returnValue.splice(28,0,{section:"CUSTOM",element:()=>this.renderer.attribution})}});const t=w.getByProps("standardSidebarView").standardSidebarView.split(" ")[0],n=document.querySelector(`.${t}`);b.getInternalInstance(n).return.return.return.return.return.return.stateNode.forceUpdate()}getUserSettings(){return new Promise(e=>{const t=b.monkeyPatch(w.getByProps("getUserSettingsSections").default.prototype,"render",{after:n=>{e(n.returnValue.type),n.thisObject.forceUpdate(),t()}})})}saveSettings(){P.setSettingGroup("settings",a)}loadSettings(){return P.getSettingGroup("settings")}updateSettings(e,t){if(3==arguments.length)return ie[arguments[0]][arguments[1]]=arguments[2],void console.log(ie);k.dispatch("setting-updated","Modules",e,t),a[e]=t,"fork-ps-5"==e&&(t?(L.watchContent("plugin"),L.watchContent("theme")):(L.unwatchContent("plugin"),L.unwatchContent("theme"))),"fork-wp-1"==e&&(Pe.setWindowPreference("transparent",t),t?Pe.setWindowPreference("backgroundColor",null):Pe.setWindowPreference("backgroundColor","#2f3136")),this.saveSettings()}initializeSettings(){a["fork-ps-5"]&&(L.watchContent("plugin"),L.watchContent("theme")),this.saveSettings()}};function Me(e,t,n,s){const o=(o,r,i)=>{e===o&&r===t&&(i?n():s())};return k.on("setting-updated",o),()=>{k.off("setting-updated",o)}}class Be{get name(){return"Unnamed Builtin"}get category(){return"Modules"}get id(){return"None"}async initialize(){a[this.id]&&await this.enable(),k.on("setting-updated",(e,t,n)=>{e===this.category&&t===this.id&&(n?this.enable():this.disable())})}async enable(){this.log("Enabled"),await this.enabled()}async disable(){this.log("Disabled"),await this.disabled()}async enabled(){}async disabled(){}log(...e){b.log(this.name,...e)}warn(...e){b.warn(this.name,...e)}error(...e){b.err(this.name,...e)}}var $e=new class extends Be{get name(){return"VoiceMode"}get category(){return"Modules"}get id(){return"bda-gs-4"}enabled(){$(".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")}disabled(){$(".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","")}};const Te=new RegExp("^(?!da-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$");var Ne=new class extends Be{get id(){return"fork-ps-4"}get category(){return"Modules"}get name(){return"ClassNormalizer"}enabled(){this.hasPatched||(this.patchClassModules(w.getModules(this.moduleFilter.bind(this))),this.normalizeElement(document.querySelector("#app-mount")),this.hasPatched=!0)}disabled(){this.hasPatched&&(this.unpatchClassModules(w.getModules(this.moduleFilter.bind(this))),this.revertElement(document.querySelector("#app-mount")),this.hasPatched=!1)}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(!Te.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(Te)[1];if(!o)continue;const r=o.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(!Te.test(t[n]))continue;const s=t[n].match(Te)[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)}},je=new class extends Be{get name(){return"DeveloperMode"}get category(){return"Modules"}get id(){return"bda-gs-8"}get selectorModeID(){return"fork-dm-1"}get selectorMode(){return a[this.selectorModeID]}constructor(){super(),this.enableSelectors=this.enableSelectors.bind(this),this.disableSelectors=this.disableSelectors.bind(this)}enabled(){$(window).on("keydown.bdDevmode",e=>{119!==e.which&&118!=e.which||this.log("Debugger Activated")}),this.selectorMode&&this.enableSelectors(),this.selectorCancel=Me(this.category,this.selectorModeID,this.enableSelectors,this.disableSelectors)}disabled(){$(window).off("keydown.bdDevmode"),this.selectorMode&&this.disableSelectors(),this.selectorCancel&&this.selectorCancel()}enableSelectors(){$(document).on("contextmenu.bdDevmode",e=>{this.lastSelector=this.getSelector(e.toElement);setImmediate(()=>{let t=$(".contextMenu-HLZMGh");t.length<=0&&((t=$('<div class="contextMenu-HLZMGh bd-context-menu"></div>')).addClass($(".app, .app-2rEoOp").hasClass("theme-dark")?"theme-dark":"theme-light"),t.appendTo(".app, .app-2rEoOp"),t.css("top",e.clientY),t.css("left",e.clientX),$(document).on("click.bdDevModeCtx",()=>{t.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("contextmenu.bdDevModeCtx",()=>{t.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("keyup.bdDevModeCtx",e=>{27===e.keyCode&&(t.remove(),$(document).off(".bdDevModeCtx"))}));const n=$("<div/>",{class:"itemGroup-1tL0uz"}),s=$("<div/>",{class:"item-1Yvehc",click:()=>{y.ElectronModule.copy(this.lastSelector),t.hide()}}).append($("<span/>",{text:"Copy Selector"}));n.append(s),t.append(n),t.hasClass("undefined")&&t.css("top","-="+n.outerHeight())}),e.stopPropagation()})}disableSelectors(){$(document).off("contextmenu.bdDevmode"),$(document).off("contextmenu.bdDevModeCtx")}getRules(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("*"))}getSelector(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(".")}`}},Fe=new class extends Be{get name(){return"PublicServers"}get category(){return"Modules"}get id(){return"bda-gs-1"}enabled(){const e=ke.guildClasses.wrapper.split(" ")[0];$(`.${e} .scroller-2FKFPG >:first-child`).after(this.button)}disabled(){$("#bd-pub-li").remove()}get component(){return y.React.createElement(s.Layer,{rootId:"pubslayerroot",id:"pubslayer"},y.React.createElement(s.Menu,{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?y.ReactDOM.render(this.component,e):console.log("FAILED TO LOCATE ROOT: .layers")}get button(){return $("<div/>",{class:ke.guildClasses.listItem,id:"bd-pub-li"}).append($("<div/>",{class:"wrapper-25eVIn "+ke.guildClasses.circleButtonMask,text:"public",id:"bd-pub-button",click:()=>{this.render()}}))}},Oe=new class extends Be{get name(){return"DarkMode"}get category(){return"Modules"}get id(){return"bda-gs-5"}enabled(){$("#app-mount").addClass("bda-dark").addClass("bd-dark")}disabled(){$("#app-mount").removeClass("bda-dark").removeClass("bd-dark")}},Ae=new class extends Be{get name(){return"MinimalMode"}get category(){return"Modules"}get id(){return"bda-gs-2"}get hideChannelsID(){return"bda-gs-3"}get hideChannels(){return a[this.hideChannelsID]}constructor(){super(),this.enableHideChannels=this.enableHideChannels.bind(this),this.disableHideChannels=this.disableHideChannels.bind(this)}enabled(){$("body").addClass("bd-minimal"),this.hideChannels&&this.enableHideChannels(),this.hideChannelCancel=Me(this.category,this.hideChannelsID,this.enableHideChannels,this.disableHideChannels)}disabled(){$("body").removeClass("bd-minimal"),this.hideChannels&&this.disableHideChannels(),this.hideChannelCancel&&this.hideChannelCancel()}enableHideChannels(){$("body").addClass("bd-minimal-chan")}disableHideChannels(){$("body").removeClass("bd-minimal-chan")}},Ie=new class extends Be{get name(){return"24Hour"}get category(){return"Modules"}get id(){return"bda-gs-6"}enabled(){this.inject24Hour()}disabled(){this.cancel24Hour&&(this.cancel24Hour(),delete this.cancel24Hour)}inject24Hour(){if(this.cancel24Hour)return;const e=new RegExp("([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)"),t=t=>{const n=t.returnValue.match(e);if(n&&4===n.length)return"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]}`)},n=b.monkeyPatch(y.TimeFormatter,"calendarFormat",{after:t}),s=b.monkeyPatch(y.TimeFormatter,"dateFormat",{after:t});this.cancel24Hour=()=>{n(),s()}}};const Le=w.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"));var Re=new class extends Be{get name(){return"ColoredText"}get category(){return"Modules"}get id(){return"bda-gs-7"}enabled(){this.injectColoredText()}disabled(){this.cancelColoredText&&(this.cancelColoredText(),delete this.cancelColoredText)}injectColoredText(){this.cancelColoredText||(this.cancelColoredText=b.monkeyPatch(Le.prototype,"render",{after:e=>{b.monkeyPatch(e.returnValue.props,"children",{silent:!0,after:({returnValue:t})=>{const n=t.props.children[1],s=e.thisObject.props.message.colorString;return n&&s&&(n.props.style={color:s}),t}})}}))}removeColoredText(){document.querySelectorAll(".markup-2BOw-j").forEach(e=>{e.style.setProperty("color","")})}},Ge=new class extends Be{get name(){return"VoiceDisconnect"}get category(){return"Modules"}get id(){return"bda-dc-0"}constructor(){super(),this.beforeUnload=this.beforeUnload.bind(this)}enabled(){window.addEventListener("beforeunload",this.beforeUnload)}disabled(){window.removeEventListener("beforeunload",this.beforeUnload)}beforeUnload(){y.ChannelActions.selectVoiceChannel(null,null)}};const Ve=(e,t,n={})=>{const{onContextMenu:s,onClick:o}=n,r=$(`<div class="emote-container">\n <img class="emote-icon" alt="${e}" src="${t}" title="${e}">\n </div>`)[0];return s&&r.addEventListener("contextmenu",s),r.addEventListener("click",o),r};var He=new class extends Be{get name(){return"EmoteMenu"}get category(){return"Modules"}get id(){return"bda-es-0"}get hideEmojisID(){return"bda-es-9"}get hideEmojis(){return a[this.hideEmojisID]}constructor(){super(),this.lastTab="bda-qem-emojis",this.favoriteEmotes={},this.qmeHeader=$('<div id="bda-qem">\n <button class="active" id="bda-qem-twitch">Twitch</button>\n <button id="bda-qem-favourite">Favourite</button>\n <button id="bda-qem-emojis">Emojis</buttond>\n</div>')[0];for(const e of this.qmeHeader.getElementsByTagName("button"))e.addEventListener("click",this.switchMenu.bind(this));this.teContainer=$('<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">\n\n </div>\n </div>\n </div>\n</div>')[0],this.teContainerInner=this.teContainer.querySelector(".emote-menu-inner"),this.faContainer=$('<div id="bda-qem-favourite-container">\n <div class="scroller-wrap scrollerWrap-2lJEkd fade">\n <div class="scroller scroller-2FKFPG">\n <div class="emote-menu-inner">\n\n </div>\n </div>\n </div>\n</div>')[0],this.faContainerInner=this.faContainer.querySelector(".emote-menu-inner"),this.observer=new MutationObserver(e=>{for(const t of e)this.observe(t)}),this.enableHideEmojis=this.enableHideEmojis.bind(this),this.disableHideEmojis=this.disableHideEmojis.bind(this),this.updateTwitchEmotes=this.updateTwitchEmotes.bind(this)}initialize(){super.initialize();const e=P.getBDData("bdfavemotes");""!==e&&null!==e&&(this.favoriteEmotes=JSON.parse(atob(e))),this.updateFavorites()}async enabled(){this.log("Starting to observe"),this.observer.observe(document.getElementById("app-mount"),{childList:!0,subtree:!0}),this.hideEmojiCancel=Me(this.category,this.hideEmojisID,this.enableHideEmojis,this.disableHideEmojis),this.hideEmojis&&this.enableHideEmojis(),r.emotesLoaded&&this.updateTwitchEmotes(),k.on("emotes-loaded",this.updateTwitchEmotes)}disabled(){k.off("emotes-loaded",this.updateTwitchEmotes),this.observer.disconnect(),this.disableHideEmojis(),this.hideEmojiCancel&&this.hideEmojiCancel()}async waitForEmotes(){if(!r.emotesLoaded)return new Promise(e=>{k.on("emotes-loaded",e)})}enableHideEmojis(){$(".emojiPicker-3m1S-j").addClass("bda-qme-hidden")}disableHideEmojis(){$(".emojiPicker-3m1S-j").removeClass("bda-qme-hidden")}insertEmote(e){const t=b.getTextArea();b.insertText(t[0]," "==t.val().slice(-1)?t.val()+e:t.val()+" "+e)}favContext(e){e.stopPropagation();const t=e.target.closest(".emote-container").children[0],n=$('<div id="removemenu" class="bd-context-menu context-menu theme-dark">Remove</div>');n.css({top:e.pageY-$("#bda-qem-favourite-container").offset().top,left:e.pageX-$("#bda-qem-favourite-container").offset().left}),$(t).parent().append(n),n.on("click",e=>{e.preventDefault(),e.stopPropagation(),$(t).remove(),delete this.favoriteEmotes[$(t).attr("title")],this.updateFavorites(),$(document).off("mousedown.emotemenu")}),$(document).on("mousedown.emotemenu",function(e){"removemenu"!=e.target.id&&($("#removemenu").remove(),$(document).off("mousedown.emotemenu"))})}switchMenu(e){let t="string"==typeof e?e:$(e.target).attr("id");"bda-qem-emojis"==t&&this.hideEmojis&&(t="bda-qem-favourite");const n=$("#bda-qem-twitch"),s=$("#bda-qem-favourite"),o=$("#bda-qem-emojis");switch(n.removeClass("active"),s.removeClass("active"),o.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide(),t){case"bda-qem-twitch":n.addClass("active"),$("#bda-qem-twitch-container").show();break;case"bda-qem-favourite":s.addClass("active"),$("#bda-qem-favourite-container").show();break;case"bda-qem-emojis":o.addClass("active"),$(".emojiPicker-3m1S-j").show(),$(".emojiPicker-3m1S-j input").focus()}t&&(this.lastTab=t)}observe(e){if(!(e.addedNodes.length&&e.addedNodes[0]instanceof Element))return;const t=e.addedNodes[0];if(!t.classList.contains("popout-3sVMXz")||t.classList.contains("popoutLeft-30WmrD")||!t.getElementsByClassName("emojiPicker-3m1S-j").length)return;const n=$(t);this.hideEmojis?n.addClass("bda-qme-hidden"):n.removeClass("bda-qme-hidden"),n.prepend(this.qmeHeader),n.append(this.teContainer),n.append(this.faContainer),this.switchMenu(this.lastTab)}favorite(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.updateFavorites()}updateTwitchEmotes(){for(;this.teContainerInner.firstChild;)this.teContainerInner.firstChild.remove();for(const e in p.TwitchGlobal){if(!p.TwitchGlobal.hasOwnProperty(e))continue;const t=p.TwitchGlobal[e],n=Ve(e,t,{onClick:this.insertEmote.bind(this,e)});this.teContainerInner.append(n)}}updateFavorites(){for(;this.faContainerInner.firstChild;)this.faContainerInner.firstChild.remove();for(const e in this.favoriteEmotes){const t=this.favoriteEmotes[e],n=Ve(e,t,{onClick:this.insertEmote.bind(this,e),onContextMenu:this.favContext.bind(this)});this.faContainerInner.append(n)}P.setBDData("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))}},ze=new class extends Be{get name(){return"EmoteAutocapitalize"}get category(){return"Modules"}get id(){return"bda-es-4"}enabled(){$("body").off(".bdac"),$("body").on("keyup.bdac change.bdac paste.bdac",$(".channelTextArea-1LDbYG textarea:first"),()=>{const e=$(".channelTextArea-1LDbYG 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&&b.insertText(b.getTextArea()[0],e.replace(t,n))}})}disabled(){$("body").off(".bdac")}capitalize(e){const t=p.TwitchGlobal;for(const n in t)if(t.hasOwnProperty(n)&&e==(n+"").toLowerCase())return n}};class We extends y.React.Component{constructor(e){super(e);const t=!!(He&&He.favoriteEmotes&&He.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 a["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&&He.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!He.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 y.React.createElement(ke.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},y.React.createElement("div",{className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},y.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}),y.React.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.state.isFavorite?(delete He.favoriteEmotes[this.label],He.updateFavorites()):He.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}const qe={TwitchGlobal:"bda-es-7",TwitchSubscriber:"bda-es-7",BTTV:"bda-es-2",FrankerFaceZ:"bda-es-1",BTTV2:"bda-es-2"};var Ue=new class extends Be{get name(){return"Emotes"}get category(){return"Modules"}get id(){return""}get categories(){return Object.keys(qe).filter(e=>a[qe[e]])}get MessageContentComponent(){return w.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}async initialize(){super.initialize()}disabled(){this.cancelEmoteRender||(this.cancelEmoteRender(),delete this.cancelEmoteRender)}patchMessageContent(){this.cancelEmoteRender||(this.cancelEmoteRender=b.monkeyPatch(this.MessageContentComponent.prototype,"render",{after:({returnValue:e})=>{b.monkeyPatch(e.props,"children",{silent:!0,after:({returnValue:e})=>{if(0==this.categories.length)return;const t=e.props.children[1];if(!t.props.children)return;const n=t.props.children[1];if(n&&n.length){for(let e=0;e<n.length;e++){const t=n[e];if("string"!=typeof t)continue;const s=t.split(/([^\s]+)([\s]|$)/g);for(let t=0,o=this.categories.length;t<o;t++)for(let o=0,r=s.length;o<r;o++){const r=s[o].split(":"),i=r[0];let l=r[1]?r[1]:"",c=l.slice(0);if(i.length<4||m.includes(i))continue;g.includes(l)&&a["bda-es-8"]||(l=""),f.includes(c)?l=c:c="";let d=this.categories[t];if("twitch"===c?p.TwitchGlobal[i]?d="TwitchGlobal":p.TwitchSubscriber[i]&&(d="TwitchSubscriber"):"bttv"===c?p.BTTV[i]?d="BTTV":p.BTTV2[i]&&(d="BTTV2"):"ffz"===c&&p.FrankerFaceZ[i]&&(d="FrankerFaceZ"),!p[d][i]||!a[qe[d]])continue;const u=n[e].match(new RegExp(`([\\s]|^)${b.escape(l?i+":"+l:i)}([\\s]|$)`));if(!u)continue;const h=n[e].substring(0,u.index+u[1].length),v=n[e].substring(u.index+u[0].length-u[2].length);n[e]=h;const w=y.React.createElement(We,{name:i,url:p[d][i],modifier:l});n.splice(e+1,0,v),n.splice(e+1,0,w)}}if(n.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 n)"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))}}})}}))}async loadEmoteData(e){const t=n(0),s=l.dataPath+"emote_data.json";if(t.existsSync(s)&&this.isCacheValid()){Ce.show("Loading emotes from cache.",{type:"info"}),b.log("Emotes","Loading emotes from local cache.");const n=await new Promise(e=>{t.readFile(s,"utf8",(t,n)=>{b.log("Emotes","Emotes loaded from cache."),t&&(n={}),e(n)})});let o=b.testJSON(n);o&&Object.assign(p,JSON.parse(n));for(const t in e)o=Object.keys(p[e[t].variable]).length>0;if(o)return Ce.show("Emotes successfully loaded.",{type:"success"}),r.emotesLoaded=!0,void k.dispatch("emotes-loaded");b.log("Emotes","Cache was corrupt, downloading..."),t.unlinkSync(s)}if(a["fork-es-3"]){Ce.show("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]);p[e[t].variable]=n}Ce.show("All emotes successfully downloaded.",{type:"success"});try{t.writeFileSync(s,JSON.stringify(p),"utf8")}catch(e){b.err("Emotes","Could not save emote data.",e)}r.emotesLoaded=!0,k.dispatch("emotes-loaded")}}downloadEmotes(e){const t=n(5),s={url:e.url,timeout:e.timeout?e.timeout:5e3};return b.log("Emotes",`Downloading: ${e.variable} (${e.url})`),new Promise((n,o)=>{t(s,(t,s,r)=>{if(t)return b.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({});let i={};try{i=JSON.parse(r)}catch(t){return b.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&&(i=e.parser(i));for(const t in i)t.length<4||m.includes(t)?delete i[t]:i[t]=e.getEmoteURL(i[t]);n(i),b.log("Emotes","Downloaded: "+e.variable)})})}getBlacklist(){return new Promise(e=>{$.getJSON("https://rauenzi.github.io/BetterDiscordApp/data/emotefilter.json",function(t){e(m.push(...t.blacklist))})})}isCacheValid(){const e=P.getBDData("emoteCacheDays")||P.setBDData("emoteCacheDays",7)||7,t=new Date(P.getBDData("emoteCacheDate")||null),n=new Date;return!(Math.round(Math.abs((n.getTime()-t.getTime())/864e5))>e)||(P.setBDData("emoteCacheDate",n.toJSON()),!1)}clearEmoteData(){const e=n(0),t=l.dataPath+"emote_data.json";e.existsSync(t)&&e.unlinkSync(t),P.setBDData("emoteCacheDate",(new Date).toJSON());for(const e in p)Object.assign(p,{[e]:{}})}};function _e(){}_e.prototype.setConfig=function(e){Object.assign(l,e)},_e.prototype.init=async function(){if(l.version<l.minSupportedVersion)return void Se.alert("Not Supported","BetterDiscord v"+l.version+" (your version) is not supported by the latest js ("+l.bbdVersion+").<br><br> Please download the latest version from <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>GitHub</a>");const e=l.updater?l.updater.LatestVersion:l.latestVersion;e>l.version&&Se.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 `),b.log("Startup","Initializing Settings"),De.initialize(),b.log("Startup","Initializing EmoteModule"),this.injectExternals(),await this.checkForGuilds(),ke.initialize(),b.log("Startup","Updating Settings"),De.initializeSettings();for(const e in o)o[e].initialize();b.log("Startup","Loading Plugins");const t=M.loadPlugins();b.log("Startup","Loading Themes");const n=T.loadThemes();$("#customcss").detach().appendTo(document.head),b.log("Startup","Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2")[0].remove(),b.log("Startup","Initializing Main Observer"),this.initObserver(),b.log("Startup","Collecting Startup Errors"),Se.showContentErrors({plugins:t,themes:n})},_e.prototype.checkForGuilds=function(){return new Promise(e=>{const t=function(){const n=ke.guildClasses.wrapper.split(" ")[0],s=ke.guildClasses.listItem.split(" ")[0],o=ke.guildClasses.blobContainer.split(" ")[0];if(document.querySelectorAll(`.${n} .${s} .${o}`).length>0)return e(l.deferLoaded=!0);setTimeout(t,100)};$(document).ready(function(){setTimeout(t,100)})})},_e.prototype.injectExternals=async function(){await b.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"),window.require.original&&(window.require=window.require.original)},_e.prototype.initObserver=function(){new MutationObserver(e=>{for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==M&&M.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")}}).observe(document,{childList:!0,subtree:!0})};var Je=new _e;n.d(t,"default",function(){return Ye}),n.d(t,"patchModuleLoad",function(){return Ke}),function(){const e=n(0),t=process.platform,s=("win32"===t?process.env.APPDATA:"darwin"===t?process.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 i=new Proxy(r,{set:function(e,t,n){r[t]=n,r.save()},get:function(e,t){return r[t]||null}});window.localStorage=i}();const Ze=document.createElement("div");Ze.className="bd-loaderv2",Ze.title="BandagedBD is loading...",document.body.appendChild(Ze),window.BdApi=Pe,window.settings=i,window.settingsCookie=a,window.pluginCookie=c,window.themeCookie=d,window.pluginModule=M,window.themeModule=T,window.bdthemes=u,window.bdplugins=h,window.bdEmotes=p,window.bemotes=m,window.bdPluginStorage=class{static get(e,t){return b.warn("Deprecation Notice",`${e}, please use BdApi.loadData() or BdApi.getData(). bdPluginStorage may be removed in future versions.`),P.getPluginData(e,t)||null}static set(e,t,n){if(b.warn("Deprecation Notice",`${e}, please use BdApi.saveData() or BdApi.setData(). bdPluginStorage may be removed in future versions.`),void 0===n)return b.warn("Deprecation Notice","Trying to set undefined value in plugin "+e);P.setPluginData(e,t,n)}static delete(e,t){b.warn("Deprecation Notice",`${e}, please use BdApi.deleteData(). bdPluginStorage may be removed in future versions.`),P.deletePluginData(e,t)}},window.BDEvents=k,window.bdConfig=l;class Ye{constructor(e){Je.setConfig(e)}init(){Je.init()}}function Ke(){const e=n(3),t=e._load;return e._load=function(e){if("betterdiscord"===e||e.startsWith("betterdiscord/")){if("api"==e.substr("betterdiscord/".length))return Pe}return t.apply(this,arguments)},function(){e._load=t}}}]).default;