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