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