Loading
function(e,t,n){"use strict";n.d(t,{l:()=>B});var l=n(64700),i=n(17928),s=n(308368),r=n(780907),a=n(730852),o=n(212245),u=n(933958),c=n(62583),d=n(969151),m=n(95701),h=n(734057),p=n(977997),f=n(776677),g=n(550151),E=n(55730),A=n(765379),C=n(946255),x=n(688810),I=n(429913),_=n(20015),S=n(207371),y=n(651743),v=n(134861),T=n(498642),N=n(71393),j=n(189081),b=n(480595),R=n(576705),P=n(994500),L=n(309010),M=n(461213),O=n(287809),w=n(689168),k=n(340829),D=n(723702),U=n(144914),G=n(652215),F=n(360469),V=n(375708);function B(e){let t,{activity:n,embeddedActivity:B,user:H,onGameJoin:W,onClose:K,location:Y,supportsAskToJoin:z=!0}=e,{analyticsLocations:Z}=(0,x.Ay)(Y??[]),[q,$]=l.useState(!1),J=B?.applicationId??n?.application_id,X=null!=B||(0,A.A)(n),Q=(0,i.bG)([O.default],()=>O.default.getCurrentUser()),ee=H.id===Q?.id,et=function(e){let{channelId:t,userId:n,activity:l}=e,i=h.A.getChannel(t);return(l?.session_id==null||null!=i&&(0,m.pQ)(i.type)?t:p.A.getVoiceStateForSession(n,l?.session_id)?.channelId)??void 0}({channelId:(0,d.H)(B?.location),userId:H.id,activity:n}),en=(0,i.bG)([j.A,y.A,k.A,v.A],()=>X||(0,E.A)(n,G.jUm.SUPPORTS_JOIN_URL)||null!=J&&(0,U.A)({LibraryApplicationStore:j.A,LaunchableGameStore:y.A,DispatchApplicationStore:k.A,ConnectedAppsStore:v.A,applicationId:J})),el=(0,i.bG)([u.Ay],()=>Array.from(u.Ay.getSelfEmbeddedActivities().values()).some(e=>{let{applicationId:t,location:l}=e;return(t===n?.application_id||t===B?.applicationId)&&(0,d.H)(l)===et})),ei=(0,i.bG)([w.A],()=>null!=n&&null!=n.application_id&&w.A.getState(n.application_id,G.xL.JOIN)===G.eAD.LOADING),es=(0,I.h)(J),er=(0,S.x)(es),ea=(0,g.vG)({userId:H.id,activity:n,channelId:et,application:es}),eo=(0,i.bG)([h.A,N.A,T.A,P.A,L.A,p.A,R.A,b.A,M.A,u.Ay],()=>null!=B?ea===g.Gy.CAN_JOIN?f.o.CAN_JOIN:f.o.CANNOT_JOIN:(0,f.A)({user:H,activity:n,application:es,channelId:et,currentUser:Q,isEmbedded:X,ChannelStore:h.A,GuildStore:N.A,GuildMemberCountStore:T.A,RelationshipStore:P.A,SelectedChannelStore:L.A,VoiceStateStore:p.A,PermissionStore:R.A,LocalActivityStore:b.A,SelfPresenceStore:M.A,EmbeddedActivitiesStore:u.Ay})),eu=(0,i.bG)([u.Ay],()=>!!Array.from(u.Ay.getSelfEmbeddedActivities().values()).some(e=>e.applicationId===B?.applicationId&&e.location.id===B?.location.id)),ec=(0,o.p)();if(X&&null==B&&(null==n||!(0,E.A)(n,G.jUm.CONTEXTLESS)))return null;let ed=!D.isPlatformEmbedded;if(!((0,E.A)(n,G.jUm.JOIN)||X)||null==J)return null;let em=!X&&eo===f.o.JOINED||X&&eu,eh=!ee||X,ep=eh&&!em&&(ed||en)&&!q&&!el;em?t=V.intl.string(V.t.TYSymS):eh?ed||en||null==n||(t=V.intl.formatToPlainString(V.t.SqJBnN,{name:n.name})):t=V.intl.string(V.t["0OiwfH"]);let ef=B?.launchId??n?.session_id,eg=async(e,t)=>{if(null==ef||null==J)return;let n=(0,E.A)(t,G.jUm.EMBEDDED),l=L.A.getVoiceChannelId(),i=h.A.getChannel(l);await r.Ay.join({userId:e.id,sessionId:ef,applicationId:J,channelId:l,messageId:null,intent:F.W9.PLAY,embedded:n,locationObject:ec.location,analyticsLocations:Z}),n||(0,C.A)({type:G.UqL.JOIN,userId:e.id,guildId:i?.guild_id,channelId:l,channelType:i?.type,applicationId:J,partyId:null!=t?t?.party?.id:"",locationObject:ec.location,analyticsLocations:Z})},eE=async()=>{let e=!1;async function t(){let e;$(!0),null!=n&&(e=await s.A.sendActivityInviteUser({type:G.xL.JOIN_REQUEST,userId:H.id,activity:n,location:G.ThZ.USER_ACTIVITY_ACTIONS})),null!=e&&a.default.selectPrivateChannel(e.id)}if(X&&!er){if(null==J)return;if(eo!==f.o.CAN_JOIN)return t();if(e=await (0,c.A)({applicationId:J,activityChannelId:et,locationObject:ec.location,analyticsLocations:Z}))return void K?.()}if(!e){if(eo===f.o.CAN_JOIN){W?.(),eg(H,n),K?.();return}await t()}};if(eo===f.o.CANNOT_JOIN&&!z||eo===f.o.CANNOT_JOIN&&(0,_.n)(es,G.gfo.EMBEDDED)||!ep&&!q&&null==t)return null;let eA=eo===f.o.CAN_JOIN?V.intl.string(V.t.VJlc0S):V.intl.string(V.t.OKsSCR);return em&&(eA=V.intl.string(V.t.DPfdsq)),{buttonCTA:eA,tooltip:t,handleJoinRequest:eE,isEnabled:ep,isJoining:ei,isEmbedded:X}}}