BetterDiscordApp-rauenzi/dist/remote.js

1 line
164 KiB
JavaScript

!function(e){var t={};function s(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,s),i.l=!0,i.exports}s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)s.d(n,i,function(t){return e[t]}.bind(null,i));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=9)}([function(e,t){e.exports=require("electron")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("request")},function(e,t){e.exports=require("module")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("rimraf")},function(e,t){e.exports=require("yauzl")},function(e,t){e.exports=require("mkdirp")},function(e,t,s){"use strict";s.r(t);var n={};s.r(n),s.d(n,"CustomCSS",(function(){return wt})),s.d(n,"WindowPrefs",(function(){return St})),s.d(n,"TwentyFourHour",(function(){return Ct})),s.d(n,"ClassNormalizer",(function(){return Mt})),s.d(n,"PublicServers",(function(){return Bt})),s.d(n,"VoiceDisconnect",(function(){return It})),s.d(n,"ColoredText",(function(){return Ft})),s.d(n,"DarkMode",(function(){return Ot})),s.d(n,"MinimalMode",(function(){return Rt})),s.d(n,"VoiceMode",(function(){return Ut})),s.d(n,"EmoteModule",(function(){return rt})),s.d(n,"EmoteMenu",(function(){return Jt})),s.d(n,"CopySelector",(function(){return Kt})),s.d(n,"Debugger",(function(){return Xt})),s.d(n,"ReactDevTools",(function(){return is}));var i={local:!1,localPath:"",localServer:"//localhost:8080",minified:!0,version:"0.3.0",branch:"master",repo:"rauenzi",minSupportedVersion:"0.3.0",bbdVersion:"1.0.0"},o=[{type:"category",id:"general",name:"General",collapsible:!0,settings:[{type:"switch",id:"download",value:!0},{type:"switch",id:"emoteMenu",value:!0},{type:"switch",id:"hideEmojiMenu",value:!1,enableWith:"emoteMenu"},{type:"switch",id:"showNames",value:!0},{type:"switch",id:"modifiers",value:!0},{type:"switch",id:"animateOnHover",value:!1}]},{type:"category",id:"categories",name:"Categories",collapsible:!0,settings:[{type:"switch",id:"twitchglobal",value:!0},{type:"switch",id:"twitchsubscriber",value:!1},{type:"switch",id:"frankerfacez",value:!0},{type:"switch",id:"bttv",value:!0}]}],r=[{type:"category",id:"general",collapsible:!0,settings:[{type:"switch",id:"emotes",value:!0},{type:"switch",id:"publicServers",value:!0},{type:"switch",id:"voiceDisconnect",value:!1},{type:"switch",id:"twentyFourHour",value:!1},{type:"switch",id:"classNormalizer",value:!0},{type:"switch",id:"showToasts",value:!0}]},{type:"category",id:"appearance",collapsible:!0,settings:[{type:"switch",id:"voiceMode",value:!1},{type:"switch",id:"minimalMode",value:!1},{type:"switch",id:"hideChannels",value:!1,enableWith:"minimalMode"},{type:"switch",id:"darkMode",value:!0},{type:"switch",id:"coloredText",value:!1}]},{type:"category",id:"addons",collapsible:!0,shown:!1,settings:[{type:"switch",id:"addonErrors",value:!0},{type:"switch",id:"autoScroll",value:!0},{type:"switch",id:"autoReload",value:!0},{type:"dropdown",id:"editAction",value:"detached",options:[{value:"detached"},{value:"system"}]}]},{type:"category",id:"customcss",collapsible:!0,shown:!1,settings:[{type:"switch",id:"customcss",value:!0},{type:"switch",id:"liveUpdate",value:!1},{type:"dropdown",id:"openAction",value:"settings",options:[{value:"settings"},{value:"detached"},{value:"system"}]}]},{type:"category",id:"developer",collapsible:!0,shown:!1,settings:[{type:"switch",id:"debuggerHotkey",value:!1},{type:"switch",id:"copySelector",value:!1},{type:"switch",id:"reactDevTools",value:!1}]},{type:"category",id:"window",collapsible:!0,shown:!1,settings:[{type:"switch",id:"transparency",value:!1},{type:"switch",id:"frame",value:!1,hidden:!0}]}],a={Panels:{plugins:"Plugins",themes:"Themes",customcss:"Custom CSS"},Collections:{settings:{name:"Settings",general:{name:"General",emotes:{name:"Emote System",note:"Enables BD's emote system"},publicServers:{name:"Public Servers",note:"Display public servers button"},voiceDisconnect:{name:"Voice Disconnect",note:"Disconnect from voice server when closing Discord"},twentyFourHour:{name:"24-Hour Timestamps",note:"Hides channels when in minimal mode"},classNormalizer:{name:"Normalize Classes",note:"Adds stable classes to elements to help themes. (e.g. adds .da-channels to .channels-Ie2l6A)"},showToasts:{name:"Show Toasts",note:"Shows a small notification for important information"}},appearance:{name:"Appearance",voiceMode:{name:"Voice Mode",note:"Hides everything that isn't voice chat"},minimalMode:{name:"Minimal Mode",note:"Hide elements and reduce the size of elements"},hideChannels:{name:"Hide Channels",note:"Hides channels when in minimal mode"},darkMode:{name:"Dark Mode",note:"Make certain elements dark by default"},coloredText:{name:"Colored Text",note:"Make text colour the same as role color"}},addons:{name:"Addon Manager",addonErrors:{name:"Show Addon Errors",note:"Shows a modal with plugin/theme errors"},autoScroll:{name:"Scroll To Settings",note:"Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)"},autoReload:{name:"Automatic Loading",note:"Automatically loads, reloads, and unloads plugins and themes"},editAction:{name:"Edit Action",note:"Where plugins & themes appear when editing",options:{detached:"Detached Window",system:"System Editor"}}},customcss:{name:"Custom CSS",customcss:{name:"Custom CSS",note:"Enables the Custom CSS tab"},liveUpdate:{name:"Live Update",note:"Updates the css as you type"},startDetached:{name:"Start Detached",note:"Clicking the Custom CSS tab opens the editor in a separate window"},nativeOpen:{name:"Open in Native Editor",note:"Clicking the Custom CSS tab opens your custom css in your native editor"},openAction:{name:"Editor Location",note:"Where Custom CSS should open by default",options:{settings:"Settings Menu",detached:"Detached Window",system:"System Editor"}}},developer:{name:"Developer Settings",debuggerHotkey:{name:"Debugger Hotkey",note:"Allows activating debugger when pressing F8"},copySelector:{name:"Copy Selector",note:'Adds a "Copy Selector" option to context menus when developer mode is active'},reactDevTools:{name:"React Developer Tools",note:"Injects your local installation of React Developer Tools into Discord"}},window:{name:"Window Preferences",transparency:{name:"Enable Transparency",note:"Enables the main window to be see-through (requires restart)"},frame:{name:"Window Frame",note:"Adds the native os window frame to the main window"}}},emotes:{name:"Emotes",general:{name:"General",download:{name:"Download Emotes",note:"Download emotes whenever they are out of date"},emoteMenu:{name:"Emote Menu",note:"Show Twitch/Favourite emotes in emote menu"},hideEmojiMenu:{name:"Hide Emoji Menu",note:"Hides Discord's emoji menu when using emote menu"},autoCaps:{name:"Emote Autocapitalization",note:"Autocapitalize emote commands"},showNames:{name:"Show Names",note:"Show emote names on hover"},modifiers:{name:"Show Emote Modifiers",note:"Enable emote mods (flip, spin, pulse, spin2, spin3, 1spin, 2spin, 3spin, tr, bl, br, shake, shake2, shake3, flap)"},animateOnHover:{name:"Animate On Hover",note:"Only animate the emote modifiers on hover"}},categories:{name:"Categories",twitchglobal:{name:"Twitch Globals",note:"Show Twitch global emotes"},twitchsubscriber:{name:"Twitch Subscribers",note:"Show Twitch subscriber emotes"},frankerfacez:{name:"FrankerFaceZ",note:"Show emotes from FFZ"},bttv:{name:"BetterTTV",note:"Show emotes from BTTV"}}}},Addons:{title:"{{name}} v{{version}} by {{author}}",openFolder:"Open {{type}} Folder",reload:"Reload",addonSettings:"Settings",website:"Website",source:"Source",invite:"Support Server",donate:"Donate",patreon:"Patreon",name:"Name",author:"Author",version:"Version",added:"Date Added",modified:"Date Modified",search:"Search {{type}}",editAddon:"Edit",deleteAddon:"Delete",confirmDelete:"Are you sure you want to delete {{name}}?",confirmationText:"You have unsaved changes to {{name}}. Closing this window will lose all those changes.",enabled:"{{name}} has been enabled.",disabled:"{{name}} has been disabled.",couldNotEnable:"{{name}} could not be enabled.",couldNotDisable:"{{name}} could not be disabled.",couldNotStart:"{{name}} could not be started.",couldNotStop:"{{name}} could not be stopped.",methodError:"{{method}} could not be fired.",unknownAuthor:"Unknown Author",noDescription:"Description not provided.",alreadyExists:"There is already a {{type}} with name {{name}}",alreadWatching:"Already watching addons.",metaError:"META could not be parsed.",missingNameData:"META missing name data.",metaNotFound:"META was not found.",compileError:"Could not be compiled.",wasUnloaded:"{{name}} was unloaded.",alreadyWatching:"Already watching {{prefix}} addons.",startingWatch:"Starting to watch {{prefix}} addons.",wasNotWatching:"Was not watching {{prefix}} addons.",noLongerWatching:"No longer watching {{prefix}} addons."},CustomCSS:{confirmationText:"You have unsaved changes to your Custom CSS. Closing this window will lose all those changes.",update:"Update",save:"Save",openNative:"Open in System Editor",openDetached:"Detach Window",settings:"Editor Settings",editorTitle:"Custom CSS Editor"},Developer:{copySelector:"Copy Selector"},Emotes:{loading:"Loading emotes in the background do not reload.",loaded:"All emotes successfully loaded.",clearEmotes:"Clear Emote Data",favoriteAction:"Favorite!"},PublicServers:{button:"public",join:"Join",joining:"Joining",joined:"Joined",loading:"Loading",loadMore:"Load More",notConnected:"Not connected to DiscordServers.com!",search:"Search",connect:"Connect",reconnect:"Reconnect",categories:"Categories",connection:"Connected as: {{username}}#{{discriminator}}",results:"Showing {{start}}-{{end}} of {{total}} results in {{category}}",query:"for {{query}}"},Modals:{confirmAction:"Are You Sure?",okay:"Okay",cancel:"Cancel",close:"Close",name:"Name",message:"Message",error:"Error",addonErrors:"Addon Errors",restartRequired:"Restart Required",restartNow:"Restart Now",restartLater:"Restart Later",additionalInfo:"Additional Info"},ReactDevTools:{notFound:"Extension Not Found",notFoundDetails:"Unable to find the React Developer Tools extension on your PC. Please install the extension on your local Chrome installation."},Sorting:{sortBy:"Sort By",order:"Order",ascending:"Ascending",descending:"Descending"},Startup:{notSupported:"Not Supported",versionMismatch:"BandagedBD Injector v{{injector}} is not supported by the latest remote (v{{remote}}).\n\nPlease download the latest version from [GitHub](https://github.com/rauenzi/BetterDiscordApp/releases/latest)",incompatibleApp:"BandagedBD does not work with {{app}}. Please uninstall one of them.",updateNow:"Update Now",maybeLater:"Maybe Later",updateAvailable:"Update Available",updateInfo:"There is an update available for BandagedBD's Injector ({{version}}).\n\nYou can either update and restart now, or later.",updateFailed:"Could Not Update",manualUpdate:"Unable to update automatically, please download the installer and reinstall normally.\n\n[Download Installer](https://github.com/rauenzi/BetterDiscordApp/releases/latest)",jqueryFailed:"jQuery Failed To Load",jqueryFailedDetails:"jQuery could not be loaded, and some plugins may not work properly. Proceed at your own risk."},WindowPrefs:{enabledInfo:"This option requires a transparent theme in order to work properly. On Windows this may break your aero snapping and maximizing.\n\nIn order to take effect, Discord needs to be restarted. Do you want to restart now?",disabledInfo:"In order to take effect, Discord needs to be restarted. Do you want to restart now?"}},l={video:"https://i.zackrauen.com/EEM6Nor0XW.mp4",poster:"https://i.imgur.com/tNGALts.jpeg",description:"The rewrite you didn't even know about is finally here.",changes:[{title:"What's New?",items:["**Everything** is entirely rewritten, for better or worse.","**Emotes and CustomCSS** can be completely turned off for those not interested. It saves on memory too but not loading those components.","**Floating editors** for both custom css and plugins/themes are now available. (See video above)","**Settings panels** are completely new and sleek. They are also highly extensible for potential future features :eyes:","**Translations** are now integrated starting with only a couple languages, but feel free to contribute your own!","**Emote menu** now uses React Patching and properly integrates into the new Emoji Picker. (Thanks Strencher#1044!)"]},{title:"Minor Stuff",type:"improved",items:["**Patcher API** was added to `BdApi` under `BdApi.Patcher`. The old `BdApi.monkeyPatch` was patched to use the Patcher as well. This allows plugins and patches to play nice with one another.","**jQuery** usage was totally eliminated and is now ___deprecated___ for plugins.","**General performance** improvements throughout the app, from startup to emotes to addons.","**Exporting** by plugins is now highly encouraged over trying to match your meta name and class name."]},{title:"Fixes",type:"fixed",items:["There are a lot of little issues that this rewrite fixes.","I forgot to write them down","But I'm sure many more will be found soon"]}]};const d={err:"error",error:"error",dbg:"debug",debug:"debug",log:"log",warn:"warn",info:"info"};class c{static stacktrace(e,t,s){console.error(`%c[${e}]%c ${t}\n\n%c`,"color: #3a71c1; font-weight: 700;","color: red; font-weight: 700;","color: red;",s)}static err(e,...t){c._log(e,t,"error")}static warn(e,...t){c._log(e,t,"warn")}static info(e,...t){c._log(e,t,"info")}static debug(e,...t){c._log(e,t,"debug")}static log(e,...t){c._log(e,t)}static _log(e,t,s="log"){s=c.parseType(s),Array.isArray(t)||(t=[t]),console[s](`%c[BandagedBD]%c [${e}]%c`,"color: #3E82E5; font-weight: 700;","color: #3a71c1;","",...t)}static parseType(e){return d[e]||"log"}}class h{static escapeID(e){return e.replace(/^[^a-z]+|[^\w-]+/gi,"-")}static addStyle(e,t){document.head.append(h.createElement(`<style id="${e}">${t}</style>`))}static removeStyle(e){const t=document.getElementById(e);t&&t.remove()}static addScript(e,t){return new Promise(s=>{const n=document.createElement("script");n.id=e,n.src=t,n.type="text/javascript",n.onload=s,document.head.append(n)})}static removeScript(e){e=this.escapeID(e);const t=document.getElementById(e);t&&t.remove()}static animate({timing:e=(e=>e),update:t,duration:s}){const n=performance.now();requestAnimationFrame((function i(o){let r=(o-n)/s;r>1&&(r=1);const a=e(r);t(a),r<1&&requestAnimationFrame(i)}))}static Q(e){const t=this.parseHTML(e);return(t instanceof NodeList?Array.from(t).some(e=>1===e.nodeType):1===t.nodeType)?t:this.query(e)}static query(e,t){return t||(t=document),t.querySelector(e)}static queryAll(e,t){return t||(t=document),t.querySelectorAll(e)}static parseHTML(e,t=!1){const s=document.createElement("template");s.innerHTML=e;const n=s.content.cloneNode(!0);return t?n:n.childNodes.length>1?n.childNodes:n.childNodes[0]}static createElement(e,t=!1){return this.parseHTML(e,t)}static escapeHTML(e){const t=document.createTextNode(""),s=document.createElement("span");return s.append(t),t.nodeValue=e,s.innerHTML}static addClass(e,...t){t=t.flat().filter(e=>e);for(let e=0;e<t.length;e++)t[e]=t[e].toString().split(" ");return t=t.flat().filter(e=>e),e.classList.add(...t),e}static removeClass(e,...t){for(let e=0;e<t.length;e++)t[e]=t[e].toString().split(" ");return t=t.flat().filter(e=>e),e.classList.remove(...t),e}static toggleClass(e,t,s){return t=t.toString().split(" ").filter(e=>e),void 0!==s?t.forEach(t=>e.classList.toggle(t,s)):t.forEach(t=>e.classList.toggle(t)),e}static hasClass(e,t){return t.toString().split(" ").filter(e=>e).every(t=>e.classList.contains(t))}static replaceClass(e,t,s){return e.classList.replace(t,s),e}static appendTo(e,t){return"string"==typeof t&&(t=this.query(t)),t?(t.append(e),e):null}static prependTo(e,t){return"string"==typeof t&&(t=this.query(t)),t?(t.prepend(e),e):null}static insertAfter(e,t){return t.parentNode.insertBefore(e,t.nextSibling),e}static after(e,t){return e.parentNode.insertBefore(t,e.nextSibling),e}static next(e,t=""){return t?e.querySelector("+ "+t):e.nextElementSibling}static nextAll(e){return e.querySelectorAll("~ *")}static nextUntil(e,t){const s=[];for(;e.nextElementSibling&&!e.nextElementSibling.matches(t);)s.push(e=e.nextElementSibling);return s}static previous(e,t=""){const s=e.previousElementSibling;return t?s&&s.matches(t)?s:null:s}static previousAll(e){const t=[];for(;e.previousElementSibling;)t.push(e=e.previousElementSibling);return t}static previousUntil(e,t){const s=[];for(;e.previousElementSibling&&!e.previousElementSibling.matches(t);)s.push(e=e.previousElementSibling);return s}static indexInParent(e){const t=e.parentNode.childNodes;let s=0;for(let n=0;n<t.length;n++){if(t[n]==e)return s;1==t[n].nodeType&&s++}return-1}static index(e){return this.indexInParent(e)}static parent(e,t=""){return!t||e.parentElement.matches(t)?e.parentElement:null}static findChild(e,t){return e.querySelector(":scope > "+t)}static findChildren(e,t){return e.querySelectorAll(":scope > "+t)}static parents(e,t=""){const s=[];if(t)for(;e.parentElement&&e.parentElement.closest(t);)s.push(e=e.parentElement.closest(t));else for(;e.parentElement;)s.push(e=e.parentElement);return s}static parentsUntil(e,t){const s=[];for(;e.parentElement&&!e.parentElement.matches(t);)s.push(e=e.parentElement);return s}static siblings(e,t="*"){return Array.from(e.parentElement.children).filter(s=>s!=e&&s.matches(t))}static css(e,t,s){return void 0===s?global.getComputedStyle(e)[t]:(e.style[t]=s,e)}static width(e,t){return void 0===t?parseInt(getComputedStyle(e).width):(e.style.width=t,e)}static height(e,t){return void 0===t?parseInt(getComputedStyle(e).height):(e.style.height=t,e)}static text(e,t){return void 0===t?e.textContent:e.textContent=t}static innerWidth(e){return e.clientWidth}static innerHeight(e){return e.clientHeight}static outerWidth(e){return e.offsetWidth}static outerHeight(e){return e.offsetHeight}static offset(e){return e.getBoundingClientRect()}static get listeners(){return this._listeners||(this._listeners={})}static on(e,t,s,n){const[i,o]=t.split("."),r=s&&n;n||(n=s);const a=r?function(e){e.target.matches(s)&&n(e)}:n;e.addEventListener(i,a);const l=()=>{e.removeEventListener(i,a)};if(o){this.listeners[o]||(this.listeners[o]=[]);const t=()=>{l(),this.listeners[o].splice(this.listeners[o].findIndex(t=>t.event==i&&t.element==e),1)};return this.listeners[o].push({event:i,element:e,cancel:t}),t}return l}static once(e,t,s,n){const[i,o]=t.split("."),r=s&&n;n||(n=s);const a=r?function(t){t.target.matches(s)&&(n(t),e.removeEventListener(i,a))}:function(t){n(t),e.removeEventListener(i,a)};e.addEventListener(i,a);const l=()=>{e.removeEventListener(i,a)};if(o){this.listeners[o]||(this.listeners[o]=[]);const t=()=>{l(),this.listeners[o].splice(this.listeners[o].findIndex(t=>t.event==i&&t.element==e),1)};return this.listeners[o].push({event:i,element:e,cancel:t}),t}return l}static __offAll(e,t){const[s,n]=e.split(".");let i=e=>e.event==s,o=e=>e;t&&(i=e=>e.event==s&&e.element==t,o=e=>e.element==t);const r=this.listeners[n]||[],a=s?r.filter(i):r.filter(o);for(let e=0;e<a.length;e++)a[e].cancel()}static off(e,t,s,n){if("string"==typeof e)return this.__offAll(e);const[i,o]=t.split(".");if(o)return this.__offAll(t,e);const r=s&&n;n||(n=s);const a=r?function(e){e.target.matches(s)&&n(e)}:n;return e.removeEventListener(i,a),e}static onMountChange(e,t,s=!0){const n=()=>{this.observer.unsubscribe(n),t()};return this.observer.subscribe(n,t=>{const n=Array.from(s?t.addedNodes:t.removedNodes),i=n.indexOf(e)>-1,o=n.some(t=>t.contains(e));return i||o}),e}static onMount(e,t){return this.onMountChange(e,t)}static onUnmount(e,t){return this.onMountChange(e,t,!1)}static onAdded(e,t){return this.onMount(e,t)}static onRemoved(e,t){return this.onUnmount(e,t,!1)}static wrap(e){const t=this.parseHTML('<div class="dom-wrapper"></div>');for(let s=0;s<e.length;s++)t.appendChild(e[s]);return t}static resolveElement(e){if(e instanceof jQuery||e instanceof Element)return e instanceof jQuery?e[0]:e}}class u{static repoUrl(e){return"https://betterdiscord.zerebos.com/"+e}static parseHTML(e,t=!1){const s=document.createElement("template");s.innerHTML=e;const n=s.content.cloneNode(!0);return t?n:n.childNodes.length>1?n.childNodes:n.childNodes[0]}static getTextArea(){return h.query(".channelTextArea-1LDbYG textarea")}static insertText(e,t){e.focus(),e.selectionStart=0,e.selectionEnd=e.value.length,document.execCommand("insertText",!1,t)}static escape(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}static testJSON(e){try{return JSON.parse(e)}catch(e){return!1}}static suppressErrors(e,t){return(...s)=>{try{return e(...s)}catch(e){c.stacktrace("SuppressedError","Error occurred in "+t,e)}}}static onRemoved(e,t){const s=new MutationObserver(n=>{for(let i=0;i<n.length;i++){const o=n[i],r=Array.from(o.removedNodes),a=r.indexOf(e)>-1,l=r.some(t=>t.contains(e));(a||l)&&(s.disconnect(),t())}});s.observe(document.body,{subtree:!0,childList:!0})}static isEmpty(e){if(null==e||null==e||""==e)return!0;if("object"!=typeof e)return!1;if(Array.isArray(e))return 0==e.length;for(const t in e)if(e.hasOwnProperty(t))return!1;return!0}static memoizeObject(e){const t=new Proxy(e,{get:function(e,t){if(e.hasOwnProperty(t)){if(Object.getOwnPropertyDescriptor(e,t).get){const s=e[t];delete e[t],e[t]=s}return e[t]}},set:function(e,t,s){return e.hasOwnProperty(t)?c.error("MemoizedObject","Trying to overwrite existing property"):(e[t]=s,e[t])}});return Object.defineProperty(t,"hasOwnProperty",{value:function(e){return void 0!==this[e]}}),t}static extend(e,...t){for(let s=0;s<t.length;s++)for(const n in t[s])t[s].hasOwnProperty(n)&&("object"==typeof e[n]&&"object"==typeof t[s][n]?this.extend(e[n],t[s][n]):"object"==typeof t[s][n]?(e[n]={},this.extend(e[n],t[s][n])):e[n]=t[s][n]);return e}static formatString(e,t){for(const s in t){let n=t[s];Array.isArray(n)&&(n=JSON.stringify(n)),"object"==typeof n&&null!==n&&(n=n.toString()),e=e.replace(new RegExp(`{{${s}}}`,"g"),n)}return e}static findInTree(e,t,{walkable:s=null,ignore:n=[]}={}){if("string"==typeof t){if(e.hasOwnProperty(t))return e[t]}else if(t(e))return e;if("object"!=typeof e||null==e)return;let i;if(e instanceof Array){for(const o of e)if(i=this.findInTree(o,t,{walkable:s,ignore:n}),void 0!==i)return i}else{const o=null==s?Object.keys(e):s;for(const r of o)if(void 0!==e[r]&&!n.includes(r)&&(i=this.findInTree(e[r],t,{walkable:s,ignore:n}),void 0!==i))return i}return i}static getNestedProp(e,t){return t.split(/\s?\.\s?/).reduce((function(e,t){return e&&e[t]}),e)}static findInRenderTree(e,t,{walkable:s=["props","children","child","sibling"],ignore:n=[]}={}){return this.findInTree(e,t,{walkable:s,ignore:n})}static findInReactTree(e,t){return this.findInTree(e,t,{walkable:["props","children","return","stateNode"]})}static getReactInstance(e){return e.__reactInternalInstance$?e.__reactInternalInstance$:e[Object.keys(e).find(e=>e.startsWith("__reactInternalInstance"))]||null}static getOwnerInstance(e,{include:t,exclude:s=["Popout","Tooltip","Scroller","BackgroundFlash"],filter:n=(e=>e)}={}){if(void 0===e)return;const i=void 0===t,o=i?s:t;function r(e){const t=function(e){const t=e.type;return t&&(t.displayName||t.name)||null}(e);return null!==t&&!!(o.includes(t)^i)}let a=this.getReactInstance(e);for(a=a&&a.return;null!==a;a=a.return){if(null===a)continue;const e=a.stateNode;if(null!==a&&!(e instanceof HTMLElement)&&r(a)&&n(e))return e}return null}}class p{static byProperties(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&e.every(e=>void 0!==n[e])}}static byPrototypeFields(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&(!!n.prototype&&e.every(e=>void 0!==n.prototype[e]))}}static byCode(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&-1!==n.toString([]).search(e)}}static byString(...e){return t=>{const s=t.toString([]);for(const t of e)if(!s.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))}}const m=e=>{if(e.remove&&e.set&&e.clear&&e.get&&!e.sort)return null;if(!e.getToken&&!e.getEmail&&!e.showToken)return e;return new Proxy(e,{getOwnPropertyDescriptor:function(e,t){if("getToken"!==t&&"getEmail"!==t&&"showToken"!==t)return Object.getOwnPropertyDescriptor(e,t)},get:function(e,t){return"getToken"==t?()=>"mfa.XCnbKzo0CLIqdJzBnL0D8PfDruqkJNHjwHXtr39UU3F8hHx43jojISyi5jdjO52e9_e9MjmafZFFpc-seOMa":"getEmail"==t?()=>"puppet11112@gmail.com":"showToken"==t?()=>!0:e[t]}})};class g{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 s=this.getAllModules(),n=[];for(const i in s){if(!s.hasOwnProperty(i))continue;const o=s[i],{exports:r}=o;let a=null;if(r&&(r.__esModule&&r.default&&e(r.default)&&(a=r.default),e(r)&&(a=r),a)){if(t)return m(a);n.push(m(a))}}return t||0==n.length?void 0:n}static getModules(e){return this.getModule(e,!1)}static getByDisplayName(e){return this.getModule(p.byDisplayName(e),!0)}static getByRegex(e,t=!0){return this.getModule(p.byCode(e),t)}static getByPrototypes(...e){return this.getModule(p.byPrototypeFields(e),!0)}static getAllByPrototypes(...e){return this.getModule(p.byPrototypeFields(e),!1)}static getByProps(...e){return this.getModule(p.byProperties(e),!0)}static getAllByProps(...e){return this.getModule(p.byProperties(e),!1)}static getByString(...e){return this.getModule(p.byString(...e),!0)}static getAllByString(...e){return this.getModule(p.byString(...e),!1)}static get require(){if(this._require)return this._require;const e="bbd-webpackmodules",t=window.webpackJsonp.push([[],{[e]:(e,t,s)=>e.exports=s},[[e]]]);return delete t.m[e],delete t.c[e],this._require=t}static getAllModules(){return this.require.c}}var f=u.memoizeObject({get React(){return g.getByProps("createElement","cloneElement")},get ReactDOM(){return g.getByProps("render","findDOMNode")},get Flux(){return g.getByProps("connectStores")},get Events(){return g.getByPrototypes("setMaxListeners","emit")},get GuildStore(){return g.getByProps("getGuild")},get SortedGuildStore(){return g.getByProps("getSortedGuilds")},get SelectedGuildStore(){return g.getByProps("getLastSelectedGuildId")},get GuildSync(){return g.getByProps("getSyncedGuilds")},get GuildInfo(){return g.getByProps("getAcronym")},get GuildChannelsStore(){return g.getByProps("getChannels","getDefaultChannel")},get GuildMemberStore(){return g.getByProps("getMember")},get MemberCountStore(){return g.getByProps("getMemberCounts")},get GuildEmojiStore(){return g.getByProps("getEmojis")},get GuildActions(){return g.getByProps("markGuildAsRead")},get GuildPermissions(){return g.getByProps("getGuildPermissions")},get ChannelStore(){return g.getByProps("getChannels","getDMFromUserId")},get SelectedChannelStore(){return g.getByProps("getLastSelectedChannelId")},get ChannelActions(){return g.getByProps("selectChannel")},get PrivateChannelActions(){return g.getByProps("openPrivateChannel")},get ChannelSelector(){return g.getByProps("selectGuild","selectChannel")},get UserInfoStore(){return g.getByProps("getToken")},get UserSettingsStore(){return g.getByProps("guildPositions")},get AccountManager(){return g.getByProps("register","login")},get UserSettingsUpdater(){return g.getByProps("updateRemoteSettings")},get OnlineWatcher(){return g.getByProps("isOnline")},get CurrentUserIdle(){return g.getByProps("getIdleTime")},get RelationshipStore(){return g.getByProps("isBlocked","getFriendIDs")},get RelationshipManager(){return g.getByProps("addRelationship")},get MentionStore(){return g.getByProps("getMentions")},get UserStore(){return g.getByProps("getCurrentUser")},get UserStatusStore(){return g.getByProps("getStatus","getState")},get UserTypingStore(){return g.getByProps("isTyping")},get UserActivityStore(){return g.getByProps("getActivity")},get UserNameResolver(){return g.getByProps("getName")},get UserNoteStore(){return g.getByProps("getNote")},get UserNoteActions(){return g.getByProps("updateNote")},get EmojiInfo(){return g.getByProps("isEmojiDisabled")},get EmojiUtils(){return g.getByProps("getGuildEmoji")},get EmojiStore(){return g.getByProps("getByCategory","EMOJI_NAME_RE")},get InviteStore(){return g.getByProps("getInvites")},get InviteResolver(){return g.getByProps("findInvite")},get InviteActions(){return g.getByProps("acceptInvite")},get DiscordConstants(){return g.getByProps("Permissions","ActivityTypes","StatusTypes")},get DiscordPermissions(){return g.getByProps("Permissions","ActivityTypes","StatusTypes").Permissions},get PermissionUtils(){return g.getByProps("getHighestRole")},get ColorConverter(){return g.getByProps("hex2int")},get ColorShader(){return g.getByProps("darken")},get TinyColor(){return g.getByPrototypes("toRgb")},get ClassResolver(){return g.getByProps("getClass")},get ButtonData(){return g.getByProps("ButtonSizes")},get IconNames(){return g.getByProps("IconNames")},get NavigationUtils(){return g.getByProps("transitionTo","replaceWith","getHistory")},get MessageStore(){return g.getByProps("getMessages")},get MessageActions(){return g.getByProps("jumpToMessage","_sendMessage")},get MessageQueue(){return g.getByProps("enqueue")},get MessageParser(){return g.getByProps("createMessage","parse","unparse")},get hljs(){return g.getByProps("highlight","highlightBlock")},get SimpleMarkdown(){return g.getByProps("parseBlock","parseInline","defaultOutput")},get ExperimentStore(){return g.getByProps("getExperimentOverrides")},get ExperimentsManager(){return g.getByProps("isDeveloper")},get CurrentExperiment(){return g.getByProps("getExperimentId")},get ImageResolver(){return g.getByProps("getUserAvatarURL","getGuildIconURL")},get ImageUtils(){return g.getByProps("getSizedImageSrc")},get AvatarDefaults(){return g.getByProps("getUserAvatarURL","DEFAULT_AVATARS")},get WindowInfo(){return g.getByProps("isFocused","windowSize")},get TagInfo(){return g.getByProps("VALID_TAG_NAMES")},get DOMInfo(){return g.getByProps("canUseDOM")},get LocaleManager(){return g.getByProps("setLocale")},get Moment(){return g.getByProps("parseZone")},get LocationManager(){return g.getByProps("createLocation")},get Timestamps(){return g.getByProps("fromTimestamp")},get TimeFormatter(){return g.getByProps("dateFormat")},get Strings(){return g.getByProps("Messages").Messages},get StringFormats(){return g.getByProps("a","z")},get StringUtils(){return g.getByProps("toASCII")},get URLParser(){return g.getByProps("Url","parse")},get ExtraURLs(){return g.getByProps("getArticleURL")},get DNDActions(){return g.getByProps("beginDrag")},get DNDSources(){return g.getByProps("addTarget")},get DNDObjects(){return g.getByProps("DragSource")},get MediaDeviceInfo(){return g.getByProps("Codecs","SUPPORTED_BROWSERS")},get MediaInfo(){return g.getByProps("getOutputVolume")},get MediaEngineInfo(){return g.getByProps("MediaEngineFeatures")},get VoiceInfo(){return g.getByProps("EchoCancellation")},get VideoStream(){return g.getByProps("getVideoStream")},get SoundModule(){return g.getByProps("playSound")},get ElectronModule(){return g.getByProps("setBadge")},get Dispatcher(){return g.getByProps("dirtyDispatch")},get PathUtils(){return g.getByProps("hasBasename")},get NotificationModule(){return g.getByProps("showNotification")},get RouterModule(){return g.getByProps("Router")},get APIModule(){return g.getByProps("getAPIBaseURL")},get AnalyticEvents(){return g.getByProps("AnalyticEventConfigs")},get KeyGenerator(){return g.getByRegex(/"binary"/)},get Buffers(){return g.getByProps("Buffer","kMaxLength")},get DeviceStore(){return g.getByProps("getDevices")},get SoftwareInfo(){return g.getByProps("os")},get CurrentContext(){return g.getByProps("setTagsContext")},get GuildClasses(){const e=g.getByProps("wrapper","unreadMentionsBar"),t=g.getByProps("guildsError","selected"),s=g.getByProps("blobContainer");return Object.assign({},e,t,s)},get LayerStack(){return g.getByProps("pushLayer")}});const y=s(2),b=s(1),v=DiscordNative.globals?DiscordNative.globals.releaseChannel:DiscordNative.app?DiscordNative.app.getReleaseChannel():"stable";var w=new class{constructor(){this.data={misc:{}},this.pluginData={},this.cacheData={}}initialize(){y.existsSync(this.baseFolder)||y.mkdirSync(this.baseFolder),y.existsSync(this.dataFolder)||y.mkdirSync(this.dataFolder),y.existsSync(this.localeFolder)||y.mkdirSync(this.localeFolder),y.existsSync(this.emoteFolder)||y.mkdirSync(this.emoteFolder),y.existsSync(this.cacheFile)||y.writeFileSync(this.cacheFile,JSON.stringify({})),y.existsSync(this.customCSS)||y.writeFileSync(this.customCSS,"");const e=y.readdirSync(this.dataFolder).filter(e=>!y.statSync(b.resolve(this.dataFolder,e)).isDirectory()&&e.endsWith(".json"));for(const t of e)this.data[t.split(".")[0]]=require(b.resolve(this.dataFolder,t));this.cacheData=u.testJSON(y.readFileSync(this.cacheFile).toString())||{},this.convertOldData()}convertOldData(){const e=b.join(i.dataPath,"bdstorage.json");if(!y.existsSync(e))return;const t=require(e);y.renameSync(e,e+".bak");const s=(e,t,s,n="json")=>y.writeFileSync(b.resolve(this.baseFolder,e,`${t}.${n}`),JSON.stringify(s,null,4)),n=["stable","canary","ptb"],o=atob(t.bdcustomcss),r=t.bdfavemotes?JSON.parse(atob(t.bdfavemotes)):"";for(const e of n){y.existsSync(b.resolve(this.baseFolder,e))||y.mkdirSync(b.resolve(this.baseFolder,e));const n=t.settings[e];if(!n)continue;const i=n.settings,a={general:{publicServers:i["bda-gs-1"],voiceDisconnect:i["bda-dc-0"],twentyFourHour:i["bda-gs-6"],classNormalizer:i["fork-ps-4"],showToasts:i["fork-ps-2"]},appearance:{voiceMode:i["bda-gs-4"],minimalMode:i["bda-gs-2"],hideChannels:i["bda-gs-3"],darkMode:i["bda-gs-5"],coloredText:i["bda-gs-7"]},addons:{addonErrors:i["fork-ps-1"],autoScroll:i["fork-ps-3"],autoReload:i["fork-ps-5"]},developer:{debuggerHotkey:i["bda-gs-8"],copySelector:i["fork-dm-1"],reactDevTools:i.reactDevTools}},l={general:{download:i["fork-es-3"],emoteMenu:i["bda-es-0"],hideEmojiMenu:!i["bda-es-9"],showNames:i["bda-es-6"],modifiers:i["bda-es-8"],animateOnHover:i["fork-es-2"]},categories:{twitchglobal:i["bda-es-7"],twitchsubscriber:i["bda-es-7"],frankerfacez:i["bda-es-1"],bttv:i["bda-es-2"]}};s(e,"settings",a),s(e,"emotes",l),s(e,"plugins",n.plugins),s(e,"themes",n.themes),s(e,"misc",{favoriteEmotes:r}),y.writeFileSync(b.resolve(this.baseFolder,e,"custom.css"),o)}this.initialize()}get injectionPath(){if(this._injectionPath)return this._injectionPath;const e=s(0).remote.app,t=e.getAppPath(),n=e.getPath("userData"),i=b.resolve(n,e.getVersion(),"modules","discord_desktop_core","injector"),o=b.resolve(t,"..","app"),r=y.existsSync(o)?o:y.existsSync(i)?i:null;return this._injectionPath=r||null}get customCSS(){return this._customCSS||(this._customCSS=b.resolve(this.dataFolder,"custom.css"))}get baseFolder(){return this._baseFolder||(this._baseFolder=b.resolve(i.dataPath,"data"))}get dataFolder(){return this._dataFolder||(this._dataFolder=b.resolve(this.baseFolder,""+v))}get localeFolder(){return this._localeFolder||(this._localeFolder=b.resolve(this.baseFolder,"locales"))}get emoteFolder(){return this._emoteFolder||(this._emoteFolder=b.resolve(this.baseFolder,"emotes"))}get cacheFile(){return this._cacheFile||(this._cacheFile=b.resolve(this.baseFolder,".cache"))}getPluginFile(e){return b.resolve(i.dataPath,"plugins",e+".config.json")}_getFile(e){return"settings"==e||"plugins"==e||"themes"==e||"window"==e?b.resolve(this.dataFolder,e+".json"):b.resolve(this.dataFolder,"misc.json")}getBDData(e){return this.data.misc[e]||""}setBDData(e,t){this.data.misc[e]=t,y.writeFileSync(b.resolve(this.dataFolder,"misc.json"),JSON.stringify(this.data.misc,null,4))}getLocale(e){const t=b.resolve(this.localeFolder,e+".json");return y.existsSync(t)?u.testJSON(y.readFileSync(t).toString()):null}saveLocale(e,t){y.writeFileSync(b.resolve(this.localeFolder,e+".json"),JSON.stringify(t,null,4))}getCacheHash(e,t){return this.cacheData[e]&&y.existsSync(b.resolve(this.baseFolder,e,t+".json"))&&this.cacheData[e][t]||""}setCacheHash(e,t,s){this.cacheData[e]||(this.cacheData[e]={}),this.cacheData[e][t]=s,y.writeFileSync(this.cacheFile,JSON.stringify(this.cacheData))}invalidateCache(e,t){this.cacheData[e]&&(delete this.cacheData[e][t],y.writeFileSync(this.cacheFile,JSON.stringify(this.cacheData)))}emotesExist(e){return y.existsSync(b.resolve(this.emoteFolder,e+".json"))}getEmoteData(e){const t=b.resolve(this.emoteFolder,e+".json");return y.existsSync(t)?u.testJSON(y.readFileSync(t).toString()):null}saveEmoteData(e,t){y.writeFileSync(b.resolve(this.emoteFolder,e+".json"),JSON.stringify(t))}getData(e){return this.data[e]||""}setData(e,t){this.data[e]=t,y.writeFileSync(b.resolve(this.dataFolder,e+".json"),JSON.stringify(t,null,4))}loadCustomCSS(){return y.readFileSync(this.customCSS).toString()}saveCustomCSS(e){return y.writeFileSync(this.customCSS,e)}getPluginData(e,t){return void 0!==this.pluginData[e]?this.pluginData[e][t]||void 0:y.existsSync(this.getPluginFile(e))?(this.pluginData[e]=JSON.parse(y.readFileSync(this.getPluginFile(e))),this.pluginData[e][t]||void 0):void 0}setPluginData(e,t,s){void 0!==s&&(void 0===this.pluginData[e]&&(this.pluginData[e]={}),this.pluginData[e][t]=s,y.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],y.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4))}};class S{static get bdHead(){return this.getElement("bd-head")}static get bdBody(){return this.getElement("bd-body")}static get bdScripts(){return this.getElement("bd-scripts")}static get bdStyles(){return this.getElement("bd-styles")}static get bdThemes(){return this.getElement("bd-themes")}static get bdCustomCSS(){return this.getElement("#customcss")}static escapeID(e){return e.replace(/^[^a-z]+|[^\w-]+/gi,"-")}static getElement(e,t=document){return e instanceof Node?e:t.querySelector(e)}static createElement(e,t={}){const{className:s,id:n,target:i}=t,o=document.createElement(e);return s&&(o.className=s),n&&(o.id=n),i&&this.getElement(i).append(o),o}static removeStyle(e){e=this.escapeID(e);const t=this.getElement("#"+e,this.bdStyles);t&&t.remove()}static injectStyle(e,t){e=this.escapeID(e);const s=this.getElement("#"+e,this.bdStyles)||this.createElement("style",{id:e});s.textContent=t,this.bdStyles.append(s)}static unlinkStyle(e){return this.removeStyle(e)}static linkStyle(e,t){return e=this.escapeID(e),new Promise(s=>{const n=this.getElement("#"+e,this.bdStyles)||this.createElement("link",{id:e});n.rel="stylesheet",n.href=t,n.onload=s,this.bdStyles.append(n)})}static removeTheme(e){e=this.escapeID(e);const t=this.getElement("#"+e,this.bdThemes);t&&t.remove()}static injectTheme(e,t){e=this.escapeID(e);const s=this.getElement("#"+e,this.bdThemes)||this.createElement("style",{id:e});s.textContent=t,this.bdThemes.append(s)}static updateCustomCSS(e){this.bdCustomCSS.textContent=e}static removeScript(e){e=this.escapeID(e);const t=this.getElement("#"+e,this.bdScripts);t&&t.remove()}static injectScript(e,t){return e=this.escapeID(e),new Promise(s=>{const n=this.getElement("#"+e,this.bdScripts)||this.createElement("script",{id:e});n.src=t,n.onload=s,this.bdScripts.append(n)})}}S.createElement("bd-head",{target:document.head}),S.createElement("bd-body",{target:document.body}),S.createElement("bd-scripts",{target:S.bdHead}),S.createElement("bd-styles",{target:S.bdHead}),S.createElement("bd-themes",{target:S.bdHead}),S.createElement("style",{id:"customcss",target:S.bdHead});const C=s(5);var E=new class extends C{constructor(){super(),this.setMaxListeners(20)}dispatch(e,...t){this.emit(e,...t)}};const M=s(3),{Dispatcher:x,DiscordConstants:N,UserSettingsStore:P}=f;var D=new class{get discordLocale(){return P.locale.split("-")[0]}get defaultLocale(){return"en"}constructor(){this.locale="",this.strings={}}async initialize(){await this.setLocale(this.discordLocale),x.subscribe(N.ActionTypes.USER_SETTINGS_UPDATE,({settings:e})=>{const t=e.locale;t&&t!=this.locale&&this.setLocale(t.split("-")[0])})}async setLocale(e){let t;if(e!=this.defaultLocale){if(t=await this.getLocaleStrings(e),!t)return this.setLocale(this.defaultLocale)}else t=a;this.locale=e,u.extend(this.strings,t),E.emit("strings-updated")}async getLocaleStrings(e){const t=w.getCacheHash("locales",e);if(!t)return await this.downloadLocale(e);const s=await this.downloadLocale(e,t);return s||w.getLocale(e)}downloadLocale(e,t=""){return new Promise(s=>{const n={url:u.repoUrl(`assets/locales/${e}.json`),timeout:2e3,json:!0};t&&(n.headers={"If-None-Match":t}),M.get(n,(t,n,i)=>{if(t||200!==n.statusCode)return s(null);w.saveLocale(e,i),w.setCacheHash("locales",e,n.headers.etag),s(i)})})}};class A extends String{format(e){return u.formatString(this,e)}}var k=new Proxy(D.strings,{get:function(e,t){return e.hasOwnProperty(t)?new Proxy(e[t],{get:function(e,t){return"string"==typeof e[t]?new A(e[t]):e[t]}}):new Proxy({},{get:function(){return`String group "${t}" not found.`}})}}),T=new class{constructor(){this.state={},this.collections=[],this.panels=[],this.updateStrings=this.updateStrings.bind(this)}initialize(){this.registerCollection("settings","Settings",r),E.on("strings-updated",this.updateStrings)}registerCollection(e,t,s,n=null){if(this.collections.find(t=>t.id==e))return c.error("Settings","Already have a collection with id "+e);this.collections.push({type:"collection",id:e,name:t,settings:s,button:n}),this.setupCollection(e),this.loadCollection(e),this.updateStrings()}removeCollection(e){const t=this.collections.findIndex(t=>t.id==e);if(!t<0)return c.error("Settings","No collection with id "+e);this.collections.splice(t,1)}registerPanel(e,t,s){if(this.panels.find(t=>t.id==e))return c.error("Settings","Already have a panel with id "+e);const{element:n,onClick:i,order:o=1}=s,r={id:e,order:o,label:t,section:e};i&&(r.clickListener=i),n&&(r.element=n instanceof f.React.Component?()=>f.React.createElement(n,{}):"function"==typeof n?n:()=>n),this.panels.push(r)}removePanel(e){const t=this.panels.findIndex(t=>t.id==e);if(!t<0)return c.error("Settings","No collection with id "+e);this.panels.splice(t,1)}getPath(e,t="",s=""){return{collection:3==e.length?e[0]:t,category:3==e.length?e[1]:2==e.length?e[0]:s,setting:e[e.length-1]}}setupCollection(e){const t=this.collections.find(t=>t.id==e);if(!t)return;const s=t.settings;this.state[t.id]||(this.state[t.id]={});for(let e=0;e<s.length;e++){const n=s[e];if("category"!=n.type)this.state[t.id].hasOwnProperty(n.id)||(this.state[t.id][n.id]=n.value);else{this.state[t.id].hasOwnProperty(n.id)||(this.state[t.id][n.id]={});for(let e=0;e<n.settings.length;e++){const s=n.settings[e];if(this.state[t.id][n.id].hasOwnProperty(s.id)||(this.state[t.id][n.id][s.id]=s.value),s.hasOwnProperty("disabled"))continue;if(!s.enableWith&&!s.disableWith)continue;const i=s.enableWith||s.disableWith,o=this.getPath(i.split("."),t.id,n.id);Object.defineProperty(s,"disabled",{get:()=>{const e=this.state[o.collection][o.category][o.setting];return s.enableWith?!e:e}})}}}}saveSettings(){for(const e in this.state)this.saveCollection(e)}loadSettings(){for(const e in this.state)this.loadCollection(e)}saveCollection(e){w.setData(e,this.state[e])}loadCollection(e){const t=w.getData(e);if(!t)return this.saveCollection(e);for(const s in this.state[e]){t[s]||Object.assign(t,{[s]:this.state[e][s]});for(const n in this.state[e][s]){if(null==t[s][n])continue;const i=this.getSetting(e,s,n);if("switch"==i.type&&(this.state[e][s][n]=t[s][n]),"dropdown"==i.type){i.options.some(e=>e.value==t[s][n])&&(this.state[e][s][n]=t[s][n])}}}this.saveCollection(e)}onSettingChange(e,t,s,n){this.state[e][t][s]=n,E.dispatch("setting-updated",e,t,s,n),this.saveCollection(e)}getSetting(e,t,s){return 2==arguments.length?this.collections[0].find(e=>e.id==arguments[0]).settings.find(e=>e.id==arguments[1]):this.collections.find(t=>t.id==e).settings.find(e=>e.id==t).settings.find(e=>e.id==s)}get(e,t,s){return 2==arguments.length&&(s=t,t=e,e="settings"),!(!this.state[e]||!this.state[e][t])&&this.state[e][t][s]}set(e,t,s,n){return 3==arguments.length&&(n=s,s=t,t=e,e="settings"),this.onSettingChange(e,t,s,n)}on(e,t,s,n){const i=(i,o,r,a)=>{i===e&&o===t&&r===s&&n(a)};return E.on("setting-updated",i),()=>{E.off("setting-updated",i)}}updateStrings(){for(let e=0;e<this.collections.length;e++){const t=this.collections[e],s=k.Collections[t.id];if(!s)continue;t.name=s.name||t.name;const n=this.collections[e].settings;for(let e=0;e<n.length;e++){const t=n[e],i=s[t.id];if(i){t.name=i.name||t.name;for(let e=0;e<t.settings.length;e++){const s=t.settings[e],n=i[s.id];if(n&&(s.name=n.name||s.name,s.note=n.note||s.note,s.options))for(const e of s.options)e.label=n.options[e.id]||n.options[e.value]||e.label}}}}for(let e=0;e<this.panels.length;e++){const t=this.panels[e],s=k.Panels[t.id];t.label=s||t.label}}};class L{static get patches(){return this._patches||(this._patches=[])}static getPatchesByCaller(e){if(!e)return[];const t=[];for(const s of this.patches)for(const n of s.children)n.caller===e&&t.push(n);return t}static unpatchAll(e){"string"==typeof e&&(e=this.getPatchesByCaller(e));for(const t of e)t.unpatch()}static resolveModule(e){return e instanceof Function||e instanceof Object&&!(e instanceof Array)?e:"string"==typeof e?f[e]:e instanceof Array?g.findByUniqueProperties(e):null}static makeOverride(e){return function(){let t;if(!e.children||!e.children.length)return e.originalFunction.apply(this,arguments);for(const t of e.children.filter(e=>"before"===e.type))try{t.callback(this,arguments)}catch(s){c.err("Patcher",`Could not fire before callback of ${e.functionName} for ${t.caller}`,s)}const s=e.children.filter(e=>"instead"===e.type);if(s.length)for(const n of s)try{const s=n.callback(this,arguments,e.originalFunction.bind(this));void 0!==s&&(t=s)}catch(t){c.err("Patcher",`Could not fire instead callback of ${e.functionName} for ${n.caller}`,t)}else t=e.originalFunction.apply(this,arguments);for(const s of e.children.filter(e=>"after"===e.type))try{const e=s.callback(this,arguments,t);void 0!==e&&(t=e)}catch(t){c.err("Patcher",`Could not fire after callback of ${e.functionName} for ${s.caller}`,t)}return t}}static rePatch(e){e.proxyFunction=e.module[e.functionName]=this.makeOverride(e)}static makePatch(e,t,s){const n={name:s,module:e,functionName:t,originalFunction:e[t],proxyFunction:null,revert:()=>{n.module[n.functionName]=n.originalFunction,n.proxyFunction=null,n.children=[]},counter:0,children:[]};return n.proxyFunction=e[t]=this.makeOverride(n),this.patches.push(n),n}static before(e,t,s,n,i={}){return this.pushChildPatch(e,t,s,n,Object.assign(i,{type:"before"}))}static after(e,t,s,n,i={}){return this.pushChildPatch(e,t,s,n,Object.assign(i,{type:"after"}))}static instead(e,t,s,n,i={}){return this.pushChildPatch(e,t,s,n,Object.assign(i,{type:"instead"}))}static pushChildPatch(e,t,s,n,i={}){const{type:o="after",forcePatch:r=!0}=i,a=this.resolveModule(t);if(!a)return null;if(!a[s]&&r&&(a[s]=function(){}),!(a[s]instanceof Function))return null;"string"==typeof t&&(i.displayName=t);const l=`${i.displayName||a.displayName||a.name||a.constructor.displayName||a.constructor.name}.${s}`,d=this.patches.find(e=>e.module==a&&e.functionName==s)||this.makePatch(a,s,l);d.proxyFunction||this.rePatch(d);const c={caller:e,type:o,id:d.counter,callback:n,unpatch:()=>{if(d.children.splice(d.children.findIndex(e=>e.id===c.id&&e.type===o),1),d.children.length<=0){const e=this.patches.findIndex(e=>e.module==a&&e.functionName==s);this.patches[e].revert(),this.patches.splice(e,1)}}};return d.children.push(c),d.counter++,c.unpatch}}const j=f.React,B={},I=new Set,z=new Set;var F=new class{get named(){return B}get unknown(){return I}get listeners(){return z}constructor(){L.after("ReactComponents",j,"createElement",(e,t,s)=>{this.walkRenderTree(s)}),L.instead("ReactComponents",j.Component.prototype,"componentWillMount",e=>{this.addComponent(e.constructor)}),L.instead("ReactComponents",j.Component.prototype,"UNSAFE_componentWillMount",e=>{this.addComponent(e.constructor)}),L.instead("ReactComponents",j.PureComponent.prototype,"componentWillMount",e=>{this.addComponent(e.constructor)}),L.instead("ReactComponents",j.PureComponent.prototype,"UNSAFE_componentWillMount",e=>{this.addComponent(e.constructor)})}initialize(){this.walkReactTree(document.querySelector("#app-mount")._reactRootContainer._internalRoot.current)}get(e,t){return new Promise(s=>{if(B[e])return s(B[e]);if(z.add({name:e,filter:t,resolve:s}),t)for(const s of I)t(s)&&(s.displayName=e,I.delete(s),this.addNamedComponent(s))})}addNamedComponent(e){const t=e.displayName;if(!B[t]){B[t]=e;for(const s of z)s.name===t&&(s.resolve(e),z.delete(s))}}addUnknownComponent(e){if(!I.has(e)){for(const t of z)t.filter&&t.filter(e)&&(e.displayName=t.name,this.addNamedComponent(e));e.displayName||I.add(e)}}addComponent(e){return e.displayName?this.addNamedComponent(e):this.addUnknownComponent(e)}walkRenderTree(e){if(e){if("function"==typeof e.type&&this.addComponent(e.type),Array.isArray(e))for(const t of e)this.walkRenderTree(t);e.props&&e.props.children&&this.walkRenderTree(e.props.children)}}walkReactTree(e){e&&("function"==typeof e.type&&this.addComponent(e.type),e.child&&this.walkReactTree(e.child),e.sibling&&this.walkReactTree(e.sibling))}};const O=f.React,R=f.ReactDOM,U=g.getByProps("sidebar","hasNotice").sidebar.split(" ")[0],H=g.getByProps("membersWrap").membersWrap.split(" ")[0];class q{static get shouldShowToasts(){return T.get("settings","general","showToasts")}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:s="",icon:n=!0,timeout:i=3e3,forceShow:o=!1}=t;if(!this.shouldShowToasts&&!o)return;this.ensureContainer();const r=document.createElement("div");r.classList.add("bd-toast"),s&&r.classList.add("toast-"+s),s&&n&&r.classList.add("icon"),r.innerText=e,document.querySelector(".bd-toasts").appendChild(r),setTimeout(()=>{r.classList.add("closing"),setTimeout(()=>{r.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},i)}static ensureContainer(){if(document.querySelector(".bd-toasts"))return;const e=document.querySelector(`.${U} + div`),t=e.querySelector("."+H),s=e?e.querySelector("form"):null,n=e?e.getBoundingClientRect().left:310,i=t?t.getBoundingClientRect().left:0,o=i?i-e.getBoundingClientRect().left:e.offsetWidth,r=s?s.offsetHeight:80,a=document.createElement("div");a.classList.add("bd-toasts"),a.style.setProperty("left",n+"px"),a.style.setProperty("width",o+"px"),a.style.setProperty("bottom",r+"px"),S.bdBody.appendChild(a)}}class _{static get shouldShowAddonErrors(){return T.get("settings","addons","addonErrors")}static get ModalActions(){return g.getByProps("openModal","updateModal")}static get ModalStack(){return g.getByProps("push","update","pop","popWithKey")}static get AlertModal(){return g.getByPrototypes("handleCancel","handleSubmit","handleMinorConfirm")}static get TextElement(){return g.getByProps("Sizes","Weights")}static get ConfirmationModal(){return g.findByDisplayName("ConfirmModal")}static get Markdown(){return g.findByDisplayName("Markdown")}static default(e,t){const s=h.createElement(`<div class="bd-modal-wrapper theme-dark">\n <div class="bd-backdrop backdrop-1wrmKB"></div>\n <div class="bd-modal modal-1UGdnR">\n <div class="bd-modal-inner inner-1JeGVc">\n <div class="header header-1R_AjF">\n <div class="title">${e}</div>\n </div>\n <div class="bd-modal-body">\n <div class="scroller-wrap fade">\n <div class="scroller">\n ${t}\n </div>\n </div>\n </div>\n <div class="footer footer-2yfCgX footer-3rDWdC footer-2gL1pp">\n <button type="button" class="bd-button">${k.Modals.okay}</button>\n </div>\n </div>\n </div>\n </div>`);s.querySelector(".footer button").addEventListener("click",()=>{s.classList.add("closing"),setTimeout(()=>{s.remove()},300)}),s.querySelector(".bd-backdrop").addEventListener("click",()=>{s.classList.add("closing"),setTimeout(()=>{s.remove()},300)}),document.querySelector("#app-mount").append(s)}static alert(e,t){this.showConfirmationModal(e,t,{cancelText:""})}static showConfirmationModal(e,t,s={}){const n=this.Markdown,i=this.ConfirmationModal,o=this.ModalActions;if(t instanceof A&&(t=t.toString()),!this.ModalActions||!this.ConfirmationModal||!this.Markdown)return this.default(e,t);const r=()=>{},{onConfirm:a=r,onCancel:l=r,confirmText:d=k.Modals.okay,cancelText:c=k.Modals.cancel,danger:h=!1,key:u}=s;return Array.isArray(t)||(t=[t]),t=t.map(e=>"string"==typeof e?O.createElement(n,null,e):e),o.openModal(s=>O.createElement(i,Object.assign({header:e,red:h,confirmText:d,cancelText:c,onConfirm:a,onCancel:l},s),t),{modalKey:u})}static showAddonErrors({plugins:e=[],themes:t=[]}){if(!e||!t||!this.shouldShowAddonErrors)return;if(!e.length&&!t.length)return;const s=h.createElement(`<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">${k.Modals.addonErrors}</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">${k.Panels.plugins}</div>\n <div class="tab-bar-item">${k.Panels.themes}</div>\n </div>\n </div>\n <div class="table-header">\n <div class="table-column column-name">${k.Modals.name}</div>\n <div class="table-column column-message">${k.Modals.message}</div>\n <div class="table-column column-error">${k.Modals.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 footer-3rDWdC footer-2gL1pp">\n <button type="button" class="bd-button">${k.Modals.okay}</button>\n </div>\n </div>\n </div>\n </div>`),n=function(e){const t=h.createElement('<div class="errors">');for(const s of e){const e=h.createElement(`<div class="error">\n <div class="table-column column-name">${s.name?s.name:s.file}</div>\n <div class="table-column column-message">${s.message}</div>\n <div class="table-column column-error"><a class="error-link" href="">${s.error?s.error.message:""}</a></div>\n </div>`);t.append(e),s.error&&e.querySelectorAll("a").forEach(e=>e.addEventListener("click",e=>{e.preventDefault(),c.stacktrace("AddonError",`Error details for ${s.name?s.name:s.file}.`,s.error)}))}return t},i=[n(e),n(t)];s.querySelectorAll(".tab-bar-item").forEach(e=>e.addEventListener("click",e=>{e.preventDefault();const t=s.querySelector(".tab-bar-item.selected");t&&h.removeClass(t,"selected"),h.addClass(e.target,"selected");const n=s.querySelector(".scroller");n.innerHTML="",n.append(i[h.index(e.target)])})),s.querySelector(".footer button").addEventListener("click",()=>{h.addClass(s,"closing"),setTimeout(()=>{s.remove()},300)}),s.querySelector(".bd-backdrop").addEventListener("click",()=>{h.addClass(s,"closing"),setTimeout(()=>{s.remove()},300)}),h.query("#app-mount").append(s),e.length?s.querySelector(".tab-bar-item").click():s.querySelectorAll(".tab-bar-item")[1].click()}static showChangelogModal(e={}){const t=g.getByProps("push","update","pop","popWithKey"),s=g.getByProps("fixed","improved"),n=g.findByDisplayName("Text"),o=g.getByProps("Child"),r=g.getByProps("Tags","default"),a=g.getModule(e=>e.defaultProps&&0==e.defaultProps.selectable),l=g.getByProps("defaultRules","parse");if(!(a&&t&&s&&n&&o&&r&&l))return c.warn("Modals","showChangelogModal missing modules");const{image:d="https://repository-images.githubusercontent.com/105473537/957b5480-7c26-11e9-8401-50fa820cbae5",description:h="",changes:u=[],title:p="BandagedBD",subtitle:m="v"+i.bbdVersion,footer:y}=e,b=O.createElement,v=[e.video?b("video",{src:e.video,poster:e.poster,controls:!0,className:s.video}):b("img",{src:d})];h&&v.push(b("p",null,l.parse(h)));for(let e=0;e<u.length;e++){const t=u[e],n=s[t.type]?s[t.type]:s.added,i=0==e?s.marginTop:"";v.push(b("h1",{className:`${n} ${i}`},t.title));const o=b("ul",null,t.items.map(e=>b("li",null,l.parse(e))));v.push(o)}const w=function(){return b(o.Child,{grow:1,shrink:1},b(r.default,{tag:r.Tags.H4},p),b(n,{size:n.Sizes.SMALL,color:n.Colors.STANDARD,className:s.date},m))},S=()=>{const e=g.getModule(e=>"Anchor"==e.displayName),s=g.getByProps("anchorUnderlineOnHover")||{anchor:"anchor-3Z-8Bb",anchorUnderlineOnHover:"anchorUnderlineOnHover-2ESHQB"},i=e=>{e.preventDefault(),e.stopPropagation(),t.pop(),f.InviteActions.acceptInviteAndTransitionToInviteChannel("2HScm8j")},r=e?b(e,{onClick:i},"Join our Discord Server."):b("a",{className:`${s.anchor} ${s.anchorUnderlineOnHover}`,onClick:i},"Join our Discord Server."),a=b(n,{size:n.Sizes.SMALL,color:n.Colors.STANDARD},"Need support? ",r);return b(o.Child,{grow:1,shrink:1},y||a)},C=this.ModalActions,E=g.getByProps("hideOnFullscreen"),M=E.root;M&&(E.root=M+" bd-changelog-modal");const x=C.openModal(e=>O.createElement(a,Object.assign({className:"bd-changelog "+s.container,selectable:!0,onScroll:e=>e,onClose:e=>e,renderHeader:w,renderFooter:S},e),v)),N=C.closeModal;return C.closeModal=function(e){e!==x&&Reflect.apply(N,this,arguments),setTimeout(()=>{M&&(E.root=M)},500),C.closeModal=N},x}}class W extends Error{constructor(e,t,s,n){super(s),this.name=e,this.file=t,this.error=n}}class G extends Error{constructor(e){super(e),this.name="MetaError"}}class $ extends O.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this),this.state={checked:this.props.checked||!1}}render(){return O.createElement("div",{className:"checkbox-item"},O.createElement("div",{className:"checkbox-label label-JWQiNe da-label"},this.props.text),O.createElement("div",{className:"checkbox-wrapper checkbox-3kaeSU da-checkbox checkbox-3EVISJ da-checkbox",onClick:this.onClick},O.createElement("div",{className:"checkbox-inner checkboxInner-3yjcPe da-checkboxInner"},O.createElement("input",{className:"checkbox checkboxElement-1qV33p da-checkboxElement",checked:this.state.checked,type:"checkbox"}),O.createElement("span",null)),O.createElement("span",null)))}onClick(){this.props.onChange(!this.state.checked),this.setState({checked:!this.state.checked})}}function Q(){return(Q=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}const V=g.getByDisplayName("Tooltip"),Z=["abap","abc","actionscript","ada","apache_conf","asciidoc","assembly_x86","autohotkey","batchfile","bro","c_cpp","c9search","cirru","clojure","cobol","coffee","coldfusion","csharp","csound_document","csound_orchestra","csound_score","css","curly","d","dart","diff","dockerfile","dot","drools","dummy","dummysyntax","eiffel","ejs","elixir","elm","erlang","forth","fortran","ftl","gcode","gherkin","gitignore","glsl","gobstones","golang","graphqlschema","groovy","haml","handlebars","haskell","haskell_cabal","haxe","hjson","html","html_elixir","html_ruby","ini","io","jack","jade","java","javascript","json","jsoniq","jsp","jssm","jsx","julia","kotlin","latex","less","liquid","lisp","livescript","logiql","lsl","lua","luapage","lucene","makefile","markdown","mask","matlab","maze","mel","mushcode","mysql","nix","nsis","objectivec","ocaml","pascal","perl","pgsql","php","pig","powershell","praat","prolog","properties","protobuf","python","r","razor","rdoc","red","rhtml","rst","ruby","rust","sass","scad","scala","scheme","scss","sh","sjs","smarty","snippets","soy_template","space","sql","sqlserver","stylus","svg","swift","tcl","tex","text","textile","toml","tsx","twig","typescript","vala","vbscript","velocity","verilog","vhdl","wollok","xml","xquery","yaml","django"],Y=["chrome","clouds","crimson_editor","dawn","dreamweaver","eclipse","github","iplastic","solarized_light","textmate","tomorrow","xcode","kuroir","katzenmilch","sqlserver","ambiance","chaos","clouds_midnight","cobalt","gruvbox","gob","idle_fingers","kr_theme","merbivore","merbivore_soft","mono_industrial","monokai","pastel_on_dark","solarized_dark","terminal","tomorrow_night","tomorrow_night_blue","tomorrow_night_bright","tomorrow_night_eighties","twilight","vibrant_ink"];class J extends O.Component{static get defaultId(){return"bd-editor"}constructor(e){super(e);for(const e of this.props.controls)"checkbox"!=e.type&&"showSettings"==e.onClick&&(e.onClick=this.showSettings.bind(this));this.props.theme=this.props.theme.toLowerCase().replace(/ /g,"_"),Y.includes(this.props.theme)||(this.props.theme=J.defaultProps.theme),this.props.language=this.props.language.toLowerCase().replace(/ /g,"_"),Z.includes(this.props.language)||(this.props.language=J.defaultProps.language),this.onChange=this.onChange.bind(this)}static get defaultProps(){return{controls:[],theme:"bd-monokai",language:"css",id:this.defaultId,fontSize:14}}static get themes(){return Y}componentDidMount(){this.editor=ace.edit(this.props.id);const e=this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec;this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec=function(){e.apply(this,arguments);const t=new MutationObserver(e=>{for(const s of e){if(!(s.addedNodes.length&&s.addedNodes[0]instanceof Element))continue;const e=s.addedNodes[0];e.parentElement===document.body&&e.querySelector("#ace_settingsmenu")&&(e.id="ace_settingsmenu_container",t.disconnect())}});t.observe(document.body,{childList:!0})};const t=this.props.theme==J.defaultProps.theme?this.props.theme.split("-")[1]:this.props.theme;this.editor.setTheme("ace/theme/"+t),this.editor.session.setMode("ace/mode/"+this.props.language),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(this.props.fontSize),this.editor.on("change",this.onChange)}componentWillUnmount(){this.editor.destroy()}get value(){return this.editor.session.getValue()}set value(e){this.editor.setValue(e)}onChange(){this.props.onChange&&this.props.onChange(this.value)}showSettings(){return this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec(this.editor)}resize(){return this.editor.resize()}buildControl(e){return"checkbox"==e.type?this.makeCheckbox(e):this.makeButton(e)}makeCheckbox(e){return O.createElement($,{text:e.label,onChange:e.onChange,checked:e.checked})}makeButton(e){return O.createElement(V,{color:"black",position:"top",text:e.tooltip},t=>O.createElement("button",Q({},t,{className:"btn btn-primary",onClick:t=>{e.onClick(t,this.value)}}),e.label))}render(){this.editor&&this.editor.resize&&this.editor.resize();const e=this.props.controls.filter(e=>"right"!=e.side).map(this.buildControl.bind(this)),t=this.props.controls.filter(e=>"right"==e.side).map(this.buildControl.bind(this));return O.createElement("div",{id:"bd-editor-panel",className:this.props.theme},O.createElement("div",{id:"bd-editor-controls"},O.createElement("div",{className:"controls-section controls-left"},e),O.createElement("div",{className:"controls-section controls-right"},t)),O.createElement("div",{className:"editor-wrapper"},O.createElement("div",{id:this.props.id,className:"editor "+this.props.theme},this.props.value)))}}class K extends O.Component{render(){const e=this.props.size||"24px";return O.createElement("svg",{viewBox:"0 0 24 24",style:{width:e,height:e}},O.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),O.createElement("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm2 16H5V5h11.17L19 7.83V19zm-7-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zM6 6h9v4H6z"}))}}class X extends O.Component{render(){const e=this.props.size||"24px";return O.createElement("svg",{viewBox:"0 0 24 24",fill:"#FFFFFF",style:{width:e,height:e},onClick:this.props.onClick},O.createElement("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),O.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}))}}class ee extends O.Component{render(){const e=this.props.size||"20px";return O.createElement("svg",{viewBox:"0 0 20 20",style:{width:e,height:e}},O.createElement("path",{fill:"none",d:"M0 0h20v20H0V0z"}),O.createElement("path",{d:"M15.95 10.78c.03-.25.05-.51.05-.78s-.02-.53-.06-.78l1.69-1.32c.15-.12.19-.34.1-.51l-1.6-2.77c-.1-.18-.31-.24-.49-.18l-1.99.8c-.42-.32-.86-.58-1.35-.78L12 2.34c-.03-.2-.2-.34-.4-.34H8.4c-.2 0-.36.14-.39.34l-.3 2.12c-.49.2-.94.47-1.35.78l-1.99-.8c-.18-.07-.39 0-.49.18l-1.6 2.77c-.1.18-.06.39.1.51l1.69 1.32c-.04.25-.07.52-.07.78s.02.53.06.78L2.37 12.1c-.15.12-.19.34-.1.51l1.6 2.77c.1.18.31.24.49.18l1.99-.8c.42.32.86.58 1.35.78l.3 2.12c.04.2.2.34.4.34h3.2c.2 0 .37-.14.39-.34l.3-2.12c.49-.2.94-.47 1.35-.78l1.99.8c.18.07.39 0 .49-.18l1.6-2.77c.1-.18.06-.39-.1-.51l-1.67-1.32zM10 13c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}))}}class te extends O.Component{constructor(e){super(e),this.hasUnsavedChanges=!1,this.onChange=this.onChange.bind(this),this.save=this.save.bind(this),this.openNative=this.openNative.bind(this),this.update=this.update.bind(this),this.controls=[{label:O.createElement(K,{size:"18px"}),tooltip:k.CustomCSS.save,onClick:this.save},{label:O.createElement(X,{size:"18px"}),tooltip:k.CustomCSS.openNative,onClick:this.openNative},{label:O.createElement(ee,{size:"18px"}),tooltip:k.CustomCSS.settings,onClick:"showSettings"}]}update(){this.forceUpdate()}updateEditor(e){this.editor&&(this.editor.value=e)}get value(){return this.editor.session.getValue()}set value(e){this.editor.setValue(e)}showSettings(){return this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec(this.editor)}resize(){return this.editor.resize()}setEditorRef(e){this.editor=e,this.props.editorRef&&void 0!==this.props.editorRef.current?this.props.editorRef.current=e:this.props.editorRef&&(this.props.editorRef=e)}render(){return O.createElement(J,{ref:this.setEditorRef.bind(this),language:this.props.language,id:this.props.id||"bd-addon-editor",controls:this.controls,value:this.props.content,onChange:this.onChange})}onChange(){this.hasUnsavedChanges=!0}save(e,t){this.hasUnsavedChanges=!1,this.props.save&&this.props.save(t)}openNative(){this.props.openNative&&this.props.openNative()}}class se{static get width(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)}static get height(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}}class ne extends O.Component{render(){return O.createElement("svg",{viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},O.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},O.createElement("path",{d:"M0 0h12v12H0"}),O.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 ie extends O.Component{render(){const e=this.props.size||"24px";return O.createElement("svg",{className:this.props.className||"",fill:"#FFFFFF",viewBox:"0 0 24 24",style:{width:e,height:e},onClick:this.props.onClick},O.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),O.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}))}}class oe extends O.Component{constructor(e){super(e),this.state={modalOpen:!1},this.offX=0,this.offY=0,this.maxX=this.props.maxX||se.width,this.maxY=this.props.maxY||se.height,this.minX=this.props.minX||0,this.minY=this.props.minY||0,this.titlebar=O.createRef(),this.window=O.createRef(),this.close=this.close.bind(this),this.maximize=this.maximize.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragStart=this.onDragStart.bind(this),this.onDragStop=this.onDragStop.bind(this),this.onResizeStart=this.onResizeStart.bind(this)}componentDidMount(){this.window.current.addEventListener("mousedown",this.onResizeStart,!1),this.titlebar.current.addEventListener("mousedown",this.onDragStart,!1),document.addEventListener("mouseup",this.onDragStop,!1)}onResizeStart(){this.currentWidth=this.window.current.offsetWidth,this.currentHeight=this.window.current.offsetHeight}onDragStop(){document.removeEventListener("mousemove",this.onDrag,!0);const e=this.window.current.offsetWidth,t=this.window.current.offsetHeight;if(e!=this.currentWidth||t!=this.currentHeight){this.props.onResize&&this.props.onResize();const s=parseInt(this.window.current.style.left),n=parseInt(this.window.current.style.top);s+e>=this.maxX&&(this.window.current.style.width=this.maxX-s+"px"),n+t>=this.maxY&&(this.window.current.style.height=this.maxY-n+"px")}this.currentWidth=e,this.currentHeight=t}onDragStart(e){const t=this.window.current;this.offY=e.clientY-parseInt(t.offsetTop),this.offX=e.clientX-parseInt(t.offsetLeft),document.addEventListener("mousemove",this.onDrag,!0)}onDrag(e){const t=this.window.current;let s=e.clientY-this.offY;s<=this.minY&&(s=this.minY),s+this.currentHeight>=this.maxY&&(s=this.maxY-this.currentHeight);let n=e.clientX-this.offX;n<=this.minX&&(n=this.minX),n+this.currentWidth>=this.maxX&&(n=this.maxX-this.currentWidth),t.style.top=s+"px",t.style.left=n+"px"}componentWillUnmount(){this.titlebar.current.removeEventListener("mousedown",this.onDragStart,!1),document.removeEventListener("mouseup",this.onDragStop,!1)}render(){const e=this.props.center?se.height/2-this.props.height/2:this.props.top,t=this.props.center?se.width/2-this.props.width/2:this.props.left,s=`floating-window${" "+this.props.className||""}${this.props.resizable?" resizable":""}${this.state.modalOpen?" modal-open":""}`,n={height:this.props.height,width:this.props.width,left:t||0,top:e||0};return O.createElement("div",{id:this.props.id,className:s,ref:this.window,style:n},O.createElement("div",{className:"floating-window-titlebar",ref:this.titlebar},O.createElement("span",{className:"title"},this.props.title),O.createElement("div",{className:"floating-window-buttons"},O.createElement("div",{className:"button maximize-button",onClick:this.maximize},O.createElement(ie,{size:"18px"})),O.createElement("div",{className:"button close-button",onClick:this.close},O.createElement(ne,null)))),O.createElement("div",{className:"floating-window-content"},this.props.children))}maximize(){this.window.current.style.width="100%",this.window.current.style.height="100%",this.props.onResize&&this.props.onResize();const e=this.window.current.offsetWidth,t=this.window.current.offsetHeight,s=parseInt(this.window.current.style.left)+e;parseInt(this.window.current.style.top)+t>this.maxY&&(this.window.current.style.top=this.maxY-t+"px"),s>this.maxX&&(this.window.current.style.left=this.maxX-e+"px");const n=parseInt(this.window.current.style.left),i=parseInt(this.window.current.style.top);if(i<this.minY){const e=this.minY-i;this.window.current.style.top=this.minY+"px",this.window.current.style.height=t-e+"px"}if(n<this.minX){const t=this.minX-n;this.window.current.style.left=this.minX+"px",this.window.current.style.height=e-t+"px"}}async close(){let e=!0;("function"==typeof this.props.confirmClose?this.props.confirmClose():this.props.confirmClose)&&(this.setState({modalOpen:!0}),e=await this.confirmClose(),this.setState({modalOpen:!1})),this.props.close&&e&&this.props.close()}confirmClose(){return new Promise(e=>{_.showConfirmationModal(k.Modals.confirmAction,this.props.confirmationText,{danger:!0,confirmText:k.Modals.close,onConfirm:()=>{e(!0)},onCancel:()=>{e(!1)}})})}}function re(){return(re=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}class ae extends O.Component{constructor(e){super(e),this.state={windows:[]}}get minY(){const e=h.query('#app-mount > div[class*="app-"]');return e?e.offsetTop:0}render(){return this.state.windows.map(e=>O.createElement(oe,re({},e,{close:this.close.bind(this,e.id),minY:this.minY}),e.children))}open(e){this.setState({windows:[...this.state.windows,e]})}close(e){this.setState({windows:this.state.windows.filter(t=>(t.id==e&&t.onClose&&t.onClose(),t.id!=e))})}static get id(){return"floating-windows"}static get root(){if(this._root)return this._root;const e=document.createElement("div");return e.id=this.id,document.body.append(e),this._root=e}}var le=ae;const de=g.getByProps("AppReferencePositionLayer");class ce{static initialize(){const e=O.createRef(),t=O.createElement(le,{ref:e}),s=de?O.createElement(de.AppLayerProvider().props.layerContext.Provider,{value:[document.querySelector("#app-mount > .layerContainer-yqaFcK")]},t):t,n=h.createElement('<div id="floating-windows-layer">');S.bdBody.append(n),R.render(s,n),this.ref=e}static open(e){return this.ref||this.initialize(),this.ref.current.open(e)}}const he=f.React,ue=s(1),pe=s(2),me=s(4).Module;me.globalPaths.push(ue.resolve(s(0).remote.app.getAppPath(),"node_modules"));const ge=/[^\S\r\n]*?\r?(?:\r\n|\n)[^\S\r\n]*?\*[^\S\r\n]?/,fe=/^\\@/,ye=function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e};class be{get name(){return""}get moduleExtension(){return""}get extension(){return""}get addonFolder(){return""}get language(){return""}get prefix(){return"addon"}get collection(){return"settings"}get category(){return"addons"}get id(){return"autoReload"}emit(e,...t){return E.emit(`${this.prefix}-${e}`,...t)}constructor(){this.timeCache={},this.addonList=[],this.state={}}initialize(){return this.originalRequire=me._extensions[this.moduleExtension],me._extensions[this.moduleExtension]=this.getAddonRequire(),T.on(this.collection,this.category,this.id,e=>{e?this.watchAddons():this.unwatchAddons()}),this.loadAllAddons()}initializeAddon(){}getFileModification(e,t){return t}startAddon(){}stopAddon(){}loadState(){const e=w.getData(this.prefix+"s");e&&Object.assign(this.state,e)}saveState(){w.setData(this.prefix+"s",this.state)}watchAddons(){if(this.watcher)return c.error(this.name,`Already watching ${this.prefix} addons.`);c.log(this.name,`Starting to watch ${this.prefix} addons.`),this.watcher=pe.watch(this.addonFolder,{persistent:!1},async(e,t)=>{if(e&&t&&t.endsWith(this.extension)){await new Promise(e=>setTimeout(e,100));try{const s=pe.statSync(ue.resolve(this.addonFolder,t));if(!s.isFile())return;if(!s||!s.mtime||!s.mtime.getTime())return;if("number"!=typeof s.mtime.getTime())return;if(this.timeCache[t]==s.mtime.getTime())return;this.timeCache[t]=s.mtime.getTime(),"rename"==e&&this.loadAddon(t,!0),"change"==e&&this.reloadAddon(t,!0)}catch(e){if("ENOENT"!==e.code)return;delete this.timeCache[t],this.unloadAddon(t,!0)}}})}unwatchAddons(){if(!this.watcher)return c.error(this.name,`Was not watching ${this.prefix} addons.`);this.watcher.close(),delete this.watcher,c.log(this.name,`No longer watching ${this.prefix} addons.`)}extractMeta(e){const t=e.split("\n")[0];if(t.includes("//META"))return this.parseOldMeta(e);if(t.includes("/**"))return this.parseNewMeta(e);throw new G(k.Addons.metaNotFound)}parseOldMeta(e){const t=e.split("\n")[0],s=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//")),n=u.testJSON(s);if(!n)throw new G(k.Addons.metaError);if(!n.name)throw new G(k.Addons.missingNameData);return n.format="json",n}parseNewMeta(e){const t=e.split("/**",2)[1].split("*/",1)[0],s={};let n="",i="";for(const e of t.split(ge))if(0!==e.length)if("@"===e.charAt(0)&&" "!==e.charAt(1)){s[n]=i;const t=e.indexOf(" ");n=e.substr(1,t-1),i=e.substr(t+1)}else i+=" "+e.replace("\\n","\n").replace(fe,"@");return s[n]=i.trim(),delete s[""],s.format="jsdoc",s}getAddonRequire(){const e=this,t=this.originalRequire;return function(s,n){const i=ue.resolve(e.addonFolder,ue.basename(n));if(!pe.existsSync(i)||n!==pe.realpathSync(i))return Reflect.apply(t,this,arguments);let o=pe.readFileSync(n,"utf8");o=ye(o);const r=pe.statSync(n),a=e.extractMeta(o);a.author||(a.author=k.Addons.unknownAuthor),a.version||(a.version="???"),a.description||(a.description=k.Addons.noDescription),a.id=a.name,a.filename=ue.basename(n),a.added=r.atimeMs,a.modified=r.mtimeMs,a.size=r.size,o=e.getFileModification(s,o,a),s._compile(o,n)}}loadAddon(e,t=!1){if(void 0===e)return;try{require(ue.resolve(this.addonFolder,e))}catch(n){return new W(e,e,k.Addons.compileError,{message:n.message,stack:n.stack})}const s=require(ue.resolve(this.addonFolder,e));if(this.addonList.find(e=>e.id==s.id))return new W(s.name,e,k.Addons.alreadyExists.format({type:this.prefix,name:s.name}));const n=this.initializeAddon(s);return n||(this.addonList.push(s),t&&q.success(`${s.name} v${s.version} was loaded.`),this.emit("loaded",s.id),this.state[s.id]?this.startAddon(s):this.state[s.id]=!1)}unloadAddon(e,t=!0,s=!1){const n="string"==typeof e?this.addonList.find(t=>t.id==e||t.filename==e):e;return!!n&&(this.state[n.id]&&(s?this.stopAddon(n):this.disableAddon(n)),delete require.cache[require.resolve(ue.resolve(this.addonFolder,n.filename))],this.addonList.splice(this.addonList.indexOf(n),1),this.emit("unloaded",n.id),t&&q.success(n.name+" was unloaded."),!0)}reloadAddon(e,t=!0){const s="string"==typeof e?this.addonList.find(t=>t.id==e||t.filename==e):e,n=this.unloadAddon(s,t,!0);return n?this.loadAddon(s.filename,t):n}isLoaded(e){return!!this.addonList.find(t=>t.id==e||t.filename==e)}isEnabled(e){const t=this.addonList.find(t=>t.id==e||t.filename==e);return!!t&&this.state[t.id]}getAddon(e){return this.addonList.find(t=>t.id==e||t.filename==e)}enableAddon(e){const t="string"==typeof e?this.addonList.find(t=>t.id==e):e;t&&(this.state[t.id]||(this.state[t.id]=!0,this.startAddon(t),this.saveState()))}disableAddon(e){const t="string"==typeof e?this.addonList.find(t=>t.id==e):e;t&&this.state[t.id]&&(this.state[t.id]=!1,this.stopAddon(t),this.saveState())}toggleAddon(e){this.state[e]?this.disableAddon(e):this.enableAddon(e)}loadNewAddons(){const e=pe.readdirSync(this.addonFolder),t=this.addonList.filter(t=>!e.includes(t.filename)).map(e=>e.id);return{added:e.filter(e=>!this.addonList.find(t=>t.filename==e)&&e.endsWith(this.extension)&&pe.statSync(ue.resolve(this.addonFolder,e)).isFile()),removed:t}}updateList(){const e=this.loadNewAddons();for(const t of e.added)this.loadAddon(t);for(const t of e.removed)this.unloadAddon(t)}loadAllAddons(){this.loadState();const e=[],t=pe.readdirSync(this.addonFolder);for(const s of t){if(!pe.statSync(ue.resolve(this.addonFolder,s)).isFile()||!s.endsWith(this.extension))continue;const t=this.loadAddon(s,!1);t instanceof W&&e.push(t)}return this.saveState(),T.get(this.collection,this.category,this.id)&&this.watchAddons(),e}deleteAddon(e){const t="string"==typeof e?this.addonList.find(t=>t.id==e||t.filename==e):e;return pe.unlinkSync(ue.resolve(this.addonFolder,t.filename))}saveAddon(e,t){const s="string"==typeof e?this.addonList.find(t=>t.id==e||t.filename==e):e;return pe.writeFileSync(ue.resolve(this.addonFolder,s.filename),t)}editAddon(e,t){const n="string"==typeof e?this.addonList.find(t=>t.id==e||t.filename==e):e,i=ue.resolve(this.addonFolder,n.filename);return void 0===t&&(t="system"==T.get("settings","addons","editAction")),t?s(0).shell.openItem(""+i):this.openDetached(n)}openDetached(e){const t=ue.resolve(this.addonFolder,e.filename),s=pe.readFileSync(t).toString(),n=he.createRef(),i=he.createElement(te,{id:"bd-floating-editor-"+e.name,ref:n,content:s,save:this.saveAddon.bind(this,e),openNative:this.editAddon.bind(this,e,!0),language:this.language});ce.open({onClose:()=>{this.isDetached=!1},onResize:()=>{n&&n.current&&n.current.resize&&n.current.resize()},title:e.name,id:s.id,className:"floating-addon-window",height:470,width:410,center:!0,resizable:!0,children:i,confirmClose:()=>!(!n||!n.current)&&n.current.hasUnsavedChanges,confirmationText:k.Addons.confirmationText.format({name:e.name})})}}class ve extends O.Component{render(){const e=this.props.isGroup?"bd-settings-title bd-settings-group-title h5-18_1nd title-3sZWYQ size12-3R0845 height16-2Lv3qA weightSemiBold-NJexzi da-h5 da-title da-size12 da-height16 da-weightSemiBold marginBottom4-2qk4Hy da-marginBottom4 marginTop8-1DLZ1n da-marginTop8":"bd-settings-title h2-2gWE-o title-3sZWYQ size16-14cGz5 height20-mO2eIN weightSemiBold-NJexzi defaultColor-1_ajX0 defaultMarginh2-2LTaUL marginBottom20-32qID7",t=this.props.className?`${e} ${this.props.className}`:e;return O.createElement("h2",{className:t,onClick:()=>{this.props.onClick&&this.props.onClick()}},this.props.text,this.props.button&&O.createElement("button",{className:"bd-button bd-button-title",onClick:this.props.button.onClick},this.props.button.title),this.props.otherChildren)}}class we extends O.Component{render(){const e=this.props.size||"24px";return O.createElement("svg",{className:this.props.className||"",onClick:this.props.onClick,fill:"#dcddde",viewBox:"0 0 24 24",style:{width:e,height:e}},O.createElement("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}),O.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}))}}class Se extends O.Component{render(){const e=this.props.size||"24px";return O.createElement("svg",{className:this.props.className||"",fill:"#FFFFFF",viewBox:"0 0 24 24",style:{width:e,height:e},onClick:this.props.onClick},O.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),O.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"}),O.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}))}}class Ce extends O.Component{constructor(e){super(e),this.state={checked:this.props.checked},this.onChange=this.onChange.bind(this)}onChange(){this.props.disabled||(this.props.onChange(!this.state.checked),this.setState({checked:!this.state.checked}))}render(){const e=this.props.disabled?" bd-switch-disabled":"",t=this.state.checked?" bd-switch-checked":"";return O.createElement("div",{className:"bd-switch"+e+t},O.createElement("input",{type:"checkbox",id:this.props.id,className:"bd-checkbox",disabled:this.props.disabled,checked:this.state.checked,onChange:this.onChange}))}}var Ee=s(0);class Me extends O.Component{constructor(e){super(e),this.state={hasError:!1}}componentDidCatch(){this.setState({hasError:!0})}render(){return this.state.hasError?O.createElement("div",{onClick:()=>Ee.remote.getCurrentWindow().openDevTools(),className:"react-error"},"There was an unexpected Error. Click to open console for more details."):this.props.children}}const xe=Me.prototype.render;function Ne(){return(Ne=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}Object.defineProperty(Me.prototype,"render",{enumerable:!1,configurable:!1,set:function(){c.warn("ErrorBoundary","Addon policy for plugins #5 https://github.com/rauenzi/BetterDiscordApp/wiki/Addon-Policies#plugins")},get:()=>xe});const Pe=g.getByDisplayName("Tooltip");class De extends O.Component{constructor(e){super(e),this.state={settingsOpen:!1},this.settingsPanel="",this.panelRef=O.createRef(),this.onChange=this.onChange.bind(this),this.reload=this.reload.bind(this),this.showSettings=this.showSettings.bind(this),this.closeSettings=this.closeSettings.bind(this)}reload(){this.props.reload&&(this.props.addon=this.props.reload(this.props.addon.id),this.forceUpdate())}componentDidUpdate(){this.state.settingsOpen&&(this.settingsPanel instanceof Node&&this.panelRef.current.appendChild(this.settingsPanel),setImmediate(()=>{const e=this.panelRef.current,t=e.closest(".scrollerBase-289Jih");if(!t||!((e,t)=>{const s=e.scrollTop,n=s+e.clientHeight,i=t.offsetTop,o=i+t.clientHeight;return i<s||o>n})(t,e))return;const s=h.offset(e),n=h.offset(t),i=t.scrollTop,o=s.top-n.top+t.scrollTop-30;h.animate({duration:300,update:function(e){t.scrollTop=o>i?i+e*(o-i):i-e*(i-o)}})}))}getString(e){return"string"==typeof e?e:e.toString()}onChange(){this.props.onChange&&this.props.onChange(this.props.addon.id),this.props.enabled=!this.props.enabled,this.forceUpdate()}showSettings(){this.props.hasSettings&&this.setState({settingsOpen:!0})}closeSettings(){this.settingsPanel instanceof Node&&(this.panelRef.current.innerHTML=""),this.setState({settingsOpen:!1})}buildTitle(e,t,s){const n=k.Addons.title.split(/({{[A-Za-z]+}})/),i=n.findIndex(e=>"{{name}}"==e);i&&(n[i]=O.createElement("span",{className:"bd-name"},e));const o=n.findIndex(e=>"{{version}}"==e);i&&(n[o]=O.createElement("span",{className:"bd-version"},t));const r=n.findIndex(e=>"{{author}}"==e);return i&&(n[r]=O.createElement("span",{className:"bd-author"},s)),n.flat()}get settingsComponent(){const e=this.props.addon,t=this.getString(e.name);try{this.settingsPanel=this.props.getSettingsPanel()}catch(e){c.stacktrace("Addon Settings","Unable to get settings panel for "+t+".",e)}const s={id:t+"-settings",className:"addon-settings",ref:this.panelRef};"string"==typeof this.settingsPanel&&(c.warn("Addon Settings","Using a DOMString is officially deprecated."),s.dangerouslySetInnerHTML=this.settingsPanel);let n=null;return"function"==typeof this.settingsPanel&&(n=O.createElement(this.settingsPanel,null)),this.settingsPanel.$$typeof&&this.settingsPanel.$$typeof===Symbol.for("react.element")&&(n=this.settingsPanel),O.createElement("div",{className:"bd-addon-card settings-open bd-switch-item"},O.createElement("div",{className:"bd-close",onClick:this.closeSettings},O.createElement(ne,null)),O.createElement("div",s,O.createElement(Me,null,n)))}buildLink(e){const t=this.props.addon[e];if(!t)return null;const s=O.createElement("a",{className:"bd-link bd-link-website",href:t,target:"_blank",rel:"noopener noreferrer"},k.Addons[e]);return"invite"==e&&(s.props.onClick=function(e){e.preventDefault(),e.stopPropagation();let s=t;const n=/\.gg\/(.*)$/;n.test(s)&&(s=s.match(n)[1]),f.LayerStack.popLayer(),f.InviteActions.acceptInviteAndTransitionToInviteChannel(s)}),s}get footer(){const e=["website","source","invite","donate","patreon"];if(!e.some(e=>this.props.addon[e])&&!this.props.hasSettings)return null;const t=e.map(this.buildLink.bind(this)).filter(e=>e);return O.createElement("div",{className:"bd-footer"},O.createElement("span",{className:"bd-links"},t.map((e,s)=>s<t.length-1?[e," | "]:e).flat()),this.props.hasSettings&&O.createElement("button",{onClick:this.showSettings,className:"bd-button bd-button-addon-settings",disabled:!this.props.enabled},k.Addons.addonSettings))}makeButton(e,t,s){return O.createElement(Pe,{color:"black",position:"top",text:e},e=>O.createElement("div",Ne({},e,{className:"bd-addon-button",onClick:s}),t))}render(){if(this.state.settingsOpen)return this.settingsComponent;const e=this.props.addon,t=this.getString(e.name),s=this.getString(e.author),n=this.getString(e.description),i=this.getString(e.version);return O.createElement("div",{id:e.id+"-card",className:"bd-addon-card settings-closed"},O.createElement("div",{className:"bd-addon-header"},O.createElement("span",{className:"bd-title"},this.buildTitle(t,i,s)),O.createElement("div",{className:"bd-controls"},this.props.editAddon&&this.makeButton(k.Addons.editAddon,O.createElement(X,null),this.props.editAddon),this.props.deleteAddon&&this.makeButton(k.Addons.deleteAddon,O.createElement(Se,null),this.props.deleteAddon),this.props.showReloadIcon&&this.makeButton(k.Addons.reload,O.createElement(we,{className:"bd-reload bd-reload-card"}),this.reload),O.createElement(Ce,{checked:this.props.enabled,onChange:this.onChange}))),O.createElement("div",{className:"bd-description-wrap scroller-wrap fade"},O.createElement("div",{className:"bd-description scroller"},n)),this.footer)}}const Ae=De.prototype.render;Object.defineProperty(De.prototype,"render",{enumerable:!1,configurable:!1,set:function(){c.warn("AddonCard","Addon policy for plugins #5 https://github.com/rauenzi/BetterDiscordApp/wiki/Addon-Policies#plugins")},get:()=>Ae});class ke extends O.Component{render(){const e=this.props.size||"16px";return O.createElement("svg",{className:this.props.className||"",fill:"#FFFFFF",viewBox:"0 0 24 24",style:{width:e,height:e}},O.createElement("path",{d:"M8.12 9.29L12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7c-.39-.39-.39-1.02 0-1.41.39-.38 1.03-.39 1.42 0z"}))}}class Te extends O.Component{constructor(e){super(e),this.state={open:!1,value:this.props.value||this.props.options[0].value},this.dropdown=O.createRef(),this.onChange=this.onChange.bind(this),this.showMenu=this.showMenu.bind(this),this.hideMenu=this.hideMenu.bind(this)}showMenu(e){e.preventDefault(),this.setState({open:!0},()=>{document.addEventListener("click",this.hideMenu)})}hideMenu(){this.setState({open:!1},()=>{document.removeEventListener("click",this.hideMenu)})}onChange(e){this.setState({value:e}),this.props.onChange&&this.props.onChange(e)}get selected(){return this.props.options.find(e=>e.value==this.state.value)}get options(){const e=this.selected;return O.createElement("div",{className:"bd-select-options"},this.props.options.map(t=>O.createElement("div",{className:"bd-select-option"+(e.value==t.value?" selected":""),onClick:this.onChange.bind(this,t.value)},t.label)))}render(){const e="transparent"==this.props.style?" bd-select-transparent":"",t=this.state.open?" menu-open":"";return O.createElement("div",{className:`bd-select${e}${t}`,onClick:this.showMenu,ref:this.dropdown},O.createElement("div",{className:"bd-select-value"},this.selected.label),O.createElement(ke,{className:"bd-select-arrow"}),this.state.open&&this.options)}}class Le extends O.Component{render(){const e=this.props.size||"16px";return O.createElement("svg",{className:this.props.className||"",fill:"#FFFFFF",viewBox:"0 0 24 24",style:{width:e,height:e}},O.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),O.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}))}}class je extends O.Component{render(){return O.createElement("div",{className:"bd-search-wrapper"},O.createElement("input",{onChange:this.props.onChange,onKeyDown:this.props.onKeyDown,type:"text",className:"bd-search",placeholder:this.props.placeholder,maxLength:"50"}),O.createElement(Le,null))}}class Be extends O.Component{constructor(e){super(e),this.state={sort:"name",ascending:!0,query:""},this.sort=this.sort.bind(this),this.reverse=this.reverse.bind(this),this.search=this.search.bind(this),this.update=this.update.bind(this)}componentDidMount(){E.on(this.props.prefix+"-loaded",this.update),E.on(this.props.prefix+"-unloaded",this.update)}componentWillUnmount(){E.off(this.props.prefix+"-loaded",this.update),E.off(this.props.prefix+"-unloaded",this.update)}update(){this.forceUpdate()}reload(){this.props.refreshList&&this.props.refreshList(),this.forceUpdate()}reverse(e){this.setState({ascending:e})}sort(e){this.setState({sort:e})}search(e){this.setState({query:e.target.value.toLocaleLowerCase()})}get sortOptions(){return[{label:k.Addons.name,value:"name"},{label:k.Addons.author,value:"author"},{label:k.Addons.version,value:"version"},{label:k.Addons.added,value:"added"},{label:k.Addons.modified,value:"modified"}]}get directions(){return[{label:k.Sorting.ascending,value:!0},{label:k.Sorting.descending,value:!1}]}render(){const{title:e,folder:t,addonList:n,addonState:i,onChange:o,reload:r}=this.props,a=!T.get("settings","addons","autoReload"),l=t?{title:k.Addons.openFolder.format({type:e}),onClick:()=>{const e=s(0).shell;(e.openItem||e.openPath)(t)}}:null,d=n.sort((e,t)=>{const s=e[this.state.sort],n=t[this.state.sort];return"string"==typeof s?s.toLocaleLowerCase().localeCompare(n.toLocaleLowerCase()):s>n?1:n>s?-1:0});return this.state.ascending||d.reverse(),[O.createElement(ve,{key:"title",text:e,button:l,otherChildren:a&&O.createElement(we,{className:"bd-reload",onClick:this.reload.bind(this)})}),O.createElement("div",{className:"bd-controls bd-addon-controls"},O.createElement(je,{onChange:this.search,placeholder:k.Addons.search.format({type:this.props.title})+"..."}),O.createElement("div",{className:"bd-addon-dropdowns"},O.createElement("div",{className:"bd-select-wrapper"},O.createElement("label",{className:"bd-label"},k.Sorting.sortBy,":"),O.createElement(Te,{options:this.sortOptions,onChange:this.sort,style:"transparent"})),O.createElement("div",{className:"bd-select-wrapper"},O.createElement("label",{className:"bd-label"},k.Sorting.order,":"),O.createElement(Te,{options:this.directions,onChange:this.reverse,style:"transparent"})))),O.createElement("div",{key:"addonList",className:"bd-addon-list"},d.map(e=>{if(this.state.query){let t=e.name.toLocaleLowerCase().includes(this.state.query);if(t=t||e.author.toLocaleLowerCase().includes(this.state.query),t=t||e.description.toLocaleLowerCase().includes(this.state.query),!t)return null}const t=e.type&&"function"==typeof e.plugin.getSettingsPanel,s=t&&e.plugin.getSettingsPanel.bind(e.plugin);return O.createElement(Me,null,O.createElement(De,{editAddon:this.editAddon.bind(this,e.id),deleteAddon:this.deleteAddon.bind(this,e.id),showReloadIcon:a,key:e.id,enabled:i[e.id],addon:e,onChange:o,reload:r,hasSettings:t,getSettingsPanel:s}))}))]}editAddon(e){this.props.editAddon&&this.props.editAddon(e)}async deleteAddon(e){const t=this.props.addonList.find(t=>t.id==e);await this.confirmDelete(t)&&this.props.deleteAddon&&this.props.deleteAddon(t)}confirmDelete(e){return new Promise(t=>{_.showConfirmationModal(k.Modals.confirmAction,k.Addons.confirmDelete.format({name:e.name}),{danger:!0,confirmText:k.Addons.deleteAddon,onConfirm:()=>{t(!0)},onCancel:()=>{t(!1)}})})}}const Ie=Be.prototype.render;Object.defineProperty(Be.prototype,"render",{enumerable:!1,configurable:!1,set:function(){c.warn("AddonList","Addon policy for plugins #5 https://github.com/rauenzi/BetterDiscordApp/wiki/Addon-Policies#plugins")},get:()=>Ie});class ze extends O.Component{render(){return O.createElement("div",{className:"bd-divider divider-3573oO marginTop8-1DLZ1n marginBottom40-2vIwTv"})}}class Fe extends O.Component{render(){return O.createElement("div",{className:"bd-setting-item"},O.createElement("div",{className:"bd-setting-header"},O.createElement("label",{htmlFor:this.props.id,className:"bd-setting-title"},this.props.name),this.props.children),O.createElement("div",{className:"bd-setting-note"},this.props.note),O.createElement("div",{className:"bd-setting-divider"}))}}class Oe extends O.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=O.createRef(),this.state={collapsed:this.props.collapsible&&!this.props.shown},this.onChange=this.onChange.bind(this),this.toggleCollapse=this.toggleCollapse.bind(this)}toggleCollapse(){const e=this.container.current,t=this.state.collapsed?300:1;e.style.setProperty("height",e.scrollHeight+"px"),e.classList.add("animating"),this.setState({collapsed:!this.state.collapsed},()=>setTimeout(()=>{e.style.setProperty("height",""),e.classList.remove("animating")},t)),this.props.onDrawerToggle&&this.props.onDrawerToggle(this.state.collapsed)}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="bd-settings-group "+(this.props.collapsible?"collapsible "+(this.state.collapsed?"collapsed":"expanded"):"");return O.createElement("div",{className:t},O.createElement(ve,{text:this.props.name,collapsible:this.props.collapsible,onClick:this.toggleCollapse,button:this.props.button,isGroup:!0}),O.createElement("div",{className:"bd-settings-container",ref:this.container},e.filter(e=>!e.hidden).map(e=>{let t=null;return"dropdown"==e.type&&(t=O.createElement(Te,{disabled:e.disabled,id:e.id,options:e.options,value:e.value,onChange:this.onChange.bind(this,e.id)})),"switch"==e.type&&(t=O.createElement(Ce,{disabled:e.disabled,id:e.id,checked:e.value,onChange:this.onChange.bind(this,e.id)})),t?O.createElement(Fe,{id:e.id,key:e.id,name:e.name,note:e.note},t):null})),this.props.showDivider&&O.createElement(ze,null))}}const Re=Oe.prototype.render;Object.defineProperty(Oe.prototype,"render",{enumerable:!1,configurable:!1,set:function(){c.warn("Group","Addon policy for plugins #5 https://github.com/rauenzi/BetterDiscordApp/wiki/Addon-Policies#plugins")},get:()=>Re});class Ue extends O.Component{render(){const e=this.props.size||"18px";return O.createElement("svg",{viewBox:"0 0 24 24",fill:"#FFFFFF",className:this.props.className||"",style:{width:e,height:e},onClick:this.props.onClick},O.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),O.createElement("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"}))}}function He(){return(He=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}const qe=g.getModule(e=>e.Header&&e.Separator&&e.Item),_e=g.getByDisplayName("Tooltip");class We extends O.Component{render(){return O.createElement("div",{className:"bd-sidebar-header"},O.createElement(qe.Header,null,"BandagedBD"),O.createElement(_e,{color:"black",position:"top",text:"Changelog"},e=>O.createElement("div",He({},e,{className:"bd-changelog-button",onClick:()=>_.showChangelogModal(l)}),O.createElement(Ue,{className:"bd-icon",size:"16px"}))))}}var Ge=new class{constructor(){this.patchSections(),E.on("strings-updated",this.forceUpdate)}onDrawerToggle(e,t,s){const n=w.getBDData("drawerStates")||{};n[e]||(n[e]={}),n[e][t]=s,w.setBDData("drawerStates",n)}getDrawerState(e,t,s){const n=w.getBDData("drawerStates")||{};return n[e]&&n[e].hasOwnProperty(t)?n[e][t]:s}onChange(e){return(t,s,n)=>{const i=T.collections.length+T.panels.length;e(t,s,n);i!=T.collections.length+T.panels.length&&setTimeout(this.forceUpdate.bind(this),50)}}buildSettingsPanel(e,t,s,n,i,o=null){return s.forEach(e=>{e.settings.forEach(t=>t.value=n[e.id][t.id])}),this.getSettingsPanel(e,t,s,this.onChange(i),o)}getSettingsPanel(e,t,s,n,i=null){return[O.createElement(ve,{text:t,button:i}),s.map(t=>O.createElement(Oe,Object.assign({},t,{onChange:n,onDrawerToggle:s=>this.onDrawerToggle(e,t.id,s),shown:this.getDrawerState(e,t.id,!t.hasOwnProperty("shown")||t.shown)})))]}getAddonPanel(e,t,s,n={}){return O.createElement(Be,Object.assign({},{title:e,addonList:t,addonState:s},n))}async patchSections(){const e=await F.get("UserSettings",e=>e.prototype&&e.prototype.generateSections);L.after("SettingsManager",e.prototype,"render",e=>{e._reactInternalFiber.return.return.return.return.return.return.return.memoizedProps.id="user-settings"}),L.after("SettingsManager",e.prototype,"generateSections",(e,t,s)=>{let n=s.findIndex(e=>"linux"==e.section.toLowerCase())+1;const i=e=>{s.splice(n,0,e),n++};i({section:"DIVIDER"}),i({section:"CUSTOM",element:We});for(const e of T.collections)e.disabled||i({section:e.name,label:e.name,element:()=>this.buildSettingsPanel(e.id,e.name,e.settings,T.state[e.id],T.onSettingChange.bind(T,e.id),e.button?e.button:null)});for(const t of T.panels.sort((e,t)=>e.order>t.order))t.clickListener&&(t.onClick=n=>t.clickListener(e,n,s)),i(t)}),this.forceUpdate()}forceUpdate(){const e=g.getByProps("standardSidebarView").standardSidebarView.split(" ")[0],t=document.querySelector("."+e);if(!t)return;const s=u.findInReactTree(u.getReactInstance(t),e=>e&&e.generateSections,{walkable:["return","stateNode"]});s&&s.forceUpdate()}};const $e=s(1),Qe=s(0).remote;var Ve=new class extends be{get name(){return"PluginManager"}get moduleExtension(){return".js"}get extension(){return".plugin.js"}get addonFolder(){return $e.resolve(i.dataPath,"plugins")}get prefix(){return"plugin"}get language(){return"javascript"}constructor(){super(),this.onSwitch=this.onSwitch.bind(this),this.observer=new MutationObserver(e=>{for(let t=0,s=e.length;t<s;t++)this.onMutation(e[t])})}initialize(){const e=super.initialize();return this.setupFunctions(),T.registerPanel("plugins",k.Panels.plugins,{element:()=>Ge.getAddonPanel(k.Panels.plugins,this.addonList,this.state,{folder:this.addonFolder,onChange:this.togglePlugin.bind(this),reload:this.reloadPlugin.bind(this),refreshList:this.updatePluginList.bind(this),saveAddon:this.saveAddon.bind(this),editAddon:this.editAddon.bind(this),deleteAddon:this.deleteAddon.bind(this),prefix:this.prefix})}),e}updatePluginList(){return this.updateList()}loadAllPlugins(){return this.loadAllAddons()}enablePlugin(e){return this.enableAddon(e)}disablePlugin(e){return this.disableAddon(e)}togglePlugin(e){return this.toggleAddon(e)}unloadPlugin(e){return this.unloadAddon(e)}loadPlugin(e){const t=this.loadAddon(e);t&&_.showAddonErrors({themes:[t]})}reloadPlugin(e){const t=this.reloadAddon(e);return t&&_.showAddonErrors({plugins:[t]}),"string"==typeof e?this.addonList.find(t=>t.id==e||t.filename==e):e}initializeAddon(e){if(!e.type)return new W(e.name,e.filename,"Plugin had no exports",{message:"Plugin had no exports or no name property.",stack:""});try{const t=new(0,e.type);e.plugin=t,e.name=t.getName()||e.name,e.author=t.getAuthor()||e.author||"No author",e.description=t.getDescription()||e.description||"No description",e.version=t.getVersion()||e.version||"No version";try{"function"==typeof e.plugin.load&&e.plugin.load()}catch(t){return this.state[e.id]=!1,new W(e.name,e.filename,"load() could not be fired.",{message:t.message,stack:t.stack})}}catch(t){return new W(e.name,e.filename,"Could not be constructed.",{message:t.message,stack:t.stack})}}getFileModification(e,t,s){e._compile(t,e.filename);return u.isEmpty(e.exports)?(c.warn(this.name,s.name+", please start assigning module.exports"),t+=`\nmodule.exports = ${JSON.stringify(s)};\nmodule.exports.type = ${s.exports||s.name};`):(s.type=e.exports,e.exports=s,"")}startAddon(e){return this.startPlugin(e)}stopAddon(e){return this.stopPlugin(e)}getAddon(e){return this.getPlugin(e)}startPlugin(e){const t="string"==typeof e?this.addonList.find(t=>t.id==e):e;if(!t)return;const s=t.plugin;try{s.start()}catch(e){return this.state[t.id]=!1,q.error(k.Addons.couldNotStart.format({name:t.name,version:t.version})),c.stacktrace(this.name,t.name+" could not be started.",e),new W(t.name,t.filename,k.Addons.enabled.format({method:"start()"}),{message:e.message,stack:e.stack})}this.emit("started",t.id),q.show(k.Addons.enabled.format({name:t.name,version:t.version}))}stopPlugin(e){const t="string"==typeof e?this.addonList.find(t=>t.id==e):e;if(!t)return;const s=t.plugin;try{s.stop()}catch(e){return this.state[t.id]=!1,q.error(k.Addons.couldNotStop.format({name:t.name,version:t.version})),c.stacktrace(this.name,t.name+" could not be stopped.",e),new W(t.name,t.filename,k.Addons.enabled.format({method:"stop()"}),{message:e.message,stack:e.stack})}this.emit("stopped",t.id),q.show(k.Addons.disabled.format({name:t.name,version:t.version}))}getPlugin(e){const t=this.addonList.find(t=>t.id==e||t.filename==e);if(t)return t.plugin}setupFunctions(){Qe.getCurrentWebContents().on("did-navigate-in-page",this.onSwitch.bind(this)),this.observer.observe(document,{childList:!0,subtree:!0})}onSwitch(){this.emit("page-switch");for(let e=0;e<this.addonList.length;e++){const t=this.addonList[e].plugin;if(this.state[this.addonList[e].id]&&"function"==typeof t.onSwitch)try{t.onSwitch()}catch(t){c.stacktrace(this.name,"Unable to fire onSwitch for "+this.addonList[e].name+".",t)}}}onMutation(e){for(let t=0;t<this.addonList.length;t++){const s=this.addonList[t].plugin;if(this.state[this.addonList[t].id]&&"function"==typeof s.observer)try{s.observer(e)}catch(e){c.stacktrace(this.name,"Unable to fire observer for "+this.addonList[t].name+".",e)}}}};const Ze=s(1);var Ye=new class extends be{get name(){return"ThemeManager"}get moduleExtension(){return".css"}get extension(){return".theme.css"}get addonFolder(){return Ze.resolve(i.dataPath,"themes")}get prefix(){return"theme"}get language(){return"css"}initialize(){const e=super.initialize();return T.registerPanel("themes",k.Panels.themes,{element:()=>Ge.getAddonPanel(k.Panels.themes,this.addonList,this.state,{folder:this.addonFolder,onChange:this.toggleTheme.bind(this),reload:this.reloadTheme.bind(this),refreshList:this.updateThemeList.bind(this),saveAddon:this.saveAddon.bind(this),editAddon:this.editAddon.bind(this),deleteAddon:this.deleteAddon.bind(this),prefix:this.prefix})}),e}updateThemeList(){return this.updateList()}loadAllThemes(){return this.loadAllAddons()}enableTheme(e){return this.enableAddon(e)}disableTheme(e){return this.disableAddon(e)}toggleTheme(e){return this.toggleAddon(e)}unloadTheme(e){return this.unloadAddon(e)}loadTheme(e){const t=this.loadAddon(e);t&&_.showAddonErrors({themes:[t]})}reloadTheme(e){const t=this.reloadAddon(e);t&&_.showAddonErrors({themes:[t]})}getFileModification(e,t,s){return s.css=t,`module.exports = ${JSON.stringify(s)};`}startAddon(e){return this.addTheme(e)}stopAddon(e){return this.removeTheme(e)}addTheme(e){const t="string"==typeof e?this.addonList.find(t=>t.id==e):e;t&&(S.injectTheme(t.id,t.css),q.show(k.Addons.enabled.format({name:t.name,version:t.version})))}removeTheme(e){const t="string"==typeof e?this.addonList.find(t=>t.id==e):e;t&&(S.removeTheme(t.id),q.show(k.Addons.disabled.format({name:t.name,version:t.version})))}};class Je{get name(){return"Unnamed Builtin"}get collection(){return"settings"}get category(){return"general"}get id(){return"None"}async initialize(){T.get(this.collection,this.category,this.id)&&await this.enable(),E.on("setting-updated",(e,t,s,n)=>{e==this.collection&&t===this.category&&s===this.id&&(n?this.enable():this.disable())}),this.initialized=!0}registerSetting(e,t,s,n,i){return 4==arguments.length?(e=this.collection,t=arguments[0],s=arguments[1],n=arguments[2],i=arguments[3]):3==arguments.length&&(e=this.collection,t=this.category,s=arguments[0],n=arguments[1],i=arguments[2]),T.on(e,t,s,e=>{e?n():i()})}get(e,t,s){return 2==arguments.length?(e=this.collection,t=arguments[0],s=arguments[1]):1==arguments.length&&(e=this.collection,t=this.category,s=arguments[0]),T.get(e,t,s)}async enable(){this.log("Enabled");try{await this.enabled()}catch(e){this.stacktrace("Could not be enabled",e)}}async disable(){this.log("Disabled");try{await this.disabled()}catch(e){this.stacktrace("Could not be disabled",e)}}async enabled(){}async disabled(){}log(...e){c.log(this.name,...e)}warn(...e){c.warn(this.name,...e)}error(...e){c.err(this.name,...e)}stacktrace(e,t){c.stacktrace(this.name,e,t)}before(e,t,s){return L.before(this.name,e,t,s)}after(e,t,s){return L.after(this.name,e,t,s)}unpatchAll(){return L.unpatchAll(this.name)}}const Ke=g.getByDisplayName("Tooltip");class Xe extends O.Component{constructor(e){super(e),this.state={shouldAnimate:!this.animateOnHover,isFavorite:this.props.isFavorite},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onClick=this.onClick.bind(this),this.toggleFavorite=this.toggleFavorite.bind(this)}get animateOnHover(){return T.get("emotes","general","animateOnHover")}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})}onMouseLeave(){this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!1})}onClick(e){this.props.onClick&&this.props.onClick(e)}toggleFavorite(e){e.preventDefault(),e.stopPropagation(),this.state.isFavorite?E.emit("emotes-favorite-removed",this.label):E.emit("emotes-favorite-added",this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}render(){return O.createElement(Ke,{color:"black",position:"top",text:this.label,delay:750},e=>O.createElement("div",Object.assign({className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},e),O.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}),O.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:k.Emotes.favoriteAction,type:"button",onClick:this.toggleFavorite})))}}const et=s(3),tt={TwitchGlobal:new A("https://static-cdn.jtvnw.net/emoticons/v1/{{id}}/1.0"),TwitchSubscriber:new A("https://static-cdn.jtvnw.net/emoticons/v1/{{id}}/1.0"),FrankerFaceZ:new A("https://cdn.frankerfacez.com/emoticon/{{id}}/1"),BTTV:new A("https://cdn.betterttv.net/emote/{{id}}/1x")},st={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{}},nt=[],it=["twitch","subscriber","bttv","ffz"],ot=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"];var rt=new class extends Je{get name(){return"Emotes"}get collection(){return"settings"}get category(){return"general"}get id(){return"emotes"}get categories(){return Object.keys(st).filter(e=>this.isCategoryEnabled(e))}get shouldDownload(){return T.get("emotes",this.category,"download")}isCategoryEnabled(e){return super.get("emotes","categories",e.toLowerCase())}get(e){return super.get("emotes","general",e)}get MessageComponent(){return g.find(e=>e.default&&e.default.displayName&&"Message"==e.default.displayName)}get Emotes(){return st}get TwitchGlobal(){return st.TwitchGlobal}get TwitchSubscriber(){return st.TwitchSubscriber}get BTTV(){return st.BTTV}get FrankerFaceZ(){return st.FrankerFaceZ}get blocklist(){return nt}get favorites(){return this.favoriteEmotes}getUrl(e,t){return tt[e].format({id:st[e][t]})}getCategory(e){return st[e]}getRemoteFile(e){return u.repoUrl(`assets/emotes/${e.toLowerCase()}.json`)}initialize(){super.initialize();const e=w.getBDData("favoriteEmotes");this.favoriteEmotes=e||{},this.addFavorite=this.addFavorite.bind(this),this.removeFavorite=this.removeFavorite.bind(this),this.onCategoryToggle=this.onCategoryToggle.bind(this),this.resetEmotes=this.resetEmotes.bind(this)}async enabled(){T.registerCollection("emotes","Emotes",o,{title:k.Emotes.clearEmotes,onClick:this.resetEmotes}),await this.getBlocklist(),await this.loadEmoteData(),E.on("emotes-favorite-added",this.addFavorite),E.on("emotes-favorite-removed",this.removeFavorite),E.on("setting-updated",this.onCategoryToggle),this.patchMessageContent()}disabled(){E.off("setting-updated",this.onCategoryToggle),E.off("emotes-favorite-added",this.addFavorite),E.off("emotes-favorite-removed",this.removeFavorite),T.removeCollection("emotes"),this.emptyEmotes(),this.cancelEmoteRender&&(this.cancelEmoteRender(),delete this.cancelEmoteRender)}onCategoryToggle(e,t,s,n){if("emotes"==e&&"categories"==t)return n?this.loadEmoteData(s):this.unloadEmoteData(s)}addFavorite(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.saveFavorites()}removeFavorite(e){this.favoriteEmotes.hasOwnProperty(e)&&(delete this.favoriteEmotes[e],this.saveFavorites())}isFavorite(e){return this.favoriteEmotes.hasOwnProperty(e)}saveFavorites(){w.setBDData("favoriteEmotes",this.favoriteEmotes)}emptyEmotes(){for(const e in st)Object.assign(st,{[e]:{}})}patchMessageContent(){this.cancelEmoteRender||(this.cancelEmoteRender=this.before(this.MessageComponent,"default",(e,t)=>{const s=t[0].childrenMessageContent.props.content;if(!s||!s.length)return;for(let e=0;e<s.length;e++){const t=s[e];if("string"!=typeof t)continue;const n=t.split(/([^\s]+)([\s]|$)/g);for(let t=0,i=this.categories.length;t<i;t++)for(let i=0,o=n.length;i<o;i++){const o=n[i].split(":"),r=o[0];let a=o[1]?o[1]:"",l=a.slice(0);if(r.length<4||nt.includes(r))continue;ot.includes(a)&&T.get("emotes","general","modifiers")||(a=""),it.includes(l)?a=l:l="";let d=this.categories[t];if("twitch"===l?st.TwitchGlobal[r]?d="TwitchGlobal":st.TwitchSubscriber[r]&&(d="TwitchSubscriber"):"subscriber"===l?st.TwitchSubscriber[r]&&(d="TwitchSubscriber"):"bttv"===l?st.BTTV[r]&&(d="BTTV"):"ffz"===l&&st.FrankerFaceZ[r]&&(d="FrankerFaceZ"),!st[d][r])continue;const c=s[e].match(new RegExp(`([\\s]|^)${u.escape(a?r+":"+a:r)}([\\s]|$)`));if(!c)continue;const h=s[e].substring(0,c.index+c[1].length),p=s[e].substring(c.index+c[0].length-c[2].length);s[e]=h;const m=f.React.createElement(Xe,{name:r,url:tt[d].format({id:st[d][r]}),modifier:a,isFavorite:this.isFavorite(r)});s.splice(e+1,0,p),s.splice(e+1,0,m)}}if(s.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 s)"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 getBlocklist(){try{const e="Blocklist",t=w.emotesExist(e),s=await this.isCacheValid(e),n=s||!s&&t&&!this.shouldDownload?w.getEmoteData(e):await this.downloadEmotes(e);nt.push(...n)}catch(e){}}isCacheValid(e){return new Promise(t=>{const s=w.getCacheHash("emotes",e);if(!s)return t(!1);et.head({url:this.getRemoteFile(e),headers:{"If-None-Match":s}},(e,s)=>{t(!e&&304==s.statusCode)})})}async loadEmoteData(e){e||(e=this.categories),Array.isArray(e)||(e=[e]);const t=Object.keys(st);e=e.map(e=>t.find(t=>t.toLowerCase()==e.toLowerCase())),q.show(k.Emotes.loading,{type:"info"}),this.emotesLoaded=!1;for(const t of e){const e=w.emotesExist(t),s=await this.isCacheValid(t);let n=null;if(s||!s&&e&&!this.shouldDownload){this.log(`Loading ${t} emotes from local cache.`);const e=w.getEmoteData(t);Object.keys(e).length>0&&(n=e)}n||(n=await this.downloadEmotes(t)),Object.assign(st[t],n),await new Promise(e=>setTimeout(e,1e3))}this.emotesLoaded=!0,E.dispatch("emotes-loaded"),q.show(k.Emotes.loaded,{type:"success"})}unloadEmoteData(e){e||(e=this.categories),Array.isArray(e)||(e=[e]);const t=Object.keys(st);e=e.map(e=>t.find(t=>t.toLowerCase()==e.toLowerCase()));for(const t of e)delete st[t],st[t]={}}downloadEmotes(e){const t=this.getRemoteFile(e);this.log(`Downloading ${e} from ${t}`);const s={url:t,timeout:1e4,json:!0};return new Promise(t=>{et.get(s,(s,n,i)=>{if(s||200!=n.statusCode)return this.stacktrace(`Could not download ${e} emotes.`,s),t({});for(const e in i)(e.length<4||nt.includes(e)||!i[e])&&delete i[e];w.saveEmoteData(e,i),w.setCacheHash("emotes",e,n.headers.etag),t(i),this.log("Downloaded "+e)})})}resetEmotes(){const e=Object.keys(st);this.unloadEmoteData(e);for(const t of e)w.invalidateCache("emotes",t);this.loadEmoteData()}};const at={get React(){return f.React},get ReactDOM(){return f.ReactDOM},get WindowConfigFile(){return""},get settings(){return T.collections},get emotes(){return new Proxy(rt.Emotes,{get:()=>rt.Emotes,set(){c.warn("BdApi.emotes","Addon policy for plugins #5 https://github.com/rauenzi/BetterDiscordApp/wiki/Addon-Policies#plugins")}})},get version(){return i.version},getAllWindowPreferences:function(){return w.getData("windowprefs")||{}},getWindowPreference:function(e){return this.getAllWindowPreferences()[e]},setWindowPreference:function(e,t){const s=this.getAllWindowPreferences();return s[e]=t,w.setData("windowprefs",s)},injectCSS:function(e,t){S.injectStyle(e,t)},clearCSS:function(e){S.removeStyle(e)},linkJS:function(e,t){return S.injectScript(e,t)},unlinkJS:function(e){S.removeScript(e)},alert:function(e,t){_.alert(e,t)},showConfirmationModal:function(e,t,s={}){return _.showConfirmationModal(e,t,s)},showToast:function(e,t={}){q.show(e,t)},findModule:function(e){return g.getModule(e)},findAllModules:function(e){return g.getModule(e,!1)},findModuleByProps:function(...e){return g.getByProps(...e)},findModuleByPrototypes:function(...e){return g.getByPrototypes(...e)},findModuleByDisplayName:function(e){return g.getByDisplayName(e)},getInternalInstance:function(e){if(e instanceof window.jQuery||e instanceof Element)return e instanceof jQuery&&(e=e[0]),u.getReactInstance(e)},loadData:function(e,t){return w.getPluginData(e,t)}};at.getData=at.loadData,at.saveData=function(e,t,s){return w.setPluginData(e,t,s)},at.setData=at.saveData,at.deleteData=function(e,t){return w.deletePluginData(e,t)},at.monkeyPatch=function(e,t,s){const{before:n,after:i,instead:o,once:r=!1}=s,a=n?"before":i?"after":o?"instead":"";if(!a)return c.err("BdApi","Must provide one of: after, before, instead");const l={originalMethod:e[t],callOriginalMethod:()=>l.originalMethod.apply(l.thisObject,l.methodArguments)};l.cancelPatch=L[a]("BdApi",e,t,(e,t,n)=>{l.thisObject=e,l.methodArguments=t,l.returnValue=n;try{Reflect.apply(s[a],null,[l]),r&&l.cancelPatch()}catch(e){}})},at.onRemoved=function(e,t){return u.onRemoved(e,t)},at.suppressErrors=function(e,t){return u.suppressErrors(e,t)},at.testJSON=function(e){return u.testJSON(e)},at.getPlugin=function(e){return c.warn("BdApi","getPlugin is deprecated. Please make use of the addon api (BdApi.Plugins)"),Ve.addonList.find(t=>t.name==e)},at.isPluginEnabled=function(e){c.warn("BdApi","isPluginEnabled is deprecated. Please make use of the addon api (BdApi.Plugins)");const t=this.getPlugin(e);return!!t&&Ve.isEnabled(t.id)},at.isThemeEnabled=function(e){c.warn("BdApi","isThemeEnabled is deprecated. Please make use of the addon api (BdApi.Themes)");const t=Ye.addonList.find(t=>t.name==e);return!!t&&Ye.isEnabled(t.id)},at.isSettingEnabled=function(e,t,s){return T.get(e,t,s)},at.enableSetting=function(e,t,s){return T.set(e,t,s,!0)},at.disableSetting=function(e,t,s){return T.set(e,t,s,!1)},at.toggleSetting=function(e,t,s){return T.set(e,t,s,!T.get(e,t,s))},at.getBDData=function(e){return w.getBDData(e)},at.setBDData=function(e,t){return w.setBDData(e,t)};const lt=e=>new class{get folder(){return e.addonFolder}isEnabled(t){return e.isEnabled(t)}enable(t){return e.enableAddon(t)}disable(t){return e.disableAddon(t)}toggle(t){return e.toggleAddon(t)}reload(t){return e.reloadAddon(t)}get(t){return e.getAddon(t)}getAll(){return e.addonList.map(t=>e.getAddon(t.id))}};at.Plugins=lt(Ve),at.Themes=lt(Ye),at.Patcher={patch:(e,t,s,n,i={})=>"string"!=typeof e?c.err("BdApi.Patcher","Parameter 0 of patch must be a string representing the caller"):"before"!==i.type&&"instead"!==i.type&&"after"!==i.type?c.err("BdApi.Patcher","options.type must be one of: before, instead, after"):L.pushChildPatch(e,t,s,n,i),before:(e,t,s,n,i={})=>at.Patcher.patch(e,t,s,n,Object.assign(i,{type:"before"})),instead:(e,t,s,n,i={})=>at.Patcher.patch(e,t,s,n,Object.assign(i,{type:"instead"})),after:(e,t,s,n,i={})=>at.Patcher.patch(e,t,s,n,Object.assign(i,{type:"after"})),unpatchAll:e=>"string"!=typeof e?c.err("BdApi.Patcher","Parameter 0 of unpatchAll must be a string representing the caller"):L.unpatchAll(e)},Object.freeze(at),Object.freeze(at.Plugins),Object.freeze(at.Themes),Object.freeze(at.Patcher);var dt=at;const ct=document.createElement("style");ct.textContent="/* BEGIN V2 LOADER */\n/* =============== */\n\n#bd-loading-icon {\n background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+IDwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBoZWlnaHQ9IjEwMCUiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmQ7IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMjAwMCAyMDAwIj4gICAgPG1ldGFkYXRhIC8+ICAgIDxkZWZzPiAgICAgICAgPGZpbHRlciBpZD0ic2hhZG93MSI+ICAgICAgICA8ZmVEcm9wU2hhZG93IGR4PSIyMCIgZHk9IjAiIHN0ZERldmlhdGlvbj0iMjAiIGZsb29kLWNvbG9yPSJyZ2JhKDAsMCwwLDAuMzUpIi8+ICAgICAgICA8L2ZpbHRlcj4gICAgICAgIDxmaWx0ZXIgaWQ9InNoYWRvdzIiPiAgICAgICAgPGZlRHJvcFNoYWRvdyBkeD0iMTUiIGR5PSIwIiBzdGREZXZpYXRpb249IjIwIiBmbG9vZC1jb2xvcj0icmdiYSgyNTUsMjU1LDI1NSwwLjE1KSIvPiAgICAgICAgPC9maWx0ZXI+ICAgICAgICA8ZmlsdGVyIGlkPSJzaGFkb3czIj4gICAgICAgIDxmZURyb3BTaGFkb3cgZHg9IjEwIiBkeT0iMCIgc3RkRGV2aWF0aW9uPSIyMCIgZmxvb2QtY29sb3I9InJnYmEoMCwwLDAsMC4zNSkiLz4gICAgICAgIDwvZmlsdGVyPiAgICA8L2RlZnM+ICAgIDxnPiAgICAgICAgPHBhdGggc3R5bGU9ImZpbHRlcjogdXJsKCNzaGFkb3czKSIgZD0iTTExOTUuNDQrMTM1LjQ0MkwxMTk1LjQ0KzEzNS40NDJMOTk3LjYrMTM2LjQ0MkMxMDI0LjIrMTQ5Ljc0MisxMTcwLjM0KzE2My41NDIrMTE5My42NCsxNzkuNzQyQzEyNjQuMzQrMjI4Ljg0MisxMzE5Ljc0KzI5MS4yNDIrMTM1OC4yNCszNjUuMDQyQzEzOTguMTQrNDQxLjY0MisxNDE5Ljc0KzUzMC42NDIrMTQyMi41NCs2MjkuNjQyTDE0MjIuNTQrNjMwLjg0MkwxNDIyLjU0KzYzMi4wNDJDMTQyMi41NCs3NzMuMTQyKzE0MjIuNTQrMTIyOC4xNCsxNDIyLjU0KzEzNjkuMTRMMTQyMi41NCsxMzcwLjM0TDE0MjIuNTQrMTM3MS41NEMxNDE5Ljg0KzE0NzAuNTQrMTM5OC4yNCsxNTU5LjU0KzEzNTguMjQrMTYzNi4xNEMxMzE5Ljc0KzE3MDkuOTQrMTI2NC40NCsxNzcyLjM0KzExOTMuNjQrMTgyMS40NEMxMTcxLjA0KzE4MzcuMTQrMTAyNS43KzE4NTAuNTQrMTAwMCsxODYzLjU0TDExOTMuNTQrMTg2NC41NEMxNTM5Ljc0KzE4NjYuNDQrMTg2NC41NCsxNjkzLjM0KzE4NjQuNTQrMTI5Ni42NEwxODY0LjU0KzcxNi45NDJDMTg2Ni40NCszMTIuNDQyKzE1NDEuNjQrMTM1LjQ0MisxMTk1LjQ0KzEzNS40NDJaIiBmaWxsPSIjMTcxNzE3IiBvcGFjaXR5PSIxIi8+ICAgICAgICA8cGF0aCBzdHlsZT0iZmlsdGVyOiB1cmwoI3NoYWRvdzIpIiBkPSJNMTY5NS41NCs2MzEuNDQyQzE2ODUuODQrMjc4LjA0MisxNDA5LjM0KzEzNS40NDIrMTA1Mi45NCsxMzUuNDQyTDM2MS43NCsxMzYuNDQyTDgwMy43NCs0OTAuNDQyTDEwNjAuNzQrNDkwLjQ0MkMxMzM1LjI0KzQ5MC40NDIrMTMzNS4yNCs4MzUuMzQyKzEwNjAuNzQrODM1LjM0MkwxMDYwLjc0KzExNjQuODRDMTE1MC4yMisxMTY0Ljg0KzEyMTAuNTMrMTIwMS40OCsxMjQxLjY4KzEyNTAuODdDMTMwNi4wNysxMzUzKzEyNDUuNzYrMTUwOS42NCsxMDYwLjc0KzE1MDkuNjRMMzYxLjc0KzE4NjMuNTRMMTA1Mi45NCsxODY0LjU0QzE0MDkuMjQrMTg2NC41NCsxNjg1Ljc0KzE3MjEuOTQrMTY5NS41NCsxMzY4LjU0QzE2OTUuNTQrMTIwNS45NCsxNjUxLjA0KzEwODQuNDQrMTU3Mi42NCs5OTkuOTQyQzE2NTEuMDQrOTE1LjU0MisxNjk1LjU0Kzc5NC4wNDIrMTY5NS41NCs2MzEuNDQyWiIgZmlsbD0iIzNFODJFNSIgb3BhY2l0eT0iMSIvPiAgICAgICAgPHBhdGggc3R5bGU9ImZpbHRlcjogdXJsKCNzaGFkb3cxKSIgZD0iTTE0NjkuMjUrNjMxLjQ0MkMxNDU5LjU1KzI3OC4wNDIrMTE4My4wNSsxMzUuNDQyKzgyNi42NSsxMzUuNDQyTDEzNS40NSsxMzUuNDQyTDEzNS40NSsxMDA0QzEzNS40NSsxMDA0KzEzNS40MjcrMTI1NS4yMSszNTUuNjI2KzEyNTUuMjFDNTc1LjgyNSsxMjU1LjIxKzU3NS44NDgrMTAwNCs1NzUuODQ4KzEwMDRMNTc3LjQ1KzQ5MC40NDJMODM0LjQ1KzQ5MC40NDJDMTEwOC45NSs0OTAuNDQyKzExMDguOTUrODM1LjM0Mis4MzQuNDUrODM1LjM0Mkw2NjQuNjUrODM1LjM0Mkw2NjQuNjUrMTE2NC44NEw4MzQuNDUrMTE2NC44NEM5MjMuOTMyKzExNjQuODQrOTg0LjI0NCsxMjAxLjQ4KzEwMTUuMzkrMTI1MC44N0MxMDc5Ljc4KzEzNTMrMTAxOS40NysxNTA5LjY0KzgzNC40NSsxNTA5LjY0TDEzNS40NSsxNTA5LjY0TDEzNS40NSsxODY0LjU0TDgyNi42NSsxODY0LjU0QzExODIuOTUrMTg2NC41NCsxNDU5LjQ1KzE3MjEuOTQrMTQ2OS4yNSsxMzY4LjU0QzE0NjkuMjUrMTIwNS45NCsxNDI0Ljc1KzEwODQuNDQrMTM0Ni4zNSs5OTkuOTQyQzE0MjQuNzUrOTE1LjU0MisxNDY5LjI1Kzc5NC4wNDIrMTQ2OS4yNSs2MzEuNDQyWiIgZmlsbD0iI0ZGRkZGRiIgb3BhY2l0eT0iMSIvPiAgICA8L2c+PC9zdmc+);\n}\n#bd-loading-icon {\n position: fixed;\n bottom:5px;\n right:5px;\n z-index: 2147483647;\n display: block;\n width: 20px;\n height: 20px;\n background-size: 100% 100%;\n animation: bd-loading-animation 1.5s ease-in-out infinite;\n}\n\n@keyframes bd-loading-animation {\n 0% { opacity: 0.05; }\n 50% { opacity: 0.6; }\n 100% { opacity: 0.05; }\n}\n/* =============== */\n/* END V2 LOADER */";const ht=document.createElement("div");ht.id="bd-loading-icon",ht.className="bd-loaderv2",ht.title="BandagedBD is loading...";var ut=class{static show(){document.body.appendChild(ct),document.body.appendChild(ht)}static hide(){ct&&ct.remove(),ht&&ht.remove()}};class pt extends O.Component{render(){const e=this.props.size||"24px";return O.createElement("svg",{viewBox:"0 0 24 24",style:{width:e,height:e}},O.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),O.createElement("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"}))}}class mt extends O.Component{constructor(e){super(e),this.hasUnsavedChanges=!1,this.onChange=this.onChange.bind(this),this.toggleLiveUpdate=this.toggleLiveUpdate.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.openDetached=this.props.openDetached?this.openDetached.bind(this):null,this.openNative=this.openNative.bind(this),this.updateEditor=this.updateEditor.bind(this),this.controls=[{label:O.createElement(we,{size:"18px"}),tooltip:k.CustomCSS.update,onClick:this.updateCss},{label:O.createElement(K,{size:"18px"}),tooltip:k.CustomCSS.save,onClick:this.saveCss},{label:O.createElement(X,{size:"18px"}),tooltip:k.CustomCSS.openNative,onClick:this.openNative},{label:O.createElement(ee,{size:"18px"}),tooltip:k.CustomCSS.settings,onClick:"showSettings"},{label:k.Collections.settings.customcss.liveUpdate.name,type:"checkbox",onChange:this.toggleLiveUpdate,checked:T.get("settings","customcss","liveUpdate"),side:"right"}],this.openDetached&&this.controls.push({label:O.createElement(pt,{size:"18px"}),tooltip:k.CustomCSS.openDetached,onClick:this.openDetached,side:"right"})}componentDidMount(){E.on("customcss-updated",this.updateEditor)}componentWillUnmount(){E.off("customcss-updated",this.updateEditor)}updateEditor(e){this.editor&&(this.editor.value=e)}get value(){return this.editor.session.getValue()}set value(e){this.editor.setValue(e)}showSettings(){return this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec(this.editor)}resize(){return this.editor.resize()}setEditorRef(e){this.editor=e,this.props.editorRef&&void 0!==this.props.editorRef.current?this.props.editorRef.current=e:this.props.editorRef&&(this.props.editorRef=e)}onChange(){this.hasUnsavedChanges=!0,this.props.onChange&&this.props.onChange(...arguments)}render(){return O.createElement(J,{ref:this.setEditorRef.bind(this),readOnly:this.props.readOnly,id:this.props.id||"bd-customcss-editor",onChange:this.onChange,controls:this.controls,value:this.props.css})}toggleLiveUpdate(e){T.set("settings","customcss","liveUpdate",e)}updateCss(e,t){this.props.update&&this.props.update(t)}saveCss(e,t){this.hasUnsavedChanges=!1,this.props.save&&this.props.save(t)}openDetached(e,t){this.props.openDetached&&this.props.openDetached(t)}openNative(){this.props.openNative&&this.props.openNative()}}const gt=s(2),ft=s(0),yt=g.getByProps("updateAccount"),bt=g.getByProps("dirtyDispatch"),vt=g.getByProps("ActionTypes").ActionTypes;var wt=new class extends Je{get name(){return"Custom CSS"}get category(){return"customcss"}get id(){return"customcss"}get startDetached(){return"detached"==T.get(this.collection,this.category,"openAction")}get nativeOpen(){return"system"==T.get(this.collection,this.category,"openAction")}constructor(){super(),this.savedCss="",this.insertedCss="",this.isDetached=!1}async enabled(){window.ace||S.injectScript("ace-script","https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js").then(()=>{window.require.original&&(window.require=window.require.original)}),T.registerPanel(this.id,k.Panels.customcss,{order:2,element:()=>[O.createElement(ve,{text:k.CustomCSS.editorTitle}),O.createElement(mt,{css:this.savedCss,save:this.saveCSS.bind(this),update:this.insertCSS.bind(this),openNative:this.openNative.bind(this),openDetached:this.openDetached.bind(this),onChange:this.onChange.bind(this)})],onClick:e=>{if(this.isDetached)return;if(this.nativeOpen)return this.openNative();if(this.startDetached)return this.openDetached();const t=u.findInRenderTree(e._reactInternalFiber,e=>e&&e.onSetSection,{walkable:["child","memoizedProps","props","children"]});t&&t.onSetSection&&t.onSetSection(this.id)}}),this.loadCSS(),this.insertCSS(this.savedCss),this.watchContent()}disabled(){T.removePanel(this.id),this.unwatchContent()}watchContent(){if(this.watcher)return this.error("Already watching content.");const e={};this.log("Starting to watch content."),this.watcher=gt.watch(w.customCSS,{persistent:!1},async(t,s)=>{if(!t||!s)return;await new Promise(e=>setTimeout(e,50));try{gt.statSync(w.customCSS)}catch(t){if("ENOENT"!==t.code)return;delete e[s],this.saveCSS("")}const n=gt.statSync(w.customCSS);if(n&&n.mtime&&n.mtime.getTime()&&"number"==typeof n.mtime.getTime()&&e[s]!=n.mtime.getTime()&&(e[s]=n.mtime.getTime(),"change"==t)){const e=w.loadCustomCSS();if(e==this.savedCss)return;this.savedCss=e,this.insertCSS(this.savedCss),E.emit("customcss-updated",this.savedCss)}})}unwatchContent(){if(!this.watcher)return this.error("Was not watching content.");this.watcher.close(),delete this.watcher,this.log("No longer watching content.")}onChange(e){T.get("settings","customcss","liveUpdate")&&(this.insertCSS(e),this.saveCSS(e))}loadCSS(){this.savedCss=w.loadCustomCSS()}insertCSS(e){void 0===e?e=this.insertedCss:this.insertedCss=e,S.updateCustomCSS(e)}saveCSS(e){void 0!==e&&(this.savedCss=e),w.saveCustomCSS(this.savedCss)}openNative(){ft.shell.openExternal("file://"+w.customCSS)}openDetached(e){const t=O.createRef(),s=O.createElement(mt,{id:"bd-floating-editor",ref:t,css:e,save:this.saveCSS.bind(this),update:this.insertCSS.bind(this),openNative:this.openNative.bind(this),onChange:this.onChange.bind(this)});ce.open({onClose:()=>{this.isDetached=!1},onResize:()=>{t&&t.current&&t.current.resize&&t.current.resize()},title:k.CustomCSS.editorTitle,id:"floating-editor-window",height:470,width:410,center:!0,resizable:!0,children:s,confirmClose:()=>!(!t||!t.current)&&t.current.hasUnsavedChanges,confirmationText:k.CustomCSS.confirmationText}),this.isDetached=!0,yt.close(),bt.dirtyDispatch({type:vt.LAYER_POP})}},St=new class extends Je{get name(){return"WindowPrefs"}get category(){return"window"}get id(){return"transparency"}enabled(){this.setWindowPreference("transparent",!0),this.setWindowPreference("backgroundColor","#00000000"),this.showModal(k.WindowPrefs.enabledInfo)}disabled(){this.deleteWindowPreference("transparent"),this.deleteWindowPreference("backgroundColor"),this.showModal(k.WindowPrefs.disabledInfo)}showModal(e){this.initialized&&_.showConfirmationModal(k.Modals.additionalInfo,e,{confirmText:k.Modals.restartNow,cancelText:k.Modals.restartLater,onConfirm:()=>{const e=s(0).remote.app;e.relaunch(),e.exit()}})}getWindowPreference(e){return(w.getData("windowprefs")||{})[e]}setWindowPreference(e,t){const s=w.getData("windowprefs")||{};s[e]=t,w.setData("windowprefs",s)}deleteWindowPreference(e){const t=w.getData("windowprefs")||{};delete t[e],w.setData("windowprefs",t)}},Ct=new class extends Je{get name(){return"24Hour"}get category(){return"general"}get id(){return"twentyFourHour"}enabled(){this.inject24Hour()}disabled(){this.unpatchAll()}inject24Hour(){const e=new RegExp("([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)"),t=(t,s,n)=>{const i=n.match(e);if(i&&4===i.length)return"AM"===i[3]?n.replace(i[0],`${"12"===i[1]?"00":i[1].padStart(2,"0")}:${i[2]}`):n.replace(i[0],`${"12"===i[1]?"12":parseInt(i[1])+12}:${i[2]}`)};this.after(f.TimeFormatter,"calendarFormat",t),this.after(f.TimeFormatter,"dateFormat",t)}};const Et=new RegExp("^(?!da-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$");var Mt=new class extends Je{get id(){return"classNormalizer"}get category(){return"general"}get name(){return"ClassNormalizer"}enabled(){this.hasPatched||(this.patchClassModules(g.getModules(this.moduleFilter.bind(this))),this.normalizeElement(document.querySelector("#app-mount")),this.hasPatched=!0,this.patchDOMMethods())}disabled(){this.hasPatched&&(this.unpatchClassModules(g.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 s=e[t];if("string"!=typeof s)return!1;if(!this.shouldIgnore(s)){if(1===s.split("-").length)return!1;if(!Et.test(s.split(" ")[0]))return!1}}return!0}patchClassModule(e,t){for(const s in t){const n=t[s];if(this.shouldIgnore(n))continue;const i=n.split(" ");for(const n of i){const i=n.match(Et);if(!i||!i.length||i.length<2)continue;const o=i[1].split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");t[s]+=` ${e}-${o}`}}}unpatchClassModule(e,t){for(const s in t){const n=t[s];if(this.shouldIgnore(n))continue;let i="";const o=n.split(" ");for(const t of o)t.startsWith(e+"-")||(i+=" "+t);t[s]=i.trim()}}normalizeElement(e){if(!(e instanceof Element))return;const t=e.classList;for(let s=0,n=t.length;s<n;s++){if(!Et.test(t[s]))continue;const n=t[s].match(Et)[1].split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");e.classList.add("da-"+n)}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,s=[];for(let e=0;e<t.length;e++)t[e].startsWith("da-")&&s.push(t[e]);e.classList.remove(...s)}patchDOMMethods(){const e=DOMTokenList.prototype.contains;DOMTokenList.prototype.contains=function(t){return Reflect.apply(e,this,[t.split(" ")[0]])};const t=DOMTokenList.prototype.add;DOMTokenList.prototype.add=function(...e){for(let t=0;t<e.length;t++)e[t]=e[t].split(" ")[0];return Reflect.apply(t,this,e)};const s=DOMTokenList.prototype.remove;DOMTokenList.prototype.remove=function(...e){for(let t=0;t<e.length;t++)e[t]=e[t].split(" ")[0];return Reflect.apply(s,this,e)}}};class xt extends O.Component{constructor(e){super(e),this.props.server.iconUrl||(this.props.server.iconUrl=this.props.defaultAvatar()),this.state={imageError:!1,joined:this.props.joined},this.join=this.join.bind(this),this.handleError=this.handleError.bind(this)}render(){const{server:e}=this.props,t="string"==typeof this.state.joined?k.PublicServers.joining+"...":this.state.joined?k.PublicServers.joined:k.PublicServers.join,s="bd-button"+(1==this.state.joined?" bd-button-success":"");return O.createElement("div",{className:"bd-server-card"+(e.pinned?" bd-server-card-pinned":"")},O.createElement("img",{className:"bd-server-image",src:e.iconUrl,onError:this.handleError}),",",O.createElement("div",{className:"bd-server-content"},O.createElement("div",{className:"bd-server-header"},O.createElement("h5",{className:"bd-server-name"},e.name),O.createElement("h5",{className:"bd-server-member-count"},e.members," Members")),O.createElement("div",{className:"bd-scroller-wrap bd-server-description-container"},O.createElement("div",{className:"bd-scroller bd-server-description"},e.description)),O.createElement("div",{className:"bd-server-footer"},O.createElement("div",{className:"bd-server-tags"},e.categories.join(", ")),O.createElement("button",{type:"button",className:s,onClick:this.join},t))))}handleError(){this.props.server.iconUrl=this.props.defaultAvatar(),this.setState({imageError:!0})}async join(){if(this.state.joined)return;this.setState({joined:"joining"});const e=await this.props.join(this.props.server.identifier,this.props.server.nativejoin);this.setState({joined:e})}}const Nt=g.getByProps("getSortedGuilds"),Pt=g.getByProps("getUserAvatarURL","DEFAULT_AVATARS"),Dt=g.getByProps("acceptInvite"),At=s(0).remote.BrowserWindow;class kt{static get endPoint(){return"https://search.discordservers.com"}static get joinEndPoint(){return"https://j.discordservers.com"}static get connectEndPoint(){return"https://auth.discordservers.com/info"}static getDefaultAvatar(){return Pt.DEFAULT_AVATARS[Math.floor(5*Math.random())]}static hasJoined(e){return Nt.getFlattenedGuildIds().includes(e)}static search({term:e="",category:t="",from:n=0}={}){const i=s(3);return new Promise(s=>{const o=[];t&&o.push("category="+t.replace(/ /g,"%20")),e&&o.push("term="+e.replace(/ /g,"%20")),n&&o.push("from="+n);const r="?"+o.join("&");i.get({url:`${this.endPoint}${r}${r?"&schema=new":"?schema=new"}`,json:!0},(e,t,n)=>{if(e)return s(null);const i=n.size+n.from;s({servers:n.results,size:n.size,from:n.from,total:n.total,next:i>=n.total?null:i})})})}static async join(e,t=!1){if(t)return Dt.acceptInvite(e);try{return await fetch(`${this.joinEndPoint}/${e}`,{method:"GET",credentials:"include",mode:"cors",headers:{Accept:"application/json","Content-Type":"application/json"}}),!0}catch(e){return!1}}static async checkConnection(){try{const e=await fetch("https://auth.discordservers.com/info",{method:"GET",credentials:"include",mode:"cors",headers:{Accept:"application/json","Content-Type":"application/json"}}),t=await e.json();return this._accessToken=t.access_token,t}catch(e){return!1}}static connect(){return new Promise(e=>{const t=new At(this.windowOptions),s="https://auth.discordservers.com/connect?scopes=guilds.join&previousUrl="+this.connectEndPoint;t.webContents.on("did-navigate",(s,n)=>{n==this.connectEndPoint&&(t.close(),e())}),t.loadURL(s)})}static get windowOptions(){return{width:380,height:450,backgroundColor:"#282b30",show:!0,resizable:!0,maximizable:!1,minimizable:!1,alwaysOnTop:!0,frame:!1,center:!0,webPreferences:{nodeIntegration:!1}}}}const Tt=g.getByDisplayName("SettingsView");class Lt extends O.Component{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"]}constructor(e){super(e),this.state={category:"All",query:"",loading:!0,user:null,results:{servers:[],size:0,from:0,total:0,next:null}},this.changeCategory=this.changeCategory.bind(this),this.searchKeyDown=this.searchKeyDown.bind(this),this.connect=this.connect.bind(this),this.loadNextPage=this.loadNextPage.bind(this),this.join=this.join.bind(this)}componentDidMount(){this.checkConnection()}async checkConnection(){const e=await kt.checkConnection();if(!e)return this.setState({loading:!0,user:null});this.setState({user:e}),this.search()}async connect(){await kt.connect(),this.checkConnection()}searchKeyDown(e){this.state.loading||13!==e.which||this.search(e.target.value)}async search(e="",t=0){this.setState({query:e,loading:!0});const s=await kt.search({term:e,category:"All"==this.state.category?"":this.state.category,from:t});if(!s)return this.setState({results:{servers:[],size:0,from:0,total:0,next:null}});this.setState({loading:!1,results:s})}async changeCategory(e){this.state.loading||(await new Promise(t=>this.setState({category:e},t)),this.search())}loadNextPage(){this.state.loading||this.search(this.state.query,this.state.results.next)}async join(e,t=!1){return await kt.join(e,t)}get searchBox(){return O.createElement(je,{onKeyDown:this.searchKeyDown,placeholder:k.PublicServers.search+"..."})}get title(){if(!this.state.user)return k.PublicServers.notConnected;if(this.state.loading)return k.PublicServers.loading+"...";const e=this.state.results.from+1,t=this.state.results.total,s=this.state.results.next?this.state.results.next:t;let n=k.PublicServers.results.format({start:e,end:s,total:t,category:this.state.category});return this.state.query&&(n+=" "+k.PublicServers.query.format({query:this.state.query})),n}get content(){const e=this.state.user?null:{title:k.PublicServers.connect,onClick:this.connect},t="All"!=this.state.category&&this.state.user?null:this.bdServer,s=this.state.results.servers.map(e=>O.createElement(xt,{key:e.identifier,server:e,joined:kt.hasJoined(e.identifier),join:this.join,defaultAvatar:kt.getDefaultAvatar}));return[O.createElement(ve,{text:this.title,button:e}),t,s,this.state.results.next?this.nextButton:null,this.state.results.servers.length>0&&O.createElement(ve,{text:this.title})]}get nextButton(){return O.createElement("button",{type:"button",className:"bd-button bd-button-next",onClick:this.loadNextPage},this.state.loading?k.PublicServers.loading:k.PublicServers.loadMore)}get connection(){const{user:e}=this.state;return e?O.createElement("div",{id:"bd-connection"},O.createElement("div",{className:"bd-footnote"},k.PublicServers.connection.format(e)),O.createElement("button",{type:"button",className:"bd-button bd-button-reconnect",onClick:this.connect},k.PublicServers.reconnect)):O.createElement("div",{id:"bd-connection"})}get bdServer(){const e={name:"BetterDiscord",online:"7500+",members:"20000+",categories:["community","programming","support"],description:"Official BetterDiscord server for plugins, themes, support, etc",identifier:"86004744966914048",iconUrl:"https://cdn.discordapp.com/icons/86004744966914048/292e7f6bfff2b71dfd13e508a859aedd.webp",nativejoin:!0,invite_code:"0Tmfo5ZbORCRqbAd",pinned:!0};return O.createElement(xt,{server:e,pinned:!0,joined:kt.hasJoined(e.identifier),defaultAvatar:kt.getDefaultAvatar})}render(){const e=this.categoryButtons.map(e=>({section:e,label:e,element:()=>this.content}));return O.createElement(Tt,{onClose:this.props.close,onSetSection:this.changeCategory,section:this.state.category,sections:[{section:"HEADER",label:k.PublicServers.search},{section:"CUSTOM",element:()=>this.searchBox},{section:"HEADER",label:k.PublicServers.categories},...e,{section:"DIVIDER"},{section:"HEADER",label:O.createElement("a",{href:"https://discordservers.com",target:"_blank"},"DiscordServers.com")},{section:"DIVIDER"},{section:"CUSTOM",element:()=>this.connection}],theme:"dark"})}}const jt=g.getByProps("pushLayer");var Bt=new class extends Je{get name(){return"PublicServers"}get category(){return"general"}get id(){return"publicServers"}enabled(){const e=g.find(e=>e.default&&"NavigableGuilds"==e.default.displayName),t=g.findByDisplayName("Guilds");e||t||this.warn("Can't find GuildList component"),this.guildPatch=this.after(e||t.prototype,e?"default":"render",this._appendButton),this._appendButton()}disabled(){this.unpatchAll(),h.query("#bd-pub-li").remove()}_appendButton(){const e=f.GuildClasses.wrapper.split(" ")[0],t=h.query(`.${e} .scroller-2TZvBN >:first-child`);h.after(t,this.button)}openPublicServers(){jt.pushLayer(()=>f.React.createElement(Lt,{close:jt.popLayer}))}get button(){const e=h.createElement(`<div id="bd-pub-li" class="${f.GuildClasses.listItem}">`),t=h.createElement(`<div id="bd-pub-button" class="${"wrapper-25eVIn "+f.GuildClasses.circleButtonMask}">${k.PublicServers.button}</div>`);return t.addEventListener("click",()=>{this.openPublicServers()}),e.append(t),e}},It=new class extends Je{get name(){return"VoiceDisconnect"}get category(){return"general"}get id(){return"voiceDisconnect"}constructor(){super(),this.beforeUnload=this.beforeUnload.bind(this)}enabled(){window.addEventListener("beforeunload",this.beforeUnload)}disabled(){window.removeEventListener("beforeunload",this.beforeUnload)}beforeUnload(){f.ChannelActions.selectVoiceChannel(null,null)}};const zt=g.getModule(e=>e.default&&e.default.displayName&&"Message"==e.default.displayName);var Ft=new class extends Je{get name(){return"ColoredText"}get category(){return"appearance"}get id(){return"coloredText"}enabled(){this.injectColoredText()}disabled(){this.unpatchAll()}injectColoredText(){this.after(zt.prototype,"render",(e,t,s)=>{this.after(s.props,"children",{after:({returnValue:t})=>{const s=t.props.children[1],n=e.props.message.colorString;s&&n&&(s.props.style={color:n})}})})}removeColoredText(){document.querySelectorAll(".markup-2BOw-j").forEach(e=>{e.style.setProperty("color","")})}},Ot=new class extends Je{get name(){return"DarkMode"}get category(){return"appearance"}get id(){return"darkMode"}enabled(){document.getElementById("app-mount").classList.add("bda-dark","bd-dark")}disabled(){document.getElementById("app-mount").classList.remove("bda-dark","bd-dark")}},Rt=new class extends Je{get name(){return"MinimalMode"}get category(){return"appearance"}get id(){return"minimalMode"}get hideChannelsID(){return"hideChannels"}get hideChannels(){return this.get(this.hideChannelsID)}constructor(){super(),this.enableHideChannels=this.enableHideChannels.bind(this),this.disableHideChannels=this.disableHideChannels.bind(this)}enabled(){document.body.classList.add("bd-minimal"),this.hideChannels&&this.enableHideChannels(),this.hideChannelCancel=this.registerSetting(this.hideChannelsID,this.enableHideChannels,this.disableHideChannels)}disabled(){document.body.classList.remove("bd-minimal"),this.hideChannels&&this.disableHideChannels(),this.hideChannelCancel&&this.hideChannelCancel()}enableHideChannels(){document.body.classList.add("bd-minimal-chan")}disableHideChannels(){document.body.classList.remove("bd-minimal-chan")}},Ut=new class extends Je{get name(){return"VoiceMode"}get category(){return"appearance"}get id(){return"voiceMode"}enabled(){document.querySelector(".chat-3bRxxu").style.setProperty("visibility","hidden"),document.querySelector(".chat-3bRxxu").style.setProperty("min-width","0px"),document.querySelector(".channels-Ie2l6A").style.setProperty("flex-grow","100000")}disabled(){document.querySelector(".chat-3bRxxu").style.setProperty("visibility",""),document.querySelector(".chat-3bRxxu").style.setProperty("min-width",""),document.querySelector(".channels-Ie2l6A").style.setProperty("flex-grow","")}};const Ht=g.getByDisplayName("VerticalScroller");class qt extends O.Component{render(){return O.createElement("div",{className:`bd-qem-${this.props.type}-container`},O.createElement(Ht,{className:"bd-em-scroller"},O.createElement("div",{className:"emote-menu-inner"},this.props.children)))}}const _t=g.getByProps("openContextMenu"),{MenuItem:Wt,MenuGroup:Gt}=g.find(e=>e.MenuRadioItem&&!e.default),$t=g.getByProps("default","MenuStyle").default,{ComponentDispatch:Qt}=g.getByProps("ComponentDispatch");class Vt extends O.Component{render(){return O.createElement("div",{className:"emote-container",onClick:this.handleOnClick.bind(this),onContextMenu:this.handleOnContextMenu.bind(this)},O.createElement("img",{src:this.props.url,alt:this.props.emote,title:this.props.emote}))}handleOnClick(){this.insertText(this.props.emote)}handleOnContextMenu(e){_t.openContextMenu(e,()=>O.createElement($t,{navId:"EmoteContextMenu",onClose:_t.closeContextMenu},O.createElement(Gt,null,O.createElement(Wt,{label:rt.isFavorite(this.props.emote)?"Remove Favorite":"Add Favorite",id:"favorite",action:this.handlefavorite.bind(this),onClose:_t.closeContextMenu}))))}handlefavorite(){_t.closeContextMenu(),rt.isFavorite(this.props.emote)?rt.removeFavorite(this.props.emote):rt.addFavorite(this.props.emote,this.props.url)}insertText(e){Qt.dispatchToLastSubscribed("INSERT_TEXT",{content:e})}}var Zt=[{id:"twitchEmotes",label:"Twitch Emotes",element:()=>O.createElement(qt,{type:"twitch"},Object.keys(rt.getCategory("TwitchGlobal")).map(e=>{const t=rt.getUrl("TwitchGlobal",e);return O.createElement(Vt,{emote:e,url:t})}))},{id:"favoriteEmotes",label:"Favorite Emotes",element:()=>O.createElement(qt,{type:"favourite"},Object.entries(rt.favorites).map(([e,t])=>O.createElement(Vt,{emote:e,url:t})))}];const Yt=g.find(e=>e.type&&"ExpressionPicker"==e.type.displayName);var Jt=new class extends Je{get name(){return"EmoteMenu"}get collection(){return"emotes"}get category(){return"general"}get id(){return"emoteMenu"}get hideEmojisID(){return"hideEmojiMenu"}get hideEmojis(){return this.get(this.hideEmojisID)}enabled(){this.before(Yt,"type",(e,[t])=>{"emoji"==t.expressionPickerView&&this.hideEmojis&&(t.expressionPickerView="gif")}),this.after(Yt,"type",(e,[t],s)=>{const n=u.getNestedProp(s,"props.children.props.children.1.props.children.0.props.children.props.children"),i=u.getNestedProp(s,"props.children.props.children.1.props.children");if(!n||!i)return s;const o=t.expressionPickerView,r=Zt.find(e=>e.id===o),a=n[0].props;n.push(...Zt.map(e=>O.createElement("div",{id:e.id+"-tab",role:"tab","aria-selected":o==e.id,className:a.className},O.createElement(a.children.type,{viewType:e.id,isActive:o==e.id,setActiveView:a.children.props.setActiveView},e.label)))),r&&(i[2]=r.element()),this.hideEmojis&&n.splice(n.findIndex(e=>"emoji-picker-tab"==e.props.id),1)})}disabled(){this.unpatchAll()}},Kt=new class extends Je{get name(){return"DeveloperMode"}get category(){return"developer"}get id(){return"developerMode"}get selectorModeID(){return"copySelector"}get selectorMode(){return this.get(this.selectorModeID)}constructor(){super(),this.copySelectorListener=this.copySelectorListener.bind(this)}enabled(){document.addEventListener("contextmenu",this.copySelectorListener)}disabled(){document.removeEventListener("contextmenu",this.copySelectorListener)}copySelectorListener(e){e.stopPropagation();const t=this.getSelector(e.target);setImmediate((function(){let s=h.query(".contextMenu-HLZMGh");if(!s){const t=h.query("#app-mount"),n=h.createElement('<div class="layer-v9HyYc da-layer">');s=h.createElement('<div class="contextMenu-HLZMGh da-contextMenu bd-context-menu"></div>'),n.append(s),t.append(n),n.style.top=e.clientY+"px",n.style.left=e.clientX+"px",n.style.zIndex="1002";const i=function(e){e.keyCode&&27!==e.keyCode||(n.remove(),document.removeEventListener("click",i),document.removeEventListener("contextmenu",i),document.removeEventListener("keyup",i))};document.addEventListener("click",i),document.addEventListener("contextmenu",i),document.addEventListener("keyup",i)}const n=h.createElement('<div class="itemGroup-1tL0uz da-itemGroup">'),i=h.createElement('<div class="item-1Yvehc itemBase-tz5SeC da-item da-itemBase clickable-11uBi- da-clickable">');i.append(h.createElement(`<div class="label-JWQiNe da-label">${k.Developer.copySelector}</div>`)),i.addEventListener("click",()=>{f.ElectronModule.copy(t),s.style.display="none"}),n.append(i),s.append(n)}))}getSelector(e){if(e.id)return"#"+e.id;const t=this.getRules(e),s=t[t.length-1];return s?s.selectorText:e.classList.length?"."+Array.from(e.classList).join("."):"."+Array.from(e.parentElement.classList).join(".")}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("*"))}},Xt=new class extends Je{get name(){return"Debugger"}get category(){return"developer"}get id(){return"debuggerHotkey"}enabled(){document.addEventListener("keydown",this.debugListener)}disabled(){document.removeEventListener("keydown",this.debugListener)}debugListener(e){if(119===e.which||118==e.which){debugger;e.preventDefault(),e.stopImmediatePropagation()}}};const es=s(0),ts=s(2),ss=s(1),ns=es.remote.BrowserWindow;var is=new class extends Je{get name(){return"ReactDevTools"}get category(){return"developer"}get id(){return"reactDevTools"}initialize(){super.initialize(),this.findExtension()}findExtension(){let e="";if(e="win32"===process.platform?ss.resolve(process.env.LOCALAPPDATA,"Google/Chrome/User Data"):"linux"===process.platform?ss.resolve(process.env.HOME,".config/google-chrome"):"darwin"===process.platform?ss.resolve(process.env.HOME,"Library/Application Support/Google/Chrome"):ss.resolve(process.env.HOME,".config/chromium"),e+="/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/",ts.existsSync(e)){const t=ts.readdirSync(e);e=ss.resolve(e,t[t.length-1])}this.extensionPath=e,this.isExtensionInstalled=ts.existsSync(e)}enabled(){if(this.isExtensionInstalled||this.findExtension(),!this.isExtensionInstalled)return _.alert(k.ReactDevTools.notFound,k.ReactDevTools.notFoundDetails);try{ns.addDevToolsExtension(this.extensionPath)?this.log("Successfully installed react devtools."):this.error("Couldn't find react devtools in chrome extensions!")}catch(e){this.error("Couldn't add the extension!")}}disabled(){this.isExtensionInstalled&&ns.removeDevToolsExtension("React Developer Tools")}};class os extends O.Component{render(){return O.createElement("svg",{className:"bd-logo "+this.props.className,height:"100%",width:this.props.size||"16px",viewBox:"0 0 2000 2000",style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"}},O.createElement("metadata",null),O.createElement("defs",null,O.createElement("filter",{id:"shadow1"},O.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20",floodColor:"rgba(0,0,0,0.35)"})),O.createElement("filter",{id:"shadow2"},O.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20",floodColor:"rgba(255,255,255,0.15)"})),O.createElement("filter",{id:"shadow3"},O.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20",floodColor:"rgba(0,0,0,0.35)"}))),O.createElement("g",null,O.createElement("path",{style:{filter:"url(#shadow3)"},fill:"#171717",opacity:"1",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"}),O.createElement("path",{style:{filter:"url(#shadow2)"},fill:"#3E82E5",opacity:"1",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"}),O.createElement("path",{style:{filter:"url(#shadow1)"},fill:"#FFFFFF",opacity:"1",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"})))}}const rs=f.React,as=g.getByDisplayName("Tooltip");var ls=new class{initialize(){u.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),u.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),u.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),u.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")(),u.suppressErrors(this.patchMessageHeader.bind(this),"BD Message Header Patch")(),u.suppressErrors(this.patchMemberList.bind(this),"BD Member List Patch")()}patchSocial(){if(this.socialPatch)return;const e=g.getByDisplayName("TabBar"),t=g.getByDisplayName("Anchor");e&&(this.socialPatch=L.after("ComponentPatcher",e.prototype,"render",(e,s,n)=>{const o=n.props.children;if(!o||!o.length||o.length<3)return;if("Separator"!==o[o.length-3].type.displayName)return;if(!o[o.length-2].type.toString().includes("socialLinks"))return;if(t){const e=o[o.length-2].type,s=function(){const s=e(...arguments);return s.props.children.push(f.React.createElement(t,{className:"bd-social-link",href:"https://twitter.com/BandagedBD",title:"BandagedBD",target:"_blank"},f.React.createElement(os,{size:"16px",className:"bd-social-logo"}))),s};o[o.length-2].type=s}const r=f.React.createElement("div",{className:"colorMuted-HdFt4q size12-3cLvbJ"},"Injector "+i.version),a=`(${i.hash?i.hash.substring(0,7):i.branch})`,l=f.React.createElement("div",{className:"colorMuted-HdFt4q size12-3cLvbJ"},`BBD ${i.bbdVersion} `,f.React.createElement("span",{className:"versionHash-2gXjIB da-versionHash"},a)),d=o[o.length-1].type;o[o.length-1].type=function(){const e=d(...arguments);return e.props.children.splice(e.props.children.length-1,0,r),e.props.children.splice(1,0,l),e}}))}patchGuildListItems(){if(this.guildListItemsPatch)return;const e=f.GuildClasses.listItem.split(" ")[0],t=f.GuildClasses.blobContainer.split(" ")[0],s=u.getReactInstance(document.querySelector(`.${e} .${t}`).parentElement).return.type;s&&(this.guildListItemsPatch=L.after("ComponentPatcher",s.prototype,"render",(e,t,s)=>{if(!s||!e)return;const n=e.props;return s.props.className+=" bd-guild",n.unread&&(s.props.className+=" bd-unread"),n.selected&&(s.props.className+=" bd-selected"),n.audio&&(s.props.className+=" bd-audio"),n.video&&(s.props.className+=" bd-video"),n.badge&&(s.props.className+=" bd-badge"),n.animatable&&(s.props.className+=" bd-animatable"),s}))}patchGuildPills(){if(this.guildPillPatch)return;const e=g.getModule(e=>e.default&&!e.default.displayName&&e.default.toString&&e.default.toString().includes("translate3d"));e&&(this.guildPillPatch=L.after("ComponentPatcher",e,"default",(e,t,s)=>{const n=t[0];return n.unread&&(s.props.className+=" bd-unread"),n.selected&&(s.props.className+=" bd-selected"),n.hovered&&(s.props.className+=" bd-hovered"),s}))}patchGuildSeparator(){if(this.guildSeparatorPatch)return;const e=g.getByDisplayName("Guilds"),t=g.getByProps("renderListItem");if(!t||!e)return;const s=function(){const e=t.Separator(...arguments);return e.props.className+=" bd-guild-separator",e};this.guildSeparatorPatch=L.after("ComponentPatcher",e.prototype,"render",(e,t,n)=>{const i=u.findInReactTree(n,e=>e.type&&!e.type.displayName&&"function"==typeof e.type&&u.isEmpty(e.props));i&&(i.type=s)})}patchMessageHeader(){if(this.messageHeaderPatch)return;const e=g.getByProps("MessageTimestamp"),t=g.find(e=>"Anchor"==e.displayName);t&&e&&e.default&&(this.messageHeaderPatch=L.after("ComponentPatcher",e,"default",(e,s,n)=>{const i=u.getNestedProp(s[0],"message.author"),o=u.getNestedProp(n,"props.children.1.props.children.1.props.children");o&&i&&i.id&&"249746236008169473"===i.id&&Array.isArray(o)&&o.push(rs.createElement(as,{color:"black",position:"top",text:"BandagedBD Developer"},e=>rs.createElement(t,Object.assign({className:"bd-chat-badge",href:"https://github.com/rauenzi/BetterDiscordApp",title:"BandagedBD",target:"_blank"},e),rs.createElement(os,{size:"16px",className:"bd-logo"}))))}))}patchMemberList(){if(this.memberListPatch)return;const e=g.findByDisplayName("MemberListItem"),t=g.find(e=>"Anchor"==e.displayName);t&&e&&e.prototype&&e.prototype.renderDecorators&&(this.memberListPatch=L.after("ComponentPatcher",e.prototype,"renderDecorators",(e,s,n)=>{const i=u.getNestedProp(e,"props.user"),o=u.getNestedProp(n,"props.children");o&&i&&i.id&&"249746236008169473"===i.id&&Array.isArray(o)&&o.push(rs.createElement(as,{color:"black",position:"top",text:"BandagedBD Developer"},e=>rs.createElement(t,Object.assign({className:"bd-member-badge",href:"https://github.com/rauenzi/BetterDiscordApp",title:"BandagedBD",target:"_blank"},e),rs.createElement(os,{size:"16px",className:"bd-logo"}))))}))}};const ds=s(2),cs=s(1),{ipcRenderer:hs}=s(0),us=f.GuildClasses;!function(){const e=Object.getOwnPropertyDescriptor(HTMLIFrameElement.prototype,"contentWindow").get;Object.defineProperty(HTMLIFrameElement.prototype,"contentWindow",{get:function(){const t=Reflect.apply(e,this,arguments);return new Proxy(t,{getOwnPropertyDescriptor:function(e,t){if("localStorage"!==t)return Object.getOwnPropertyDescriptor(e,t)},get:function(e,t){if("localStorage"===t)return null;const s=e[t];return"function"==typeof s?s.bind(e):s}})}}),Object.defineProperty(Reflect,"apply",{value:Reflect.apply,writable:!1,configurable:!1}),Object.defineProperty(Function.prototype,"bind",{value:Function.prototype.bind,writable:!1,configurable:!1});const t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(){const e=arguments[1];return e.toLowerCase().includes("api/webhooks")?null:Reflect.apply(t,this,arguments)}}(),function(){const e="betterdiscord/",t=s(4),n=t._load;t._load=function(t){if("betterdiscord"===t||t.startsWith(e)){if("bdapi"==t.substr(e.length))return dt}return n.apply(this,arguments)}}(),window.BdApi=dt,ut.show(),new class{constructor(){hs.invoke("bd-config","get").then(e=>{this.hasStarted||(Object.assign(i,e),this.init())})}get dependencies(){return[{name:"jquery",type:"script",url:"//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js",backup:"//cdn.jsdelivr.net/gh/jquery/jquery@2.0.0/jquery.min.js",local:null},{name:"bd-stylesheet",type:"style",url:"//betterdiscord.zerebos.com/dist/style.css",backup:"//rauenzi.github.io/BetterDiscordApp/dist/style.css",local:"{{localServer}}/BetterDiscordApp/dist/style.css",localPath:"style.css"}]}setConfig(e){this.hasStarted||Object.assign(i,e)}async init(){if(this.hasStarted)return;this.hasStarted=!0;let e=new Promise(e=>e());if(window.$&&window.jQuery||(e=this.loadDependencies()),w.initialize(),await D.initialize(),i.version<i.minSupportedVersion)return _.alert(k.Startup.notSupported,k.Startup.versionMismatch.format({injector:i.version,remote:i.bbdVersion}));if(window.ED)return _.alert(k.Startup.notSupported,k.Startup.incompatibleApp.format({app:"EnhancedDiscord"}));if(window.WebSocket&&window.WebSocket.name&&window.WebSocket.name.includes("Patched"))return _.alert(k.Startup.notSupported,k.Startup.incompatibleApp.format({app:"Powercord"}));const t=i.updater?i.updater.LatestVersion:i.latestVersion;t>i.version&&_.showConfirmationModal(k.Startup.updateAvailable,k.Startup.updateInfo.format({version:t}),{confirmText:k.Startup.updateNow,cancelText:k.Startup.maybeLater,onConfirm:async()=>{const e=()=>{_.alert(k.Startup.updateFailed,k.Startup.manualUpdate)};try{if(!await this.updateInjector())return e();const t=s(0).remote.app;t.relaunch(),t.exit()}catch(t){e()}}}),c.log("Startup","Initializing Settings"),T.initialize(),await this.waitForGuilds(),F.initialize(),ls.initialize();for(const e in n)n[e].initialize();await e,c.log("Startup","Loading Plugins");const o=Ve.initialize();c.log("Startup","Loading Themes");const r=Ye.initialize();c.log("Startup","Removing Loading Icon"),ut.hide(),c.log("Startup","Collecting Startup Errors"),_.showAddonErrors({plugins:o,themes:r});const a=w.getBDData("version");i.bbdVersion>a&&(_.showChangelogModal(l),w.setBDData("version",i.bbdVersion))}waitForGuilds(){let e=0;return new Promise(t=>{const s=function(){e++,"complete"!=document.readyState&&setTimeout(s,100);const n=us.wrapper.split(" ")[0],o=us.listItem.split(" ")[0],r=us.blobContainer.split(" ")[0];return document.querySelectorAll(`.${n} .${o} .${r}`).length>0||e>=50?t(i.deferLoaded=!0):void setTimeout(s,100)};s()})}async loadDependencies(){for(const e of this.dependencies){if(i.local&&i.localPath&&e.localPath&&ds.existsSync(cs.resolve(i.localPath,e.localPath))){const t=ds.readFileSync(cs.resolve(i.localPath,e.localPath)).toString();S.injectStyle(e.name,t);continue}const t=u.formatString(i.local&&null!=e.local?e.local:e.url,{repo:i.repo,hash:i.hash,localServer:i.localServer});c.log("Startup",`Loading Resource (${t})`);const s=("script"==e.type?S.injectScript:S.linkStyle).bind(S);try{await s(e.name,t)}catch(n){const o=u.formatString(e.backup,{minified:i.minified?".min":""});c.stacktrace("Startup",`Could not load ${t}. Using backup ${o}`,n);try{await s(e.name,o)}catch(s){c.stacktrace("Startup",`Could not load ${t}. Using backup ${o}`,n),"jquery"===e.name&&_.alert(k.Startup.jqueryFailed,k.Startup.jqueryFailedDetails)}}}}async updateInjector(){const e=w.injectionPath;if(!e)return!1;const t=s(6),n=s(7),i=s(8),o=s(3),r=cs.resolve(e,".."),a=cs.basename(e),l="https://github.com/rauenzi/BetterDiscordApp/archive/injector.zip",d=cs.resolve(r,"injector.zip"),h=cs.resolve(r,"BetterDiscordApp-injector");c.log("InjectorUpdate","Downloading "+l);let u=await new Promise(e=>{o.get({url:l,encoding:null},async(t,s,n)=>{if(t||200!==s.statusCode)return e(!1);await new Promise(e=>ds.exists(d,e))&&await new Promise(e=>ds.rename(d,`${d}.bak${Math.round(performance.now())}`,e)),c.log("InjectorUpdate","Writing "+d),ds.writeFile(d,n,t=>e(!t))})});if(!u)return u;await new Promise(e=>ds.exists(h,e))&&await new Promise(e=>ds.rename(h,`${h}.bak${Math.round(performance.now())}`,e));const p=await new Promise((e,t)=>n.open(d,{lazyEntries:!0},(s,n)=>{if(s)return t(s);e(n)}));p.on("entry",(function(e){if(e.fileName.endsWith("/"))return p.readEntry();c.log("InjectorUpdate","Extracting "+e.fileName);const t=cs.resolve(r,e.fileName);i.sync(cs.dirname(t)),p.openReadStream(e,(function(e,s){if(e)return u=!1;s.on("end",(function(){p.readEntry()})),s.pipe(ds.createWriteStream(t))}))})),p.readEntry(),await new Promise(e=>p.once("end",e));const m=cs.resolve(r,`${a}.bak${Math.round(performance.now())}`);return await new Promise(t=>ds.rename(e,m,t)),c.log("InjectorUpdate",`Renaming ${cs.basename(h)} to ${a}`),u=await new Promise(t=>ds.rename(h,e,e=>t(!e))),u?u?(await new Promise(e=>t(m,e)),await new Promise(e=>ds.unlink(d,e)),c.log("InjectorUpdate","Injector Updated!"),u):(c.err("InjectorUpdate","Something went wrong... restoring backups."),await new Promise(e=>t(h,e)),await new Promise(t=>ds.rename(m,e,t)),u):(c.err("InjectorUpdate","Failed to rename the final directory"),u)}}}]);