@clerk/clerk-js
Version:
Clerk JS library
4 lines (3 loc) • 68 kB
JavaScript
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["470"],{9140:function(e,t,r){r.d(t,{_:()=>z});var i=r(9109),o=r(3799),a=r(9144),l=r(2672),n=r(431),s=r(9460),c=r(8487),d=r(8870),u=r(6788),h=r(8969),m=r(1576),p=r(7703),f=r(207),g=r(4676),y=r(3344),v=r(4204),P=r(2464);let Z=e=>{let{navigate:t}=(0,g.useRouter)(),{email:r,nextStep:o,onReset:n}=e,c=(0,l.useCardState)(),u=(0,m.useUserProfileContext)(),{startEnterpriseSSOLinkFlow:h}=(0,P.eq)(r);async function p(){await t(r.verification.externalVerificationRedirectURL?.href||"")}return a.useEffect(()=>{let{mode:e,componentName:t}=u;h({redirectUrl:"modal"===e?(0,y.bX)({url:window.location.href,componentName:t}):window.location.href}).then(()=>o()).catch(e=>(0,d.S3)(e,[],c.setError))},[]),(0,i.BX)(i.HY,{children:[(0,i.tZ)(v.Flex,{justify:"center",children:(0,i.tZ)(v.Button,{variant:"link",onClick:p,localizationKey:(0,v.localizationKeys)("userProfile.emailAddressPage.enterpriseSSOLink.formButton")})}),(0,i.tZ)(s.K,{children:(0,i.tZ)(v.Button,{variant:"ghost",localizationKey:(0,v.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:v.descriptors.formButtonReset,onClick:n})})]})};var b=r(2786);let z=(0,l.withCardStateProvider)(e=>{let{emailId:t,onSuccess:r,onReset:g,disableAutoFocus:y=!1}=e,v=(0,l.useCardState)(),{user:P}=(0,o.aF)(),z=(0,m.useEnvironment)(),K=(0,o.WZ)(e=>P?.createEmailAddress({email:e})),_=a.useRef(P?.emailAddresses.find(e=>e.id===t)),R=C(_.current,z),x=(0,h.a2)({defaultStep:+!!_.current,onNextStep:()=>v.setError(void 0)}),B=(0,u.Yp)("emailAddress","",{type:"email",label:(0,p.u1)("formFieldLabel__emailAddress"),placeholder:(0,p.u1)("formFieldInputPlaceholder__emailAddress"),isRequired:!0}),w=B.value.length>1&&P?.username!==B.value,k=async e=>{if(e.preventDefault(),P)return K(B.value).then(e=>{_.current=e,x.nextStep()}).catch(e=>(0,d.S3)(e,[B],v.setError))},I=S(R);return(0,i.BX)(h.en,{...x.props,children:[(0,i.tZ)(c.Y,{headerTitle:e.title||(0,p.u1)("userProfile.emailAddressPage.title"),headerSubtitle:e.subtitle||(0,p.u1)("userProfile.emailAddressPage.formHint"),children:(0,i.BX)(n.l.Root,{onSubmit:k,children:[(0,i.tZ)(n.l.ControlRow,{elementId:B.id,children:(0,i.tZ)(n.l.PlainInput,{...B.props,autoFocus:!y})}),(0,i.tZ)(s.A,{submitLabel:(0,p.u1)("userProfile.formButtonPrimary__add"),isDisabled:!w,onReset:g})]})}),(0,i.BX)(c.Y,{headerTitle:(0,p.u1)("userProfile.emailAddressPage.verifyTitle"),headerSubtitle:(0,p.u1)(`${I}.formSubtitle`,{identifier:_.current?.emailAddress||""}),children:["email_link"===R&&(0,i.tZ)(b.K,{nextStep:r,email:_.current,onReset:g}),"email_code"===R&&(0,i.tZ)(f.H,{nextStep:r,identification:_.current,identifier:_.current?.emailAddress,prepareVerification:()=>_.current?.prepareVerification({strategy:"email_code"}),onReset:g}),"enterprise_sso"===R&&(0,i.tZ)(Z,{nextStep:r,email:_.current,onReset:g})]})]})}),S=e=>{switch(e){case"email_code":return"userProfile.emailAddressPage.emailCode";case"enterprise_sso":return"userProfile.emailAddressPage.enterpriseSSOLink";case"email_link":return"userProfile.emailAddressPage.emailLink";default:throw Error(`Unsupported strategy for email verification: ${e}`)}},C=(e,t)=>e?.matchesSsoConnection?"enterprise_sso":!function(e){let{userSettings:t}=e,{email_address:r}=t.attributes;return!!(r?.enabled&&r?.verifications.includes("email_link"))}(t)?"email_code":"email_link"},207:function(e,t,r){r.d(t,{H:()=>u});var i=r(9109),o=r(9144),a=r(2667),l=r(2672),n=r(431),s=r(9460),c=r(8870),d=r(4204);let u=e=>{let t=(0,l.useCardState)(),{nextStep:r,identification:u,identifier:h,onReset:m,prepareVerification:p}=e,f=()=>p?.()?.catch(e=>(0,c.S3)(e,[],t.setError)),g=(0,a.e3)({onCodeEntryFinished:(e,t,r)=>{u?.attemptVerification({code:e}).then(()=>t()).catch(r)},onResendCodeClicked:f,onResolve:r});return o.useEffect(()=>{f()},[]),(0,i.BX)(i.HY,{children:[(0,i.tZ)(n.l.OTPInput,{...g,label:(0,d.localizationKeys)("userProfile.emailAddressPage.emailCode.formTitle"),description:(0,d.localizationKeys)("userProfile.emailAddressPage.emailCode.formSubtitle",{identifier:h||""}),resendButton:(0,d.localizationKeys)("userProfile.emailAddressPage.emailCode.resendButton"),centerAlign:!1}),(0,i.BX)(s.K,{children:[(0,i.tZ)(d.Button,{isLoading:g.isLoading,localizationKey:(0,d.localizationKeys)("formButtonPrimary__verify"),elementDescriptor:d.descriptors.formButtonPrimary,onClick:g.onFakeContinue}),(0,i.tZ)(d.Button,{variant:"ghost",isDisabled:g.isLoading,localizationKey:(0,d.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:d.descriptors.formButtonReset,onClick:m})]})]})}},2786:function(e,t,r){r.d(t,{K:()=>p,M:()=>f});var i=r(9109),o=r(9144),a=r(2672),l=r(9460),n=r(5495),s=r(8870),c=r(8969),d=r(6749),u=r(1576),h=r(4204),m=r(2464);let p=e=>{let{email:t,nextStep:r,onReset:c}=e,p=(0,a.useCardState)(),f=(0,u.useUserProfileContext)(),{startEmailLinkFlow:g}=(0,m.E2)(t),{displayConfig:y}=(0,u.useEnvironment)();function v(){let{routing:e}=f,t="virtual"===e?y.userProfileUrl:"";g({redirectUrl:(0,d.Uu)({ctx:f,baseUrl:t,intent:"profile"})}).then(()=>r()).catch(e=>(0,s.S3)(e,[],p.setError))}return o.useEffect(()=>{v()},[]),(0,i.BX)(i.HY,{children:[(0,i.tZ)(n.V,{resendButton:(0,h.localizationKeys)("userProfile.emailAddressPage.emailLink.resendButton"),onResendCodeClicked:v}),(0,i.tZ)(l.K,{children:(0,i.tZ)(h.Button,{variant:"ghost",localizationKey:(0,h.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:h.descriptors.formButtonReset,onClick:c})})]})},f=()=>(0,i.tZ)(c.Ej,{title:(0,h.localizationKeys)("signUp.emailLink.verifiedSwitchTab.title"),subtitle:(0,h.localizationKeys)("signUp.emailLink.verifiedSwitchTab.subtitle"),status:"verified"})},6591:function(e,t,r){r.r(t),r.d(t,{UserProfileModal:()=>tk,UserProfile:()=>tw});var i=r(9109),o=r(9144),a=r(2672),l=r(5579),n=r(3394),s=r(1673),c=r(1576),d=r(4204),u=r(4676),h=r(7703);let m=e=>{let{pages:t}=(0,c.useUserProfileContext)();return(0,i.BX)(l.Uh,{contentRef:e.contentRef,children:[(0,i.tZ)(l.l2,{title:(0,h.u1)("userProfile.navbar.title"),description:(0,h.u1)("userProfile.navbar.description"),routes:t.routes,contentRef:e.contentRef}),e.children]})};var p=r(4995),f=r(3799),g=r(2418),y=r(2654),v=r(9655),P=r(3009),Z=r(8870),b=r(3344),z=r(8969),S=r(9805),C=r(4709),K=r(2464),_=r(7046);let R=e=>{let{strategy:t}=e,r=(0,a.useCardState)(),{user:o}=(0,f.aF)(),{navigate:l}=(0,u.useRouter)(),{strategyToDisplayData:n}=(0,K.vO)(),{additionalOAuthScopes:s,componentName:h,mode:m}=(0,c.useUserProfileContext)(),p="modal"===m,g=(0,f.WZ)(()=>{let e=t.replace("oauth_",""),r=p?(0,b.bX)({url:window.location.href,componentName:h,socialProvider:e}):window.location.href,i=s?s[e]:[];return o?.createExternalAccount({strategy:t,redirectUrl:r,additionalScopes:i})}),y=n[t].iconUrl?(0,i.tZ)(d.Image,{isLoading:r.loadingMetadata===t,isDisabled:r.isLoading,elementDescriptor:d.descriptors.providerIcon,elementId:d.descriptors.providerIcon.setId(n[t].id),src:n[t].iconUrl,alt:`Connect ${n[t].name} account`,sx:e=>({width:e.sizes.$4})}):(0,i.tZ)(z.e_,{id:n[t].id,value:n[t].name,isLoading:r.loadingMetadata===t,isDisabled:r.isLoading});return(0,i.tZ)(v.zd.ActionMenuItem,{id:n[t].id,onClick:()=>{if(o)return r.setLoading(t),g().then(e=>{e&&e.verification?.externalVerificationRedirectURL&&((0,_._)(2e3).then(()=>r.setIdle(t)),l(e.verification.externalVerificationRedirectURL.href))}).catch(e=>{(0,Z.S3)(e,[],r.setError),r.setIdle(t)})},isDisabled:r.isLoading,variant:"ghost",isLoading:r.loadingMetadata===t,focusRing:!1,closeAfterClick:!1,localizationKey:(0,d.localizationKeys)("userProfile.connectedAccountPage.socialButtonsBlockButton",{provider:n[t].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:y},t)},x=({onClick:e})=>{let{user:t}=(0,f.aF)(),{strategies:r}=(0,K.vO)(),o=r.filter(e=>e.startsWith("oauth")),a=t?.verifiedExternalAccounts.map(e=>`oauth_${e.provider}`),l=o.filter(e=>!a.includes(e));return 0===l.length?null:(0,i.tZ)(v.zd.ActionMenu,{triggerLocalizationKey:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.primaryButton"),id:"connectedAccounts",onClick:e,children:l.map(e=>(0,i.tZ)(R,{strategy:e},e))})},B=e=>{let{onSuccess:t,onReset:r}=e,{user:a}=(0,f.aF)(),{emailId:l}=e,n=a?.emailAddresses.find(e=>e.id===l),s=o.useRef(n?.emailAddress),c=n?.verification?.status==="verified"?(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.messageLine2"):void 0;return s.current?(0,i.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:c,successMessage:(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.successMessage",{emailAddress:s.current}),deleteResource:()=>Promise.resolve(n?.destroy()),onSuccess:t,onReset:r}):null},w=e=>{let{phoneId:t,onSuccess:r,onReset:a}=e,{user:l}=(0,f.aF)(),n=l?.phoneNumbers.find(e=>e.id===t),s=o.useRef(n?.phoneNumber),c=n?.verification?.status==="verified"?(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.messageLine2"):void 0;return s.current?(0,i.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:c,successMessage:(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.successMessage",{phoneNumber:s.current}),deleteResource:()=>Promise.resolve(n?.destroy()),onSuccess:r,onReset:a}):null},k=e=>{let{accountId:t,onSuccess:r,onReset:a}=e,{user:l}=(0,f.aF)(),n=l?.externalAccounts.find(e=>e.id===t),s=o.useRef(n?.provider),{providerToDisplayData:c}=(0,K.vO)();return s.current?(0,i.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.messageLine1",{identifier:c[s.current]?.name||""}),messageLine2:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.messageLine2"),successMessage:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.successMessage",{connectedAccount:c[s.current]?.name||""}),deleteResource:()=>Promise.resolve(n?.destroy()),onSuccess:r,onReset:a}):null},I=e=>{let{user:t}=(0,f.aF)(),{walletId:r,onSuccess:a,onReset:l}=e,n=t?.web3Wallets.find(e=>e.id===r),s=o.useRef(n?.web3Wallet),c=n?.verification?.status==="verified"?(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.messageLine2"):void 0;return s.current?(0,i.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:c,successMessage:(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.successMessage",{web3Wallet:s.current}),deleteResource:()=>Promise.resolve(n?.destroy()),onSuccess:a,onReset:l}):null},A=e=>{let{user:t}=(0,f.aF)(),{phoneId:r,onSuccess:a,onReset:l}=e,n=t?.phoneNumbers.find(e=>e.id===r),s=o.useRef(n?.phoneNumber);return s.current?(0,i.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.removeResource.messageLine1",{identifier:s.current}),messageLine2:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.removeResource.messageLine2"),successMessage:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.removeResource.successMessage",{mfaPhoneCode:s.current}),deleteResource:()=>Promise.resolve(n?.setReservedForSecondFactor({reserved:!1})),onSuccess:a,onReset:l}):null},T=e=>{let{onSuccess:t,onReset:r}=e,{user:o}=(0,f.aF)();return o?(0,i.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.mfaTOTPPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.mfaTOTPPage.removeResource.messageLine1"),messageLine2:(0,d.localizationKeys)("userProfile.mfaTOTPPage.removeResource.messageLine2"),successMessage:(0,d.localizationKeys)("userProfile.mfaTOTPPage.removeResource.successMessage"),deleteResource:o.disableTOTP,onSuccess:t,onReset:r}):null},X=e=>{let{onSuccess:t,onReset:r,passkey:o}=e;return(0,i.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.passkeyScreen.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.passkeyScreen.removeResource.messageLine1",{name:o.name||""}),deleteResource:o.delete,onSuccess:t,onReset:r})},L=e=>{let{close:t}=(0,C.XC)();return(0,i.tZ)(k,{onSuccess:t,onReset:t,...e})},$=["external_account_missing_refresh_token","oauth_fetch_user_error","oauth_token_exchange_error","external_account_email_address_verification_required"],F=(0,a.withCardStateProvider)(({shouldAllowCreation:e=!0})=>{let{user:t}=(0,f.aF)(),r=(0,a.useCardState)(),l=!!t?.externalAccounts?.length,[n,s]=(0,o.useState)(null);if(!t||!e&&!l)return null;let c=[...t.verifiedExternalAccounts,...t.unverifiedExternalAccounts.filter(e=>e.verification?.error)];return(0,i.BX)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.title"),centered:!1,id:"connectedAccounts",children:[(0,i.tZ)(g.Z.Alert,{children:r.error}),(0,i.BX)(S.a.Root,{value:n,onChange:s,children:[(0,i.tZ)(v.zd.ItemList,{id:"connectedAccounts",children:c.map(e=>(0,i.tZ)(E,{account:e},e.id))}),e&&(0,i.tZ)(x,{onClick:()=>s(null)})]})]})}),E=({account:e})=>{let{additionalOAuthScopes:t,componentName:r,mode:l}=(0,c.useUserProfileContext)(),{navigate:n}=(0,u.useRouter)(),{user:s}=(0,f.aF)(),h=(0,a.useCardState)(),m=e.id,p="modal"===l,g=p?(0,b.bX)({url:window.location.href,componentName:r}):window.location.href,y=(0,f.WZ)(()=>s?.createExternalAccount({strategy:e.verification.strategy,redirectUrl:g,additionalScopes:R}));if(!s)return null;let{providerToDisplayData:P}=(0,K.vO)(),C=e.username||e.emailAddress,_=e.verification?.error?.longMessage,R=function(e,t){if(!t)return[];let r=t[e.provider]||[],i=e.approvedScopes.split(" ");return 0===r.filter(e=>!i.includes(e)).length?[]:r}(e,t),x=R.length>0&&""!=e.approvedScopes,B=$.includes(e.verification?.error?.code||"")||x,w=B?(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.subtitle__disconnected"):_,k=async()=>{let t=p?(0,b.bX)({url:window.location.href,componentName:r}):window.location.href;try{let r;(r=x?await e.reauthorize({additionalScopes:R,redirectUrl:t}):await y())&&await n(r.verification.externalVerificationRedirectURL?.href||"")}catch(e){(0,Z.S3)(e,[],h.setError)}};return(0,i.BX)(o.Fragment,{children:[(0,i.BX)(v.zd.Item,{id:"connectedAccounts",children:[(0,i.BX)(d.Flex,{sx:e=>({overflow:"hidden",gap:e.space.$2}),children:[(0,i.tZ)(()=>P[e.provider].iconUrl?(0,i.tZ)(d.Image,{elementDescriptor:[d.descriptors.providerIcon],elementId:d.descriptors.socialButtonsProviderIcon.setId(e.provider),alt:P[e.provider].name,src:P[e.provider].iconUrl,sx:e=>({width:e.sizes.$4,flexShrink:0})}):(0,i.tZ)(z.e_,{id:e.provider,value:P[e.provider].name}),{}),(0,i.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.BX)(d.Flex,{gap:1,center:!0,children:[(0,i.tZ)(d.Text,{sx:e=>({color:e.colors.$colorForeground}),children:`${P[e.provider].name}`}),(0,i.tZ)(d.Text,{truncate:!0,as:"span",colorScheme:"secondary",children:C?`\u{2022} ${C}`:""})]})})]}),(0,i.tZ)(D,{account:e})]}),B&&(0,i.BX)(d.Box,{sx:e=>({padding:`${e.sizes.$none} ${e.sizes.$none} ${e.sizes.$1x5} ${e.sizes.$8x5}`}),children:[(0,i.tZ)(d.Text,{colorScheme:"secondary",sx:e=>({paddingRight:e.sizes.$1x5,display:"inline-block"}),localizationKey:w}),(0,i.tZ)(d.Button,{sx:{display:"inline-block"},onClick:k,variant:"link",localizationKey:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.actionLabel__connectionFailed")})]}),e.verification?.error?.code&&!B&&(0,i.tZ)(d.Text,{colorScheme:"danger",sx:e=>({padding:`${e.sizes.$none} ${e.sizes.$1x5} ${e.sizes.$1x5} ${e.sizes.$8x5}`}),children:_}),(0,i.tZ)(S.a.Open,{value:`remove-${m}`,children:(0,i.tZ)(S.a.Card,{variant:"destructive",children:(0,i.tZ)(L,{accountId:e.id})})})]},e.id)},D=({account:e})=>{let{open:t}=(0,C.XC)(),r=e.id,o=[{label:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.destructiveActionTitle"),isDestructive:!0,onClick:()=>t(`remove-${r}`)}].filter(e=>null!==e);return(0,i.tZ)(P.a,{actions:o})},O=e=>e.defaultSecondFactor?-1:1;function N(e){let t=[];return Object.entries(e).forEach(([,e])=>{e.used_for_second_factor&&t.push(...e.second_factors)}),t}function W(e,t){let r=N(e);return t.totpEnabled&&(r=r.filter(e=>"totp"!==e)),(t.backupCodeEnabled||!t.twoFactorEnabled)&&(r=r.filter(e=>"backup_code"!==e)),r}function M(e,t){if(!e)return[];let r=e.filter(e=>e.id===t),i=e.filter(e=>e.id!==t),o=i.filter(e=>e.verification?.status==="verified"),a=i.filter(e=>!!e.verification?.status&&e.verification?.status!=="verified"),l=i.filter(e=>!e.verification.status);return o.sort((e,t)=>e.id.localeCompare(t.id)),a.sort((e,t)=>e.verification?.expireAt&&t.verification?.expireAt?e.verification.expireAt.getTime()-t.verification.expireAt.getTime():0),[...r,...o,...a,...l]}var U=r(9140);let Y=e=>{let{close:t}=(0,C.XC)();return(0,i.tZ)(B,{onSuccess:t,onReset:t,...e})},q=e=>{let{close:t}=(0,C.XC)();return(0,i.tZ)(U._,{onSuccess:t,onReset:t,...e})},j=({shouldAllowCreation:e=!0})=>{let{user:t}=(0,f.aF)();return(0,i.tZ)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.title"),centered:!1,id:"emailAddresses",children:(0,i.tZ)(S.a.Root,{children:(0,i.BX)(v.zd.ItemList,{id:"emailAddresses",children:[M(t?.emailAddresses,t?.primaryEmailAddressId).map(e=>{let r=e.id;return(0,i.BX)(o.Fragment,{children:[(0,i.BX)(v.zd.Item,{id:"emailAddresses",children:[(0,i.BX)(d.Flex,{sx:e=>({overflow:"hidden",gap:e.space.$1}),children:[(0,i.tZ)(d.Text,{sx:e=>({color:e.colors.$colorForeground}),truncate:!0,children:e.emailAddress}),t?.primaryEmailAddressId===r&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__primary")}),"verified"!==e.verification.status&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__unverified")})]}),(0,i.tZ)(V,{email:e})]}),(0,i.tZ)(S.a.Open,{value:`remove-${r}`,children:(0,i.tZ)(S.a.Card,{variant:"destructive",children:(0,i.tZ)(Y,{emailId:r})})}),(0,i.tZ)(S.a.Open,{value:`verify-${r}`,children:(0,i.tZ)(S.a.Card,{children:(0,i.tZ)(q,{emailId:r})})})]},e.emailAddress)}),e&&(0,i.BX)(i.HY,{children:[(0,i.tZ)(S.a.Trigger,{value:"add",children:(0,i.tZ)(v.zd.ArrowButton,{id:"emailAddresses",localizationKey:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.primaryButton")})}),(0,i.tZ)(S.a.Open,{value:"add",children:(0,i.tZ)(S.a.Card,{children:(0,i.tZ)(q,{})})})]})]})})})},V=({email:e})=>{let t=(0,a.useCardState)(),{user:r}=(0,f.aF)(),{open:o}=(0,C.XC)(),l=e.id,n=r?.primaryEmailAddressId===l,s="verified"===e.verification.status,c=(0,f.WZ)(()=>r?.update({primaryEmailAddressId:l})),u=[n&&!s?{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.detailsAction__primary"),onClick:()=>o(`verify-${l}`)}:null,!n&&s?{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.detailsAction__nonPrimary"),onClick:()=>{c().catch(e=>(0,Z.S3)(e,[],t.setError))}}:null,!n&&!s?{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.detailsAction__unverified"),onClick:()=>o(`verify-${l}`)}:null,{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.destructiveAction"),isDestructive:!0,onClick:()=>o(`remove-${l}`)}].filter(e=>null!==e);return(0,i.tZ)(P.a,{actions:u})},H=()=>{let{user:e}=(0,f.aF)(),t=e?.enterpriseAccounts.filter(({enterpriseConnection:e})=>e?.active);return t?.length?(0,i.tZ)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.enterpriseAccountsSection.title"),id:"enterpriseAccounts",centered:!1,children:(0,i.tZ)(v.zd.ItemList,{id:"enterpriseAccounts",children:t.map(e=>(0,i.tZ)(Q,{account:e},e.id))})}):null},Q=({account:e})=>{let t=e.emailAddress,r=e?.enterpriseConnection?.name,o=e.verification?.error?.longMessage;return(0,i.BX)(v.zd.Item,{id:"enterpriseAccounts",sx:e=>({gap:e.space.$2,justifyContent:"start"}),children:[(0,i.tZ)(G,{account:e}),(0,i.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.BX)(d.Flex,{gap:1,center:!0,children:[(0,i.tZ)(d.Text,{truncate:!0,colorScheme:"body",children:r}),(0,i.tZ)(d.Text,{truncate:!0,as:"span",colorScheme:"secondary",children:t?`\u{2022} ${t}`:""}),o&&(0,i.tZ)(d.Badge,{colorScheme:"danger",localizationKey:(0,d.localizationKeys)("badge__requiresAction")})]})})]},e.id)},G=({account:e})=>{let{provider:t,enterpriseConnection:r}=e,o=t.replace(/(oauth_|saml_)/,"").trim(),a=r?.name??o,l={elementDescriptor:[d.descriptors.providerIcon],alt:a,sx:e=>({width:e.sizes.$4}),elementId:d.descriptors.enterpriseButtonsProviderIcon.setId(e.provider)};return r?.logoPublicUrl?(0,i.tZ)(d.Image,{...l,src:r.logoPublicUrl}):(0,i.tZ)(z.e_,{id:o,value:a,"aria-label":`${a}'s icon`,elementDescriptor:[d.descriptors.providerIcon,d.descriptors.providerInitialIcon],elementId:d.descriptors.providerInitialIcon.setId(o)})};var J=r(8690),ee=r(431),et=r(9460),er=r(8487),ei=r(6788),eo=r(207);let ea=(0,a.withCardStateProvider)(e=>{let{phoneId:t,onSuccess:r,onReset:a}=e,{user:l}=(0,f.aF)(),n=o.useRef(l?.phoneNumbers.find(e=>e.id===t)),s=(0,z.a2)({defaultStep:+!!n.current});return(0,i.BX)(z.en,{...s.props,children:[(0,i.tZ)(el,{resourceRef:n,title:(0,d.localizationKeys)("userProfile.phoneNumberPage.title"),onSuccess:s.nextStep,onReset:a}),(0,i.tZ)(en,{resourceRef:n,title:(0,d.localizationKeys)("userProfile.phoneNumberPage.verifyTitle"),onSuccess:r,onReset:a})]})}),el=e=>{let{title:t,onSuccess:r,onReset:o,onUseExistingNumberClick:l,resourceRef:n}=e,s=(0,a.useCardState)(),{user:c}=(0,f.aF)(),u=(0,f.WZ)((e,t)=>e.createPhoneNumber(t)),h=(0,ei.Yp)("phoneNumber","",{type:"tel",label:(0,d.localizationKeys)("formFieldLabel__phoneNumber"),isRequired:!0}),m=h.value.length>1&&c?.username!==h.value,p=!!c?.phoneNumbers?.length&&l,g=async e=>{if(e.preventDefault(),c)return u(c,{phoneNumber:h.value}).then(e=>{n.current=e,r()}).catch(e=>(0,Z.S3)(e,[h],s.setError))};return(0,i.tZ)(er.Y,{headerTitle:t,gap:1,children:(0,i.BX)(ee.l.Root,{gap:4,onSubmit:g,children:[(0,i.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.phoneNumberPage.infoText"),colorScheme:"secondary"}),(0,i.tZ)(ee.l.ControlRow,{elementId:h.id,children:(0,i.tZ)(ee.l.PhoneInput,{...h.props,autoFocus:!0})}),(0,i.BX)(d.Flex,{justify:p?"between":"end",children:[p&&(0,i.tZ)(d.Button,{variant:"ghost",localizationKey:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.backButton"),onClick:l}),(0,i.tZ)(et.A,{submitLabel:(0,d.localizationKeys)("userProfile.formButtonPrimary__add"),isDisabled:!m,onReset:o})]})]})})},en=e=>{let{title:t,onSuccess:r,resourceRef:o,onReset:a}=e;return(0,i.tZ)(er.Y,{headerTitle:t,headerSubtitle:(0,d.localizationKeys)("userProfile.phoneNumberPage.verifySubtitle",{identifier:o.current?.phoneNumber||""}),children:(0,i.tZ)(eo.H,{nextStep:r,identification:o.current,identifier:o.current?.phoneNumber,prepareVerification:o.current?.prepareVerification,onReset:a})})},es=e=>{let{close:t}=(0,C.XC)();return(0,i.tZ)(w,{onSuccess:t,onReset:t,...e})},ec=e=>{let{close:t}=(0,C.XC)();return(0,i.tZ)(ea,{onSuccess:t,onReset:t,...e})},ed=({shouldAllowCreation:e=!0})=>{let{user:t}=(0,f.aF)(),r=!!t?.phoneNumbers?.length;return e||r?(0,i.tZ)(v.zd.Root,{centered:!1,title:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.title"),id:"phoneNumbers",children:(0,i.tZ)(S.a.Root,{children:(0,i.BX)(v.zd.ItemList,{id:"phoneNumbers",children:[M(t?.phoneNumbers,t?.primaryPhoneNumberId).map(e=>{let r=e.id;return(0,i.BX)(o.Fragment,{children:[(0,i.BX)(v.zd.Item,{id:"phoneNumbers",children:[(0,i.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.BX)(d.Flex,{gap:2,center:!0,children:[(0,i.tZ)(d.Text,{sx:e=>({color:e.colors.$colorForeground}),children:(0,J.L_)(e.phoneNumber)}),t?.primaryPhoneNumberId===r&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__primary")}),"verified"!==e.verification.status&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__unverified")})]})}),(0,i.tZ)(eu,{phone:e})]}),(0,i.tZ)(S.a.Open,{value:`remove-${r}`,children:(0,i.tZ)(S.a.Card,{variant:"destructive",children:(0,i.tZ)(es,{phoneId:r})})}),(0,i.tZ)(S.a.Open,{value:`verify-${r}`,children:(0,i.tZ)(S.a.Card,{children:(0,i.tZ)(ec,{phoneId:r})})})]},r)}),e&&(0,i.BX)(i.HY,{children:[(0,i.tZ)(S.a.Trigger,{value:"add",children:(0,i.tZ)(v.zd.ArrowButton,{id:"phoneNumbers",localizationKey:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.primaryButton")})}),(0,i.tZ)(S.a.Open,{value:"add",children:(0,i.tZ)(S.a.Card,{children:(0,i.tZ)(ec,{})})})]})]})})}):null},eu=({phone:e})=>{let t=(0,a.useCardState)(),{open:r}=(0,C.XC)(),{user:o}=(0,f.aF)(),l=e.id,n=(0,f.WZ)(t=>t.update({primaryPhoneNumberId:e.id}));if(!o)return null;let s=o.primaryPhoneNumberId===e.id,c="verified"===e.verification.status,u=[s&&!c?{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.detailsAction__primary"),onClick:()=>r(`verify-${l}`)}:null,!s&&c?{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.detailsAction__nonPrimary"),onClick:()=>n(o).catch(e=>(0,Z.S3)(e,[],t.setError))}:null,!s&&!c?{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.detailsAction__unverified"),onClick:()=>r(`verify-${l}`)}:null,{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.destructiveAction"),isDestructive:!0,onClick:()=>r(`remove-${l}`)}].filter(e=>null!==e);return(0,i.tZ)(P.a,{actions:u})};var eh=r(1217),em=r(6127);let ep=(0,a.withCardStateProvider)(e=>{let{onSuccess:t,onReset:r}=e,{user:o}=(0,f.aF)(),l=(0,f.WZ)(e=>o?.update({username:e})),{userSettings:n}=(0,c.useEnvironment)(),s=(0,a.useCardState)(),{t:u,locale:h}=(0,d.useLocalizations)(),{usernameSettings:m}=n,p=(0,ei.Yp)("username",o?.username||"",{type:"text",label:(0,d.localizationKeys)("formFieldLabel__username"),placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__username"),buildErrorMessage:e=>(0,em.f)(e,{t:u,locale:h,usernameSettings:m})});if(!o)return null;let g=n.attributes.username?.required,y=(!g||p.value.length>0)&&o.username!==p.value,v=async()=>{try{await l(p.value),t()}catch(e){(0,Z.S3)(e,[p],s.setError)}};return(0,i.tZ)(er.Y,{headerTitle:o.username?(0,d.localizationKeys)("userProfile.usernamePage.title__update"):(0,d.localizationKeys)("userProfile.usernamePage.title__set"),children:(0,i.BX)(ee.l.Root,{onSubmit:v,children:[(0,i.tZ)(ee.l.ControlRow,{elementId:p.id,children:(0,i.tZ)(ee.l.PlainInput,{...p.props,autoFocus:!0,isRequired:g})}),(0,i.tZ)(et.A,{isDisabled:!y,onReset:r})]})})}),ef=()=>{let{close:e}=(0,C.XC)();return(0,i.tZ)(ep,{onSuccess:e,onReset:e})},eg=()=>{let{user:e}=(0,f.aF)();return e?(0,i.tZ)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.usernameSection.title"),id:"username",sx:{alignItems:"center",[eh.mqu.md]:{alignItems:"flex-start"}},children:(0,i.BX)(S.a.Root,{children:[(0,i.tZ)(S.a.Closed,{value:"edit",children:(0,i.BX)(v.zd.Item,{id:"username",sx:{paddingLeft:e.username?void 0:"0"},children:[e.username&&(0,i.tZ)(d.Text,{truncate:!0,sx:e=>({color:e.colors.$colorForeground}),children:e.username}),(0,i.tZ)(S.a.Trigger,{value:"edit",children:(0,i.tZ)(v.zd.Button,{id:"username",localizationKey:e.username?(0,d.localizationKeys)("userProfile.start.usernameSection.primaryButton__updateUsername"):(0,d.localizationKeys)("userProfile.start.usernameSection.primaryButton__setUsername")})})]})}),(0,i.tZ)(S.a.Open,{value:"edit",children:(0,i.tZ)(S.a.Card,{children:(0,i.tZ)(ef,{})})})]})}):null};var ey=r(7295),ev=r(3300),eP=r(6654),eZ=r(5472);let eb=e=>{let{user:t,...r}=e;return(0,i.tZ)(eP.C,{...r,title:(0,h.u1)("userProfile.profilePage.imageFormTitle"),avatarPreview:(0,i.tZ)(eZ.Y,{size:e=>e.sizes.$12,...t})})},ez=(0,a.withCardStateProvider)(e=>{let{onSuccess:t,onReset:r}=e,o=(0,a.useCardState)(),{user:l}=(0,f.aF)();if(!l)return null;let{first_name:n,last_name:s}=(0,c.useEnvironment)().userSettings.attributes,u=n?.enabled,h=s?.enabled,m=l.firstName||"",p=l.lastName||"",g=(0,ei.Yp)("firstName",l.firstName||"",{type:"text",label:(0,d.localizationKeys)("formFieldLabel__firstName"),placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__firstName"),isRequired:s?.required}),y=(0,ei.Yp)("lastName",l.lastName||"",{type:"text",label:(0,d.localizationKeys)("formFieldLabel__lastName"),placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__lastName"),isRequired:s?.required}),v=u&&g.value!==m||h&&y.value!==p,P=u&&n.required||h&&s.required,z=P&&!!y.value&&!!g.value&&v,S=l.enterpriseAccounts.some(e=>e.active),C=async e=>(e.preventDefault(),(v?l.update({firstName:g.value,lastName:y.value}):Promise.resolve()).then(t).catch(e=>{(0,Z.S3)(e,[g,y],o.setError)}));return(0,i.BX)(er.Y,{headerTitle:(0,d.localizationKeys)("userProfile.profilePage.title"),children:[S&&(0,i.tZ)(ev.e,{message:(0,d.localizationKeys)("userProfile.profilePage.readonly")}),(0,i.BX)(ee.l.Root,{onSubmit:C,sx:e=>({gap:e.space.$6}),children:[(0,i.tZ)(eb,{user:l,onAvatarChange:e=>l.setProfileImage({file:e}).then(()=>{o.setIdle()}).catch(e=>(0,Z.S3)(e,[],o.setError)),onAvatarRemove:(0,b.QO)(l.imageUrl)?null:()=>{l.setProfileImage({file:null}).then(()=>{o.setIdle()}).catch(e=>(0,Z.S3)(e,[],o.setError))}}),(u||h)&&(0,i.BX)(ee.l.ControlRow,{elementId:"name",children:[u&&(0,i.tZ)(ee.l.PlainInput,{...g.props,isDisabled:S,autoFocus:!0}),h&&(0,i.tZ)(ee.l.PlainInput,{...y.props,isDisabled:S,autoFocus:!u})]}),(0,i.tZ)(et.A,{isDisabled:P?!z:!v,onReset:r})]})]})}),eS=()=>{let{close:e}=(0,C.XC)();return(0,i.tZ)(ez,{onSuccess:e,onReset:e})},eC=()=>{let{user:e}=(0,f.aF)();if(!e)return null;let{username:t,primaryEmailAddress:r,primaryPhoneNumber:o,primaryWeb3Wallet:a,...l}=e;return(0,i.tZ)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.profileSection.title"),id:"profile",sx:{[eh.mqu.md]:{alignItems:"flex-start"}},children:(0,i.BX)(S.a.Root,{children:[(0,i.tZ)(S.a.Closed,{value:"edit",children:(0,i.BX)(v.zd.Item,{id:"profile",children:[(0,i.tZ)(ey.E,{user:l,size:"lg",mainIdentifierVariant:"subtitle",sx:e=>({color:e.colors.$colorForeground})}),(0,i.tZ)(S.a.Trigger,{value:"edit",children:(0,i.tZ)(v.zd.Button,{id:"profile",localizationKey:(0,d.localizationKeys)("userProfile.start.profileSection.primaryButton")})})]})}),(0,i.tZ)(S.a.Open,{value:"edit",children:(0,i.tZ)(S.a.Card,{children:(0,i.tZ)(eS,{})})})]})})};var eK=r(4101);let e_=(0,a.withCardStateProvider)(({onClick:e})=>{let t=(0,a.useCardState)(),{user:r}=(0,f.aF)(),{strategies:o,strategyToDisplayData:l}=(0,K.vO)(),n=o.filter(e=>e.startsWith("web3")),s=r?.verifiedWeb3Wallets.map(e=>e.verification.strategy),c=n.filter(e=>!s.includes(e)),u=(0,f.WZ)(e=>r?.createWeb3Wallet({web3Wallet:e})),h=async e=>{let i=e.replace("web3_","").replace("_signature","");t.setError(void 0);try{t.setLoading(e);let o=await (0,eK.Ly)({provider:i});if(!r)throw Error("user is not defined");let a=await u(o);a=await a?.prepareVerification({strategy:e});let l=a?.verification.message,n=await (0,eK.bQ)({identifier:o,nonce:l,provider:i});await a?.attemptVerification({signature:n}),t.setIdle()}catch(r){t.setIdle();let e=(0,Z.zQ)(r);e?t.setError(e.longMessage):(0,Z.S3)(r,[],t.setError)}};return 0===c.length?null:(0,i.BX)(i.HY,{children:[(0,i.tZ)(v.zd.ActionMenu,{id:"web3Wallets",triggerLocalizationKey:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.primaryButton"),onClick:e,children:c.map(e=>(0,i.tZ)(v.zd.ActionMenuItem,{id:l[e].id,onClick:()=>h(e),isLoading:t.loadingMetadata===e,isDisabled:t.isLoading,localizationKey:(0,d.localizationKeys)("userProfile.web3WalletPage.web3WalletButtonsBlockButton",{provider:l[e].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:(0,i.tZ)(d.Image,{elementDescriptor:d.descriptors.providerIcon,elementId:d.descriptors.providerIcon.setId(l[e].id),isLoading:t.loadingMetadata===e,isDisabled:t.isLoading,src:l[e].iconUrl,alt:`Connect ${l[e].name}`,sx:e=>({width:e.sizes.$5})})},e))}),t.error&&(0,i.tZ)(d.Text,{colorScheme:"danger",sx:e=>({padding:e.sizes.$1x5,paddingLeft:e.sizes.$8x5}),children:t.error})]})}),eR=e=>{let{close:t}=(0,C.XC)();return(0,i.tZ)(I,{onSuccess:t,onReset:t,...e})},ex=(0,a.withCardStateProvider)(({shouldAllowCreation:e=!0})=>{let{user:t}=(0,f.aF)(),r=(0,a.useCardState)(),{strategyToDisplayData:l}=(0,K.vO)(),n=!!t?.web3Wallets?.length,[s,c]=(0,o.useState)(null);return e||n?(0,i.BX)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.title"),centered:!1,id:"web3Wallets",children:[(0,i.tZ)(g.Z.Alert,{children:r.error}),(0,i.BX)(S.a.Root,{value:s,onChange:c,children:[(0,i.tZ)(v.zd.ItemList,{id:"web3Wallets",children:M(t?.web3Wallets,t?.primaryWeb3WalletId).map(e=>{var r;let a=e.verification.strategy,n=e.id;return l[a]&&(0,i.BX)(o.Fragment,{children:[(0,i.BX)(v.zd.Item,{id:"web3Wallets",align:"start",children:[(0,i.BX)(d.Flex,{sx:e=>({alignItems:"center",gap:e.space.$2,width:"100%"}),children:[l[a].iconUrl&&(0,i.tZ)(d.Image,{src:l[a].iconUrl,alt:l[a].name,sx:e=>({width:e.sizes.$4})}),(0,i.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.BX)(d.Flex,{gap:2,justify:"start",children:[(0,i.BX)(d.Text,{children:[l[a].name," (",(r=e.web3Wallet).length<=10?r:r.slice(0,6)+"..."+r.slice(-4),")"]}),t?.primaryWeb3WalletId===n&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__primary")}),"verified"!==e.verification.status&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__unverified")})]})})]}),(0,i.tZ)(eB,{walletId:n})]},n),(0,i.tZ)(S.a.Open,{value:`remove-${n}`,children:(0,i.tZ)(S.a.Card,{variant:"destructive",children:(0,i.tZ)(eR,{walletId:e.id})})})]},e.id)})}),e&&(0,i.tZ)(e_,{onClick:()=>c(null)})]})]}):null}),eB=({walletId:e})=>{let t=(0,a.useCardState)(),{open:r}=(0,C.XC)(),{user:o}=(0,f.aF)(),l=o?.primaryWeb3WalletId===e,n=(0,f.WZ)(()=>o?.update({primaryWeb3WalletId:e})),s=[!l?{label:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.detailsAction__nonPrimary"),onClick:()=>{n().catch(e=>(0,Z.S3)(e,[],t.setError))}}:null,{label:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.destructiveAction"),isDestructive:!0,onClick:()=>r(`remove-${e}`)}].filter(e=>null!==e);return(0,i.tZ)(P.a,{actions:s})},ew=(0,a.withCardStateProvider)(()=>{let{attributes:e,social:t,enterpriseSSO:r}=(0,c.useEnvironment)().userSettings,o=(0,a.useCardState)(),{user:l}=(0,f.aF)(),n=e.username?.enabled,s=e.email_address?.enabled,u=e.phone_number?.enabled,h=t&&Object.values(t).filter(e=>e.enabled).length>0,m=l&&r.enabled,p=e.web3_wallet?.enabled,v=!m||!l.enterpriseAccounts.some(e=>e.active&&e.enterpriseConnection?.disableAdditionalIdentifications);return(0,i.tZ)(d.Col,{elementDescriptor:d.descriptors.page,sx:e=>({gap:e.space.$8,color:e.colors.$colorForeground}),children:(0,i.BX)(d.Col,{elementDescriptor:d.descriptors.profilePage,elementId:d.descriptors.profilePage.setId("account"),children:[(0,i.tZ)(y.h.Root,{children:(0,i.tZ)(y.h.Title,{localizationKey:(0,d.localizationKeys)("userProfile.start.headerTitle__account"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,i.tZ)(g.Z.Alert,{children:o.error}),(0,i.tZ)(eC,{}),n&&(0,i.tZ)(eg,{}),s&&(0,i.tZ)(j,{shouldAllowCreation:v}),u&&(0,i.tZ)(ed,{shouldAllowCreation:v}),h&&(0,i.tZ)(F,{shouldAllowCreation:v}),m&&(0,i.tZ)(H,{}),p&&(0,i.tZ)(ex,{shouldAllowCreation:v})]})})});var ek=r(8104),eI=r(3997),eA=r(4174);let eT=()=>{let e,{user:t}=(0,f.aF)(),{session:r}=(0,f.kP)(),{data:o,isLoading:a}=(0,K.ib)(t?.getSessions,"user-sessions");return(0,i.tZ)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.activeDevicesSection.title"),centered:!1,id:"activeDevices",children:(0,i.tZ)(v.zd.ItemList,{id:"activeDevices",disableAnimation:!0,children:a?(0,i.tZ)(ek.m,{}):o?.sort((e=r.id,t=>t.id===e?-1:1)).map(e=>eX(e.status)?(0,i.tZ)(eL,{session:e},e.id):null)})})},eX=e=>["active","pending"].includes(e),eL=({session:e})=>{let t=(0,f.kP)().session?.id===e.id,r=(0,K._m)(),o=(0,f.WZ)(e.revoke.bind(e)),a=async()=>{if(!t&&e)return r.setLoading(),o().catch(e=>(0,Z.S3)(e,[],r.setError)).finally(()=>r.setIdle())};return(0,i.tZ)(v.zd.Item,{id:"activeDevices",elementDescriptor:d.descriptors.activeDeviceListItem,elementId:t?d.descriptors.activeDeviceListItem.setId("current"):void 0,sx:{alignItems:"flex-start",opacity:r.isLoading?.5:1},isDisabled:r.isLoading,children:(0,i.BX)(i.HY,{children:[(0,i.tZ)(e$,{session:e}),!t&&(0,i.tZ)(eF,{revoke:a})]})})},e$=e=>{let{session:t}=(0,f.kP)(),r=t?.id===e.session.id,o=!!t?.actor,a=!!e.session.actor,{city:l,country:n,browserName:s,browserVersion:c,deviceType:u,ipAddress:h,isMobile:m}=e.session.latestActivity,p=`${s||""} ${c||""}`.trim()||"Web browser",g=[l||"",n||""].filter(Boolean).join(", ").trim()||null,{t:y}=(0,d.useLocalizations)();return(0,i.BX)(d.Flex,{elementDescriptor:d.descriptors.activeDevice,elementId:r?d.descriptors.activeDevice.setId("current"):void 0,sx:e=>({width:"100%",overflow:"hidden",gap:e.space.$4,[eh.mqu.sm]:{gap:e.space.$2}}),children:[(0,i.tZ)(d.Flex,{sx:e=>({[eh.mqu.sm]:{padding:"0"},borderRadius:e.radii.$md}),children:(0,i.tZ)(d.Icon,{elementDescriptor:d.descriptors.activeDeviceIcon,elementId:d.descriptors.activeDeviceIcon.setId(m?"mobile":"desktop"),icon:m?eA.Fh:eA.eu,sx:e=>({"--cl-chassis-bottom":"#444444","--cl-chassis-back":"#343434","--cl-chassis-screen":"#575757","--cl-screen":"#000000",width:e.space.$8,height:e.space.$8})})}),(0,i.BX)(d.Col,{align:"start",gap:1,children:[(0,i.BX)(d.Flex,{center:!0,gap:2,children:[(0,i.tZ)(d.Text,{children:u||(m?"Mobile device":"Desktop device")}),r&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__thisDevice"),colorScheme:o?"danger":"primary"}),o&&!a&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__userDevice")}),!r&&a&&(0,i.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__otherImpersonatorDevice"),colorScheme:"danger"})]}),(0,i.tZ)(d.Text,{colorScheme:"secondary",children:p}),(0,i.BX)(d.Text,{colorScheme:"secondary",children:[h," (",g,")"]}),(0,i.tZ)(d.Text,{colorScheme:"secondary",children:y((0,eI.Q)(e.session.lastActiveAt))})]})]})},eF=({revoke:e})=>{let t=[{label:(0,d.localizationKeys)("userProfile.start.activeDevicesSection.destructiveAction"),isDestructive:!0,onClick:e}].filter(e=>null!==e);return(0,i.tZ)(P.a,{actions:t})};var eE=r(4264);let eD=(0,a.withCardStateProvider)(e=>{let{onReset:t}=e,r=(0,a.useCardState)(),{afterSignOutUrl:o,afterMultiSessionSingleSignOutUrl:l}=(0,c.useSignOutContext)(),{user:n}=(0,f.aF)(),{t:s}=(0,d.useLocalizations)(),{otherSessions:u}=(0,eE.j)({user:n}),{setActive:h}=(0,f.cL)(),m=(0,f.WZ)(()=>n?.delete()),p=(0,ei.Yp)("deleteConfirmation","",{type:"text",label:(0,d.localizationKeys)("userProfile.deletePage.actionDescription"),isRequired:!0,placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__confirmDeletionUserAccount")}),g=p.value===(s((0,d.localizationKeys)("formFieldInputPlaceholder__confirmDeletionUserAccount"))||"Delete account"),y=async()=>{if(g)try{await m();let e=0===u.length?o:l;return await h({session:null,redirectUrl:e})}catch(e){(0,Z.S3)(e,[],r.setError)}};return(0,i.tZ)(er.Y,{headerTitle:(0,d.localizationKeys)("userProfile.deletePage.title"),sx:e=>({gap:e.space.$0x5}),children:(0,i.BX)(ee.l.Root,{onSubmit:y,children:[(0,i.BX)(d.Col,{gap:1,children:[(0,i.tZ)(d.Text,{colorScheme:"secondary",localizationKey:(0,d.localizationKeys)("userProfile.deletePage.messageLine1")}),(0,i.tZ)(d.Text,{colorScheme:"danger",localizationKey:(0,d.localizationKeys)("userProfile.deletePage.messageLine2")})]}),(0,i.tZ)(ee.l.ControlRow,{elementId:p.id,children:(0,i.tZ)(ee.l.PlainInput,{...p.props,ignorePasswordManager:!0})}),(0,i.tZ)(et.A,{submitLabel:(0,d.localizationKeys)("userProfile.deletePage.confirm"),colorScheme:"danger",isDisabled:!g,onReset:t})]})})}),eO=()=>{let{close:e}=(0,C.XC)();return(0,i.tZ)(eD,{onSuccess:e,onReset:e})},eN=()=>(0,i.tZ)(v.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.dangerSection.title"),id:"danger",sx:{alignItems:"center",[eh.mqu.md]:{alignItems:"flex-start"}},children:(0,i.BX)(S.a.Root,{children:[(0,i.tZ)(S.a.Closed,{value:"delete",children:(0,i.tZ)(v.zd.Item,{id:"danger",sx:e=>({paddingLeft:e.space.$1}),children:(0,i.tZ)(S.a.Trigger,{value:"delete",children:(0,i.tZ)(v.zd.Button,{id:"danger",variant:"ghost",colorScheme:"danger",localizationKey:(0,d.localizationKeys)("userProfile.start.dangerSection.deleteAccountButton")})})})}),(0,i.tZ)(S.a.Open,{value:"delete",children:(0,i.tZ)(S.a.Card,{variant:"destructive",children:(0,i.tZ)(eO,{})})})]})});var eW=r(5994),eM=r(3531),eU=r(5878);let eY=e=>{let{code:t}=e;return(0,i.tZ)(d.Flex,{center:!0,sx:e=>({padding:`${e.space.$1} ${e.space.$4}`}),children:(0,i.tZ)(d.Text,{children:t})})},eq=e=>{let{subtitle:t,backupCodes:r}=e,{applicationName:o}=(0,c.useEnvironment)().displayConfig,{user:a}=(0,f.aF)(),{print:l,printableProps:n}=(0,z.Qz)(),{onCopy:s,hasCopied:u}=(0,K.VP)(r?.join(",")||"");if(!a)return null;let h=(0,eU.xC)(a);return r?(0,i.BX)(i.HY,{children:[(0,i.BX)(d.Col,{gap:1,children:[(0,i.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.title__codelist"),variant:"subtitle"}),(0,i.tZ)(d.Text,{localizationKey:t,variant:"caption",colorScheme:"secondary"})]}),(0,i.BX)(d.Box,{sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg}),children:[(0,i.tZ)(d.Grid,{gap:2,sx:e=>({gridTemplateColumns:`repeat(2, minmax(${e.sizes.$12}, 1fr))`,padding:`${e.space.$4} ${e.space.$6}`}),children:r.map((e,t)=>(0,i.tZ)(eY,{code:e},t))}),(0,i.BX)(d.Grid,{sx:e=>({borderTopWidth:e.borderWidths.$normal,borderTopStyle:e.borderStyles.$solid,borderTopColor:e.colors.$borderAlpha100,gridTemplateColumns:"repeat(3, minmax(0, 1fr))",">:not([hidden])~:not([hidden])":{borderRightWidth:"0px",borderLeftWidth:"1px",borderStyle:"solid",borderColor:e.colors.$borderAlpha100},">:first-child":{borderBottomLeftRadius:e.radii.$lg},">:last-child":{borderBottomRightRadius:e.radii.$lg}}),children:[(0,i.tZ)(d.Button,{variant:"ghost",sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),onClick:()=>{let e=document.createElement("a"),t=new Blob([function(e,t,r){let i=e?.join("\n");return`These are your backup codes for ${t} account ${r}.
Store them securely and keep them secret. Each code can only be used once.
${i}`}(r,o,h)],{type:"text/plain"});e.href=URL.createObjectURL(t),e.download=`${o}_backup_codes.txt`,document.body.appendChild(e),e.click()},children:(0,i.tZ)(d.Icon,{icon:eA.UW})}),(0,i.tZ)(d.Button,{variant:"ghost",sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),onClick:l,children:(0,i.tZ)(d.Icon,{icon:eA.Kh})}),(0,i.tZ)(d.Button,{variant:"ghost",onClick:s,sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),children:(0,i.tZ)(d.Icon,{icon:u?eA.Jr:eA.CK})})]})]}),(0,i.BX)(z.o4,{...n,children:[(0,i.BX)(d.Heading,{children:["Your backup codes for ",o," account ",h,":"]}),(0,i.tZ)(d.Col,{gap:2,children:r.map((e,t)=>(0,i.tZ)(eY,{code:e},t))})]})]}):null},ej=(0,a.withCardStateProvider)(e=>{let{onSuccess:t,onReset:r}=e,{user:l}=(0,f.aF)(),n=(0,a.useCardState)(),s=(0,f.WZ)(()=>l?.createBackupCode()),[c,u]=o.useState(void 0);return(o.useEffect(()=>{!c&&l&&s().then(e=>u(e)).catch(e=>{if((0,eM.mh)(e))return r();(0,Z.S3)(e,[],n.setError)})},[]),n.error)?(0,i.tZ)(er.Y,{headerTitle:(0,d.localizationKeys)("userProfile.backupCodePage.title")}):(0,i.tZ)(er.Y,{headerTitle:(0,d.localizationKeys)("userProfile.backupCodePage.title"),children:c?(0,i.BX)(i.HY,{children:[(0,i.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.successMessage")}),(0,i.tZ)(eq,{subtitle:(0,d.localizationKeys)("userProfile.backupCodePage.subtitle__codelist"),backupCodes:c.codes}),(0,i.tZ)(et.K,{children:(0,i.tZ)(d.Button,{autoFocus:!0,onClick:t,localizationKey:(0,d.localizationKeys)("userProfile.formButtonPrimary__finish"),elementDescriptor:d.descriptors.formButtonPrimary})})]}):(0,i.tZ)(ek.m,{})})}),eV=(0,a.withCardStateProvider)(e=>{let{onSuccess:t,onReset:r}=e,o=(0,z.a2)();return(0,i.BX)(z.en,{...o.props,children:[(0,i.tZ)(eH,{onContinue:o.nextStep}),(0,i.tZ)(ej,{onSuccess:t,onReset:r})]})}),eH=e=>{let{onContinue:t}=e,{close:r}=(0,C.XC)();return(0,i.BX)(er.Y,{headerTitle:(0,d.localizationKeys)("userProfile.backupCodePage.title"),children:[(0,i.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.infoText1")}),(0,i.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.infoText2")}),(0,i.BX)(et.K,{sx:{marginTop:0},children:[(0,i.tZ)(d.Button,{textVariant:"buttonSmall",onClick:t,localizationKey:(0,d.localizationKeys)("userProfile.formButtonPrimary__finish"),elementDescriptor:d.descriptors.formButtonPrimary}),(0,i.tZ)(d.Button,{variant:"ghost",onClick:r,localizationKey:(0,d.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:d.descriptors.formButtonReset})]})]})};var eQ=r(3412),eG=r(7263);let eJ=(0,a.withCardStateProvider)(e=>{let{onReset:t,onSuccess:r}=e,a=o.useRef(),l=(0,z.a2)({defaultStep:2}),n=(0,c.useEnvironment)().userSettings.attributes.backup_code?.enabled;return(0,i.BX)(z.en,{...l.props,children:[(0,i.tZ)(el,{title:(0,d.localizationKeys)("userProfile.phoneNumberPage.title"),resourceRef:a,onSuccess:l.nextStep,onUseExistingNumberClick:()=>l.goToStep(2),onReset:t}),(0,i.tZ)(e1,{title:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.title"),resourceRef:a,onSuccess:()=>n?l.goToStep(3):r(),onReset:()=>l.goToStep(2)}),(0,i.tZ)(e2,{onSuccess:n?l.nextStep:r,onReset:t,onAddPhoneClick:()=>l.goToStep(0),onUnverifiedPhoneClick:e=>{a.current=e,l.goToStep(1)},title:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.title"),resourceRef:a}),n&&(0,i.tZ)(eG.I,{title:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successTitle"),text:a.current?.backupCodes&&a.current?.backupCodes.length>0?[(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successMessage1"),(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successMessage2")]:[(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successMessage1")],onFinish:t,contents:(0,i.tZ)(eq,{backupCodes:a.current?.backupCodes})})]})}),e0=e=>{let{phone:t,onSuccess:r,onUnverifiedPhoneClick:o,resourceRef:l}=e,n=(0,a.useCardState)(),s=(0,f.WZ)(()=>t.setReservedForSecondFactor({reserved:!0})),{country:c}=(0,J.Z_)(t.phoneNumber),u=(0,J.L_)(t.phoneNumber),h=async()=>{if("verified"!==t.verification.status)return o(t);n.setLoading(t.id);try{await s(),l.current=t,r()}catch(e){(0,Z.S3)(e,[],n.setError)}finally{n.setIdle()}};return(0,i.BX)(d.Button,{variant:"outline",colorScheme:"neutral",sx:{justifyContent:"start"},onClick:h,isLoading:n.loadingMetadata===t.id,isDisabled:n.isLoading,children:[c.iso.toUpperCase()," ",u]},t.id)},e1=e=>{let{title:t,onSuccess:r,resourceRef:o,onReset:l}=e,n=(0,a.useCardState)(),s=o.current,c=(0,f.WZ)(()=>s?.setReservedForSecondFactor({reserved:!0})),u=async()=>{n.setLoading(s?.id);try{await c(),o.current=s,r()}catch(e){(0,Z.S3)(e,[],n.setError)}finally{n.setIdle()}};return(0,i.tZ)(er.Y,{headerTitle:t,headerSubtitle:(0,d.localizationKeys)("userProfile.phoneNumberPage.verifySubtitle",{identifier:o.current?.phoneNumber||""}),children:(0,i.tZ)(eo.H,{nextStep:()=>{u()},identification:o.current,identifier:o.current?.phoneNumber,prepareVerification:o.current?.prepareVerification,onReset:l})})},e2=e=>{let{onSuccess:t,onReset:r,title:o,onAddPhoneClick:a,onUnverifiedPhoneClick:l,resourceRef:n}=e,{user:s}=(0,f.aF)();if(!s)return null;let c=s.phoneNumbers.filter(e=>!e.reservedForSecondFactor);return(0,i.BX)(er.Y,{headerTitle:o,gap:1,children:[(0,i.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)(c.length?"userProfile.mfaPhoneCodePage.subtitle__availablePhoneNumbers":"userProfile.mfaPhoneCodePage.subtitle__unavailablePhoneNumbers"),colorScheme:"secondary"}),c.length>0&&(0,i.tZ)(d.Col,{gap:2,children:c.map(e=>(0,i.tZ)(e0,{onSuccess:t,phone:e,onUnverifiedPhoneClick:l,resourceRef:n},e.id))}),(0,i.BX)(et.K,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[(0,i.tZ)(eQ.h,{variant:"ghost","aria-label":"Add phone number",icon:(0,i.tZ)(d.Icon,{icon:eA.v3,sx:e=>({marginRight:e.space.$2})}),localizationKey:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.primaryButton__addPhoneNumber"),onClick:a}),(0,i.tZ)(d.Button,{variant:"ghost",localizationKey:(0,d.localizationKeys)("userProfile.formButtonReset"),onClick:r})]})]})};var e3=r(8864);let e4=(0,a.withCardStateProvider)(e=>{let{title:t,onSuccess:r,onReset:l}=e,{user:n}=(0,f.aF)(),s=(0,a.useCardState)(),c=(0,f.WZ)(()=>n?.createTOTP()),{close:u}=(0,C.XC)(),[h,m]=o.useState(void 0),[p,g]=o.useState("qr");return(o.useEffect(()=>{n&&c().then(e=>m(e)).catch(e=>(0,eM.uX)(e)&&"reverification_cancelled"===e.code?u():(0,Z.S3)(e,[],s.setError))},[]),s.error)?(0,i.tZ)(er.Y,{headerTitle:t}):(0,i.BX)(er.Y,{headerTitle:t,headerSubtitle:"qr"==p?(0,d.localizationKeys)("userProfile.mfaTOTPPage.authenticatorApp.infoText__ableToScan"):(0,d.localizationKeys)("userProfile.mfaTOTPPage.authenticatorApp.infoText__unableToScan"),children:[!h&&(0,i.tZ)(ek.m,{}),h&&(0,i.BX)(i.HY,{children:[(0,i.BX)(d.Col,{gap:4,children:["qr"==p&&(0,i.tZ)(z.s_,{justify:"center",url:h.uri||""}),"uri"==p&&(0,i.BX)(i.HY,{children:[(0,i.tZ)(d.Text,{colorScheme:"secondary",localizationKey:(0,d.localizationKeys)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan1")}),(0,i.tZ)(e3.D,{value:h.secret}),(0,i.tZ)(d.Text,{colorScheme:"secondary",localizationKey:(0,d.localizationKeys)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan2")}),(0,i.tZ)(e3.D,{value:h.uri})]})]}),(0,i.BX)(d.Flex,{justify:"between",align:"center",sx:{width:"100%"},children:["qr"==p&&(0,i.tZ)(d.Button,{variant:"link",textVariant:"buttonLarge",onClick:()=>g("uri"),localizationKey:(0,d.localizationKeys)("userProfile.mfaTOTPPage.authenticatorApp.buttonUnableToScan__nonPrimary")}),"uri"==p&&(0,i.tZ)(d.Button,{variant:"