Loading
function(e,t,n){"use strict";n.d(t,{A:()=>M});var i=n(627968),r=n(64700),s=n(503698),a=n.n(s),o=n(3203),l=n(192308),u=n(408278),c=n(308528),d=n(688810),_=n(355622),h=n(408018),f=n(138617),p=n(195880),E=n(45787),m=n(95701),g=n(562153),A=n(183555),I=n(448613),T=n(597770),S=n(751188),y=n(17928),C=n(451988),N=n(775602),v=n(21161),R=n(652215),O=n(375708);function b(e){let{user:t,analyticsLocations:n,confettiEnabled:s=!0,onClose:a}=e,{giftButtonRef:o,handleMouseEnter:l}=function(e){let{enabled:t}=e,n=(0,y.bG)([N.Ay],()=>N.Ay.useReducedMotion),i=r.useRef(null),s=r.useRef(0),{createMultipleConfettiAt:a}=r.useContext(v.x),o=r.useMemo(()=>({size:{type:"static-random",minValue:2,maxValue:6},velocity:{type:"static-random",minValue:{x:-10,y:-25},maxValue:{x:10,y:-5}},dragCoefficient:{type:"static",value:.001}}),[]),l=r.useCallback(()=>{if(n)return;let e=i.current?.getBoundingClientRect();null!=e&&a(e.left+e.width/2,e.top+e.height/2,o,30)},[a,n,o]);return r.useEffect(()=>{if(!t||n)return;let e=new C.J_(1e3,l);return e.delay(),()=>e.cancel()},[t,n,l]),{giftButtonRef:i,handleMouseEnter:r.useCallback(()=>{t&&(s.current+=1,s.current%4==0&&l())},[t,l])}}({enabled:s}),{openGiftModal:c}=(0,S.$)({giftRecipient:t,analyticsLocations:n,analyticsObject:{page:R.liQ.USER_PROFILE,section:R.JJy.USER_PROFILE,object:R.ZSU.BUTTON_ICON,objectType:R.AnalyticsObjectTypes.GIFT},location:"gift-button-with-confetti"}),d=r.useCallback(()=>{c(),a?.()},[c,a]);return(0,i.jsx)("div",{ref:o,onMouseEnter:l,children:(0,i.jsx)(u.K,{size:"sm",variant:"icon-only",icon:T.o,"aria-label":O.intl.string(O.t.PEjaCx),onClick:d})})}var D=n(788868),L=n(831111);let w=(0,m.createChannelRecord)({id:"1",type:R.rbe.DM});function M(e){let{user:t,guildId:s,channelId:m,onClose:T,disableAutoFocus:S=!1,upsell:y=!1}=e,{newestAnalyticsLocation:C,analyticsLocations:N}=(0,d.Ay)(),{trackUserProfileAction:v}=(0,A.NJ)(),[R,M]=r.useState(""),[P,x]=r.useState((0,h.x7)(R)),k=r.useRef(!1),U=r.useRef(null),G=r.useRef(null),{Component:F}=(0,o.V)(),V=r.useMemo(()=>({..._.oU.USER_PROFILE,disableAutoFocus:S}),[S]),B=r.useCallback(async()=>{(0,E.xs)(t.id),await c.A.openPrivateChannel({recipientIds:[t.id]}),(0,l.openModalLazy)(async()=>{let{default:e}=await Promise.all([n.e("30593"),n.e("22638"),n.e("8891"),n.e("95501")]).then(n.bind(n,367516));return t=>(0,i.jsx)(e,{...t,giftIntentType:D.np.FRIEND_ANNIVERSARY,analyticsLocationHistory:N})})},[t.id,N]),j=r.useCallback(()=>(0,i.jsxs)("div",{className:L.Uo,children:[(0,i.jsx)(u.K,{size:"sm",variant:"icon-only",icon:F,"aria-label":O.intl.string(O.t.I61IsE),onClick:B}),(0,i.jsx)(b,{user:t,analyticsLocations:N,onClose:T,confettiEnabled:y})]}),[F,B,t,N,T,y]);return(0,i.jsx)(f.Ay,{className:a()(L.kL,{[L.UX]:y}),editorClassName:L.EN,type:V,placeholder:O.intl.formatToPlainString(O.t["0ZQw/X"],{name:g.Ay.getName(s,m,t)}),channel:w,textValue:R,richValue:P,onChange:(e,t,n)=>{t!==R&&(M(t),x(n))},focused:k.current,onFocus:()=>{k.current=!0},onBlur:()=>{k.current=!1},onSubmit:async e=>{let{value:n}=e,i=n.trim();if(""===i)return{shouldClear:!1,shouldRefocus:!0};(U.current!==i||null==G.current)&&(U.current=i,G.current=(0,p.m)());try{return v({action:"SEND_DIRECT_MESSAGE"}),await (0,I.p)({userId:t.id,content:i,openChannel:!0,whenReady:!0,location:C,nonce:G.current??void 0}),U.current=null,G.current=null,T?.(),{shouldClear:!0,shouldRefocus:!1}}catch{return{shouldClear:!1,shouldRefocus:!1}}},renderButtons:y?j:void 0})}}