Module 565645

2,407 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>S});var i=n(627968),r=n(64700),s=n(503698),a=n.n(s),o=n(17928),l=n(724442),u=n(692051),c=n(868132),d=n(776231),_=n(830178),h=n(885386),f=n(184809),E=n(486020),p=n(690521),m=n(218394),g=n(732139);let A=__OVERLAY__?()=>(0,o.bG)([f.default],()=>f.default.isInstanceFocused()):m.j;function I(e){let{src:t,alt:n,className:s,emojiId:o,emojiName:u,channelId:_,messageId:f,animated:m,size:I="default",isInteracting:T=!1,shouldAnimate:S,onMouseEnter:N,onMouseLeave:C,canSelect:y=!0,autoplay:O,registerInnerRef:R,registerAnimatedElementRef:v,surrogate:b,...L}=e,[D,w]=r.useState(!1),[P,M]=r.useState(void 0),x=r.useRef(void 0),{triggerAnimation:U,untriggerAnimation:k}=r.useContext(c.wE),G=h.Sf.useSetting(),V=A(),F=null==O?G:O,B=g.Ec[I],H=r.useRef(null),j=r.useMemo(()=>{if(null!=t)return t;if(null!=o){let e=!0===S&&F;return E.Ay.getEmojiURL({id:o,animated:V&&!0===m&&(e||D||!0===T),size:B})}if(null!=u)return p.Ay.getURL(u);throw Error("Unknown Src for Emoji")},[m,F,o,u,B,V,D,T,S,t]),W=r.useCallback(()=>{null!=j&&(x.current=(0,d.yt)(j,e=>{e||M(Date.now())}))},[j]),Y=r.useCallback(e=>{m&&w(!0),null==o&&U(u),N?.(e)},[m,u,N,U,o]),K=r.useCallback(e=>{m&&w(!1),null==o&&k(u),C?.(e)},[m,o,u,C,k]),$=r.useMemo(()=>{let e=null!=o&&""!==o?{"data-id":o}:{"data-name":u};return{...L,className:a()("emoji",s,{jumboable:"jumbo"===I}),onError:W,onMouseEnter:Y,onMouseLeave:K,"data-type":"emoji",...e}},[s,o,u,Y,K,W,L,I]);r.useEffect(()=>()=>x.current?.(),[]);let z=r.useCallback(e=>{H.current=e,R?.(e),v?.(e)},[R,v]),q=(0,l.A)(H);return null==j||""===j?(0,i.jsx)("span",{...$,ref:z,className:a()("emoji","emoji-text"),children:b??u}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.q6,{channelId:_,messageId:f,emojiName:u,disable:!1===F||!1===G,emojiRef:q}),y?(0,i.jsx)("img",{...$,ref:z,src:j,alt:n??u??void 0,draggable:!1},P):(0,i.jsx)("div",{...$,ref:z,role:"img","aria-label":n??u??void 0,style:{backgroundImage:`url(${j})`,backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"center center"}},P)]})}function T(e){let{useThoughtfullyAnimated:t}=r.useContext(_.W),{animate:n,registerRef:s}=t(),{disableAnimations:a}=r.useContext(u.Y);return(0,i.jsx)(I,{...e,registerAnimatedElementRef:s,shouldAnimate:n&&!a})}function S(e){return null==e.emojiId&&null==e.emojiName&&null==e.src?null:e.animated&&void 0===e.shouldAnimate?(0,i.jsx)(T,{...e}):(0,i.jsx)(I,{...e})}}