revenge-plugins/server-drawer/install/index.js
2026-08-02 14:25:20 +00:00

1 line
27 KiB
JavaScript

(function(L,te,h,c,r,i,ne,D,O,re,Ue){"use strict";function b(e){const t=window?.modules;if(t)for(const n in t){const o=t[n];if(!o?.isInitialized)continue;const s=o.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 b(function(t){return t?.name===e||t?.displayName===e})}function C(...e){return b(function(t){return e.every(function(n){return typeof t?.[n]=="function"})})}function j(e){const t=Object.keys(e);return b(function(n){return t.every(function(o){try{return e[o](n?.[o])}catch{return!1}})})}function E(e){return b(function(t){return typeof t?.getName=="function"&&t.getName.length===0&&t.getName()===e})}function We(e){const t=C("useIsMobileQuestDockRendered");if(!t?.useIsMobileQuestDockRendered)return!1;const n=t.useIsMobileQuestDockRendered;return t.useIsMobileQuestDockRendered=function(...o){return n.apply(this,o),!0},e.push(function(){t.useIsMobileQuestDockRendered=n}),!0}function qe(e){const t=C("useIsMobileQuestDockRenderedBase");if(!t?.useIsMobileQuestDockRenderedBase)return!1;const n=t.useIsMobileQuestDockRenderedBase;return t.useIsMobileQuestDockRenderedBase=function(...o){return n.apply(this,o),!0},e.push(function(){t.useIsMobileQuestDockRenderedBase=n}),!0}function Je(e){const t=C("useIsMobileQuestDockVisibleToUser");if(!t?.useIsMobileQuestDockVisibleToUser)return!1;const n=t.useIsMobileQuestDockVisibleToUser;return t.useIsMobileQuestDockVisibleToUser=function(...o){return n.apply(this,o),!0},e.push(function(){t.useIsMobileQuestDockVisibleToUser=n}),!0}function Xe(e){const t=C("useMobileQuestDock");if(!t?.useMobileQuestDock)return!1;const n=t.useMobileQuestDock;return t.useMobileQuestDock=function(...o){return n.apply(this,o)||{id:"server-drawer",config:{quest_content_type:0,assets:{questBarHeroVideo:"",questBarHero:""},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=C("getQuestAsset");if(!t?.getQuestAsset)return console.log(Ye,"WARN: getQuestAsset not found"),!1;const n=t.getQuestAsset;return t.getQuestAsset=function(...o){try{return n.apply(this,o)}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 o=e();return o!=null&&(t=o,n=!0),o??void 0}}const V=a(function(){return C("useStateFromStores")}),B=a(function(){return j({triggerHapticFeedback:function(e){return typeof e=="function"},HapticFeedbackTypes:function(e){return e?.SOFT!==void 0}})}),oe=a(function(){return j({colors:function(e){return e?.BG_ACCENT!==void 0},unsafe_rawColors:function(e){return e?.WHITE!==void 0}})}),ye=a(function(){return C("bulkAck","ackChannel")}),Ce=a(function(){return j({ReadStateTypes:function(e){return e?.CHANNEL!==void 0},UnreadSetting:function(e){return e?.ALL_MESSAGES!==void 0}})}),Ze=a(function(){return E("GuildStore")});function Ee({id:e,size:t=48}){const n=V(),o=Ze(),s=oe()?.colors,u=n?.useStateFromStores?.([o],function(){return o?.getGuild?.(e)},[e])??null;if(!u)return null;const l=t>=40?16:8;return u.icon?r.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}}):r.createElement(i.View,{style:[we.fallback,{width:t,height:t,borderRadius:l,backgroundColor:s?.BG_ACCENT??"#5865f2"}]},r.createElement(i.Text,{style:[we.letter,{fontSize:Math.max(10,t*.4)}]},u.name?.split(" ").map(function(g){return g[0]}).join("").slice(0,2).toUpperCase()||"?"))}const we=i.StyleSheet.create({fallback:{alignItems:"center",justifyContent:"center"},letter:{color:"#fff",fontWeight:"700"}}),$e=a(function(){return E("ThemeStore")}),Ne=a(function(){return b(function(e){return e?.default?.internal?.resolveSemanticColor})?.default?.internal?.resolveSemanticColor??b(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 j({TextStyleSheet:function(e){return e?.["text-md/bold"]!==void 0}})?.TextStyleSheet});function U(e,t){return et(e)??t}const x=12,ie=12,ke=42,se=220,Se=4,P=16,z=20,Ie={tension:200,friction:20};function nt({visible:e,items:t,title:n,anchorX:o,anchorY:s,onClose:u}){const l=tt(),g=B(),{width:p,height:S}=i.Dimensions.get("window"),y=(n?ie+20+Se:0)+t.length*ke;let d=o,w=s+48+10;d+se>p-x&&(d=p-se-x),d<x&&(d=x),w+y>S-x&&(w=s-y-10),w<x&&(w=x);const H=U(O.semanticColors?.BACKGROUND_SURFACE_HIGHEST,"#1e1f22"),A=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)"),F=r.useRef(new i.Animated.Value(0)).current,_=r.useRef(new i.Animated.Value(.5)).current,G=r.useRef(new i.Animated.Value(0)).current,[N,je]=r.useState(!1),ee=r.useRef(!1);r.useEffect(function(){e&&!ee.current&&(je(!0),F.setValue(0),_.setValue(.5),G.setValue(0),i.Animated.parallel([i.Animated.timing(F,{toValue:1,duration:150,useNativeDriver:!0}),i.Animated.spring(_,{toValue:1,useNativeDriver:!0,...Ie}),i.Animated.spring(G,{toValue:1,useNativeDriver:!0,...Ie})]).start())},[e]);const ge=r.useCallback(function(){ee.current||(ee.current=!0,i.Animated.parallel([i.Animated.timing(F,{toValue:0,duration:120,useNativeDriver:!0}),i.Animated.timing(_,{toValue:.8,duration:120,useNativeDriver:!0}),i.Animated.timing(G,{toValue:0,duration:120,useNativeDriver:!0})]).start(function(){ee.current=!1,je(!1),u()}))},[u]);return N?r.createElement(i.Modal,{transparent:!0,visible:N,onRequestClose:ge,statusBarTranslucent:!0},r.createElement(i.Pressable,{style:ue.root,onPress:ge},r.createElement(i.Animated.View,{style:[ue.backdrop,{opacity:F}]}),r.createElement(i.Animated.View,{style:[ue.container,{left:d,top:w,backgroundColor:H,borderColor:A,minWidth:se,opacity:G,transform:[{scale:_}]}]},n?r.createElement(i.View,null,r.createElement(i.Text,{style:[l?.["text-md/bold"],{color:f,paddingHorizontal:ie,paddingTop:13,paddingBottom:12}]},n),r.createElement(i.View,{style:{borderBottomWidth:Se,borderBottomColor:A}})):null,t.map(function(T,pe){const me=pe===0&&!n,be=pe===t.length-1,cn=!!(T.iconSource||T.IconComponent);return r.createElement(i.Pressable,{key:pe,style:function({pressed:dn}){return{paddingHorizontal:ie,paddingVertical:10,minHeight:ke,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:8,backgroundColor:dn?I:"transparent",borderTopLeftRadius:me?P:0,borderTopRightRadius:me?P:0,borderBottomLeftRadius:be?P:0,borderBottomRightRadius:be?P:0,borderBottomWidth:!me&&!be?1:0,borderBottomColor:A}},onPress:function(){g?.triggerHapticFeedback?.(g.HapticFeedbackTypes.IMPACT_LIGHT),ge(),T.action?.()}},r.createElement(i.Text,{style:[l?.["text-md/medium"],{flexShrink:1,color:f}]},T.label),cn?r.createElement(i.View,{style:{width:z,height:z,alignItems:"center",justifyContent:"center"}},T.IconComponent?r.createElement(T.IconComponent,{size:"sm",color:f}):T.iconSource?r.createElement(i.Image,{source:T.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,rt=ye,ot=a(function(){return Ce()?.ReadStateTypes}),it=a(function(){return E("GuildReadStateStore")}),st=a(function(){return E("GuildStore")}),ut=a(function(){return E("GuildChannelStore")}),lt=a(function(){return E("ChannelStore")});function at(e){const t=rt(),n=ot(),o=ut(),s=lt();if(!t?.bulkAck||n?.CHANNEL==null||!o?.getSelectableChannelIds){D.showToast("Couldn't find Discord's read-state action - this may be unavailable on your version.",void 0);return}const u=[...o.getSelectableChannelIds(e)??[],...o.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(),o=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?o>0?r.createElement(i.View,{style:M.outline},r.createElement(i.View,{style:M.badge},r.createElement(i.Text,{style:M.text},o>99?"99+":String(o)))):s?r.createElement(i.View,{style:M.dotOutline},r.createElement(i.View,{style:M.dot})):null:null}function De({node:e,onPick:t}){const n=r.useRef(null),o=r.useRef(new i.Animated.Value(1)).current,s=function(){return i.Animated.spring(o,{toValue:.85,useNativeDriver:!0}).start()},u=function(){return i.Animated.spring(o,{toValue:1,useNativeDriver:!0}).start()},[l,g]=r.useState({visible:!1,items:[],title:"",x:0,y:0}),p=r.useCallback(function(){const d=e.id,w=st()?.getGuild?.(d);if(!w)return;const H=n.current;if(!H?.measure)return;const A=[{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)}}];H.measure(function(f,I,F,_,G,N){g({visible:!0,items:A,title:w.name,x:G,y:N})})},[e.id]),S=r.useCallback(function(){const d=B();d?.triggerHapticFeedback?.(d.HapticFeedbackTypes.IMPACT_MEDIUM),p()},[p]),y=e.id;return r.createElement(r.Fragment,null,r.createElement(i.Pressable,{onPressIn:s,onPressOut:u,onPress:function(){return t(y)},onLongPress:S,delayLongPress:500},r.createElement(i.View,{ref:n,style:Re.outer,collapsable:!1},r.createElement(i.Animated.View,{style:[Re.icon,{transform:[{scale:o}]}]},r.createElement(Ee,{id:y})),r.createElement(ct,{guildId:y}))),r.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 Re=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 E("ExpandedGuildFolderStore")});function ft(e){const t=V(),n=dt();return t?.useStateFromStores?.([n],function(){const o=n?.getExpandedFolders?.();return o instanceof Set?o.has(e):!1},[e])??!1}const ht=a(function(){return C("toggleGuildFolderExpand")}),gt=a(function(){return E("GuildReadStateStore")}),R=48,le=16,pt=[{top:6,left:6},{top:6,right:6},{bottom:6,left:6},{bottom:6,right:6}],Fe=re.getAssetIDByName("FolderIcon");function Te(e){return e==null?"#5865f2":`#${e.toString(16).padStart(6,"0")}`}function mt({node:e}){const t=V(),n=gt(),o=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 o>0?r.createElement(i.View,{style:ce.outline},r.createElement(i.View,{style:ce.badge},r.createElement(i.Text,{style:ce.text},o>99?"99+":String(o)))):null}function bt({node:e}){ne.useProxy(h.storage);const t=Te(e.color);return r.createElement(i.View,{style:q.outer},r.createElement(i.View,{style:[q.icon,{backgroundColor:t}]},h.storage.hideFolderIcons?r.createElement(i.View,{style:q.plainIcon},r.createElement(i.Image,{source:Fe,style:ae.folderImg,tintColor:"#fff"})):e.children.slice(0,4).map(function(n,o){return r.createElement(i.View,{key:n.id,style:[q.cell,pt[o]]},r.createElement(Ee,{id:n.id,size:le}))})),r.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=r.useRef(new i.Animated.Value(0)).current;return r.useEffect(function(){i.Animated.timing(t,{toValue:1,duration:180,useNativeDriver:!0}).start()},[]),r.createElement(i.Animated.View,{style:{opacity:t}},e)}function Ct({node:e,onPick:t}){const n=ft(e.id),o=function(){ht()?.toggleGuildFolderExpand?.(e.id)};return n?r.createElement(r.Fragment,null,r.createElement(i.Pressable,{onPress:o},r.createElement(i.View,{style:[ae.openIcon,{backgroundColor:Te(e.color)}]},r.createElement(i.Image,{source:Fe,style:ae.folderImg,tintColor:"#fff"}))),e.children.map(function(s){return r.createElement(yt,{key:s.id},r.createElement(De,{node:s,onPick:t}))})):r.createElement(i.Pressable,{onPress:o},r.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=re.getAssetIDByName("ChatIcon"),wt=a(function(){return C("selectPrivateChannel")}),kt=a(function(){return ze("SelectedChannelStore")}),St=a(function(){return C("getGuildId")});function It(){const e=B();e?.triggerHapticFeedback?.(e.HapticFeedbackTypes.SOFT);const t=wt();if(t?.selectPrivateChannel){const n=kt()?.getLastSelectedChannelId?.();t.selectPrivateChannel(n)}}function Dt(){const e=V(),t=St(),n=oe()?.colors,o=e?.useStateFromStores?.([t],function(){return t?.getGuildId?.()==null})??!1;return r.createElement(i.Pressable,{onPress:It,style:xe.outer},r.createElement(i.View,{style:[xe.icon,{backgroundColor:o?n?.BG_ACCENT??"#5865f2":"rgba(128,128,128,0.24)"}]},r.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"}}),Ae=48,Rt=re.getAssetIDByName("CheckmarkLargeIcon"),Ft=ye,Tt=a(function(){return Ce()?.ReadStateTypes}),xt=a(function(){return E("SortedGuildStore")}),At=a(function(){return E("GuildChannelStore")}),Vt=a(function(){return E("ChannelStore")});function Bt(){const e=(xt()?.getGuildsTree?.()?.root?.children??[]).filter(function(o){return o?.type!=="root"}),t=[],n=function(o){for(const s of o)s.type==="folder"?n(s.children??[]):s.id!=null&&t.push(String(s.id))};return n(e),t}function Ht(){const e=Ft(),t=Tt(),n=At(),o=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:o?.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 Gt(){const e=r.useCallback(function(){const t=B();t?.triggerHapticFeedback?.(t.HapticFeedbackTypes.SOFT),Ht()},[]);return r.createElement(i.Pressable,{onPress:e,style:Pt.outer},r.createElement(i.Image,{source:Rt,style:{width:24,height:24,tintColor:"#80848e"}}))}const Pt=i.StyleSheet.create({outer:{width:Ae,height:Ae,alignItems:"center",justifyContent:"center"}}),Mt=a(function(){return C("getRootNavigationRef")}),vt=a(function(){return C("transitionToGuild")}),Qt=a(function(){return b(function(e){return typeof e?.handleCreateJoinGuildPress=="function"})}),_t=a(function(){return b(function(e){return e?.CirclePlusIcon})?.CirclePlusIcon}),Lt=a(function(){return b(function(e){return e?.QuestDockExternalCoordinationContext})?.QuestDockExternalCoordinationContext}),Ot=a(function(){return b(function(e){return e?.QuestDockMode?.COLLAPSED!=null})?.QuestDockMode}),jt=a(function(){return b(function(e){return typeof e?.getName=="function"&&e.getName.length===0&&e.getName()==="SortedGuildStore"})}),X=48,Y=6,Ut=12;function zt(){const e=r.useRef(new i.Animated.Value(1)).current,t=r.useCallback(function(){i.Animated.spring(e,{toValue:.9,useNativeDriver:!0}).start()},[e]),n=r.useCallback(function(){i.Animated.spring(e,{toValue:1,useNativeDriver:!0}).start()},[e]),o=r.useCallback(function(){const l=B();l?.triggerHapticFeedback?.(l.HapticFeedbackTypes.SOFT),Qt()?.handleCreateJoinGuildPress?.()},[]),s=_t(),u=oe()?.unsafe_rawColors;return r.createElement(i.Pressable,{onPress:o,onPressIn:t,onPressOut:n},r.createElement(i.Animated.View,{style:[K.createJoin,{backgroundColor:u?.GREEN_360,transform:[{scale:e}]}]},s?r.createElement(s,{size:"md",color:u?.WHITE}):r.createElement(i.Text,{style:[K.createJoinFallback,{color:u?.WHITE}]},"+")))}function Ve({gestureContext:e}){const t=r.useCallback(function(f){const I=B();I?.triggerHapticFeedback?.(I.HapticFeedbackTypes.SOFT);const F=vt();F?.transitionToGuild?F.transitionToGuild(f):Mt()?.getRootNavigationRef?.()?.navigate("guilds",{guildId:f})},[]),n=V(),o=jt(),s=n?.useStateFromStores?.([o],function(){return(o?.getGuildsTree()?.root?.children||[]).filter(function(f){return f.type!=="root"})})??[],u=e?r.useContext(e):null,l=u?.minExpandedContentHeight,g=r.useCallback(function(f){if(!l)return;const I=f.nativeEvent.layout.height;l.get()!==I&&l.set(I)},[l]),p=Lt(),S=(p?r.useContext(p):null)?.setRestingQuestDockMode,y=u?.questDockWrapperSpecs;r.useEffect(function(){const f=Ot();if(!S||!f||!y)return;const I=i.BackHandler.addEventListener("hardwareBackPress",function(){return(y.get()?.height??56)>80?(S(f.COLLAPSED),!0):!1});return function(){return I.remove()}},[S,y]);const{width:d}=i.Dimensions.get("window"),w=Math.max(3,Math.floor((d-Ut*2+Y)/(X+Y))),H=w*X+(w-1)*Y,A=Math.max(0,(d-H)/2);return r.createElement(i.View,{style:K.alignTop},r.createElement(i.View,{style:[K.grid,{paddingHorizontal:A,gap:Y}],onLayout:g},r.createElement(Dt,null),s.map(function(f){return f.type==="folder"?r.createElement(Ct,{key:f.id,node:f,onPick:t}):r.createElement(De,{key:f.id,node:f,onPick:t})}),r.createElement(zt,null),r.createElement(Gt,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 Wt(e,t,n=100){let o=!1,s;const u=e();return u?(t(u),{cancel(){}}):(s=setInterval(function(){if(o)return;const l=e();l&&(o=!0,clearInterval(s),t(l))},n),{cancel(){o=!0,s&&clearInterval(s)}})}const de=new Map,Be=[];let v=[],Z=!1;function He(e,t,n){de.set(e,{replacement:t,extraProps:n})}function qt(e,t){v.push({predicate:e,onDetected:t})}function Jt(e){if(v.length===0)return;const t=[];for(const n of v){let o=!1;try{o=n.predicate(e)}catch{}if(o)try{n.onDetected(e)}catch{}else t.push(n)}v=t}function Ge(e,t){if(Jt(e),t)for(const{predicate:o,replacement:s}of Be)try{if(o(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 o=[],s=Wt(function(){return b(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,S,...y){const d=Ge(p,S);return d===null?null:d?g.call(this,d.type,d.props,...y):g.call(this,p,S,...y)},o.push(function(){u[l]=g}))}});e.push(function(){s.cancel(),Z&&(c.React.createElement=t,Z=!1),o.forEach(function(u){return u()}),de.clear(),Be.length=0,v=[]})}const fe="[ServerDrawer]";let he=null;function Pe(){return he||(he=b(function(e){return e?.QuestDockGestureContext})?.QuestDockGestureContext??null),he}function Yt(e){const t=b(function(o){return o?.type?.displayName==="QuestDockContentExpanded"||o?.type?.name==="QuestDockContentExpanded"});if(!t?.type)return console.log(fe,"WARN: QuestDockContentExpanded not found (will retry)"),!1;const n=t.type;return He(n,Ve,{gestureContext:Pe()}),t.type=function(){return c.React.createElement(Ve,{gestureContext:Pe()})},e.push(function(){t.type=n}),console.log(fe,"PATCH: QuestDockContentExpanded replaced"),!0}function Q(e,t){const n=b(function(u){return u?.type?.displayName===e||u?.type?.name===e});if(!n?.type)return console.log(fe,`WARN: ${e} not found`),!1;const o=n.type,s=o;return n.type=function(){return null},s&&(Object.defineProperties(n.type,Object.getOwnPropertyDescriptors(s)),n.type.displayName=e),t.push(function(){n.type=o}),!0}const Me="[ServerDrawer]";function Kt(e){if(e)try{let t=null;if(e._internalFiberInstanceHandleDEV)t=e._internalFiberInstanceHandleDEV;else if(e._internalInstanceHandle)t=e._internalInstanceHandle;else if(e.__internalInstanceHandle)t=e.__internalInstanceHandle;else{const s=Object.keys(e).find(function(u){return u.startsWith("__reactFiber$")||u.startsWith("__reactInternalInstance$")});s&&(t=e[s])}if(!t)return;if(t.return===void 0&&t.child===void 0){const s=t.stateNode??t.fiber??t._debugOwner;if(s&&(s.return!==void 0||s.child!==void 0))t=s;else return}let n=t,o=0;for(;n.return&&o<5e3;)n=n.return,o++;window.__keyInspectorFiberRoot=n,window.__keyInspectorFiberSelf=t}catch{}}function Zt(){return r.createElement(i.View,{ref:Kt,style:{width:1,height:1}})}function $t(e){return e?.name==="GuildsBar"||e?.displayName==="GuildsBar"||e?.type?.name==="GuildsBar"||e?.type?.displayName==="GuildsBar"}function Nt(e){return qt($t,function(t){He(t,Zt),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 en(e){const t=E("ExpandedGuildFolderStore");if(!t?.getExpandedFolders)return!1;const n=function({folderId:o}){if(!h.storage.autoCollapseFolders||o==null)return;const s=t.getExpandedFolders();if(!(!(s instanceof Set)||!s.has(o)))for(const u of s)u!==o&&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:tn,View:nn}=c.ReactNative;function rn({children:e}){return c.React.createElement(tn,{style:{flex:1}},e,c.React.createElement(nn,{style:{height:24}}))}const{View:on,Text:sn}=c.ReactNative;function ve({children:e,style:t}){return c.React.createElement(on,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},t]},c.React.createElement(sn,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},e))}const{FormSection:Qe,FormSwitchRow:$}=Ue.Forms;function un(){return ne.useProxy(h.storage),c.React.createElement(rn,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 m=[],k;function ln(e,t){try{return t()}catch(n){return te.logger.error(`[ServerDrawer] "${e}" patch threw, skipping: ${n}`),!1}}function _e(){const e={questDockRender:function(){return We(m)},questDockBase:function(){return qe(m)},questDockVisible:function(){return Je(m)},mobileQuestDock:function(){return Xe(m)},getQuestAsset:function(){return Ke(m)},expanded:function(){return Yt(m)},collapsed:function(){return Q("QuestDockContentCollapsed",m)},enrolledHeader:function(){return Q("QuestDockEnrolledHeader",m)},unenrolledHeader:function(){return Q("QuestDockUnenrolledHeader",m)},enrolledBody:function(){return Q("QuestDockEnrolledBody",m)},unenrolledBody:function(){return Q("QuestDockUnenrolledBody",m)},autoCollapseFolders:function(){return en(m)},...h.storage.hideGuildsBar?{hideGuildsBar:function(){return Nt(m)}}:{}};Xt(m);const t=new Set(Object.keys(e)),n=new Set,o=function(){for(const s of t)ln(s,e[s])&&(n.add(s),t.delete(s));t.size===0&&k&&(clearInterval(k),k=void 0)};if(o(),t.size>0){let s=0;k=setInterval(function(){o(),++s>=50&&k&&(clearInterval(k),k=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 Le(){k&&(clearInterval(k),k=void 0);for(const e of m)try{e()}catch{}m=[]}function Oe(){Le(),_e()}var an={onLoad:function(){h.storage.hideGuildsBar??=!0,h.storage.showUnreadBadges??=!0,h.storage.autoCollapseFolders??=!1,h.storage.hideFolderIcons??=!1,_e()},onUnload:function(){return Le()},settings:un};return L.default=an,L.restart=Oe,Object.defineProperty(L,"__esModule",{value:!0}),L})({},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);