1 line
26 KiB
JavaScript
1 line
26 KiB
JavaScript
(function(Q,$,f,c,o,r,a,N,w,M,ee,Ye){"use strict";function I(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 y(...e){return I(function(t){return e.every(function(n){return t?.[n]!==void 0})})}function Ze(e){return I(function(t){return typeof t?.getName=="function"&&t.getName.length===0&&t.getName()===e})}function $e(e){const t=y("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 Ne(e){const t=y("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 et(e){const t=y("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 tt(e){const t=y("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 nt="[ServerDrawer]";function ot(e){const t=y("getQuestAsset");if(!t?.getQuestAsset)return console.log(nt,"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 k(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"),rt=a.findByProps("useStateFromStores"),st=a.findByProps("colors","unsafe_rawColors")?.colors;function be({id:e,size:t=48}){const n=rt?.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:st?.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"}}),it=a.findByStoreName("ThemeStore"),lt=a.find(function(e){return e?.default?.internal?.resolveSemanticColor})?.default?.internal?.resolveSemanticColor??a.find(function(e){return e?.meta?.resolveSemanticColor})?.meta?.resolveSemanticColor??function(){};function at(e,t=it?.theme){if(e)try{return lt(t,e)}catch{return}}const Se=a.findByProps("TextStyleSheet")?.TextStyleSheet,ke=a.findByProps("triggerHapticFeedback","HapticFeedbackTypes");function v(e,t){return at(e)??t}const F=12,te=12,Ee=42,ne=220,we=4,x=16,L=20,Ie={tension:200,friction:20};function ut({visible:e,items:t,title:n,anchorX:s,anchorY:i,onClose:l}){const{width:u,height:g}=r.Dimensions.get("window"),p=(n?te+20+we:0)+t.length*Ee;let C=s,m=i+48+10;C+ne>u-F&&(C=u-ne-F),C<F&&(C=F),m+p>g-F&&(m=i-p-10),m<F&&(m=F);const b=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=o.useRef(new r.Animated.Value(0)).current,H=o.useRef(new r.Animated.Value(.5)).current,G=o.useRef(new r.Animated.Value(0)).current,[fe,Z]=o.useState(!1),T=o.useRef(!1);o.useEffect(function(){e&&!T.current&&(Z(!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,...Ie}),r.Animated.spring(G,{toValue:1,useNativeDriver:!0,...Ie})]).start())},[e]);const he=o.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,Z(!1),l()}))},[l]);return fe?o.createElement(r.Modal,{transparent:!0,visible:fe,onRequestClose:he,statusBarTranslucent:!0},o.createElement(r.Pressable,{style:oe.root,onPress:he},o.createElement(r.Animated.View,{style:[oe.backdrop,{opacity:V}]}),o.createElement(r.Animated.View,{style:[oe.container,{left:C,top:m,backgroundColor:b,borderColor:d,minWidth:ne,opacity:G,transform:[{scale:H}]}]},n?o.createElement(r.View,null,o.createElement(r.Text,{style:[Se?.["text-md/bold"],{color:S,paddingHorizontal:te,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,gn=!!(R.iconSource||R.IconComponent);return o.createElement(r.Pressable,{key:ge,style:function({pressed:pn}){return{paddingHorizontal:te,paddingVertical:10,minHeight:Ee,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:8,backgroundColor:pn?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:S}]},R.label),gn?o.createElement(r.View,{style:{width:L,height:L,alignItems:"center",justifyContent:"center"}},R.IconComponent?o.createElement(R.IconComponent,{size:"sm",color:S}):R.iconSource?o.createElement(r.Image,{source:R.iconSource,style:{width:L,height:L,tintColor:S}}):null):null)})))):null}const oe=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=a.findByProps("useStateFromStores"),O=a.findByStoreName("GuildReadStateStore"),ct=a.findByStoreName("GuildStore"),re=a.findByStoreName("GuildChannelStore"),dt=a.findByStoreName("ChannelStore"),Re=a.findByProps("triggerHapticFeedback","HapticFeedbackTypes"),ft=k(function(){return y("bulkAck","ackChannel")}),ht=k(function(){return y("ReadStateTypes","UnreadSetting")?.ReadStateTypes});function gt(e){const t=ft(),n=ht();if(!t?.bulkAck||n?.CHANNEL==null||!re?.getSelectableChannelIds){w.showToast("Couldn't find Discord's read-state action - this may be unavailable on your version.",void 0);return}const s=[...re.getSelectableChannelIds(e)??[],...re.getVocalChannelIds?.(e)??[]].map(function(i){return{channelId:i,readStateType:n.CHANNEL,messageId:dt?.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 pt({guildId:e}){N.useProxy(f.storage);const t=De?.useStateFromStores?.([O],function(){return O?.getMentionCount?.(e)??0},[e])??0,n=De?.useStateFromStores?.([O],function(){return O?.hasUnread?.(e)??!1},[e])??!1;return f.storage.showUnreadBadges?t>0?o.createElement(r.View,{style:P.outline},o.createElement(r.View,{style:P.badge},o.createElement(r.Text,{style:P.text},t>99?"99+":String(t)))):n?o.createElement(r.View,{style:P.dotOutline},o.createElement(r.View,{style:P.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 b=e.id,d=ct?.getGuild?.(b);if(!d)return;const S=n.current;if(!S?.measure)return;const B=[{label:"Mark as Read",action:function(){return gt(b)}},{label:"Copy Server ID",action:function(){c.clipboard.setString(b),w.showToast("Copied server ID",void 0)}}];S.measure(function(V,H,G,fe,Z,T){g({visible:!0,items:B,title:d.name,x:Z,y:T})})},[e.id]),C=o.useCallback(function(){Re?.triggerHapticFeedback?.(Re.HapticFeedbackTypes.IMPACT_MEDIUM),p()},[p]),m=e.id;return o.createElement(o.Fragment,null,o.createElement(r.Pressable,{onPressIn:i,onPressOut:l,onPress:function(){return t(m)},onLongPress:C,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:m})),o.createElement(pt,{guildId:m}))),o.createElement(ut,{visible:u.visible,items:u.items,title:u.title,anchorX:u.x,anchorY:u.y,onClose:function(){return g(function(b){return{...b,visible:!1}})}}))}const Be=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"}}),yt=a.findByProps("useStateFromStores");a.findByProps("colors","unsafe_rawColors")?.colors;const Te=a.findByStoreName("ExpandedGuildFolderStore");function mt(e){return yt?.useStateFromStores?.([Te],function(){const t=Te?.getExpandedFolders?.();return t instanceof Set?t.has(e):!1},[e])??!1}const bt=a.findByProps("toggleGuildFolderExpand"),Ct=a.findByProps("useStateFromStores"),xe=a.findByStoreName("GuildReadStateStore"),D=48,se=16,St=[{top:6,left:6},{top:6,right:6},{bottom:6,left:6},{bottom:6,right:6}],Pe=ee.getAssetIDByName("FolderIcon");function Ae(e){return e==null?"#5865f2":`#${e.toString(16).padStart(6,"0")}`}function kt({node:e}){const t=Ct?.useStateFromStores?.([xe],function(){let n=0;for(const s of e.children)n+=xe?.getMentionCount?.(s.id)??0;return n},[e.children])??0;return t>0?o.createElement(r.View,{style:le.outline},o.createElement(r.View,{style:le.badge},o.createElement(r.Text,{style:le.text},t>99?"99+":String(t)))):null}function Et({node:e}){N.useProxy(f.storage);const t=Ae(e.color);return o.createElement(r.View,{style:_.outer},o.createElement(r.View,{style:[_.icon,{backgroundColor:t}]},f.storage.hideFolderIcons?o.createElement(r.View,{style:_.plainIcon},o.createElement(r.Image,{source:Pe,style:ie.folderImg,tintColor:"#fff"})):e.children.slice(0,4).map(function(n,s){return o.createElement(r.View,{key:n.id,style:[_.cell,St[s]]},o.createElement(be,{id:n.id,size:se}))})),o.createElement(kt,{node:e}))}const _=r.StyleSheet.create({outer:{width:D,height:D},icon:{width:D,height:D,borderRadius:16,overflow:"hidden"},cell:{position:"absolute",width:se,height:se,borderRadius:8,overflow:"hidden"},plainIcon:{width:D,height:D,alignItems:"center",justifyContent:"center"}});function wt({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 It({node:e,onPick:t}){const n=mt(e.id),s=function(){bt?.toggleGuildFolderExpand?.(e.id)};return n?o.createElement(o.Fragment,null,o.createElement(r.Pressable,{onPress:s},o.createElement(r.View,{style:[ie.openIcon,{backgroundColor:Ae(e.color)}]},o.createElement(r.Image,{source:Pe,style:ie.folderImg,tintColor:"#fff"}))),e.children.map(function(i){return o.createElement(wt,{key:i.id},o.createElement(Fe,{node:i,onPick:t}))})):o.createElement(r.Pressable,{onPress:s},o.createElement(Et,{node:e}))}const ie=r.StyleSheet.create({openIcon:{width:D,height:D,borderRadius:16,alignItems:"center",justifyContent:"center"},folderImg:{width:24,height:24}}),le=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=ee.getAssetIDByName("ChatIcon"),Ve=a.findByProps("triggerHapticFeedback","HapticFeedbackTypes"),He=a.findByProps("selectPrivateChannel"),Rt=a.findByName("SelectedChannelStore"),Ft=a.findByProps("useStateFromStores"),Ge=a.findByProps("getGuildId"),Bt=a.findByProps("colors","unsafe_rawColors")?.colors;function Tt(){if(Ve?.triggerHapticFeedback(Ve.HapticFeedbackTypes.SOFT),He?.selectPrivateChannel){const e=Rt?.getLastSelectedChannelId?.();He.selectPrivateChannel(e)}}function xt(){const e=Ft?.useStateFromStores?.([Ge],function(){return Ge?.getGuildId?.()==null})??!1;return o.createElement(r.Pressable,{onPress:Tt,style:Qe.outer},o.createElement(r.View,{style:[Qe.icon,{backgroundColor:e?Bt?.BG_ACCENT??"#5865f2":"rgba(128,128,128,0.24)"}]},o.createElement(r.Image,{source:Dt,style:{width:24,height:24,tintColor:"#fff"}})))}const Qe=r.StyleSheet.create({outer:{width:U,height:U},icon:{width:U,height:U,borderRadius:16,alignItems:"center",justifyContent:"center"}}),Me=48,Pt=ee.getAssetIDByName("CheckmarkLargeIcon"),At=a.findByStoreName("SortedGuildStore"),z=a.findByStoreName("GuildChannelStore"),Vt=a.findByStoreName("ChannelStore"),Ht=k(function(){return y("triggerHapticFeedback","HapticFeedbackTypes")}),Gt=k(function(){return y("bulkAck","ackChannel")}),Qt=k(function(){return y("ReadStateTypes","UnreadSetting")?.ReadStateTypes});function Mt(){const e=(At?.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 vt(){const e=Gt(),t=Qt();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 n=Mt();if(n.length===0){w.showToast("Nothing to mark as read.",void 0);return}const s=[];for(const i of n){const l=[...z.getSelectableChannelIds(i)??[],...z.getVocalChannelIds(i)??[]];for(const u of l)s.push({channelId:u,readStateType:t.CHANNEL,messageId:Vt?.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 Lt(){const e=o.useCallback(function(){const t=Ht();t?.triggerHapticFeedback?.(t.HapticFeedbackTypes.SOFT),vt()},[]);return o.createElement(r.Pressable,{onPress:e,style:jt.outer},o.createElement(r.Image,{source:Pt,style:{width:24,height:24,tintColor:"#80848e"}}))}const jt=r.StyleSheet.create({outer:{width:Me,height:Me,alignItems:"center",justifyContent:"center"}}),Ot=a.findByProps("useStateFromStores"),ve=a.findByStoreName("SortedGuildStore"),_t=k(function(){return y("getRootNavigationRef")}),Le=k(function(){return y("triggerHapticFeedback","HapticFeedbackTypes")}),Ut=k(function(){return y("transitionToGuild")}),zt=k(function(){return I(function(e){return typeof e?.handleCreateJoinGuildPress=="function"})}),Wt=k(function(){return I(function(e){return e?.CirclePlusIcon})?.CirclePlusIcon}),qt=k(function(){return y("colors","unsafe_rawColors")?.unsafe_rawColors}),Xt=a.find(function(e){return e?.QuestDockExternalCoordinationContext}),je=Xt?.QuestDockExternalCoordinationContext,Oe=a.find(function(e){return e?.QuestDockMode?.COLLAPSED!=null})?.QuestDockMode,W=48,q=6,Jt=12;function Kt(){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),zt()?.handleCreateJoinGuildPress?.()},[]),i=Wt(),l=qt();return o.createElement(r.Pressable,{onPress:s,onPressIn:t,onPressOut:n},o.createElement(r.Animated.View,{style:[X.createJoin,{backgroundColor:l?.GREEN_360,transform:[{scale:e}]}]},i?o.createElement(i,{size:"md",color:l?.WHITE}):o.createElement(r.Text,{style:[X.createJoinFallback,{color:l?.WHITE}]},"+")))}function _e({gestureContext:e}){const t=o.useCallback(function(d){const S=Le();S?.triggerHapticFeedback?.(S.HapticFeedbackTypes.SOFT);const B=Ut();B?.transitionToGuild?B.transitionToGuild(d):_t()?.getRootNavigationRef?.()?.navigate("guilds",{guildId:d})},[]),n=Ot?.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 S=d.nativeEvent.layout.height;i.get()!==S&&i.set(S)},[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"),C=Math.max(3,Math.floor((p-Jt*2+q)/(W+q))),m=C*W+(C-1)*q,b=Math.max(0,(p-m)/2);return o.createElement(r.View,{style:X.alignTop},o.createElement(r.View,{style:[X.grid,{paddingHorizontal:b,gap:q}],onLayout:l},o.createElement(xt,null),n.map(function(d){return d.type==="folder"?o.createElement(It,{key:d.id,node:d,onPick:t}):o.createElement(Fe,{key:d.id,node:d,onPick:t})}),o.createElement(Kt,null),o.createElement(Lt,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}});function Yt(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 ae=new Map,ue=[];let J=[],K=!1;function Zt(e,t,n){ae.set(e,{replacement:t,extraProps:n})}function $t(e,t){ue.push({predicate:e,replacement:t})}function Nt(e){if(J.length===0)return;const t=[];for(const n of J){let s=!1;try{s=n.predicate(e)}catch{}if(s)try{n.onDetected(e)}catch{}else t.push(n)}J=t}function Ue(e,t){if(Nt(e),t)for(const{predicate:s,replacement:i}of ue)try{if(s(t))return i?{type:i,props:t}:null}catch{}const n=ae.get(e);if(n)return{type:n.replacement,props:n.extraProps?{...t,...n.extraProps}:t}}function en(e){if(K)return;const t=c.React.createElement;if(!t){console.warn("[createElementIntercept] React.createElement is null, skipping patch");return}const n=function(l,u,...g){const p=Ue(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,K=!0;const s=[],i=Yt(function(){return I(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,C,...m){const b=Ue(p,C);return b===null?null:b?g.call(this,b.type,b.props,...m):g.call(this,p,C,...m)},s.push(function(){l[u]=g}))}});e.push(function(){i.cancel(),K&&(c.React.createElement=t,K=!1),s.forEach(function(l){return l()}),ae.clear(),ue.length=0,J=[]})}const ce="[ServerDrawer]";let de=null;function ze(){return de||(de=I(function(e){return e?.QuestDockGestureContext})?.QuestDockGestureContext??null),de}function tn(e){const t=I(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 Zt(n,_e,{gestureContext:ze()}),t.type=function(){return c.React.createElement(_e,{gestureContext:ze()})},e.push(function(){t.type=n}),console.log(ce,"PATCH: QuestDockContentExpanded replaced"),!0}function A(e,t){const n=I(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 nn="[ServerDrawer]";function on(e){return $t(function(t){return t?.nativeID==="guilds-bar-view"},null),e.push(function(){}),console.log(nn,"PATCH: guilds-bar-view createElement calls now render nothing"),!0}function rn(e){const t=Ze("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:sn,View:ln}=c.ReactNative;function an({children:e}){return c.React.createElement(sn,{style:{flex:1}},e,c.React.createElement(ln,{style:{height:24}}))}const{View:un,Text:cn}=c.ReactNative;function We({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(cn,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},e))}const{FormSection:qe,FormSwitchRow:Y}=Ye.Forms;function dn(){return N.useProxy(f.storage),c.React.createElement(an,null,c.React.createElement(We,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(Y,{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,Ke()}}),c.React.createElement(Y,{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(qe,{title:"Folders"},c.React.createElement(Y,{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(Y,{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(We,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=[],E;function fn(e,t){try{return t()}catch(n){return $.logger.error(`[ServerDrawer] "${e}" patch threw, skipping: ${n}`),!1}}function Xe(){const e={questDockRender:function(){return $e(h)},questDockBase:function(){return Ne(h)},questDockVisible:function(){return et(h)},mobileQuestDock:function(){return tt(h)},getQuestAsset:function(){return ot(h)},expanded:function(){return tn(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 rn(h)},...f.storage.hideGuildsBar?{hideGuildsBar:function(){return on(h)}}:{}};en(h);const t=new Set(Object.keys(e)),n=new Set,s=function(){for(const i of t)fn(i,e[i])&&(n.add(i),t.delete(i));t.size===0&&E&&(clearInterval(E),E=void 0)};if(s(),t.size>0){let i=0;E=setInterval(function(){s(),++i>=50&&E&&(clearInterval(E),E=void 0,t.size>0&&$.logger.error(`[ServerDrawer] Gave up waiting on: ${[...t].join(", ")}`))},200)}$.logger.log(`[ServerDrawer] onLoad: applied immediately - ${[...n].join(", ")||"none"}${t.size?`, still waiting on ${[...t].join(", ")}`:""}`)}function Je(){E&&(clearInterval(E),E=void 0);for(const e of h)try{e()}catch{}h=[]}function Ke(){Je(),Xe()}var hn={onLoad:function(){f.storage.hideGuildsBar??=!0,f.storage.showUnreadBadges??=!0,f.storage.autoCollapseFolders??=!1,f.storage.hideFolderIcons??=!1,Xe()},onUnload:function(){return Je()},settings:dn};return Q.default=hn,Q.restart=Ke,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);
|