@clerk/clerk-js
Version:
Clerk JS library
1 lines • 71 kB
JavaScript
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["470"],{99140:function(e,t,i){i.d(t,{_:()=>z}),i(92037),i(28419);var r=i(79109),l=i(83799),o=i(69144),a=i(2672),n=i(70431),s=i(19460),c=i(68487),d=i(88870),u=i(36788),h=i(8969),m=i(11576),p=i(17703),f=i(10207);i(50725);var v=i(24676),g=i(93344),y=i(64204),P=i(12464);let Z=e=>{let{navigate:t}=(0,v.useRouter)(),{email:i,nextStep:l,onReset:n}=e,c=(0,a.useCardState)(),u=(0,m.useUserProfileContext)(),{startEnterpriseSSOLinkFlow:h}=(0,P.eq)(i);async function p(){var e;await t((null==(e=i.verification.externalVerificationRedirectURL)?void 0:e.href)||"")}return o.useEffect(()=>{let{mode:e,componentName:t}=u;h({redirectUrl:"modal"===e?(0,g.bX)({url:window.location.href,componentName:t}):window.location.href}).then(()=>l()).catch(e=>(0,d.S3)(e,[],c.setError))},[]),(0,r.BX)(r.HY,{children:[(0,r.tZ)(y.Flex,{justify:"center",children:(0,r.tZ)(y.Button,{variant:"link",onClick:p,localizationKey:(0,y.localizationKeys)("userProfile.emailAddressPage.enterpriseSSOLink.formButton")})}),(0,r.tZ)(s.K,{children:(0,r.tZ)(y.Button,{variant:"ghost",localizationKey:(0,y.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:y.descriptors.formButtonReset,onClick:n})})]})};var b=i(12786);let z=(0,a.withCardStateProvider)(e=>{var t,i;let{emailId:v,onSuccess:g,onReset:y,disableAutoFocus:P=!1}=e,z=(0,a.useCardState)(),{user:K}=(0,l.aF)(),_=(0,m.useEnvironment)(),R=(0,l.WZ)(e=>null==K?void 0:K.createEmailAddress({email:e})),x=o.useRef(null==K?void 0:K.emailAddresses.find(e=>e.id===v)),B=C(x.current,_),w=(0,h.a2)({defaultStep:+!!x.current,onNextStep:()=>z.setError(void 0)}),k=(0,u.Yp)("emailAddress","",{type:"email",label:(0,p.u1)("formFieldLabel__emailAddress"),placeholder:(0,p.u1)("formFieldInputPlaceholder__emailAddress"),isRequired:!0}),I=k.value.length>1&&(null==K?void 0:K.username)!==k.value,A=async e=>{if(e.preventDefault(),K)return R(k.value).then(e=>{x.current=e,w.nextStep()}).catch(e=>(0,d.S3)(e,[k],z.setError))},T=S(B);return(0,r.BX)(h.en,{...w.props,children:[(0,r.tZ)(c.Y,{headerTitle:e.title||(0,p.u1)("userProfile.emailAddressPage.title"),headerSubtitle:e.subtitle||(0,p.u1)("userProfile.emailAddressPage.formHint"),children:(0,r.BX)(n.l.Root,{onSubmit:A,children:[(0,r.tZ)(n.l.ControlRow,{elementId:k.id,children:(0,r.tZ)(n.l.PlainInput,{...k.props,autoFocus:!P})}),(0,r.tZ)(s.A,{submitLabel:(0,p.u1)("userProfile.formButtonPrimary__add"),isDisabled:!I,onReset:y})]})}),(0,r.BX)(c.Y,{headerTitle:(0,p.u1)("userProfile.emailAddressPage.verifyTitle"),headerSubtitle:(0,p.u1)("".concat(T,".formSubtitle"),{identifier:(null==(t=x.current)?void 0:t.emailAddress)||""}),children:["email_link"===B&&(0,r.tZ)(b.K,{nextStep:g,email:x.current,onReset:y}),"email_code"===B&&(0,r.tZ)(f.H,{nextStep:g,identification:x.current,identifier:null==(i=x.current)?void 0:i.emailAddress,prepareVerification:()=>{var e;return null==(e=x.current)?void 0:e.prepareVerification({strategy:"email_code"})},onReset:y}),"enterprise_sso"===B&&(0,r.tZ)(Z,{nextStep:g,email:x.current,onReset:y})]})]})}),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: ".concat(e))}},C=(e,t)=>(null==e?void 0:e.matchesSsoConnection)?"enterprise_sso":!function(e){let{userSettings:t}=e,{email_address:i}=t.attributes;return!!((null==i?void 0:i.enabled)&&(null==i?void 0:i.verifications.includes("email_link")))}(t)?"email_code":"email_link"},10207:function(e,t,i){i.d(t,{H:()=>u});var r=i(79109),l=i(69144),o=i(12667),a=i(2672),n=i(70431),s=i(19460),c=i(88870),d=i(64204);let u=e=>{let t=(0,a.useCardState)(),{nextStep:i,identification:u,identifier:h,onReset:m,prepareVerification:p}=e,f=()=>{var e;return null==p||null==(e=p())?void 0:e.catch(e=>(0,c.S3)(e,[],t.setError))},v=(0,o.e3)({onCodeEntryFinished:(e,t,i)=>{null==u||u.attemptVerification({code:e}).then(()=>t()).catch(i)},onResendCodeClicked:f,onResolve:i});return l.useEffect(()=>{f()},[]),(0,r.BX)(r.HY,{children:[(0,r.tZ)(n.l.OTPInput,{...v,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,r.BX)(s.K,{children:[(0,r.tZ)(d.Button,{isLoading:v.isLoading,localizationKey:(0,d.localizationKeys)("formButtonPrimary__verify"),elementDescriptor:d.descriptors.formButtonPrimary,onClick:v.onFakeContinue}),(0,r.tZ)(d.Button,{variant:"ghost",isDisabled:v.isLoading,localizationKey:(0,d.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:d.descriptors.formButtonReset,onClick:m})]})]})}},12786:function(e,t,i){i.d(t,{K:()=>p,M:()=>f});var r=i(79109),l=i(69144),o=i(2672),a=i(19460),n=i(65495),s=i(88870),c=i(8969),d=i(56749),u=i(11576),h=i(64204),m=i(12464);let p=e=>{let{email:t,nextStep:i,onReset:c}=e,p=(0,o.useCardState)(),f=(0,u.useUserProfileContext)(),{startEmailLinkFlow:v}=(0,m.E2)(t),{displayConfig:g}=(0,u.useEnvironment)();function y(){let{routing:e}=f,t="virtual"===e?g.userProfileUrl:"";v({redirectUrl:(0,d.Uu)({ctx:f,baseUrl:t,intent:"profile"})}).then(()=>i()).catch(e=>(0,s.S3)(e,[],p.setError))}return l.useEffect(()=>{y()},[]),(0,r.BX)(r.HY,{children:[(0,r.tZ)(n.V,{resendButton:(0,h.localizationKeys)("userProfile.emailAddressPage.emailLink.resendButton"),onResendCodeClicked:y}),(0,r.tZ)(a.K,{children:(0,r.tZ)(h.Button,{variant:"ghost",localizationKey:(0,h.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:h.descriptors.formButtonReset,onClick:c})})]})},f=()=>(0,r.tZ)(c.Ej,{title:(0,h.localizationKeys)("signUp.emailLink.verifiedSwitchTab.title"),subtitle:(0,h.localizationKeys)("signUp.emailLink.verifiedSwitchTab.subtitle"),status:"verified"})},26591:function(e,t,i){i.r(t),i.d(t,{UserProfileModal:()=>tk,UserProfile:()=>tw});var r=i(79109),l=i(69144),o=i(2672),a=i(15579),n=i(23394),s=i(31673),c=i(11576),d=i(64204),u=i(24676),h=i(17703);let m=e=>{let{pages:t}=(0,c.useUserProfileContext)();return(0,r.BX)(a.Uh,{contentRef:e.contentRef,children:[(0,r.tZ)(a.l2,{title:(0,h.u1)("userProfile.navbar.title"),description:(0,h.u1)("userProfile.navbar.description"),routes:t.routes,contentRef:e.contentRef}),e.children]})};i(50725);var p=i(94995),f=i(83799),v=i(92418),g=i(92654);i(65223),i(28419),i(56113);var y=i(19655),P=i(33009),Z=i(88870),b=i(93344),z=i(8969),S=i(99805),C=i(44709),K=i(12464);i(87945);var _=i(57046);let R=e=>{let{strategy:t}=e,i=(0,o.useCardState)(),{user:l}=(0,f.aF)(),{navigate:a}=(0,u.useRouter)(),{strategyToDisplayData:n}=(0,K.vO)(),{additionalOAuthScopes:s,componentName:h,mode:m}=(0,c.useUserProfileContext)(),p="modal"===m,v=(0,f.WZ)(()=>{let e=t.replace("oauth_",""),i=p?(0,b.bX)({url:window.location.href,componentName:h,socialProvider:e}):window.location.href,r=s?s[e]:[];return null==l?void 0:l.createExternalAccount({strategy:t,redirectUrl:i,additionalScopes:r})}),g=n[t].iconUrl?(0,r.tZ)(d.Image,{isLoading:i.loadingMetadata===t,isDisabled:i.isLoading,elementDescriptor:d.descriptors.providerIcon,elementId:d.descriptors.providerIcon.setId(n[t].id),src:n[t].iconUrl,alt:"Connect ".concat(n[t].name," account"),sx:e=>({width:e.sizes.$4})}):(0,r.tZ)(z.e_,{id:n[t].id,value:n[t].name,isLoading:i.loadingMetadata===t,isDisabled:i.isLoading});return(0,r.tZ)(y.zd.ActionMenuItem,{id:n[t].id,onClick:()=>{if(l)return i.setLoading(t),v().then(e=>{var r;e&&(null==(r=e.verification)?void 0:r.externalVerificationRedirectURL)&&((0,_._)(2e3).then(()=>i.setIdle(t)),a(e.verification.externalVerificationRedirectURL.href))}).catch(e=>{(0,Z.S3)(e,[],i.setError),i.setIdle(t)})},isDisabled:i.isLoading,variant:"ghost",isLoading:i.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:g},t)},x=e=>{let{onClick:t}=e,{user:i}=(0,f.aF)(),{strategies:l}=(0,K.vO)(),o=l.filter(e=>e.startsWith("oauth")),a=null==i?void 0:i.verifiedExternalAccounts.map(e=>"oauth_".concat(e.provider)),n=o.filter(e=>!a.includes(e));return 0===n.length?null:(0,r.tZ)(y.zd.ActionMenu,{triggerLocalizationKey:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.primaryButton"),id:"connectedAccounts",onClick:t,children:n.map(e=>(0,r.tZ)(R,{strategy:e},e))})},B=e=>{var t;let{onSuccess:i,onReset:o}=e,{user:a}=(0,f.aF)(),{emailId:n}=e,s=null==a?void 0:a.emailAddresses.find(e=>e.id===n),c=l.useRef(null==s?void 0:s.emailAddress),u=(null==s||null==(t=s.verification)?void 0:t.status)==="verified"?(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.messageLine2"):void 0;return c.current?(0,r.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.messageLine1",{identifier:c.current}),messageLine2:u,successMessage:(0,d.localizationKeys)("userProfile.emailAddressPage.removeResource.successMessage",{emailAddress:c.current}),deleteResource:()=>Promise.resolve(null==s?void 0:s.destroy()),onSuccess:i,onReset:o}):null},w=e=>{var t;let{phoneId:i,onSuccess:o,onReset:a}=e,{user:n}=(0,f.aF)(),s=null==n?void 0:n.phoneNumbers.find(e=>e.id===i),c=l.useRef(null==s?void 0:s.phoneNumber),u=(null==s||null==(t=s.verification)?void 0:t.status)==="verified"?(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.messageLine2"):void 0;return c.current?(0,r.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.messageLine1",{identifier:c.current}),messageLine2:u,successMessage:(0,d.localizationKeys)("userProfile.phoneNumberPage.removeResource.successMessage",{phoneNumber:c.current}),deleteResource:()=>Promise.resolve(null==s?void 0:s.destroy()),onSuccess:o,onReset:a}):null},k=e=>{var t,i;let{accountId:o,onSuccess:a,onReset:n}=e,{user:s}=(0,f.aF)(),c=null==s?void 0:s.externalAccounts.find(e=>e.id===o),u=l.useRef(null==c?void 0:c.provider),{providerToDisplayData:h}=(0,K.vO)();return u.current?(0,r.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.messageLine1",{identifier:(null==(t=h[u.current])?void 0:t.name)||""}),messageLine2:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.messageLine2"),successMessage:(0,d.localizationKeys)("userProfile.connectedAccountPage.removeResource.successMessage",{connectedAccount:(null==(i=h[u.current])?void 0:i.name)||""}),deleteResource:()=>Promise.resolve(null==c?void 0:c.destroy()),onSuccess:a,onReset:n}):null},I=e=>{var t;let{user:i}=(0,f.aF)(),{walletId:o,onSuccess:a,onReset:n}=e,s=null==i?void 0:i.web3Wallets.find(e=>e.id===o),c=l.useRef(null==s?void 0:s.web3Wallet),u=(null==s||null==(t=s.verification)?void 0:t.status)==="verified"?(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.messageLine2"):void 0;return c.current?(0,r.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.messageLine1",{identifier:c.current}),messageLine2:u,successMessage:(0,d.localizationKeys)("userProfile.web3WalletPage.removeResource.successMessage",{web3Wallet:c.current}),deleteResource:()=>Promise.resolve(null==s?void 0:s.destroy()),onSuccess:a,onReset:n}):null},A=e=>{let{user:t}=(0,f.aF)(),{phoneId:i,onSuccess:o,onReset:a}=e,n=null==t?void 0:t.phoneNumbers.find(e=>e.id===i),s=l.useRef(null==n?void 0:n.phoneNumber);return s.current?(0,r.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(null==n?void 0:n.setReservedForSecondFactor({reserved:!1})),onSuccess:o,onReset:a}):null},T=e=>{let{onSuccess:t,onReset:i}=e,{user:l}=(0,f.aF)();return l?(0,r.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:l.disableTOTP,onSuccess:t,onReset:i}):null},X=e=>{let{onSuccess:t,onReset:i,passkey:l}=e;return(0,r.tZ)(z.LE,{title:(0,d.localizationKeys)("userProfile.passkeyScreen.removeResource.title"),messageLine1:(0,d.localizationKeys)("userProfile.passkeyScreen.removeResource.messageLine1",{name:l.name||""}),deleteResource:l.delete,onSuccess:t,onReset:i})},L=e=>{let{close:t}=(0,C.XC)();return(0,r.tZ)(k,{onSuccess:t,onReset:t,...e})},F=["external_account_missing_refresh_token","oauth_fetch_user_error","oauth_token_exchange_error","external_account_email_address_verification_required"],E=(0,o.withCardStateProvider)(e=>{var t;let{shouldAllowCreation:i=!0}=e,{user:a}=(0,f.aF)(),n=(0,o.useCardState)(),s=!!(null==a||null==(t=a.externalAccounts)?void 0:t.length),[c,u]=(0,l.useState)(null);if(!a||!i&&!s)return null;let h=[...a.verifiedExternalAccounts,...a.unverifiedExternalAccounts.filter(e=>{var t;return null==(t=e.verification)?void 0:t.error})];return(0,r.BX)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.title"),centered:!1,id:"connectedAccounts",children:[(0,r.tZ)(v.Z.Alert,{children:n.error}),(0,r.BX)(S.a.Root,{value:c,onChange:u,children:[(0,r.tZ)(y.zd.ItemList,{id:"connectedAccounts",children:h.map(e=>(0,r.tZ)(D,{account:e},e.id))}),i&&(0,r.tZ)(x,{onClick:()=>u(null)})]})]})}),D=e=>{var t,i,a,n,s,h;let{account:m}=e,{additionalOAuthScopes:p,componentName:v,mode:g}=(0,c.useUserProfileContext)(),{navigate:P}=(0,u.useRouter)(),{user:C}=(0,f.aF)(),_=(0,o.useCardState)(),R=m.id,x="modal"===g,B=x?(0,b.bX)({url:window.location.href,componentName:v}):window.location.href,w=(0,f.WZ)(()=>null==C?void 0:C.createExternalAccount({strategy:m.verification.strategy,redirectUrl:B,additionalScopes:T}));if(!C)return null;let{providerToDisplayData:k}=(0,K.vO)(),I=m.username||m.emailAddress,A=null==(i=m.verification)||null==(t=i.error)?void 0:t.longMessage,T=function(e,t){if(!t)return[];let i=t[e.provider]||[],r=e.approvedScopes.split(" ");return 0===i.filter(e=>!r.includes(e)).length?[]:i}(m,p),X=T.length>0&&""!=m.approvedScopes,E=F.includes((null==(n=m.verification)||null==(a=n.error)?void 0:a.code)||"")||X,D=E?(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.subtitle__disconnected"):A,$=async()=>{let e=x?(0,b.bX)({url:window.location.href,componentName:v}):window.location.href;try{let i;if(i=X?await m.reauthorize({additionalScopes:T,redirectUrl:e}):await w()){var t;await P((null==(t=i.verification.externalVerificationRedirectURL)?void 0:t.href)||"")}}catch(e){(0,Z.S3)(e,[],_.setError)}};return(0,r.BX)(l.Fragment,{children:[(0,r.BX)(y.zd.Item,{id:"connectedAccounts",children:[(0,r.BX)(d.Flex,{sx:e=>({overflow:"hidden",gap:e.space.$2}),children:[(0,r.tZ)(()=>k[m.provider].iconUrl?(0,r.tZ)(d.Image,{elementDescriptor:[d.descriptors.providerIcon],elementId:d.descriptors.socialButtonsProviderIcon.setId(m.provider),alt:k[m.provider].name,src:k[m.provider].iconUrl,sx:e=>({width:e.sizes.$4,flexShrink:0})}):(0,r.tZ)(z.e_,{id:m.provider,value:k[m.provider].name}),{}),(0,r.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,r.BX)(d.Flex,{gap:1,center:!0,children:[(0,r.tZ)(d.Text,{sx:e=>({color:e.colors.$colorForeground}),children:"".concat(k[m.provider].name)}),(0,r.tZ)(d.Text,{truncate:!0,as:"span",colorScheme:"secondary",children:I?"• ".concat(I):""})]})})]}),(0,r.tZ)(O,{account:m})]}),E&&(0,r.BX)(d.Box,{sx:e=>({padding:"".concat(e.sizes.$none," ").concat(e.sizes.$none," ").concat(e.sizes.$1x5," ").concat(e.sizes.$8x5)}),children:[(0,r.tZ)(d.Text,{colorScheme:"secondary",sx:e=>({paddingRight:e.sizes.$1x5,display:"inline-block"}),localizationKey:D}),(0,r.tZ)(d.Button,{sx:{display:"inline-block"},onClick:$,variant:"link",localizationKey:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.actionLabel__connectionFailed")})]}),(null==(h=m.verification)||null==(s=h.error)?void 0:s.code)&&!E&&(0,r.tZ)(d.Text,{colorScheme:"danger",sx:e=>({padding:"".concat(e.sizes.$none," ").concat(e.sizes.$1x5," ").concat(e.sizes.$1x5," ").concat(e.sizes.$8x5)}),children:A}),(0,r.tZ)(S.a.Open,{value:"remove-".concat(R),children:(0,r.tZ)(S.a.Card,{variant:"destructive",children:(0,r.tZ)(L,{accountId:m.id})})})]},m.id)},O=e=>{let{account:t}=e,{open:i}=(0,C.XC)(),l=t.id,o=[{label:(0,d.localizationKeys)("userProfile.start.connectedAccountsSection.destructiveActionTitle"),isDestructive:!0,onClick:()=>i("remove-".concat(l))}].filter(e=>null!==e);return(0,r.tZ)(P.a,{actions:o})};i(79876);let $=e=>e.defaultSecondFactor?-1:1;function N(e){let t=[];return Object.entries(e).forEach(e=>{let[,i]=e;i.used_for_second_factor&&t.push(...i.second_factors)}),t}function W(e,t){let i=N(e);return t.totpEnabled&&(i=i.filter(e=>"totp"!==e)),(t.backupCodeEnabled||!t.twoFactorEnabled)&&(i=i.filter(e=>"backup_code"!==e)),i}function M(e,t){if(!e)return[];let i=e.filter(e=>e.id===t),r=e.filter(e=>e.id!==t),l=r.filter(e=>{var t;return(null==(t=e.verification)?void 0:t.status)==="verified"}),o=r.filter(e=>{var t,i;return!!(null==(t=e.verification)?void 0:t.status)&&(null==(i=e.verification)?void 0:i.status)!=="verified"}),a=r.filter(e=>!e.verification.status);return l.sort((e,t)=>e.id.localeCompare(t.id)),o.sort((e,t)=>{var i,r;return(null==(i=e.verification)?void 0:i.expireAt)&&(null==(r=t.verification)?void 0:r.expireAt)?e.verification.expireAt.getTime()-t.verification.expireAt.getTime():0}),[...i,...l,...o,...a]}var U=i(99140);let Y=e=>{let{close:t}=(0,C.XC)();return(0,r.tZ)(B,{onSuccess:t,onReset:t,...e})},q=e=>{let{close:t}=(0,C.XC)();return(0,r.tZ)(U._,{onSuccess:t,onReset:t,...e})},j=e=>{let{shouldAllowCreation:t=!0}=e,{user:i}=(0,f.aF)();return(0,r.tZ)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.title"),centered:!1,id:"emailAddresses",children:(0,r.tZ)(S.a.Root,{children:(0,r.BX)(y.zd.ItemList,{id:"emailAddresses",children:[M(null==i?void 0:i.emailAddresses,null==i?void 0:i.primaryEmailAddressId).map(e=>{let t=e.id;return(0,r.BX)(l.Fragment,{children:[(0,r.BX)(y.zd.Item,{id:"emailAddresses",children:[(0,r.BX)(d.Flex,{sx:e=>({overflow:"hidden",gap:e.space.$1}),children:[(0,r.tZ)(d.Text,{sx:e=>({color:e.colors.$colorForeground}),truncate:!0,children:e.emailAddress}),(null==i?void 0:i.primaryEmailAddressId)===t&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__primary")}),"verified"!==e.verification.status&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__unverified")})]}),(0,r.tZ)(V,{email:e})]}),(0,r.tZ)(S.a.Open,{value:"remove-".concat(t),children:(0,r.tZ)(S.a.Card,{variant:"destructive",children:(0,r.tZ)(Y,{emailId:t})})}),(0,r.tZ)(S.a.Open,{value:"verify-".concat(t),children:(0,r.tZ)(S.a.Card,{children:(0,r.tZ)(q,{emailId:t})})})]},e.emailAddress)}),t&&(0,r.BX)(r.HY,{children:[(0,r.tZ)(S.a.Trigger,{value:"add",children:(0,r.tZ)(y.zd.ArrowButton,{id:"emailAddresses",localizationKey:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.primaryButton")})}),(0,r.tZ)(S.a.Open,{value:"add",children:(0,r.tZ)(S.a.Card,{children:(0,r.tZ)(q,{})})})]})]})})})},V=e=>{let{email:t}=e,i=(0,o.useCardState)(),{user:l}=(0,f.aF)(),{open:a}=(0,C.XC)(),n=t.id,s=(null==l?void 0:l.primaryEmailAddressId)===n,c="verified"===t.verification.status,u=(0,f.WZ)(()=>null==l?void 0:l.update({primaryEmailAddressId:n})),h=[s&&!c?{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.detailsAction__primary"),onClick:()=>a("verify-".concat(n))}:null,!s&&c?{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.detailsAction__nonPrimary"),onClick:()=>{u().catch(e=>(0,Z.S3)(e,[],i.setError))}}:null,!s&&!c?{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.detailsAction__unverified"),onClick:()=>a("verify-".concat(n))}:null,{label:(0,d.localizationKeys)("userProfile.start.emailAddressesSection.destructiveAction"),isDestructive:!0,onClick:()=>a("remove-".concat(n))}].filter(e=>null!==e);return(0,r.tZ)(P.a,{actions:h})},H=()=>{let{user:e}=(0,f.aF)(),t=null==e?void 0:e.enterpriseAccounts.filter(e=>{let{enterpriseConnection:t}=e;return null==t?void 0:t.active});return(null==t?void 0:t.length)?(0,r.tZ)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.enterpriseAccountsSection.title"),id:"enterpriseAccounts",centered:!1,children:(0,r.tZ)(y.zd.ItemList,{id:"enterpriseAccounts",children:t.map(e=>(0,r.tZ)(Q,{account:e},e.id))})}):null},Q=e=>{var t,i,l;let{account:o}=e,a=o.emailAddress,n=null==o||null==(t=o.enterpriseConnection)?void 0:t.name,s=null==(l=o.verification)||null==(i=l.error)?void 0:i.longMessage;return(0,r.BX)(y.zd.Item,{id:"enterpriseAccounts",sx:e=>({gap:e.space.$2,justifyContent:"start"}),children:[(0,r.tZ)(G,{account:o}),(0,r.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,r.BX)(d.Flex,{gap:1,center:!0,children:[(0,r.tZ)(d.Text,{truncate:!0,colorScheme:"body",children:n}),(0,r.tZ)(d.Text,{truncate:!0,as:"span",colorScheme:"secondary",children:a?"• ".concat(a):""}),s&&(0,r.tZ)(d.Badge,{colorScheme:"danger",localizationKey:(0,d.localizationKeys)("badge__requiresAction")})]})})]},o.id)},G=e=>{var t;let{account:i}=e,{provider:l,enterpriseConnection:o}=i,a=l.replace(/(oauth_|saml_)/,"").trim(),n=null!=(t=null==o?void 0:o.name)?t:a,s={elementDescriptor:[d.descriptors.providerIcon],alt:n,sx:e=>({width:e.sizes.$4}),elementId:d.descriptors.enterpriseButtonsProviderIcon.setId(i.provider)};return(null==o?void 0:o.logoPublicUrl)?(0,r.tZ)(d.Image,{...s,src:o.logoPublicUrl}):(0,r.tZ)(z.e_,{id:a,value:n,"aria-label":"".concat(n,"'s icon"),elementDescriptor:[d.descriptors.providerIcon,d.descriptors.providerInitialIcon],elementId:d.descriptors.providerInitialIcon.setId(a)})};var J=i(98690),ee=i(70431),et=i(19460),ei=i(68487),er=i(36788),el=i(10207);let eo=(0,o.withCardStateProvider)(e=>{let{phoneId:t,onSuccess:i,onReset:o}=e,{user:a}=(0,f.aF)(),n=l.useRef(null==a?void 0:a.phoneNumbers.find(e=>e.id===t)),s=(0,z.a2)({defaultStep:+!!n.current});return(0,r.BX)(z.en,{...s.props,children:[(0,r.tZ)(ea,{resourceRef:n,title:(0,d.localizationKeys)("userProfile.phoneNumberPage.title"),onSuccess:s.nextStep,onReset:o}),(0,r.tZ)(en,{resourceRef:n,title:(0,d.localizationKeys)("userProfile.phoneNumberPage.verifyTitle"),onSuccess:i,onReset:o})]})}),ea=e=>{var t;let{title:i,onSuccess:l,onReset:a,onUseExistingNumberClick:n,resourceRef:s}=e,c=(0,o.useCardState)(),{user:u}=(0,f.aF)(),h=(0,f.WZ)((e,t)=>e.createPhoneNumber(t)),m=(0,er.Yp)("phoneNumber","",{type:"tel",label:(0,d.localizationKeys)("formFieldLabel__phoneNumber"),isRequired:!0}),p=m.value.length>1&&(null==u?void 0:u.username)!==m.value,v=!!(null==u||null==(t=u.phoneNumbers)?void 0:t.length)&&n,g=async e=>{if(e.preventDefault(),u)return h(u,{phoneNumber:m.value}).then(e=>{s.current=e,l()}).catch(e=>(0,Z.S3)(e,[m],c.setError))};return(0,r.tZ)(ei.Y,{headerTitle:i,gap:1,children:(0,r.BX)(ee.l.Root,{gap:4,onSubmit:g,children:[(0,r.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.phoneNumberPage.infoText"),colorScheme:"secondary"}),(0,r.tZ)(ee.l.ControlRow,{elementId:m.id,children:(0,r.tZ)(ee.l.PhoneInput,{...m.props,autoFocus:!0})}),(0,r.BX)(d.Flex,{justify:v?"between":"end",children:[v&&(0,r.tZ)(d.Button,{variant:"ghost",localizationKey:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.backButton"),onClick:n}),(0,r.tZ)(et.A,{submitLabel:(0,d.localizationKeys)("userProfile.formButtonPrimary__add"),isDisabled:!p,onReset:a})]})]})})},en=e=>{var t,i,l;let{title:o,onSuccess:a,resourceRef:n,onReset:s}=e;return(0,r.tZ)(ei.Y,{headerTitle:o,headerSubtitle:(0,d.localizationKeys)("userProfile.phoneNumberPage.verifySubtitle",{identifier:(null==(t=n.current)?void 0:t.phoneNumber)||""}),children:(0,r.tZ)(el.H,{nextStep:a,identification:n.current,identifier:null==(i=n.current)?void 0:i.phoneNumber,prepareVerification:null==(l=n.current)?void 0:l.prepareVerification,onReset:s})})},es=e=>{let{close:t}=(0,C.XC)();return(0,r.tZ)(w,{onSuccess:t,onReset:t,...e})},ec=e=>{let{close:t}=(0,C.XC)();return(0,r.tZ)(eo,{onSuccess:t,onReset:t,...e})},ed=e=>{var t;let{shouldAllowCreation:i=!0}=e,{user:o}=(0,f.aF)(),a=!!(null==o||null==(t=o.phoneNumbers)?void 0:t.length);return i||a?(0,r.tZ)(y.zd.Root,{centered:!1,title:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.title"),id:"phoneNumbers",children:(0,r.tZ)(S.a.Root,{children:(0,r.BX)(y.zd.ItemList,{id:"phoneNumbers",children:[M(null==o?void 0:o.phoneNumbers,null==o?void 0:o.primaryPhoneNumberId).map(e=>{let t=e.id;return(0,r.BX)(l.Fragment,{children:[(0,r.BX)(y.zd.Item,{id:"phoneNumbers",children:[(0,r.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,r.BX)(d.Flex,{gap:2,center:!0,children:[(0,r.tZ)(d.Text,{sx:e=>({color:e.colors.$colorForeground}),children:(0,J.L_)(e.phoneNumber)}),(null==o?void 0:o.primaryPhoneNumberId)===t&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__primary")}),"verified"!==e.verification.status&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__unverified")})]})}),(0,r.tZ)(eu,{phone:e})]}),(0,r.tZ)(S.a.Open,{value:"remove-".concat(t),children:(0,r.tZ)(S.a.Card,{variant:"destructive",children:(0,r.tZ)(es,{phoneId:t})})}),(0,r.tZ)(S.a.Open,{value:"verify-".concat(t),children:(0,r.tZ)(S.a.Card,{children:(0,r.tZ)(ec,{phoneId:t})})})]},t)}),i&&(0,r.BX)(r.HY,{children:[(0,r.tZ)(S.a.Trigger,{value:"add",children:(0,r.tZ)(y.zd.ArrowButton,{id:"phoneNumbers",localizationKey:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.primaryButton")})}),(0,r.tZ)(S.a.Open,{value:"add",children:(0,r.tZ)(S.a.Card,{children:(0,r.tZ)(ec,{})})})]})]})})}):null},eu=e=>{let{phone:t}=e,i=(0,o.useCardState)(),{open:l}=(0,C.XC)(),{user:a}=(0,f.aF)(),n=t.id,s=(0,f.WZ)(e=>e.update({primaryPhoneNumberId:t.id}));if(!a)return null;let c=a.primaryPhoneNumberId===t.id,u="verified"===t.verification.status,h=[c&&!u?{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.detailsAction__primary"),onClick:()=>l("verify-".concat(n))}:null,!c&&u?{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.detailsAction__nonPrimary"),onClick:()=>s(a).catch(e=>(0,Z.S3)(e,[],i.setError))}:null,!c&&!u?{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.detailsAction__unverified"),onClick:()=>l("verify-".concat(n))}:null,{label:(0,d.localizationKeys)("userProfile.start.phoneNumbersSection.destructiveAction"),isDestructive:!0,onClick:()=>l("remove-".concat(n))}].filter(e=>null!==e);return(0,r.tZ)(P.a,{actions:h})};var eh=i(51217),em=i(36127);let ep=(0,o.withCardStateProvider)(e=>{var t;let{onSuccess:i,onReset:l}=e,{user:a}=(0,f.aF)(),n=(0,f.WZ)(e=>null==a?void 0:a.update({username:e})),{userSettings:s}=(0,c.useEnvironment)(),u=(0,o.useCardState)(),{t:h,locale:m}=(0,d.useLocalizations)(),{usernameSettings:p}=s,v=(0,er.Yp)("username",(null==a?void 0:a.username)||"",{type:"text",label:(0,d.localizationKeys)("formFieldLabel__username"),placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__username"),buildErrorMessage:e=>(0,em.f)(e,{t:h,locale:m,usernameSettings:p})});if(!a)return null;let g=null==(t=s.attributes.username)?void 0:t.required,y=(!g||v.value.length>0)&&a.username!==v.value,P=async()=>{try{await n(v.value),i()}catch(e){(0,Z.S3)(e,[v],u.setError)}};return(0,r.tZ)(ei.Y,{headerTitle:a.username?(0,d.localizationKeys)("userProfile.usernamePage.title__update"):(0,d.localizationKeys)("userProfile.usernamePage.title__set"),children:(0,r.BX)(ee.l.Root,{onSubmit:P,children:[(0,r.tZ)(ee.l.ControlRow,{elementId:v.id,children:(0,r.tZ)(ee.l.PlainInput,{...v.props,autoFocus:!0,isRequired:g})}),(0,r.tZ)(et.A,{isDisabled:!y,onReset:l})]})})}),ef=()=>{let{close:e}=(0,C.XC)();return(0,r.tZ)(ep,{onSuccess:e,onReset:e})},ev=()=>{let{user:e}=(0,f.aF)();return e?(0,r.tZ)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.usernameSection.title"),id:"username",sx:{alignItems:"center",[eh.mqu.md]:{alignItems:"flex-start"}},children:(0,r.BX)(S.a.Root,{children:[(0,r.tZ)(S.a.Closed,{value:"edit",children:(0,r.BX)(y.zd.Item,{id:"username",sx:{paddingLeft:e.username?void 0:"0"},children:[e.username&&(0,r.tZ)(d.Text,{truncate:!0,sx:e=>({color:e.colors.$colorForeground}),children:e.username}),(0,r.tZ)(S.a.Trigger,{value:"edit",children:(0,r.tZ)(y.zd.Button,{id:"username",localizationKey:e.username?(0,d.localizationKeys)("userProfile.start.usernameSection.primaryButton__updateUsername"):(0,d.localizationKeys)("userProfile.start.usernameSection.primaryButton__setUsername")})})]})}),(0,r.tZ)(S.a.Open,{value:"edit",children:(0,r.tZ)(S.a.Card,{children:(0,r.tZ)(ef,{})})})]})}):null};var eg=i(97295),ey=i(43300),eP=i(6654),eZ=i(5472);let eb=e=>{let{user:t,...i}=e;return(0,r.tZ)(eP.C,{...i,title:(0,h.u1)("userProfile.profilePage.imageFormTitle"),avatarPreview:(0,r.tZ)(eZ.Y,{size:e=>e.sizes.$12,...t})})},ez=(0,o.withCardStateProvider)(e=>{let{onSuccess:t,onReset:i}=e,l=(0,o.useCardState)(),{user:a}=(0,f.aF)();if(!a)return null;let{first_name:n,last_name:s}=(0,c.useEnvironment)().userSettings.attributes,u=null==n?void 0:n.enabled,h=null==s?void 0:s.enabled,m=a.firstName||"",p=a.lastName||"",v=(0,er.Yp)("firstName",a.firstName||"",{type:"text",label:(0,d.localizationKeys)("formFieldLabel__firstName"),placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__firstName"),isRequired:null==s?void 0:s.required}),g=(0,er.Yp)("lastName",a.lastName||"",{type:"text",label:(0,d.localizationKeys)("formFieldLabel__lastName"),placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__lastName"),isRequired:null==s?void 0:s.required}),y=u&&v.value!==m||h&&g.value!==p,P=u&&n.required||h&&s.required,z=P&&!!g.value&&!!v.value&&y,S=a.enterpriseAccounts.some(e=>e.active),C=async e=>(e.preventDefault(),(y?a.update({firstName:v.value,lastName:g.value}):Promise.resolve()).then(t).catch(e=>{(0,Z.S3)(e,[v,g],l.setError)}));return(0,r.BX)(ei.Y,{headerTitle:(0,d.localizationKeys)("userProfile.profilePage.title"),children:[S&&(0,r.tZ)(ey.e,{message:(0,d.localizationKeys)("userProfile.profilePage.readonly")}),(0,r.BX)(ee.l.Root,{onSubmit:C,sx:e=>({gap:e.space.$6}),children:[(0,r.tZ)(eb,{user:a,onAvatarChange:e=>a.setProfileImage({file:e}).then(()=>{l.setIdle()}).catch(e=>(0,Z.S3)(e,[],l.setError)),onAvatarRemove:(0,b.QO)(a.imageUrl)?null:()=>{a.setProfileImage({file:null}).then(()=>{l.setIdle()}).catch(e=>(0,Z.S3)(e,[],l.setError))}}),(u||h)&&(0,r.BX)(ee.l.ControlRow,{elementId:"name",children:[u&&(0,r.tZ)(ee.l.PlainInput,{...v.props,isDisabled:S,autoFocus:!0}),h&&(0,r.tZ)(ee.l.PlainInput,{...g.props,isDisabled:S,autoFocus:!u})]}),(0,r.tZ)(et.A,{isDisabled:P?!z:!y,onReset:i})]})]})}),eS=()=>{let{close:e}=(0,C.XC)();return(0,r.tZ)(ez,{onSuccess:e,onReset:e})},eC=()=>{let{user:e}=(0,f.aF)();if(!e)return null;let{username:t,primaryEmailAddress:i,primaryPhoneNumber:l,primaryWeb3Wallet:o,...a}=e;return(0,r.tZ)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.profileSection.title"),id:"profile",sx:{[eh.mqu.md]:{alignItems:"flex-start"}},children:(0,r.BX)(S.a.Root,{children:[(0,r.tZ)(S.a.Closed,{value:"edit",children:(0,r.BX)(y.zd.Item,{id:"profile",children:[(0,r.tZ)(eg.E,{user:a,size:"lg",mainIdentifierVariant:"subtitle",sx:e=>({color:e.colors.$colorForeground})}),(0,r.tZ)(S.a.Trigger,{value:"edit",children:(0,r.tZ)(y.zd.Button,{id:"profile",localizationKey:(0,d.localizationKeys)("userProfile.start.profileSection.primaryButton")})})]})}),(0,r.tZ)(S.a.Open,{value:"edit",children:(0,r.tZ)(S.a.Card,{children:(0,r.tZ)(eS,{})})})]})})};i(92037);var eK=i(35274);let e_=(0,o.withCardStateProvider)(e=>{let{onClick:t}=e,i=(0,o.useCardState)(),{user:l}=(0,f.aF)(),{strategies:a,strategyToDisplayData:n}=(0,K.vO)(),s=a.filter(e=>e.startsWith("web3")),c=null==l?void 0:l.verifiedWeb3Wallets.map(e=>e.verification.strategy),u=s.filter(e=>!c.includes(e)),h=(0,f.WZ)(e=>null==l?void 0:l.createWeb3Wallet({web3Wallet:e})),m=async e=>{let t=e.replace("web3_","").replace("_signature","");i.setError(void 0);try{i.setLoading(e);let r=await (0,eK.Ly)({provider:t});if(!l)throw Error("user is not defined");let o=await h(r),a=null==(o=await (null==o?void 0:o.prepareVerification({strategy:e})))?void 0:o.verification.message,n=await (0,eK.bQ)({identifier:r,nonce:a,provider:t});await (null==o?void 0:o.attemptVerification({signature:n})),i.setIdle()}catch(t){i.setIdle();let e=(0,Z.zQ)(t);e?i.setError(e.longMessage):(0,Z.S3)(t,[],i.setError)}};return 0===u.length?null:(0,r.BX)(r.HY,{children:[(0,r.tZ)(y.zd.ActionMenu,{id:"web3Wallets",triggerLocalizationKey:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.primaryButton"),onClick:t,children:u.map(e=>(0,r.tZ)(y.zd.ActionMenuItem,{id:n[e].id,onClick:()=>m(e),isLoading:i.loadingMetadata===e,isDisabled:i.isLoading,localizationKey:(0,d.localizationKeys)("userProfile.web3WalletPage.web3WalletButtonsBlockButton",{provider:n[e].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:(0,r.tZ)(d.Image,{elementDescriptor:d.descriptors.providerIcon,elementId:d.descriptors.providerIcon.setId(n[e].id),isLoading:i.loadingMetadata===e,isDisabled:i.isLoading,src:n[e].iconUrl,alt:"Connect ".concat(n[e].name),sx:e=>({width:e.sizes.$5})})},e))}),i.error&&(0,r.tZ)(d.Text,{colorScheme:"danger",sx:e=>({padding:e.sizes.$1x5,paddingLeft:e.sizes.$8x5}),children:i.error})]})}),eR=e=>{let{close:t}=(0,C.XC)();return(0,r.tZ)(I,{onSuccess:t,onReset:t,...e})},ex=(0,o.withCardStateProvider)(e=>{var t;let{shouldAllowCreation:i=!0}=e,{user:a}=(0,f.aF)(),n=(0,o.useCardState)(),{strategyToDisplayData:s}=(0,K.vO)(),c=!!(null==a||null==(t=a.web3Wallets)?void 0:t.length),[u,h]=(0,l.useState)(null);return i||c?(0,r.BX)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.title"),centered:!1,id:"web3Wallets",children:[(0,r.tZ)(v.Z.Alert,{children:n.error}),(0,r.BX)(S.a.Root,{value:u,onChange:h,children:[(0,r.tZ)(y.zd.ItemList,{id:"web3Wallets",children:M(null==a?void 0:a.web3Wallets,null==a?void 0:a.primaryWeb3WalletId).map(e=>{var t;let i=e.verification.strategy,o=e.id;return s[i]&&(0,r.BX)(l.Fragment,{children:[(0,r.BX)(y.zd.Item,{id:"web3Wallets",align:"start",children:[(0,r.BX)(d.Flex,{sx:e=>({alignItems:"center",gap:e.space.$2,width:"100%"}),children:[s[i].iconUrl&&(0,r.tZ)(d.Image,{src:s[i].iconUrl,alt:s[i].name,sx:e=>({width:e.sizes.$4})}),(0,r.tZ)(d.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,r.BX)(d.Flex,{gap:2,justify:"start",children:[(0,r.BX)(d.Text,{children:[s[i].name," (",(t=e.web3Wallet).length<=10?t:t.slice(0,6)+"..."+t.slice(-4),")"]}),(null==a?void 0:a.primaryWeb3WalletId)===o&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__primary")}),"verified"!==e.verification.status&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__unverified")})]})})]}),(0,r.tZ)(eB,{walletId:o})]},o),(0,r.tZ)(S.a.Open,{value:"remove-".concat(o),children:(0,r.tZ)(S.a.Card,{variant:"destructive",children:(0,r.tZ)(eR,{walletId:e.id})})})]},e.id)})}),i&&(0,r.tZ)(e_,{onClick:()=>h(null)})]})]}):null}),eB=e=>{let{walletId:t}=e,i=(0,o.useCardState)(),{open:l}=(0,C.XC)(),{user:a}=(0,f.aF)(),n=(null==a?void 0:a.primaryWeb3WalletId)===t,s=(0,f.WZ)(()=>null==a?void 0:a.update({primaryWeb3WalletId:t})),c=[!n?{label:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.detailsAction__nonPrimary"),onClick:()=>{s().catch(e=>(0,Z.S3)(e,[],i.setError))}}:null,{label:(0,d.localizationKeys)("userProfile.start.web3WalletsSection.destructiveAction"),isDestructive:!0,onClick:()=>l("remove-".concat(t))}].filter(e=>null!==e);return(0,r.tZ)(P.a,{actions:c})},ew=(0,o.withCardStateProvider)(()=>{var e,t,i,l;let{attributes:a,social:n,enterpriseSSO:s}=(0,c.useEnvironment)().userSettings,u=(0,o.useCardState)(),{user:h}=(0,f.aF)(),m=null==(e=a.username)?void 0:e.enabled,p=null==(t=a.email_address)?void 0:t.enabled,y=null==(i=a.phone_number)?void 0:i.enabled,P=n&&Object.values(n).filter(e=>e.enabled).length>0,Z=h&&s.enabled,b=null==(l=a.web3_wallet)?void 0:l.enabled,z=!Z||!h.enterpriseAccounts.some(e=>{var t;return e.active&&(null==(t=e.enterpriseConnection)?void 0:t.disableAdditionalIdentifications)});return(0,r.tZ)(d.Col,{elementDescriptor:d.descriptors.page,sx:e=>({gap:e.space.$8,color:e.colors.$colorForeground}),children:(0,r.BX)(d.Col,{elementDescriptor:d.descriptors.profilePage,elementId:d.descriptors.profilePage.setId("account"),children:[(0,r.tZ)(g.h.Root,{children:(0,r.tZ)(g.h.Title,{localizationKey:(0,d.localizationKeys)("userProfile.start.headerTitle__account"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,r.tZ)(v.Z.Alert,{children:u.error}),(0,r.tZ)(eC,{}),m&&(0,r.tZ)(ev,{}),p&&(0,r.tZ)(j,{shouldAllowCreation:z}),y&&(0,r.tZ)(ed,{shouldAllowCreation:z}),P&&(0,r.tZ)(E,{shouldAllowCreation:z}),Z&&(0,r.tZ)(H,{}),b&&(0,r.tZ)(ex,{shouldAllowCreation:z})]})})});i(38062);var ek=i(58104),eI=i(53997),eA=i(96519);let eT=()=>{let e,{user:t}=(0,f.aF)(),{session:i}=(0,f.kP)(),{data:l,isLoading:o}=(0,K.ib)(null==t?void 0:t.getSessions,"user-sessions");return(0,r.tZ)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.activeDevicesSection.title"),centered:!1,id:"activeDevices",children:(0,r.tZ)(y.zd.ItemList,{id:"activeDevices",disableAnimation:!0,children:o?(0,r.tZ)(ek.m,{}):null==l?void 0:l.sort((e=i.id,t=>t.id===e?-1:1)).map(e=>eX(e.status)?(0,r.tZ)(eL,{session:e},e.id):null)})})},eX=e=>["active","pending"].includes(e),eL=e=>{var t;let{session:i}=e,l=(null==(t=(0,f.kP)().session)?void 0:t.id)===i.id,o=(0,K._m)(),a=(0,f.WZ)(i.revoke.bind(i)),n=async()=>{if(!l&&i)return o.setLoading(),a().catch(e=>(0,Z.S3)(e,[],o.setError)).finally(()=>o.setIdle())};return(0,r.tZ)(y.zd.Item,{id:"activeDevices",elementDescriptor:d.descriptors.activeDeviceListItem,elementId:l?d.descriptors.activeDeviceListItem.setId("current"):void 0,sx:{alignItems:"flex-start",opacity:o.isLoading?.5:1},isDisabled:o.isLoading,children:(0,r.BX)(r.HY,{children:[(0,r.tZ)(eF,{session:i}),!l&&(0,r.tZ)(eE,{revoke:n})]})})},eF=e=>{let{session:t}=(0,f.kP)(),i=(null==t?void 0:t.id)===e.session.id,l=!!(null==t?void 0:t.actor),o=!!e.session.actor,{city:a,country:n,browserName:s,browserVersion:c,deviceType:u,ipAddress:h,isMobile:m}=e.session.latestActivity,p="".concat(s||""," ").concat(c||"").trim()||"Web browser",v=[a||"",n||""].filter(Boolean).join(", ").trim()||null,{t:g}=(0,d.useLocalizations)();return(0,r.BX)(d.Flex,{elementDescriptor:d.descriptors.activeDevice,elementId:i?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,r.tZ)(d.Flex,{sx:e=>({[eh.mqu.sm]:{padding:"0"},borderRadius:e.radii.$md}),children:(0,r.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,r.BX)(d.Col,{align:"start",gap:1,children:[(0,r.BX)(d.Flex,{center:!0,gap:2,children:[(0,r.tZ)(d.Text,{children:u||(m?"Mobile device":"Desktop device")}),i&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__thisDevice"),colorScheme:l?"danger":"primary"}),l&&!o&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__userDevice")}),!i&&o&&(0,r.tZ)(d.Badge,{localizationKey:(0,d.localizationKeys)("badge__otherImpersonatorDevice"),colorScheme:"danger"})]}),(0,r.tZ)(d.Text,{colorScheme:"secondary",children:p}),(0,r.BX)(d.Text,{colorScheme:"secondary",children:[h," (",v,")"]}),(0,r.tZ)(d.Text,{colorScheme:"secondary",children:g((0,eI.Q)(e.session.lastActiveAt))})]})]})},eE=e=>{let{revoke:t}=e,i=[{label:(0,d.localizationKeys)("userProfile.start.activeDevicesSection.destructiveAction"),isDestructive:!0,onClick:t}].filter(e=>null!==e);return(0,r.tZ)(P.a,{actions:i})};var eD=i(54264);let eO=(0,o.withCardStateProvider)(e=>{let{onReset:t}=e,i=(0,o.useCardState)(),{afterSignOutUrl:l,afterMultiSessionSingleSignOutUrl:a}=(0,c.useSignOutContext)(),{user:n}=(0,f.aF)(),{t:s}=(0,d.useLocalizations)(),{otherSessions:u}=(0,eD.j)({user:n}),{setActive:h}=(0,f.cL)(),m=(0,f.WZ)(()=>null==n?void 0:n.delete()),p=(0,er.Yp)("deleteConfirmation","",{type:"text",label:(0,d.localizationKeys)("userProfile.deletePage.actionDescription"),isRequired:!0,placeholder:(0,d.localizationKeys)("formFieldInputPlaceholder__confirmDeletionUserAccount")}),v=p.value===(s((0,d.localizationKeys)("formFieldInputPlaceholder__confirmDeletionUserAccount"))||"Delete account"),g=async()=>{if(v)try{await m();let e=0===u.length?l:a;return await h({session:null,redirectUrl:e})}catch(e){(0,Z.S3)(e,[],i.setError)}};return(0,r.tZ)(ei.Y,{headerTitle:(0,d.localizationKeys)("userProfile.deletePage.title"),sx:e=>({gap:e.space.$0x5}),children:(0,r.BX)(ee.l.Root,{onSubmit:g,children:[(0,r.BX)(d.Col,{gap:1,children:[(0,r.tZ)(d.Text,{colorScheme:"secondary",localizationKey:(0,d.localizationKeys)("userProfile.deletePage.messageLine1")}),(0,r.tZ)(d.Text,{colorScheme:"danger",localizationKey:(0,d.localizationKeys)("userProfile.deletePage.messageLine2")})]}),(0,r.tZ)(ee.l.ControlRow,{elementId:p.id,children:(0,r.tZ)(ee.l.PlainInput,{...p.props,ignorePasswordManager:!0})}),(0,r.tZ)(et.A,{submitLabel:(0,d.localizationKeys)("userProfile.deletePage.confirm"),colorScheme:"danger",isDisabled:!v,onReset:t})]})})}),e$=()=>{let{close:e}=(0,C.XC)();return(0,r.tZ)(eO,{onSuccess:e,onReset:e})},eN=()=>(0,r.tZ)(y.zd.Root,{title:(0,d.localizationKeys)("userProfile.start.dangerSection.title"),id:"danger",sx:{alignItems:"center",[eh.mqu.md]:{alignItems:"flex-start"}},children:(0,r.BX)(S.a.Root,{children:[(0,r.tZ)(S.a.Closed,{value:"delete",children:(0,r.tZ)(y.zd.Item,{id:"danger",sx:e=>({paddingLeft:e.space.$1}),children:(0,r.tZ)(S.a.Trigger,{value:"delete",children:(0,r.tZ)(y.zd.Button,{id:"danger",variant:"ghost",colorScheme:"danger",localizationKey:(0,d.localizationKeys)("userProfile.start.dangerSection.deleteAccountButton")})})})}),(0,r.tZ)(S.a.Open,{value:"delete",children:(0,r.tZ)(S.a.Card,{variant:"destructive",children:(0,r.tZ)(e$,{})})})]})});var eW=i(5994),eM=i(73531);i(91634),i(98383),i(45261),i(70957),i(24551),i(22349);var eU=i(95878);let eY=e=>{let{code:t}=e;return(0,r.tZ)(d.Flex,{center:!0,sx:e=>({padding:"".concat(e.space.$1," ").concat(e.space.$4)}),children:(0,r.tZ)(d.Text,{children:t})})},eq=e=>{let{subtitle:t,backupCodes:i}=e,{applicationName:l}=(0,c.useEnvironment)().displayConfig,{user:o}=(0,f.aF)(),{print:a,printableProps:n}=(0,z.Qz)(),{onCopy:s,hasCopied:u}=(0,K.VP)((null==i?void 0:i.join(","))||"");if(!o)return null;let h=(0,eU.xC)(o);return i?(0,r.BX)(r.HY,{children:[(0,r.BX)(d.Col,{gap:1,children:[(0,r.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.title__codelist"),variant:"subtitle"}),(0,r.tZ)(d.Text,{localizationKey:t,variant:"caption",colorScheme:"secondary"})]}),(0,r.BX)(d.Box,{sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg}),children:[(0,r.tZ)(d.Grid,{gap:2,sx:e=>({gridTemplateColumns:"repeat(2, minmax(".concat(e.sizes.$12,", 1fr))"),padding:"".concat(e.space.$4," ").concat(e.space.$6)}),children:i.map((e,t)=>(0,r.tZ)(eY,{code:e},t))}),(0,r.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,r.tZ)(d.Button,{variant:"ghost",sx:e=>({width:"100%",padding:"".concat(e.space.$2," 0"),borderRadius:0}),onClick:()=>{let e=document.createElement("a"),t=new Blob([function(e,t,i){let r=null==e?void 0:e.join("\n");return"These are your backup codes for ".concat(t," account ").concat(i,".\nStore them securely and keep them secret. Each code can only be used once.\n\n").concat(r)}(i,l,h)],{type:"text/plain"});e.href=URL.createObjectURL(t),e.download="".concat(l,"_backup_codes.txt"),document.body.appendChild(e),e.click()},children:(0,r.tZ)(d.Icon,{icon:eA.UW})}),(0,r.tZ)(d.Button,{variant:"ghost",sx:e=>({width:"100%",padding:"".concat(e.space.$2," 0"),borderRadius:0}),onClick:a,children:(0,r.tZ)(d.Icon,{icon:eA.Kh})}),(0,r.tZ)(d.Button,{variant:"ghost",onClick:s,sx:e=>({width:"100%",padding:"".concat(e.space.$2," 0"),borderRadius:0}),children:(0,r.tZ)(d.Icon,{icon:u?eA.Jr:eA.CK})})]})]}),(0,r.BX)(z.o4,{...n,children:[(0,r.BX)(d.Heading,{children:["Your backup codes for ",l," account ",h,":"]}),(0,r.tZ)(d.Col,{gap:2,children:i.map((e,t)=>(0,r.tZ)(eY,{code:e},t))})]})]}):null},ej=(0,o.withCardStateProvider)(e=>{let{onSuccess:t,onReset:i}=e,{user:a}=(0,f.aF)(),n=(0,o.useCardState)(),s=(0,f.WZ)(()=>null==a?void 0:a.createBackupCode()),[c,u]=l.useState(void 0);return(l.useEffect(()=>{!c&&a&&s().then(e=>u(e)).catch(e=>{if((0,eM.mh)(e))return i();(0,Z.S3)(e,[],n.setError)})},[]),n.error)?(0,r.tZ)(ei.Y,{headerTitle:(0,d.localizationKeys)("userProfile.backupCodePage.title")}):(0,r.tZ)(ei.Y,{headerTitle:(0,d.localizationKeys)("userProfile.backupCodePage.title"),children:c?(0,r.BX)(r.HY,{children:[(0,r.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.successMessage")}),(0,r.tZ)(eq,{subtitle:(0,d.localizationKeys)("userProfile.backupCodePage.subtitle__codelist"),backupCodes:c.codes}),(0,r.tZ)(et.K,{children:(0,r.tZ)(d.Button,{autoFocus:!0,onClick:t,localizationKey:(0,d.localizationKeys)("userProfile.formButtonPrimary__finish"),elementDescriptor:d.descriptors.formButtonPrimary})})]}):(0,r.tZ)(ek.m,{})})}),eV=(0,o.withCardStateProvider)(e=>{let{onSuccess:t,onReset:i}=e,l=(0,z.a2)();return(0,r.BX)(z.en,{...l.props,children:[(0,r.tZ)(eH,{onContinue:l.nextStep}),(0,r.tZ)(ej,{onSuccess:t,onReset:i})]})}),eH=e=>{let{onContinue:t}=e,{close:i}=(0,C.XC)();return(0,r.BX)(ei.Y,{headerTitle:(0,d.localizationKeys)("userProfile.backupCodePage.title"),children:[(0,r.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.infoText1")}),(0,r.tZ)(d.Text,{localizationKey:(0,d.localizationKeys)("userProfile.backupCodePage.infoText2")}),(0,r.BX)(et.K,{sx:{marginTop:0},children:[(0,r.tZ)(d.Button,{textVariant:"buttonSmall",onClick:t,localizationKey:(0,d.localizationKeys)("userProfile.formButtonPrimary__finish"),elementDescriptor:d.descriptors.formButtonPrimary}),(0,r.tZ)(d.Button,{variant:"ghost",onClick:i,localizationKey:(0,d.localizationKeys)("userProfile.formButtonReset"),elementDescriptor:d.descriptors.formButtonReset})]})]})};var eQ=i(53412),eG=i(67263);let eJ=(0,o.withCardStateProvider)(e=>{var t,i,o,a;let{onReset:n,onSuccess:s}=e,u=l.useRef(),h=(0,z.a2)({defaultStep:2}),m=null==(t=(0,c.useEnvironment)().userSettings.attributes.backup_code)?void 0:t.enabled;return(0,r.BX)(z.en,{...h.props,children:[(0,r.tZ)(ea,{title:(0,d.localizationKeys)("userProfile.phoneNumberPage.title"),resourceRef:u,onSuccess:h.nextStep,onUseExistingNumberClick:()=>h.goToStep(2),onReset:n}),(0,r.tZ)(e1,{title:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.title"),resourceRef:u,onSuccess:()=>m?h.goToStep(3):s(),onReset:()=>h.goToStep(2)}),(0,r.tZ)(e2,{onSuccess:m?h.nextStep:s,onReset:n,onAddPhoneClick:()=>h.goToStep(0),onUnverifiedPhoneClick:e=>{u.current=e,h.goToStep(1)},title:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.title"),resourceRef:u}),m&&(0,r.tZ)(eG.I,{title:(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successTitle"),text:(null==(i=u.current)?void 0:i.backupCodes)&&(null==(o=u.current)?void 0:o.backupCodes.length)>0?[(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successMessage1"),(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successMessage2")]:[(0,d.localizationKeys)("userProfile.mfaPhoneCodePage.successMessage1")],onFinish:n,contents:(0,r.tZ)(eq,{backupCodes:null==(a=u.current)?void 0:a.backupCodes})})]})}),e0=e=>{let{phone:t,onSuccess:i,onUnverifiedPhoneClick:l,resourceRef:a}=e,n=(0,o.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 l(t);n.setLoading(t.id);try{await s(),a.current=t,i()}catch(e){(0,Z.S3)(e,[],n.setError)}finally{n.setIdle()}};return(0,r.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=>{var t,i,l;let{title:a,onSuccess:n,resourceRef:s,onReset:c}=e,u=(0,o.useCardState)(),h=s.current,m=(0,f.WZ)(()=>null==h?void 0:h.setReservedForSecondFactor({reserved:!0})),p=async()=>{u.setLoading(null==h?void 0:h.id);try{await m(),s.current=h,n()}catch(e){(0,Z.S3)(e,[],u.setError)}finally{u.setIdle()}};return(0,r.tZ)(ei.Y,{headerTitle:a,headerSubtitle:(0,d.localizationKeys)("userProfile.phoneNumberPage.verifySubtitle",{identifier:(null==(t=s.current