');i.append(h.createElement(`
${k.Developer.copySelector}
`)),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 Ye{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){119!==e.which&&118!=e.which||(e.preventDefault(),e.stopImmediatePropagation())}};const es=s(0),ts=s(2),ss=s(1),ns=es.remote.BrowserWindow;var is=new class extends Ye{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 W.alert(k.ReactDevTools.notFound,k.ReactDevTools.notFoundDetails);ns.addDevToolsExtension(this.extensionPath)?this.log("Successfully installed react devtools."):this.error("Couldn't find react devtools in chrome extensions!")}disabled(){this.isExtensionInstalled&&ns.removeDevToolsExtension("React Developer Tools")}};class rs 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 os=f.React,as=g.getByDisplayName("Tooltip");var ls=new class{initialize(){p.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),p.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),p.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),p.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")(),p.suppressErrors(this.patchMessageHeader.bind(this),"BD Message Header Patch")(),p.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 r=n.props.children;if(!r||!r.length||r.length<3)return;if("Separator"!==r[r.length-3].type.displayName)return;if(!r[r.length-2].type.toString().includes("socialLinks"))return;if(t){const e=r[r.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(rs,{size:"16px",className:"bd-social-logo"}))),s};r[r.length-2].type=s}const o=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=r[r.length-1].type;r[r.length-1].type=function(){const e=d(...arguments);return e.props.children.splice(e.props.children.length-1,0,o),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=p.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=p.findInReactTree(n,e=>e.type&&!e.type.displayName&&"function"==typeof e.type&&p.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=p.getNestedProp(s[0],"message.author"),r=p.getNestedProp(n,"props.children.1.props.children.1.props.children");r&&i&&i.id&&"249746236008169473"===i.id&&Array.isArray(r)&&r.push(os.createElement(as,{color:"black",position:"top",text:"BandagedBD Developer"},e=>os.createElement(t,Object.assign({className:"bd-chat-badge",href:"https://github.com/rauenzi/BetterDiscordApp",title:"BandagedBD",target:"_blank"},e),os.createElement(rs,{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=p.getNestedProp(e,"props.user"),r=p.getNestedProp(n,"props.children");r&&i&&i.id&&"249746236008169473"===i.id&&Array.isArray(r)&&r.push(os.createElement(as,{color:"black",position:"top",text:"BandagedBD Developer"},e=>os.createElement(t,Object.assign({className:"bd-member-badge",href:"https://github.com/rauenzi/BetterDiscordApp",title:"BandagedBD",target:"_blank"},e),os.createElement(rs,{size:"16px",className:"bd-logo"}))))}))}};const ds=s(2),cs=s(1),{ipcRenderer:hs}=s(0),ps=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 lt}return n.apply(this,arguments)}}(),window.BdApi=lt,ht.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:"//cdn.staticaly.com/gh/{{repo}}/BetterDiscordApp/{{hash}}/dist/style.min.css",backup:"//rauenzi.github.io/BetterDiscordApp/dist/style.min.css",local:"{{localServer}}/BetterDiscordApp/dist/style.min.css",localPath:"style.min.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.version&&W.showConfirmationModal(k.Startup.updateAvailable,k.Startup.updateInfo.format({version:t}),{confirmText:k.Startup.updateNow,cancelText:k.Startup.maybeLater,onConfirm:async()=>{const e=()=>{W.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 r=Qe.initialize();c.log("Startup","Loading Themes");const o=Ze.initialize();c.log("Startup","Removing Loading Icon"),ht.hide(),c.log("Startup","Collecting Startup Errors"),W.showAddonErrors({plugins:r,themes:o});const a=w.getBDData("version");i.bbdVersion>a&&(W.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=ps.wrapper.split(" ")[0],r=ps.listItem.split(" ")[0],o=ps.blobContainer.split(" ")[0];return document.querySelectorAll(`.${n} .${r} .${o}`).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=p.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 r=p.formatString(e.backup,{minified:i.minified?".min":""});c.stacktrace("Startup",`Could not load ${t}. Using backup ${r}`,n);try{await s(e.name,r)}catch(s){c.stacktrace("Startup",`Could not load ${t}. Using backup ${r}`,n),"jquery"===e.name&&W.alert(k.Startup.jqueryFailed,k.Startup.jqueryFailedDetails)}}}}async updateInjector(){const e=w.injectionPath;if(!e)return!1;const t=s(2),n=s(1),i=s(6),r=s(7),o=s(8),a=s(3),l=n.resolve(e,".."),d=n.basename(e),h="https://github.com/rauenzi/BetterDiscordApp/archive/injector.zip",p=n.resolve(l,"injector.zip"),u=n.resolve(l,"BetterDiscordApp-injector");c.log("InjectorUpdate","Downloading "+h);let m=await new Promise(e=>{a.get({url:h,encoding:null},async(s,n,i)=>{if(s||200!==n.statusCode)return e(!1);await new Promise(e=>t.exists(p,e))&&await new Promise(e=>t.rename(p,`${p}.bak${Math.round(performance.now())}`,e)),c.log("InjectorUpdate","Writing "+p),t.writeFile(p,i,t=>e(!t))})});if(!m)return m;await new Promise(e=>t.exists(u,e))&&await new Promise(e=>t.rename(u,`${u}.bak${Math.round(performance.now())}`,e));const g=await new Promise(e=>r.open(p,{lazyEntries:!0},(t,s)=>e(s)));g.on("entry",(function(e){if(e.fileName.endsWith("/"))return g.readEntry();c.log("InjectorUpdate","Extracting "+e.fileName);const s=n.resolve(l,e.fileName);o.sync(n.dirname(s)),g.openReadStream(e,(function(e,n){if(e)return m=!1;n.on("end",(function(){g.readEntry()})),n.pipe(t.createWriteStream(s))}))})),g.readEntry(),await new Promise(e=>g.once("end",e));const f=n.resolve(l,`${d}.bak${Math.round(performance.now())}`);return await new Promise(s=>t.rename(e,f,s)),c.log("InjectorUpdate",`Renaming ${n.basename(u)} to ${d}`),m=await new Promise(s=>t.rename(u,e,e=>s(!e))),m?m?(await new Promise(e=>i(f,e)),await new Promise(e=>t.unlink(p,e)),c.log("InjectorUpdate","Injector Updated!"),m):(c.err("InjectorUpdate","Something went wrong... restoring backups."),await new Promise(e=>i(u,e)),await new Promise(s=>t.rename(f,e,s)),m):(c.err("InjectorUpdate","Failed to rename the final directory"),m)}}}]);