import{aI as P,az as W,aj as F,bp as q,bc as z,bK as G,bI as $,ge as K,f$ as J,aC as Q,ao as e,aF as X,fq as Y,L as v,aq as p,aP as Z,bU as A,v as i,f as c,e as l,o as j,p as C,am as ee,E as L,r as N,bg as te,de as se,W as ne,a as ae}from"./app-k0jcl5PQ.js";import{E as ie}from"./ChH5FnWn.chunk.js";import{S as oe}from"./CSEWPTB7.chunk.js";import"./BcYgJJPz.chunk.js";const re="_selectPresentation_1vc9d_18",k={selectPresentation:re},o="settings.welcomePopup",T=v.encloseNamespace(o),ce=[{application:l.CONTENT_UPDATES,action:c.ContentUpdates.CONTENT_UPDATES},{application:l.MOVIES_AND_TV,action:c.MoviesAndTv.HOME}].reduce((r,u)=>(r[i.getAppLinkString(u)]=!0,r),{});function me(r){const[u,d]=P.useState(!1),[t,h]=P.useState(),f=W(F.currentUser()),m=q(),g=m.xs||m.sm,U=g&&m.md,D=z(),{availablePresentations:s,hasCompleted:x}=G(),{setActivePresentation:I}=$(),{setPreferredPresentation:y}=K(),a=(s==null?void 0:s.length)>=J.MULTI_PRESENTATION_THRESHOLD;function R(){j.logUserAction({id:t.id,name:t.name},{actionType:N.Click,entity:L.Presentation,location:C.WelcomePopup,workflowPhase:ne.Complete,descriptor:se.Button,eventVersion:te.V3});const n=ae.getCurrentRoute().appLink;ce[i.getAppLinkString(n)]?i.trigger(n,{replace:!0}):i.trigger({application:l.DASHBOARD,action:c.Dashboard.HOME,args:[null]}),d(!1),r.closePopup()}function _(){d(!1),D.error(v.getPhrase(o,"error"))}function b(){return d(!0),I(t),y(t).then(R).catch(_)}function H(){return a?!t:!1}function O(){j.logUserAction({url:i.getHref({application:l.DEFAULT,action:c.Default.CHALLENGE})},{actionType:N.Click,entity:L.AppLink,descriptor:ee.SignIn,location:C.WelcomePopup})}function w(){return g?"sm":(s==null?void 0:s.length)>2?"lg":"md"}P.useEffect(()=>{!x||a||h(Q.first(s))},[a,x]);const S=()=>e.jsx(A,{children:e.jsx(A.Submit,{variant:"dark",onClick:b,text:T("cta"),showSpinner:u,disabled:H(),className:"mx-auto"})}),E=()=>e.jsx("div",{className:"mt-3 text-center",children:e.jsx(ie,{link:i.getHref({application:l.DEFAULT,action:c.Default.CHALLENGE}),onClick:O})}),M=()=>{var n;return e.jsxs("div",{className:`${k.selectPresentation}`,children:[e.jsx("div",{className:"d-block mx-auto p-4",children:e.jsx("img",{src:Z.SignUp.UPGRADE,className:"img-fluid",alt:""})}),e.jsx("h2",{className:"h4 text-center",children:e.jsx(p,{namespace:o,phrase:"infoPrimary"})}),e.jsx("p",{className:"text-center",children:e.jsx(p,{namespace:o,phrase:"infoSecondary"})}),e.jsx("div",{className:"mt-3",children:e.jsx(S,{})}),!((n=f.data)!=null&&n.isAuthenticated)&&e.jsx(E,{})]})},B=()=>{var n;return e.jsxs("div",{className:`${k.selectPresentation}`,children:[e.jsx("h2",{className:"h4 text-center",children:e.jsx(p,{namespace:o,phrase:"infoPrimary"})}),e.jsx("p",{className:"text-center",children:e.jsx(p,{namespace:o,phrase:"infoSecondaryMulti"})}),e.jsx("div",{className:"position-relative",children:e.jsx(oe,{schoolLevels:s,onSelect:V=>h(V),selectedId:t==null?void 0:t.id,showCoverPills:U})}),e.jsx(S,{}),!((n=f.data)!=null&&n.isAuthenticated)&&e.jsx(E,{})]})};return x?e.jsx(X,{title:T("title"),size:w(),closeButton:!a,closePopup:r.closePopup,backdrop:a?"static":!0,dialogClassName:Y.WELCOME_POPUP_SELECTOR,centered:!0,children:a?e.jsx(B,{}):e.jsx(M,{})}):e.jsx(e.Fragment,{})}export{me as WelcomePopupView};
//# sourceMappingURL=DwSxwep6.chunk.js.map
