@clerk/ui 1.0.0-snapshot.v20251218183643 → 1.0.0-snapshot.v20260105214115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/207_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  2. package/dist/217_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  3. package/dist/360_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  4. package/dist/444_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  5. package/dist/573_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  6. package/dist/970_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  7. package/dist/ClerkUi.js +2 -2
  8. package/dist/apiKeys_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  9. package/dist/blankcaptcha_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  10. package/dist/{checkout_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → checkout_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +1 -1
  11. package/dist/checkout_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  12. package/dist/components/Checkout/CheckoutPage.js +1 -1
  13. package/dist/components/Checkout/CheckoutPage.js.map +1 -1
  14. package/dist/components/Checkout/parts.js +1 -1
  15. package/dist/components/Checkout/parts.js.map +1 -1
  16. package/dist/components/OrganizationList/UserMembershipList.js +1 -1
  17. package/dist/components/OrganizationList/UserMembershipList.js.map +1 -1
  18. package/dist/components/OrganizationSwitcher/OrganizationSwitcherPopover.js +1 -1
  19. package/dist/components/OrganizationSwitcher/OrganizationSwitcherPopover.js.map +1 -1
  20. package/dist/components/OrganizationSwitcher/OrganizationSwitcherTrigger.js +1 -1
  21. package/dist/components/OrganizationSwitcher/OrganizationSwitcherTrigger.js.map +1 -1
  22. package/dist/components/OrganizationSwitcher/UserMembershipList.js +1 -1
  23. package/dist/components/OrganizationSwitcher/UserMembershipList.js.map +1 -1
  24. package/dist/components/SignIn/index.js +1 -1
  25. package/dist/components/SignIn/index.js.map +1 -1
  26. package/dist/components/SignUp/index.js +1 -1
  27. package/dist/components/SignUp/index.js.map +1 -1
  28. package/dist/components/UserProfile/Web3Form.js +32 -45
  29. package/dist/components/UserProfile/Web3Form.js.map +1 -1
  30. package/dist/components/UserProfile/Web3Section.js +6 -3
  31. package/dist/components/UserProfile/Web3Section.js.map +1 -1
  32. package/dist/copy-api-key-modal_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  33. package/dist/createorganization_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  34. package/dist/enableOrganizationsPrompt_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  35. package/dist/framework_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  36. package/dist/impersonationfab_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  37. package/dist/index.js +1 -1
  38. package/dist/internal/index.js +1 -1
  39. package/dist/keylessPrompt_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  40. package/dist/oauthConsent_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  41. package/dist/onetap_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  42. package/dist/op-api-keys-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  43. package/dist/op-billing-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  44. package/dist/op-plans-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  45. package/dist/organizationlist_ui_bd1c40_1.0.0-snapshot.v20260105214115.js +1 -0
  46. package/dist/organizationlist_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  47. package/dist/organizationprofile_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  48. package/dist/organizationswitcher_ui_bd1c40_1.0.0-snapshot.v20260105214115.js +1 -0
  49. package/dist/organizationswitcher_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  50. package/dist/payment-attempt-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  51. package/dist/planDetails_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  52. package/dist/prefetchorganizationlist_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  53. package/dist/pricingTable_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  54. package/dist/revoke-api-key-modal_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  55. package/dist/sessionTasks_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  56. package/dist/{signin_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → signin_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +1 -1
  57. package/dist/signin_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  58. package/dist/{signup_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → signup_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +1 -1
  59. package/dist/signup_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  60. package/dist/statement-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  61. package/dist/subscriptionDetails_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  62. package/dist/taskChooseOrganization_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  63. package/dist/taskResetPassword_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  64. package/dist/{ui-common_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → ui-common_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +7 -7
  65. package/dist/ui-common_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  66. package/dist/ui.browser.js +1 -1
  67. package/dist/ui.legacy.browser.js +1 -0
  68. package/dist/up-api-keys-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  69. package/dist/up-billing-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  70. package/dist/up-plans-page_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  71. package/dist/useravatar_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  72. package/dist/userbutton_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  73. package/dist/{userprofile_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → userprofile_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +2 -2
  74. package/dist/userprofile_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  75. package/dist/userverification_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  76. package/dist/utils/errorHandler.js +1 -7
  77. package/dist/utils/errorHandler.js.map +1 -1
  78. package/dist/{vendors_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → vendors_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +1 -1
  79. package/dist/vendors_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  80. package/dist/waitlist_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  81. package/dist/{web3-solana-wallet-buttons_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → web3-solana-wallet-buttons_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +3 -3
  82. package/dist/web3-solana-wallet-buttons_ui_dd6371_1.0.0-snapshot.v20260105214115.js +1 -0
  83. package/package.json +8 -5
  84. package/dist/organizationlist_ui_b31bc8_1.0.0-snapshot.v20251218183643.js +0 -1
  85. package/dist/organizationswitcher_ui_b31bc8_1.0.0-snapshot.v20251218183643.js +0 -1
  86. /package/dist/{207_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → 207_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  87. /package/dist/{217_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → 217_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  88. /package/dist/{360_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → 360_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  89. /package/dist/{444_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → 444_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  90. /package/dist/{573_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → 573_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  91. /package/dist/{970_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → 970_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  92. /package/dist/{apiKeys_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → apiKeys_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  93. /package/dist/{blankcaptcha_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → blankcaptcha_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  94. /package/dist/{copy-api-key-modal_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → copy-api-key-modal_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  95. /package/dist/{createorganization_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → createorganization_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  96. /package/dist/{enableOrganizationsPrompt_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → enableOrganizationsPrompt_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  97. /package/dist/{framework_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → framework_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  98. /package/dist/{impersonationfab_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → impersonationfab_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  99. /package/dist/{keylessPrompt_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → keylessPrompt_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  100. /package/dist/{oauthConsent_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → oauthConsent_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  101. /package/dist/{onetap_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → onetap_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  102. /package/dist/{op-api-keys-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → op-api-keys-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  103. /package/dist/{op-billing-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → op-billing-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  104. /package/dist/{op-plans-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → op-plans-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  105. /package/dist/{organizationprofile_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → organizationprofile_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  106. /package/dist/{payment-attempt-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → payment-attempt-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  107. /package/dist/{planDetails_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → planDetails_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  108. /package/dist/{prefetchorganizationlist_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → prefetchorganizationlist_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  109. /package/dist/{pricingTable_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → pricingTable_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  110. /package/dist/{revoke-api-key-modal_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → revoke-api-key-modal_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  111. /package/dist/{sessionTasks_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → sessionTasks_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  112. /package/dist/{statement-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → statement-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  113. /package/dist/{subscriptionDetails_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → subscriptionDetails_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  114. /package/dist/{taskChooseOrganization_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → taskChooseOrganization_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  115. /package/dist/{taskResetPassword_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → taskResetPassword_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  116. /package/dist/{up-api-keys-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → up-api-keys-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  117. /package/dist/{up-billing-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → up-billing-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  118. /package/dist/{up-plans-page_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → up-plans-page_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  119. /package/dist/{useravatar_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → useravatar_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  120. /package/dist/{userbutton_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → userbutton_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  121. /package/dist/{userverification_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → userverification_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
  122. /package/dist/{waitlist_ui_b31bc8_1.0.0-snapshot.v20251218183643.js → waitlist_ui_bd1c40_1.0.0-snapshot.v20260105214115.js} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["718"],{4484:function(e,r,t){t.r(r),t.d(r,{UserProfile:()=>r6,UserProfileModal:()=>r7});var i=t(4518),n=t(5074),l=t(1227),o=t(3264),a=t(5240),s=t(4607),c=t(2861),d=t(3269),u=t(9764),h=t(5396),m=t(7831),f=t(2265);let p=e=>{let{pages:r,apiKeysProps:t}=(0,a.B)(),n=r.routes.filter(e=>e.id!==l.j2.API_KEYS||!t?.hide);return(0,i.FD)(u.XM,{contentRef:e.contentRef,children:[(0,i.Y)(u.jq,{title:(0,c.G)("userProfile.navbar.title"),description:(0,c.G)("userProfile.navbar.description"),routes:n,contentRef:e.contentRef}),e.children]})};var g=t(540),Y=t(7697),v=t(1210),P=t(6088),b=t(6153),y=t(8272),S=t(8920),_=t(1421),D=t(4003),R=t(8080),G=t(4468),w=t(2660),C=t(3453),$=t(2513),F=t(2216),I=t(4964),x=t(6735);let k=e=>{let{strategy:r}=e,t=(0,d.f0)(),{user:n}=(0,v.Jd)(),{navigate:l}=(0,I.r)(),{strategyToDisplayData:o}=(0,F.k)(),{additionalOAuthScopes:s,componentName:u,mode:h}=(0,a.B)(),m="modal"===h,f=(0,v.Wp)(()=>{let e=r.replace("oauth_",""),t=m?(0,_.j)({url:window.location.href,componentName:u,socialProvider:e}):window.location.href,i=s?s[e]:[];return n?.createExternalAccount({strategy:r,redirectUrl:t,additionalScopes:i})}),p=o[r].iconUrl?(0,i.Y)(y._V,{isLoading:t.loadingMetadata===r,isDisabled:t.isLoading,elementDescriptor:S.$z.providerIcon,elementId:S.$z.providerIcon.setId(o[r].id),src:o[r].iconUrl,alt:`Connect ${o[r].name} account`,sx:e=>({width:e.sizes.$4})}):(0,i.Y)(w.T,{id:o[r].id,value:o[r].name,isLoading:t.loadingMetadata===r,isDisabled:t.isLoading});return(0,i.Y)(D.rd.ActionMenuItem,{id:o[r].id,onClick:()=>{if(n)return t.setLoading(r),f().then(e=>{e&&e.verification?.externalVerificationRedirectURL&&((0,x.y)(2e3).then(()=>t.setIdle(r)),l(e.verification.externalVerificationRedirectURL.href))}).catch(e=>{(0,G.H4)(e,[],t.setError),t.setIdle(r)})},isDisabled:t.isLoading,variant:"ghost",isLoading:t.loadingMetadata===r,focusRing:!1,closeAfterClick:!1,localizationKey:(0,c.G)("userProfile.connectedAccountPage.socialButtonsBlockButton",{provider:o[r].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:p},r)},A=({onClick:e})=>{let{user:r}=(0,v.Jd)(),{strategies:t}=(0,F.k)(),n=t.filter(e=>e.startsWith("oauth")),l=r?.verifiedExternalAccounts.map(e=>`oauth_${e.provider}`),o=n.filter(e=>!l.includes(e));return 0===o.length?null:(0,i.Y)(D.rd.ActionMenu,{triggerLocalizationKey:(0,c.G)("userProfile.start.connectedAccountsSection.primaryButton"),id:"connectedAccounts",onClick:e,children:o.map(e=>(0,i.Y)(k,{strategy:e},e))})};var z=t(8046);let T=e=>{let{onSuccess:r,onReset:t}=e,{user:l}=(0,v.Jd)(),{emailId:o}=e,a=l?.emailAddresses.find(e=>e.id===o),s=n.useRef(a?.emailAddress),d=a?.verification?.status==="verified"?(0,c.G)("userProfile.emailAddressPage.removeResource.messageLine2"):void 0;return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.emailAddressPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.emailAddressPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:d,successMessage:(0,c.G)("userProfile.emailAddressPage.removeResource.successMessage",{emailAddress:s.current}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:r,onReset:t}):null},E=e=>{let{phoneId:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=o?.phoneNumbers.find(e=>e.id===r),s=n.useRef(a?.phoneNumber),d=a?.verification?.status==="verified"?(0,c.G)("userProfile.phoneNumberPage.removeResource.messageLine2"):void 0;return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.phoneNumberPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.phoneNumberPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:d,successMessage:(0,c.G)("userProfile.phoneNumberPage.removeResource.successMessage",{phoneNumber:s.current}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:t,onReset:l}):null},L=e=>{let{accountId:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=o?.externalAccounts.find(e=>e.id===r),s=n.useRef(a?.provider),{providerToDisplayData:d}=(0,F.k)();return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.connectedAccountPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.connectedAccountPage.removeResource.messageLine1",{identifier:d[s.current]?.name||""}),messageLine2:(0,c.G)("userProfile.connectedAccountPage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.connectedAccountPage.removeResource.successMessage",{connectedAccount:d[s.current]?.name||""}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:t,onReset:l}):null},O=e=>{let{user:r}=(0,v.Jd)(),{walletId:t,onSuccess:l,onReset:o}=e,a=r?.web3Wallets.find(e=>e.id===t),s=n.useRef(a?.web3Wallet),d=a?.verification?.status==="verified"?(0,c.G)("userProfile.web3WalletPage.removeResource.messageLine2"):void 0;return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.web3WalletPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.web3WalletPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:d,successMessage:(0,c.G)("userProfile.web3WalletPage.removeResource.successMessage",{web3Wallet:s.current}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:l,onReset:o}):null},K=e=>{let{user:r}=(0,v.Jd)(),{phoneId:t,onSuccess:l,onReset:o}=e,a=r?.phoneNumbers.find(e=>e.id===t),s=n.useRef(a?.phoneNumber);return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.title"),messageLine1:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.messageLine1",{identifier:s.current}),messageLine2:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.successMessage",{mfaPhoneCode:s.current}),deleteResource:()=>Promise.resolve(a?.setReservedForSecondFactor({reserved:!1})),onSuccess:l,onReset:o}):null},B=e=>{let{onSuccess:r,onReset:t}=e,{user:n}=(0,v.Jd)();return n?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.mfaTOTPPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.mfaTOTPPage.removeResource.messageLine1"),messageLine2:(0,c.G)("userProfile.mfaTOTPPage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.mfaTOTPPage.removeResource.successMessage"),deleteResource:n.disableTOTP,onSuccess:r,onReset:t}):null},M=e=>{let{onSuccess:r,onReset:t,passkey:n}=e;return(0,i.Y)(z.P,{title:(0,c.G)("userProfile.passkeyScreen.removeResource.title"),messageLine1:(0,c.G)("userProfile.passkeyScreen.removeResource.messageLine1",{name:n.name||""}),deleteResource:n.delete,onSuccess:r,onReset:t})},W=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(L,{onSuccess:r,onReset:r,...e})},N=["external_account_missing_refresh_token","oauth_fetch_user_error","oauth_token_exchange_error","external_account_email_address_verification_required"],J=(0,d.dm)(({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)(),t=(0,d.f0)(),l=!!r?.externalAccounts?.length,[o,a]=(0,n.useState)(null);if(!r||!e&&!l)return null;let s=[...r.verifiedExternalAccounts,...r.unverifiedExternalAccounts.filter(e=>e.verification?.error)];return(0,i.FD)(D.rd.Root,{title:(0,c.G)("userProfile.start.connectedAccountsSection.title"),centered:!1,id:"connectedAccounts",children:[(0,i.Y)(P.Z.Alert,{children:t.error}),(0,i.FD)(C.r.Root,{value:o,onChange:a,children:[(0,i.Y)(D.rd.ItemList,{id:"connectedAccounts",children:s.map(e=>(0,i.Y)(q,{account:e},e.id))}),e&&(0,i.Y)(A,{onClick:()=>a(null)})]})]})}),q=({account:e})=>{let{additionalOAuthScopes:r,componentName:t,mode:l}=(0,a.B)(),{navigate:o}=(0,I.r)(),{user:s}=(0,v.Jd)(),u=(0,d.f0)(),h=e.id,m="modal"===l,f=m?(0,_.j)({url:window.location.href,componentName:t}):window.location.href,p=(0,v.Wp)(()=>s?.createExternalAccount({strategy:e.verification.strategy,redirectUrl:f,additionalScopes:b}));if(!s)return null;let{providerToDisplayData:g}=(0,F.k)(),Y=e.username||e.emailAddress,P=e.verification?.error?.longMessage,b=function(e,r){if(!r)return[];let t=r[e.provider]||[],i=e.approvedScopes.split(" ");return 0===t.filter(e=>!i.includes(e)).length?[]:t}(e,r),R=b.length>0&&""!=e.approvedScopes,$=N.includes(e.verification?.error?.code||"")||R,x=$?(0,c.G)("userProfile.start.connectedAccountsSection.subtitle__disconnected"):P,k=async()=>{let r=m?(0,_.j)({url:window.location.href,componentName:t}):window.location.href;try{let t;(t=R?await e.reauthorize({additionalScopes:b,redirectUrl:r}):await p())&&await o(t.verification.externalVerificationRedirectURL?.href||"")}catch(e){(0,G.H4)(e,[],u.setError)}};return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"connectedAccounts",children:[(0,i.FD)(y.so,{sx:e=>({overflow:"hidden",gap:e.space.$2}),children:[(0,i.Y)(()=>g[e.provider].iconUrl?(0,i.Y)(y._V,{elementDescriptor:[S.$z.providerIcon],elementId:S.$z.socialButtonsProviderIcon.setId(e.provider),alt:g[e.provider].name,src:g[e.provider].iconUrl,sx:e=>({width:e.sizes.$4,flexShrink:0})}):(0,i.Y)(w.T,{id:e.provider,value:g[e.provider].name}),{}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:1,center:!0,children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),children:`${g[e.provider].name}`}),(0,i.Y)(y.EY,{truncate:!0,as:"span",colorScheme:"secondary",children:Y?`• ${Y}`:""})]})})]}),(0,i.Y)(U,{account:e})]}),$&&(0,i.FD)(y.az,{sx:e=>({padding:`${e.sizes.$none} ${e.sizes.$none} ${e.sizes.$1x5} ${e.sizes.$8x5}`}),children:[(0,i.Y)(y.EY,{colorScheme:"secondary",sx:e=>({paddingRight:e.sizes.$1x5,display:"inline-block"}),localizationKey:x}),(0,i.Y)(y.$n,{sx:{display:"inline-block"},onClick:k,variant:"link",localizationKey:(0,c.G)("userProfile.start.connectedAccountsSection.actionLabel__connectionFailed")})]}),e.verification?.error?.code&&!$&&(0,i.Y)(y.EY,{colorScheme:"danger",sx:e=>({padding:`${e.sizes.$none} ${e.sizes.$1x5} ${e.sizes.$1x5} ${e.sizes.$8x5}`}),children:P}),(0,i.Y)(C.r.Open,{value:`remove-${h}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(W,{accountId:e.id})})})]},e.id)},U=({account:e})=>{let{open:r}=(0,$.D5)(),t=e.id,n=[{label:(0,c.G)("userProfile.start.connectedAccountsSection.destructiveActionTitle"),isDestructive:!0,onClick:()=>r(`remove-${t}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:n})},j=e=>e.defaultSecondFactor?-1:1;function H(e){let r=[];return Object.entries(e).forEach(([,e])=>{e.used_for_second_factor&&r.push(...e.second_factors)}),r}function V(e,r){let t=H(e);return r.totpEnabled&&(t=t.filter(e=>"totp"!==e)),(r.backupCodeEnabled||!r.twoFactorEnabled)&&(t=t.filter(e=>"backup_code"!==e)),t}function Z(e,r){if(!e)return[];let t=e.filter(e=>e.id===r),i=e.filter(e=>e.id!==r),n=i.filter(e=>e.verification?.status==="verified"),l=i.filter(e=>!!e.verification?.status&&e.verification?.status!=="verified"),o=i.filter(e=>!e.verification.status);return n.sort((e,r)=>e.id.localeCompare(r.id)),l.sort((e,r)=>e.verification?.expireAt&&r.verification?.expireAt?e.verification.expireAt.getTime()-r.verification.expireAt.getTime():0),[...t,...n,...l,...o]}var X=t(2336);let Q=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(T,{onSuccess:r,onReset:r,...e})},ee=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(X.v,{onSuccess:r,onReset:r,...e})},er=({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)();return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.emailAddressesSection.title"),centered:!1,id:"emailAddresses",children:(0,i.Y)(C.r.Root,{children:(0,i.FD)(D.rd.ItemList,{id:"emailAddresses",children:[Z(r?.emailAddresses,r?.primaryEmailAddressId).map(e=>{let t=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"emailAddresses",children:[(0,i.FD)(y.so,{sx:e=>({overflow:"hidden",gap:e.space.$1}),children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),truncate:!0,children:e.emailAddress}),r?.primaryEmailAddressId===t&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]}),(0,i.Y)(et,{email:e})]}),(0,i.Y)(C.r.Open,{value:`remove-${t}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(Q,{emailId:t})})}),(0,i.Y)(C.r.Open,{value:`verify-${t}`,children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ee,{emailId:t})})})]},e.emailAddress)}),e&&(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Trigger,{value:"add",children:(0,i.Y)(D.rd.ArrowButton,{id:"emailAddresses",localizationKey:(0,c.G)("userProfile.start.emailAddressesSection.primaryButton")})}),(0,i.Y)(C.r.Open,{value:"add",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ee,{})})})]})]})})})},et=({email:e})=>{let r=(0,d.f0)(),{user:t}=(0,v.Jd)(),{open:n}=(0,$.D5)(),l=e.id,o=t?.primaryEmailAddressId===l,a="verified"===e.verification.status,s=(0,v.Wp)(()=>t?.update({primaryEmailAddressId:l})),u=[o&&!a?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__primary"),onClick:()=>n(`verify-${l}`)}:null,!o&&a?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__nonPrimary"),onClick:()=>{s().catch(e=>(0,G.H4)(e,[],r.setError))}}:null,!o&&!a?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__unverified"),onClick:()=>n(`verify-${l}`)}:null,{label:(0,c.G)("userProfile.start.emailAddressesSection.destructiveAction"),isDestructive:!0,onClick:()=>n(`remove-${l}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:u})},ei=()=>{let{user:e}=(0,v.Jd)(),r=e?.enterpriseAccounts.filter(({enterpriseConnection:e})=>e?.active);return r?.length?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.enterpriseAccountsSection.title"),id:"enterpriseAccounts",centered:!1,children:(0,i.Y)(D.rd.ItemList,{id:"enterpriseAccounts",children:r.map(e=>(0,i.Y)(en,{account:e},e.id))})}):null},en=({account:e})=>{let r=e.emailAddress,t=e?.enterpriseConnection?.name,n=e.verification?.error?.longMessage;return(0,i.FD)(D.rd.Item,{id:"enterpriseAccounts",sx:e=>({gap:e.space.$2,justifyContent:"start"}),children:[(0,i.Y)(el,{account:e}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:1,center:!0,children:[(0,i.Y)(y.EY,{truncate:!0,colorScheme:"body",children:t}),(0,i.Y)(y.EY,{truncate:!0,as:"span",colorScheme:"secondary",children:r?`• ${r}`:""}),n&&(0,i.Y)(y.Ex,{colorScheme:"danger",localizationKey:(0,c.G)("badge__requiresAction")})]})})]},e.id)},el=({account:e})=>{let{provider:r,enterpriseConnection:t}=e,n=r.replace(/(oauth_|saml_)/,"").trim(),l=t?.name??n,o={elementDescriptor:[S.$z.providerIcon],alt:l,sx:e=>({width:e.sizes.$4}),elementId:S.$z.enterpriseButtonsProviderIcon.setId(e.provider)};return t?.logoPublicUrl?(0,i.Y)(y._V,{...o,src:t.logoPublicUrl}):(0,i.Y)(w.T,{id:n,value:l,"aria-label":`${l}'s icon`,elementDescriptor:[S.$z.providerIcon,S.$z.providerInitialIcon],elementId:S.$z.providerInitialIcon.setId(n)})};var eo=t(7651),ea=t(2454),es=t(1475),ec=t(3549),ed=t(8640),eu=t(6245),eh=t(1282);let em=(0,d.dm)(e=>{let{phoneId:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=n.useRef(o?.phoneNumbers.find(e=>e.id===r)),s=(0,eu.X)({defaultStep:+!!a.current});return(0,i.FD)(eu.s,{...s.props,children:[(0,i.Y)(ef,{resourceRef:a,title:(0,c.G)("userProfile.phoneNumberPage.title"),onSuccess:s.nextStep,onReset:l}),(0,i.Y)(ep,{resourceRef:a,title:(0,c.G)("userProfile.phoneNumberPage.verifyTitle"),onSuccess:t,onReset:l})]})}),ef=e=>{let{title:r,onSuccess:t,onReset:n,onUseExistingNumberClick:l,resourceRef:o}=e,a=(0,d.f0)(),{user:s}=(0,v.Jd)(),u=(0,v.Wp)((e,r)=>e.createPhoneNumber(r)),h=(0,ed.tJ)("phoneNumber","",{type:"tel",label:(0,c.G)("formFieldLabel__phoneNumber"),isRequired:!0}),m=h.value.length>1&&s?.username!==h.value,f=!!s?.phoneNumbers?.length&&l,p=async e=>{if(e.preventDefault(),s)return u(s,{phoneNumber:h.value}).then(e=>{o.current=e,t()}).catch(e=>(0,G.H4)(e,[h],a.setError))};return(0,i.Y)(ec.M,{headerTitle:r,gap:1,children:(0,i.FD)(ea.l.Root,{gap:4,onSubmit:p,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.phoneNumberPage.infoText"),colorScheme:"secondary"}),(0,i.Y)(ea.l.ControlRow,{elementId:h.id,children:(0,i.Y)(ea.l.PhoneInput,{...h.props,autoFocus:!0})}),(0,i.FD)(y.so,{justify:f?"between":"end",children:[f&&(0,i.Y)(y.$n,{variant:"ghost",localizationKey:(0,c.G)("userProfile.mfaPhoneCodePage.backButton"),onClick:l}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.formButtonPrimary__add"),isDisabled:!m,onReset:n})]})]})})},ep=e=>{let{title:r,onSuccess:t,resourceRef:n,onReset:l}=e;return(0,i.Y)(ec.M,{headerTitle:r,headerSubtitle:(0,c.G)("userProfile.phoneNumberPage.verifySubtitle",{identifier:n.current?.phoneNumber||""}),children:(0,i.Y)(eh.j,{nextStep:t,identification:n.current,identifier:n.current?.phoneNumber,prepareVerification:n.current?.prepareVerification,onReset:l})})},eg=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(E,{onSuccess:r,onReset:r,...e})},eY=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(em,{onSuccess:r,onReset:r,...e})},ev=({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)(),t=!!r?.phoneNumbers?.length;return e||t?(0,i.Y)(D.rd.Root,{centered:!1,title:(0,c.G)("userProfile.start.phoneNumbersSection.title"),id:"phoneNumbers",children:(0,i.Y)(C.r.Root,{children:(0,i.FD)(D.rd.ItemList,{id:"phoneNumbers",children:[Z(r?.phoneNumbers,r?.primaryPhoneNumberId).map(e=>{let t=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"phoneNumbers",children:[(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:2,center:!0,children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),children:(0,eo.Om)(e.phoneNumber)}),r?.primaryPhoneNumberId===t&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]})}),(0,i.Y)(eP,{phone:e})]}),(0,i.Y)(C.r.Open,{value:`remove-${t}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(eg,{phoneId:t})})}),(0,i.Y)(C.r.Open,{value:`verify-${t}`,children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eY,{phoneId:t})})})]},t)}),e&&(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Trigger,{value:"add",children:(0,i.Y)(D.rd.ArrowButton,{id:"phoneNumbers",localizationKey:(0,c.G)("userProfile.start.phoneNumbersSection.primaryButton")})}),(0,i.Y)(C.r.Open,{value:"add",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eY,{})})})]})]})})}):null},eP=({phone:e})=>{let r=(0,d.f0)(),{open:t}=(0,$.D5)(),{user:n}=(0,v.Jd)(),l=e.id,o=(0,v.Wp)(r=>r.update({primaryPhoneNumberId:e.id}));if(!n)return null;let a=n.primaryPhoneNumberId===e.id,s="verified"===e.verification.status,u=[a&&!s?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__primary"),onClick:()=>t(`verify-${l}`)}:null,!a&&s?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__nonPrimary"),onClick:()=>o(n).catch(e=>(0,G.H4)(e,[],r.setError))}:null,!a&&!s?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__unverified"),onClick:()=>t(`verify-${l}`)}:null,{label:(0,c.G)("userProfile.start.phoneNumbersSection.destructiveAction"),isDestructive:!0,onClick:()=>t(`remove-${l}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:u})};var eb=t(7591),ey=t(4557),eS=t(78);let e_=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,{user:n}=(0,v.Jd)(),l=(0,v.Wp)(e=>n?.update({username:e})),{userSettings:o}=(0,Y.O)(),a=(0,d.f0)(),{t:s,locale:u}=(0,eS._)(),{usernameSettings:h}=o,m=(0,ed.tJ)("username",n?.username||"",{type:"text",label:(0,c.G)("formFieldLabel__username"),placeholder:(0,c.G)("formFieldInputPlaceholder__username"),buildErrorMessage:e=>(0,ey.Z)(e,{t:s,locale:u,usernameSettings:h})});if(!n)return null;let f=o.attributes.username?.required,p=(!f||m.value.length>0)&&n.username!==m.value,g=async()=>{try{await l(m.value),r()}catch(e){(0,G.H4)(e,[m],a.setError)}};return(0,i.Y)(ec.M,{headerTitle:n.username?(0,c.G)("userProfile.usernamePage.title__update"):(0,c.G)("userProfile.usernamePage.title__set"),children:(0,i.FD)(ea.l.Root,{onSubmit:g,children:[(0,i.Y)(ea.l.ControlRow,{elementId:m.id,children:(0,i.Y)(ea.l.PlainInput,{...m.props,autoFocus:!0,isRequired:f})}),(0,i.Y)(es.G,{isDisabled:!p,onReset:t})]})})}),eD=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(e_,{onSuccess:e,onReset:e})},eR=()=>{let{user:e}=(0,v.Jd)();return e?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.usernameSection.title"),id:"username",sx:{alignItems:"center",[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"username",sx:{paddingLeft:e.username?void 0:"0"},children:[e.username&&(0,i.Y)(y.EY,{truncate:!0,sx:e=>({color:e.colors.$colorForeground}),children:e.username}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"username",localizationKey:e.username?(0,c.G)("userProfile.start.usernameSection.primaryButton__updateUsername"):(0,c.G)("userProfile.start.usernameSection.primaryButton__setUsername")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eD,{})})})]})}):null};var eG=t(9345),ew=t(2421),eC=t(8225),e$=t(3817),eF=t(9538);let eI=e=>{let{user:r,...t}=e;return(0,i.Y)(e$.k,{...t,title:(0,c.G)("userProfile.profilePage.imageFormTitle"),avatarPreview:(0,i.Y)(eF.H,{size:e=>e.sizes.$12,...r})})},ex=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,n=(0,d.f0)(),{user:l}=(0,v.Jd)();if(!l)return null;let{first_name:o,last_name:a}=(0,Y.O)().userSettings.attributes,s=o?.enabled,u=a?.enabled,h=l.firstName||"",m=l.lastName||"",f=(0,ed.tJ)("firstName",l.firstName||"",{type:"text",label:(0,c.G)("formFieldLabel__firstName"),placeholder:(0,c.G)("formFieldInputPlaceholder__firstName"),isRequired:a?.required}),p=(0,ed.tJ)("lastName",l.lastName||"",{type:"text",label:(0,c.G)("formFieldLabel__lastName"),placeholder:(0,c.G)("formFieldInputPlaceholder__lastName"),isRequired:a?.required}),g=s&&f.value!==h||u&&p.value!==m,P=s&&o.required||u&&a.required,b=P&&!!p.value&&!!f.value&&g,y=l.enterpriseAccounts.some(e=>e.active),S=async e=>(e.preventDefault(),(g?l.update({firstName:f.value,lastName:p.value}):Promise.resolve()).then(r).catch(e=>{(0,G.H4)(e,[f,p],n.setError)}));return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.profilePage.title"),children:[y&&(0,i.Y)(ew.k,{message:(0,c.G)("userProfile.profilePage.readonly")}),(0,i.FD)(ea.l.Root,{onSubmit:S,sx:e=>({gap:e.space.$6}),children:[(0,i.Y)(eI,{user:l,onAvatarChange:e=>l.setProfileImage({file:e}).then(()=>{n.setIdle(),r?.()}).catch(e=>(0,G.H4)(e,[],n.setError)),onAvatarRemove:(0,eC.p)(l.imageUrl)?null:()=>{l.setProfileImage({file:null}).then(()=>{n.setIdle(),r?.()}).catch(e=>(0,G.H4)(e,[],n.setError))}}),(s||u)&&(0,i.FD)(ea.l.ControlRow,{elementId:"name",children:[s&&(0,i.Y)(ea.l.PlainInput,{...f.props,isDisabled:y,autoFocus:!0}),u&&(0,i.Y)(ea.l.PlainInput,{...p.props,isDisabled:y,autoFocus:!s})]}),(0,i.Y)(es.G,{isDisabled:P?!b:!g,onReset:t})]})]})}),ek=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(ex,{onSuccess:e,onReset:e})},eA=()=>{let{user:e}=(0,v.Jd)();if(!e)return null;let{username:r,primaryEmailAddress:t,primaryPhoneNumber:n,primaryWeb3Wallet:l,...o}=e;return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.profileSection.title"),id:"profile",sx:{[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"profile",children:[(0,i.Y)(eG.c,{user:o,size:"lg",mainIdentifierVariant:"subtitle",sx:e=>({color:e.colors.$colorForeground})}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"profile",localizationKey:(0,c.G)("userProfile.start.profileSection.primaryButton")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ek,{})})})]})})};var ez=t(6463),eT=t(3610);let eE=(0,n.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("188")]).then(t.bind(t,6464)).then(e=>({default:e.Web3SolanaWalletButtons}))),eL=({onConnect:e})=>{let r=(0,d.f0)(),{close:t}=(0,$.D5)(),l=async({walletName:i})=>{r.setLoading(i);try{await e({strategy:"web3_solana_signature",walletName:i}),r.setIdle(),t()}catch(e){if(r.setIdle(),e instanceof Error)(0,G.H4)(e,[],r.setError);else{let t=new eT.cR("An error occurred while generating the Solana signature.",{code:"web3_solana_signature_generation_failed",cause:e instanceof Error?e:void 0});(0,G.H4)(t,[],r.setError)}}};return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.start.web3WalletsSection.web3SelectSolanaWalletScreen.title"),headerSubtitle:(0,c.G)("userProfile.start.web3WalletsSection.web3SelectSolanaWalletScreen.subtitle"),children:(0,i.FD)(ea.l.Root,{children:[(0,i.Y)(n.Suspense,{fallback:(0,i.Y)(y.so,{direction:"row",align:"center",justify:"center",sx:e=>({height:"100%",minHeight:e.sizes.$32}),children:(0,i.Y)(y.y$,{size:"lg",colorScheme:"primary",elementDescriptor:S.$z.spinner})}),children:(0,i.Y)(eE,{web3AuthCallback:l})}),(0,i.Y)(es.c,{children:(0,i.Y)(y.$n,{type:"button",variant:"ghost",onClick:()=>{t()},localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})})]})})};var eO=t(5243);let eK=()=>{let e=(0,d.f0)(),{open:r}=(0,$.D5)(),{user:t}=(0,v.Jd)(),{strategies:n,strategyToDisplayData:l}=(0,F.k)(),o=(0,eO.R)(),a=n.filter(e=>e.startsWith("web3")),s=t?.verifiedWeb3Wallets?.map(e=>e.verification.strategy)??[],u=a.filter(e=>!s.includes(e)&&l[e]);if(0===u.length)return null;let h=(0,v.Wp)(e=>t?.createWeb3Wallet({web3Wallet:e})),m=async({strategy:i,walletName:n})=>{let l=(0,ez.U)(o);if("web3_solana_signature"===i&&!n)return void r("web3Wallets");let a=i.replace("web3_","").replace("_signature","");e.setError(void 0);try{e.setLoading(i);let r=await l.getWeb3Identifier({provider:a,walletName:n});if(!t)throw Error("user is not defined");let o=await h(r);o=await o?.prepareVerification({strategy:i});let s=o?.verification.message,c=await l.generateWeb3Signature({identifier:r,nonce:s,provider:a,walletName:n});await o?.attemptVerification({signature:c}),e.setIdle()}catch(t){e.setIdle();let r=(0,G.hG)(t);r?e.setError(r.longMessage):(0,G.H4)(t,[],e.setError)}};return(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Closed,{value:"web3Wallets",children:(0,i.Y)(D.rd.ActionMenu,{id:"web3Wallets",triggerLocalizationKey:(0,c.G)("userProfile.start.web3WalletsSection.primaryButton"),children:u.map(r=>(0,i.Y)(D.rd.ActionMenuItem,{id:l[r].id,onClick:()=>{m({strategy:r})},isLoading:e.loadingMetadata===r,isDisabled:e.isLoading,localizationKey:(0,c.G)("userProfile.web3WalletPage.web3WalletButtonsBlockButton",{provider:l[r].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:(0,i.Y)(y._V,{elementDescriptor:S.$z.providerIcon,elementId:S.$z.providerIcon.setId(l[r].id),isLoading:e.loadingMetadata===r,isDisabled:e.isLoading,src:l[r].iconUrl,alt:`Connect ${l[r].name}`,sx:e=>({width:e.sizes.$5})})},r))})}),(0,i.Y)(C.r.Open,{value:"web3Wallets",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eL,{onConnect:m})})}),e.error&&(0,i.Y)(y.EY,{colorScheme:"danger",sx:e=>({padding:e.sizes.$1x5,paddingLeft:e.sizes.$8x5}),children:e.error})]})},eB=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(O,{onSuccess:r,onReset:r,...e})},eM=(0,d.dm)(({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)(),t=(0,d.f0)(),{strategyToDisplayData:l}=(0,F.k)(),o=!!r?.web3Wallets?.length,[a,s]=(0,n.useState)(null);return e||o?(0,i.FD)(D.rd.Root,{title:(0,c.G)("userProfile.start.web3WalletsSection.title"),centered:!1,id:"web3Wallets",children:[(0,i.Y)(P.Z.Alert,{children:t.error}),(0,i.FD)(C.r.Root,{value:a,onChange:s,children:[(0,i.Y)(D.rd.ItemList,{id:"web3Wallets",children:Z(r?.web3Wallets,r?.primaryWeb3WalletId).map(e=>{var t;let o=e.verification.strategy,a=e.id;return l[o]&&(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"web3Wallets",align:"start",children:[(0,i.FD)(y.so,{sx:e=>({alignItems:"center",gap:e.space.$2,width:"100%"}),children:[l[o].iconUrl&&(0,i.Y)(y._V,{src:l[o].iconUrl,alt:l[o].name,sx:e=>({width:e.sizes.$4})}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:2,justify:"start",children:[(0,i.FD)(y.EY,{children:[l[o].name," (",(t=e.web3Wallet).length<=10?t:t.slice(0,6)+"..."+t.slice(-4),")"]}),r?.primaryWeb3WalletId===a&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]})})]}),(0,i.Y)(eW,{walletId:a})]},a),(0,i.Y)(C.r.Open,{value:`remove-${a}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(eB,{walletId:e.id})})})]},e.id)})}),e&&(0,i.Y)(eK,{})]})]}):null}),eW=({walletId:e})=>{let r=(0,d.f0)(),{open:t}=(0,$.D5)(),{user:n}=(0,v.Jd)(),l=n?.primaryWeb3WalletId===e,o=(0,v.Wp)(()=>n?.update({primaryWeb3WalletId:e})),a=[!l?{label:(0,c.G)("userProfile.start.web3WalletsSection.detailsAction__nonPrimary"),onClick:()=>{o().catch(e=>(0,G.H4)(e,[],r.setError))}}:null,{label:(0,c.G)("userProfile.start.web3WalletsSection.destructiveAction"),isDestructive:!0,onClick:()=>t(`remove-${e}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:a})},eN=(0,d.dm)(()=>{let{attributes:e,social:r,enterpriseSSO:t}=(0,Y.O)().userSettings,n=(0,d.f0)(),{user:l}=(0,v.Jd)(),{shouldAllowIdentificationCreation:o}=(0,a.B)(),s=e.username?.enabled,u=e.email_address?.enabled,h=e.phone_number?.enabled,m=r&&Object.values(r).filter(e=>e.enabled).length>0,f=l&&t.enabled,p=e.web3_wallet?.enabled;return(0,i.Y)(y.fv,{elementDescriptor:S.$z.page,sx:e=>({gap:e.space.$8,color:e.colors.$colorForeground}),children:(0,i.FD)(y.fv,{elementDescriptor:S.$z.profilePage,elementId:S.$z.profilePage.setId("account"),children:[(0,i.Y)(b.Y.Root,{children:(0,i.Y)(b.Y.Title,{localizationKey:(0,c.G)("userProfile.start.headerTitle__account"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,i.Y)(P.Z.Alert,{children:n.error}),(0,i.Y)(eA,{}),s&&(0,i.Y)(eR,{}),u&&(0,i.Y)(er,{shouldAllowCreation:o}),h&&(0,i.Y)(ev,{shouldAllowCreation:o}),m&&(0,i.Y)(J,{shouldAllowCreation:o}),f&&(0,i.Y)(ei,{}),p&&(0,i.Y)(eM,{shouldAllowCreation:o})]})})});var eJ=t(2611),eq=t(7806),eU=t(7896),ej=t(4901),eH=t(892),eV=t(8910);let eZ=()=>{let e,{user:r}=(0,v.Jd)(),{session:t}=(0,v.wV)(),{data:n,isLoading:l}=(0,eU.s)(r?.getSessions,"user-sessions");return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.activeDevicesSection.title"),centered:!1,id:"activeDevices",children:(0,i.Y)(D.rd.ItemList,{id:"activeDevices",disableAnimation:!0,children:l?(0,i.Y)(eJ.K,{}):n?.sort((e=t.id,r=>r.id===e?-1:1)).map(e=>eX(e.status)?(0,i.Y)(eQ,{session:e},e.id):null)})})},eX=e=>["active","pending"].includes(e),eQ=({session:e})=>{let r=(0,v.wV)().session?.id===e.id,t=(0,ej.m)(),n=(0,v.Wp)(e.revoke.bind(e)),l=async()=>{if(!r&&e)return t.setLoading(),n().catch(e=>(0,G.H4)(e,[],t.setError)).finally(()=>t.setIdle())};return(0,i.Y)(D.rd.Item,{id:"activeDevices",elementDescriptor:S.$z.activeDeviceListItem,elementId:r?S.$z.activeDeviceListItem.setId("current"):void 0,sx:{alignItems:"flex-start",opacity:t.isLoading?.5:1},isDisabled:t.isLoading,children:(0,i.FD)(i.FK,{children:[(0,i.Y)(e0,{session:e}),!r&&(0,i.Y)(e1,{revoke:l})]})})},e0=e=>{let{session:r}=(0,v.wV)(),t=r?.id===e.session.id,n=!!r?.actor,l=!!e.session.actor,{city:o,country:a,browserName:s,browserVersion:d,deviceType:u,ipAddress:h,isMobile:m}=e.session.latestActivity,f=`${s||""} ${d||""}`.trim()||"Web browser",p=[o||"",a||""].filter(Boolean).join(", ").trim()||null,{t:g}=(0,eS._)();return(0,i.FD)(y.so,{elementDescriptor:S.$z.activeDevice,elementId:t?S.$z.activeDevice.setId("current"):void 0,sx:e=>({width:"100%",overflow:"hidden",gap:e.space.$4,[eb.g.sm]:{gap:e.space.$2}}),children:[(0,i.Y)(y.so,{sx:e=>({[eb.g.sm]:{padding:"0"},borderRadius:e.radii.$md}),children:(0,i.Y)(y.In,{elementDescriptor:S.$z.activeDeviceIcon,elementId:S.$z.activeDeviceIcon.setId(m?"mobile":"desktop"),icon:m?eH.A:eV.A,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.FD)(y.fv,{align:"start",gap:1,children:[(0,i.FD)(y.so,{center:!0,gap:2,children:[(0,i.Y)(y.EY,{children:u||(m?"Mobile device":"Desktop device")}),t&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__thisDevice"),colorScheme:n?"danger":"primary"}),n&&!l&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__userDevice")}),!t&&l&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__otherImpersonatorDevice"),colorScheme:"danger"})]}),(0,i.Y)(y.EY,{colorScheme:"secondary",children:f}),(0,i.FD)(y.EY,{colorScheme:"secondary",children:[h," (",p,")"]}),(0,i.Y)(y.EY,{colorScheme:"secondary",children:g((0,eq.T)(e.session.lastActiveAt))})]})]})},e1=({revoke:e})=>{let r=[{label:(0,c.G)("userProfile.start.activeDevicesSection.destructiveAction"),isDestructive:!0,onClick:e}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})};var e2=t(9599),e5=t(8691);let e4=(0,d.dm)(e=>{let{onReset:r}=e,t=(0,d.f0)(),{afterSignOutUrl:n,afterMultiSessionSingleSignOutUrl:l}=(0,e2.g)(),{user:o}=(0,v.Jd)(),{t:a}=(0,eS._)(),{otherSessions:s}=(0,e5.z)({user:o}),{setActive:u}=(0,v.ho)(),h=(0,v.Wp)(()=>o?.delete()),m=(0,ed.tJ)("deleteConfirmation","",{type:"text",label:(0,c.G)("userProfile.deletePage.actionDescription"),isRequired:!0,placeholder:(0,c.G)("formFieldInputPlaceholder__confirmDeletionUserAccount")}),f=m.value===(a((0,c.G)("formFieldInputPlaceholder__confirmDeletionUserAccount"))||"Delete account"),p=async()=>{if(f)try{await h();let e=0===s.length?n:l;return await u({session:null,redirectUrl:e})}catch(e){(0,G.H4)(e,[],t.setError)}};return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.deletePage.title"),sx:e=>({gap:e.space.$0x5}),children:(0,i.FD)(ea.l.Root,{onSubmit:p,children:[(0,i.FD)(y.fv,{gap:1,children:[(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.deletePage.messageLine1")}),(0,i.Y)(y.EY,{colorScheme:"danger",localizationKey:(0,c.G)("userProfile.deletePage.messageLine2")})]}),(0,i.Y)(ea.l.ControlRow,{elementId:m.id,children:(0,i.Y)(ea.l.PlainInput,{...m.props,ignorePasswordManager:!0})}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.deletePage.confirm"),colorScheme:"danger",isDisabled:!f,onReset:r})]})})}),e3=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(e4,{onSuccess:e,onReset:e})},e6=()=>(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.dangerSection.title"),id:"danger",sx:{alignItems:"center",[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"delete",children:(0,i.Y)(D.rd.Item,{id:"danger",sx:e=>({paddingLeft:e.space.$1}),children:(0,i.Y)(C.r.Trigger,{value:"delete",children:(0,i.Y)(D.rd.Button,{id:"danger",variant:"ghost",colorScheme:"danger",localizationKey:(0,c.G)("userProfile.start.dangerSection.deleteAccountButton")})})})}),(0,i.Y)(C.r.Open,{value:"delete",children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(e3,{})})})]})});var e8=t(1323),e7=t(5079),e9=t(6103),re=t(2534),rr=t(8095),rt=t(9126),ri=t(7782),rn=t(1072),rl=t(5976),ro=t(2405),ra=t(2852);let rs=e=>{let{code:r}=e;return(0,i.Y)(y.so,{center:!0,sx:e=>({padding:`${e.space.$1} ${e.space.$4}`}),children:(0,i.Y)(y.EY,{children:r})})},rc=e=>{let{subtitle:r,backupCodes:t}=e,{applicationName:n}=(0,Y.O)().displayConfig,{user:l}=(0,v.Jd)(),{print:o,printableProps:a}=(0,rt.h)(),{onCopy:s,hasCopied:d}=(0,ri.i)(t?.join(",")||"");if(!l)return null;let u=(0,rr.Cm)(l);return t?(0,i.FD)(i.FK,{children:[(0,i.FD)(y.fv,{gap:1,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.title__codelist"),variant:"subtitle"}),(0,i.Y)(y.EY,{localizationKey:r,variant:"caption",colorScheme:"secondary"})]}),(0,i.FD)(y.az,{sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg}),children:[(0,i.Y)(y.xA,{gap:2,sx:e=>({gridTemplateColumns:`repeat(2, minmax(${e.sizes.$12}, 1fr))`,padding:`${e.space.$4} ${e.space.$6}`}),children:t.map((e,r)=>(0,i.Y)(rs,{code:e},r))}),(0,i.FD)(y.xA,{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.Y)(y.$n,{variant:"ghost",sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),onClick:()=>{var e,r,i;let l,o=document.createElement("a"),a=new Blob([(e=t,r=n,i=u,l=e?.join("\n"),`These are your backup codes for ${r} account ${i}.
1
+ "use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["718"],{4484:function(e,r,t){t.r(r),t.d(r,{UserProfile:()=>r8,UserProfileModal:()=>r9});var i=t(4518),n=t(5074),l=t(1227),o=t(3264),a=t(5240),s=t(4607),c=t(2861),d=t(3269),u=t(9764),h=t(5396),f=t(7831),m=t(2265);let p=e=>{let{pages:r,apiKeysProps:t}=(0,a.B)(),n=r.routes.filter(e=>e.id!==l.j2.API_KEYS||!t?.hide);return(0,i.FD)(u.XM,{contentRef:e.contentRef,children:[(0,i.Y)(u.jq,{title:(0,c.G)("userProfile.navbar.title"),description:(0,c.G)("userProfile.navbar.description"),routes:n,contentRef:e.contentRef}),e.children]})};var g=t(540),Y=t(7697),v=t(1210),P=t(6088),b=t(6153),y=t(8272),S=t(8920),_=t(1421),D=t(4003),R=t(8080),G=t(4468),w=t(2660),C=t(3453),$=t(2513),F=t(2216),I=t(4964),k=t(6735);let x=e=>{let{strategy:r}=e,t=(0,d.f0)(),{user:n}=(0,v.Jd)(),{navigate:l}=(0,I.r)(),{strategyToDisplayData:o}=(0,F.k)(),{additionalOAuthScopes:s,componentName:u,mode:h}=(0,a.B)(),f="modal"===h,m=(0,v.Wp)(()=>{let e=r.replace("oauth_",""),t=f?(0,_.j)({url:window.location.href,componentName:u,socialProvider:e}):window.location.href,i=s?s[e]:[];return n?.createExternalAccount({strategy:r,redirectUrl:t,additionalScopes:i})}),p=o[r].iconUrl?(0,i.Y)(y._V,{isLoading:t.loadingMetadata===r,isDisabled:t.isLoading,elementDescriptor:S.$z.providerIcon,elementId:S.$z.providerIcon.setId(o[r].id),src:o[r].iconUrl,alt:`Connect ${o[r].name} account`,sx:e=>({width:e.sizes.$4})}):(0,i.Y)(w.T,{id:o[r].id,value:o[r].name,isLoading:t.loadingMetadata===r,isDisabled:t.isLoading});return(0,i.Y)(D.rd.ActionMenuItem,{id:o[r].id,onClick:()=>{if(n)return t.setLoading(r),m().then(e=>{e&&e.verification?.externalVerificationRedirectURL&&((0,k.y)(2e3).then(()=>t.setIdle(r)),l(e.verification.externalVerificationRedirectURL.href))}).catch(e=>{(0,G.H4)(e,[],t.setError),t.setIdle(r)})},isDisabled:t.isLoading,variant:"ghost",isLoading:t.loadingMetadata===r,focusRing:!1,closeAfterClick:!1,localizationKey:(0,c.G)("userProfile.connectedAccountPage.socialButtonsBlockButton",{provider:o[r].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:p},r)},A=({onClick:e})=>{let{user:r}=(0,v.Jd)(),{strategies:t}=(0,F.k)(),n=t.filter(e=>e.startsWith("oauth")),l=r?.verifiedExternalAccounts.map(e=>`oauth_${e.provider}`),o=n.filter(e=>!l.includes(e));return 0===o.length?null:(0,i.Y)(D.rd.ActionMenu,{triggerLocalizationKey:(0,c.G)("userProfile.start.connectedAccountsSection.primaryButton"),id:"connectedAccounts",onClick:e,children:o.map(e=>(0,i.Y)(x,{strategy:e},e))})};var z=t(8046);let T=e=>{let{onSuccess:r,onReset:t}=e,{user:l}=(0,v.Jd)(),{emailId:o}=e,a=l?.emailAddresses.find(e=>e.id===o),s=n.useRef(a?.emailAddress),d=a?.verification?.status==="verified"?(0,c.G)("userProfile.emailAddressPage.removeResource.messageLine2"):void 0;return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.emailAddressPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.emailAddressPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:d,successMessage:(0,c.G)("userProfile.emailAddressPage.removeResource.successMessage",{emailAddress:s.current}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:r,onReset:t}):null},E=e=>{let{phoneId:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=o?.phoneNumbers.find(e=>e.id===r),s=n.useRef(a?.phoneNumber),d=a?.verification?.status==="verified"?(0,c.G)("userProfile.phoneNumberPage.removeResource.messageLine2"):void 0;return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.phoneNumberPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.phoneNumberPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:d,successMessage:(0,c.G)("userProfile.phoneNumberPage.removeResource.successMessage",{phoneNumber:s.current}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:t,onReset:l}):null},L=e=>{let{accountId:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=o?.externalAccounts.find(e=>e.id===r),s=n.useRef(a?.provider),{providerToDisplayData:d}=(0,F.k)();return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.connectedAccountPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.connectedAccountPage.removeResource.messageLine1",{identifier:d[s.current]?.name||""}),messageLine2:(0,c.G)("userProfile.connectedAccountPage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.connectedAccountPage.removeResource.successMessage",{connectedAccount:d[s.current]?.name||""}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:t,onReset:l}):null},O=e=>{let{user:r}=(0,v.Jd)(),{walletId:t,onSuccess:l,onReset:o}=e,a=r?.web3Wallets.find(e=>e.id===t),s=n.useRef(a?.web3Wallet),d=a?.verification?.status==="verified"?(0,c.G)("userProfile.web3WalletPage.removeResource.messageLine2"):void 0;return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.web3WalletPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.web3WalletPage.removeResource.messageLine1",{identifier:s.current}),messageLine2:d,successMessage:(0,c.G)("userProfile.web3WalletPage.removeResource.successMessage",{web3Wallet:s.current}),deleteResource:()=>Promise.resolve(a?.destroy()),onSuccess:l,onReset:o}):null},K=e=>{let{user:r}=(0,v.Jd)(),{phoneId:t,onSuccess:l,onReset:o}=e,a=r?.phoneNumbers.find(e=>e.id===t),s=n.useRef(a?.phoneNumber);return s.current?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.title"),messageLine1:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.messageLine1",{identifier:s.current}),messageLine2:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.successMessage",{mfaPhoneCode:s.current}),deleteResource:()=>Promise.resolve(a?.setReservedForSecondFactor({reserved:!1})),onSuccess:l,onReset:o}):null},B=e=>{let{onSuccess:r,onReset:t}=e,{user:n}=(0,v.Jd)();return n?(0,i.Y)(z.P,{title:(0,c.G)("userProfile.mfaTOTPPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.mfaTOTPPage.removeResource.messageLine1"),messageLine2:(0,c.G)("userProfile.mfaTOTPPage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.mfaTOTPPage.removeResource.successMessage"),deleteResource:n.disableTOTP,onSuccess:r,onReset:t}):null},W=e=>{let{onSuccess:r,onReset:t,passkey:n}=e;return(0,i.Y)(z.P,{title:(0,c.G)("userProfile.passkeyScreen.removeResource.title"),messageLine1:(0,c.G)("userProfile.passkeyScreen.removeResource.messageLine1",{name:n.name||""}),deleteResource:n.delete,onSuccess:r,onReset:t})},M=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(L,{onSuccess:r,onReset:r,...e})},N=["external_account_missing_refresh_token","oauth_fetch_user_error","oauth_token_exchange_error","external_account_email_address_verification_required"],J=(0,d.dm)(({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)(),t=(0,d.f0)(),l=!!r?.externalAccounts?.length,[o,a]=(0,n.useState)(null);if(!r||!e&&!l)return null;let s=[...r.verifiedExternalAccounts,...r.unverifiedExternalAccounts.filter(e=>e.verification?.error)];return(0,i.FD)(D.rd.Root,{title:(0,c.G)("userProfile.start.connectedAccountsSection.title"),centered:!1,id:"connectedAccounts",children:[(0,i.Y)(P.Z.Alert,{children:t.error}),(0,i.FD)(C.r.Root,{value:o,onChange:a,children:[(0,i.Y)(D.rd.ItemList,{id:"connectedAccounts",children:s.map(e=>(0,i.Y)(q,{account:e},e.id))}),e&&(0,i.Y)(A,{onClick:()=>a(null)})]})]})}),q=({account:e})=>{let{additionalOAuthScopes:r,componentName:t,mode:l}=(0,a.B)(),{navigate:o}=(0,I.r)(),{user:s}=(0,v.Jd)(),u=(0,d.f0)(),h=e.id,f="modal"===l,m=f?(0,_.j)({url:window.location.href,componentName:t}):window.location.href,p=(0,v.Wp)(()=>s?.createExternalAccount({strategy:e.verification.strategy,redirectUrl:m,additionalScopes:b}));if(!s)return null;let{providerToDisplayData:g}=(0,F.k)(),Y=e.username||e.emailAddress,P=e.verification?.error?.longMessage,b=function(e,r){if(!r)return[];let t=r[e.provider]||[],i=e.approvedScopes.split(" ");return 0===t.filter(e=>!i.includes(e)).length?[]:t}(e,r),R=b.length>0&&""!=e.approvedScopes,$=N.includes(e.verification?.error?.code||"")||R,k=$?(0,c.G)("userProfile.start.connectedAccountsSection.subtitle__disconnected"):P,x=async()=>{let r=f?(0,_.j)({url:window.location.href,componentName:t}):window.location.href;try{let t;(t=R?await e.reauthorize({additionalScopes:b,redirectUrl:r}):await p())&&await o(t.verification.externalVerificationRedirectURL?.href||"")}catch(e){(0,G.H4)(e,[],u.setError)}};return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"connectedAccounts",children:[(0,i.FD)(y.so,{sx:e=>({overflow:"hidden",gap:e.space.$2}),children:[(0,i.Y)(()=>g[e.provider].iconUrl?(0,i.Y)(y._V,{elementDescriptor:[S.$z.providerIcon],elementId:S.$z.socialButtonsProviderIcon.setId(e.provider),alt:g[e.provider].name,src:g[e.provider].iconUrl,sx:e=>({width:e.sizes.$4,flexShrink:0})}):(0,i.Y)(w.T,{id:e.provider,value:g[e.provider].name}),{}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:1,center:!0,children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),children:`${g[e.provider].name}`}),(0,i.Y)(y.EY,{truncate:!0,as:"span",colorScheme:"secondary",children:Y?`• ${Y}`:""})]})})]}),(0,i.Y)(U,{account:e})]}),$&&(0,i.FD)(y.az,{sx:e=>({padding:`${e.sizes.$none} ${e.sizes.$none} ${e.sizes.$1x5} ${e.sizes.$8x5}`}),children:[(0,i.Y)(y.EY,{colorScheme:"secondary",sx:e=>({paddingRight:e.sizes.$1x5,display:"inline-block"}),localizationKey:k}),(0,i.Y)(y.$n,{sx:{display:"inline-block"},onClick:x,variant:"link",localizationKey:(0,c.G)("userProfile.start.connectedAccountsSection.actionLabel__connectionFailed")})]}),e.verification?.error?.code&&!$&&(0,i.Y)(y.EY,{colorScheme:"danger",sx:e=>({padding:`${e.sizes.$none} ${e.sizes.$1x5} ${e.sizes.$1x5} ${e.sizes.$8x5}`}),children:P}),(0,i.Y)(C.r.Open,{value:`remove-${h}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(M,{accountId:e.id})})})]},e.id)},U=({account:e})=>{let{open:r}=(0,$.D5)(),t=e.id,n=[{label:(0,c.G)("userProfile.start.connectedAccountsSection.destructiveActionTitle"),isDestructive:!0,onClick:()=>r(`remove-${t}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:n})},j=e=>e.defaultSecondFactor?-1:1;function H(e){let r=[];return Object.entries(e).forEach(([,e])=>{e.used_for_second_factor&&r.push(...e.second_factors)}),r}function V(e,r){let t=H(e);return r.totpEnabled&&(t=t.filter(e=>"totp"!==e)),(r.backupCodeEnabled||!r.twoFactorEnabled)&&(t=t.filter(e=>"backup_code"!==e)),t}function Z(e,r){if(!e)return[];let t=e.filter(e=>e.id===r),i=e.filter(e=>e.id!==r),n=i.filter(e=>e.verification?.status==="verified"),l=i.filter(e=>!!e.verification?.status&&e.verification?.status!=="verified"),o=i.filter(e=>!e.verification.status);return n.sort((e,r)=>e.id.localeCompare(r.id)),l.sort((e,r)=>e.verification?.expireAt&&r.verification?.expireAt?e.verification.expireAt.getTime()-r.verification.expireAt.getTime():0),[...t,...n,...l,...o]}var X=t(2336);let Q=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(T,{onSuccess:r,onReset:r,...e})},ee=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(X.v,{onSuccess:r,onReset:r,...e})},er=({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)();return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.emailAddressesSection.title"),centered:!1,id:"emailAddresses",children:(0,i.Y)(C.r.Root,{children:(0,i.FD)(D.rd.ItemList,{id:"emailAddresses",children:[Z(r?.emailAddresses,r?.primaryEmailAddressId).map(e=>{let t=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"emailAddresses",children:[(0,i.FD)(y.so,{sx:e=>({overflow:"hidden",gap:e.space.$1}),children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),truncate:!0,children:e.emailAddress}),r?.primaryEmailAddressId===t&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]}),(0,i.Y)(et,{email:e})]}),(0,i.Y)(C.r.Open,{value:`remove-${t}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(Q,{emailId:t})})}),(0,i.Y)(C.r.Open,{value:`verify-${t}`,children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ee,{emailId:t})})})]},e.emailAddress)}),e&&(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Trigger,{value:"add",children:(0,i.Y)(D.rd.ArrowButton,{id:"emailAddresses",localizationKey:(0,c.G)("userProfile.start.emailAddressesSection.primaryButton")})}),(0,i.Y)(C.r.Open,{value:"add",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ee,{})})})]})]})})})},et=({email:e})=>{let r=(0,d.f0)(),{user:t}=(0,v.Jd)(),{open:n}=(0,$.D5)(),l=e.id,o=t?.primaryEmailAddressId===l,a="verified"===e.verification.status,s=(0,v.Wp)(()=>t?.update({primaryEmailAddressId:l})),u=[o&&!a?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__primary"),onClick:()=>n(`verify-${l}`)}:null,!o&&a?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__nonPrimary"),onClick:()=>{s().catch(e=>(0,G.H4)(e,[],r.setError))}}:null,!o&&!a?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__unverified"),onClick:()=>n(`verify-${l}`)}:null,{label:(0,c.G)("userProfile.start.emailAddressesSection.destructiveAction"),isDestructive:!0,onClick:()=>n(`remove-${l}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:u})},ei=()=>{let{user:e}=(0,v.Jd)(),r=e?.enterpriseAccounts.filter(({enterpriseConnection:e})=>e?.active);return r?.length?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.enterpriseAccountsSection.title"),id:"enterpriseAccounts",centered:!1,children:(0,i.Y)(D.rd.ItemList,{id:"enterpriseAccounts",children:r.map(e=>(0,i.Y)(en,{account:e},e.id))})}):null},en=({account:e})=>{let r=e.emailAddress,t=e?.enterpriseConnection?.name,n=e.verification?.error?.longMessage;return(0,i.FD)(D.rd.Item,{id:"enterpriseAccounts",sx:e=>({gap:e.space.$2,justifyContent:"start"}),children:[(0,i.Y)(el,{account:e}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:1,center:!0,children:[(0,i.Y)(y.EY,{truncate:!0,colorScheme:"body",children:t}),(0,i.Y)(y.EY,{truncate:!0,as:"span",colorScheme:"secondary",children:r?`• ${r}`:""}),n&&(0,i.Y)(y.Ex,{colorScheme:"danger",localizationKey:(0,c.G)("badge__requiresAction")})]})})]},e.id)},el=({account:e})=>{let{provider:r,enterpriseConnection:t}=e,n=r.replace(/(oauth_|saml_)/,"").trim(),l=t?.name??n,o={elementDescriptor:[S.$z.providerIcon],alt:l,sx:e=>({width:e.sizes.$4}),elementId:S.$z.enterpriseButtonsProviderIcon.setId(e.provider)};return t?.logoPublicUrl?(0,i.Y)(y._V,{...o,src:t.logoPublicUrl}):(0,i.Y)(w.T,{id:n,value:l,"aria-label":`${l}'s icon`,elementDescriptor:[S.$z.providerIcon,S.$z.providerInitialIcon],elementId:S.$z.providerInitialIcon.setId(n)})};var eo=t(7651),ea=t(2454),es=t(1475),ec=t(3549),ed=t(8640),eu=t(6245),eh=t(1282);let ef=(0,d.dm)(e=>{let{phoneId:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=n.useRef(o?.phoneNumbers.find(e=>e.id===r)),s=(0,eu.X)({defaultStep:+!!a.current});return(0,i.FD)(eu.s,{...s.props,children:[(0,i.Y)(em,{resourceRef:a,title:(0,c.G)("userProfile.phoneNumberPage.title"),onSuccess:s.nextStep,onReset:l}),(0,i.Y)(ep,{resourceRef:a,title:(0,c.G)("userProfile.phoneNumberPage.verifyTitle"),onSuccess:t,onReset:l})]})}),em=e=>{let{title:r,onSuccess:t,onReset:n,onUseExistingNumberClick:l,resourceRef:o}=e,a=(0,d.f0)(),{user:s}=(0,v.Jd)(),u=(0,v.Wp)((e,r)=>e.createPhoneNumber(r)),h=(0,ed.tJ)("phoneNumber","",{type:"tel",label:(0,c.G)("formFieldLabel__phoneNumber"),isRequired:!0}),f=h.value.length>1&&s?.username!==h.value,m=!!s?.phoneNumbers?.length&&l,p=async e=>{if(e.preventDefault(),s)return u(s,{phoneNumber:h.value}).then(e=>{o.current=e,t()}).catch(e=>(0,G.H4)(e,[h],a.setError))};return(0,i.Y)(ec.M,{headerTitle:r,gap:1,children:(0,i.FD)(ea.l.Root,{gap:4,onSubmit:p,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.phoneNumberPage.infoText"),colorScheme:"secondary"}),(0,i.Y)(ea.l.ControlRow,{elementId:h.id,children:(0,i.Y)(ea.l.PhoneInput,{...h.props,autoFocus:!0})}),(0,i.FD)(y.so,{justify:m?"between":"end",children:[m&&(0,i.Y)(y.$n,{variant:"ghost",localizationKey:(0,c.G)("userProfile.mfaPhoneCodePage.backButton"),onClick:l}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.formButtonPrimary__add"),isDisabled:!f,onReset:n})]})]})})},ep=e=>{let{title:r,onSuccess:t,resourceRef:n,onReset:l}=e;return(0,i.Y)(ec.M,{headerTitle:r,headerSubtitle:(0,c.G)("userProfile.phoneNumberPage.verifySubtitle",{identifier:n.current?.phoneNumber||""}),children:(0,i.Y)(eh.j,{nextStep:t,identification:n.current,identifier:n.current?.phoneNumber,prepareVerification:n.current?.prepareVerification,onReset:l})})},eg=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(E,{onSuccess:r,onReset:r,...e})},eY=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(ef,{onSuccess:r,onReset:r,...e})},ev=({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)(),t=!!r?.phoneNumbers?.length;return e||t?(0,i.Y)(D.rd.Root,{centered:!1,title:(0,c.G)("userProfile.start.phoneNumbersSection.title"),id:"phoneNumbers",children:(0,i.Y)(C.r.Root,{children:(0,i.FD)(D.rd.ItemList,{id:"phoneNumbers",children:[Z(r?.phoneNumbers,r?.primaryPhoneNumberId).map(e=>{let t=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"phoneNumbers",children:[(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:2,center:!0,children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),children:(0,eo.Om)(e.phoneNumber)}),r?.primaryPhoneNumberId===t&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]})}),(0,i.Y)(eP,{phone:e})]}),(0,i.Y)(C.r.Open,{value:`remove-${t}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(eg,{phoneId:t})})}),(0,i.Y)(C.r.Open,{value:`verify-${t}`,children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eY,{phoneId:t})})})]},t)}),e&&(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Trigger,{value:"add",children:(0,i.Y)(D.rd.ArrowButton,{id:"phoneNumbers",localizationKey:(0,c.G)("userProfile.start.phoneNumbersSection.primaryButton")})}),(0,i.Y)(C.r.Open,{value:"add",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eY,{})})})]})]})})}):null},eP=({phone:e})=>{let r=(0,d.f0)(),{open:t}=(0,$.D5)(),{user:n}=(0,v.Jd)(),l=e.id,o=(0,v.Wp)(r=>r.update({primaryPhoneNumberId:e.id}));if(!n)return null;let a=n.primaryPhoneNumberId===e.id,s="verified"===e.verification.status,u=[a&&!s?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__primary"),onClick:()=>t(`verify-${l}`)}:null,!a&&s?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__nonPrimary"),onClick:()=>o(n).catch(e=>(0,G.H4)(e,[],r.setError))}:null,!a&&!s?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__unverified"),onClick:()=>t(`verify-${l}`)}:null,{label:(0,c.G)("userProfile.start.phoneNumbersSection.destructiveAction"),isDestructive:!0,onClick:()=>t(`remove-${l}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:u})};var eb=t(7591),ey=t(4557),eS=t(78);let e_=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,{user:n}=(0,v.Jd)(),l=(0,v.Wp)(e=>n?.update({username:e})),{userSettings:o}=(0,Y.O)(),a=(0,d.f0)(),{t:s,locale:u}=(0,eS._)(),{usernameSettings:h}=o,f=(0,ed.tJ)("username",n?.username||"",{type:"text",label:(0,c.G)("formFieldLabel__username"),placeholder:(0,c.G)("formFieldInputPlaceholder__username"),buildErrorMessage:e=>(0,ey.Z)(e,{t:s,locale:u,usernameSettings:h})});if(!n)return null;let m=o.attributes.username?.required,p=(!m||f.value.length>0)&&n.username!==f.value,g=async()=>{try{await l(f.value),r()}catch(e){(0,G.H4)(e,[f],a.setError)}};return(0,i.Y)(ec.M,{headerTitle:n.username?(0,c.G)("userProfile.usernamePage.title__update"):(0,c.G)("userProfile.usernamePage.title__set"),children:(0,i.FD)(ea.l.Root,{onSubmit:g,children:[(0,i.Y)(ea.l.ControlRow,{elementId:f.id,children:(0,i.Y)(ea.l.PlainInput,{...f.props,autoFocus:!0,isRequired:m})}),(0,i.Y)(es.G,{isDisabled:!p,onReset:t})]})})}),eD=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(e_,{onSuccess:e,onReset:e})},eR=()=>{let{user:e}=(0,v.Jd)();return e?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.usernameSection.title"),id:"username",sx:{alignItems:"center",[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"username",sx:{paddingLeft:e.username?void 0:"0"},children:[e.username&&(0,i.Y)(y.EY,{truncate:!0,sx:e=>({color:e.colors.$colorForeground}),children:e.username}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"username",localizationKey:e.username?(0,c.G)("userProfile.start.usernameSection.primaryButton__updateUsername"):(0,c.G)("userProfile.start.usernameSection.primaryButton__setUsername")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eD,{})})})]})}):null};var eG=t(9345),ew=t(2421),eC=t(8225),e$=t(3817),eF=t(9538);let eI=e=>{let{user:r,...t}=e;return(0,i.Y)(e$.k,{...t,title:(0,c.G)("userProfile.profilePage.imageFormTitle"),avatarPreview:(0,i.Y)(eF.H,{size:e=>e.sizes.$12,...r})})},ek=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,n=(0,d.f0)(),{user:l}=(0,v.Jd)();if(!l)return null;let{first_name:o,last_name:a}=(0,Y.O)().userSettings.attributes,s=o?.enabled,u=a?.enabled,h=l.firstName||"",f=l.lastName||"",m=(0,ed.tJ)("firstName",l.firstName||"",{type:"text",label:(0,c.G)("formFieldLabel__firstName"),placeholder:(0,c.G)("formFieldInputPlaceholder__firstName"),isRequired:a?.required}),p=(0,ed.tJ)("lastName",l.lastName||"",{type:"text",label:(0,c.G)("formFieldLabel__lastName"),placeholder:(0,c.G)("formFieldInputPlaceholder__lastName"),isRequired:a?.required}),g=s&&m.value!==h||u&&p.value!==f,P=s&&o.required||u&&a.required,b=P&&!!p.value&&!!m.value&&g,y=l.enterpriseAccounts.some(e=>e.active),S=async e=>(e.preventDefault(),(g?l.update({firstName:m.value,lastName:p.value}):Promise.resolve()).then(r).catch(e=>{(0,G.H4)(e,[m,p],n.setError)}));return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.profilePage.title"),children:[y&&(0,i.Y)(ew.k,{message:(0,c.G)("userProfile.profilePage.readonly")}),(0,i.FD)(ea.l.Root,{onSubmit:S,sx:e=>({gap:e.space.$6}),children:[(0,i.Y)(eI,{user:l,onAvatarChange:e=>l.setProfileImage({file:e}).then(()=>{n.setIdle(),r?.()}).catch(e=>(0,G.H4)(e,[],n.setError)),onAvatarRemove:(0,eC.p)(l.imageUrl)?null:()=>{l.setProfileImage({file:null}).then(()=>{n.setIdle(),r?.()}).catch(e=>(0,G.H4)(e,[],n.setError))}}),(s||u)&&(0,i.FD)(ea.l.ControlRow,{elementId:"name",children:[s&&(0,i.Y)(ea.l.PlainInput,{...m.props,isDisabled:y,autoFocus:!0}),u&&(0,i.Y)(ea.l.PlainInput,{...p.props,isDisabled:y,autoFocus:!s})]}),(0,i.Y)(es.G,{isDisabled:P?!b:!g,onReset:t})]})]})}),ex=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(ek,{onSuccess:e,onReset:e})},eA=()=>{let{user:e}=(0,v.Jd)();if(!e)return null;let{username:r,primaryEmailAddress:t,primaryPhoneNumber:n,primaryWeb3Wallet:l,...o}=e;return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.profileSection.title"),id:"profile",sx:{[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"profile",children:[(0,i.Y)(eG.c,{user:o,size:"lg",mainIdentifierVariant:"subtitle",sx:e=>({color:e.colors.$colorForeground})}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"profile",localizationKey:(0,c.G)("userProfile.start.profileSection.primaryButton")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ex,{})})})]})})};var ez=t(6463),eT=t(5243),eE=t(3610);let eL=(0,n.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("188")]).then(t.bind(t,6464)).then(e=>({default:e.Web3SolanaWalletButtons}))),eO=({onConnect:e})=>{let r=(0,d.f0)(),{close:t}=(0,$.D5)(),l=async({walletName:i})=>{r.setLoading(i);try{await e({strategy:"web3_solana_signature",walletName:i}),r.setIdle(),t()}catch(e){if(r.setIdle(),e instanceof Error)(0,G.H4)(e,[],r.setError);else{let t=new eE.cR("An error occurred while generating the Solana signature.",{code:"web3_solana_signature_generation_failed",cause:e instanceof Error?e:void 0});(0,G.H4)(t,[],r.setError)}}};return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.start.web3WalletsSection.web3SelectSolanaWalletScreen.title"),headerSubtitle:(0,c.G)("userProfile.start.web3WalletsSection.web3SelectSolanaWalletScreen.subtitle"),children:(0,i.FD)(ea.l.Root,{children:[(0,i.Y)(n.Suspense,{fallback:(0,i.Y)(y.so,{direction:"row",align:"center",justify:"center",sx:e=>({height:"100%",minHeight:e.sizes.$32}),children:(0,i.Y)(y.y$,{size:"lg",colorScheme:"primary",elementDescriptor:S.$z.spinner})}),children:(0,i.Y)(eL,{web3AuthCallback:l})}),(0,i.Y)(es.c,{children:(0,i.Y)(y.$n,{type:"button",variant:"ghost",onClick:()=>{t()},localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})})]})})};var eK=t(9236);let eB=()=>{let e=(0,d.f0)(),{open:r}=(0,$.D5)(),{user:t}=(0,v.Jd)(),{strategies:n,strategyToDisplayData:l}=(0,F.k)(),o=(0,eT.R)(),a=n.filter(e=>e.startsWith("web3")),s=t?.verifiedWeb3Wallets?.map(e=>e.verification.strategy)??[],u=a.filter(e=>!s.includes(e)&&l[e]);if(0===u.length)return null;let h=(0,v.Wp)(e=>t?.createWeb3Wallet({web3Wallet:e})),f=async({strategy:i,walletName:n})=>{let l=(0,ez.U)(o);if("web3_solana_signature"===i&&!n)return void r("web3Wallets");let a=i.replace("web3_","").replace("_signature","");e.setError(void 0);try{e.setLoading(i);let r=await l.getWeb3Identifier({provider:a,walletName:n});if(!t)throw Error("user is not defined");let o=await h(r);o=await o?.prepareVerification({strategy:i});let s=o?.verification.message,c=await l.generateWeb3Signature({identifier:r,nonce:s,provider:a,walletName:n});await o?.attemptVerification({signature:c}),e.setIdle()}catch(r){e.setIdle(),(0,eK.f)(r,e.setError)}};return(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Closed,{value:"web3Wallets",children:(0,i.Y)(D.rd.ActionMenu,{id:"web3Wallets",triggerLocalizationKey:(0,c.G)("userProfile.start.web3WalletsSection.primaryButton"),children:u.map(r=>(0,i.Y)(D.rd.ActionMenuItem,{id:l[r].id,onClick:()=>{f({strategy:r})},isLoading:e.loadingMetadata===r,isDisabled:e.isLoading,localizationKey:(0,c.G)("userProfile.web3WalletPage.web3WalletButtonsBlockButton",{provider:l[r].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:(0,i.Y)(y._V,{elementDescriptor:S.$z.providerIcon,elementId:S.$z.providerIcon.setId(l[r].id),isLoading:e.loadingMetadata===r,isDisabled:e.isLoading,src:l[r].iconUrl,alt:`Connect ${l[r].name}`,sx:e=>({width:e.sizes.$5})})},r))})}),(0,i.Y)(C.r.Open,{value:"web3Wallets",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eO,{onConnect:f})})})]})},eW=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(O,{onSuccess:r,onReset:r,...e})},eM=(0,d.dm)(({shouldAllowCreation:e=!0})=>{let{user:r}=(0,v.Jd)(),t=(0,d.f0)(),{strategyToDisplayData:l}=(0,F.k)(),o=!!r?.web3Wallets?.length,[a,s]=(0,n.useState)(null);return e||o?(0,i.FD)(D.rd.Root,{title:(0,c.G)("userProfile.start.web3WalletsSection.title"),centered:!1,id:"web3Wallets",children:[(0,i.Y)(P.Z.Alert,{children:t.error}),(0,i.FD)(C.r.Root,{value:a,onChange:s,children:[(0,i.Y)(D.rd.ItemList,{id:"web3Wallets",children:Z(r?.web3Wallets,r?.primaryWeb3WalletId).map(e=>{var t;let o=e.verification.strategy,a=e.id;return l[o]&&(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"web3Wallets",align:"start",children:[(0,i.FD)(y.so,{sx:e=>({alignItems:"center",gap:e.space.$2,width:"100%"}),children:[l[o].iconUrl&&(0,i.Y)(y._V,{src:l[o].iconUrl,alt:l[o].name,sx:e=>({width:e.sizes.$4})}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:2,justify:"start",children:[(0,i.FD)(y.EY,{children:[l[o].name," (",(t=e.web3Wallet).length<=10?t:t.slice(0,6)+"..."+t.slice(-4),")"]}),r?.primaryWeb3WalletId===a&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]})})]}),(0,i.Y)(eN,{walletId:a,isVerified:"verified"===e.verification.status})]},a),(0,i.Y)(C.r.Open,{value:`remove-${a}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(eW,{walletId:e.id})})})]},e.id)})}),e&&(0,i.Y)(eB,{})]})]}):null}),eN=({walletId:e,isVerified:r})=>{let t=(0,d.f0)(),{open:n}=(0,$.D5)(),{user:l}=(0,v.Jd)(),o=l?.primaryWeb3WalletId===e,a=(0,v.Wp)(()=>l?.update({primaryWeb3WalletId:e})),s=[!o&&r?{label:(0,c.G)("userProfile.start.web3WalletsSection.detailsAction__nonPrimary"),onClick:()=>{a().catch(e=>(0,G.H4)(e,[],t.setError))}}:null,{label:(0,c.G)("userProfile.start.web3WalletsSection.destructiveAction"),isDestructive:!0,onClick:()=>n(`remove-${e}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:s})},eJ=(0,d.dm)(()=>{let{attributes:e,social:r,enterpriseSSO:t}=(0,Y.O)().userSettings,n=(0,d.f0)(),{user:l}=(0,v.Jd)(),{shouldAllowIdentificationCreation:o}=(0,a.B)(),s=e.username?.enabled,u=e.email_address?.enabled,h=e.phone_number?.enabled,f=r&&Object.values(r).filter(e=>e.enabled).length>0,m=l&&t.enabled,p=e.web3_wallet?.enabled;return(0,i.Y)(y.fv,{elementDescriptor:S.$z.page,sx:e=>({gap:e.space.$8,color:e.colors.$colorForeground}),children:(0,i.FD)(y.fv,{elementDescriptor:S.$z.profilePage,elementId:S.$z.profilePage.setId("account"),children:[(0,i.Y)(b.Y.Root,{children:(0,i.Y)(b.Y.Title,{localizationKey:(0,c.G)("userProfile.start.headerTitle__account"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,i.Y)(P.Z.Alert,{children:n.error}),(0,i.Y)(eA,{}),s&&(0,i.Y)(eR,{}),u&&(0,i.Y)(er,{shouldAllowCreation:o}),h&&(0,i.Y)(ev,{shouldAllowCreation:o}),f&&(0,i.Y)(J,{shouldAllowCreation:o}),m&&(0,i.Y)(ei,{}),p&&(0,i.Y)(eM,{shouldAllowCreation:o})]})})});var eq=t(2611),eU=t(7806),ej=t(7896),eH=t(4901),eV=t(892),eZ=t(8910);let eX=()=>{let e,{user:r}=(0,v.Jd)(),{session:t}=(0,v.wV)(),{data:n,isLoading:l}=(0,ej.s)(r?.getSessions,"user-sessions");return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.activeDevicesSection.title"),centered:!1,id:"activeDevices",children:(0,i.Y)(D.rd.ItemList,{id:"activeDevices",disableAnimation:!0,children:l?(0,i.Y)(eq.K,{}):n?.sort((e=t.id,r=>r.id===e?-1:1)).map(e=>eQ(e.status)?(0,i.Y)(e0,{session:e},e.id):null)})})},eQ=e=>["active","pending"].includes(e),e0=({session:e})=>{let r=(0,v.wV)().session?.id===e.id,t=(0,eH.m)(),n=(0,v.Wp)(e.revoke.bind(e)),l=async()=>{if(!r&&e)return t.setLoading(),n().catch(e=>(0,G.H4)(e,[],t.setError)).finally(()=>t.setIdle())};return(0,i.Y)(D.rd.Item,{id:"activeDevices",elementDescriptor:S.$z.activeDeviceListItem,elementId:r?S.$z.activeDeviceListItem.setId("current"):void 0,sx:{alignItems:"flex-start",opacity:t.isLoading?.5:1},isDisabled:t.isLoading,children:(0,i.FD)(i.FK,{children:[(0,i.Y)(e1,{session:e}),!r&&(0,i.Y)(e2,{revoke:l})]})})},e1=e=>{let{session:r}=(0,v.wV)(),t=r?.id===e.session.id,n=!!r?.actor,l=!!e.session.actor,{city:o,country:a,browserName:s,browserVersion:d,deviceType:u,ipAddress:h,isMobile:f}=e.session.latestActivity,m=`${s||""} ${d||""}`.trim()||"Web browser",p=[o||"",a||""].filter(Boolean).join(", ").trim()||null,{t:g}=(0,eS._)();return(0,i.FD)(y.so,{elementDescriptor:S.$z.activeDevice,elementId:t?S.$z.activeDevice.setId("current"):void 0,sx:e=>({width:"100%",overflow:"hidden",gap:e.space.$4,[eb.g.sm]:{gap:e.space.$2}}),children:[(0,i.Y)(y.so,{sx:e=>({[eb.g.sm]:{padding:"0"},borderRadius:e.radii.$md}),children:(0,i.Y)(y.In,{elementDescriptor:S.$z.activeDeviceIcon,elementId:S.$z.activeDeviceIcon.setId(f?"mobile":"desktop"),icon:f?eV.A:eZ.A,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.FD)(y.fv,{align:"start",gap:1,children:[(0,i.FD)(y.so,{center:!0,gap:2,children:[(0,i.Y)(y.EY,{children:u||(f?"Mobile device":"Desktop device")}),t&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__thisDevice"),colorScheme:n?"danger":"primary"}),n&&!l&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__userDevice")}),!t&&l&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__otherImpersonatorDevice"),colorScheme:"danger"})]}),(0,i.Y)(y.EY,{colorScheme:"secondary",children:m}),(0,i.FD)(y.EY,{colorScheme:"secondary",children:[h," (",p,")"]}),(0,i.Y)(y.EY,{colorScheme:"secondary",children:g((0,eU.T)(e.session.lastActiveAt))})]})]})},e2=({revoke:e})=>{let r=[{label:(0,c.G)("userProfile.start.activeDevicesSection.destructiveAction"),isDestructive:!0,onClick:e}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})};var e5=t(9599),e4=t(8691);let e3=(0,d.dm)(e=>{let{onReset:r}=e,t=(0,d.f0)(),{afterSignOutUrl:n,afterMultiSessionSingleSignOutUrl:l}=(0,e5.g)(),{user:o}=(0,v.Jd)(),{t:a}=(0,eS._)(),{otherSessions:s}=(0,e4.z)({user:o}),{setActive:u}=(0,v.ho)(),h=(0,v.Wp)(()=>o?.delete()),f=(0,ed.tJ)("deleteConfirmation","",{type:"text",label:(0,c.G)("userProfile.deletePage.actionDescription"),isRequired:!0,placeholder:(0,c.G)("formFieldInputPlaceholder__confirmDeletionUserAccount")}),m=f.value===(a((0,c.G)("formFieldInputPlaceholder__confirmDeletionUserAccount"))||"Delete account"),p=async()=>{if(m)try{await h();let e=0===s.length?n:l;return await u({session:null,redirectUrl:e})}catch(e){(0,G.H4)(e,[],t.setError)}};return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.deletePage.title"),sx:e=>({gap:e.space.$0x5}),children:(0,i.FD)(ea.l.Root,{onSubmit:p,children:[(0,i.FD)(y.fv,{gap:1,children:[(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.deletePage.messageLine1")}),(0,i.Y)(y.EY,{colorScheme:"danger",localizationKey:(0,c.G)("userProfile.deletePage.messageLine2")})]}),(0,i.Y)(ea.l.ControlRow,{elementId:f.id,children:(0,i.Y)(ea.l.PlainInput,{...f.props,ignorePasswordManager:!0})}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.deletePage.confirm"),colorScheme:"danger",isDisabled:!m,onReset:r})]})})}),e6=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(e3,{onSuccess:e,onReset:e})},e8=()=>(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.dangerSection.title"),id:"danger",sx:{alignItems:"center",[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"delete",children:(0,i.Y)(D.rd.Item,{id:"danger",sx:e=>({paddingLeft:e.space.$1}),children:(0,i.Y)(C.r.Trigger,{value:"delete",children:(0,i.Y)(D.rd.Button,{id:"danger",variant:"ghost",colorScheme:"danger",localizationKey:(0,c.G)("userProfile.start.dangerSection.deleteAccountButton")})})})}),(0,i.Y)(C.r.Open,{value:"delete",children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(e6,{})})})]})});var e7=t(1323),e9=t(5079),re=t(6103),rr=t(2534),rt=t(8095),ri=t(9126),rn=t(7782),rl=t(1072),ro=t(5976),ra=t(2405),rs=t(2852);let rc=e=>{let{code:r}=e;return(0,i.Y)(y.so,{center:!0,sx:e=>({padding:`${e.space.$1} ${e.space.$4}`}),children:(0,i.Y)(y.EY,{children:r})})},rd=e=>{let{subtitle:r,backupCodes:t}=e,{applicationName:n}=(0,Y.O)().displayConfig,{user:l}=(0,v.Jd)(),{print:o,printableProps:a}=(0,ri.h)(),{onCopy:s,hasCopied:d}=(0,rn.i)(t?.join(",")||"");if(!l)return null;let u=(0,rt.Cm)(l);return t?(0,i.FD)(i.FK,{children:[(0,i.FD)(y.fv,{gap:1,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.title__codelist"),variant:"subtitle"}),(0,i.Y)(y.EY,{localizationKey:r,variant:"caption",colorScheme:"secondary"})]}),(0,i.FD)(y.az,{sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg}),children:[(0,i.Y)(y.xA,{gap:2,sx:e=>({gridTemplateColumns:`repeat(2, minmax(${e.sizes.$12}, 1fr))`,padding:`${e.space.$4} ${e.space.$6}`}),children:t.map((e,r)=>(0,i.Y)(rc,{code:e},r))}),(0,i.FD)(y.xA,{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.Y)(y.$n,{variant:"ghost",sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),onClick:()=>{var e,r,i;let l,o=document.createElement("a"),a=new Blob([(e=t,r=n,i=u,l=e?.join("\n"),`These are your backup codes for ${r} account ${i}.
2
2
  Store them securely and keep them secret. Each code can only be used once.
3
3
 
4
- ${l}`)],{type:"text/plain"});o.href=URL.createObjectURL(a),o.download=`${n}_backup_codes.txt`,document.body.appendChild(o),o.click()},children:(0,i.Y)(y.In,{icon:rn.A})}),(0,i.Y)(y.$n,{variant:"ghost",sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),onClick:o,children:(0,i.Y)(y.In,{icon:rl.A})}),(0,i.Y)(y.$n,{variant:"ghost",onClick:s,sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),children:(0,i.Y)(y.In,{icon:d?ro.A:ra.A})})]})]}),(0,i.FD)(rt.L,{...a,children:[(0,i.FD)(y.DZ,{children:["Your backup codes for ",n," account ",u,":"]}),(0,i.Y)(y.fv,{gap:2,children:t.map((e,r)=>(0,i.Y)(rs,{code:e},r))})]})]}):null},rd=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,{user:l}=(0,v.Jd)(),o=(0,d.f0)(),a=(0,v.Wp)(()=>l?.createBackupCode()),[s,u]=n.useState(void 0);return(n.useEffect(()=>{!s&&l&&a().then(e=>u(e)).catch(e=>{if((0,eT.I3)(e))return t();(0,G.H4)(e,[],o.setError)})},[]),o.error)?(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title")}):(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title"),children:s?(0,i.FD)(i.FK,{children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.successMessage")}),(0,i.Y)(rc,{subtitle:(0,c.G)("userProfile.backupCodePage.subtitle__codelist"),backupCodes:s.codes}),(0,i.Y)(es.c,{children:(0,i.Y)(y.$n,{autoFocus:!0,onClick:r,localizationKey:(0,c.G)("userProfile.formButtonPrimary__finish"),elementDescriptor:S.$z.formButtonPrimary})})]}):(0,i.Y)(eJ.K,{})})}),ru=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,n=(0,eu.X)();return(0,i.FD)(eu.s,{...n.props,children:[(0,i.Y)(rh,{onContinue:n.nextStep}),(0,i.Y)(rd,{onSuccess:r,onReset:t})]})}),rh=e=>{let{onContinue:r}=e,{close:t}=(0,$.D5)();return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title"),children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.infoText1")}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.infoText2")}),(0,i.FD)(es.c,{sx:{marginTop:0},children:[(0,i.Y)(y.$n,{textVariant:"buttonSmall",onClick:r,localizationKey:(0,c.G)("userProfile.formButtonPrimary__finish"),elementDescriptor:S.$z.formButtonPrimary}),(0,i.Y)(y.$n,{variant:"ghost",onClick:t,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})]})]})};var rm=t(155),rf=t(6370),rp=t(9679);let rg=(0,d.dm)(e=>{let{onReset:r,onSuccess:t}=e,l=n.useRef(),o=(0,eu.X)({defaultStep:2}),a=(0,Y.O)().userSettings.attributes.backup_code?.enabled;return(0,i.FD)(eu.s,{...o.props,children:[(0,i.Y)(ef,{title:(0,c.G)("userProfile.phoneNumberPage.title"),resourceRef:l,onSuccess:o.nextStep,onUseExistingNumberClick:()=>o.goToStep(2),onReset:r}),(0,i.Y)(rv,{title:(0,c.G)("userProfile.mfaPhoneCodePage.title"),resourceRef:l,onSuccess:()=>a?o.goToStep(3):t(),onReset:()=>o.goToStep(2)}),(0,i.Y)(rP,{onSuccess:a?o.nextStep:t,onReset:r,onAddPhoneClick:()=>o.goToStep(0),onUnverifiedPhoneClick:e=>{l.current=e,o.goToStep(1)},title:(0,c.G)("userProfile.mfaPhoneCodePage.title"),resourceRef:l}),a&&(0,i.Y)(rf.B,{title:(0,c.G)("userProfile.mfaPhoneCodePage.successTitle"),text:l.current?.backupCodes&&l.current?.backupCodes.length>0?[(0,c.G)("userProfile.mfaPhoneCodePage.successMessage1"),(0,c.G)("userProfile.mfaPhoneCodePage.successMessage2")]:[(0,c.G)("userProfile.mfaPhoneCodePage.successMessage1")],onFinish:r,contents:(0,i.Y)(rc,{backupCodes:l.current?.backupCodes})})]})}),rY=e=>{let{phone:r,onSuccess:t,onUnverifiedPhoneClick:n,resourceRef:l}=e,o=(0,d.f0)(),a=(0,v.Wp)(()=>r.setReservedForSecondFactor({reserved:!0})),{country:s}=(0,eo.Mz)(r.phoneNumber),c=(0,eo.Om)(r.phoneNumber),u=async()=>{if("verified"!==r.verification.status)return n(r);o.setLoading(r.id);try{await a(),l.current=r,t()}catch(e){(0,G.H4)(e,[],o.setError)}finally{o.setIdle()}};return(0,i.FD)(y.$n,{variant:"outline",colorScheme:"neutral",sx:{justifyContent:"start"},onClick:u,isLoading:o.loadingMetadata===r.id,isDisabled:o.isLoading,children:[s.iso.toUpperCase()," ",c]},r.id)},rv=e=>{let{title:r,onSuccess:t,resourceRef:n,onReset:l}=e,o=(0,d.f0)(),a=n.current,s=(0,v.Wp)(()=>a?.setReservedForSecondFactor({reserved:!0})),u=async()=>{o.setLoading(a?.id);try{await s(),n.current=a,t()}catch(e){(0,G.H4)(e,[],o.setError)}finally{o.setIdle()}};return(0,i.Y)(ec.M,{headerTitle:r,headerSubtitle:(0,c.G)("userProfile.phoneNumberPage.verifySubtitle",{identifier:n.current?.phoneNumber||""}),children:(0,i.Y)(eh.j,{nextStep:()=>{u()},identification:n.current,identifier:n.current?.phoneNumber,prepareVerification:n.current?.prepareVerification,onReset:l})})},rP=e=>{let{onSuccess:r,onReset:t,title:n,onAddPhoneClick:l,onUnverifiedPhoneClick:o,resourceRef:a}=e,{user:s}=(0,v.Jd)();if(!s)return null;let d=s.phoneNumbers.filter(e=>!e.reservedForSecondFactor);return(0,i.FD)(ec.M,{headerTitle:n,gap:1,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)(d.length?"userProfile.mfaPhoneCodePage.subtitle__availablePhoneNumbers":"userProfile.mfaPhoneCodePage.subtitle__unavailablePhoneNumbers"),colorScheme:"secondary"}),d.length>0&&(0,i.Y)(y.fv,{gap:2,children:d.map(e=>(0,i.Y)(rY,{onSuccess:r,phone:e,onUnverifiedPhoneClick:o,resourceRef:a},e.id))}),(0,i.FD)(es.c,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[(0,i.Y)(rm.K,{variant:"ghost","aria-label":"Add phone number",icon:(0,i.Y)(y.In,{icon:rp.A,sx:e=>({marginRight:e.space.$2})}),localizationKey:(0,c.G)("userProfile.mfaPhoneCodePage.primaryButton__addPhoneNumber"),onClick:l}),(0,i.Y)(y.$n,{variant:"ghost",localizationKey:(0,c.G)("userProfile.formButtonReset"),onClick:t})]})]})};var rb=t(5559),ry=t(2094);let rS=(0,d.dm)(e=>{let{title:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=(0,d.f0)(),s=(0,v.Wp)(()=>o?.createTOTP()),{close:u}=(0,$.D5)(),[h,m]=n.useState(void 0),[f,p]=n.useState("qr");return(n.useEffect(()=>{o&&s().then(e=>m(e)).catch(e=>(0,eT.Cm)(e)&&"reverification_cancelled"===e.code?u():(0,G.H4)(e,[],a.setError))},[]),a.error)?(0,i.Y)(ec.M,{headerTitle:r}):(0,i.FD)(ec.M,{headerTitle:r,headerSubtitle:"qr"==f?(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.infoText__ableToScan"):(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.infoText__unableToScan"),children:[!h&&(0,i.Y)(eJ.K,{}),h&&(0,i.FD)(i.FK,{children:[(0,i.FD)(y.fv,{gap:4,children:["qr"==f&&(0,i.Y)(ry.r,{justify:"center",url:h.uri||""}),"uri"==f&&(0,i.FD)(i.FK,{children:[(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan1")}),(0,i.Y)(rb.r,{value:h.secret}),(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan2")}),(0,i.Y)(rb.r,{value:h.uri})]})]}),(0,i.FD)(y.so,{justify:"between",align:"center",sx:{width:"100%"},children:["qr"==f&&(0,i.Y)(y.$n,{variant:"link",textVariant:"buttonLarge",onClick:()=>p("uri"),localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.buttonUnableToScan__nonPrimary")}),"uri"==f&&(0,i.Y)(y.$n,{variant:"link",textVariant:"buttonLarge",onClick:()=>p("qr"),localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.buttonAbleToScan__nonPrimary")}),(0,i.FD)(es.c,{children:[(0,i.Y)(y.$n,{onClick:t,localizationKey:(0,c.G)("userProfile.formButtonPrimary__continue"),elementDescriptor:S.$z.formButtonPrimary}),(0,i.Y)(y.$n,{variant:"ghost",onClick:l,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})]})]})]})]})});var r_=t(3356);let rD=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,resourceRef:n}=e,{user:l}=(0,v.Jd)(),o=(0,r_.xM)({onCodeEntryFinished:(e,r,t)=>{l?.verifyTOTP({code:e}).then(e=>r(e)).catch(t)},onResolve:e=>{n.current=e,r()}});return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.mfaTOTPPage.title"),children:[(0,i.Y)(y.fv,{children:(0,i.Y)(ea.l.OTPInput,{...o,label:(0,c.G)("userProfile.mfaTOTPPage.verifyTitle"),description:(0,c.G)("userProfile.mfaTOTPPage.verifySubtitle")})}),(0,i.Y)(es.c,{sx:{marginTop:0},children:(0,i.Y)(y.$n,{onClick:t,variant:"ghost",isDisabled:o.isLoading,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})})]})}),rR=(0,d.dm)(e=>{let{onReset:r}=e,t=(0,eu.X)(),l=n.useRef();return(0,i.FD)(eu.s,{...t.props,children:[(0,i.Y)(rS,{title:(0,c.G)("userProfile.mfaTOTPPage.title"),onSuccess:t.nextStep,onReset:r}),(0,i.Y)(rD,{onSuccess:t.nextStep,onReset:r,resourceRef:l}),(0,i.Y)(rf.B,{title:(0,c.G)("userProfile.mfaTOTPPage.title"),text:(0,c.G)("userProfile.mfaTOTPPage.successMessage"),onFinish:r,contents:(0,i.Y)(rc,{subtitle:(0,c.G)("userProfile.backupCodePage.successSubtitle"),backupCodes:l.current?.backupCodes})})]})}),rG=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,selectedStrategy:l}=e,o=(0,d.f0)(),{userSettings:{attributes:a}}=(0,Y.O)(),{user:s}=(0,v.Jd)();if(!s)return null;let u=(0,c.G)("userProfile.mfaPage.title"),h=n.useMemo(()=>V(a,s),[]);return(n.useEffect(()=>{0===h.length&&o.setError("There are no second factors available to add")},[]),o.error)?(0,i.Y)(ec.M,{headerTitle:u}):0!==h.length||l?(0,i.Y)(rw,{onSuccess:r,onReset:t,method:l||h[0]}):null}),rw=e=>{let{method:r,onSuccess:t,onReset:n}=e;switch(r){case"phone_code":return(0,i.Y)(rg,{onSuccess:t,onReset:n});case"totp":return(0,i.Y)(rR,{onSuccess:t,onReset:n});case"backup_code":return(0,i.Y)(ru,{onSuccess:t,onReset:n});default:return null}},rC=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(B,{onSuccess:e,onReset:e})},r$=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(K,{onSuccess:r,onReset:r,...e})},rF=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(rd,{onSuccess:e,onReset:e})},rI=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(rG,{onSuccess:r,onReset:r,selectedStrategy:e.selectedStrategy})},rx=()=>{let{userSettings:{attributes:e}}=(0,Y.O)(),{user:r}=(0,v.Jd)(),[t,l]=(0,n.useState)(null);if(!r)return null;let o=H(e),a=V(e,r),s=o.includes("totp")&&r.totpEnabled,d=o.includes("backup_code")&&r.backupCodeEnabled,u=r.phoneNumbers.filter(e=>"verified"===e.verification.status).filter(e=>e.reservedForSecondFactor).sort(j);return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.mfaSection.title"),centered:!1,id:"mfa",children:(0,i.Y)(C.r.Root,{value:t,onChange:l,children:(0,i.FD)(D.rd.ItemList,{id:"mfa",children:[s&&(0,i.FD)(i.FK,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:e7.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.start.mfaSection.totp.headerTitle")}),(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__default")})]}),(0,i.Y)(rz,{})]}),(0,i.Y)(C.r.Open,{value:"remove-totp",children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(rC,{})})})]}),o.includes("phone_code")&&u.map(e=>{let r=!s&&e.defaultSecondFactor,t=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:e9.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.FD)(y.EY,{children:["SMS Code ",(0,i.Y)(e8.R,{value:e.phoneNumber})]}),r&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__default")})]}),(0,i.Y)(rk,{phone:e,showTOTP:s})]}),(0,i.Y)(C.r.Open,{value:`remove-${t}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(r$,{phoneId:t})})})]},t)}),d&&(0,i.FD)(i.FK,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:re.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.start.mfaSection.backupCodes.headerTitle")})]}),(0,i.Y)(rA,{})]}),(0,i.Y)(C.r.Open,{value:"regenerate",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rF,{})})})]}),(0,i.Y)(rT,{secondFactorsAvailableToAdd:a,onClick:()=>l(null)})]})})})},rk=({phone:e,showTOTP:r})=>{let{open:t}=(0,$.D5)(),n=(0,d.f0)(),l=e.id,o=[!r&&!e.defaultSecondFactor?{label:(0,c.G)("userProfile.start.mfaSection.phoneCode.actionLabel__setDefault"),onClick:()=>e.makeDefaultSecondFactor().catch(e=>(0,G.H4)(e,[],n.setError))}:null,{label:(0,c.G)("userProfile.start.mfaSection.phoneCode.destructiveActionLabel"),isDestructive:!0,onClick:()=>t(`remove-${l}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:o})},rA=()=>{let{open:e}=(0,$.D5)(),r=[{label:(0,c.G)("userProfile.start.mfaSection.backupCodes.actionLabel__regenerate"),onClick:()=>e("regenerate")}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})},rz=()=>{let{open:e}=(0,$.D5)(),r=[{label:(0,c.G)("userProfile.start.mfaSection.totp.destructiveActionTitle"),isDestructive:!0,onClick:()=>e("remove-totp")}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})},rT=e=>{let{open:r}=(0,$.D5)(),{secondFactorsAvailableToAdd:t,onClick:l}=e,[o,a]=(0,n.useState)(),s=n.useMemo(()=>t.map(e=>"phone_code"===e?{icon:e9.A,text:"SMS code",key:"phone_code"}:"totp"===e?{icon:e7.A,text:"Authenticator application",key:"totp"}:"backup_code"===e?{icon:re.A,text:"Backup code",key:"backup_code"}:null).filter(e=>null!==e),[t]);return(0,i.FD)(i.FK,{children:[t.length>0&&(0,i.Y)(C.r.Closed,{value:"multi-factor",children:(0,i.Y)(D.rd.ActionMenu,{id:"mfa",triggerLocalizationKey:(0,c.G)("userProfile.start.mfaSection.primaryButton"),onClick:l,children:s.map(e=>e&&(0,i.Y)(D.rd.ActionMenuItem,{id:e.key,localizationKey:e.text,leftIcon:e.icon,onClick:()=>{a(e.key),r("multi-factor")}},e.key))})}),(0,i.Y)(C.r.Open,{value:"multi-factor",children:(0,i.Y)(C.r.Card,{children:o&&(0,i.Y)(rI,{selectedStrategy:o})})})]})},rE=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(M,{onSuccess:r,onReset:r,...e})},rL=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(rO,{onSuccess:r,onReset:r,passkey:e.passkey})},rO=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,passkey:n}=e,l=(0,d.f0)(),o=(0,ed.tJ)("passkeyName",n.name||"",{type:"text",label:(0,c.G)("formFieldLabel__passkeyName"),isRequired:!0}),a=o.value.length>1&&n.name!==o.value,s=async e=>(e.preventDefault(),n.update({name:o.value}).then(r).catch(e=>(0,G.H4)(e,[o],l.setError)));return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.passkeyScreen.title__rename"),headerSubtitle:(0,c.G)("userProfile.passkeyScreen.subtitle__rename"),children:(0,i.FD)(ea.l.Root,{onSubmit:s,children:[(0,i.Y)(ea.l.ControlRow,{elementId:o.id,children:(0,i.Y)(ea.l.PlainInput,{...o.props,autoComplete:"off"})}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.formButtonPrimary__save"),isDisabled:!a,onReset:t})]})})}),rK=()=>{let{user:e}=(0,v.Jd)(),[r,t]=(0,n.useState)(null);return e?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.passkeysSection.title"),centered:!1,id:"passkeys",children:(0,i.Y)(C.r.Root,{value:r,onChange:t,children:(0,i.FD)(D.rd.ItemList,{id:"passkeys",children:[e.passkeys.map(e=>{let r=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.Y)(rB,{...e},r),(0,i.Y)(C.r.Open,{value:`remove-${r}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(rE,{passkey:e})})}),(0,i.Y)(C.r.Open,{value:`rename-${r}`,children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rL,{passkey:e})})})]},r)}),(0,i.Y)(rN,{onClick:()=>t(null)})]})})}):null},rB=e=>(0,i.FD)(D.rd.Item,{id:"passkeys",hoverable:!0,sx:{alignItems:"flex-start"},children:[(0,i.Y)(rM,{...e}),(0,i.Y)(rW,{passkey:e})]}),rM=e=>{let{name:r,createdAt:t,lastUsedAt:n}=e,{t:l}=(0,eS._)();return(0,i.Y)(y.so,{sx:e=>({width:"100%",overflow:"hidden",gap:e.space.$4,[eb.g.sm]:{gap:e.space.$2}}),children:(0,i.FD)(y.fv,{align:"start",gap:1,children:[(0,i.Y)(y.EY,{children:r}),(0,i.FD)(y.EY,{colorScheme:"secondary",children:["Created: ",l((0,eq.T)(t))]}),n&&(0,i.FD)(y.EY,{colorScheme:"secondary",children:["Last used: ",l((0,eq.T)(n))]})]})})},rW=({passkey:e})=>{let{open:r}=(0,$.D5)(),t=e.id,n=[{label:(0,c.G)("userProfile.start.passkeysSection.menuAction__rename"),onClick:()=>r(`rename-${t}`)},{label:(0,c.G)("userProfile.start.passkeysSection.menuAction__destructive"),isDestructive:!0,onClick:()=>r(`remove-${t}`)}];return(0,i.Y)(R.o,{actions:n})},rN=({onClick:e})=>{let r=(0,d.f0)(),{isSatellite:t}=(0,v.ho)(),{user:n}=(0,v.Jd)(),l=(0,v.Wp)(()=>n?.createPasskey()),o=async()=>{if(e?.(),n)try{await l()}catch(e){(0,G.H4)(e,[],r.setError)}};return t?null:(0,i.Y)(D.rd.ArrowButton,{id:"passkeys",localizationKey:(0,c.G)("userProfile.start.passkeysSection.primaryButton"),onClick:o})};var rJ=t(3990),rq=t(620);let rU=(0,d.dm)(e=>{let{t:r,locale:t}=(0,eS._)(),{onSuccess:l,onReset:o}=e,{user:a}=(0,v.Jd)(),s=(0,v.Wp)((e,r)=>e.updatePassword(...r));if(!a)return null;let{userSettings:{passwordSettings:u},authConfig:{reverification:h}}=(0,Y.O)(),{session:m}=(0,v.wV)(),f=a.passwordEnabled?(0,c.G)("userProfile.passwordPage.title__update"):(0,c.G)("userProfile.passwordPage.title__set"),p=(0,d.f0)(),g=a.enterpriseAccounts.some(e=>e.active),P=a.passwordEnabled&&!h,b=(0,n.useRef)({title:(0,c.G)("userProfile.passwordPage.title__set")}),y=(0,ed.tJ)("currentPassword","",{type:"password",label:(0,c.G)("formFieldLabel__currentPassword"),isRequired:!0}),S=(0,ed.tJ)("newPassword","",{type:"password",label:(0,c.G)("formFieldLabel__newPassword"),isRequired:!0,validatePassword:!0,buildErrorMessage:e=>(0,rJ.C5)(e,{t:r,locale:t,passwordSettings:u})}),_=(0,ed.tJ)("confirmPassword","",{type:"password",label:(0,c.G)("formFieldLabel__confirmPassword"),isRequired:!0}),D=(0,ed.tJ)("signOutOfOtherSessions","",{type:"checkbox",label:(0,c.G)("formFieldLabel__signOutOfOtherSessions"),defaultChecked:!0}),{setConfirmPasswordFeedback:R,isPasswordMatch:w}=(0,rq.Z)({passwordField:S,confirmPasswordField:_}),C=(P?y.value&&w:w)&&S.value&&_.value,$=async()=>{if(C)try{var e,r;let t;b.current={title:a.passwordEnabled?(0,c.G)("userProfile.passwordPage.title__update"):(0,c.G)("userProfile.passwordPage.title__set"),text:(e=a.passwordEnabled,r=!!D.checked,t=[],e?t.push((0,c.G)("userProfile.passwordPage.successMessage__update")):t.push((0,c.G)("userProfile.passwordPage.successMessage__set")),r&&t.push((0,c.G)("userProfile.passwordPage.successMessage__signOutOfOtherSessions")),t)};let i={newPassword:S.value,signOutOfOtherSessions:D.checked,currentPassword:P?y.value:void 0};await s(a,[i]),l()}catch(e){(0,G.H4)(e,[y,S,_],p.setError)}};return(0,i.FD)(ec.M,{headerTitle:f,children:[g&&(0,i.Y)(ew.k,{message:(0,c.G)("userProfile.passwordPage.readonly")}),(0,i.FD)(ea.l.Root,{onSubmit:$,onBlur:()=>{S.value&&R(_.value)},children:[(0,i.Y)("input",{readOnly:!0,"data-testid":"hidden-identifier",id:"identifier-field",name:"identifier",value:m?.publicUserData.identifier||"",style:{display:"none"}}),P&&(0,i.Y)(ea.l.ControlRow,{elementId:y.id,children:(0,i.Y)(ea.l.PasswordInput,{...y.props,minLength:6,isRequired:!0,autoFocus:!0,isDisabled:g})}),(0,i.Y)(ea.l.ControlRow,{elementId:S.id,children:(0,i.Y)(ea.l.PasswordInput,{...S.props,minLength:6,isRequired:!0,autoFocus:!a.passwordEnabled,isDisabled:g})}),(0,i.Y)(ea.l.ControlRow,{elementId:_.id,children:(0,i.Y)(ea.l.PasswordInput,{..._.props,onChange:e=>(e.target.value&&R(e.target.value),_.props.onChange(e)),isRequired:!0,isDisabled:g})}),(0,i.Y)(ea.l.ControlRow,{elementId:D.id,children:(0,i.Y)(ea.l.Checkbox,{...D.props,description:(0,c.G)("userProfile.passwordPage.checkboxInfoText__signOutOfOtherSessions"),isDisabled:g})}),g?(0,i.Y)(es.c,{children:(0,i.Y)(ea.l.ResetButton,{localizationKey:(0,c.G)("userProfile.formButtonReset"),block:!1,onClick:o})}):(0,i.Y)(es.G,{isDisabled:!C,onReset:o})]})]})}),rj=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(rU,{onSuccess:e,onReset:e})},rH=()=>{let{user:e}=(0,v.Jd)();if(!e)return null;let{passwordEnabled:r}=e;return(0,i.Y)(D.rd.Root,{centered:!1,title:(0,c.G)("userProfile.start.passwordSection.title"),id:"password",children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"password",sx:e=>({paddingLeft:r?void 0:"0",paddingTop:e.space.$0x25,paddingBottom:e.space.$0x25}),children:[r&&(0,i.Y)(y.EY,{variant:"h2",children:"••••••••••"}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"password",localizationKey:r?(0,c.G)("userProfile.start.passwordSection.primaryButton__updatePassword"):(0,c.G)("userProfile.start.passwordSection.primaryButton__setPassword")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rj,{})})})]})})},rV=(0,d.dm)(()=>{let{attributes:e,instanceIsPasswordBased:r}=(0,Y.O)().userSettings,t=(0,d.f0)(),{user:n}=(0,v.Jd)(),{shouldAllowIdentificationCreation:l}=(0,a.B)(),o=e.passkey?.enabled&&l,s=H(e).length>0,u=n?.deleteSelfEnabled;return(0,i.Y)(y.fv,{elementDescriptor:S.$z.page,sx:e=>({gap:e.space.$8}),children:(0,i.FD)(y.fv,{elementDescriptor:S.$z.profilePage,elementId:S.$z.profilePage.setId("security"),children:[(0,i.Y)(b.Y.Root,{children:(0,i.Y)(b.Y.Title,{localizationKey:(0,c.G)("userProfile.start.headerTitle__security"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,i.Y)(P.Z.Alert,{children:t.error}),r&&(0,i.Y)(rH,{}),o&&(0,i.Y)(rK,{}),s&&(0,i.Y)(rx,{}),(0,i.Y)(eZ,{}),u&&(0,i.Y)(e6,{})]})})}),rZ=(0,n.lazy)(()=>Promise.all([t.e("666"),t.e("207"),t.e("259")]).then(t.bind(t,1608)).then(e=>({default:e.BillingPage}))),rX=(0,n.lazy)(()=>Promise.all([t.e("666"),t.e("326"),t.e("817")]).then(t.bind(t,8201)).then(e=>({default:e.APIKeysPage}))),rQ=(0,n.lazy)(()=>Promise.all([t.e("666"),t.e("970"),t.e("110")]).then(t.bind(t,7437)).then(e=>({default:e.PlansPage}))),r0=(0,n.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("627")]).then(t.bind(t,1666)).then(e=>({default:e.StatementPage}))),r1=(0,n.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("122")]).then(t.bind(t,4856)).then(e=>({default:e.PaymentAttemptPage}))),r2=()=>{let{pages:e,shouldShowBilling:r,apiKeysProps:t}=(0,a.B)(),{apiKeysSettings:o,commerceSettings:s}=(0,Y.O)(),c=e.routes[0].id===l.j2.ACCOUNT,d=e.routes[0].id===l.j2.SECURITY,u=e.routes[0].id===l.j2.BILLING,h=e.routes[0].id===l.j2.API_KEYS,p=e.contents?.map((e,r)=>{let t=!c&&!d&&0===r;return(0,i.Y)(f.q,{index:t,path:t?void 0:e.url,children:(0,i.Y)(g.H,{mount:e.mount,unmount:e.unmount})},`custom-page-${e.url}`)});return(0,i.FD)(m.d,{children:[p,(0,i.FD)(f.q,{children:[(0,i.Y)(f.q,{path:c?void 0:"account",children:(0,i.Y)(m.d,{children:(0,i.Y)(f.q,{index:!0,children:(0,i.Y)(eN,{})})})}),(0,i.Y)(f.q,{path:d?void 0:"security",children:(0,i.Y)(m.d,{children:(0,i.Y)(f.q,{index:!0,children:(0,i.Y)(rV,{})})})}),s.billing.user.enabled&&r?(0,i.Y)(f.q,{path:u?void 0:"billing",children:(0,i.FD)(m.d,{children:[(0,i.Y)(f.q,{index:!0,children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(rZ,{})})}),s.billing.user.hasPaidPlans?(0,i.Y)(f.q,{path:"plans",children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(rQ,{})})}):null,(0,i.Y)(f.q,{path:"statement/:statementId",children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(r0,{})})}),(0,i.Y)(f.q,{path:"payment-attempt/:paymentAttemptId",children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(r1,{})})})]})}):null,o.user_api_keys_enabled&&!t?.hide&&(0,i.Y)(f.q,{path:h?void 0:"api-keys",children:(0,i.Y)(m.d,{children:(0,i.Y)(f.q,{index:!0,children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(rX,{})})})})})]})]})};var r5=t(393);let r4=()=>(0,i.Y)(s.n.Root,{flow:"userProfile",children:(0,i.Y)(s.n.Part,{children:(0,i.FD)(m.d,{children:[(0,i.Y)(f.q,{path:"verify",children:(0,i.Y)(r5.G,{})}),(0,i.Y)(f.q,{children:(0,i.Y)(r3,{})})]})})}),r3=(0,o.G)(()=>{let e=n.useRef(null);return(0,i.Y)(h.a.Root,{children:(0,i.FD)(p,{contentRef:e,children:[(0,i.Y)(u.oT,{navbarTitleLocalizationKey:(0,c.G)("userProfile.navbar.title")}),(0,i.Y)(h.a.Content,{contentRef:e,scrollBoxId:l.AG,children:(0,i.Y)(r2,{})})]})})}),r6=(0,d.dm)(r4),r8=(0,d.dm)(r4),r7=e=>{let r={...e,routing:"virtual",componentName:"UserProfile",mode:"modal"};return(0,i.Y)(f.q,{path:"user",children:(0,i.Y)(a.M.Provider,{value:r,children:(0,i.Y)("div",{children:(0,i.Y)(r8,{...r})})})})}},9599:function(e,r,t){t.d(r,{g:()=>l});var i=t(1210),n=t(4964);let l=()=>{let{navigate:e}=(0,n.r)(),r=(0,i.ho)();return{navigateAfterSignOut:()=>e(r.buildAfterSignOutUrl()),navigateAfterMultiSessionSingleSignOutUrl:()=>e(r.buildAfterMultiSessionSingleSignOutUrl()),afterSignOutUrl:r.buildAfterSignOutUrl(),afterMultiSessionSingleSignOutUrl:r.buildAfterMultiSessionSingleSignOutUrl()}}}}]);
4
+ ${l}`)],{type:"text/plain"});o.href=URL.createObjectURL(a),o.download=`${n}_backup_codes.txt`,document.body.appendChild(o),o.click()},children:(0,i.Y)(y.In,{icon:rl.A})}),(0,i.Y)(y.$n,{variant:"ghost",sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),onClick:o,children:(0,i.Y)(y.In,{icon:ro.A})}),(0,i.Y)(y.$n,{variant:"ghost",onClick:s,sx:e=>({width:"100%",padding:`${e.space.$2} 0`,borderRadius:0}),children:(0,i.Y)(y.In,{icon:d?ra.A:rs.A})})]})]}),(0,i.FD)(ri.L,{...a,children:[(0,i.FD)(y.DZ,{children:["Your backup codes for ",n," account ",u,":"]}),(0,i.Y)(y.fv,{gap:2,children:t.map((e,r)=>(0,i.Y)(rc,{code:e},r))})]})]}):null},ru=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,{user:l}=(0,v.Jd)(),o=(0,d.f0)(),a=(0,v.Wp)(()=>l?.createBackupCode()),[s,u]=n.useState(void 0);return(n.useEffect(()=>{!s&&l&&a().then(e=>u(e)).catch(e=>{if((0,eE.I3)(e))return t();(0,G.H4)(e,[],o.setError)})},[]),o.error)?(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title")}):(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title"),children:s?(0,i.FD)(i.FK,{children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.successMessage")}),(0,i.Y)(rd,{subtitle:(0,c.G)("userProfile.backupCodePage.subtitle__codelist"),backupCodes:s.codes}),(0,i.Y)(es.c,{children:(0,i.Y)(y.$n,{autoFocus:!0,onClick:r,localizationKey:(0,c.G)("userProfile.formButtonPrimary__finish"),elementDescriptor:S.$z.formButtonPrimary})})]}):(0,i.Y)(eq.K,{})})}),rh=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,n=(0,eu.X)();return(0,i.FD)(eu.s,{...n.props,children:[(0,i.Y)(rf,{onContinue:n.nextStep}),(0,i.Y)(ru,{onSuccess:r,onReset:t})]})}),rf=e=>{let{onContinue:r}=e,{close:t}=(0,$.D5)();return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title"),children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.infoText1")}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.infoText2")}),(0,i.FD)(es.c,{sx:{marginTop:0},children:[(0,i.Y)(y.$n,{textVariant:"buttonSmall",onClick:r,localizationKey:(0,c.G)("userProfile.formButtonPrimary__finish"),elementDescriptor:S.$z.formButtonPrimary}),(0,i.Y)(y.$n,{variant:"ghost",onClick:t,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})]})]})};var rm=t(155),rp=t(6370),rg=t(9679);let rY=(0,d.dm)(e=>{let{onReset:r,onSuccess:t}=e,l=n.useRef(),o=(0,eu.X)({defaultStep:2}),a=(0,Y.O)().userSettings.attributes.backup_code?.enabled;return(0,i.FD)(eu.s,{...o.props,children:[(0,i.Y)(em,{title:(0,c.G)("userProfile.phoneNumberPage.title"),resourceRef:l,onSuccess:o.nextStep,onUseExistingNumberClick:()=>o.goToStep(2),onReset:r}),(0,i.Y)(rP,{title:(0,c.G)("userProfile.mfaPhoneCodePage.title"),resourceRef:l,onSuccess:()=>a?o.goToStep(3):t(),onReset:()=>o.goToStep(2)}),(0,i.Y)(rb,{onSuccess:a?o.nextStep:t,onReset:r,onAddPhoneClick:()=>o.goToStep(0),onUnverifiedPhoneClick:e=>{l.current=e,o.goToStep(1)},title:(0,c.G)("userProfile.mfaPhoneCodePage.title"),resourceRef:l}),a&&(0,i.Y)(rp.B,{title:(0,c.G)("userProfile.mfaPhoneCodePage.successTitle"),text:l.current?.backupCodes&&l.current?.backupCodes.length>0?[(0,c.G)("userProfile.mfaPhoneCodePage.successMessage1"),(0,c.G)("userProfile.mfaPhoneCodePage.successMessage2")]:[(0,c.G)("userProfile.mfaPhoneCodePage.successMessage1")],onFinish:r,contents:(0,i.Y)(rd,{backupCodes:l.current?.backupCodes})})]})}),rv=e=>{let{phone:r,onSuccess:t,onUnverifiedPhoneClick:n,resourceRef:l}=e,o=(0,d.f0)(),a=(0,v.Wp)(()=>r.setReservedForSecondFactor({reserved:!0})),{country:s}=(0,eo.Mz)(r.phoneNumber),c=(0,eo.Om)(r.phoneNumber),u=async()=>{if("verified"!==r.verification.status)return n(r);o.setLoading(r.id);try{await a(),l.current=r,t()}catch(e){(0,G.H4)(e,[],o.setError)}finally{o.setIdle()}};return(0,i.FD)(y.$n,{variant:"outline",colorScheme:"neutral",sx:{justifyContent:"start"},onClick:u,isLoading:o.loadingMetadata===r.id,isDisabled:o.isLoading,children:[s.iso.toUpperCase()," ",c]},r.id)},rP=e=>{let{title:r,onSuccess:t,resourceRef:n,onReset:l}=e,o=(0,d.f0)(),a=n.current,s=(0,v.Wp)(()=>a?.setReservedForSecondFactor({reserved:!0})),u=async()=>{o.setLoading(a?.id);try{await s(),n.current=a,t()}catch(e){(0,G.H4)(e,[],o.setError)}finally{o.setIdle()}};return(0,i.Y)(ec.M,{headerTitle:r,headerSubtitle:(0,c.G)("userProfile.phoneNumberPage.verifySubtitle",{identifier:n.current?.phoneNumber||""}),children:(0,i.Y)(eh.j,{nextStep:()=>{u()},identification:n.current,identifier:n.current?.phoneNumber,prepareVerification:n.current?.prepareVerification,onReset:l})})},rb=e=>{let{onSuccess:r,onReset:t,title:n,onAddPhoneClick:l,onUnverifiedPhoneClick:o,resourceRef:a}=e,{user:s}=(0,v.Jd)();if(!s)return null;let d=s.phoneNumbers.filter(e=>!e.reservedForSecondFactor);return(0,i.FD)(ec.M,{headerTitle:n,gap:1,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)(d.length?"userProfile.mfaPhoneCodePage.subtitle__availablePhoneNumbers":"userProfile.mfaPhoneCodePage.subtitle__unavailablePhoneNumbers"),colorScheme:"secondary"}),d.length>0&&(0,i.Y)(y.fv,{gap:2,children:d.map(e=>(0,i.Y)(rv,{onSuccess:r,phone:e,onUnverifiedPhoneClick:o,resourceRef:a},e.id))}),(0,i.FD)(es.c,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[(0,i.Y)(rm.K,{variant:"ghost","aria-label":"Add phone number",icon:(0,i.Y)(y.In,{icon:rg.A,sx:e=>({marginRight:e.space.$2})}),localizationKey:(0,c.G)("userProfile.mfaPhoneCodePage.primaryButton__addPhoneNumber"),onClick:l}),(0,i.Y)(y.$n,{variant:"ghost",localizationKey:(0,c.G)("userProfile.formButtonReset"),onClick:t})]})]})};var ry=t(5559),rS=t(2094);let r_=(0,d.dm)(e=>{let{title:r,onSuccess:t,onReset:l}=e,{user:o}=(0,v.Jd)(),a=(0,d.f0)(),s=(0,v.Wp)(()=>o?.createTOTP()),{close:u}=(0,$.D5)(),[h,f]=n.useState(void 0),[m,p]=n.useState("qr");return(n.useEffect(()=>{o&&s().then(e=>f(e)).catch(e=>(0,eE.Cm)(e)&&"reverification_cancelled"===e.code?u():(0,G.H4)(e,[],a.setError))},[]),a.error)?(0,i.Y)(ec.M,{headerTitle:r}):(0,i.FD)(ec.M,{headerTitle:r,headerSubtitle:"qr"==m?(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.infoText__ableToScan"):(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.infoText__unableToScan"),children:[!h&&(0,i.Y)(eq.K,{}),h&&(0,i.FD)(i.FK,{children:[(0,i.FD)(y.fv,{gap:4,children:["qr"==m&&(0,i.Y)(rS.r,{justify:"center",url:h.uri||""}),"uri"==m&&(0,i.FD)(i.FK,{children:[(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan1")}),(0,i.Y)(ry.r,{value:h.secret}),(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan2")}),(0,i.Y)(ry.r,{value:h.uri})]})]}),(0,i.FD)(y.so,{justify:"between",align:"center",sx:{width:"100%"},children:["qr"==m&&(0,i.Y)(y.$n,{variant:"link",textVariant:"buttonLarge",onClick:()=>p("uri"),localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.buttonUnableToScan__nonPrimary")}),"uri"==m&&(0,i.Y)(y.$n,{variant:"link",textVariant:"buttonLarge",onClick:()=>p("qr"),localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.buttonAbleToScan__nonPrimary")}),(0,i.FD)(es.c,{children:[(0,i.Y)(y.$n,{onClick:t,localizationKey:(0,c.G)("userProfile.formButtonPrimary__continue"),elementDescriptor:S.$z.formButtonPrimary}),(0,i.Y)(y.$n,{variant:"ghost",onClick:l,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})]})]})]})]})});var rD=t(3356);let rR=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,resourceRef:n}=e,{user:l}=(0,v.Jd)(),o=(0,rD.xM)({onCodeEntryFinished:(e,r,t)=>{l?.verifyTOTP({code:e}).then(e=>r(e)).catch(t)},onResolve:e=>{n.current=e,r()}});return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.mfaTOTPPage.title"),children:[(0,i.Y)(y.fv,{children:(0,i.Y)(ea.l.OTPInput,{...o,label:(0,c.G)("userProfile.mfaTOTPPage.verifyTitle"),description:(0,c.G)("userProfile.mfaTOTPPage.verifySubtitle")})}),(0,i.Y)(es.c,{sx:{marginTop:0},children:(0,i.Y)(y.$n,{onClick:t,variant:"ghost",isDisabled:o.isLoading,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})})]})}),rG=(0,d.dm)(e=>{let{onReset:r}=e,t=(0,eu.X)(),l=n.useRef();return(0,i.FD)(eu.s,{...t.props,children:[(0,i.Y)(r_,{title:(0,c.G)("userProfile.mfaTOTPPage.title"),onSuccess:t.nextStep,onReset:r}),(0,i.Y)(rR,{onSuccess:t.nextStep,onReset:r,resourceRef:l}),(0,i.Y)(rp.B,{title:(0,c.G)("userProfile.mfaTOTPPage.title"),text:(0,c.G)("userProfile.mfaTOTPPage.successMessage"),onFinish:r,contents:(0,i.Y)(rd,{subtitle:(0,c.G)("userProfile.backupCodePage.successSubtitle"),backupCodes:l.current?.backupCodes})})]})}),rw=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,selectedStrategy:l}=e,o=(0,d.f0)(),{userSettings:{attributes:a}}=(0,Y.O)(),{user:s}=(0,v.Jd)();if(!s)return null;let u=(0,c.G)("userProfile.mfaPage.title"),h=n.useMemo(()=>V(a,s),[]);return(n.useEffect(()=>{0===h.length&&o.setError("There are no second factors available to add")},[]),o.error)?(0,i.Y)(ec.M,{headerTitle:u}):0!==h.length||l?(0,i.Y)(rC,{onSuccess:r,onReset:t,method:l||h[0]}):null}),rC=e=>{let{method:r,onSuccess:t,onReset:n}=e;switch(r){case"phone_code":return(0,i.Y)(rY,{onSuccess:t,onReset:n});case"totp":return(0,i.Y)(rG,{onSuccess:t,onReset:n});case"backup_code":return(0,i.Y)(rh,{onSuccess:t,onReset:n});default:return null}},r$=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(B,{onSuccess:e,onReset:e})},rF=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(K,{onSuccess:r,onReset:r,...e})},rI=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(ru,{onSuccess:e,onReset:e})},rk=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(rw,{onSuccess:r,onReset:r,selectedStrategy:e.selectedStrategy})},rx=()=>{let{userSettings:{attributes:e}}=(0,Y.O)(),{user:r}=(0,v.Jd)(),[t,l]=(0,n.useState)(null);if(!r)return null;let o=H(e),a=V(e,r),s=o.includes("totp")&&r.totpEnabled,d=o.includes("backup_code")&&r.backupCodeEnabled,u=r.phoneNumbers.filter(e=>"verified"===e.verification.status).filter(e=>e.reservedForSecondFactor).sort(j);return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.mfaSection.title"),centered:!1,id:"mfa",children:(0,i.Y)(C.r.Root,{value:t,onChange:l,children:(0,i.FD)(D.rd.ItemList,{id:"mfa",children:[s&&(0,i.FD)(i.FK,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:e9.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.start.mfaSection.totp.headerTitle")}),(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__default")})]}),(0,i.Y)(rT,{})]}),(0,i.Y)(C.r.Open,{value:"remove-totp",children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(r$,{})})})]}),o.includes("phone_code")&&u.map(e=>{let r=!s&&e.defaultSecondFactor,t=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:re.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.FD)(y.EY,{children:["SMS Code ",(0,i.Y)(e7.R,{value:e.phoneNumber})]}),r&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__default")})]}),(0,i.Y)(rA,{phone:e,showTOTP:s})]}),(0,i.Y)(C.r.Open,{value:`remove-${t}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(rF,{phoneId:t})})})]},t)}),d&&(0,i.FD)(i.FK,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:rr.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.start.mfaSection.backupCodes.headerTitle")})]}),(0,i.Y)(rz,{})]}),(0,i.Y)(C.r.Open,{value:"regenerate",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rI,{})})})]}),(0,i.Y)(rE,{secondFactorsAvailableToAdd:a,onClick:()=>l(null)})]})})})},rA=({phone:e,showTOTP:r})=>{let{open:t}=(0,$.D5)(),n=(0,d.f0)(),l=e.id,o=[!r&&!e.defaultSecondFactor?{label:(0,c.G)("userProfile.start.mfaSection.phoneCode.actionLabel__setDefault"),onClick:()=>e.makeDefaultSecondFactor().catch(e=>(0,G.H4)(e,[],n.setError))}:null,{label:(0,c.G)("userProfile.start.mfaSection.phoneCode.destructiveActionLabel"),isDestructive:!0,onClick:()=>t(`remove-${l}`)}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:o})},rz=()=>{let{open:e}=(0,$.D5)(),r=[{label:(0,c.G)("userProfile.start.mfaSection.backupCodes.actionLabel__regenerate"),onClick:()=>e("regenerate")}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})},rT=()=>{let{open:e}=(0,$.D5)(),r=[{label:(0,c.G)("userProfile.start.mfaSection.totp.destructiveActionTitle"),isDestructive:!0,onClick:()=>e("remove-totp")}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})},rE=e=>{let{open:r}=(0,$.D5)(),{secondFactorsAvailableToAdd:t,onClick:l}=e,[o,a]=(0,n.useState)(),s=n.useMemo(()=>t.map(e=>"phone_code"===e?{icon:re.A,text:"SMS code",key:"phone_code"}:"totp"===e?{icon:e9.A,text:"Authenticator application",key:"totp"}:"backup_code"===e?{icon:rr.A,text:"Backup code",key:"backup_code"}:null).filter(e=>null!==e),[t]);return(0,i.FD)(i.FK,{children:[t.length>0&&(0,i.Y)(C.r.Closed,{value:"multi-factor",children:(0,i.Y)(D.rd.ActionMenu,{id:"mfa",triggerLocalizationKey:(0,c.G)("userProfile.start.mfaSection.primaryButton"),onClick:l,children:s.map(e=>e&&(0,i.Y)(D.rd.ActionMenuItem,{id:e.key,localizationKey:e.text,leftIcon:e.icon,onClick:()=>{a(e.key),r("multi-factor")}},e.key))})}),(0,i.Y)(C.r.Open,{value:"multi-factor",children:(0,i.Y)(C.r.Card,{children:o&&(0,i.Y)(rk,{selectedStrategy:o})})})]})},rL=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(W,{onSuccess:r,onReset:r,...e})},rO=e=>{let{close:r}=(0,$.D5)();return(0,i.Y)(rK,{onSuccess:r,onReset:r,passkey:e.passkey})},rK=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,passkey:n}=e,l=(0,d.f0)(),o=(0,ed.tJ)("passkeyName",n.name||"",{type:"text",label:(0,c.G)("formFieldLabel__passkeyName"),isRequired:!0}),a=o.value.length>1&&n.name!==o.value,s=async e=>(e.preventDefault(),n.update({name:o.value}).then(r).catch(e=>(0,G.H4)(e,[o],l.setError)));return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.passkeyScreen.title__rename"),headerSubtitle:(0,c.G)("userProfile.passkeyScreen.subtitle__rename"),children:(0,i.FD)(ea.l.Root,{onSubmit:s,children:[(0,i.Y)(ea.l.ControlRow,{elementId:o.id,children:(0,i.Y)(ea.l.PlainInput,{...o.props,autoComplete:"off"})}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.formButtonPrimary__save"),isDisabled:!a,onReset:t})]})})}),rB=()=>{let{user:e}=(0,v.Jd)(),[r,t]=(0,n.useState)(null);return e?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.passkeysSection.title"),centered:!1,id:"passkeys",children:(0,i.Y)(C.r.Root,{value:r,onChange:t,children:(0,i.FD)(D.rd.ItemList,{id:"passkeys",children:[e.passkeys.map(e=>{let r=e.id;return(0,i.FD)(n.Fragment,{children:[(0,i.Y)(rW,{...e},r),(0,i.Y)(C.r.Open,{value:`remove-${r}`,children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(rL,{passkey:e})})}),(0,i.Y)(C.r.Open,{value:`rename-${r}`,children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rO,{passkey:e})})})]},r)}),(0,i.Y)(rJ,{onClick:()=>t(null)})]})})}):null},rW=e=>(0,i.FD)(D.rd.Item,{id:"passkeys",hoverable:!0,sx:{alignItems:"flex-start"},children:[(0,i.Y)(rM,{...e}),(0,i.Y)(rN,{passkey:e})]}),rM=e=>{let{name:r,createdAt:t,lastUsedAt:n}=e,{t:l}=(0,eS._)();return(0,i.Y)(y.so,{sx:e=>({width:"100%",overflow:"hidden",gap:e.space.$4,[eb.g.sm]:{gap:e.space.$2}}),children:(0,i.FD)(y.fv,{align:"start",gap:1,children:[(0,i.Y)(y.EY,{children:r}),(0,i.FD)(y.EY,{colorScheme:"secondary",children:["Created: ",l((0,eU.T)(t))]}),n&&(0,i.FD)(y.EY,{colorScheme:"secondary",children:["Last used: ",l((0,eU.T)(n))]})]})})},rN=({passkey:e})=>{let{open:r}=(0,$.D5)(),t=e.id,n=[{label:(0,c.G)("userProfile.start.passkeysSection.menuAction__rename"),onClick:()=>r(`rename-${t}`)},{label:(0,c.G)("userProfile.start.passkeysSection.menuAction__destructive"),isDestructive:!0,onClick:()=>r(`remove-${t}`)}];return(0,i.Y)(R.o,{actions:n})},rJ=({onClick:e})=>{let r=(0,d.f0)(),{isSatellite:t}=(0,v.ho)(),{user:n}=(0,v.Jd)(),l=(0,v.Wp)(()=>n?.createPasskey()),o=async()=>{if(e?.(),n)try{await l()}catch(e){(0,G.H4)(e,[],r.setError)}};return t?null:(0,i.Y)(D.rd.ArrowButton,{id:"passkeys",localizationKey:(0,c.G)("userProfile.start.passkeysSection.primaryButton"),onClick:o})};var rq=t(3990),rU=t(620);let rj=(0,d.dm)(e=>{let{t:r,locale:t}=(0,eS._)(),{onSuccess:l,onReset:o}=e,{user:a}=(0,v.Jd)(),s=(0,v.Wp)((e,r)=>e.updatePassword(...r));if(!a)return null;let{userSettings:{passwordSettings:u},authConfig:{reverification:h}}=(0,Y.O)(),{session:f}=(0,v.wV)(),m=a.passwordEnabled?(0,c.G)("userProfile.passwordPage.title__update"):(0,c.G)("userProfile.passwordPage.title__set"),p=(0,d.f0)(),g=a.enterpriseAccounts.some(e=>e.active),P=a.passwordEnabled&&!h,b=(0,n.useRef)({title:(0,c.G)("userProfile.passwordPage.title__set")}),y=(0,ed.tJ)("currentPassword","",{type:"password",label:(0,c.G)("formFieldLabel__currentPassword"),isRequired:!0}),S=(0,ed.tJ)("newPassword","",{type:"password",label:(0,c.G)("formFieldLabel__newPassword"),isRequired:!0,validatePassword:!0,buildErrorMessage:e=>(0,rq.C5)(e,{t:r,locale:t,passwordSettings:u})}),_=(0,ed.tJ)("confirmPassword","",{type:"password",label:(0,c.G)("formFieldLabel__confirmPassword"),isRequired:!0}),D=(0,ed.tJ)("signOutOfOtherSessions","",{type:"checkbox",label:(0,c.G)("formFieldLabel__signOutOfOtherSessions"),defaultChecked:!0}),{setConfirmPasswordFeedback:R,isPasswordMatch:w}=(0,rU.Z)({passwordField:S,confirmPasswordField:_}),C=(P?y.value&&w:w)&&S.value&&_.value,$=async()=>{if(C)try{var e,r;let t;b.current={title:a.passwordEnabled?(0,c.G)("userProfile.passwordPage.title__update"):(0,c.G)("userProfile.passwordPage.title__set"),text:(e=a.passwordEnabled,r=!!D.checked,t=[],e?t.push((0,c.G)("userProfile.passwordPage.successMessage__update")):t.push((0,c.G)("userProfile.passwordPage.successMessage__set")),r&&t.push((0,c.G)("userProfile.passwordPage.successMessage__signOutOfOtherSessions")),t)};let i={newPassword:S.value,signOutOfOtherSessions:D.checked,currentPassword:P?y.value:void 0};await s(a,[i]),l()}catch(e){(0,G.H4)(e,[y,S,_],p.setError)}};return(0,i.FD)(ec.M,{headerTitle:m,children:[g&&(0,i.Y)(ew.k,{message:(0,c.G)("userProfile.passwordPage.readonly")}),(0,i.FD)(ea.l.Root,{onSubmit:$,onBlur:()=>{S.value&&R(_.value)},children:[(0,i.Y)("input",{readOnly:!0,"data-testid":"hidden-identifier",id:"identifier-field",name:"identifier",value:f?.publicUserData.identifier||"",style:{display:"none"}}),P&&(0,i.Y)(ea.l.ControlRow,{elementId:y.id,children:(0,i.Y)(ea.l.PasswordInput,{...y.props,minLength:6,isRequired:!0,autoFocus:!0,isDisabled:g})}),(0,i.Y)(ea.l.ControlRow,{elementId:S.id,children:(0,i.Y)(ea.l.PasswordInput,{...S.props,minLength:6,isRequired:!0,autoFocus:!a.passwordEnabled,isDisabled:g})}),(0,i.Y)(ea.l.ControlRow,{elementId:_.id,children:(0,i.Y)(ea.l.PasswordInput,{..._.props,onChange:e=>(e.target.value&&R(e.target.value),_.props.onChange(e)),isRequired:!0,isDisabled:g})}),(0,i.Y)(ea.l.ControlRow,{elementId:D.id,children:(0,i.Y)(ea.l.Checkbox,{...D.props,description:(0,c.G)("userProfile.passwordPage.checkboxInfoText__signOutOfOtherSessions"),isDisabled:g})}),g?(0,i.Y)(es.c,{children:(0,i.Y)(ea.l.ResetButton,{localizationKey:(0,c.G)("userProfile.formButtonReset"),block:!1,onClick:o})}):(0,i.Y)(es.G,{isDisabled:!C,onReset:o})]})]})}),rH=()=>{let{close:e}=(0,$.D5)();return(0,i.Y)(rj,{onSuccess:e,onReset:e})},rV=()=>{let{user:e}=(0,v.Jd)();if(!e)return null;let{passwordEnabled:r}=e;return(0,i.Y)(D.rd.Root,{centered:!1,title:(0,c.G)("userProfile.start.passwordSection.title"),id:"password",children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"password",sx:e=>({paddingLeft:r?void 0:"0",paddingTop:e.space.$0x25,paddingBottom:e.space.$0x25}),children:[r&&(0,i.Y)(y.EY,{variant:"h2",children:"••••••••••"}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"password",localizationKey:r?(0,c.G)("userProfile.start.passwordSection.primaryButton__updatePassword"):(0,c.G)("userProfile.start.passwordSection.primaryButton__setPassword")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rH,{})})})]})})},rZ=(0,d.dm)(()=>{let{attributes:e,instanceIsPasswordBased:r}=(0,Y.O)().userSettings,t=(0,d.f0)(),{user:n}=(0,v.Jd)(),{shouldAllowIdentificationCreation:l}=(0,a.B)(),o=e.passkey?.enabled&&l,s=H(e).length>0,u=n?.deleteSelfEnabled;return(0,i.Y)(y.fv,{elementDescriptor:S.$z.page,sx:e=>({gap:e.space.$8}),children:(0,i.FD)(y.fv,{elementDescriptor:S.$z.profilePage,elementId:S.$z.profilePage.setId("security"),children:[(0,i.Y)(b.Y.Root,{children:(0,i.Y)(b.Y.Title,{localizationKey:(0,c.G)("userProfile.start.headerTitle__security"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,i.Y)(P.Z.Alert,{children:t.error}),r&&(0,i.Y)(rV,{}),o&&(0,i.Y)(rB,{}),s&&(0,i.Y)(rx,{}),(0,i.Y)(eX,{}),u&&(0,i.Y)(e8,{})]})})}),rX=(0,n.lazy)(()=>Promise.all([t.e("666"),t.e("207"),t.e("259")]).then(t.bind(t,1608)).then(e=>({default:e.BillingPage}))),rQ=(0,n.lazy)(()=>Promise.all([t.e("666"),t.e("326"),t.e("817")]).then(t.bind(t,8201)).then(e=>({default:e.APIKeysPage}))),r0=(0,n.lazy)(()=>Promise.all([t.e("666"),t.e("970"),t.e("110")]).then(t.bind(t,7437)).then(e=>({default:e.PlansPage}))),r1=(0,n.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("627")]).then(t.bind(t,1666)).then(e=>({default:e.StatementPage}))),r2=(0,n.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("122")]).then(t.bind(t,4856)).then(e=>({default:e.PaymentAttemptPage}))),r5=()=>{let{pages:e,shouldShowBilling:r,apiKeysProps:t}=(0,a.B)(),{apiKeysSettings:o,commerceSettings:s}=(0,Y.O)(),c=e.routes[0].id===l.j2.ACCOUNT,d=e.routes[0].id===l.j2.SECURITY,u=e.routes[0].id===l.j2.BILLING,h=e.routes[0].id===l.j2.API_KEYS,p=e.contents?.map((e,r)=>{let t=!c&&!d&&0===r;return(0,i.Y)(m.q,{index:t,path:t?void 0:e.url,children:(0,i.Y)(g.H,{mount:e.mount,unmount:e.unmount})},`custom-page-${e.url}`)});return(0,i.FD)(f.d,{children:[p,(0,i.FD)(m.q,{children:[(0,i.Y)(m.q,{path:c?void 0:"account",children:(0,i.Y)(f.d,{children:(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(eJ,{})})})}),(0,i.Y)(m.q,{path:d?void 0:"security",children:(0,i.Y)(f.d,{children:(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(rZ,{})})})}),s.billing.user.enabled&&r?(0,i.Y)(m.q,{path:u?void 0:"billing",children:(0,i.FD)(f.d,{children:[(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(rX,{})})}),s.billing.user.hasPaidPlans?(0,i.Y)(m.q,{path:"plans",children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(r0,{})})}):null,(0,i.Y)(m.q,{path:"statement/:statementId",children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(r1,{})})}),(0,i.Y)(m.q,{path:"payment-attempt/:paymentAttemptId",children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(r2,{})})})]})}):null,o.user_api_keys_enabled&&!t?.hide&&(0,i.Y)(m.q,{path:h?void 0:"api-keys",children:(0,i.Y)(f.d,{children:(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(n.Suspense,{fallback:"",children:(0,i.Y)(rQ,{})})})})})]})]})};var r4=t(393);let r3=()=>(0,i.Y)(s.n.Root,{flow:"userProfile",children:(0,i.Y)(s.n.Part,{children:(0,i.FD)(f.d,{children:[(0,i.Y)(m.q,{path:"verify",children:(0,i.Y)(r4.G,{})}),(0,i.Y)(m.q,{children:(0,i.Y)(r6,{})})]})})}),r6=(0,o.G)(()=>{let e=n.useRef(null);return(0,i.Y)(h.a.Root,{children:(0,i.FD)(p,{contentRef:e,children:[(0,i.Y)(u.oT,{navbarTitleLocalizationKey:(0,c.G)("userProfile.navbar.title")}),(0,i.Y)(h.a.Content,{contentRef:e,scrollBoxId:l.AG,children:(0,i.Y)(r5,{})})]})})}),r8=(0,d.dm)(r3),r7=(0,d.dm)(r3),r9=e=>{let r={...e,routing:"virtual",componentName:"UserProfile",mode:"modal"};return(0,i.Y)(m.q,{path:"user",children:(0,i.Y)(a.M.Provider,{value:r,children:(0,i.Y)("div",{children:(0,i.Y)(r7,{...r})})})})}},9599:function(e,r,t){t.d(r,{g:()=>l});var i=t(1210),n=t(4964);let l=()=>{let{navigate:e}=(0,n.r)(),r=(0,i.ho)();return{navigateAfterSignOut:()=>e(r.buildAfterSignOutUrl()),navigateAfterMultiSessionSingleSignOutUrl:()=>e(r.buildAfterMultiSessionSingleSignOutUrl()),afterSignOutUrl:r.buildAfterSignOutUrl(),afterMultiSessionSingleSignOutUrl:r.buildAfterMultiSessionSingleSignOutUrl()}}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["718"],{34484:function(e,r,t){t.r(r),t.d(r,{UserProfile:()=>r9,UserProfileModal:()=>r7});var i=t(14518),l=t(35074),n=t(21227),o=t(43264),a=t(85240),s=t(44607),c=t(22861),d=t(63269),u=t(9764),h=t(65396),f=t(80212),m=t(42265);t(19161),t(95055);let p=e=>{let{pages:r,apiKeysProps:t}=(0,a.B)(),l=r.routes.filter(e=>e.id!==n.j2.API_KEYS||!(null==t?void 0:t.hide));return(0,i.FD)(u.XM,{contentRef:e.contentRef,children:[(0,i.Y)(u.jq,{title:(0,c.G)("userProfile.navbar.title"),description:(0,c.G)("userProfile.navbar.description"),routes:l,contentRef:e.contentRef}),e.children]})};t(50036),t(22239);var v=t(50540),g=t(97697),Y=t(21210),P=t(23707),b=t(76153),y=t(18272),S=t(58920);t(88711),t(30945),t(22501);var _=t(51421),D=t(44003),R=t(48080),G=t(4468),w=t(62660),C=t(93453),F=t(92513),I=t(19835),k=t(4964);t(58910);var x=t(6735);let A=e=>{let{strategy:r}=e,t=(0,d.f0)(),{user:l}=(0,Y.Jd)(),{navigate:n}=(0,k.r)(),{strategyToDisplayData:o}=(0,I.k)(),{additionalOAuthScopes:s,componentName:u,mode:h}=(0,a.B)(),f="modal"===h,m=(0,Y.Wp)(()=>{let e=r.replace("oauth_",""),t=f?(0,_.j)({url:window.location.href,componentName:u,socialProvider:e}):window.location.href,i=s?s[e]:[];return null==l?void 0:l.createExternalAccount({strategy:r,redirectUrl:t,additionalScopes:i})}),p=o[r].iconUrl?(0,i.Y)(y._V,{isLoading:t.loadingMetadata===r,isDisabled:t.isLoading,elementDescriptor:S.$z.providerIcon,elementId:S.$z.providerIcon.setId(o[r].id),src:o[r].iconUrl,alt:"Connect ".concat(o[r].name," account"),sx:e=>({width:e.sizes.$4})}):(0,i.Y)(w.T,{id:o[r].id,value:o[r].name,isLoading:t.loadingMetadata===r,isDisabled:t.isLoading});return(0,i.Y)(D.rd.ActionMenuItem,{id:o[r].id,onClick:()=>{if(l)return t.setLoading(r),m().then(e=>{var i;e&&(null==(i=e.verification)?void 0:i.externalVerificationRedirectURL)&&((0,x.y)(2e3).then(()=>t.setIdle(r)),n(e.verification.externalVerificationRedirectURL.href))}).catch(e=>{(0,G.H4)(e,[],t.setError),t.setIdle(r)})},isDisabled:t.isLoading,variant:"ghost",isLoading:t.loadingMetadata===r,focusRing:!1,closeAfterClick:!1,localizationKey:(0,c.G)("userProfile.connectedAccountPage.socialButtonsBlockButton",{provider:o[r].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:p},r)},z=e=>{let{onClick:r}=e,{user:t}=(0,Y.Jd)(),{strategies:l}=(0,I.k)(),n=l.filter(e=>e.startsWith("oauth")),o=null==t?void 0:t.verifiedExternalAccounts.map(e=>"oauth_".concat(e.provider)),a=n.filter(e=>!o.includes(e));return 0===a.length?null:(0,i.Y)(D.rd.ActionMenu,{triggerLocalizationKey:(0,c.G)("userProfile.start.connectedAccountsSection.primaryButton"),id:"connectedAccounts",onClick:r,children:a.map(e=>(0,i.Y)(A,{strategy:e},e))})};t(85074);var T=t(88046);let $=e=>{var r;let{onSuccess:t,onReset:n}=e,{user:o}=(0,Y.Jd)(),{emailId:a}=e,s=null==o?void 0:o.emailAddresses.find(e=>e.id===a),d=l.useRef(null==s?void 0:s.emailAddress),u=(null==s||null==(r=s.verification)?void 0:r.status)==="verified"?(0,c.G)("userProfile.emailAddressPage.removeResource.messageLine2"):void 0;return d.current?(0,i.Y)(T.P,{title:(0,c.G)("userProfile.emailAddressPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.emailAddressPage.removeResource.messageLine1",{identifier:d.current}),messageLine2:u,successMessage:(0,c.G)("userProfile.emailAddressPage.removeResource.successMessage",{emailAddress:d.current}),deleteResource:()=>Promise.resolve(null==s?void 0:s.destroy()),onSuccess:t,onReset:n}):null},E=e=>{var r;let{phoneId:t,onSuccess:n,onReset:o}=e,{user:a}=(0,Y.Jd)(),s=null==a?void 0:a.phoneNumbers.find(e=>e.id===t),d=l.useRef(null==s?void 0:s.phoneNumber),u=(null==s||null==(r=s.verification)?void 0:r.status)==="verified"?(0,c.G)("userProfile.phoneNumberPage.removeResource.messageLine2"):void 0;return d.current?(0,i.Y)(T.P,{title:(0,c.G)("userProfile.phoneNumberPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.phoneNumberPage.removeResource.messageLine1",{identifier:d.current}),messageLine2:u,successMessage:(0,c.G)("userProfile.phoneNumberPage.removeResource.successMessage",{phoneNumber:d.current}),deleteResource:()=>Promise.resolve(null==s?void 0:s.destroy()),onSuccess:n,onReset:o}):null},L=e=>{var r,t;let{accountId:n,onSuccess:o,onReset:a}=e,{user:s}=(0,Y.Jd)(),d=null==s?void 0:s.externalAccounts.find(e=>e.id===n),u=l.useRef(null==d?void 0:d.provider),{providerToDisplayData:h}=(0,I.k)();return u.current?(0,i.Y)(T.P,{title:(0,c.G)("userProfile.connectedAccountPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.connectedAccountPage.removeResource.messageLine1",{identifier:(null==(r=h[u.current])?void 0:r.name)||""}),messageLine2:(0,c.G)("userProfile.connectedAccountPage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.connectedAccountPage.removeResource.successMessage",{connectedAccount:(null==(t=h[u.current])?void 0:t.name)||""}),deleteResource:()=>Promise.resolve(null==d?void 0:d.destroy()),onSuccess:o,onReset:a}):null},O=e=>{var r;let{user:t}=(0,Y.Jd)(),{walletId:n,onSuccess:o,onReset:a}=e,s=null==t?void 0:t.web3Wallets.find(e=>e.id===n),d=l.useRef(null==s?void 0:s.web3Wallet),u=(null==s||null==(r=s.verification)?void 0:r.status)==="verified"?(0,c.G)("userProfile.web3WalletPage.removeResource.messageLine2"):void 0;return d.current?(0,i.Y)(T.P,{title:(0,c.G)("userProfile.web3WalletPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.web3WalletPage.removeResource.messageLine1",{identifier:d.current}),messageLine2:u,successMessage:(0,c.G)("userProfile.web3WalletPage.removeResource.successMessage",{web3Wallet:d.current}),deleteResource:()=>Promise.resolve(null==s?void 0:s.destroy()),onSuccess:o,onReset:a}):null},K=e=>{let{user:r}=(0,Y.Jd)(),{phoneId:t,onSuccess:n,onReset:o}=e,a=null==r?void 0:r.phoneNumbers.find(e=>e.id===t),s=l.useRef(null==a?void 0:a.phoneNumber);return s.current?(0,i.Y)(T.P,{title:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.title"),messageLine1:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.messageLine1",{identifier:s.current}),messageLine2:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.mfaPhoneCodePage.removeResource.successMessage",{mfaPhoneCode:s.current}),deleteResource:()=>Promise.resolve(null==a?void 0:a.setReservedForSecondFactor({reserved:!1})),onSuccess:n,onReset:o}):null},B=e=>{let{onSuccess:r,onReset:t}=e,{user:l}=(0,Y.Jd)();return l?(0,i.Y)(T.P,{title:(0,c.G)("userProfile.mfaTOTPPage.removeResource.title"),messageLine1:(0,c.G)("userProfile.mfaTOTPPage.removeResource.messageLine1"),messageLine2:(0,c.G)("userProfile.mfaTOTPPage.removeResource.messageLine2"),successMessage:(0,c.G)("userProfile.mfaTOTPPage.removeResource.successMessage"),deleteResource:l.disableTOTP,onSuccess:r,onReset:t}):null},W=e=>{let{onSuccess:r,onReset:t,passkey:l}=e;return(0,i.Y)(T.P,{title:(0,c.G)("userProfile.passkeyScreen.removeResource.title"),messageLine1:(0,c.G)("userProfile.passkeyScreen.removeResource.messageLine1",{name:l.name||""}),deleteResource:l.delete,onSuccess:r,onReset:t})},M=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(L,{onSuccess:r,onReset:r,...e})},N=["external_account_missing_refresh_token","oauth_fetch_user_error","oauth_token_exchange_error","external_account_email_address_verification_required"],J=(0,d.dm)(e=>{var r;let{shouldAllowCreation:t=!0}=e,{user:n}=(0,Y.Jd)(),o=(0,d.f0)(),a=!!(null==n||null==(r=n.externalAccounts)?void 0:r.length),[s,u]=(0,l.useState)(null);if(!n||!t&&!a)return null;let h=[...n.verifiedExternalAccounts,...n.unverifiedExternalAccounts.filter(e=>{var r;return null==(r=e.verification)?void 0:r.error})];return(0,i.FD)(D.rd.Root,{title:(0,c.G)("userProfile.start.connectedAccountsSection.title"),centered:!1,id:"connectedAccounts",children:[(0,i.Y)(P.Z.Alert,{children:o.error}),(0,i.FD)(C.r.Root,{value:s,onChange:u,children:[(0,i.Y)(D.rd.ItemList,{id:"connectedAccounts",children:h.map(e=>(0,i.Y)(q,{account:e},e.id))}),t&&(0,i.Y)(z,{onClick:()=>u(null)})]})]})}),q=e=>{var r,t,n,o,s,u;let{account:h}=e,{additionalOAuthScopes:f,componentName:m,mode:p}=(0,a.B)(),{navigate:v}=(0,k.r)(),{user:g}=(0,Y.Jd)(),P=(0,d.f0)(),b=h.id,R="modal"===p,F=R?(0,_.j)({url:window.location.href,componentName:m}):window.location.href,x=(0,Y.Wp)(()=>null==g?void 0:g.createExternalAccount({strategy:h.verification.strategy,redirectUrl:F,additionalScopes:$}));if(!g)return null;let{providerToDisplayData:A}=(0,I.k)(),z=h.username||h.emailAddress,T=null==(t=h.verification)||null==(r=t.error)?void 0:r.longMessage,$=function(e,r){if(!r)return[];let t=r[e.provider]||[],i=e.approvedScopes.split(" ");return 0===t.filter(e=>!i.includes(e)).length?[]:t}(h,f),E=$.length>0&&""!=h.approvedScopes,L=N.includes((null==(o=h.verification)||null==(n=o.error)?void 0:n.code)||"")||E,O=L?(0,c.G)("userProfile.start.connectedAccountsSection.subtitle__disconnected"):T,K=async()=>{let e=R?(0,_.j)({url:window.location.href,componentName:m}):window.location.href;try{let t;if(t=E?await h.reauthorize({additionalScopes:$,redirectUrl:e}):await x()){var r;await v((null==(r=t.verification.externalVerificationRedirectURL)?void 0:r.href)||"")}}catch(e){(0,G.H4)(e,[],P.setError)}};return(0,i.FD)(l.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"connectedAccounts",children:[(0,i.FD)(y.so,{sx:e=>({overflow:"hidden",gap:e.space.$2}),children:[(0,i.Y)(()=>A[h.provider].iconUrl?(0,i.Y)(y._V,{elementDescriptor:[S.$z.providerIcon],elementId:S.$z.socialButtonsProviderIcon.setId(h.provider),alt:A[h.provider].name,src:A[h.provider].iconUrl,sx:e=>({width:e.sizes.$4,flexShrink:0})}):(0,i.Y)(w.T,{id:h.provider,value:A[h.provider].name}),{}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:1,center:!0,children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),children:"".concat(A[h.provider].name)}),(0,i.Y)(y.EY,{truncate:!0,as:"span",colorScheme:"secondary",children:z?"• ".concat(z):""})]})})]}),(0,i.Y)(U,{account:h})]}),L&&(0,i.FD)(y.az,{sx:e=>({padding:"".concat(e.sizes.$none," ").concat(e.sizes.$none," ").concat(e.sizes.$1x5," ").concat(e.sizes.$8x5)}),children:[(0,i.Y)(y.EY,{colorScheme:"secondary",sx:e=>({paddingRight:e.sizes.$1x5,display:"inline-block"}),localizationKey:O}),(0,i.Y)(y.$n,{sx:{display:"inline-block"},onClick:K,variant:"link",localizationKey:(0,c.G)("userProfile.start.connectedAccountsSection.actionLabel__connectionFailed")})]}),(null==(u=h.verification)||null==(s=u.error)?void 0:s.code)&&!L&&(0,i.Y)(y.EY,{colorScheme:"danger",sx:e=>({padding:"".concat(e.sizes.$none," ").concat(e.sizes.$1x5," ").concat(e.sizes.$1x5," ").concat(e.sizes.$8x5)}),children:T}),(0,i.Y)(C.r.Open,{value:"remove-".concat(b),children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(M,{accountId:h.id})})})]},h.id)},U=e=>{let{account:r}=e,{open:t}=(0,F.D5)(),l=r.id,n=[{label:(0,c.G)("userProfile.start.connectedAccountsSection.destructiveActionTitle"),isDestructive:!0,onClick:()=>t("remove-".concat(l))}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:n})};t(41730),t(10676);let j=e=>e.defaultSecondFactor?-1:1;function H(e){let r=[];return Object.entries(e).forEach(e=>{let[,t]=e;t.used_for_second_factor&&r.push(...t.second_factors)}),r}function V(e,r){let t=H(e);return r.totpEnabled&&(t=t.filter(e=>"totp"!==e)),(r.backupCodeEnabled||!r.twoFactorEnabled)&&(t=t.filter(e=>"backup_code"!==e)),t}function Z(e,r){if(!e)return[];let t=e.filter(e=>e.id===r),i=e.filter(e=>e.id!==r),l=i.filter(e=>{var r;return(null==(r=e.verification)?void 0:r.status)==="verified"}),n=i.filter(e=>{var r,t;return!!(null==(r=e.verification)?void 0:r.status)&&(null==(t=e.verification)?void 0:t.status)!=="verified"}),o=i.filter(e=>!e.verification.status);return l.sort((e,r)=>e.id.localeCompare(r.id)),n.sort((e,r)=>{var t,i;return(null==(t=e.verification)?void 0:t.expireAt)&&(null==(i=r.verification)?void 0:i.expireAt)?e.verification.expireAt.getTime()-r.verification.expireAt.getTime():0}),[...t,...l,...n,...o]}var X=t(32336);let Q=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)($,{onSuccess:r,onReset:r,...e})},ee=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(X.v,{onSuccess:r,onReset:r,...e})},er=e=>{let{shouldAllowCreation:r=!0}=e,{user:t}=(0,Y.Jd)();return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.emailAddressesSection.title"),centered:!1,id:"emailAddresses",children:(0,i.Y)(C.r.Root,{children:(0,i.FD)(D.rd.ItemList,{id:"emailAddresses",children:[Z(null==t?void 0:t.emailAddresses,null==t?void 0:t.primaryEmailAddressId).map(e=>{let r=e.id;return(0,i.FD)(l.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"emailAddresses",children:[(0,i.FD)(y.so,{sx:e=>({overflow:"hidden",gap:e.space.$1}),children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),truncate:!0,children:e.emailAddress}),(null==t?void 0:t.primaryEmailAddressId)===r&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]}),(0,i.Y)(et,{email:e})]}),(0,i.Y)(C.r.Open,{value:"remove-".concat(r),children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(Q,{emailId:r})})}),(0,i.Y)(C.r.Open,{value:"verify-".concat(r),children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ee,{emailId:r})})})]},e.emailAddress)}),r&&(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Trigger,{value:"add",children:(0,i.Y)(D.rd.ArrowButton,{id:"emailAddresses",localizationKey:(0,c.G)("userProfile.start.emailAddressesSection.primaryButton")})}),(0,i.Y)(C.r.Open,{value:"add",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(ee,{})})})]})]})})})},et=e=>{let{email:r}=e,t=(0,d.f0)(),{user:l}=(0,Y.Jd)(),{open:n}=(0,F.D5)(),o=r.id,a=(null==l?void 0:l.primaryEmailAddressId)===o,s="verified"===r.verification.status,u=(0,Y.Wp)(()=>null==l?void 0:l.update({primaryEmailAddressId:o})),h=[a&&!s?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__primary"),onClick:()=>n("verify-".concat(o))}:null,!a&&s?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__nonPrimary"),onClick:()=>{u().catch(e=>(0,G.H4)(e,[],t.setError))}}:null,!a&&!s?{label:(0,c.G)("userProfile.start.emailAddressesSection.detailsAction__unverified"),onClick:()=>n("verify-".concat(o))}:null,{label:(0,c.G)("userProfile.start.emailAddressesSection.destructiveAction"),isDestructive:!0,onClick:()=>n("remove-".concat(o))}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:h})},ei=()=>{let{user:e}=(0,Y.Jd)(),r=null==e?void 0:e.enterpriseAccounts.filter(e=>{let{enterpriseConnection:r}=e;return null==r?void 0:r.active});return(null==r?void 0:r.length)?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.enterpriseAccountsSection.title"),id:"enterpriseAccounts",centered:!1,children:(0,i.Y)(D.rd.ItemList,{id:"enterpriseAccounts",children:r.map(e=>(0,i.Y)(el,{account:e},e.id))})}):null},el=e=>{var r,t,l;let{account:n}=e,o=n.emailAddress,a=null==n||null==(r=n.enterpriseConnection)?void 0:r.name,s=null==(l=n.verification)||null==(t=l.error)?void 0:t.longMessage;return(0,i.FD)(D.rd.Item,{id:"enterpriseAccounts",sx:e=>({gap:e.space.$2,justifyContent:"start"}),children:[(0,i.Y)(en,{account:n}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:1,center:!0,children:[(0,i.Y)(y.EY,{truncate:!0,colorScheme:"body",children:a}),(0,i.Y)(y.EY,{truncate:!0,as:"span",colorScheme:"secondary",children:o?"• ".concat(o):""}),s&&(0,i.Y)(y.Ex,{colorScheme:"danger",localizationKey:(0,c.G)("badge__requiresAction")})]})})]},n.id)},en=e=>{var r;let{account:t}=e,{provider:l,enterpriseConnection:n}=t,o=l.replace(/(oauth_|saml_)/,"").trim(),a=null!=(r=null==n?void 0:n.name)?r:o,s={elementDescriptor:[S.$z.providerIcon],alt:a,sx:e=>({width:e.sizes.$4}),elementId:S.$z.enterpriseButtonsProviderIcon.setId(t.provider)};return(null==n?void 0:n.logoPublicUrl)?(0,i.Y)(y._V,{...s,src:n.logoPublicUrl}):(0,i.Y)(w.T,{id:o,value:a,"aria-label":"".concat(a,"'s icon"),elementDescriptor:[S.$z.providerIcon,S.$z.providerInitialIcon],elementId:S.$z.providerInitialIcon.setId(o)})};var eo=t(87651),ea=t(52454),es=t(11475),ec=t(23549),ed=t(8640),eu=t(46245),eh=t(1282);let ef=(0,d.dm)(e=>{let{phoneId:r,onSuccess:t,onReset:n}=e,{user:o}=(0,Y.Jd)(),a=l.useRef(null==o?void 0:o.phoneNumbers.find(e=>e.id===r)),s=(0,eu.X)({defaultStep:+!!a.current});return(0,i.FD)(eu.s,{...s.props,children:[(0,i.Y)(em,{resourceRef:a,title:(0,c.G)("userProfile.phoneNumberPage.title"),onSuccess:s.nextStep,onReset:n}),(0,i.Y)(ep,{resourceRef:a,title:(0,c.G)("userProfile.phoneNumberPage.verifyTitle"),onSuccess:t,onReset:n})]})}),em=e=>{var r;let{title:t,onSuccess:l,onReset:n,onUseExistingNumberClick:o,resourceRef:a}=e,s=(0,d.f0)(),{user:u}=(0,Y.Jd)(),h=(0,Y.Wp)((e,r)=>e.createPhoneNumber(r)),f=(0,ed.tJ)("phoneNumber","",{type:"tel",label:(0,c.G)("formFieldLabel__phoneNumber"),isRequired:!0}),m=f.value.length>1&&(null==u?void 0:u.username)!==f.value,p=!!(null==u||null==(r=u.phoneNumbers)?void 0:r.length)&&o,v=async e=>{if(e.preventDefault(),u)return h(u,{phoneNumber:f.value}).then(e=>{a.current=e,l()}).catch(e=>(0,G.H4)(e,[f],s.setError))};return(0,i.Y)(ec.M,{headerTitle:t,gap:1,children:(0,i.FD)(ea.l.Root,{gap:4,onSubmit:v,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.phoneNumberPage.infoText"),colorScheme:"secondary"}),(0,i.Y)(ea.l.ControlRow,{elementId:f.id,children:(0,i.Y)(ea.l.PhoneInput,{...f.props,autoFocus:!0})}),(0,i.FD)(y.so,{justify:p?"between":"end",children:[p&&(0,i.Y)(y.$n,{variant:"ghost",localizationKey:(0,c.G)("userProfile.mfaPhoneCodePage.backButton"),onClick:o}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.formButtonPrimary__add"),isDisabled:!m,onReset:n})]})]})})},ep=e=>{var r,t,l;let{title:n,onSuccess:o,resourceRef:a,onReset:s}=e;return(0,i.Y)(ec.M,{headerTitle:n,headerSubtitle:(0,c.G)("userProfile.phoneNumberPage.verifySubtitle",{identifier:(null==(r=a.current)?void 0:r.phoneNumber)||""}),children:(0,i.Y)(eh.j,{nextStep:o,identification:a.current,identifier:null==(t=a.current)?void 0:t.phoneNumber,prepareVerification:null==(l=a.current)?void 0:l.prepareVerification,onReset:s})})},ev=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(E,{onSuccess:r,onReset:r,...e})},eg=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(ef,{onSuccess:r,onReset:r,...e})},eY=e=>{var r;let{shouldAllowCreation:t=!0}=e,{user:n}=(0,Y.Jd)(),o=!!(null==n||null==(r=n.phoneNumbers)?void 0:r.length);return t||o?(0,i.Y)(D.rd.Root,{centered:!1,title:(0,c.G)("userProfile.start.phoneNumbersSection.title"),id:"phoneNumbers",children:(0,i.Y)(C.r.Root,{children:(0,i.FD)(D.rd.ItemList,{id:"phoneNumbers",children:[Z(null==n?void 0:n.phoneNumbers,null==n?void 0:n.primaryPhoneNumberId).map(e=>{let r=e.id;return(0,i.FD)(l.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"phoneNumbers",children:[(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:2,center:!0,children:[(0,i.Y)(y.EY,{sx:e=>({color:e.colors.$colorForeground}),children:(0,eo.Om)(e.phoneNumber)}),(null==n?void 0:n.primaryPhoneNumberId)===r&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]})}),(0,i.Y)(eP,{phone:e})]}),(0,i.Y)(C.r.Open,{value:"remove-".concat(r),children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(ev,{phoneId:r})})}),(0,i.Y)(C.r.Open,{value:"verify-".concat(r),children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eg,{phoneId:r})})})]},r)}),t&&(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Trigger,{value:"add",children:(0,i.Y)(D.rd.ArrowButton,{id:"phoneNumbers",localizationKey:(0,c.G)("userProfile.start.phoneNumbersSection.primaryButton")})}),(0,i.Y)(C.r.Open,{value:"add",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eg,{})})})]})]})})}):null},eP=e=>{let{phone:r}=e,t=(0,d.f0)(),{open:l}=(0,F.D5)(),{user:n}=(0,Y.Jd)(),o=r.id,a=(0,Y.Wp)(e=>e.update({primaryPhoneNumberId:r.id}));if(!n)return null;let s=n.primaryPhoneNumberId===r.id,u="verified"===r.verification.status,h=[s&&!u?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__primary"),onClick:()=>l("verify-".concat(o))}:null,!s&&u?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__nonPrimary"),onClick:()=>a(n).catch(e=>(0,G.H4)(e,[],t.setError))}:null,!s&&!u?{label:(0,c.G)("userProfile.start.phoneNumbersSection.detailsAction__unverified"),onClick:()=>l("verify-".concat(o))}:null,{label:(0,c.G)("userProfile.start.phoneNumbersSection.destructiveAction"),isDestructive:!0,onClick:()=>l("remove-".concat(o))}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:h})};var eb=t(37591),ey=t(94557),eS=t(10078);let e_=(0,d.dm)(e=>{var r;let{onSuccess:t,onReset:l}=e,{user:n}=(0,Y.Jd)(),o=(0,Y.Wp)(e=>null==n?void 0:n.update({username:e})),{userSettings:a}=(0,g.O)(),s=(0,d.f0)(),{t:u,locale:h}=(0,eS._)(),{usernameSettings:f}=a,m=(0,ed.tJ)("username",(null==n?void 0:n.username)||"",{type:"text",label:(0,c.G)("formFieldLabel__username"),placeholder:(0,c.G)("formFieldInputPlaceholder__username"),buildErrorMessage:e=>(0,ey.Z)(e,{t:u,locale:h,usernameSettings:f})});if(!n)return null;let p=null==(r=a.attributes.username)?void 0:r.required,v=(!p||m.value.length>0)&&n.username!==m.value,P=async()=>{try{await o(m.value),t()}catch(e){(0,G.H4)(e,[m],s.setError)}};return(0,i.Y)(ec.M,{headerTitle:n.username?(0,c.G)("userProfile.usernamePage.title__update"):(0,c.G)("userProfile.usernamePage.title__set"),children:(0,i.FD)(ea.l.Root,{onSubmit:P,children:[(0,i.Y)(ea.l.ControlRow,{elementId:m.id,children:(0,i.Y)(ea.l.PlainInput,{...m.props,autoFocus:!0,isRequired:p})}),(0,i.Y)(es.G,{isDisabled:!v,onReset:l})]})})}),eD=()=>{let{close:e}=(0,F.D5)();return(0,i.Y)(e_,{onSuccess:e,onReset:e})},eR=()=>{let{user:e}=(0,Y.Jd)();return e?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.usernameSection.title"),id:"username",sx:{alignItems:"center",[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"username",sx:{paddingLeft:e.username?void 0:"0"},children:[e.username&&(0,i.Y)(y.EY,{truncate:!0,sx:e=>({color:e.colors.$colorForeground}),children:e.username}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"username",localizationKey:e.username?(0,c.G)("userProfile.start.usernameSection.primaryButton__updateUsername"):(0,c.G)("userProfile.start.usernameSection.primaryButton__setUsername")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eD,{})})})]})}):null};var eG=t(29345);t(89305);var ew=t(62421),eC=t(80396),eF=t(63817),eI=t(99538);let ek=e=>{let{user:r,...t}=e;return(0,i.Y)(eF.k,{...t,title:(0,c.G)("userProfile.profilePage.imageFormTitle"),avatarPreview:(0,i.Y)(eI.H,{size:e=>e.sizes.$12,...r})})},ex=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,l=(0,d.f0)(),{user:n}=(0,Y.Jd)();if(!n)return null;let{first_name:o,last_name:a}=(0,g.O)().userSettings.attributes,s=null==o?void 0:o.enabled,u=null==a?void 0:a.enabled,h=n.firstName||"",f=n.lastName||"",m=(0,ed.tJ)("firstName",n.firstName||"",{type:"text",label:(0,c.G)("formFieldLabel__firstName"),placeholder:(0,c.G)("formFieldInputPlaceholder__firstName"),isRequired:null==a?void 0:a.required}),p=(0,ed.tJ)("lastName",n.lastName||"",{type:"text",label:(0,c.G)("formFieldLabel__lastName"),placeholder:(0,c.G)("formFieldInputPlaceholder__lastName"),isRequired:null==a?void 0:a.required}),v=s&&m.value!==h||u&&p.value!==f,P=s&&o.required||u&&a.required,b=P&&!!p.value&&!!m.value&&v,y=n.enterpriseAccounts.some(e=>e.active),S=async e=>(e.preventDefault(),(v?n.update({firstName:m.value,lastName:p.value}):Promise.resolve()).then(r).catch(e=>{(0,G.H4)(e,[m,p],l.setError)}));return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.profilePage.title"),children:[y&&(0,i.Y)(ew.k,{message:(0,c.G)("userProfile.profilePage.readonly")}),(0,i.FD)(ea.l.Root,{onSubmit:S,sx:e=>({gap:e.space.$6}),children:[(0,i.Y)(ek,{user:n,onAvatarChange:e=>n.setProfileImage({file:e}).then(()=>{l.setIdle(),null==r||r()}).catch(e=>(0,G.H4)(e,[],l.setError)),onAvatarRemove:(0,eC.p)(n.imageUrl)?null:()=>{n.setProfileImage({file:null}).then(()=>{l.setIdle(),null==r||r()}).catch(e=>(0,G.H4)(e,[],l.setError))}}),(s||u)&&(0,i.FD)(ea.l.ControlRow,{elementId:"name",children:[s&&(0,i.Y)(ea.l.PlainInput,{...m.props,isDisabled:y,autoFocus:!0}),u&&(0,i.Y)(ea.l.PlainInput,{...p.props,isDisabled:y,autoFocus:!s})]}),(0,i.Y)(es.G,{isDisabled:P?!b:!v,onReset:t})]})]})}),eA=()=>{let{close:e}=(0,F.D5)();return(0,i.Y)(ex,{onSuccess:e,onReset:e})},ez=()=>{let{user:e}=(0,Y.Jd)();if(!e)return null;let{username:r,primaryEmailAddress:t,primaryPhoneNumber:l,primaryWeb3Wallet:n,...o}=e;return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.profileSection.title"),id:"profile",sx:{[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"profile",children:[(0,i.Y)(eG.c,{user:o,size:"lg",mainIdentifierVariant:"subtitle",sx:e=>({color:e.colors.$colorForeground})}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"profile",localizationKey:(0,c.G)("userProfile.start.profileSection.primaryButton")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eA,{})})})]})})};t(98114);var eT=t(66463),e$=t(25243),eE=t(73610);let eL=(0,l.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("188")]).then(t.bind(t,66464)).then(e=>({default:e.Web3SolanaWalletButtons}))),eO=e=>{let{onConnect:r}=e,t=(0,d.f0)(),{close:n}=(0,F.D5)(),o=async e=>{let{walletName:i}=e;t.setLoading(i);try{await r({strategy:"web3_solana_signature",walletName:i}),t.setIdle(),n()}catch(e){if(t.setIdle(),e instanceof Error)(0,G.H4)(e,[],t.setError);else{let r=new eE.cR("An error occurred while generating the Solana signature.",{code:"web3_solana_signature_generation_failed",cause:e instanceof Error?e:void 0});(0,G.H4)(r,[],t.setError)}}};return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.start.web3WalletsSection.web3SelectSolanaWalletScreen.title"),headerSubtitle:(0,c.G)("userProfile.start.web3WalletsSection.web3SelectSolanaWalletScreen.subtitle"),children:(0,i.FD)(ea.l.Root,{children:[(0,i.Y)(l.Suspense,{fallback:(0,i.Y)(y.so,{direction:"row",align:"center",justify:"center",sx:e=>({height:"100%",minHeight:e.sizes.$32}),children:(0,i.Y)(y.y$,{size:"lg",colorScheme:"primary",elementDescriptor:S.$z.spinner})}),children:(0,i.Y)(eL,{web3AuthCallback:o})}),(0,i.Y)(es.c,{children:(0,i.Y)(y.$n,{type:"button",variant:"ghost",onClick:()=>{n()},localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})})]})})};var eK=t(49236);let eB=()=>{var e,r;let t=(0,d.f0)(),{open:l}=(0,F.D5)(),{user:n}=(0,Y.Jd)(),{strategies:o,strategyToDisplayData:a}=(0,I.k)(),s=(0,e$.R)(),u=o.filter(e=>e.startsWith("web3")),h=null!=(r=null==n||null==(e=n.verifiedWeb3Wallets)?void 0:e.map(e=>e.verification.strategy))?r:[],f=u.filter(e=>!h.includes(e)&&a[e]);if(0===f.length)return null;let m=(0,Y.Wp)(e=>null==n?void 0:n.createWeb3Wallet({web3Wallet:e})),p=async e=>{let{strategy:r,walletName:i}=e,o=(0,eT.U)(s);if("web3_solana_signature"===r&&!i)return void l("web3Wallets");let a=r.replace("web3_","").replace("_signature","");t.setError(void 0);try{t.setLoading(r);let e=await o.getWeb3Identifier({provider:a,walletName:i});if(!n)throw Error("user is not defined");let l=await m(e),s=null==(l=await (null==l?void 0:l.prepareVerification({strategy:r})))?void 0:l.verification.message,c=await o.generateWeb3Signature({identifier:e,nonce:s,provider:a,walletName:i});await (null==l?void 0:l.attemptVerification({signature:c})),t.setIdle()}catch(e){t.setIdle(),(0,eK.f)(e,t.setError)}};return(0,i.FD)(i.FK,{children:[(0,i.Y)(C.r.Closed,{value:"web3Wallets",children:(0,i.Y)(D.rd.ActionMenu,{id:"web3Wallets",triggerLocalizationKey:(0,c.G)("userProfile.start.web3WalletsSection.primaryButton"),children:f.map(e=>(0,i.Y)(D.rd.ActionMenuItem,{id:a[e].id,onClick:()=>{p({strategy:e})},isLoading:t.loadingMetadata===e,isDisabled:t.isLoading,localizationKey:(0,c.G)("userProfile.web3WalletPage.web3WalletButtonsBlockButton",{provider:a[e].name}),sx:e=>({justifyContent:"start",gap:e.space.$2}),leftIcon:(0,i.Y)(y._V,{elementDescriptor:S.$z.providerIcon,elementId:S.$z.providerIcon.setId(a[e].id),isLoading:t.loadingMetadata===e,isDisabled:t.isLoading,src:a[e].iconUrl,alt:"Connect ".concat(a[e].name),sx:e=>({width:e.sizes.$5})})},e))})}),(0,i.Y)(C.r.Open,{value:"web3Wallets",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(eO,{onConnect:p})})})]})},eW=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(O,{onSuccess:r,onReset:r,...e})},eM=(0,d.dm)(e=>{var r;let{shouldAllowCreation:t=!0}=e,{user:n}=(0,Y.Jd)(),o=(0,d.f0)(),{strategyToDisplayData:a}=(0,I.k)(),s=!!(null==n||null==(r=n.web3Wallets)?void 0:r.length),[u,h]=(0,l.useState)(null);return t||s?(0,i.FD)(D.rd.Root,{title:(0,c.G)("userProfile.start.web3WalletsSection.title"),centered:!1,id:"web3Wallets",children:[(0,i.Y)(P.Z.Alert,{children:o.error}),(0,i.FD)(C.r.Root,{value:u,onChange:h,children:[(0,i.Y)(D.rd.ItemList,{id:"web3Wallets",children:Z(null==n?void 0:n.web3Wallets,null==n?void 0:n.primaryWeb3WalletId).map(e=>{var r;let t=e.verification.strategy,o=e.id;return a[t]&&(0,i.FD)(l.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"web3Wallets",align:"start",children:[(0,i.FD)(y.so,{sx:e=>({alignItems:"center",gap:e.space.$2,width:"100%"}),children:[a[t].iconUrl&&(0,i.Y)(y._V,{src:a[t].iconUrl,alt:a[t].name,sx:e=>({width:e.sizes.$4})}),(0,i.Y)(y.az,{sx:{whiteSpace:"nowrap",overflow:"hidden"},children:(0,i.FD)(y.so,{gap:2,justify:"start",children:[(0,i.FD)(y.EY,{children:[a[t].name," (",(r=e.web3Wallet).length<=10?r:r.slice(0,6)+"..."+r.slice(-4),")"]}),(null==n?void 0:n.primaryWeb3WalletId)===o&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__primary")}),"verified"!==e.verification.status&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__unverified")})]})})]}),(0,i.Y)(eN,{walletId:o,isVerified:"verified"===e.verification.status})]},o),(0,i.Y)(C.r.Open,{value:"remove-".concat(o),children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(eW,{walletId:e.id})})})]},e.id)})}),t&&(0,i.Y)(eB,{})]})]}):null}),eN=e=>{let{walletId:r,isVerified:t}=e,l=(0,d.f0)(),{open:n}=(0,F.D5)(),{user:o}=(0,Y.Jd)(),a=(null==o?void 0:o.primaryWeb3WalletId)===r,s=(0,Y.Wp)(()=>null==o?void 0:o.update({primaryWeb3WalletId:r})),u=[!a&&t?{label:(0,c.G)("userProfile.start.web3WalletsSection.detailsAction__nonPrimary"),onClick:()=>{s().catch(e=>(0,G.H4)(e,[],l.setError))}}:null,{label:(0,c.G)("userProfile.start.web3WalletsSection.destructiveAction"),isDestructive:!0,onClick:()=>n("remove-".concat(r))}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:u})},eJ=(0,d.dm)(()=>{var e,r,t,l;let{attributes:n,social:o,enterpriseSSO:s}=(0,g.O)().userSettings,u=(0,d.f0)(),{user:h}=(0,Y.Jd)(),{shouldAllowIdentificationCreation:f}=(0,a.B)(),m=null==(e=n.username)?void 0:e.enabled,p=null==(r=n.email_address)?void 0:r.enabled,v=null==(t=n.phone_number)?void 0:t.enabled,_=o&&Object.values(o).filter(e=>e.enabled).length>0,D=h&&s.enabled,R=null==(l=n.web3_wallet)?void 0:l.enabled;return(0,i.Y)(y.fv,{elementDescriptor:S.$z.page,sx:e=>({gap:e.space.$8,color:e.colors.$colorForeground}),children:(0,i.FD)(y.fv,{elementDescriptor:S.$z.profilePage,elementId:S.$z.profilePage.setId("account"),children:[(0,i.Y)(b.Y.Root,{children:(0,i.Y)(b.Y.Title,{localizationKey:(0,c.G)("userProfile.start.headerTitle__account"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,i.Y)(P.Z.Alert,{children:u.error}),(0,i.Y)(ez,{}),m&&(0,i.Y)(eR,{}),p&&(0,i.Y)(er,{shouldAllowCreation:f}),v&&(0,i.Y)(eY,{shouldAllowCreation:f}),_&&(0,i.Y)(J,{shouldAllowCreation:f}),D&&(0,i.Y)(ei,{}),R&&(0,i.Y)(eM,{shouldAllowCreation:f})]})})});t(1589);var eq=t(12611),eU=t(97806),ej=t(67896),eH=t(84901),eV=t(50892),eZ=t(36529);let eX=()=>{let e,{user:r}=(0,Y.Jd)(),{session:t}=(0,Y.wV)(),{data:l,isLoading:n}=(0,ej.s)(null==r?void 0:r.getSessions,"user-sessions");return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.activeDevicesSection.title"),centered:!1,id:"activeDevices",children:(0,i.Y)(D.rd.ItemList,{id:"activeDevices",disableAnimation:!0,children:n?(0,i.Y)(eq.K,{}):null==l?void 0:l.sort((e=t.id,r=>r.id===e?-1:1)).map(e=>eQ(e.status)?(0,i.Y)(e0,{session:e},e.id):null)})})},eQ=e=>["active","pending"].includes(e),e0=e=>{var r;let{session:t}=e,l=(null==(r=(0,Y.wV)().session)?void 0:r.id)===t.id,n=(0,eH.m)(),o=(0,Y.Wp)(t.revoke.bind(t)),a=async()=>{if(!l&&t)return n.setLoading(),o().catch(e=>(0,G.H4)(e,[],n.setError)).finally(()=>n.setIdle())};return(0,i.Y)(D.rd.Item,{id:"activeDevices",elementDescriptor:S.$z.activeDeviceListItem,elementId:l?S.$z.activeDeviceListItem.setId("current"):void 0,sx:{alignItems:"flex-start",opacity:n.isLoading?.5:1},isDisabled:n.isLoading,children:(0,i.FD)(i.FK,{children:[(0,i.Y)(e1,{session:t}),!l&&(0,i.Y)(e2,{revoke:a})]})})},e1=e=>{let{session:r}=(0,Y.wV)(),t=(null==r?void 0:r.id)===e.session.id,l=!!(null==r?void 0:r.actor),n=!!e.session.actor,{city:o,country:a,browserName:s,browserVersion:d,deviceType:u,ipAddress:h,isMobile:f}=e.session.latestActivity,m="".concat(s||""," ").concat(d||"").trim()||"Web browser",p=[o||"",a||""].filter(Boolean).join(", ").trim()||null,{t:v}=(0,eS._)();return(0,i.FD)(y.so,{elementDescriptor:S.$z.activeDevice,elementId:t?S.$z.activeDevice.setId("current"):void 0,sx:e=>({width:"100%",overflow:"hidden",gap:e.space.$4,[eb.g.sm]:{gap:e.space.$2}}),children:[(0,i.Y)(y.so,{sx:e=>({[eb.g.sm]:{padding:"0"},borderRadius:e.radii.$md}),children:(0,i.Y)(y.In,{elementDescriptor:S.$z.activeDeviceIcon,elementId:S.$z.activeDeviceIcon.setId(f?"mobile":"desktop"),icon:f?eV.A:eZ.A,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.FD)(y.fv,{align:"start",gap:1,children:[(0,i.FD)(y.so,{center:!0,gap:2,children:[(0,i.Y)(y.EY,{children:u||(f?"Mobile device":"Desktop device")}),t&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__thisDevice"),colorScheme:l?"danger":"primary"}),l&&!n&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__userDevice")}),!t&&n&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__otherImpersonatorDevice"),colorScheme:"danger"})]}),(0,i.Y)(y.EY,{colorScheme:"secondary",children:m}),(0,i.FD)(y.EY,{colorScheme:"secondary",children:[h," (",p,")"]}),(0,i.Y)(y.EY,{colorScheme:"secondary",children:v((0,eU.T)(e.session.lastActiveAt))})]})]})},e2=e=>{let{revoke:r}=e,t=[{label:(0,c.G)("userProfile.start.activeDevicesSection.destructiveAction"),isDestructive:!0,onClick:r}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:t})};var e5=t(49599),e4=t(38691);let e3=(0,d.dm)(e=>{let{onReset:r}=e,t=(0,d.f0)(),{afterSignOutUrl:l,afterMultiSessionSingleSignOutUrl:n}=(0,e5.g)(),{user:o}=(0,Y.Jd)(),{t:a}=(0,eS._)(),{otherSessions:s}=(0,e4.z)({user:o}),{setActive:u}=(0,Y.ho)(),h=(0,Y.Wp)(()=>null==o?void 0:o.delete()),f=(0,ed.tJ)("deleteConfirmation","",{type:"text",label:(0,c.G)("userProfile.deletePage.actionDescription"),isRequired:!0,placeholder:(0,c.G)("formFieldInputPlaceholder__confirmDeletionUserAccount")}),m=f.value===(a((0,c.G)("formFieldInputPlaceholder__confirmDeletionUserAccount"))||"Delete account"),p=async()=>{if(m)try{await h();let e=0===s.length?l:n;return await u({session:null,redirectUrl:e})}catch(e){(0,G.H4)(e,[],t.setError)}};return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.deletePage.title"),sx:e=>({gap:e.space.$0x5}),children:(0,i.FD)(ea.l.Root,{onSubmit:p,children:[(0,i.FD)(y.fv,{gap:1,children:[(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.deletePage.messageLine1")}),(0,i.Y)(y.EY,{colorScheme:"danger",localizationKey:(0,c.G)("userProfile.deletePage.messageLine2")})]}),(0,i.Y)(ea.l.ControlRow,{elementId:f.id,children:(0,i.Y)(ea.l.PlainInput,{...f.props,ignorePasswordManager:!0})}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.deletePage.confirm"),colorScheme:"danger",isDisabled:!m,onReset:r})]})})}),e6=()=>{let{close:e}=(0,F.D5)();return(0,i.Y)(e3,{onSuccess:e,onReset:e})},e9=()=>(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.dangerSection.title"),id:"danger",sx:{alignItems:"center",[eb.g.md]:{alignItems:"flex-start"}},children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"delete",children:(0,i.Y)(D.rd.Item,{id:"danger",sx:e=>({paddingLeft:e.space.$1}),children:(0,i.Y)(C.r.Trigger,{value:"delete",children:(0,i.Y)(D.rd.Button,{id:"danger",variant:"ghost",colorScheme:"danger",localizationKey:(0,c.G)("userProfile.start.dangerSection.deleteAccountButton")})})})}),(0,i.Y)(C.r.Open,{value:"delete",children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(e6,{})})})]})});var e8=t(11323),e7=t(15079),re=t(16103),rr=t(2534);t(64178),t(60962),t(60486),t(25089),t(61244),t(77895);var rt=t(8095),ri=t(99126),rl=t(27782),rn=t(48691),ro=t(75976),ra=t(92405),rs=t(42852);let rc=e=>{let{code:r}=e;return(0,i.Y)(y.so,{center:!0,sx:e=>({padding:"".concat(e.space.$1," ").concat(e.space.$4)}),children:(0,i.Y)(y.EY,{children:r})})},rd=e=>{let{subtitle:r,backupCodes:t}=e,{applicationName:l}=(0,g.O)().displayConfig,{user:n}=(0,Y.Jd)(),{print:o,printableProps:a}=(0,ri.h)(),{onCopy:s,hasCopied:d}=(0,rl.i)((null==t?void 0:t.join(","))||"");if(!n)return null;let u=(0,rt.Cm)(n);return t?(0,i.FD)(i.FK,{children:[(0,i.FD)(y.fv,{gap:1,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.title__codelist"),variant:"subtitle"}),(0,i.Y)(y.EY,{localizationKey:r,variant:"caption",colorScheme:"secondary"})]}),(0,i.FD)(y.az,{sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg}),children:[(0,i.Y)(y.xA,{gap:2,sx:e=>({gridTemplateColumns:"repeat(2, minmax(".concat(e.sizes.$12,", 1fr))"),padding:"".concat(e.space.$4," ").concat(e.space.$6)}),children:t.map((e,r)=>(0,i.Y)(rc,{code:e},r))}),(0,i.FD)(y.xA,{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.Y)(y.$n,{variant:"ghost",sx:e=>({width:"100%",padding:"".concat(e.space.$2," 0"),borderRadius:0}),onClick:()=>{var e,r,i;let n,o=document.createElement("a"),a=new Blob([(e=t,r=l,i=u,n=null==e?void 0:e.join("\n"),"These are your backup codes for ".concat(r," account ").concat(i,".\nStore them securely and keep them secret. Each code can only be used once.\n\n").concat(n))],{type:"text/plain"});o.href=URL.createObjectURL(a),o.download="".concat(l,"_backup_codes.txt"),document.body.appendChild(o),o.click()},children:(0,i.Y)(y.In,{icon:rn.A})}),(0,i.Y)(y.$n,{variant:"ghost",sx:e=>({width:"100%",padding:"".concat(e.space.$2," 0"),borderRadius:0}),onClick:o,children:(0,i.Y)(y.In,{icon:ro.A})}),(0,i.Y)(y.$n,{variant:"ghost",onClick:s,sx:e=>({width:"100%",padding:"".concat(e.space.$2," 0"),borderRadius:0}),children:(0,i.Y)(y.In,{icon:d?ra.A:rs.A})})]})]}),(0,i.FD)(ri.L,{...a,children:[(0,i.FD)(y.DZ,{children:["Your backup codes for ",l," account ",u,":"]}),(0,i.Y)(y.fv,{gap:2,children:t.map((e,r)=>(0,i.Y)(rc,{code:e},r))})]})]}):null},ru=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,{user:n}=(0,Y.Jd)(),o=(0,d.f0)(),a=(0,Y.Wp)(()=>null==n?void 0:n.createBackupCode()),[s,u]=l.useState(void 0);return(l.useEffect(()=>{!s&&n&&a().then(e=>u(e)).catch(e=>{if((0,eE.I3)(e))return t();(0,G.H4)(e,[],o.setError)})},[]),o.error)?(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title")}):(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title"),children:s?(0,i.FD)(i.FK,{children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.successMessage")}),(0,i.Y)(rd,{subtitle:(0,c.G)("userProfile.backupCodePage.subtitle__codelist"),backupCodes:s.codes}),(0,i.Y)(es.c,{children:(0,i.Y)(y.$n,{autoFocus:!0,onClick:r,localizationKey:(0,c.G)("userProfile.formButtonPrimary__finish"),elementDescriptor:S.$z.formButtonPrimary})})]}):(0,i.Y)(eq.K,{})})}),rh=(0,d.dm)(e=>{let{onSuccess:r,onReset:t}=e,l=(0,eu.X)();return(0,i.FD)(eu.s,{...l.props,children:[(0,i.Y)(rf,{onContinue:l.nextStep}),(0,i.Y)(ru,{onSuccess:r,onReset:t})]})}),rf=e=>{let{onContinue:r}=e,{close:t}=(0,F.D5)();return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.backupCodePage.title"),children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.infoText1")}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.backupCodePage.infoText2")}),(0,i.FD)(es.c,{sx:{marginTop:0},children:[(0,i.Y)(y.$n,{textVariant:"buttonSmall",onClick:r,localizationKey:(0,c.G)("userProfile.formButtonPrimary__finish"),elementDescriptor:S.$z.formButtonPrimary}),(0,i.Y)(y.$n,{variant:"ghost",onClick:t,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})]})]})};var rm=t(50155),rp=t(26370),rv=t(9679);let rg=(0,d.dm)(e=>{var r,t,n,o;let{onReset:a,onSuccess:s}=e,d=l.useRef(),u=(0,eu.X)({defaultStep:2}),h=null==(r=(0,g.O)().userSettings.attributes.backup_code)?void 0:r.enabled;return(0,i.FD)(eu.s,{...u.props,children:[(0,i.Y)(em,{title:(0,c.G)("userProfile.phoneNumberPage.title"),resourceRef:d,onSuccess:u.nextStep,onUseExistingNumberClick:()=>u.goToStep(2),onReset:a}),(0,i.Y)(rP,{title:(0,c.G)("userProfile.mfaPhoneCodePage.title"),resourceRef:d,onSuccess:()=>h?u.goToStep(3):s(),onReset:()=>u.goToStep(2)}),(0,i.Y)(rb,{onSuccess:h?u.nextStep:s,onReset:a,onAddPhoneClick:()=>u.goToStep(0),onUnverifiedPhoneClick:e=>{d.current=e,u.goToStep(1)},title:(0,c.G)("userProfile.mfaPhoneCodePage.title"),resourceRef:d}),h&&(0,i.Y)(rp.B,{title:(0,c.G)("userProfile.mfaPhoneCodePage.successTitle"),text:(null==(t=d.current)?void 0:t.backupCodes)&&(null==(n=d.current)?void 0:n.backupCodes.length)>0?[(0,c.G)("userProfile.mfaPhoneCodePage.successMessage1"),(0,c.G)("userProfile.mfaPhoneCodePage.successMessage2")]:[(0,c.G)("userProfile.mfaPhoneCodePage.successMessage1")],onFinish:a,contents:(0,i.Y)(rd,{backupCodes:null==(o=d.current)?void 0:o.backupCodes})})]})}),rY=e=>{let{phone:r,onSuccess:t,onUnverifiedPhoneClick:l,resourceRef:n}=e,o=(0,d.f0)(),a=(0,Y.Wp)(()=>r.setReservedForSecondFactor({reserved:!0})),{country:s}=(0,eo.Mz)(r.phoneNumber),c=(0,eo.Om)(r.phoneNumber),u=async()=>{if("verified"!==r.verification.status)return l(r);o.setLoading(r.id);try{await a(),n.current=r,t()}catch(e){(0,G.H4)(e,[],o.setError)}finally{o.setIdle()}};return(0,i.FD)(y.$n,{variant:"outline",colorScheme:"neutral",sx:{justifyContent:"start"},onClick:u,isLoading:o.loadingMetadata===r.id,isDisabled:o.isLoading,children:[s.iso.toUpperCase()," ",c]},r.id)},rP=e=>{var r,t,l;let{title:n,onSuccess:o,resourceRef:a,onReset:s}=e,u=(0,d.f0)(),h=a.current,f=(0,Y.Wp)(()=>null==h?void 0:h.setReservedForSecondFactor({reserved:!0})),m=async()=>{u.setLoading(null==h?void 0:h.id);try{await f(),a.current=h,o()}catch(e){(0,G.H4)(e,[],u.setError)}finally{u.setIdle()}};return(0,i.Y)(ec.M,{headerTitle:n,headerSubtitle:(0,c.G)("userProfile.phoneNumberPage.verifySubtitle",{identifier:(null==(r=a.current)?void 0:r.phoneNumber)||""}),children:(0,i.Y)(eh.j,{nextStep:()=>{m()},identification:a.current,identifier:null==(t=a.current)?void 0:t.phoneNumber,prepareVerification:null==(l=a.current)?void 0:l.prepareVerification,onReset:s})})},rb=e=>{let{onSuccess:r,onReset:t,title:l,onAddPhoneClick:n,onUnverifiedPhoneClick:o,resourceRef:a}=e,{user:s}=(0,Y.Jd)();if(!s)return null;let d=s.phoneNumbers.filter(e=>!e.reservedForSecondFactor);return(0,i.FD)(ec.M,{headerTitle:l,gap:1,children:[(0,i.Y)(y.EY,{localizationKey:(0,c.G)(d.length?"userProfile.mfaPhoneCodePage.subtitle__availablePhoneNumbers":"userProfile.mfaPhoneCodePage.subtitle__unavailablePhoneNumbers"),colorScheme:"secondary"}),d.length>0&&(0,i.Y)(y.fv,{gap:2,children:d.map(e=>(0,i.Y)(rY,{onSuccess:r,phone:e,onUnverifiedPhoneClick:o,resourceRef:a},e.id))}),(0,i.FD)(es.c,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[(0,i.Y)(rm.K,{variant:"ghost","aria-label":"Add phone number",icon:(0,i.Y)(y.In,{icon:rv.A,sx:e=>({marginRight:e.space.$2})}),localizationKey:(0,c.G)("userProfile.mfaPhoneCodePage.primaryButton__addPhoneNumber"),onClick:n}),(0,i.Y)(y.$n,{variant:"ghost",localizationKey:(0,c.G)("userProfile.formButtonReset"),onClick:t})]})]})};var ry=t(95559),rS=t(2094);let r_=(0,d.dm)(e=>{let{title:r,onSuccess:t,onReset:n}=e,{user:o}=(0,Y.Jd)(),a=(0,d.f0)(),s=(0,Y.Wp)(()=>null==o?void 0:o.createTOTP()),{close:u}=(0,F.D5)(),[h,f]=l.useState(void 0),[m,p]=l.useState("qr");return(l.useEffect(()=>{o&&s().then(e=>f(e)).catch(e=>(0,eE.Cm)(e)&&"reverification_cancelled"===e.code?u():(0,G.H4)(e,[],a.setError))},[]),a.error)?(0,i.Y)(ec.M,{headerTitle:r}):(0,i.FD)(ec.M,{headerTitle:r,headerSubtitle:"qr"==m?(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.infoText__ableToScan"):(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.infoText__unableToScan"),children:[!h&&(0,i.Y)(eq.K,{}),h&&(0,i.FD)(i.FK,{children:[(0,i.FD)(y.fv,{gap:4,children:["qr"==m&&(0,i.Y)(rS.r,{justify:"center",url:h.uri||""}),"uri"==m&&(0,i.FD)(i.FK,{children:[(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan1")}),(0,i.Y)(ry.r,{value:h.secret}),(0,i.Y)(y.EY,{colorScheme:"secondary",localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.inputLabel__unableToScan2")}),(0,i.Y)(ry.r,{value:h.uri})]})]}),(0,i.FD)(y.so,{justify:"between",align:"center",sx:{width:"100%"},children:["qr"==m&&(0,i.Y)(y.$n,{variant:"link",textVariant:"buttonLarge",onClick:()=>p("uri"),localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.buttonUnableToScan__nonPrimary")}),"uri"==m&&(0,i.Y)(y.$n,{variant:"link",textVariant:"buttonLarge",onClick:()=>p("qr"),localizationKey:(0,c.G)("userProfile.mfaTOTPPage.authenticatorApp.buttonAbleToScan__nonPrimary")}),(0,i.FD)(es.c,{children:[(0,i.Y)(y.$n,{onClick:t,localizationKey:(0,c.G)("userProfile.formButtonPrimary__continue"),elementDescriptor:S.$z.formButtonPrimary}),(0,i.Y)(y.$n,{variant:"ghost",onClick:n,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})]})]})]})]})});var rD=t(63356);let rR=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,resourceRef:l}=e,{user:n}=(0,Y.Jd)(),o=(0,rD.xM)({onCodeEntryFinished:(e,r,t)=>{null==n||n.verifyTOTP({code:e}).then(e=>r(e)).catch(t)},onResolve:e=>{l.current=e,r()}});return(0,i.FD)(ec.M,{headerTitle:(0,c.G)("userProfile.mfaTOTPPage.title"),children:[(0,i.Y)(y.fv,{children:(0,i.Y)(ea.l.OTPInput,{...o,label:(0,c.G)("userProfile.mfaTOTPPage.verifyTitle"),description:(0,c.G)("userProfile.mfaTOTPPage.verifySubtitle")})}),(0,i.Y)(es.c,{sx:{marginTop:0},children:(0,i.Y)(y.$n,{onClick:t,variant:"ghost",isDisabled:o.isLoading,localizationKey:(0,c.G)("userProfile.formButtonReset"),elementDescriptor:S.$z.formButtonReset})})]})}),rG=(0,d.dm)(e=>{var r;let{onReset:t}=e,n=(0,eu.X)(),o=l.useRef();return(0,i.FD)(eu.s,{...n.props,children:[(0,i.Y)(r_,{title:(0,c.G)("userProfile.mfaTOTPPage.title"),onSuccess:n.nextStep,onReset:t}),(0,i.Y)(rR,{onSuccess:n.nextStep,onReset:t,resourceRef:o}),(0,i.Y)(rp.B,{title:(0,c.G)("userProfile.mfaTOTPPage.title"),text:(0,c.G)("userProfile.mfaTOTPPage.successMessage"),onFinish:t,contents:(0,i.Y)(rd,{subtitle:(0,c.G)("userProfile.backupCodePage.successSubtitle"),backupCodes:null==(r=o.current)?void 0:r.backupCodes})})]})}),rw=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,selectedStrategy:n}=e,o=(0,d.f0)(),{userSettings:{attributes:a}}=(0,g.O)(),{user:s}=(0,Y.Jd)();if(!s)return null;let u=(0,c.G)("userProfile.mfaPage.title"),h=l.useMemo(()=>V(a,s),[]);return(l.useEffect(()=>{0===h.length&&o.setError("There are no second factors available to add")},[]),o.error)?(0,i.Y)(ec.M,{headerTitle:u}):0!==h.length||n?(0,i.Y)(rC,{onSuccess:r,onReset:t,method:n||h[0]}):null}),rC=e=>{let{method:r,onSuccess:t,onReset:l}=e;switch(r){case"phone_code":return(0,i.Y)(rg,{onSuccess:t,onReset:l});case"totp":return(0,i.Y)(rG,{onSuccess:t,onReset:l});case"backup_code":return(0,i.Y)(rh,{onSuccess:t,onReset:l});default:return null}},rF=()=>{let{close:e}=(0,F.D5)();return(0,i.Y)(B,{onSuccess:e,onReset:e})},rI=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(K,{onSuccess:r,onReset:r,...e})},rk=()=>{let{close:e}=(0,F.D5)();return(0,i.Y)(ru,{onSuccess:e,onReset:e})},rx=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(rw,{onSuccess:r,onReset:r,selectedStrategy:e.selectedStrategy})},rA=()=>{let{userSettings:{attributes:e}}=(0,g.O)(),{user:r}=(0,Y.Jd)(),[t,n]=(0,l.useState)(null);if(!r)return null;let o=H(e),a=V(e,r),s=o.includes("totp")&&r.totpEnabled,d=o.includes("backup_code")&&r.backupCodeEnabled,u=r.phoneNumbers.filter(e=>"verified"===e.verification.status).filter(e=>e.reservedForSecondFactor).sort(j);return(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.mfaSection.title"),centered:!1,id:"mfa",children:(0,i.Y)(C.r.Root,{value:t,onChange:n,children:(0,i.FD)(D.rd.ItemList,{id:"mfa",children:[s&&(0,i.FD)(i.FK,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:e7.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.start.mfaSection.totp.headerTitle")}),(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__default")})]}),(0,i.Y)(r$,{})]}),(0,i.Y)(C.r.Open,{value:"remove-totp",children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(rF,{})})})]}),o.includes("phone_code")&&u.map(e=>{let r=!s&&e.defaultSecondFactor,t=e.id;return(0,i.FD)(l.Fragment,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:re.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.FD)(y.EY,{children:["SMS Code ",(0,i.Y)(e8.R,{value:e.phoneNumber})]}),r&&(0,i.Y)(y.Ex,{localizationKey:(0,c.G)("badge__default")})]}),(0,i.Y)(rz,{phone:e,showTOTP:s})]}),(0,i.Y)(C.r.Open,{value:"remove-".concat(t),children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(rI,{phoneId:t})})})]},t)}),d&&(0,i.FD)(i.FK,{children:[(0,i.FD)(D.rd.Item,{id:"mfa",hoverable:!0,children:[(0,i.FD)(y.so,{sx:e=>({gap:e.space.$2,alignItems:"center"}),children:[(0,i.Y)(y.In,{icon:rr.A,sx:e=>({color:e.colors.$neutralAlpha700})}),(0,i.Y)(y.EY,{localizationKey:(0,c.G)("userProfile.start.mfaSection.backupCodes.headerTitle")})]}),(0,i.Y)(rT,{})]}),(0,i.Y)(C.r.Open,{value:"regenerate",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rk,{})})})]}),(0,i.Y)(rE,{secondFactorsAvailableToAdd:a,onClick:()=>n(null)})]})})})},rz=e=>{let{phone:r,showTOTP:t}=e,{open:l}=(0,F.D5)(),n=(0,d.f0)(),o=r.id,a=[!t&&!r.defaultSecondFactor?{label:(0,c.G)("userProfile.start.mfaSection.phoneCode.actionLabel__setDefault"),onClick:()=>r.makeDefaultSecondFactor().catch(e=>(0,G.H4)(e,[],n.setError))}:null,{label:(0,c.G)("userProfile.start.mfaSection.phoneCode.destructiveActionLabel"),isDestructive:!0,onClick:()=>l("remove-".concat(o))}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:a})},rT=()=>{let{open:e}=(0,F.D5)(),r=[{label:(0,c.G)("userProfile.start.mfaSection.backupCodes.actionLabel__regenerate"),onClick:()=>e("regenerate")}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})},r$=()=>{let{open:e}=(0,F.D5)(),r=[{label:(0,c.G)("userProfile.start.mfaSection.totp.destructiveActionTitle"),isDestructive:!0,onClick:()=>e("remove-totp")}].filter(e=>null!==e);return(0,i.Y)(R.o,{actions:r})},rE=e=>{let{open:r}=(0,F.D5)(),{secondFactorsAvailableToAdd:t,onClick:n}=e,[o,a]=(0,l.useState)(),s=l.useMemo(()=>t.map(e=>"phone_code"===e?{icon:re.A,text:"SMS code",key:"phone_code"}:"totp"===e?{icon:e7.A,text:"Authenticator application",key:"totp"}:"backup_code"===e?{icon:rr.A,text:"Backup code",key:"backup_code"}:null).filter(e=>null!==e),[t]);return(0,i.FD)(i.FK,{children:[t.length>0&&(0,i.Y)(C.r.Closed,{value:"multi-factor",children:(0,i.Y)(D.rd.ActionMenu,{id:"mfa",triggerLocalizationKey:(0,c.G)("userProfile.start.mfaSection.primaryButton"),onClick:n,children:s.map(e=>e&&(0,i.Y)(D.rd.ActionMenuItem,{id:e.key,localizationKey:e.text,leftIcon:e.icon,onClick:()=>{a(e.key),r("multi-factor")}},e.key))})}),(0,i.Y)(C.r.Open,{value:"multi-factor",children:(0,i.Y)(C.r.Card,{children:o&&(0,i.Y)(rx,{selectedStrategy:o})})})]})},rL=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(W,{onSuccess:r,onReset:r,...e})},rO=e=>{let{close:r}=(0,F.D5)();return(0,i.Y)(rK,{onSuccess:r,onReset:r,passkey:e.passkey})},rK=(0,d.dm)(e=>{let{onSuccess:r,onReset:t,passkey:l}=e,n=(0,d.f0)(),o=(0,ed.tJ)("passkeyName",l.name||"",{type:"text",label:(0,c.G)("formFieldLabel__passkeyName"),isRequired:!0}),a=o.value.length>1&&l.name!==o.value,s=async e=>(e.preventDefault(),l.update({name:o.value}).then(r).catch(e=>(0,G.H4)(e,[o],n.setError)));return(0,i.Y)(ec.M,{headerTitle:(0,c.G)("userProfile.passkeyScreen.title__rename"),headerSubtitle:(0,c.G)("userProfile.passkeyScreen.subtitle__rename"),children:(0,i.FD)(ea.l.Root,{onSubmit:s,children:[(0,i.Y)(ea.l.ControlRow,{elementId:o.id,children:(0,i.Y)(ea.l.PlainInput,{...o.props,autoComplete:"off"})}),(0,i.Y)(es.G,{submitLabel:(0,c.G)("userProfile.formButtonPrimary__save"),isDisabled:!a,onReset:t})]})})}),rB=()=>{let{user:e}=(0,Y.Jd)(),[r,t]=(0,l.useState)(null);return e?(0,i.Y)(D.rd.Root,{title:(0,c.G)("userProfile.start.passkeysSection.title"),centered:!1,id:"passkeys",children:(0,i.Y)(C.r.Root,{value:r,onChange:t,children:(0,i.FD)(D.rd.ItemList,{id:"passkeys",children:[e.passkeys.map(e=>{let r=e.id;return(0,i.FD)(l.Fragment,{children:[(0,i.Y)(rW,{...e},r),(0,i.Y)(C.r.Open,{value:"remove-".concat(r),children:(0,i.Y)(C.r.Card,{variant:"destructive",children:(0,i.Y)(rL,{passkey:e})})}),(0,i.Y)(C.r.Open,{value:"rename-".concat(r),children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rO,{passkey:e})})})]},r)}),(0,i.Y)(rJ,{onClick:()=>t(null)})]})})}):null},rW=e=>(0,i.FD)(D.rd.Item,{id:"passkeys",hoverable:!0,sx:{alignItems:"flex-start"},children:[(0,i.Y)(rM,{...e}),(0,i.Y)(rN,{passkey:e})]}),rM=e=>{let{name:r,createdAt:t,lastUsedAt:l}=e,{t:n}=(0,eS._)();return(0,i.Y)(y.so,{sx:e=>({width:"100%",overflow:"hidden",gap:e.space.$4,[eb.g.sm]:{gap:e.space.$2}}),children:(0,i.FD)(y.fv,{align:"start",gap:1,children:[(0,i.Y)(y.EY,{children:r}),(0,i.FD)(y.EY,{colorScheme:"secondary",children:["Created: ",n((0,eU.T)(t))]}),l&&(0,i.FD)(y.EY,{colorScheme:"secondary",children:["Last used: ",n((0,eU.T)(l))]})]})})},rN=e=>{let{passkey:r}=e,{open:t}=(0,F.D5)(),l=r.id,n=[{label:(0,c.G)("userProfile.start.passkeysSection.menuAction__rename"),onClick:()=>t("rename-".concat(l))},{label:(0,c.G)("userProfile.start.passkeysSection.menuAction__destructive"),isDestructive:!0,onClick:()=>t("remove-".concat(l))}];return(0,i.Y)(R.o,{actions:n})},rJ=e=>{let{onClick:r}=e,t=(0,d.f0)(),{isSatellite:l}=(0,Y.ho)(),{user:n}=(0,Y.Jd)(),o=(0,Y.Wp)(()=>null==n?void 0:n.createPasskey()),a=async()=>{if(null==r||r(),n)try{await o()}catch(e){(0,G.H4)(e,[],t.setError)}};return l?null:(0,i.Y)(D.rd.ArrowButton,{id:"passkeys",localizationKey:(0,c.G)("userProfile.start.passkeysSection.primaryButton"),onClick:a})};var rq=t(23990),rU=t(23468);let rj=(0,d.dm)(e=>{let{t:r,locale:t}=(0,eS._)(),{onSuccess:n,onReset:o}=e,{user:a}=(0,Y.Jd)(),s=(0,Y.Wp)((e,r)=>e.updatePassword(...r));if(!a)return null;let{userSettings:{passwordSettings:u},authConfig:{reverification:h}}=(0,g.O)(),{session:f}=(0,Y.wV)(),m=a.passwordEnabled?(0,c.G)("userProfile.passwordPage.title__update"):(0,c.G)("userProfile.passwordPage.title__set"),p=(0,d.f0)(),v=a.enterpriseAccounts.some(e=>e.active),P=a.passwordEnabled&&!h,b=(0,l.useRef)({title:(0,c.G)("userProfile.passwordPage.title__set")}),y=(0,ed.tJ)("currentPassword","",{type:"password",label:(0,c.G)("formFieldLabel__currentPassword"),isRequired:!0}),S=(0,ed.tJ)("newPassword","",{type:"password",label:(0,c.G)("formFieldLabel__newPassword"),isRequired:!0,validatePassword:!0,buildErrorMessage:e=>(0,rq.C5)(e,{t:r,locale:t,passwordSettings:u})}),_=(0,ed.tJ)("confirmPassword","",{type:"password",label:(0,c.G)("formFieldLabel__confirmPassword"),isRequired:!0}),D=(0,ed.tJ)("signOutOfOtherSessions","",{type:"checkbox",label:(0,c.G)("formFieldLabel__signOutOfOtherSessions"),defaultChecked:!0}),{setConfirmPasswordFeedback:R,isPasswordMatch:w}=(0,rU.Z)({passwordField:S,confirmPasswordField:_}),C=(P?y.value&&w:w)&&S.value&&_.value,F=async()=>{if(C)try{var e,r;let t;b.current={title:a.passwordEnabled?(0,c.G)("userProfile.passwordPage.title__update"):(0,c.G)("userProfile.passwordPage.title__set"),text:(e=a.passwordEnabled,r=!!D.checked,t=[],e?t.push((0,c.G)("userProfile.passwordPage.successMessage__update")):t.push((0,c.G)("userProfile.passwordPage.successMessage__set")),r&&t.push((0,c.G)("userProfile.passwordPage.successMessage__signOutOfOtherSessions")),t)};let i={newPassword:S.value,signOutOfOtherSessions:D.checked,currentPassword:P?y.value:void 0};await s(a,[i]),n()}catch(e){(0,G.H4)(e,[y,S,_],p.setError)}};return(0,i.FD)(ec.M,{headerTitle:m,children:[v&&(0,i.Y)(ew.k,{message:(0,c.G)("userProfile.passwordPage.readonly")}),(0,i.FD)(ea.l.Root,{onSubmit:F,onBlur:()=>{S.value&&R(_.value)},children:[(0,i.Y)("input",{readOnly:!0,"data-testid":"hidden-identifier",id:"identifier-field",name:"identifier",value:(null==f?void 0:f.publicUserData.identifier)||"",style:{display:"none"}}),P&&(0,i.Y)(ea.l.ControlRow,{elementId:y.id,children:(0,i.Y)(ea.l.PasswordInput,{...y.props,minLength:6,isRequired:!0,autoFocus:!0,isDisabled:v})}),(0,i.Y)(ea.l.ControlRow,{elementId:S.id,children:(0,i.Y)(ea.l.PasswordInput,{...S.props,minLength:6,isRequired:!0,autoFocus:!a.passwordEnabled,isDisabled:v})}),(0,i.Y)(ea.l.ControlRow,{elementId:_.id,children:(0,i.Y)(ea.l.PasswordInput,{..._.props,onChange:e=>(e.target.value&&R(e.target.value),_.props.onChange(e)),isRequired:!0,isDisabled:v})}),(0,i.Y)(ea.l.ControlRow,{elementId:D.id,children:(0,i.Y)(ea.l.Checkbox,{...D.props,description:(0,c.G)("userProfile.passwordPage.checkboxInfoText__signOutOfOtherSessions"),isDisabled:v})}),v?(0,i.Y)(es.c,{children:(0,i.Y)(ea.l.ResetButton,{localizationKey:(0,c.G)("userProfile.formButtonReset"),block:!1,onClick:o})}):(0,i.Y)(es.G,{isDisabled:!C,onReset:o})]})]})}),rH=()=>{let{close:e}=(0,F.D5)();return(0,i.Y)(rj,{onSuccess:e,onReset:e})},rV=()=>{let{user:e}=(0,Y.Jd)();if(!e)return null;let{passwordEnabled:r}=e;return(0,i.Y)(D.rd.Root,{centered:!1,title:(0,c.G)("userProfile.start.passwordSection.title"),id:"password",children:(0,i.FD)(C.r.Root,{children:[(0,i.Y)(C.r.Closed,{value:"edit",children:(0,i.FD)(D.rd.Item,{id:"password",sx:e=>({paddingLeft:r?void 0:"0",paddingTop:e.space.$0x25,paddingBottom:e.space.$0x25}),children:[r&&(0,i.Y)(y.EY,{variant:"h2",children:"••••••••••"}),(0,i.Y)(C.r.Trigger,{value:"edit",children:(0,i.Y)(D.rd.Button,{id:"password",localizationKey:r?(0,c.G)("userProfile.start.passwordSection.primaryButton__updatePassword"):(0,c.G)("userProfile.start.passwordSection.primaryButton__setPassword")})})]})}),(0,i.Y)(C.r.Open,{value:"edit",children:(0,i.Y)(C.r.Card,{children:(0,i.Y)(rH,{})})})]})})},rZ=(0,d.dm)(()=>{var e;let{attributes:r,instanceIsPasswordBased:t}=(0,g.O)().userSettings,l=(0,d.f0)(),{user:n}=(0,Y.Jd)(),{shouldAllowIdentificationCreation:o}=(0,a.B)(),s=(null==(e=r.passkey)?void 0:e.enabled)&&o,u=H(r).length>0,h=null==n?void 0:n.deleteSelfEnabled;return(0,i.Y)(y.fv,{elementDescriptor:S.$z.page,sx:e=>({gap:e.space.$8}),children:(0,i.FD)(y.fv,{elementDescriptor:S.$z.profilePage,elementId:S.$z.profilePage.setId("security"),children:[(0,i.Y)(b.Y.Root,{children:(0,i.Y)(b.Y.Title,{localizationKey:(0,c.G)("userProfile.start.headerTitle__security"),sx:e=>({marginBottom:e.space.$4}),textVariant:"h2"})}),(0,i.Y)(P.Z.Alert,{children:l.error}),t&&(0,i.Y)(rV,{}),s&&(0,i.Y)(rB,{}),u&&(0,i.Y)(rA,{}),(0,i.Y)(eX,{}),h&&(0,i.Y)(e9,{})]})})}),rX=(0,l.lazy)(()=>Promise.all([t.e("666"),t.e("207"),t.e("259")]).then(t.bind(t,61608)).then(e=>({default:e.BillingPage}))),rQ=(0,l.lazy)(()=>Promise.all([t.e("666"),t.e("326"),t.e("817")]).then(t.bind(t,68201)).then(e=>({default:e.APIKeysPage}))),r0=(0,l.lazy)(()=>Promise.all([t.e("666"),t.e("970"),t.e("110")]).then(t.bind(t,37437)).then(e=>({default:e.PlansPage}))),r1=(0,l.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("627")]).then(t.bind(t,91666)).then(e=>({default:e.StatementPage}))),r2=(0,l.lazy)(()=>Promise.all([t.e("545"),t.e("666"),t.e("122")]).then(t.bind(t,64856)).then(e=>({default:e.PaymentAttemptPage}))),r5=()=>{var e;let{pages:r,shouldShowBilling:t,apiKeysProps:o}=(0,a.B)(),{apiKeysSettings:s,commerceSettings:c}=(0,g.O)(),d=r.routes[0].id===n.j2.ACCOUNT,u=r.routes[0].id===n.j2.SECURITY,h=r.routes[0].id===n.j2.BILLING,p=r.routes[0].id===n.j2.API_KEYS,Y=null==(e=r.contents)?void 0:e.map((e,r)=>{let t=!d&&!u&&0===r;return(0,i.Y)(m.q,{index:t,path:t?void 0:e.url,children:(0,i.Y)(v.H,{mount:e.mount,unmount:e.unmount})},"custom-page-".concat(e.url))});return(0,i.FD)(f.d,{children:[Y,(0,i.FD)(m.q,{children:[(0,i.Y)(m.q,{path:d?void 0:"account",children:(0,i.Y)(f.d,{children:(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(eJ,{})})})}),(0,i.Y)(m.q,{path:u?void 0:"security",children:(0,i.Y)(f.d,{children:(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(rZ,{})})})}),c.billing.user.enabled&&t?(0,i.Y)(m.q,{path:h?void 0:"billing",children:(0,i.FD)(f.d,{children:[(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(l.Suspense,{fallback:"",children:(0,i.Y)(rX,{})})}),c.billing.user.hasPaidPlans?(0,i.Y)(m.q,{path:"plans",children:(0,i.Y)(l.Suspense,{fallback:"",children:(0,i.Y)(r0,{})})}):null,(0,i.Y)(m.q,{path:"statement/:statementId",children:(0,i.Y)(l.Suspense,{fallback:"",children:(0,i.Y)(r1,{})})}),(0,i.Y)(m.q,{path:"payment-attempt/:paymentAttemptId",children:(0,i.Y)(l.Suspense,{fallback:"",children:(0,i.Y)(r2,{})})})]})}):null,s.user_api_keys_enabled&&!(null==o?void 0:o.hide)&&(0,i.Y)(m.q,{path:p?void 0:"api-keys",children:(0,i.Y)(f.d,{children:(0,i.Y)(m.q,{index:!0,children:(0,i.Y)(l.Suspense,{fallback:"",children:(0,i.Y)(rQ,{})})})})})]})]})};var r4=t(10393);let r3=()=>(0,i.Y)(s.n.Root,{flow:"userProfile",children:(0,i.Y)(s.n.Part,{children:(0,i.FD)(f.d,{children:[(0,i.Y)(m.q,{path:"verify",children:(0,i.Y)(r4.G,{})}),(0,i.Y)(m.q,{children:(0,i.Y)(r6,{})})]})})}),r6=(0,o.G)(()=>{let e=l.useRef(null);return(0,i.Y)(h.a.Root,{children:(0,i.FD)(p,{contentRef:e,children:[(0,i.Y)(u.oT,{navbarTitleLocalizationKey:(0,c.G)("userProfile.navbar.title")}),(0,i.Y)(h.a.Content,{contentRef:e,scrollBoxId:n.AG,children:(0,i.Y)(r5,{})})]})})}),r9=(0,d.dm)(r3),r8=(0,d.dm)(r3),r7=e=>{let r={...e,routing:"virtual",componentName:"UserProfile",mode:"modal"};return(0,i.Y)(m.q,{path:"user",children:(0,i.Y)(a.M.Provider,{value:r,children:(0,i.Y)("div",{children:(0,i.Y)(r8,{...r})})})})}},49599:function(e,r,t){t.d(r,{g:()=>n});var i=t(21210),l=t(4964);let n=()=>{let{navigate:e}=(0,l.r)(),r=(0,i.ho)();return{navigateAfterSignOut:()=>e(r.buildAfterSignOutUrl()),navigateAfterMultiSessionSingleSignOutUrl:()=>e(r.buildAfterMultiSessionSingleSignOutUrl()),afterSignOutUrl:r.buildAfterSignOutUrl(),afterMultiSessionSingleSignOutUrl:r.buildAfterMultiSessionSingleSignOutUrl()}}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["636"],{19090:function(e,t,r){r.d(t,{n:()=>a});var i=r(14518),o=r(45170),n=r(22861);let a=e=>{let{onBackLinkClick:t}=e;return(0,i.Y)(o.J,{cardTitle:(0,n.G)("signIn.alternativeMethods.getHelp.title"),cardSubtitle:(0,n.G)("signIn.alternativeMethods.getHelp.content"),onBackLinkClick:t})}},22690:function(e,t,r){r.d(t,{j:()=>a}),r(88711);var i=r(35074),o=r(55763);let n=e=>{if(!e)return"";let t=e.strategy;return"phoneNumberId"in e&&(t+=e.phoneNumberId),t};function a(e){let t=i.useRef(""),[r,a]=i.useState(()=>(0,o.R5)(e)),[l,c]=i.useState(!r),s=t.current===n(r);return{currentFactor:r,factorAlreadyPrepared:s,handleFactorPrepare:()=>{t.current=n(r)},selectFactor:e=>{a(e),c(!1)},showAllStrategies:l,toggleAllStrategies:()=>c(e=>!e)}}},55763:function(e,t,r){r.d(t,{Cm:()=>u,Kw:()=>p,R5:()=>h,UY:()=>v,iy:()=>m,oj:()=>k,xf:()=>s}),r(19161),r(85074),r(30945),r(22501),r(21044);var i=r(62620),o=r(87651),n=r(1959),a=r(68289);let l=e=>t=>"safeIdentifier"in t&&t.safeIdentifier===e;function c(e){if((0,i.Bz)()){let t=e.find(e=>{let{strategy:t}=e;return"passkey"===t});if(t)return t}return null}function s(e,t,r){return e&&0!==e.length?r===n._o.Password?function(e,t){let r=c(e);if(r)return r;let i=e.sort(a.Kn)[0];return"password"===i.strategy?i:e.find(l(t))||i||null}(e,t):function(e,t){let r=c(e);if(r)return r;let i=e.sort(a.Ih),o=i.find(l(t));if(o)return o;let n=i[0];return"email_link"===n.strategy?n:e.find(l(t))||n||null}(e,t):null}let d=["passkey","email_code","password","phone_code","email_link"];function u(e){return!!e&&d.includes(e.strategy)}function h(e){if(!e||0===e.length)return null;let t=e.find(e=>"totp"===e.strategy);if(t)return t;let r=e.find(e=>"phone_code"===e.strategy);return r||e[0]}let f=["reset_password_phone_code","reset_password_email_code"],p=e=>!!e&&f.includes(e);function v(e){let t;return"tel"===e.type?"phoneNumber":(t=e.value,/^\S+@\S+\.\S+$/.test(t))?"emailAddress":"username"}let k=(e,t,r)=>{var i,n;if(!t)return null;let a=null==(i=e.find(e=>"strategy"===e.id))?void 0:i.value;if(a&&"phone_code"!==a)return null;let l=null==(n=e.find(e=>e.id===r))?void 0:n.value;if(!l||!(null==l?void 0:l.startsWith("+")))return null;let c=(0,o.TV)(l,t);return"sms"===c?null:c},m=(e,t,r)=>{if(!e||!t||"phoneNumber"!==t||!r||!(null==r?void 0:r.startsWith("+")))return null;let i=(0,o.TV)(r,e);return"sms"===i?null:i}},49066:function(e,t,r){r.r(t),r.d(t,{UserVerification:()=>eh,UserVerificationModal:()=>ef});var i=r(14518),o=r(35074),n=r(85577),a=r(9078),l=r(44607),c=r(80212),s=r(42265);r(19161),r(95055),r(30945),r(88711);var d=r(63269),u=r(45170),h=r(56980),f=r(97697),p=r(22861),v=r(4964),k=r(55763);r(22239),r(98114);var m=r(38738),Y=r(29),y=r(23707),b=r(76153),g=r(99835),C=r(18272),w=r(58920),F=r(74421),M=r(11051),A=r(30743),_=r(16889),S=r(89830),B=r(62620),G=r(68289);function D(e){let{filterOutFactor:t,supportedFirstFactors:r}=e,i=r?r.filter(e=>!(0,k.Kw)(e.strategy)):[],n=i&&i.length>0,a=(0,o.useMemo)(()=>r?r.filter(e=>!e.strategy.startsWith("oauth_")).filter(e=>(0,k.Cm)(e)).filter(e=>!e||!t||("email_code"===e.strategy&&"email_code"===t.strategy?e.emailAddressId!==t.emailAddressId:"phone_code"===e.strategy&&"phone_code"===t.strategy?e.phoneNumberId!==t.phoneNumberId:e.strategy!==t.strategy)).filter(e=>"passkey"!==e.strategy||(0,B.Bz)()).sort(G.aR):[],[r,t]);return{hasAnyStrategy:n,hasFirstParty:a&&a.length>0,firstPartyFactors:a}}var L=r(21210),I=r(67896);let z=()=>{let{session:e}=(0,L.wV)(),t=(()=>{let{level:e}=(0,a.k)();return(0,o.useMemo)(()=>({level:e||"second_factor"}),[e])})();return{...(0,I.s)(e?e.startVerification:void 0,t,{throttleTime:300})}};function T(e){let t=t=>{let{isLoading:r,data:o}=z();return r||!o?(0,i.Y)(h.B,{}):(0,i.Y)(e,{...t})},r=e.displayName||e.name||"Component";return e.displayName=r,t.displayName=r,t}let Z=e=>{let{onBackLinkClick:t}=e;return(0,i.Y)(u.J,{cardTitle:(0,p.G)("reverification.alternativeMethods.getHelp.title"),cardSubtitle:(0,p.G)("reverification.alternativeMethods.getHelp.content"),onBackLinkClick:t})},P=e=>((e,t)=>{let[r,n]=o.useState(!1),a=o.useCallback(()=>n(e=>!e),[n]);return r?(0,i.Y)(Z,{onBackLinkClick:a}):(0,i.Y)(e,{...t,onHavingTroubleClick:a})})(V,{...e}),V=e=>{let{onBackLinkClick:t,onHavingTroubleClick:r,onFactorSelected:o}=e,n=(0,d.f0)(),{data:a}=z(),{firstPartyFactors:c,hasAnyStrategy:s}=D({filterOutFactor:null==e?void 0:e.currentFactor,supportedFirstFactors:null==a?void 0:a.supportedFirstFactors});return(0,i.Y)(l.n.Part,{part:"alternativeMethods",children:(0,i.FD)(y.Z.Root,{children:[(0,i.FD)(y.Z.Content,{children:[(0,i.FD)(b.Y.Root,{children:[(0,i.Y)(b.Y.Title,{localizationKey:(0,p.G)("reverification.alternativeMethods.title")}),(0,i.Y)(b.Y.Subtitle,{localizationKey:(0,p.G)("reverification.alternativeMethods.subtitle")})]}),(0,i.Y)(y.Z.Alert,{children:n.error}),(0,i.Y)(C.so,{direction:"col",elementDescriptor:w.$z.main,gap:6,children:(0,i.FD)(C.fv,{gap:4,children:[s&&(0,i.Y)(C.so,{elementDescriptor:w.$z.alternativeMethods,direction:"col",gap:2,children:c.map((e,t)=>{var r;return(0,i.Y)(m.X,{leftIcon:(r=e,({email_code:F.A,phone_code:M.A,password:A.A,passkey:_.A,enterprise_sso:S.A})[r.strategy]),textLocalizationKey:function(e){switch(e.strategy){case"email_code":return(0,p.G)("reverification.alternativeMethods.blockButton__emailCode",{identifier:(0,g.u)(e.safeIdentifier)||""});case"phone_code":return(0,p.G)("reverification.alternativeMethods.blockButton__phoneCode",{identifier:(0,g.u)(e.safeIdentifier)||""});case"password":return(0,p.G)("reverification.alternativeMethods.blockButton__password");case"passkey":return(0,p.G)("reverification.alternativeMethods.blockButton__passkey");default:throw Error('Invalid sign in strategy: "'.concat(e.strategy,'"'))}}(e),elementDescriptor:w.$z.alternativeMethodsBlockButton,textElementDescriptor:w.$z.alternativeMethodsBlockButtonText,arrowElementDescriptor:w.$z.alternativeMethodsBlockButtonArrow,textVariant:"buttonLarge",isDisabled:n.isLoading,onClick:()=>{n.setError(void 0),o(e)}},t)})}),t&&(0,i.Y)(Y.E,{boxElementDescriptor:w.$z.backRow,linkElementDescriptor:w.$z.backLink,onClick:t})]})})]}),(0,i.Y)(y.Z.Footer,{children:(0,i.FD)(y.Z.Action,{elementId:"havingTrouble",children:[(0,i.Y)(y.Z.ActionText,{localizationKey:(0,p.G)("reverification.alternativeMethods.actionText")}),(0,i.Y)(y.Z.ActionLink,{localizationKey:(0,p.G)("reverification.alternativeMethods.actionLink"),onClick:r})]})})]})})};var R=r(52454),E=r(4468),K=r(8640),x=r(19090),N=r(31475),$=r(19426);let U=()=>{let{afterVerification:e}=(0,a.k)(),t=(0,$.p)(),{setActive:r}=(0,L.ho)(),{setCache:i}=z(),{navigate:n}=(0,v.r)();return{handleVerificationResponse:(0,o.useCallback)(async o=>{switch(i({data:o,isLoading:!1,isValidating:!1,error:null,cachedAt:Date.now()}),o.status){case"complete":return await r({session:o.session.id}),null==e?void 0:e();case"needs_second_factor":return n("./factor-two");default:return console.error((0,N.wv)(o.status,t))}},[n,r,t])}};function H(e){let{onShowAlternativeMethodsClick:t}=e,{session:r}=(0,L.wV)(),{handleVerificationResponse:n}=U(),a=(0,d.f0)(),[c,s]=o.useState(!1),u=o.useCallback(()=>s(e=>!e),[s]),h=(0,K.tJ)("password","",{type:"password",label:(0,p.G)("formFieldLabel__password"),placeholder:(0,p.G)("formFieldInputPlaceholder__password")}),f=async e=>(e.preventDefault(),null==r?void 0:r.attemptFirstFactorVerification({strategy:"password",password:h.value}).then(n).catch(e=>(0,E.H4)(e,[h],a.setError)));return c?(0,i.Y)(x.n,{onBackLinkClick:u}):(0,i.Y)(l.n.Part,{part:"password",children:(0,i.FD)(y.Z.Root,{children:[(0,i.FD)(y.Z.Content,{children:[(0,i.FD)(b.Y.Root,{showLogo:!0,children:[(0,i.Y)(b.Y.Title,{localizationKey:(0,p.G)("reverification.password.title")}),(0,i.Y)(b.Y.Subtitle,{localizationKey:(0,p.G)("reverification.password.subtitle")})]}),(0,i.Y)(y.Z.Alert,{children:a.error}),(0,i.FD)(C.fv,{elementDescriptor:w.$z.main,gap:4,children:[(0,i.FD)(R.l.Root,{onSubmit:f,gap:8,children:[(0,i.Y)(R.l.ControlRow,{elementId:h.id,children:(0,i.Y)(R.l.PasswordInput,{...h.props,autoFocus:!0})}),(0,i.Y)(R.l.SubmitButton,{hasArrow:!0})]}),(0,i.Y)(y.Z.Action,{elementId:t?"alternativeMethods":"havingTrouble",children:(0,i.Y)(y.Z.ActionLink,{localizationKey:(0,p.G)(t?"reverification.password.actionLink":"reverification.alternativeMethods.actionLink"),onClick:t||u})})]})]}),(0,i.Y)(y.Z.Footer,{})]})})}function j(e,t){return"primary"in e&&e.primary&&!("primary"in t&&t.primary)?-1:"primary"in t&&t.primary&&!("primary"in e&&e.primary)?1:0}var J=r(27912);let W=e=>{var t;let{session:r}=(0,L.wV)(),n=(0,d.f0)(),{handleVerificationResponse:a}=U();o.useEffect(()=>{e.factorAlreadyPrepared||l()},[]);let l=()=>{r.prepareFirstFactorVerification(e.factor).then(()=>e.onFactorPrepare()).catch(e=>(0,E.H4)(e,[],n.setError))};return(0,i.Y)(J.j,{cardTitle:e.cardTitle,cardSubtitle:e.cardSubtitle,inputLabel:e.inputLabel,resendButton:e.resendButton,onCodeEntryFinishedAction:(t,i,o)=>{r.attemptFirstFactorVerification({strategy:e.factor.strategy,code:t}).then(async e=>(await i(),a(e))).catch(o)},onResendCodeClicked:l,safeIdentifier:e.factor.safeIdentifier,profileImageUrl:null==r||null==(t=r.user)?void 0:t.imageUrl,onShowAlternativeMethodsClicked:e.onShowAlternativeMethodsClicked,showAlternativeMethods:e.showAlternativeMethods,onBackLinkClicked:e.onBackLinkClicked})},q=e=>(0,i.Y)(l.n.Part,{part:"emailCode",children:(0,i.Y)(W,{...e,cardTitle:(0,p.G)("reverification.emailCode.title"),cardSubtitle:(0,p.G)("reverification.emailCode.subtitle"),inputLabel:(0,p.G)("reverification.emailCode.formTitle"),resendButton:(0,p.G)("reverification.emailCode.resendButton")})}),O=e=>{let{onShowAlternativeMethodsClicked:t}=e,{session:r}=(0,L.wV)(),{__internal_isWebAuthnSupported:o}=(0,L.ho)(),{handleVerificationResponse:n}=U(),a=(0,d.f0)();return(0,i.FD)(y.Z.Root,{children:[(0,i.FD)(y.Z.Content,{children:[(0,i.FD)(b.Y.Root,{showLogo:!0,children:[(0,i.Y)(b.Y.Title,{localizationKey:(0,p.G)("reverification.passkey.title")}),(0,i.Y)(b.Y.Subtitle,{localizationKey:(0,p.G)("reverification.passkey.subtitle")})]}),(0,i.Y)(y.Z.Alert,{children:a.error}),(0,i.Y)(C.fv,{elementDescriptor:w.$z.main,gap:8,children:(0,i.Y)(R.l.Root,{children:(0,i.FD)(C.fv,{gap:3,children:[(0,i.Y)(C.$n,{type:"button",onClick:e=>{e.preventDefault(),null==r||r.verifyWithPasskey().then(e=>n(e)).catch(e=>(0,E.H4)(e,[],a.setError))},localizationKey:(0,p.G)("reverification.passkey.blockButton__passkey"),hasArrow:!0}),(0,i.Y)(y.Z.Action,{elementId:"alternativeMethods",children:t&&(0,i.Y)(y.Z.ActionLink,{localizationKey:(0,p.G)("footerActionLink__useAnotherMethod"),onClick:t})})]})})})]}),(0,i.Y)(y.Z.Footer,{})]})},X=e=>(0,i.Y)(l.n.Part,{part:"phoneCode",children:(0,i.Y)(W,{...e,cardTitle:(0,p.G)("reverification.phoneCode.title"),cardSubtitle:(0,p.G)("reverification.phoneCode.subtitle"),inputLabel:(0,p.G)("reverification.phoneCode.formTitle"),resendButton:(0,p.G)("reverification.phoneCode.resendButton"),showAlternativeMethods:e.showAlternativeMethods})}),Q=e=>{if(!e)return"";let t=e.strategy;return"emailAddressId"in e&&(t+=e.emailAddressId),"phoneNumberId"in e&&(t+=e.phoneNumberId),t},ee=["password","email_code","phone_code","passkey"],et=T((0,d.dm)(function(){let{data:e}=z(),t=(0,d.f0)(),{navigate:r}=(0,v.r)(),n=o.useRef(""),a=(0,o.useMemo)(()=>{var t,r;return(null==(r=e.supportedFirstFactors)||null==(t=r.filter(e=>ee.includes(e.strategy)))?void 0:t.sort(j))||null},[e.supportedFirstFactors]),{preferredSignInStrategy:l}=(0,f.O)().displayConfig,[{currentFactor:c},s]=o.useState(()=>({currentFactor:(0,k.xf)(a,null,l),prevCurrentFactor:void 0})),{hasAnyStrategy:m,hasFirstParty:Y}=D({filterOutFactor:c,supportedFirstFactors:a}),[y,b]=o.useState(()=>!c||!(0,k.Cm)(c)),g=m?()=>{t.setError(void 0),b(e=>!e)}:void 0,C=()=>{n.current=Q(c)};if((0,o.useEffect)(()=>{"needs_second_factor"===e.status&&r("factor-two")},[]),!c)return(0,i.Y)(u.J,{cardTitle:(0,p.G)("reverification.noAvailableMethods.title"),cardSubtitle:(0,p.G)("reverification.noAvailableMethods.subtitle"),message:(0,p.G)("reverification.noAvailableMethods.message"),shouldNavigateBack:!1});if(y){let e=(0,k.Cm)(c);return(0,i.Y)(P,{onBackLinkClick:e?()=>{t.setError(void 0),null==g||g()}:void 0,onFactorSelected:e=>{s(t=>({currentFactor:e,prevCurrentFactor:t.currentFactor})),null==g||g()},currentFactor:c})}switch(null==c?void 0:c.strategy){case"password":return(0,i.Y)(H,{onShowAlternativeMethodsClick:g});case"email_code":return(0,i.Y)(q,{factorAlreadyPrepared:n.current===Q(c),onFactorPrepare:C,onShowAlternativeMethodsClicked:g,factor:c,showAlternativeMethods:Y});case"phone_code":return(0,i.Y)(X,{factorAlreadyPrepared:n.current===Q(c),onFactorPrepare:C,onShowAlternativeMethodsClicked:g,factor:c,showAlternativeMethods:Y});case"passkey":return(0,i.Y)(O,{onShowAlternativeMethodsClicked:g});default:return(0,i.Y)(h.B,{})}}));var er=r(22690);let ei=e=>{var t;let r=(0,d.f0)(),{session:n}=(0,L.wV)(),{handleVerificationResponse:a}=U();o.useEffect(()=>{e.factorAlreadyPrepared||null==l||l()},[]);let l=e.prepare?()=>{var t;return null==(t=e.prepare)?void 0:t.call(e).then(()=>e.onFactorPrepare()).catch(e=>(0,E.H4)(e,[],r.setError))}:void 0;return(0,i.Y)(J.j,{cardTitle:e.cardTitle,cardSubtitle:e.cardSubtitle,resendButton:e.resendButton,inputLabel:e.inputLabel,onCodeEntryFinishedAction:(t,r,i)=>{n.attemptSecondFactorVerification({strategy:e.factor.strategy,code:t}).then(async e=>(await r(),a(e))).catch(i)},onResendCodeClicked:l,safeIdentifier:"safeIdentifier"in e.factor?e.factor.safeIdentifier:void 0,profileImageUrl:null==n||null==(t=n.user)?void 0:t.imageUrl,onShowAlternativeMethodsClicked:e.onShowAlternativeMethodsClicked,showAlternativeMethods:e.showAlternativeMethods})};function eo(e){return(0,i.Y)(l.n.Part,{part:"totp2Fa",children:(0,i.Y)(ei,{...e,cardTitle:(0,p.G)("reverification.totpMfa.title"),cardSubtitle:(0,p.G)("reverification.totpMfa.subtitle"),inputLabel:(0,p.G)("reverification.totpMfa.formTitle"),showAlternativeMethods:e.showAlternativeMethods})})}let en=e=>{let[t,r]=o.useState(!1),n=o.useCallback(()=>r(e=>!e),[r]);return t?(0,i.Y)(Z,{onBackLinkClick:n}):(0,i.Y)(ea,{supportedSecondFactors:e.supportedSecondFactors,onBackLinkClick:e.onBackLinkClick,onFactorSelected:e.onFactorSelected,onHavingTroubleClick:n})},ea=e=>{let{supportedSecondFactors:t,onHavingTroubleClick:r,onFactorSelected:o,onBackLinkClick:n}=e,a=(0,d.f0)();return(0,i.Y)(l.n.Part,{part:"alternativeMethods",children:(0,i.FD)(y.Z.Root,{children:[(0,i.FD)(y.Z.Content,{children:[(0,i.FD)(b.Y.Root,{showLogo:!0,children:[(0,i.Y)(b.Y.Title,{localizationKey:(0,p.G)("reverification.alternativeMethods.title")}),(0,i.Y)(b.Y.Subtitle,{localizationKey:(0,p.G)("reverification.alternativeMethods.subtitle")})]}),(0,i.Y)(y.Z.Alert,{children:a.error}),(0,i.FD)(C.fv,{elementDescriptor:w.$z.main,gap:3,children:[(0,i.Y)(C.fv,{gap:2,children:null==t?void 0:t.sort(G.Wy).map((e,t)=>(0,i.Y)(m.X,{textLocalizationKey:function(e){switch(e.strategy){case"phone_code":return(0,p.G)("reverification.alternativeMethods.blockButton__phoneCode",{identifier:(0,g.u)(e.safeIdentifier)||""});case"totp":return(0,p.G)("reverification.alternativeMethods.blockButton__totp");case"backup_code":return(0,p.G)("reverification.alternativeMethods.blockButton__backupCode");default:throw Error('Invalid verification strategy: "'.concat(e.strategy,'"'))}}(e),elementDescriptor:w.$z.alternativeMethodsBlockButton,textElementDescriptor:w.$z.alternativeMethodsBlockButtonText,arrowElementDescriptor:w.$z.alternativeMethodsBlockButtonArrow,isDisabled:a.isLoading,onClick:()=>o(e)},t))}),(0,i.Y)(y.Z.Action,{elementId:"alternativeMethods",children:n&&(0,i.Y)(y.Z.ActionLink,{localizationKey:(0,p.G)("backButton"),onClick:e.onBackLinkClick})})]})]}),(0,i.Y)(y.Z.Footer,{children:(0,i.FD)(y.Z.Action,{elementId:"havingTrouble",children:[(0,i.Y)(y.Z.ActionText,{localizationKey:(0,p.G)("reverification.alternativeMethods.actionText")}),(0,i.Y)(y.Z.ActionLink,{localizationKey:(0,p.G)("reverification.alternativeMethods.actionLink"),onClick:r})]})})]})})},el=e=>{let{onShowAlternativeMethodsClicked:t}=e,{session:r}=(0,L.wV)(),{handleVerificationResponse:o}=U(),n=(0,d.f0)(),a=(0,K.tJ)("code","",{type:"text",label:(0,p.G)("formFieldLabel__backupCode"),isRequired:!0});return(0,i.FD)(y.Z.Root,{children:[(0,i.FD)(y.Z.Content,{children:[(0,i.FD)(b.Y.Root,{showLogo:!0,children:[(0,i.Y)(b.Y.Title,{localizationKey:(0,p.G)("reverification.backupCodeMfa.title")}),(0,i.Y)(b.Y.Subtitle,{localizationKey:(0,p.G)("reverification.backupCodeMfa.subtitle")})]}),(0,i.Y)(y.Z.Alert,{children:n.error}),(0,i.Y)(C.fv,{elementDescriptor:w.$z.main,gap:8,children:(0,i.FD)(R.l.Root,{onSubmit:e=>(e.preventDefault(),r.attemptSecondFactorVerification({strategy:"backup_code",code:a.value}).then(o).catch(e=>(0,E.H4)(e,[a],n.setError))),children:[(0,i.Y)(R.l.ControlRow,{elementId:a.id,children:(0,i.Y)(R.l.PlainInput,{...a.props,autoFocus:!0,onActionClicked:t})}),(0,i.FD)(C.fv,{gap:3,children:[(0,i.Y)(R.l.SubmitButton,{hasArrow:!0}),(0,i.Y)(y.Z.Action,{elementId:"alternativeMethods",children:t&&(0,i.Y)(y.Z.ActionLink,{localizationKey:(0,p.G)("footerActionLink__useAnotherMethod"),onClick:t})})]})]})})]}),(0,i.Y)(y.Z.Footer,{})]})},ec=e=>{let{session:t}=(0,L.wV)();return(0,i.Y)(l.n.Part,{part:"phoneCode2Fa",children:(0,i.Y)(ei,{...e,cardTitle:(0,p.G)("reverification.phoneCodeMfa.title"),cardSubtitle:(0,p.G)("reverification.phoneCodeMfa.subtitle"),inputLabel:(0,p.G)("reverification.phoneCodeMfa.formTitle"),resendButton:(0,p.G)("reverification.phoneCodeMfa.resendButton"),prepare:()=>{let{phoneNumberId:r,strategy:i}=e.factor;return t.prepareSecondFactorVerification({phoneNumberId:r,strategy:i})}})})},es=["phone_code","totp","backup_code"],ed=T((0,d.dm)(function(){let{navigate:e}=(0,v.r)(),{data:t}=z(),r=(0,o.useMemo)(()=>{var e,r;return(null==(r=t.supportedSecondFactors)||null==(e=r.filter(e=>es.includes(e.strategy)))?void 0:e.sort(j))||null},[t.supportedSecondFactors]),{currentFactor:n,factorAlreadyPrepared:a,handleFactorPrepare:l,selectFactor:c,showAllStrategies:s,toggleAllStrategies:d}=(0,er.j)(r),u=(0,o.useMemo)(()=>null==r?void 0:r.filter(e=>!e||!n||("phone_code"===e.strategy&&"phone_code"===n.strategy?e.phoneNumberId!==n.phoneNumberId:e.strategy!==n.strategy)),[r,n]),f=(0,o.useMemo)(()=>u&&u.length>0||!1,[u]);if((0,o.useEffect)(()=>{"needs_first_factor"===t.status&&e("../")},[]),!n)return(0,i.Y)(h.B,{});if(s&&f)return(0,i.Y)(en,{supportedSecondFactors:u||null,onBackLinkClick:d,onFactorSelected:c});switch(null==n?void 0:n.strategy){case"phone_code":return(0,i.Y)(ec,{factorAlreadyPrepared:a,onFactorPrepare:l,factor:n,onShowAlternativeMethodsClicked:d,showAlternativeMethods:f});case"totp":return(0,i.Y)(eo,{factorAlreadyPrepared:a,onFactorPrepare:l,factor:n,onShowAlternativeMethodsClicked:d,showAlternativeMethods:f});case"backup_code":return(0,i.Y)(el,{onShowAlternativeMethodsClicked:d});default:return(0,i.Y)(h.B,{})}}));function eu(){let{invalidate:e}=z();return(0,o.useEffect)(()=>()=>{e()},[]),(0,i.Y)(l.n.Root,{flow:"userVerification",children:(0,i.FD)(c.d,{children:[(0,i.Y)(s.q,{path:"factor-two",children:(0,i.Y)(ed,{})}),(0,i.Y)(s.q,{index:!0,children:(0,i.Y)(et,{})})]})})}eu.displayName="UserVerification";let eh=(0,n.Z)(eu),ef=e=>(0,i.Y)(s.q,{path:"user-verification",children:(0,i.Y)(a._.Provider,{value:{componentName:"UserVerification",...e,routing:"virtual"},children:(0,i.Y)("div",{children:(0,i.Y)(eh,{...e,routing:"virtual"})})})})},9078:function(e,t,r){r.d(t,{_:()=>o,k:()=>n}),r(98114);var i=r(35074);let o=(0,i.createContext)(null),n=()=>{let e=(0,i.useContext)(o);if(!e||"UserVerification"!==e.componentName)throw Error("Clerk: useUserVerificationContext called outside of the mounted UserVerification component.");let{componentName:t,...r}=e;return{...r,componentName:t}}}}]);
@@ -33,12 +33,6 @@ const handleError = (err, fieldStates, setGlobalError) => {
33
33
  if (isClerkRuntimeError(err) && err.code === "reverification_cancelled") return;
34
34
  if (isClerkRuntimeError(err)) return handleClerkRuntimeError(err, fieldStates, setGlobalError);
35
35
  };
36
- function getFieldError(err) {
37
- if (!isClerkAPIResponseError(err)) return;
38
- const { fieldErrors } = parseErrors(err.errors);
39
- if (!fieldErrors.length) return;
40
- return fieldErrors[0];
41
- }
42
36
  const handleMetamaskError = (err, _, setGlobalError) => {
43
37
  return setGlobalError?.(err.message);
44
38
  };
@@ -62,5 +56,5 @@ const handleClerkRuntimeError = (err, _, setGlobalError) => {
62
56
  };
63
57
 
64
58
  //#endregion
65
- export { getFieldError, handleError };
59
+ export { handleError };
66
60
  //# sourceMappingURL=errorHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorHandler.js","names":["handleError: HandleError","handleMetamaskError: HandleError","handleClerkApiError: HandleError","handleClerkRuntimeError: HandleError"],"sources":["../../src/utils/errorHandler.ts"],"sourcesContent":["import { isClerkAPIResponseError, isClerkRuntimeError, isKnownError, isMetamaskError } from '@clerk/shared/error';\nimport type { ClerkAPIError, ClerkRuntimeError } from '@clerk/shared/types';\nimport { snakeToCamel } from '@clerk/shared/underscore';\n\nimport type { FormControlState } from './useFormControl';\n\ninterface ParserErrors {\n fieldErrors: ClerkAPIError[];\n globalErrors: ClerkAPIError[];\n}\n\nconst getFirstError = (err: ClerkAPIError[]) => err[0];\n\nfunction setFieldErrors(fieldStates: Array<FormControlState<string>>, errors: ClerkAPIError[]) {\n if (!errors || errors.length < 1) {\n return;\n }\n\n fieldStates.forEach(field => {\n let buildErrorMessage = field?.buildErrorMessage;\n\n if (!buildErrorMessage) {\n buildErrorMessage = getFirstError;\n }\n\n const errorsArray = errors.filter(err => {\n return err.meta?.paramName === field.id || snakeToCamel(err.meta?.paramName) === field.id;\n });\n\n const errorMessage = buildErrorMessage(errorsArray);\n if (errorsArray.length && errorMessage) {\n field.setError(errorMessage);\n } else {\n field.clearFeedback();\n }\n });\n}\n\nfunction parseErrors(errors: ClerkAPIError[]): ParserErrors {\n return (errors || []).reduce(\n (memo, err) => {\n if (err.meta?.paramName) {\n memo.fieldErrors.push(err);\n } else {\n memo.globalErrors.push(err);\n }\n return memo;\n },\n {\n fieldErrors: Array<ClerkAPIError>(0),\n globalErrors: Array<ClerkAPIError>(0),\n },\n );\n}\n\ntype HandleError = {\n (\n err: Error,\n fieldStates: Array<FormControlState<string>>,\n setGlobalError?: (err: ClerkRuntimeError | ClerkAPIError | string | undefined) => void,\n ): void;\n};\n\nexport const handleError: HandleError = (err, fieldStates, setGlobalError) => {\n // Throw unknown errors\n if (!isKnownError(err)) {\n throw err;\n }\n\n if (isMetamaskError(err)) {\n return handleMetamaskError(err, fieldStates, setGlobalError);\n }\n\n if (isClerkAPIResponseError(err)) {\n return handleClerkApiError(err, fieldStates, setGlobalError);\n }\n\n if (isClerkRuntimeError(err) && err.code === 'reverification_cancelled') {\n // Don't log or display an error for cancelled reverification, the user simply closed the modal.\n return;\n }\n\n if (isClerkRuntimeError(err)) {\n return handleClerkRuntimeError(err, fieldStates, setGlobalError);\n }\n};\n\n// Returns the first global API error or undefined if none exists.\nexport function getGlobalError(err: Error): ClerkAPIError | undefined {\n if (!isClerkAPIResponseError(err)) {\n return;\n }\n const { globalErrors } = parseErrors(err.errors);\n if (!globalErrors.length) {\n return;\n }\n return globalErrors[0];\n}\n\n// Returns the first field API error or undefined if none exists.\nexport function getFieldError(err: Error): ClerkAPIError | undefined {\n if (!isClerkAPIResponseError(err)) {\n return;\n }\n const { fieldErrors } = parseErrors(err.errors);\n\n if (!fieldErrors.length) {\n return;\n }\n\n return fieldErrors[0];\n}\n\nexport function getClerkAPIErrorMessage(err: ClerkAPIError): string {\n return err.longMessage || err.message;\n}\n\nconst handleMetamaskError: HandleError = (err, _, setGlobalError) => {\n return setGlobalError?.(err.message);\n};\n\nconst handleClerkApiError: HandleError = (err, fieldStates, setGlobalError) => {\n if (!isClerkAPIResponseError(err)) {\n return;\n }\n\n const { fieldErrors, globalErrors } = parseErrors(err.errors);\n setFieldErrors(fieldStates, fieldErrors);\n\n if (setGlobalError) {\n setGlobalError(undefined);\n // Show only the first global error until we have snack bar stacks if applicable\n // TODO: Make global errors localizable\n const firstGlobalError = globalErrors[0];\n if (firstGlobalError) {\n setGlobalError(firstGlobalError);\n }\n }\n};\n\nconst handleClerkRuntimeError: HandleError = (err, _, setGlobalError) => {\n if (!isClerkRuntimeError(err)) {\n return;\n }\n\n if (setGlobalError) {\n setGlobalError(undefined);\n const firstGlobalError = err;\n if (firstGlobalError) {\n setGlobalError(firstGlobalError);\n }\n }\n};\n"],"mappings":";;;;AAWA,MAAM,iBAAiB,QAAyB,IAAI;AAEpD,SAAS,eAAe,aAA8C,QAAyB;AAC7F,KAAI,CAAC,UAAU,OAAO,SAAS,EAC7B;AAGF,aAAY,SAAQ,UAAS;EAC3B,IAAI,oBAAoB,OAAO;AAE/B,MAAI,CAAC,kBACH,qBAAoB;EAGtB,MAAM,cAAc,OAAO,QAAO,QAAO;AACvC,UAAO,IAAI,MAAM,cAAc,MAAM,MAAM,aAAa,IAAI,MAAM,UAAU,KAAK,MAAM;IACvF;EAEF,MAAM,eAAe,kBAAkB,YAAY;AACnD,MAAI,YAAY,UAAU,aACxB,OAAM,SAAS,aAAa;MAE5B,OAAM,eAAe;GAEvB;;AAGJ,SAAS,YAAY,QAAuC;AAC1D,SAAQ,UAAU,EAAE,EAAE,QACnB,MAAM,QAAQ;AACb,MAAI,IAAI,MAAM,UACZ,MAAK,YAAY,KAAK,IAAI;MAE1B,MAAK,aAAa,KAAK,IAAI;AAE7B,SAAO;IAET;EACE,aAAa,MAAqB,EAAE;EACpC,cAAc,MAAqB,EAAE;EACtC,CACF;;AAWH,MAAaA,eAA4B,KAAK,aAAa,mBAAmB;AAE5E,KAAI,CAAC,aAAa,IAAI,CACpB,OAAM;AAGR,KAAI,gBAAgB,IAAI,CACtB,QAAO,oBAAoB,KAAK,aAAa,eAAe;AAG9D,KAAI,wBAAwB,IAAI,CAC9B,QAAO,oBAAoB,KAAK,aAAa,eAAe;AAG9D,KAAI,oBAAoB,IAAI,IAAI,IAAI,SAAS,2BAE3C;AAGF,KAAI,oBAAoB,IAAI,CAC1B,QAAO,wBAAwB,KAAK,aAAa,eAAe;;AAiBpE,SAAgB,cAAc,KAAuC;AACnE,KAAI,CAAC,wBAAwB,IAAI,CAC/B;CAEF,MAAM,EAAE,gBAAgB,YAAY,IAAI,OAAO;AAE/C,KAAI,CAAC,YAAY,OACf;AAGF,QAAO,YAAY;;AAOrB,MAAMC,uBAAoC,KAAK,GAAG,mBAAmB;AACnE,QAAO,iBAAiB,IAAI,QAAQ;;AAGtC,MAAMC,uBAAoC,KAAK,aAAa,mBAAmB;AAC7E,KAAI,CAAC,wBAAwB,IAAI,CAC/B;CAGF,MAAM,EAAE,aAAa,iBAAiB,YAAY,IAAI,OAAO;AAC7D,gBAAe,aAAa,YAAY;AAExC,KAAI,gBAAgB;AAClB,iBAAe,OAAU;EAGzB,MAAM,mBAAmB,aAAa;AACtC,MAAI,iBACF,gBAAe,iBAAiB;;;AAKtC,MAAMC,2BAAwC,KAAK,GAAG,mBAAmB;AACvE,KAAI,CAAC,oBAAoB,IAAI,CAC3B;AAGF,KAAI,gBAAgB;AAClB,iBAAe,OAAU;EACzB,MAAM,mBAAmB;AACzB,MAAI,iBACF,gBAAe,iBAAiB"}
1
+ {"version":3,"file":"errorHandler.js","names":["handleError: HandleError","handleMetamaskError: HandleError","handleClerkApiError: HandleError","handleClerkRuntimeError: HandleError"],"sources":["../../src/utils/errorHandler.ts"],"sourcesContent":["import { isClerkAPIResponseError, isClerkRuntimeError, isKnownError, isMetamaskError } from '@clerk/shared/error';\nimport type { ClerkAPIError, ClerkRuntimeError } from '@clerk/shared/types';\nimport { snakeToCamel } from '@clerk/shared/underscore';\n\nimport type { FormControlState } from './useFormControl';\n\ninterface ParserErrors {\n fieldErrors: ClerkAPIError[];\n globalErrors: ClerkAPIError[];\n}\n\nconst getFirstError = (err: ClerkAPIError[]) => err[0];\n\nfunction setFieldErrors(fieldStates: Array<FormControlState<string>>, errors: ClerkAPIError[]) {\n if (!errors || errors.length < 1) {\n return;\n }\n\n fieldStates.forEach(field => {\n let buildErrorMessage = field?.buildErrorMessage;\n\n if (!buildErrorMessage) {\n buildErrorMessage = getFirstError;\n }\n\n const errorsArray = errors.filter(err => {\n return err.meta?.paramName === field.id || snakeToCamel(err.meta?.paramName) === field.id;\n });\n\n const errorMessage = buildErrorMessage(errorsArray);\n if (errorsArray.length && errorMessage) {\n field.setError(errorMessage);\n } else {\n field.clearFeedback();\n }\n });\n}\n\nfunction parseErrors(errors: ClerkAPIError[]): ParserErrors {\n return (errors || []).reduce(\n (memo, err) => {\n if (err.meta?.paramName) {\n memo.fieldErrors.push(err);\n } else {\n memo.globalErrors.push(err);\n }\n return memo;\n },\n {\n fieldErrors: Array<ClerkAPIError>(0),\n globalErrors: Array<ClerkAPIError>(0),\n },\n );\n}\n\ntype HandleError = {\n (\n err: Error,\n fieldStates: Array<FormControlState<string>>,\n setGlobalError?: (err: ClerkRuntimeError | ClerkAPIError | string | undefined) => void,\n ): void;\n};\n\nexport const handleError: HandleError = (err, fieldStates, setGlobalError) => {\n // Throw unknown errors\n if (!isKnownError(err)) {\n throw err;\n }\n\n if (isMetamaskError(err)) {\n return handleMetamaskError(err, fieldStates, setGlobalError);\n }\n\n if (isClerkAPIResponseError(err)) {\n return handleClerkApiError(err, fieldStates, setGlobalError);\n }\n\n if (isClerkRuntimeError(err) && err.code === 'reverification_cancelled') {\n // Don't log or display an error for cancelled reverification, the user simply closed the modal.\n return;\n }\n\n if (isClerkRuntimeError(err)) {\n return handleClerkRuntimeError(err, fieldStates, setGlobalError);\n }\n};\n\n// Returns the first global API error or undefined if none exists.\nexport function getGlobalError(err: Error): ClerkAPIError | undefined {\n if (!isClerkAPIResponseError(err)) {\n return;\n }\n const { globalErrors } = parseErrors(err.errors);\n if (!globalErrors.length) {\n return;\n }\n return globalErrors[0];\n}\n\n// Returns the first field API error or undefined if none exists.\nexport function getFieldError(err: Error): ClerkAPIError | undefined {\n if (!isClerkAPIResponseError(err)) {\n return;\n }\n const { fieldErrors } = parseErrors(err.errors);\n\n if (!fieldErrors.length) {\n return;\n }\n\n return fieldErrors[0];\n}\n\nexport function getClerkAPIErrorMessage(err: ClerkAPIError): string {\n return err.longMessage || err.message;\n}\n\nconst handleMetamaskError: HandleError = (err, _, setGlobalError) => {\n return setGlobalError?.(err.message);\n};\n\nconst handleClerkApiError: HandleError = (err, fieldStates, setGlobalError) => {\n if (!isClerkAPIResponseError(err)) {\n return;\n }\n\n const { fieldErrors, globalErrors } = parseErrors(err.errors);\n setFieldErrors(fieldStates, fieldErrors);\n\n if (setGlobalError) {\n setGlobalError(undefined);\n // Show only the first global error until we have snack bar stacks if applicable\n // TODO: Make global errors localizable\n const firstGlobalError = globalErrors[0];\n if (firstGlobalError) {\n setGlobalError(firstGlobalError);\n }\n }\n};\n\nconst handleClerkRuntimeError: HandleError = (err, _, setGlobalError) => {\n if (!isClerkRuntimeError(err)) {\n return;\n }\n\n if (setGlobalError) {\n setGlobalError(undefined);\n const firstGlobalError = err;\n if (firstGlobalError) {\n setGlobalError(firstGlobalError);\n }\n }\n};\n"],"mappings":";;;;AAWA,MAAM,iBAAiB,QAAyB,IAAI;AAEpD,SAAS,eAAe,aAA8C,QAAyB;AAC7F,KAAI,CAAC,UAAU,OAAO,SAAS,EAC7B;AAGF,aAAY,SAAQ,UAAS;EAC3B,IAAI,oBAAoB,OAAO;AAE/B,MAAI,CAAC,kBACH,qBAAoB;EAGtB,MAAM,cAAc,OAAO,QAAO,QAAO;AACvC,UAAO,IAAI,MAAM,cAAc,MAAM,MAAM,aAAa,IAAI,MAAM,UAAU,KAAK,MAAM;IACvF;EAEF,MAAM,eAAe,kBAAkB,YAAY;AACnD,MAAI,YAAY,UAAU,aACxB,OAAM,SAAS,aAAa;MAE5B,OAAM,eAAe;GAEvB;;AAGJ,SAAS,YAAY,QAAuC;AAC1D,SAAQ,UAAU,EAAE,EAAE,QACnB,MAAM,QAAQ;AACb,MAAI,IAAI,MAAM,UACZ,MAAK,YAAY,KAAK,IAAI;MAE1B,MAAK,aAAa,KAAK,IAAI;AAE7B,SAAO;IAET;EACE,aAAa,MAAqB,EAAE;EACpC,cAAc,MAAqB,EAAE;EACtC,CACF;;AAWH,MAAaA,eAA4B,KAAK,aAAa,mBAAmB;AAE5E,KAAI,CAAC,aAAa,IAAI,CACpB,OAAM;AAGR,KAAI,gBAAgB,IAAI,CACtB,QAAO,oBAAoB,KAAK,aAAa,eAAe;AAG9D,KAAI,wBAAwB,IAAI,CAC9B,QAAO,oBAAoB,KAAK,aAAa,eAAe;AAG9D,KAAI,oBAAoB,IAAI,IAAI,IAAI,SAAS,2BAE3C;AAGF,KAAI,oBAAoB,IAAI,CAC1B,QAAO,wBAAwB,KAAK,aAAa,eAAe;;AAkCpE,MAAMC,uBAAoC,KAAK,GAAG,mBAAmB;AACnE,QAAO,iBAAiB,IAAI,QAAQ;;AAGtC,MAAMC,uBAAoC,KAAK,aAAa,mBAAmB;AAC7E,KAAI,CAAC,wBAAwB,IAAI,CAC/B;CAGF,MAAM,EAAE,aAAa,iBAAiB,YAAY,IAAI,OAAO;AAC7D,gBAAe,aAAa,YAAY;AAExC,KAAI,gBAAgB;AAClB,iBAAe,OAAU;EAGzB,MAAM,mBAAmB,aAAa;AACtC,MAAI,iBACF,gBAAe,iBAAiB;;;AAKtC,MAAMC,2BAAwC,KAAK,GAAG,mBAAmB;AACvE,KAAI,CAAC,oBAAoB,IAAI,CAC3B;AAGF,KAAI,gBAAgB;AAClB,iBAAe,OAAU;EACzB,MAAM,mBAAmB;AACzB,MAAI,iBACF,gBAAe,iBAAiB"}