Loading
function(e,t,n){"use strict";n.d(t,{RI:()=>p,Ay:()=>m});var i=n(636537),r=n(439372),s=n(546183),a=n(927813),o=n(17928),l=n(228366);let u=new Map;class c extends o.Ay.Store{initialize(){this.waitFor(s.default)}static displayName="AccountLinkStore";getPendingAuthorizations(){return u}deletePendingAuthorization(e){u.delete(e)}}let d=new c(l.h,{ACCOUNT_LINK_AUTHORIZATION_STARTED:function(e){null==s.default.getNewestTokenForApplication(e.applicationId)&&u.set(e.applicationId,{applicationId:e.applicationId,startedAt:Date.now(),accountLinkCallbacks:e.accountLinkCallbacks,claimIncentivizedAccountLinkingRewardCallbacks:e.claimIncentivizedAccountLinkingRewardCallbacks})}});var _=n(942370),h=n(652215);let f=20*a.A.Millis.MINUTE;async function p(e){let{applicationId:t,onSuccess:n,onError:r}=e;try{await i.Bo.post({url:h.Rsh.OAUTH2_ACCOUNT_LINKING_ACHIEVEMENT,body:{application_id:t},rejectWithError:!0}),n?.()}catch(e){r?.(e)}}class E extends r.A{static displayName="AccountLinkManager";actions={OAUTH2_TOKEN_CREATE:e=>this.handleOAuth2TokenCreate(e),USER_AUTHORIZED_APPS_UPDATE:()=>this.handleAuthorizedAppsUpdate(),APP_STATE_UPDATE:e=>this.handleAppStateUpdate(e),ACCOUNT_LINK_AUTHORIZATION_COMPLETED:e=>this.handleAccountLinkAuthorizationCompleted(e)};evaluatePending(){let e=d.getPendingAuthorizations();if(0===e.size)return;let t=Date.now();for(let[n,i]of e){if(t-i.startedAt>f){d.deletePendingAuthorization(n);continue}null!=s.default.getNewestTokenForApplication(n)&&_.YJ.has(n)&&null!=i.claimIncentivizedAccountLinkingRewardCallbacks&&(p({applicationId:n,onSuccess:i.claimIncentivizedAccountLinkingRewardCallbacks.onSuccess,onError:i.claimIncentivizedAccountLinkingRewardCallbacks.onError}),d.deletePendingAuthorization(n))}}handleOAuth2TokenCreate(e){d.getPendingAuthorizations().has(e.application.id)&&this.evaluatePending()}handleAuthorizedAppsUpdate(){this.evaluatePending()}handleAccountLinkAuthorizationCompleted(e){d.getPendingAuthorizations().has(e.applicationId)&&this.evaluatePending()}handleAppStateUpdate(e){e.state===h.g6G.ACTIVE&&this.evaluatePending()}}let m=new E}