1import{d as re,ec as rt,ed as it,bW as X,a7 as $,a0 as Oe,U as te,az as at,ac as ot,j as c,a8 as F,ba as ve,a4 as Ue,e6 as st,ee as ct,m as lt,u as ut,ef as dt,eg as ft,bk as ht,S as J,n as gt,D as ee,A as z,cu as Q,P as mt,p as G,an as De,bE as yt,c9 as pt}from"./index-a2f714b1.js";import{r as A,a as bt,h as St}from"./vendor-react-deaa6ed9.js";import{l as de}from"./logo-3d4bf15b.js";import{u as _e,T as At}from"./vendor-i18n-e0d2b2f8.js";import{u as Et}from"./index-1f5407c0.js";import"./vendor-forms-3d4cb5b3.js";import{g as Ce,c as Me}from"./linkableSamlStorage-4ad7e964.js";import{M as C}from"./mixpanelEvents-37af1116.js";import{l as fe}from"./handleSSOClick-061313d2.js";import{L as wt}from"./LinkToHelpEmail-2d7a650d.js";import{s as K}from"./vendor-ui-489ff94d.js";import{b as ge,c as V}from"./vendor-sentry-a979067a.js";import{s as Lt,g as It}from"./index-5b926851.js";import{c as Nt}from"./emailOtpLoginSession-d9897067.js";import{c as Rt}from"./phoneOtpLoginSession-3d7eb9d0.js";import{M as ne}from"./mixpanelEvents-537edfdb.js";import"./vendor-analytics-85aa0bb5.js";import"./vendor-apollo-7579deb5.js";import"./vendor-auth-85cd8932.js";import"./vendor-utils-e285ae05.js";import"./index-242778c0.js";import"./index-2565d2d0.js";import"./SignInLink-2d75f9fb.js";import"./injectI18nErrorMessages-f4f846bb.js";import"./joi-date-bb4e5d44.js";import"./is-military-zip-code.es-162d6926.js";const xt=n=>{var k;const e=re.c(19),[a,r]=A.useState(null);let h;e:{let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ce(),e[0]=o):o=e[0];const b=o;if(b!=null&&b.samlId){let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N={linkableSamlId:b.samlId,samlSource:b.source??null},e[1]=N):N=e[1],h=N;break e}const x=(k=n==null?void 0:n.app_metadata)==null?void 0:k.linkable_saml_id;if(x){let N;e[2]!==x?(N={linkableSamlId:x,samlSource:null},e[2]=x,e[3]=N):N=e[3],h=N;break e}let T;e[4]===Symbol.for("react.memo_cache_sentinel")?(T={linkableSamlId:null,samlSource:null},e[4]=T):T=e[4],h=T}const{linkableSamlId:s,samlSource:d}=h,E=!!s;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f={fetchPolicy:"network-only"},e[5]=f):f=e[5];const[m,R]=rt(f),{loading:w}=R,[l]=it();let y;e[6]!==m?(y=async()=>{var T;const{data:o,error:b}=await m();if(b||!(o!=null&&o.user))return null;const x={firstName:o.user.firstName,lastName:o.user.lastName,dateOfBirth:o.user.dateOfBirth,clientIdentifier:(T=o.user.client)==null?void 0:T.identifier};return r(x),x},e[6]=m,e[7]=y):y=e[7];const u=y;let L;e[8]!==l||e[9]!==s?(L=async()=>{var x,T;if(!s)throw new Error("No linkable SAML ID available");const{data:o,errors:b}=await l({variables:{input:{samlId:s}}});if(b!=null&&b.length||!((x=o==null?void 0:o.linkSamlAccount)!=null&&x.success))throw new Error(((T=o==null?void 0:o.linkSamlAccount)==null?void 0:T.message)||"Failed to link SAML account");Me()},e[8]=l,e[9]=s,e[10]=L):L=e[10];const p=L,O=kt;let I;return e[11]!==u||e[12]!==E||e[13]!==w||e[14]!==p||e[15]!==s||e[16]!==d||e[17]!==a?(I={linkableSamlId:s,samlSource:d,hasLinkableSamlId:E,userData:a,isLoadingUserData:w,fetchUserData:u,linkAccount:p,clearLinkableSamlId:O},e[11]=u,e[12]=E,e[13]=w,e[14]=p,e[15]=s,e[16]=d,e[17]=a,e[18]=I):I=e[18],I};function kt(){Me()}const Tt=1e4,Ot=K.div` 2 position: fixed; 3 top: 0; 4 left: 0; 5 width: 100vw; 6 height: 100vh; 7 background-color: white; 8 z-index: ${Tt}; 9 overflow: auto; 10 display: flex; 11 flex-direction: column; 12 align-items: center; 13 justify-content: flex-start; 14 15 @media (min-width: ${X.breakpoints.xl}) { 16 justify-content: center; 17 } 18`,vt=K.div` 19 width: 100%; 20 padding: ${$.s24}px; 21 display: flex; 22 flex-direction: column; 23 gap: ${$.s24}px; 24 text-align: left; 25 min-height: 100vh; 26 27 @media (min-width: ${X.breakpoints.md}) { 28 width: 500px; 29 padding: ${$.s32}px; 30 } 31 32 @media (min-width: ${X.breakpoints.xl}) { 33 min-height: auto; 34 } 35`,Ut=K.div` 36 display: flex; 37 align-items: center; 38 justify-content: center; 39 40 img { 41 height: ${Oe(80)}; 42 width: auto; 43 max-width: 100%; 44 45 @media (min-width: ${X.breakpoints.sm}) { 46 height: ${Oe(96)}; 47 } 48 } 49`,Dt=K.div` 50 background-color: ${te.background_neutral_secondary}; 51 border-radius: ${at.md}px; 52 padding: ${$.s24}px; 53 display: flex; 54 flex-direction: column; 55 gap: ${$.s16}px; 56 text-align: left; 57`,he=K.div` 58 display: flex; 59 align-items: center; 60 gap: ${$.s8}px; 61 62 > * { 63 &:first-child { 64 color: ${te.text_neutral_secondary_default}; 65 } 66 &:last-child { 67 font-weight: bold; 68 } 69 } 70`,Pt=K.div` 71 display: flex; 72 flex-direction: column; 73 gap: ${$.s16}px; 74 width: 100%; 75 margin-top: auto; 76 padding-top: ${$.s24}px; 77 padding-bottom: ${$.s16}px; 78 79 /* Target both direct button children and wrapper divs */ 80 > * { 81 width: 100%; 82 } 83 84 && button { 85 width: 100%; 86 max-width: none; 87 } 88 89 @media (min-width: ${X.breakpoints.lg}) { 90 flex-direction: row-reverse; 91 padding-top: 0; 92 93 > * { 94 flex: 1; 95 } 96 97 && button { 98 width: 100%; 99 max-width: none; 100 } 101 } 102 103 /* On large desktop (centered content), remove auto margin */ 104 @media (min-width: ${X.breakpoints.xl}) { 105 margin-top: ${$.s16}px; 106 } 107`,_t=K.div` 108 position: absolute; 109 width: 1px; 110 height: 1px; 111 padding: 0; 112 margin: -1px; 113 overflow: hidden; 114 clip: rect(0, 0, 0, 0); 115 white-space: nowrap; 116 border-width: 0; 117`,Ct=K.span` 118 a { 119 color: ${te.text_neutral_primary_default}; 120 121 &:hover { 122 color: ${te.text_neutral_primary_default}; 123 } 124 } 125`,Mt=(n,e)=>({heading:e?n("initial.heading",{partnerName:e}):n("initial.headingGeneric"),subheading:n("initial.subheading"),disclaimer:n("initial.disclaimer"),announcement:"",showUserInfo:!0,buttons:{primary:{action:"link",label:n("initial.linkButton")},secondary:{action:"cancel",label:n("initial.cancelButton")}}}),Bt=(n,e)=>({heading:e?n("linking.heading",{partnerName:e}):n("linking.headingGeneric"),subheading:n("linking.subheading"),disclaimer:n("initial.disclaimer"),announcement:n("linking.announcement"),showUserInfo:!0,buttons:{primary:{action:"pending",label:n("linking.linkingButton"),disabled:!0,showSpinner:!0}}}),$t=(n,e)=>({heading:n("success.heading"),subheading:e?n("success.subheading",{partnerName:e}):n("success.subheadingGeneric"),announcement:n("success.announcement"),showUserInfo:!1,buttons:{primary:{action:"close",label:n("success.closeButton")}}}),jt=(n,e)=>({heading:n("cancelled.heading"),subheading:e?n("cancelled.subheading",{partnerName:e}):n("cancelled.subheadingGeneric"),announcement:n("cancelled.announcement"),showUserInfo:!1,buttons:{primary:{action:"close",label:n("cancelled.closeButton")}}}),Ft=(n,e,a)=>{const r=e??!1;return{heading:n("error.heading"),subheading:a?n("error.subheading",{partnerName:a}):n("error.subheadingGeneric"),announcement:n(r?"error.announcementRetry":"error.announcementMaxAttempts"),showUserInfo:!1,buttons:{primary:r?{action:"try-again",label:n("error.tryAgainButton")}:{action:"close",label:n("error.cancelButton")},secondary:r?{action:"cancel",label:n("error.cancelButton")}:void 0}}},Ht=({stateType:n,canRetry:e=!1,t:a,partnerName:r})=>{switch(n){case"idle":return Mt(a,r);
125case"pending":return Bt(a,r);case"success":return $t(a,r);case"cancelled":return jt(a,r);case"failed":return Ft(a,e,r)}},Gt=(n,e)=>{if(!n)return"";const a=n.split("T")[0];if(!(a!=null&&a.match(/^\d{4}-\d{2}-\d{2}$/)))return n;const[r,h,s]=a.split("-").map(Number);return new Intl.DateTimeFormat(e,ot).format(new Date(r,h-1,s))},Kt=n=>{const e=re.c(35),{firstName:a,lastName:r,dateOfBirth:h}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={keyPrefix:"components.organisms.linkSamlAccountScreen"},e[0]=s):s=e[0];const{t:d,i18n:E}=_e("translation",s);let f;e[1]!==d?(f=d("infoBox.firstName"),e[1]=d,e[2]=f):f=e[2];let m;e[3]!==f?(m=c.jsx(F,{type:"body1",children:f}),e[3]=f,e[4]=m):m=e[4];let R;e[5]!==a?(R=c.jsx(F,{type:"body1",testID:"first-name-value",children:a}),e[5]=a,e[6]=R):R=e[6];let w;e[7]!==m||e[8]!==R?(w=c.jsxs(he,{children:[m,R]}),e[7]=m,e[8]=R,e[9]=w):w=e[9];let l;e[10]!==d?(l=d("infoBox.lastName"),e[10]=d,e[11]=l):l=e[11];let y;e[12]!==l?(y=c.jsx(F,{type:"body1",children:l}),e[12]=l,e[13]=y):y=e[13];let u;e[14]!==r?(u=c.jsx(F,{type:"body1",testID:"last-name-value",children:r}),e[14]=r,e[15]=u):u=e[15];let L;e[16]!==y||e[17]!==u?(L=c.jsxs(he,{children:[y,u]}),e[16]=y,e[17]=u,e[18]=L):L=e[18];let p;e[19]!==d?(p=d("infoBox.dateOfBirth"),e[19]=d,e[20]=p):p=e[20];let O;e[21]!==p?(O=c.jsx(F,{type:"body1",children:p}),e[21]=p,e[22]=O):O=e[22];let I;e[23]!==h||e[24]!==E.language?(I=Gt(h,E.language),e[23]=h,e[24]=E.language,e[25]=I):I=e[25];let k;e[26]!==I?(k=c.jsx(F,{type:"body1",testID:"dob-value",children:I}),e[26]=I,e[27]=k):k=e[27];let o;e[28]!==O||e[29]!==k?(o=c.jsxs(he,{children:[O,k]}),e[28]=O,e[29]=k,e[30]=o):o=e[30];let b;return e[31]!==o||e[32]!==w||e[33]!==L?(b=c.jsxs(Dt,{"data-testid":"user-info-box",children:[w,L,o]}),e[31]=o,e[32]=w,e[33]=L,e[34]=b):b=e[34],b},Wt=n=>{const e=re.c(44),{stateType:a,canRetry:r,firstName:h,lastName:s,dateOfBirth:d,partnerName:E,logoSrc:f,logoAlt:m,onLink:R,onCancel:w,onRetry:l,onClose:y}=n;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={keyPrefix:"components.organisms.linkSamlAccountScreen"},e[0]=u):u=e[0];const{t:L}=_e("translation",u);let p,O,I,k,o,b,x,T,N;if(e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==s||e[5]!==m||e[6]!==f||e[7]!==w||e[8]!==y||e[9]!==R||e[10]!==l||e[11]!==E||e[12]!==a||e[13]!==L){const v=Ht({stateType:a,canRetry:r,t:L,partnerName:E}),j=E?`${E} and Hinge Health`:"Partner and Hinge Health";let P;e[23]!==w||e[24]!==y||e[25]!==R||e[26]!==l?(P=Y=>{switch(Y){case"link":return R;case"cancel":return w;case"try-again":return l;case"close":return y;default:return Vt}},e[23]=w,e[24]=y,e[25]=R,e[26]=l,e[27]=P):P=e[27];const W=P;k=c.jsx(_t,{role:"status","aria-live":"assertive","aria-atomic":"true","data-testid":"link-account-announcement",children:v.announcement}),e[28]!==j||e[29]!==m||e[30]!==f?(o=f&&c.jsx(Ut,{children:c.jsx("img",{src:f,alt:m||j,"data-testid":"cobranded-logo"})}),e[28]=j,e[29]=m,e[30]=f,e[31]=o):o=e[31],b=c.jsx(F,{type:"heading2",id:"link-saml-account-screen-header",testID:"screen-heading",children:v.heading}),x=c.jsx(F,{type:"body1",testID:"screen-subheading",children:v.subheading}),T=v.showUserInfo&&c.jsx(Kt,{firstName:h,lastName:s,dateOfBirth:d}),N=v.disclaimer&&c.jsx(F,{type:"body1",testID:"disclaimer-text",children:c.jsx(Ct,{children:c.jsx(At,{i18nKey:"components.organisms.linkSamlAccountScreen.initial.disclaimer",components:{linkToHelpEmail:c.jsx(wt,{showIcon:!1})}})})}),p=Pt,O=v.buttons.primary&&c.jsx(ve,{onPress:W(v.buttons.primary.action),testID:`link-account-btn-${v.buttons.primary.action}`,type:"primary",color:"brand",style:Ue,disabled:v.buttons.primary.showSpinner?"spinner":v.buttons.primary.disabled,label:v.buttons.primary.label}),I=v.buttons.secondary&&c.jsx(ve,{type:"secondary",color:"brand",style:Ue,label:v.buttons.secondary.label,onPress:W(v.buttons.secondary.action),testID:`link-account-btn-${v.buttons.secondary.action}`}),e[1]=r,e[2]=d,e[3]=h,e[4]=s,e[5]=m,e[6]=f,e[7]=w,e[8]=y,e[9]=R,e[10]=l,e[11]=E,e[12]=a,e[13]=L,e[14]=p,e[15]=O,e[16]=I,e[17]=k,e[18]=o,e[19]=b,e[20]=x,e[21]=T,e[22]=N}else p=e[14],O=e[15],I=e[16],k=e[17],o=e[18],b=e[19],x=e[20],T=e[21],N=e[22];let H;e[32]!==p||e[33]!==O||e[34]!==I?(H=c.jsxs(p,{children:[O,I]}),e[32]=p,e[33]=O,e[34]=I,e[35]=H):H=e[35];let M;return e[36]!==H||e[37]!==k||e[38]!==o||e[39]!==b||e[40]!==x||e[41]!==T||e[42]!==N?(M=c.jsxs(c.Fragment,{children:[k,o,b,x,T,N,H]}),e[36]=H,e[37]=k,e[38]=o,e[39]=b,e[40]=x,e[41]=T,e[42]=N,e[43]=M):M=e[43],M};function Vt(){}const zt=(n,e)=>{switch(e.type){case"START_LINK":return{type:"pending",attempt:e.attempt};case"LINK_SUCCESS":return{type:"success",linkedAt:e.linkedAt};case"LINK_ERROR":return{type:"failed",error:e.error,canRetry:e.canRetry};case"CANCEL":return{type:"cancelled"};case"RETRY":case"RESET":return{type:"idle"};default:return n}},Xt=3,Qt=({onLinkAccounts:n,onClose:e,initialState:a={type:"idle"}})=>{const[r,h]=A.useReducer(zt,a),s=A.useRef(!1),d=A.useRef(0),E={link:A.useCallback(async()=>
125{if(!s.current){s.current=!0,d.current+=1,h({type:"START_LINK",attempt:d.current});try{await n(),h({type:"LINK_SUCCESS",linkedAt:new Date})}catch(f){const m=f instanceof Error?f:new Error(String(f));ge(m,{tags:{component:"LinkSamlAccountScreen",action:"link_accounts",attempt:d.current}}),h({type:"LINK_ERROR",error:m,canRetry:d.current<Xt})}finally{s.current=!1}}},[n]),cancel:A.useCallback(()=>{h({type:"CANCEL"})},[]),retry:A.useCallback(()=>{h({type:"RETRY"})},[]),close:A.useCallback(()=>{e()},[e])};return{state:r,actions:E}},Be=n=>{const e=re.c(17),{isOpen:a,firstName:r,lastName:h,dateOfBirth:s,onLinkAccounts:d,onClose:E,initialState:f,partnerName:m,logoSrc:R,logoAlt:w}=n;let l;e[0]!==f||e[1]!==E||e[2]!==d?(l={onLinkAccounts:d,onClose:E,initialState:f},e[0]=f,e[1]=E,e[2]=d,e[3]=l):l=e[3];const{state:y,actions:u}=Qt(l);if(!a)return null;const L=y.type==="failed"?y.canRetry:void 0;let p;return e[4]!==u.cancel||e[5]!==u.close||e[6]!==u.link||e[7]!==u.retry||e[8]!==L||e[9]!==s||e[10]!==r||e[11]!==h||e[12]!==w||e[13]!==R||e[14]!==m||e[15]!==y.type?(p=bt.createPortal(c.jsx(st,{children:c.jsx(ct,{children:c.jsx(Ot,{role:"dialog","aria-modal":"true","aria-labelledby":"link-saml-account-screen-header","data-testid":"link-saml-account-screen",children:c.jsx(vt,{children:c.jsx(Wt,{stateType:y.type,canRetry:L,firstName:r,lastName:h,dateOfBirth:s,partnerName:m,logoSrc:R,logoAlt:w,onLink:u.link,onCancel:u.cancel,onRetry:u.retry,onClose:u.close})})})})}),document.body),e[4]=u.cancel,e[5]=u.close,e[6]=u.link,e[7]=u.retry,e[8]=L,e[9]=s,e[10]=r,e[11]=h,e[12]=w,e[13]=R,e[14]=m,e[15]=y.type,e[16]=p):p=e[16],p};Be.displayName="LinkSamlAccountScreen";const Pe=n=>n instanceof Object&&n.hasOwnProperty("error_description"),Yt={mfa_required:ne.MFA_CHALLENGE_REDIRECT,consent_required:ne.CONSENT_REQUIRED_REDIRECT},In=()=>{const n=St(),e=lt(),a=ut(),r=window.history.state,h=new URLSearchParams(window.location.search),s=h.get("connection"),d=h.get("connectionType"),E=h.get("status"),[f,m]=A.useState(!1),[R,w]=A.useState(),[l,y]=A.useState(null),[u,L]=A.useState(null),[p,O]=A.useState(!1),[I,k]=A.useState(!1),o=A.useRef(!1),[b]=dt({fetchPolicy:"network-only"}),[x]=ft({fetchPolicy:"cache-first"}),[T,N]=A.useState(void 0),[H,M]=A.useState(void 0),[v,j]=A.useState(void 0),P=Ce(),W=P==null?void 0:P.source,Y=P==null?void 0:P.hhUuid,ie={};W&&(ie.saml_source=W),Y&&(ie.hh_uuid=Y);const{treatments:me,loading:$e}=ht([J.SAML_ACCOUNT_LINKING,J.SAML_MOBILE_DEEPLINK],ie,!1,"network-only"),ye=me[J.SAML_ACCOUNT_LINKING],je=me[J.SAML_MOBILE_DEEPLINK],q=ye===!0,pe=je===!0,be=!$e&&ye!==void 0,{hasLinkableSamlId:Z,fetchUserData:Se,linkAccount:Ae,clearLinkableSamlId:Ee}=xt(R),we=t=>{var i;return G.REGISTRATION_PROFILE.replace(":clientSlug",(i=t==null?void 0:t.client)==null?void 0:i.toString())},{error:ae,isAuthenticated:Le,isLoading:Ie,getAccessToken:Fe,getIdToken:He,setAuthToken:Ge,retryInteractiveSignIn:Ke}=gt(),Ne=A.useCallback(async(t,i=!1)=>{var g;try{await e.validateAuth();const S=(g=t==null?void 0:t.redirectTo)==null?void 0:g.toString();S&&!S.startsWith(we(t))?n(t==null?void 0:t.redirectTo,{replace:i}):n(ee.BASE,{replace:i})}catch(S){V(`Error during authentication redirect: ${S}`,{tags:{connectionType:(t==null?void 0:t.connectionType)||"unknown"}}),n(z.NO_ACCOUNT)}},[e,n]),Re=A.useCallback(async(t,i)=>{var B;if((((B=i==null?void 0:i.sub)==null?void 0:B.startsWith(Q.SAML.ID_PREFIX))??!1)||!q||!Z)return!1;const S=await Se();if(!S)return V("Failed to fetch user data for SAML account linking modal",{level:"warning",extra:{hasLinkableSamlId:Z,isSamlAccountLinkingEnabled:q,userSub:i==null?void 0:i.sub}}),!1;const U=S.clientIdentifier;if(U)try{const{data:D}=await x({variables:{input:{clientIdentifier:U}}}),_=D==null?void 0:D.clientBranding,se=_==null?void 0:_.webClientName,ce=(_==null?void 0:_.cobrandedLogoUrl)??void 0;N(se),ce?(await new Promise(le=>{const ue=new Image,Te=setTimeout(le,1500);ue.onload=()=>{clearTimeout(Te),le()},ue.onerror=()=>{clearTimeout(Te),le()},ue.src=ce}),M(ce),j(se?`${se} Logo`:void 0)):(M(de),j("Hinge Health Logo"))}catch(D){ge(D,{level:"warning",extra:{clientIdentifier:U,samlSource:W}}),N(void 0),M(de),j("Hinge Health Logo")}else N(void 0),M(de),j("Hinge Health Logo");return y(S),L(()=>t),O(!1),k(!1),m(!0),!0},[q,Z,Se,x,W]),We=A.useCallback(async()=>{try{await Ae(),O(!0),await a.track(C.SAML_ACCOUNT_LINKED)}catch(t){throw k(!0),await a.track(C.SAML_ACCOUNT_LINKING_FAILED),t}},[Ae,a]),Ve=A.useCallback(()=>{m(!1),N(void 0),M(void 0),j(void 0),y(null),!p&&!I&&(a.track(C.SAML_ACCOUNT_LINKING_DECLINED),Ee()),u&&u(!0),L(null)},[Ee,I,p,a,u]),oe=A.useCallback(async(t,i)=>{const g=U=>{Ne(t,U)};await Re(g,i)||g(!1)},[Ne,Re]),ze=t=>{var i,g,S;if(((g=(i=t.appState)==null?void 0:i.streamlinedState)==null?void 0:g.source)==="am_i_eligible"){fe(),n(G.STREAMLINED,{state:t.appState.streamlinedState});return}if((S=t.appState)!=null&&S.client){n(G.REGISTRATION.replace(":clientSlug",t.appState.client.toString()));return}n(G.BASILISK_USER_SIGN_IN)},Xe=(t,i)=>{a.track(Yt[i]),Ke({...t.appState,interactiveRetryAttempted:!0}).catch(g=>{var S;V(`Error during interactive sign-in retry: ${g}`,{tags:{connectionType:((S=t.appState)==null?void 0:S.connectionType)||"unknown"}}),n(z.NO_ACCOUNT)})},Qe=t=>{var g,S;if(Pe(t)){if(t.error_description==="user_cancelled_authorize"){ze(t);return}const U=Q.SIGN_IN_SILENT_AUTH_RETRYABLE_ERRORS.find(({errorDescription:B})=>B===t.error_description);if(U&&((g=t.appState)==null?void 0:g.sender)===Q.SENDER.SIGN_IN_SILENT_AUTH&&!((S=t.appState)!=null&&S.interactiveRetryAttempted)){Xe(t,U.reason);return}}const i=Pe(t)?t:void 0;V(`Error during SSO redirect: ${t}`,{tags:{connectionType:(r==null?void 0:r.connectionType)||"unknown",authErrorCode:i==null?void 0:i.error},extra:{authErrorDescription:i==null?void 0:i.error_description}}),n(z.NO_ACCOUNT)},xe=async(t,i)=>{try{await e.validateAuth();const{data:g}=await b();if(!((g==null?void 0:g.userApplications)??[]).some(_=>_.standing===yt.ACCEPTED)){await oe(t,i);return}let B;const D=()=>{document.hidden||(clearTimeout(B),document.removeEventListener("visibilitychange",D),n(ee.BASE,{replace:!0}))};document.addEventListener("visibilitychange",D),B=setTimeout(()=>{document.removeEventListener("visibilitychange",D),n(ee.BASE,{replace:!0})},2e3),window.location.replace(pt)}catch(g){ge(g,{tags:{connectionType:(t==null?void 0:t.connectionType)||"unknown"}}),n(ee.BASE,{replace:!0})}},Ye=async t=>{var g;if(d!=="enterprise")return;if(E==="waitlist"){await a.track(C.SAML_WAITLIST,{redirected_to:"waitlist",inbound_referral_source:s}),n(G.SAML_WAITLIST,{state:{id:t==null?void 0:t.sub}});return}else if(E==="paused"){await a.track(C.SAML_PAUSED,{redirected_to:"for-individuals",inbound_referral_source:s}),window.location.href=It(r==null?void 0:r.connectionType,s);return}if((g=t==null?void 0:t.hh)!=null&&g.uuid){if(await a.track(C.AUTHENTICATED_SUCCESSFUL_LOGIN,{redirected_to:"dashboard",inbou
125nd_referral_source:s,hhUuid:t.hh.uuid}),pe&&De()){await xe(r,t);return}await oe(r,t);return}await a.track(C.SAML_REGISTRATION,{redirected_to:"registration_precheck",inbound_referral_source:s});const i=new URLSearchParams({id:(t==null?void 0:t.sub)??"",source:s??"",type:"saml"});n(`${G.REGISTRATION_PRECHECK}?${i.toString()}`)},qe=async t=>{try{return(t==null?void 0:t.sender)===Q.SENDER.OUTBOUND_REFERRAL&&t.redirectTo?(await a.track(C.OUTBOUND_REFERRAL_SUCCESS),window.location.href=t.redirectTo+"?idp_flow=true",!0):!1}catch(i){return await a.track(C.OUTBOUND_REFERRAL_FAILED),V(`Error during outbound referral redirect: ${i}`,{tags:{redirectTo:(t==null?void 0:t.redirectTo)||"unknown"}}),!0}},Ze=(t,i)=>{var S;if(!(t!=null&&t.streamlinedState)||t.streamlinedState.source!=="am_i_eligible"||(S=i==null?void 0:i.hh)!=null&&S.uuid)return!1;if(!(i!=null&&i.sub))return V("SSO redirect missing idToken sub claim"),fe(),n(G.STREAMLINED,{state:t.streamlinedState}),!0;a.track(C.AUTHENTICATED_SUCCESSFUL_LOGIN,{redirected_to:"streamlined_sso",inbound_referral_source:t.streamlinedState.source});const g=fe();return n(G.STREAMLINED,{state:{...t.streamlinedState,...g,authProviderId:i.sub,emailAddress:i.email}}),!0},Je=async()=>{const t=Nt();t&&await a.track(ne.EMAIL_OTP_AUTH_SUCCEEDED,{entryPoint:t,flowName:"login",flowType:t==="primary"?"emailOtp":"emailOtpFallback"})},et=async()=>{const t=Rt();t&&await a.track(ne.PHONE_OTP_AUTH_SUCCEEDED,{entryPoint:t,flowName:"login"})},tt=async t=>{var g,S,U,B,D,_;if((g=t==null?void 0:t.sub)!=null&&g.startsWith(Q.SAML.ID_PREFIX))return Ye(t);if(await qe(r)||Ze(r,t))return;if(!(r!=null&&r.client)&&!((S=t==null?void 0:t.hh)!=null&&S.uuid)){n(z.NO_ACCOUNT);return}if(await a.track(C.AUTHENTICATED_SUCCESSFUL_LOGIN,{redirected_to:(U=t==null?void 0:t.hh)!=null&&U.uuid?"dashboard":"registration",hhUuid:(B=t==null?void 0:t.hh)==null?void 0:B.uuid}),await Je(),await et(),(D=t==null?void 0:t.hh)!=null&&D.uuid){if(d==="enterprise"&&pe&&De()){await xe(r,t);return}await oe(r,t);return}const i=(_=r==null?void 0:r.redirectTo)==null?void 0:_.toString();i&&i.startsWith(we(r))?n(r.redirectTo,{state:{registrationValues:r.registrationValues}}):n(z.NO_ACCOUNT)},nt=()=>Ie?!1:d==="enterprise"?!0:Le;A.useEffect(()=>{Lt()},[]);const ke=Et(async()=>{if(!o.current){if(ae!==void 0){o.current=!0,Qe(ae);return}if(nt()&&be){o.current=!0;try{const t=await Fe();Ge(t);const i=await He();w(i),tt(i)}catch(t){(t==null?void 0:t.error)!=="login_required"&&V(`Error during authentication handleAuthRedirect: ${t}`,{tags:{connectionType:(r==null?void 0:r.connectionType)||"unknown"}}),n(z.NO_ACCOUNT)}}}});return A.useEffect(()=>{ke()},[ke,Le,ae,Ie,be,q,Z]),c.jsxs(c.Fragment,{children:[c.jsx(mt,{}),c.jsx(Be,{isOpen:f,firstName:(l==null?void 0:l.firstName)??"",lastName:(l==null?void 0:l.lastName)??"",dateOfBirth:(l==null?void 0:l.dateOfBirth)??"",onLinkAccounts:We,onClose:Ve,initialState:f&&l?{type:"idle"}:void 0,partnerName:T,logoSrc:H,logoAlt:v})]})};export{In as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.