Module 305070

5,715 characters · in bca0a10bf65022b8.js
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>F});var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(837381),o=n(17928),c=n(689175),u=n(623646),d=n(811024),h=n(933958),m=n(969151),p=n(659280),f=n(579940),g=n(915089),x=n(352505),A=n(750506),E=n(513609),C=n(71393),I=n(597184),y=n(105330),S=n(27867),v=n(459016),N=n(861382),_=n(355622),T=n(820066),j=n(696451),b=n(576705),R=n(351906),O=n(287809),M=n(31498),w=n(887129),L=n(741918),k=n(267102),P=n(652215),D=n(307731);let U=new Map([["thread",new Set(["name"])]]);var V=n(5867),G=n(122484);let F=i.forwardRef(function(e,t){let{channel:n,type:s,editorHeight:F,onVisibilityChange:H,editorScrollerRef:B,barsHeight:W}=e,K=(0,g.GV)(),z=(0,o.bG)([C.A],()=>C.A.getGuild(n.guild_id)??null,[n.guild_id]),Z=i.useRef(null),[Y,q,J]=function(e,t,n){let{channel:l,type:s}=e,[r,a]=i.useState(()=>(0,M.Ur)()),c=(0,S.A)(),u=(0,o.bG)([j.Ay,O.default],()=>{let e=O.default.getCurrentUser();return(null!=l.guild_id&&null!=e?j.Ay.getMember(l.guild_id,e.id)?.isPending:null)??!1}),{canMentionEveryone:d,hidePersonalInformation:h}=(0,o.cf)([b.A,R.A],()=>({canMentionEveryone:l.isPrivate()||u||s===_.oU.RULES_INPUT||b.A.can(P.xBc.MENTION_EVERYONE,l),hidePersonalInformation:R.A.hidePersonalInformation}),[l,s,u]),{activeCommand:m,activeCommandOption:p}=(0,o.cf)([N.A],()=>({activeCommand:N.A.getActiveCommand(l.id),activeCommandOption:N.A.getActiveOption(l.id)})),f=i.useMemo(()=>m?.untranslatedName!=null&&p?.name!=null&&(U.get(m.untranslatedName)?.has(p.name)??!1),[m?.untranslatedName,p?.name]),g=function(e){let{navId:t,scrollerRef:n,state:l,onFocus:s}=e,{renderWindow:r}=i.useContext(k.Ay),a=(e,t,i)=>{if(n.current?.scrollToTop(),e&&null!=l.query){let e=l.query.typeInfo.focusMode,n=e!==I.e.MANUAL&&(e!==I.e.AUTO_WHEN_FILTERED||0!==l.query.queryText.length);l.isVisible&&(!0!==t||!1!==n)&&!0!==i?(c.setFocus("0"),s?.(0)):(c.setFocus(null),s?.(null))}},o=e=>{if(n.current?.scrollToBottom(),e&&null!=l.query&&l.query.resultCount>0){let e=l.query.resultCount-1;c.setFocus(e.toString()),s?.(e)}},c=(0,w.Ay)({id:t,isEnabled:l.isVisible,orientation:L.Gl.VERTICAL,useVirtualFocus:!0,setFocus:(e,t)=>{let l=r.document.querySelector(e);null!=l&&n.current?.scrollIntoViewNode({node:l}),s?.(+t)},onNavigateNextAtEnd:()=>a(!0),onNavigatePreviousAtStart:()=>o(!0),scrollToStart:()=>(a(!1,!1),Promise.resolve()),scrollToEnd:()=>(o(!1),Promise.resolve())}),u=i.useRef(a);return i.useEffect(()=>{u.current=a}),i.useEffect(()=>{u.current(!0,!0,l.isInitialAfterError)},[l.query?.type,l.query?.queryText,l.query?.isLoading,l.isVisible,l.isInitialAfterError]),c}({navId:"channel-autocomplete",scrollerRef:n,state:r,onFocus:e=>y.setSelectedIndex(e)}),x=e.editorRef.current?.getCurrentWord(),A=e.editorRef.current?.getSlateEditor(),E=null;null!=A&&(E=T.VW.getSelectedParentOfType(A,M.mk)?.[0]??null);let C={...e,navigator:g,activeCommand:m,activeCommandOption:p,activeInlineAutocompleteInput:E,canMentionUsers:s.users?.allowMentioning??!1,canMentionEveryone:d,hidePersonalInformation:h,hideMentionDescription:s===_.oU.RULES_INPUT,emojiIntention:s===_.oU.RULES_INPUT?D.EmojiIntention.COMMUNITY_CONTENT:f?D.EmojiIntention.NO_CUSTOM_EMOJI:D.EmojiIntention.CHAT,currentWord:x?.word??"",currentWordIsAtStart:x?.isAtStart===!0,optionText:null!=p?(0,v.getString)({[p.name]:e.editorRef.current?.getCurrentCommandOptionValue()??[]},p.name):""},[y]=i.useState(()=>new M.Ay(C));return i.useEffect(()=>{y.updateProps(C)}),i.useImperativeHandle(t,()=>y,[y]),i.useEffect(()=>{let e=e=>a(e);return y.on("change",e),y.on("update",c),()=>{y.off("change",e),y.off("update",c)}},[c,y]),i.useEffect(()=>{let e=r.query?.typeInfo.stores;if(null!=e){let t=()=>y.queryResults();for(let n of e)n.addChangeListener(t);return()=>{for(let n of e)n.removeChangeListener(t)}}},[y,r.query?.typeInfo]),[r,y,g]}({...e,guild:z},t,Z),$=s.autocomplete?.forceChatLayer?E.Ay:A.Ay,X=(0,p.aI)(Y.selectedIndex);(0,f.gf)(K,Y.isVisible,X);let Q=(0,y.l)({editorHeight:F,type:s,state:Y}),ee=(0,o.bG)([h.Ay],()=>{let e=h.Ay.getSelfEmbeddedActivityForChannel(n.id),t=h.Ay.getActivityPanelMode();return(0,d.AX)(n)&&null!=e&&(0,m.H)(e.location)===n.id&&t===V.Gd.PANEL},[n]),et=i.useMemo(()=>Q?.top==null&&Q?.left==null&&Q?.bottom==null&&Q?.right==null?"":String(Date.now()),[Q?.top,Q?.left,Q?.bottom,Q?.right]);if(i.useEffect(()=>{H(Y.isVisible)},[H,Y.isVisible]),!Y.isVisible||null==Y.query||void 0===Q)return null;let en=Y.query.typeInfo.renderResults({results:Y.query.results,selectedIndex:Y.selectedIndex,channel:n,guild:z,query:Y.query.queryText,options:Y.query.options,onHover:e=>q.onResultHover(e),onClick:e=>q.onResultClick(e)})??null;if(null==en)return null;let el={[G.pK]:null==Q,[G.YB]:null!=Q,[G.sQ]:null==Q&&"bottom"===e.position,[G.mO]:ee},ei=x.r.getConfig({location:"channel autocomplete"}),es=Y.query?.type===I.DB.MENTIONS,er=ei.combineMentionAutocomplete&&es?670:490;null!=Q&&(er=s.autocomplete?.small?200:Y.query?.type===I.DB.EMOJIS_AND_STICKERS?490:245);let ea=Math.max(F,B?.current?.clientHeight??0),eo=Math.min(.5*window.innerHeight,ea);er=Math.min(window.innerHeight-120-eo-(W??0),er);let ec=(0,l.jsx)(p.Ay,{id:K,className:r()(G.nx,el),innerClassName:G.Fv,onMouseDown:e=>e.preventDefault(),children:(0,l.jsx)(a.hD,{navigator:J,children:(0,l.jsx)(a.PR,{children:e=>{let{ref:t,...n}=e;return(0,l.jsx)(c.Ch,{id:K,ref:e=>{t.current=e?.getScrollerNode()??null,Z.current=e},orientation:"vertical",overflow:"auto",...n,className:G.XG,style:{maxHeight:er},role:"listbox","aria-labelledby":(0,p.Sz)(K),children:en})}})})});return null!=Q?(0,l.jsx)($,{children:(0,l.jsx)(u.Q,{targetRef:e.targetRef,overrideTargetRect:Q,positionKey:et,position:e.position??"top",align:"left",spacing:8,autoInvert:!0,nudgeAlignIntoViewport:!0,children:()=>ec})}):ec})}