revenge-plugins/server-drawer/install/index.js
2026-08-02 13:30:56 +00:00

1 line
26 KiB
JavaScript

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