revenge-plugins/server-drawer/install/index.js
2026-08-02 12:57:33 +00:00

1 line
26 KiB
JavaScript

(function(v,N,f,c,o,r,a,ee,D,L,te,Ne){"use strict";function E(e){const t=window?.modules;if(t)for(const n in t){const s=t[n];if(!s?.isInitialized)continue;const i=s.publicModule?.exports;if(i)try{if(e(i))return i;if(i.default!=null&&e(i.default))return i.default}catch{}}}function w(...e){return E(function(t){return e.every(function(n){return t?.[n]!==void 0})})}function P(...e){return E(function(t){return e.every(function(n){return typeof t?.[n]=="function"})})}function et(e){return E(function(t){return typeof t?.getName=="function"&&t.getName.length===0&&t.getName()===e})}function tt(e){const t=P("useIsMobileQuestDockRendered");if(!t?.useIsMobileQuestDockRendered)return!1;const n=t.useIsMobileQuestDockRendered;return t.useIsMobileQuestDockRendered=function(...s){return n.apply(this,s),!0},e.push(function(){t.useIsMobileQuestDockRendered=n}),!0}function nt(e){const t=P("useIsMobileQuestDockRenderedBase");if(!t?.useIsMobileQuestDockRenderedBase)return!1;const n=t.useIsMobileQuestDockRenderedBase;return t.useIsMobileQuestDockRenderedBase=function(...s){return n.apply(this,s),!0},e.push(function(){t.useIsMobileQuestDockRenderedBase=n}),!0}function ot(e){const t=P("useIsMobileQuestDockVisibleToUser");if(!t?.useIsMobileQuestDockVisibleToUser)return!1;const n=t.useIsMobileQuestDockVisibleToUser;return t.useIsMobileQuestDockVisibleToUser=function(...s){return n.apply(this,s),!0},e.push(function(){t.useIsMobileQuestDockVisibleToUser=n}),!0}function rt(e){const t=P("useMobileQuestDock");if(!t?.useMobileQuestDock)return!1;const n=t.useMobileQuestDock;return t.useMobileQuestDock=function(...s){return n.apply(this,s)||{id:"server-drawer",config:{quest_content_type:0,assets:{questBarHeroVideo:null,questBarHero:null},features:[]},userStatus:{enrolledAt:"2099-01-01",claimedAt:null},benefits:{rewards:[]},guildId:"0",tasks:[]}},e.push(function(){t.useMobileQuestDock=n}),!0}const st="[ServerDrawer]";function it(e){const t=P("getQuestAsset");if(!t?.getQuestAsset)return console.log(st,"WARN: getQuestAsset not found"),!1;const n=t.getQuestAsset;return t.getQuestAsset=function(...s){try{return n.apply(this,s)}catch{return{url:null,isAnimated:!1}}},e.push(function(){t.getQuestAsset=n}),!0}function S(e){let t,n=!1;return function(){if(n)return t;const s=e();return s!=null&&(t=s,n=!0),s??void 0}}const me=a.findByStoreName("GuildStore"),lt=a.findByProps("useStateFromStores"),at=a.findByProps("colors","unsafe_rawColors")?.colors;function be({id:e,size:t=48}){const n=lt?.useStateFromStores?.([me],function(){return me?.getGuild?.(e)},[e])??null;if(!n)return null;const s=t>=40?16:8;return n.icon?o.createElement(r.Image,{source:{uri:`https://cdn.discordapp.com/icons/${n.id}/${n.icon}.png?size=${t*2}`},style:{width:t,height:t,borderRadius:s}}):o.createElement(r.View,{style:[Ce.fallback,{width:t,height:t,borderRadius:s,backgroundColor:at?.BG_ACCENT??"#5865f2"}]},o.createElement(r.Text,{style:[Ce.letter,{fontSize:Math.max(10,t*.4)}]},n.name?.split(" ").map(function(i){return i[0]}).join("").slice(0,2).toUpperCase()||"?"))}const Ce=r.StyleSheet.create({fallback:{alignItems:"center",justifyContent:"center"},letter:{color:"#fff",fontWeight:"700"}}),ut=a.findByStoreName("ThemeStore"),ct=a.find(function(e){return e?.default?.internal?.resolveSemanticColor})?.default?.internal?.resolveSemanticColor??a.find(function(e){return e?.meta?.resolveSemanticColor})?.meta?.resolveSemanticColor??function(){};function dt(e,t=ut?.theme){if(e)try{return ct(t,e)}catch{return}}const Se=a.findByProps("TextStyleSheet")?.TextStyleSheet,ke=a.findByProps("triggerHapticFeedback","HapticFeedbackTypes");function j(e,t){return dt(e)??t}const F=12,ne=12,Ee=42,oe=220,we=4,x=16,O=20,De={tension:200,friction:20};function ft({visible:e,items:t,title:n,anchorX:s,anchorY:i,onClose:l}){const{width:u,height:g}=r.Dimensions.get("window"),p=(n?ne+20+we:0)+t.length*Ee;let b=s,y=i+48+10;b+oe>u-F&&(b=u-oe-F),b<F&&(b=F),y+p>g-F&&(y=i-p-10),y<F&&(y=F);const m=j(L.semanticColors?.BACKGROUND_SURFACE_HIGHEST,"#1e1f22"),d=j(L.semanticColors?.BORDER_SUBTLE,"#3f4147"),C=j(L.semanticColors?.TEXT_STRONG,"#f2f3f5"),B=j(L.semanticColors?.BACKGROUND_MOD_SUBTLE,"rgba(255,255,255,0.06)"),G=o.useRef(new r.Animated.Value(0)).current,Q=o.useRef(new r.Animated.Value(.5)).current,M=o.useRef(new r.Animated.Value(0)).current,[fe,$]=o.useState(!1),T=o.useRef(!1);o.useEffect(function(){e&&!T.current&&($(!0),G.setValue(0),Q.setValue(.5),M.setValue(0),r.Animated.parallel([r.Animated.timing(G,{toValue:1,duration:150,useNativeDriver:!0}),r.Animated.spring(Q,{toValue:1,useNativeDriver:!0,...De}),r.Animated.spring(M,{toValue:1,useNativeDriver:!0,...De})]).start())},[e]);const he=o.useCallback(function(){T.current||(T.current=!0,r.Animated.parallel([r.Animated.timing(G,{toValue:0,duration:120,useNativeDriver:!0}),r.Animated.timing(Q,{toValue:.8,duration:120,useNativeDriver:!0}),r.Animated.timing(M,{toValue:0,duration:120,useNativeDriver:!0})]).start(function(){T.current=!1,$(!1),l()}))},[l]);return fe?o.createElement(r.Modal,{transparent:!0,visible:fe,onRequestClose:he,statusBarTranslucent:!0},o.createElement(r.Pressable,{style:re.root,onPress:he},o.createElement(r.Animated.View,{style:[re.backdrop,{opacity:G}]}),o.createElement(r.Animated.View,{style:[re.container,{left:b,top:y,backgroundColor:m,borderColor:d,minWidth:oe,opacity:M,transform:[{scale:Q}]}]},n?o.createElement(r.View,null,o.createElement(r.Text,{style:[Se?.["text-md/bold"],{color:C,paddingHorizontal:ne,paddingTop:13,paddingBottom:12}]},n),o.createElement(r.View,{style:{borderBottomWidth:we,borderBottomColor:d}})):null,t.map(function(R,ge){const pe=ge===0&&!n,ye=ge===t.length-1,mn=!!(R.iconSource||R.IconComponent);return o.createElement(r.Pressable,{key:ge,style:function({pressed:bn}){return{paddingHorizontal:ne,paddingVertical:10,minHeight:Ee,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:8,backgroundColor:bn?B:"transparent",borderTopLeftRadius:pe?x:0,borderTopRightRadius:pe?x:0,borderBottomLeftRadius:ye?x:0,borderBottomRightRadius:ye?x:0,borderBottomWidth:!pe&&!ye?1:0,borderBottomColor:d}},onPress:function(){ke?.triggerHapticFeedback?.(ke.HapticFeedbackTypes.IMPACT_LIGHT),he(),R.action?.()}},o.createElement(r.Text,{style:[Se?.["text-md/medium"],{flexShrink:1,color:C}]},R.label),mn?o.createElement(r.View,{style:{width:O,height:O,alignItems:"center",justifyContent:"center"}},R.IconComponent?o.createElement(R.IconComponent,{size:"sm",color:C}):R.iconSource?o.createElement(r.Image,{source:R.iconSource,style:{width:O,height:O,tintColor:C}}):null):null)})))):null}const re=r.StyleSheet.create({root:{flex:1},backdrop:{...r.StyleSheet.absoluteFill,backgroundColor:"rgba(0,0,0,0.55)"},container:{position:"absolute",borderWidth:1,borderRadius:x,overflow:"hidden",elevation:20,shadowColor:"#000",shadowOffset:{width:0,height:12},shadowOpacity:.24,shadowRadius:24}}),_=48,Ie=a.findByProps("useStateFromStores"),U=a.findByStoreName("GuildReadStateStore"),ht=a.findByStoreName("GuildStore"),se=a.findByStoreName("GuildChannelStore"),gt=a.findByStoreName("ChannelStore"),Re=a.findByProps("triggerHapticFeedback","HapticFeedbackTypes"),pt=S(function(){return w("bulkAck","ackChannel")}),yt=S(function(){return w("ReadStateTypes","UnreadSetting")?.ReadStateTypes});function mt(e){const t=pt(),n=yt();if(!t?.bulkAck||n?.CHANNEL==null||!se?.getSelectableChannelIds){D.showToast("Couldn't find Discord's read-state action - this may be unavailable on your version.",void 0);return}const s=[...se.getSelectableChannelIds(e)??[],...se.getVocalChannelIds?.(e)??[]].map(function(i){return{channelId:i,readStateType:n.CHANNEL,messageId:gt?.getChannel?.(i)?.lastMessageId??null}});if(s.length===0){D.showToast("Nothing to mark as read.",void 0);return}t.bulkAck(s),D.showToast("Marked as read",void 0)}function bt({guildId:e}){ee.useProxy(f.storage);const t=Ie?.useStateFromStores?.([U],function(){return U?.getMentionCount?.(e)??0},[e])??0,n=Ie?.useStateFromStores?.([U],function(){return U?.hasUnread?.(e)??!1},[e])??!1;return f.storage.showUnreadBadges?t>0?o.createElement(r.View,{style:A.outline},o.createElement(r.View,{style:A.badge},o.createElement(r.Text,{style:A.text},t>99?"99+":String(t)))):n?o.createElement(r.View,{style:A.dotOutline},o.createElement(r.View,{style:A.dot})):null:null}function Fe({node:e,onPick:t}){const n=o.useRef(null),s=o.useRef(new r.Animated.Value(1)).current,i=function(){return r.Animated.spring(s,{toValue:.85,useNativeDriver:!0}).start()},l=function(){return r.Animated.spring(s,{toValue:1,useNativeDriver:!0}).start()},[u,g]=o.useState({visible:!1,items:[],title:"",x:0,y:0}),p=o.useCallback(function(){const m=e.id,d=ht?.getGuild?.(m);if(!d)return;const C=n.current;if(!C?.measure)return;const B=[{label:"Mark as Read",action:function(){return mt(m)}},{label:"Copy Server ID",action:function(){c.clipboard.setString(m),D.showToast("Copied server ID",void 0)}}];C.measure(function(G,Q,M,fe,$,T){g({visible:!0,items:B,title:d.name,x:$,y:T})})},[e.id]),b=o.useCallback(function(){Re?.triggerHapticFeedback?.(Re.HapticFeedbackTypes.IMPACT_MEDIUM),p()},[p]),y=e.id;return o.createElement(o.Fragment,null,o.createElement(r.Pressable,{onPressIn:i,onPressOut:l,onPress:function(){return t(y)},onLongPress:b,delayLongPress:500},o.createElement(r.View,{ref:n,style:Be.outer,collapsable:!1},o.createElement(r.Animated.View,{style:[Be.icon,{transform:[{scale:s}]}]},o.createElement(be,{id:y})),o.createElement(bt,{guildId:y}))),o.createElement(ft,{visible:u.visible,items:u.items,title:u.title,anchorX:u.x,anchorY:u.y,onClose:function(){return g(function(m){return{...m,visible:!1}})}}))}const Be=r.StyleSheet.create({outer:{width:_,height:_},icon:{width:_,height:_,borderRadius:16,overflow:"hidden"}}),A=r.StyleSheet.create({outline:{position:"absolute",bottom:-3,right:-3,minWidth:23,minHeight:23,borderRadius:12,backgroundColor:"#1a1a2e",alignItems:"center",justifyContent:"center"},badge:{minWidth:19,height:19,borderRadius:9,backgroundColor:"#ed4245",alignItems:"center",justifyContent:"center",paddingHorizontal:5},text:{color:"#fff",fontSize:10,fontWeight:"700",lineHeight:19},dotOutline:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,backgroundColor:"#1a1a2e",alignItems:"center",justifyContent:"center"},dot:{width:10,height:10,borderRadius:5,backgroundColor:"#ed4245"}}),Ct=a.findByProps("useStateFromStores");a.findByProps("colors","unsafe_rawColors")?.colors;const Te=a.findByStoreName("ExpandedGuildFolderStore");function St(e){return Ct?.useStateFromStores?.([Te],function(){const t=Te?.getExpandedFolders?.();return t instanceof Set?t.has(e):!1},[e])??!1}const kt=a.findByProps("toggleGuildFolderExpand"),Et=a.findByProps("useStateFromStores"),Pe=a.findByStoreName("GuildReadStateStore"),I=48,ie=16,wt=[{top:6,left:6},{top:6,right:6},{bottom:6,left:6},{bottom:6,right:6}],xe=te.getAssetIDByName("FolderIcon");function Ae(e){return e==null?"#5865f2":`#${e.toString(16).padStart(6,"0")}`}function Dt({node:e}){const t=Et?.useStateFromStores?.([Pe],function(){let n=0;for(const s of e.children)n+=Pe?.getMentionCount?.(s.id)??0;return n},[e.children])??0;return t>0?o.createElement(r.View,{style:ae.outline},o.createElement(r.View,{style:ae.badge},o.createElement(r.Text,{style:ae.text},t>99?"99+":String(t)))):null}function It({node:e}){ee.useProxy(f.storage);const t=Ae(e.color);return o.createElement(r.View,{style:z.outer},o.createElement(r.View,{style:[z.icon,{backgroundColor:t}]},f.storage.hideFolderIcons?o.createElement(r.View,{style:z.plainIcon},o.createElement(r.Image,{source:xe,style:le.folderImg,tintColor:"#fff"})):e.children.slice(0,4).map(function(n,s){return o.createElement(r.View,{key:n.id,style:[z.cell,wt[s]]},o.createElement(be,{id:n.id,size:ie}))})),o.createElement(Dt,{node:e}))}const z=r.StyleSheet.create({outer:{width:I,height:I},icon:{width:I,height:I,borderRadius:16,overflow:"hidden"},cell:{position:"absolute",width:ie,height:ie,borderRadius:8,overflow:"hidden"},plainIcon:{width:I,height:I,alignItems:"center",justifyContent:"center"}});function Rt({children:e}){const t=o.useRef(new r.Animated.Value(0)).current;return o.useEffect(function(){r.Animated.timing(t,{toValue:1,duration:180,useNativeDriver:!0}).start()},[]),o.createElement(r.Animated.View,{style:{opacity:t}},e)}function Ft({node:e,onPick:t}){const n=St(e.id),s=function(){kt?.toggleGuildFolderExpand?.(e.id)};return n?o.createElement(o.Fragment,null,o.createElement(r.Pressable,{onPress:s},o.createElement(r.View,{style:[le.openIcon,{backgroundColor:Ae(e.color)}]},o.createElement(r.Image,{source:xe,style:le.folderImg,tintColor:"#fff"}))),e.children.map(function(i){return o.createElement(Rt,{key:i.id},o.createElement(Fe,{node:i,onPick:t}))})):o.createElement(r.Pressable,{onPress:s},o.createElement(It,{node:e}))}const le=r.StyleSheet.create({openIcon:{width:I,height:I,borderRadius:16,alignItems:"center",justifyContent:"center"},folderImg:{width:24,height:24}}),ae=r.StyleSheet.create({outline:{position:"absolute",bottom:-3,right:-3,minWidth:23,minHeight:23,borderRadius:12,backgroundColor:"#1a1a2e",alignItems:"center",justifyContent:"center"},badge:{minWidth:19,height:19,borderRadius:9,backgroundColor:"#ed4245",alignItems:"center",justifyContent:"center",paddingHorizontal:5},text:{color:"#fff",fontSize:10,fontWeight:"700",lineHeight:19}}),W=48,Bt=te.getAssetIDByName("ChatIcon"),Ve=a.findByProps("triggerHapticFeedback","HapticFeedbackTypes"),He=a.findByProps("selectPrivateChannel"),Tt=a.findByName("SelectedChannelStore"),Pt=a.findByProps("useStateFromStores"),Ge=a.findByProps("getGuildId"),xt=a.findByProps("colors","unsafe_rawColors")?.colors;function At(){if(Ve?.triggerHapticFeedback(Ve.HapticFeedbackTypes.SOFT),He?.selectPrivateChannel){const e=Tt?.getLastSelectedChannelId?.();He.selectPrivateChannel(e)}}function Vt(){const e=Pt?.useStateFromStores?.([Ge],function(){return Ge?.getGuildId?.()==null})??!1;return o.createElement(r.Pressable,{onPress:At,style:Qe.outer},o.createElement(r.View,{style:[Qe.icon,{backgroundColor:e?xt?.BG_ACCENT??"#5865f2":"rgba(128,128,128,0.24)"}]},o.createElement(r.Image,{source:Bt,style:{width:24,height:24,tintColor:"#fff"}})))}const Qe=r.StyleSheet.create({outer:{width:W,height:W},icon:{width:W,height:W,borderRadius:16,alignItems:"center",justifyContent:"center"}}),Me=48,Ht=te.getAssetIDByName("CheckmarkLargeIcon"),Gt=a.findByStoreName("SortedGuildStore"),q=a.findByStoreName("GuildChannelStore"),Qt=a.findByStoreName("ChannelStore"),Mt=S(function(){return w("triggerHapticFeedback","HapticFeedbackTypes")}),vt=S(function(){return w("bulkAck","ackChannel")}),Lt=S(function(){return w("ReadStateTypes","UnreadSetting")?.ReadStateTypes});function jt(){const e=(Gt?.getGuildsTree?.()?.root?.children??[]).filter(function(s){return s?.type!=="root"}),t=[],n=function(s){for(const i of s)i.type==="folder"?n(i.children??[]):i.id!=null&&t.push(String(i.id))};return n(e),t}function Ot(){const e=vt(),t=Lt();if(!e?.bulkAck||t?.CHANNEL==null||!q?.getSelectableChannelIds||!q?.getVocalChannelIds){D.showToast("Couldn't find Discord's read-state action - this may be unavailable on your version.",void 0);return}const n=jt();if(n.length===0){D.showToast("Nothing to mark as read.",void 0);return}const s=[];for(const i of n){const l=[...q.getSelectableChannelIds(i)??[],...q.getVocalChannelIds(i)??[]];for(const u of l)s.push({channelId:u,readStateType:t.CHANNEL,messageId:Qt?.getChannel?.(u)?.lastMessageId??null})}if(s.length===0){D.showToast("Nothing to mark as read.",void 0);return}e.bulkAck(s),D.showToast(`Marked ${s.length} channel${s.length===1?"":"s"} as read`,void 0)}function _t(){const e=o.useCallback(function(){const t=Mt();t?.triggerHapticFeedback?.(t.HapticFeedbackTypes.SOFT),Ot()},[]);return o.createElement(r.Pressable,{onPress:e,style:Ut.outer},o.createElement(r.Image,{source:Ht,style:{width:24,height:24,tintColor:"#80848e"}}))}const Ut=r.StyleSheet.create({outer:{width:Me,height:Me,alignItems:"center",justifyContent:"center"}}),zt=a.findByProps("useStateFromStores"),ve=a.findByStoreName("SortedGuildStore"),Wt=S(function(){return w("getRootNavigationRef")}),Le=S(function(){return w("triggerHapticFeedback","HapticFeedbackTypes")}),qt=S(function(){return w("transitionToGuild")}),Xt=S(function(){return E(function(e){return typeof e?.handleCreateJoinGuildPress=="function"})}),Jt=S(function(){return E(function(e){return e?.CirclePlusIcon})?.CirclePlusIcon}),Kt=S(function(){return w("colors","unsafe_rawColors")?.unsafe_rawColors}),Yt=a.find(function(e){return e?.QuestDockExternalCoordinationContext}),je=Yt?.QuestDockExternalCoordinationContext,Oe=a.find(function(e){return e?.QuestDockMode?.COLLAPSED!=null})?.QuestDockMode,X=48,J=6,Zt=12;function $t(){const e=o.useRef(new r.Animated.Value(1)).current,t=o.useCallback(function(){r.Animated.spring(e,{toValue:.9,useNativeDriver:!0}).start()},[e]),n=o.useCallback(function(){r.Animated.spring(e,{toValue:1,useNativeDriver:!0}).start()},[e]),s=o.useCallback(function(){const u=Le();u?.triggerHapticFeedback?.(u.HapticFeedbackTypes.SOFT),Xt()?.handleCreateJoinGuildPress?.()},[]),i=Jt(),l=Kt();return o.createElement(r.Pressable,{onPress:s,onPressIn:t,onPressOut:n},o.createElement(r.Animated.View,{style:[K.createJoin,{backgroundColor:l?.GREEN_360,transform:[{scale:e}]}]},i?o.createElement(i,{size:"md",color:l?.WHITE}):o.createElement(r.Text,{style:[K.createJoinFallback,{color:l?.WHITE}]},"+")))}function _e({gestureContext:e}){const t=o.useCallback(function(d){const C=Le();C?.triggerHapticFeedback?.(C.HapticFeedbackTypes.SOFT);const B=qt();B?.transitionToGuild?B.transitionToGuild(d):Wt()?.getRootNavigationRef?.()?.navigate("guilds",{guildId:d})},[]),n=zt?.useStateFromStores?.([ve],function(){return(ve?.getGuildsTree()?.root?.children||[]).filter(function(d){return d.type!=="root"})})??[],s=e?o.useContext(e):null,i=s?.minExpandedContentHeight,l=o.useCallback(function(d){if(!i)return;const C=d.nativeEvent.layout.height;i.get()!==C&&i.set(C)},[i]),u=(je?o.useContext(je):null)?.setRestingQuestDockMode,g=s?.questDockWrapperSpecs;o.useEffect(function(){if(!u||!Oe||!g)return;const d=r.BackHandler.addEventListener("hardwareBackPress",function(){return(g.get()?.height??56)>80?(u(Oe.COLLAPSED),!0):!1});return function(){return d.remove()}},[u,g]);const{width:p}=r.Dimensions.get("window"),b=Math.max(3,Math.floor((p-Zt*2+J)/(X+J))),y=b*X+(b-1)*J,m=Math.max(0,(p-y)/2);return o.createElement(r.View,{style:K.alignTop},o.createElement(r.View,{style:[K.grid,{paddingHorizontal:m,gap:J}],onLayout:l},o.createElement(Vt,null),n.map(function(d){return d.type==="folder"?o.createElement(Ft,{key:d.id,node:d,onPick:t}):o.createElement(Fe,{key:d.id,node:d,onPick:t})}),o.createElement($t,null),o.createElement(_t,null)))}const K=r.StyleSheet.create({alignTop:{flex:1,justifyContent:"flex-start",alignItems:"flex-start"},grid:{flexDirection:"row",flexWrap:"wrap",paddingTop:4,paddingBottom:16},createJoin:{width:X,height:X,borderRadius:16,alignItems:"center",justifyContent:"center"},createJoinFallback:{fontSize:28,fontWeight:"700",lineHeight:30}});function Nt(e,t,n=100){let s=!1,i;const l=e();return l?(t(l),{cancel(){}}):(i=setInterval(function(){if(s)return;const u=e();u&&(s=!0,clearInterval(i),t(u))},n),{cancel(){s=!0,i&&clearInterval(i)}})}const ue=new Map,Ue=[];let V=[],Y=!1;function ze(e,t,n){ue.set(e,{replacement:t,extraProps:n})}function en(e,t){V.push({predicate:e,onDetected:t})}function tn(e){if(V.length===0)return;const t=[];for(const n of V){let s=!1;try{s=n.predicate(e)}catch{}if(s)try{n.onDetected(e)}catch{}else t.push(n)}V=t}function We(e,t){if(tn(e),t)for(const{predicate:s,replacement:i}of Ue)try{if(s(t))return i?{type:i,props:t}:null}catch{}const n=ue.get(e);if(n)return{type:n.replacement,props:n.extraProps?{...t,...n.extraProps}:t}}function nn(e){if(Y)return;const t=c.React.createElement;if(!t){console.warn("[ServerDrawer] React.createElement is null, skipping patch");return}const n=function(l,u,...g){const p=We(l,u);return p===null?null:p?t.call(c.React,p.type,p.props,...g):t.call(c.React,l,u,...g)};Object.assign(n,t),c.React.createElement=n,Y=!0;const s=[],i=Nt(function(){return E(function(l){return typeof l?.jsx=="function"&&typeof l?.jsxs=="function"&&"Fragment"in l})},function(l){for(const u of["jsx","jsxs"]){const g=l[u];typeof g=="function"&&(l[u]=function(p,b,...y){const m=We(p,b);return m===null?null:m?g.call(this,m.type,m.props,...y):g.call(this,p,b,...y)},s.push(function(){l[u]=g}))}});e.push(function(){i.cancel(),Y&&(c.React.createElement=t,Y=!1),s.forEach(function(l){return l()}),ue.clear(),Ue.length=0,V=[]})}const ce="[ServerDrawer]";let de=null;function qe(){return de||(de=E(function(e){return e?.QuestDockGestureContext})?.QuestDockGestureContext??null),de}function on(e){const t=E(function(s){return s?.type?.displayName==="QuestDockContentExpanded"||s?.type?.name==="QuestDockContentExpanded"});if(!t?.type)return console.log(ce,"WARN: QuestDockContentExpanded not found (will retry)"),!1;const n=t.type;return ze(n,_e,{gestureContext:qe()}),t.type=function(){return c.React.createElement(_e,{gestureContext:qe()})},e.push(function(){t.type=n}),console.log(ce,"PATCH: QuestDockContentExpanded replaced"),!0}function H(e,t){const n=E(function(l){return l?.type?.displayName===e||l?.type?.name===e});if(!n?.type)return console.log(ce,`WARN: ${e} not found`),!1;const s=n.type,i=s;return n.type=function(){return null},i&&(Object.defineProperties(n.type,Object.getOwnPropertyDescriptors(i)),n.type.displayName=e),t.push(function(){n.type=s}),!0}const Xe="[ServerDrawer]";function rn(){return null}function sn(e){return e?.name==="GuildsBar"||e?.displayName==="GuildsBar"}function ln(e){return en(sn,function(t){ze(t,rn),console.log(Xe,"PATCH: found the real GuildsBar reference, now rendering nothing")}),e.push(function(){}),console.log(Xe,"PATCH: watching for the real GuildsBar to appear"),!0}function an(e){const t=et("ExpandedGuildFolderStore");if(!t?.getExpandedFolders)return!1;const n=function({folderId:s}){if(!f.storage.autoCollapseFolders||s==null)return;const i=t.getExpandedFolders();if(!(!(i instanceof Set)||!i.has(s)))for(const l of i)l!==s&&c.FluxDispatcher.dispatch({type:"TOGGLE_GUILD_FOLDER_EXPAND",folderId:l})};return c.FluxDispatcher.subscribe("TOGGLE_GUILD_FOLDER_EXPAND",n),e.push(function(){return c.FluxDispatcher.unsubscribe("TOGGLE_GUILD_FOLDER_EXPAND",n)}),!0}const{ScrollView:un,View:cn}=c.ReactNative;function dn({children:e}){return c.React.createElement(un,{style:{flex:1}},e,c.React.createElement(cn,{style:{height:24}}))}const{View:fn,Text:hn}=c.ReactNative;function Je({children:e,style:t}){return c.React.createElement(fn,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},t]},c.React.createElement(hn,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},e))}const{FormSection:Ke,FormSwitchRow:Z}=Ne.Forms;function gn(){return ee.useProxy(f.storage),c.React.createElement(dn,null,c.React.createElement(Je,null,"Server Drawer takes over the Quest Dock (the strip above the tab bar) to show your servers as a grid instead - tap to expand, long-press a server for its usual context menu, the chat bubble jumps to DMs, the + button creates or joins a server through Discord's own modal, and the check button marks every channel in every server as read."),c.React.createElement(Ke,{title:"Layout"},c.React.createElement(Z,{label:"Hide the left server rail",subLabel:"Your servers and DMs already live in the drawer, so the rail is redundant",value:f.storage.hideGuildsBar!==!1,onValueChange:function(e){f.storage.hideGuildsBar=e,$e()}}),c.React.createElement(Z,{label:"Unread badges",subLabel:"Show mention counts and unread dots on server icons in the drawer",value:f.storage.showUnreadBadges!==!1,onValueChange:function(e){f.storage.showUnreadBadges=e}})),c.React.createElement(Ke,{title:"Folders"},c.React.createElement(Z,{label:"Auto-collapse other folders",subLabel:"Opening a folder collapses any other folder that was already open",value:!!f.storage.autoCollapseFolders,onValueChange:function(e){f.storage.autoCollapseFolders=e}}),c.React.createElement(Z,{label:"Hide icons in collapsed folders",subLabel:"Show a plain folder icon instead of a 4-server preview",value:!!f.storage.hideFolderIcons,onValueChange:function(e){f.storage.hideFolderIcons=e}})),c.React.createElement(Je,null,"The folder options above are ported from fres621's BetterFolders - its other half (hiding icons in the native left server rail) patched a component that no longer exists in current Discord builds, so it's been rebuilt here instead, where it actually applies to what you see."))}let h=[],k;function pn(e,t){try{return t()}catch(n){return N.logger.error(`[ServerDrawer] "${e}" patch threw, skipping: ${n}`),!1}}function Ye(){const e={questDockRender:function(){return tt(h)},questDockBase:function(){return nt(h)},questDockVisible:function(){return ot(h)},mobileQuestDock:function(){return rt(h)},getQuestAsset:function(){return it(h)},expanded:function(){return on(h)},collapsed:function(){return H("QuestDockContentCollapsed",h)},enrolledHeader:function(){return H("QuestDockEnrolledHeader",h)},unenrolledHeader:function(){return H("QuestDockUnenrolledHeader",h)},enrolledBody:function(){return H("QuestDockEnrolledBody",h)},unenrolledBody:function(){return H("QuestDockUnenrolledBody",h)},autoCollapseFolders:function(){return an(h)},...f.storage.hideGuildsBar?{hideGuildsBar:function(){return ln(h)}}:{}};nn(h);const t=new Set(Object.keys(e)),n=new Set,s=function(){for(const i of t)pn(i,e[i])&&(n.add(i),t.delete(i));t.size===0&&k&&(clearInterval(k),k=void 0)};if(s(),t.size>0){let i=0;k=setInterval(function(){s(),++i>=50&&k&&(clearInterval(k),k=void 0,t.size>0&&N.logger.error(`[ServerDrawer] Gave up waiting on: ${[...t].join(", ")}`))},200)}N.logger.log(`[ServerDrawer] onLoad: applied immediately - ${[...n].join(", ")||"none"}${t.size?`, still waiting on ${[...t].join(", ")}`:""}`)}function Ze(){k&&(clearInterval(k),k=void 0);for(const e of h)try{e()}catch{}h=[]}function $e(){Ze(),Ye()}var yn={onLoad:function(){f.storage.hideGuildsBar??=!0,f.storage.showUnreadBadges??=!0,f.storage.autoCollapseFolders??=!1,f.storage.hideFolderIcons??=!1,Ye()},onUnload:function(){return Ze()},settings:gn};return v.default=yn,v.restart=$e,Object.defineProperty(v,"__esModule",{value:!0}),v})({},vendetta,vendetta.plugin,vendetta.metro.common,window.React,vendetta.metro.common.ReactNative,vendetta.metro,vendetta.storage,vendetta.ui.toasts,vendetta.ui,vendetta.ui.assets,vendetta.ui.components);