');i.append(A.createElement('
Remove
')),i.addEventListener("click",()=>{delete this.favoriteEmotes[e.target.getAttribute("title")],e.target.parentElement.remove(),this.saveFavorites(),o()}),r.append(i),s.append(r)},te.prototype.switchHandler=function(e){this.switchQem(e.target.id)},te.prototype.switchQem=function(e){this.twitchButton.classList.remove("active"),this.favoriteButton.classList.remove("active"),this.emojiButton.classList.remove("active");const t=A.query(".emojiPicker-3m1S-j");switch(t.style.display="none",this.faContainer.style.display="none",this.teContainer.style.display="none",e){case"bda-qem-twitch":this.twitchButton.classList.add("active"),this.teContainer.style.display="";break;case"bda-qem-favourite":this.favoriteButton.classList.add("active"),this.faContainer.style.display="";break;case"bda-qem-emojis":this.emojiButton.classList.add("active"),t.style.display="",t.querySelector("input").focus()}},te.prototype.obsCallback=function(e){this.initialized&&(u["bda-es-9"]?e.classList.remove("bda-qme-hidden"):e.classList.add("bda-qme-hidden"),u["bda-es-0"]&&(A.prependTo(this.qmeHeader,e),e.append(this.teContainer),e.append(this.faContainer),this.switchQem("bda-qem-emojis")))},te.prototype.favorite=function(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.updateFavorites()},te.prototype.saveFavorites=function(){ee.setBDData("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))},te.prototype.updateFavorites=function(){this.faInner.innerHTML="";for(const e in this.favoriteEmotes)this.faInner.append(se(e,this.favoriteEmotes[e],{contextmenu:this.favContext}));this.saveFavorites()};var oe=new te;class re extends F.reactComponent{constructor(e){super(e);const t=!!(oe&&oe.favoriteEmotes&&oe.favoriteEmotes[this.label]);this.state={shouldAnimate:!this.animateOnHover,isFavorite:t},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onClick=this.onClick.bind(this)}get animateOnHover(){return u["fork-es-2"]}get label(){return this.props.modifier?`${this.props.name}:${this.props.modifier}`:this.props.name}get modifierClass(){return this.props.modifier?` emote${this.props.modifier}`:""}onMouseEnter(){!this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!0}),!this.state.isFavorite&&oe.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!oe.favoriteEmotes[this.label]&&this.setState({isFavorite:!1})}onMouseLeave(){this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!1})}onClick(e){this.props.onClick&&this.props.onClick(e)}render(){return F.react.createElement(F.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},e=>F.react.createElement("div",Object.assign({className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},e),F.react.createElement("img",{draggable:!1,className:"emote"+this.modifierClass+(this.props.jumboable?" jumboable":"")+(this.state.shouldAnimate?"":" stop-animation"),dataModifier:this.props.modifier,alt:this.label,src:this.props.url}),F.react.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.state.isFavorite?(delete oe.favoriteEmotes[this.label],oe.updateFavorites()):oe.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}function ie(){Object.defineProperty(this,"categories",{get:function(){const e=[];for(const t in w)u[w[t]]&&e.push(t);return e}})}ie.prototype.init=async function(){this.modifiers=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"],this.overrides=["twitch","bttv","ffz"];const e={TwitchGlobal:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_global.json",variable:"TwitchGlobal",oldVariable:"emotesTwitch",getEmoteURL:e=>`https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`},TwitchSubscriber:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_subscriber.json",variable:"TwitchSubscriber",oldVariable:"subEmotesTwitch",getEmoteURL:e=>`https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`},FrankerFaceZ:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_ffz.json",variable:"FrankerFaceZ",oldVariable:"emotesFfz",getEmoteURL:e=>`https://cdn.frankerfacez.com/emoticon/${e}/1`},BTTV:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv.json",variable:"BTTV",oldVariable:"emotesBTTV",getEmoteURL:e=>`https://cdn.betterttv.net/emote/${e}/1x`},BTTV2:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv2.json",variable:"BTTV2",oldVariable:"emotesBTTV2",getEmoteURL:e=>`https://cdn.betterttv.net/emote/${e}/1x`}};for(await this.getBlacklist(),await this.loadEmoteData(e);!F.MessageComponent;)await new Promise(e=>setTimeout(e,100));this.cancelEmoteRender||(this.cancelEmoteRender=j.monkeyPatch(F.MessageComponent,"default",{before:({methodArguments:e})=>{const t=e[0].childrenMessageContent.props.content;if(t&&t.length){for(let e=0;e
"string"==typeof e&&""==e.replace(/\s*/,"")||(!(!e.type||"BDEmote"!=e.type.name)||!!(e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName))))for(const e of t)"object"==typeof e&&("BDEmote"==e.type.name?e.props.jumboable=!0:e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName&&(e.props.children.props.jumboable=!0))}}}))},ie.prototype.disable=function(){this.cancelEmoteRender||(this.cancelEmoteRender(),this.cancelEmoteRender=null)},ie.prototype.clearEmoteData=async function(){const e=n(0),t=m.dataPath+"emote_data.json";e.existsSync(t)&&e.unlinkSync(t),ee.setBDData("emoteCacheDate",(new Date).toJSON()),Object.assign(E,{TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}})},ie.prototype.isCacheValid=function(){const e=ee.getBDData("emoteCacheDays")||ee.setBDData("emoteCacheDays",7)||7,t=new Date(ee.getBDData("emoteCacheDate")||null),n=new Date;return!(Math.round(Math.abs((n.getTime()-t.getTime())/864e5))>e)||(ee.setBDData("emoteCacheDate",n.toJSON()),!1)},ie.prototype.loadEmoteData=async function(e){const t=n(0),s=m.dataPath+"emote_data.json";if(await new Promise(e=>t.exists(s,e))&&this.isCacheValid()){u["fork-ps-2"]&&j.showToast("Loading emotes from cache.",{type:"info"}),j.log("Emotes","Loading emotes from local cache.");const n=await new Promise(e=>{t.readFile(s,"utf8",(t,n)=>{j.log("Emotes","Emote file read."),t&&(n={}),e(n)})}),o=j.testJSON(n);let r=!!o;r&&Object.assign(E,o);for(const t in e)r=Object.keys(E[e[t].variable]).length>0;if(r)return void(u["fork-ps-2"]&&j.showToast("Emotes successfully loaded.",{type:"success"}));j.log("Emotes","Cache was corrupt, downloading..."),await new Promise(e=>t.unlink(s,e))}if(u["fork-es-3"]){u["fork-ps-2"]&&j.showToast("Downloading emotes in the background do not reload.",{type:"info"});for(const t in e){await new Promise(e=>setTimeout(e,1e3));const n=await this.downloadEmotes(e[t]);E[e[t].variable]=n}u["fork-ps-2"]&&j.showToast("All emotes successfully downloaded.",{type:"success"});try{await new Promise(e=>t.writeFile(s,JSON.stringify(E),"utf8",e))}catch(e){j.err("Emotes","Could not save emote data.",e)}}},ie.prototype.downloadEmotes=function(e){const t=n(3),s={url:e.url,timeout:e.timeout?e.timeout:5e3,json:!0};return j.log("Emotes",`Downloading: ${e.variable} (${e.url})`),new Promise((n,o)=>{t(s,(t,s,r)=>{if(t)return j.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),n(this.downloadEmotes(e))):o({});"function"==typeof e.parser&&(r=e.parser(r));for(const t in r)t.length<4||g.includes(t)?delete r[t]:r[t]=e.getEmoteURL(r[t]);n(r),j.log("Emotes","Downloaded: "+e.variable)})})},ie.prototype.getBlacklist=function(){return new Promise(e=>{n(3).get({url:"https://rauenzi.github.io/BetterDiscordApp/data/emotefilter.json",json:!0},(function(t,n,s){if(t)return e(g);e(g.splice(0,0,...s.blacklist))}))})};var ae=new ie;class le extends F.reactComponent{constructor(e){super(e)}render(){return F.react.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class ce extends F.reactComponent{constructor(e){super(e)}render(){return F.react.createElement("div",{className:"ui-tab-bar-header"},this.props.text,this.props.button)}}class de extends F.reactComponent{constructor(e){super(e),this.setInitialState(),this.onClick=this.onClick.bind(this)}setInitialState(){this.state={selected:this.props.selected||!1}}render(){return F.react.createElement("div",{className:`ui-tab-bar-item${this.props.selected?" selected":""}`,onClick:this.onClick},this.props.text)}onClick(){this.props.onClick&&this.props.onClick(this.props.id)}}class ue extends F.reactComponent{constructor(e){super(e);const t=document.querySelector("[class*=side-] > [class*=selected]");t&&(this.scn=t.className);const n=document.querySelector("[class*=side-] > [class*='item-']:not([class*=selected])");n&&(this.nscn=n.className);const s=document.querySelectorAll("[class*='side-'] > [class*='item-']");for(const e of s)e.addEventListener("click",()=>{this.setState({selected:null})});this.setInitialState(),this.onClick=this.onClick.bind(this),this.setSelected=this.setSelected.bind(this)}setInitialState(){const e=this;e.state={selected:null,items:e.props.items};const t=e.props.items.find(e=>e.selected);t&&(e.state.selected=t.id)}render(){const e=this,{headerText:t}=e.props,{items:n,selected:s}=e.state;return F.react.createElement("div",null,F.react.createElement(le,null),F.react.createElement(ce,{text:t,button:this.props.headerButton}),n.map(t=>{const{id:n,text:o}=t;return F.react.createElement(de,{key:n,selected:s===n,text:o,id:n,onClick:e.onClick})}))}setSelected(e){e.target.className=this.scn}onClick(e){const t=document.querySelector("[class*=side] > [class*=selected]");t&&(t.removeEventListener("click",this.setSelected),t.addEventListener("click",this.setSelected),t.className=this.nscn),this.setState({selected:null}),this.setState({selected:e}),this.props.onClick&&this.props.onClick(e)}}const he=F.React;class pe extends he.Component{render(){const e=this.props.size||"18px";return he.createElement("svg",{viewBox:"0 0 24 24",fill:"#FFFFFF",className:this.props.className||"",style:{width:e,height:e},onClick:this.props.onClick},he.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),he.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"}))}}const me=M("tooltip","tooltipBlack"),ge=M("layer","layerContainer"),fe=function(e){const t=e[0].toUpperCase()+e.slice(1),n=me[`tooltip${t}`];return n||null},be=function(e){return!!fe(e)},ve=function(e){return`${e}px`};class ye{constructor(e,t,n={}){const{style:s="black",side:o="top",preventFlip:r=!1,disabled:i=!1}=n;if(this.node=e instanceof jQuery?e[0]:e,this.label=t,this.style=s.toLowerCase(),this.side=o.toLowerCase(),this.preventFlip=r,this.disabled=i,!be(this.side))return j.err("EmulatedTooltip",`Side ${this.side} does not exist.`);if(!be(this.style))return j.err("EmulatedTooltip",`Style ${this.style} does not exist.`);this.element=document.createElement("div"),this.element.className=ge.layer,this.tooltipElement=document.createElement("div"),this.tooltipElement.className=`${me.tooltip} ${fe(this.style)}`,this.labelElement=document.createTextNode("TEST");const a=document.createElement("div");a.className=me.tooltipPointer,this.tooltipElement.append(a),this.tooltipElement.append(this.labelElement),this.element.append(this.tooltipElement),this.node.addEventListener("mouseenter",()=>{if(this.disabled)return;this.show();const e=new MutationObserver(t=>{t.forEach(t=>{const n=Array.from(t.removedNodes),s=n.indexOf(this.node)>-1,o=n.some(e=>e.contains(this.node));(s||o)&&(this.hide(),e.disconnect())})});e.observe(document.body,{subtree:!0,childList:!0})}),this.node.addEventListener("mouseleave",()=>{this.hide()})}get container(){return document.querySelector(".popouts-2bnG9Z ~ .layerContainer-yqaFcK")}get canShowAbove(){return this.node.getBoundingClientRect().top-this.element.offsetHeight>=0}get canShowBelow(){return this.node.getBoundingClientRect().top+this.node.offsetHeight+this.element.offsetHeight<=j.screenHeight}get canShowLeft(){return this.node.getBoundingClientRect().left-this.element.offsetWidth>=0}get canShowRight(){return this.node.getBoundingClientRect().left+this.node.offsetWidth+this.element.offsetWidth<=j.screenWidth}hide(){this.element.remove(),this.tooltipElement.className=this._className}show(){this.tooltipElement.className=`${me.tooltip} ${fe(this.style)}`,this.labelElement.textContent=this.label,this.element.appendTo(this.container),"top"==this.side&&(this.canShowAbove||!this.canShowAbove&&this.preventFlip?this.showAbove():this.showBelow()),"bottom"==this.side&&(this.canShowBelow||!this.canShowBelow&&this.preventFlip?this.showBelow():this.showAbove()),"left"==this.side&&(this.canShowLeft||!this.canShowLeft&&this.preventFlip?this.showLeft():this.showRight()),"right"==this.side&&(this.canShowRight||!this.canShowRight&&this.preventFlip?this.showRight():this.showLeft())}showAbove(){this.tooltipElement.addClass(fe("top")),this.element.style.setProperty("top",ve(this.node.getBoundingClientRect().top-this.element.offsetHeight-10)),this.centerHorizontally()}showBelow(){this.tooltipElement.addClass(fe("bottom")),this.element.style.setProperty("top",ve(this.node.getBoundingClientRect().top+this.node.offsetHeight+10)),this.centerHorizontally()}showLeft(){this.tooltipElement.addClass(fe("left")),this.element.style.setProperty("left",ve(this.node.getBoundingClientRect().left-this.element.offsetWidth-10)),this.centerVertically()}showRight(){this.tooltipElement.addClass(fe("right")),this.element.style.setProperty("left",ve(this.node.getBoundingClientRect().left+this.node.offsetWidth+10)),this.centerVertically()}centerHorizontally(){const e=this.node.getBoundingClientRect().left+this.node.offsetWidth/2;this.element.style.setProperty("left",ve(e-this.element.offsetWidth/2))}centerVertically(){const e=this.node.getBoundingClientRect().top+this.node.offsetHeight/2;this.element.style.setProperty("top",ve(e-this.element.offsetHeight/2))}}var Ce=class extends F.reactComponent{constructor(e){super(e)}async componentDidMount(){const{style:e="black",side:t="top",text:n=""}=this.props;this.node=F.reactDom.findDOMNode(this),this.tooltip=new ye(this.node,n,{style:e,side:t})}componentWillUnmount(){this.tooltip.hide(),delete this.tooltip}render(){return this.props.children}};class Ee{constructor(e){this.onClick=e}get items(){return[{text:"Settings",id:"core"},{text:"Emotes",id:"emotes"},{text:"Plugins",id:"plugins"},{text:"Themes",id:"themes"},{text:"Custom CSS",id:"customcss"}]}get component(){const e=F.react.createElement(Ce,{color:"black",side:"top",text:"Changelog"},F.react.createElement("div",{className:"bd-changelog-button",onClick:()=>{j.showChangelogModal(l)}},F.react.createElement(pe,{className:"bd-icon",size:"16px"})));return F.react.createElement("span",null,F.react.createElement(ue,{onClick:this.onClick,headerText:"Bandaged BD",headerButton:e,items:this.items}))}get root(){const e=A.query("#bd-settings-sidebar");return e||(this.injectRoot()?this.root:null)}injectRoot(){const e=A.queryAll("[class*='side-'] > [class*='item-']:not([class*=Danger])"),t=e[e.length-1];return!!t&&(t.parentElement.insertBefore(A.createElement('