@singlebase/elements 0.7.0 → 0.8.0
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.
- package/dist/authui-display-C2o9gApg.cjs +961 -0
- package/dist/authui-display-C2o9gApg.cjs.map +1 -0
- package/dist/{authui-display-BM_F3-5e.js → authui-display-CRUABt43.js} +1009 -862
- package/dist/authui-display-CRUABt43.js.map +1 -0
- package/dist/authui.cjs +1 -1
- package/dist/authui.js +2 -2
- package/dist/{chat-ezUmd9II.cjs → chat-BWcGH9lr.cjs} +2 -2
- package/dist/chat-BWcGH9lr.cjs.map +1 -0
- package/dist/{chat-BH_3e1jT.js → chat-t4o5FsxM.js} +5 -5
- package/dist/chat-t4o5FsxM.js.map +1 -0
- package/dist/chat.cjs +1 -1
- package/dist/chat.js +1 -1
- package/dist/elements/authui-account.d.ts +0 -1
- package/dist/elements/authui-buttons.d.ts +1 -1
- package/dist/elements/authui.d.ts +25 -1
- package/dist/elements/chat.d.ts +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/messages.d.ts +34 -3
- package/dist/singlebase-elements.min.js +2197 -2021
- package/dist/singlebase-elements.min.js.map +1 -1
- package/dist/{uploader-COP8PkJ6.cjs → uploader-C57vgFME.cjs} +27 -1
- package/dist/uploader-C57vgFME.cjs.map +1 -0
- package/dist/{uploader-tdMU9Gxv.js → uploader-Cz9yfzfV.js} +27 -1
- package/dist/uploader-Cz9yfzfV.js.map +1 -0
- package/dist/uploader.cjs +1 -1
- package/dist/uploader.js +1 -1
- package/dist/utils/auth-errors.d.ts +7 -0
- package/dist/utils/oauth.d.ts +24 -0
- package/dist/utils/password.d.ts +16 -0
- package/package.json +3 -3
- package/dist/authui-display-BM_F3-5e.js.map +0 -1
- package/dist/authui-display-CMVHTNFz.cjs +0 -956
- package/dist/authui-display-CMVHTNFz.cjs.map +0 -1
- package/dist/chat-BH_3e1jT.js.map +0 -1
- package/dist/chat-ezUmd9II.cjs.map +0 -1
- package/dist/uploader-COP8PkJ6.cjs.map +0 -1
- package/dist/uploader-tdMU9Gxv.js.map +0 -1
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
"use strict";var hs=Object.defineProperty;var qe=a=>{throw TypeError(a)};var cs=(a,n,t)=>n in a?hs(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var g=(a,n,t)=>cs(a,typeof n!="symbol"?n+"":n,t),je=(a,n,t)=>n.has(a)||qe("Cannot "+t);var l=(a,n,t)=>(je(a,n,"read from private field"),t?t.call(a):n.get(a)),h=(a,n,t)=>n.has(a)?qe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(a):n.set(a,t),c=(a,n,t,e)=>(je(a,n,"write to private field"),e?e.call(a,t):n.set(a,t),t);const i=require("lit"),o=require("lit/decorators.js"),k=require("lit/directives/if-defined.js"),P=require("@singlebase/singlebase-sdk"),Je=require("./uploader-C57vgFME.cjs"),Re=require("./files-4T62wkwj.cjs"),A=require("@singlebase/core");class Ze{constructor(n){g(this,"host");g(this,"client",null);g(this,"unsubscribe",null);g(this,"state",{status:"loading",session:null,user:null});this.host=n,n.addController(this)}bind(n){var t;n!==this.client&&((t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.client=n,n&&(this.state=n.getState(),this.unsubscribe=n.subscribe(e=>{this.state=e,this.host.requestUpdate()}),this.host.requestUpdate()))}hostDisconnected(){var n;(n=this.unsubscribe)==null||n.call(this),this.unsubscribe=null}}const xe={signInTitle:"Sign in",signUpTitle:"Create your account",forgotTitle:"Reset your password",verifyTitle:"Enter your code",otpTitle:"Sign in with a code",newPassTitle:"Choose a new password",inviteTitle:"You have been invited",signInSubEmailAndOauth:"Use your email or a connected provider.",signInSubEmailOnly:"Use your email address and password.",signInSubOauthOnly:"Continue with a connected provider.",signUpSub:"Free to start. No card required.",forgotSub:"We will email you a six-digit code to confirm it is you.",otpSub:"No password needed — we will email you a six-digit code.",inviteSub:"Set up your account to continue.",signInCta:"Sign in",signUpCta:"Create account",forgotCta:"Send code",verifyCta:"Verify code",otpCta:"Email me a code",newPassCta:"Save password",inviteCta:"Create account",continueCta:"Continue",backCta:"Back",emailMethodTitle:"Email",emailMethodTitleSignUp:"Email and password",emailMethodMeta:"Password or one-time code",emailMethodMetaSignUp:"Create with an address",emailMethodMetaOtp:"One-time code",oauthMethodTitle:"Single sign-on",oauthMethodMeta:"Use an account you already have",fullNameLabel:"Full name",fullNamePlaceholder:"Ada Lovelace",emailLabel:"Email",emailPlaceholder:"you@company.com",passwordLabel:"Password",passwordPlaceholder:"••••••••",newPasswordLabel:"New password",newPasswordPlaceholder:"At least {min} characters",newPasswordPlaceholderPlain:"Choose a password",passwordRulesLabel:"Password requirements",passwordRuleLength:"{min}–{max} characters",passwordRuleMinLength:"At least {min} characters",passwordRuleLowercase:"A lowercase letter",passwordRuleUppercase:"An uppercase letter",passwordRuleNumber:"A number",passwordRuleSymbol:"A symbol",confirmPasswordLabel:"Confirm password",confirmPasswordPlaceholder:"Repeat it",firstNameLabel:"First name",firstNamePlaceholder:"Ada",lastNameLabel:"Last name",lastNamePlaceholder:"Lovelace",phoneLabel:"Phone number",phonePlaceholder:"+1 (555) 000-0000",invitedEmailLabel:"Invited email",forgotLink:"Forgot?",otpInsteadLink:"Email me a one-time code instead",footTextSignIn:"New here?",footActionSignIn:"Create an account",footTextSignUp:"Already have an account?",footActionSignUp:"Sign in",resendQuestion:"Did not get it?",resendCta:"Resend code",oauthContinueWith:"Continue with",blockedTitleDisabled:"Sign-in is turned off",blockedTitleUnavailable:"Sign-in unavailable",blockedBodyDisabled:"Authentication is currently disabled for this application.",blockedBodyUnavailable:"No sign-in methods are enabled for this application.",blockedHint:"Contact the site owner if you think this is a mistake.",signOutCta:"Sign out",addPhotoLink:"Add photo",changePhotoLink:"Change",photoUploading:"Uploading…",photoUpdated:"Photo updated",editingLabel:"Editing",uploadPhotoCta:"Upload photo",replacePhotoCta:"Replace photo",photoHint:"PNG or JPG, up to 2 MB.",doneCta:"Done",cancelCta:"Cancel",editAccountCta:"Edit account",saveChangesCta:"Save changes",emailChangeHint:"We will send a verification link to the new address.",passwordSectionTitle:"Password",passwordChangedHint:"Last changed three months ago.",changePasswordCta:"Change password",updatePasswordCta:"Update password",twoFaTitle:"Two-factor authentication",twoFaHintOff:"Add a second step when signing in.",twoFaHintOn:"Enabled with an authenticator app.",twoFaScanHint:"Scan with your authenticator app, then enter the 6-digit code.",connectedTitle:"Connected accounts",connectedHint:"Sign in with any provider you connect here.",addAnotherLabel:"Add another",disconnectCta:"Disconnect",notConnectedLabel:"Not connected",deleteAccountCta:"Delete account",deleteAccountConfirmCta:"Permanently delete account",deletePanelBody:"This removes your profile, sessions and connected providers. It cannot be undone.",deleteConfirmLabel:"Type DELETE to confirm",deleteConfirmPlaceholder:"DELETE",savedNote:"Saved",passwordUpdatedNote:"Password updated",changeEmailTitle:"Email",newEmailLabel:"New email",changeEmailCta:"Send verification code",changeUsernameTitle:"Username",newUsernameLabel:"New username",changeUsernameCta:"Send verification code",genericErrorMessage:"Something went wrong. Please try again.",rateLimitedMessage:"Too many attempts. Wait a few minutes, then try again.",codeSentNeutral:"If an eligible account exists, a code has been sent.",invalidEmailError:"Enter a valid email address.",requiredError:"This cannot be empty.",passwordTooShortError:"Use at least {min} characters.",passwordTooLongError:"Use at most {max} characters.",passwordNeedsLowercaseError:"Include a lowercase letter.",passwordNeedsUppercaseError:"Include an uppercase letter.",passwordNeedsNumberError:"Include a number.",passwordNeedsSymbolError:"Include a symbol.",invalidPasswordMessage:"That password doesn't meet the requirements.",passwordMatchError:"Both passwords must match.",invalidCodeError:"That code is not valid. Check it and try again.",invalidCredentialsError:"That email and password do not match.",codeResentNotice:"New code sent.",confirmNewPasswordLabel:"Confirm new password",notSignedInNote:"Not signed in.",connectProviderLabel:"Connect {name}",digitLabel:"Digit {n}",accountCreatedNotice:"Account created. Sign in to continue.",inviteCodeLabel:"Invite code",submittingStatus:"Submitting…",doneStatus:"Done.",codeIncompleteError:"Enter all six digits.",invalidPhoneError:"Enter a valid phone number.",firstNameRequiredError:"Enter your first name.",notYetSupported:"Not yet supported",alreadySignedInTitle:"You are already signed in",alreadySignedInSub:"Continue where you left off, or sign out to use another account.",alreadySignedInSubPrefix:"Signed in as",continueHint:"Continuing takes you to your account.",consentPrefix:"By continuing you agree to our",consentJoin:"and",termsLabel:"Terms",privacyLabel:"Privacy Policy",emailUnchangedError:"That is already your email address.",emailUpdatedNote:"Email updated",changeEmailCtaShort:"Change email",changeEmailHint:"We will send a code to your current address to confirm it is you.",changeEmailConfirmHint:"Enter the code we sent, and your email becomes",changeEmailElsewhereHint:"Your email is changed below, with a verification step.",confirmChangeCta:"Confirm change",codeLabel:"Verification code",linkRequiresSignIn:"Sign in first, then link a provider.",oauthCallbackTitle:"Finishing sign-in",oauthCallbackSub:"One moment while we complete your sign-in.",oauthDenied:"Sign-in was cancelled or denied.",oauthRetryMessage:"We couldn't finish signing you in with that provider. Please try again.",oauthUnavailableMessage:"This sign-in option isn't available right now.",oauthVerifiedEmailMessage:"Your provider account needs a verified email address. Verify it with the provider, then try again.",providerConnectedNotice:"{name} is now connected to your account.",signInToLinkMessage:"An account with this email already exists. Sign in first, then connect the provider from your account.",providerAlreadyLinkedMessage:"That provider account is already connected to another account.",oauthNoAccountMessage:"There's no account for that provider yet. Create an account first, or sign in another way."};function Qe(a){return a?{...xe,...a}:xe}var ds=Object.defineProperty,us=Object.getOwnPropertyDescriptor,O=(a,n,t,e)=>{for(var s=us(n,t),r=a.length-1,d;r>=0;r--)(d=a[r])&&(s=d(n,t,s)||s);return s&&ds(n,t,s),s},M,I,R,D,F,B;class v extends i.LitElement{constructor(){super(...arguments);h(this,M,null);h(this,I,{});h(this,R);h(this,D);h(this,F);h(this,B);g(this,"auth",new Ze(this));g(this,"appliedConfig",new Set)}get client(){return l(this,M)}set client(t){c(this,M,t)}get messages(){return l(this,I)}set messages(t){c(this,I,t)}get theme(){return l(this,R)}set theme(t){c(this,R,t)}get density(){return l(this,D)}set density(t){c(this,D,t)}get fieldStyle(){return l(this,F)}set fieldStyle(t){c(this,F,t)}get radius(){return l(this,B)}set radius(t){c(this,B,t)}get resolvedClient(){var t;return this.client?this.client:((t=A.getDefaultClient())==null?void 0:t.auth)??null}get uiConfig(){var t;return((t=this.resolvedClient)==null?void 0:t.authui)??null}get msg(){var e;const t=(e=this.uiConfig)==null?void 0:e.messages;return Qe(t?{...t,...this.messages}:this.messages)}applyUIConfig(){const t=this.uiConfig;if(t){for(const e of A.AUTHUI_PROP_KEYS){const s=t[e];s!==void 0&&e in this&&(this.hasAttribute(A.authUIAttributeFor(e))||this.appliedConfig.has(e)||(this.appliedConfig.add(e),this[e]=s))}for(const[e,s]of Object.entries(t.tokens??{}))e.startsWith("--")&&(this.style.getPropertyValue(e)||this.style.setProperty(e,s))}}isAuthenticated(){var t;return((t=this.resolvedClient)==null?void 0:t.isAuthenticated())??!1}getUser(){var t;return((t=this.resolvedClient)==null?void 0:t.getUser())??null}async refreshSession(){var t;return(t=this.resolvedClient)==null?void 0:t.refreshSession()}async logout(){var t;await((t=this.resolvedClient)==null?void 0:t.logout())}willUpdate(t){super.willUpdate(t),this.auth.bind(this.resolvedClient),this.applyUIConfig()}}M=new WeakMap,I=new WeakMap,R=new WeakMap,D=new WeakMap,F=new WeakMap,B=new WeakMap,g(v,"styles",[Re.tokenDefaults,Je.sharedStyles]);O([o.property({attribute:!1})],v.prototype,"client");O([o.property({attribute:!1})],v.prototype,"messages");O([o.property({reflect:!0})],v.prototype,"theme");O([o.property({reflect:!0})],v.prototype,"density");O([o.property({reflect:!0,attribute:"field-style"})],v.prototype,"fieldStyle");O([o.property({reflect:!0})],v.prototype,"radius");class Ae{constructor(n){g(this,"host");g(this,"client",null);g(this,"cache",new WeakMap);g(this,"settings",null);g(this,"error",null);this.host=n,n.addController(this)}hostConnected(){}load(n,t){if(t){this.settings=t;return}if(!n||n===this.client)return;this.client=n;let e=this.cache.get(n);e||(e=n.getSettings(),this.cache.set(n,e)),e.then(s=>{this.settings=s,this.error=null,this.host.requestUpdate()}).catch(s=>{this.error=s,this.host.requestUpdate()})}}const ps=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],gs={load:"auth:ready",signin:"auth:signin",signup:"auth:signup",session:"auth:session","account-updated":"auth:profile-update",signout:"auth:signout",error:"auth:error",navigate:"auth:navigate"};function Ge(a){return"on"+a.replace(/(^|-)([a-z])/g,(n,t,e)=>e.toUpperCase())}class ms{constructor(n){g(this,"unsubscribes",[]);g(this,"client",null);this.host=n,n.addController(this)}bind(n){n!==this.client&&(this.release(),this.client=n,n&&(this.unsubscribes=ps.map(t=>n.on(t,e=>this.publish(t,e)))))}publish(n,t){const e=this.host[Ge(n)];if(typeof e=="function")try{e.call(this.host,t)}catch(d){console.error(`[singlebase] ${Ge(n)} threw:`,d)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${n}`,s));const r=gs[n];r&&this.host.dispatchEvent(new CustomEvent(r,s))}release(){this.unsubscribes.forEach(n=>n()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}const Pe=a=>`${a}:link`,bs={google:"G",github:"GH",linkedin:"in",facebook:"f"};function Xe(a){var t;const n=a==null?void 0:a.oauth_settings;return!!(n!=null&&n.enabled)&&!!((t=n.redirect_url)!=null&&t.trim())}function fs(a,n){return n==="signin"&&(a!=null&&a.oauth_settings.allow_signup)?"signup":n}function U(a,n){if(!a||!Xe(a))return[];const t=a.oauth_settings;return n==="signin"&&!t.allow_signin?[]:n==="signup"&&!t.allow_signup?[]:Object.entries(a.oauth_providers??{}).filter(([,e])=>e.enabled).map(([e,s])=>({id:e,name:s.provider_name,mark:bs[e]??s.provider_name.slice(0,2)}))}function Ue(a,n){if(!(a instanceof P.SinglebaseAuthError))return n.genericErrorMessage;switch(P.mapErrorToHint(a.code)){case"disable_retry_show_rate_limited":return n.rateLimitedMessage;case"show_password_requirements":return n.invalidPasswordMessage;case"expired_or_invalid_code_message":return n.invalidCodeError;case"explain_verified_email_required":return n.oauthVerifiedEmailMessage;case"restart_oauth":case"restart_oauth_new_nonce":return n.oauthRetryMessage;case"ask_signin_then_link":return n.signInToLinkMessage;case"provider_already_linked":return n.providerAlreadyLinkedMessage;case"hide_oauth":case"remove_oauth_from_signin":case"remove_oauth_from_signup":case"refresh_settings_hide_provider":return n.oauthUnavailableMessage;case"show_integrator_config_error":return console.warn(`[singlebase] Auth is misconfigured for this project (${a.code}).`),a.code==="MISSING_OAUTH_CREDENTIALS"?n.oauthUnavailableMessage:n.genericErrorMessage;default:return n.genericErrorMessage}}function ts(a,n){var e;const t=(e=a==null?void 0:a.LENGTH)==null?void 0:e[0];return t?n.newPasswordPlaceholder.replace("{min}",String(t)):n.newPasswordPlaceholderPlain}function es(a,n,t){if(!a)return t.requiredError;if(!n)return"";const[e,s]=n.LENGTH??[0,0];return e&&a.length<e?t.passwordTooShortError.replace("{min}",String(e)):s&&a.length>s?t.passwordTooLongError.replace("{max}",String(s)):n.LOWERCASE&&!/[a-z]/.test(a)?t.passwordNeedsLowercaseError:n.UPPERCASE&&!/[A-Z]/.test(a)?t.passwordNeedsUppercaseError:n.NUMBERS&&!/\d/.test(a)?t.passwordNeedsNumberError:n.SYMBOLS&&!/[^A-Za-z0-9\s]/.test(a)?t.passwordNeedsSymbolError:""}function vs(a,n){if(!a)return[];const[t,e]=a.LENGTH??[0,0],s=[];if(t||e){const r=e?n.passwordRuleLength.replace("{min}",String(t||1)).replace("{max}",String(e)):n.passwordRuleMinLength.replace("{min}",String(t));s.push({label:r})}return a.LOWERCASE&&s.push({label:n.passwordRuleLowercase}),a.UPPERCASE&&s.push({label:n.passwordRuleUppercase}),a.NUMBERS&&s.push({label:n.passwordRuleNumber}),a.SYMBOLS&&s.push({label:n.passwordRuleSymbol}),s}function ss(a,n){const t=vs(a,n);return t.length===0?i.nothing:i.html`<details class="pw-rules" part="password-rules">
|
|
2
|
+
<summary>${n.passwordRulesLabel}</summary>
|
|
3
|
+
<ul>
|
|
4
|
+
${t.map(e=>i.html`<li>${e.label}</li>`)}
|
|
5
|
+
</ul>
|
|
6
|
+
</details>`}var ws=Object.defineProperty,Ss=Object.getOwnPropertyDescriptor,De=(a,n,t,e)=>{for(var s=Ss(n,t),r=a.length-1,d;r>=0;r--)(d=a[r])&&(s=d(n,t,s)||s);return s&&ws(n,t,s),s},H,q,j;class Ce extends v{constructor(){super(...arguments);h(this,H,"idle");h(this,q,"");h(this,j,"");g(this,"abortController",null)}get phase(){return l(this,H)}set phase(t){c(this,H,t)}get formError(){return l(this,q)}set formError(t){c(this,q,t)}get noticeMessage(){return l(this,j)}set noticeMessage(t){c(this,j,t)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.abortController)==null||t.abort()}get signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}async run(t){this.phase="submitting",this.formError="";try{await t(),this.phase="success"}catch(e){if(this.isAbortError(e))return;this.phase="error",this.formError=this.describeError(e)}}isAbortError(t){return t instanceof DOMException&&t.name==="AbortError"}describeError(t){return Ue(t,this.msg)}get submitting(){return this.phase==="submitting"}renderStatus(){return i.html`
|
|
7
|
+
<div
|
|
8
|
+
role="status"
|
|
9
|
+
aria-live="polite"
|
|
10
|
+
style="position:absolute;width:1px;height:1px;overflow:hidden;"
|
|
11
|
+
>
|
|
12
|
+
${this.phase==="submitting"?this.msg.submittingStatus:""}
|
|
13
|
+
${this.phase==="success"?this.msg.doneStatus:""}
|
|
14
|
+
</div>
|
|
15
|
+
${this.formError?i.html`<p class="banner" role="alert">${this.formError}</p>`:null}
|
|
16
|
+
${this.noticeMessage?i.html`<p class="notice" role="status">${this.noticeMessage}</p>`:null}
|
|
17
|
+
`}}H=new WeakMap,q=new WeakMap,j=new WeakMap;De([o.state()],Ce.prototype,"phase");De([o.state()],Ce.prototype,"formError");De([o.state()],Ce.prototype,"noticeMessage");function Fe(a){return[a==null?void 0:a.first_name,a==null?void 0:a.last_name].filter(Boolean).join(" ").trim()}function Be(a){const n=Fe(a);if(n)return n.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();const t=(a==null?void 0:a.email)??"";return t?t[0].toUpperCase():"·"}var ys=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,b=(a,n,t,e)=>{for(var s=e>1?void 0:e?$s(n,t):n,r=a.length-1,d;r>=0;r--)(d=a[r])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&ys(n,t,s),s};const Es={profile_photo:!0},Cs=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp";var G,K,V,W,Y,z,J,Z,Q,X,tt,et,st,it,nt,at,rt,ot,lt,ht,ct,dt,ut,pt,gt,Ke;exports.SinglebaseAccountScreen=(Ke=class extends Ce{constructor(){super(...arguments);h(this,G,"");h(this,K,"");h(this,V,null);h(this,W,"singlebase-oauth-nonce");h(this,Y,"");h(this,z,"");h(this,J,!1);h(this,Z,"");h(this,Q,"");h(this,X,"");h(this,tt,"");h(this,et,"");h(this,st,0);h(this,it,"");h(this,nt,"");h(this,at,"");h(this,rt,"");h(this,ot,"");h(this,lt,"request");h(this,ht,"");h(this,ct,"");h(this,dt,"");h(this,ut,"");h(this,pt,"");h(this,gt,"");g(this,"settingsCtl",new Ae(this));g(this,"flashTimer");g(this,"uidBase",`sb-acct-${Math.random().toString(36).slice(2,8)}`);g(this,"uploadClientFor",null);g(this,"uploadClientCache",null);g(this,"onChoosePhoto",()=>{var t;this.formError="",(t=this.renderRoot.querySelector("singlebase-uploader"))==null||t.open()});g(this,"onPhotoSelected",()=>{this.photoBusy=!0,this.toast=""});g(this,"onPhotoUploaded",async t=>{var r;const{completed:e,failed:s}=t.detail;try{e.length?(await((r=this.resolvedClient)==null?void 0:r.getAccount()),this.photoFailed="",this.toast=this.msg.photoUpdated):s.length&&(this.formError=s[0].error||this.msg.genericErrorMessage)}catch(d){this.formError=this.describeError(d)}finally{this.photoBusy=!1}});g(this,"onPhotoProblem",t=>{this.photoBusy=!1,this.formError=t.detail.message})}get logoText(){return l(this,G)}set logoText(t){c(this,G,t)}get logoUrl(){return l(this,K)}set logoUrl(t){c(this,K,t)}get settings(){return l(this,V)}set settings(t){c(this,V,t)}get nonceStorageKey(){return l(this,W)}set nonceStorageKey(t){c(this,W,t)}get editMode(){return l(this,Y)}set editMode(t){c(this,Y,t)}get toast(){return l(this,z)}set toast(t){c(this,z,t)}get photoBusy(){return l(this,J)}set photoBusy(t){c(this,J,t)}get photoFailed(){return l(this,Z)}set photoFailed(t){c(this,Z,t)}get profileSaved(){return l(this,Q)}set profileSaved(t){c(this,Q,t)}get passSaved(){return l(this,X)}set passSaved(t){c(this,X,t)}get profileError(){return l(this,tt)}set profileError(t){c(this,tt,t)}get newPassError(){return l(this,et)}set newPassError(t){c(this,et,t)}get deleteStage(){return l(this,st)}set deleteStage(t){c(this,st,t)}get confirmText(){return l(this,it)}set confirmText(t){c(this,it,t)}get dFirst(){return l(this,nt)}set dFirst(t){c(this,nt,t)}get dLast(){return l(this,at)}set dLast(t){c(this,at,t)}get dPhone(){return l(this,rt)}set dPhone(t){c(this,rt,t)}get dEmail(){return l(this,ot)}set dEmail(t){c(this,ot,t)}get emailStep(){return l(this,lt)}set emailStep(t){c(this,lt,t)}get dNewEmail(){return l(this,ht)}set dNewEmail(t){c(this,ht,t)}get emailCode(){return l(this,ct)}set emailCode(t){c(this,ct,t)}get emailError(){return l(this,dt)}set emailError(t){c(this,dt,t)}get emailSaved(){return l(this,ut)}set emailSaved(t){c(this,ut,t)}get newPass(){return l(this,pt)}set newPass(t){c(this,pt,t)}get confirmPass(){return l(this,gt)}set confirmPass(t){c(this,gt,t)}uid(t){return`${this.uidBase}-${t}`}willUpdate(t){super.willUpdate(t),this.settingsCtl.load(this.resolvedClient,this.settings)}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this.flashTimer)}flash(t,e){this[t]=e,clearTimeout(this.flashTimer),this.flashTimer=setTimeout(()=>{this[t]=""},2600)}renderLogo(){return this.logoUrl?i.html`<img
|
|
18
|
+
part="logo"
|
|
19
|
+
src=${this.logoUrl}
|
|
20
|
+
alt=${this.logoText}
|
|
21
|
+
style="display:block;align-self:flex-start;height:var(--sb-logo-height,20px);width:auto;max-width:100%"
|
|
22
|
+
/>`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}get user(){const t=this.auth.state;return t.status==="authenticated"?t.user:null}get fullName(){return Fe(this.user)}get initials(){return Be(this.user)}get uploadClient(){const t=this.resolvedClient;return t?(this.uploadClientFor!==t&&(this.uploadClientFor=t,this.uploadClientCache={files:P.createFilesUploadApi(t.dispatcher)}),this.uploadClientCache):null}startProfileEdit(){const t=this.user;t&&(this.dFirst=t.first_name??"",this.dLast=t.last_name??"",this.dPhone=t.phone??"",this.dEmail=t.email,this.profileError="",this.profileSaved="",this.passSaved="",this.toast="",this.editMode="profile")}async onSaveProfile(){const t=this.resolvedClient;if(!t)return;const e=this.dFirst.trim(),s=this.dLast.trim(),r=this.dPhone.trim();if(!e){this.profileError=this.msg.firstNameRequiredError;return}if(r&&r.replace(/\D/g,"").length<7){this.profileError=this.msg.invalidPhoneError;return}const d=this.user,p={};if(e!==((d==null?void 0:d.first_name)??"")&&(p.first_name=e),s!==((d==null?void 0:d.last_name)??"")&&(p.last_name=s),r!==((d==null?void 0:d.phone)??"")&&(p.phone=r),Object.keys(p).length===0){this.editMode="";return}await this.run(async()=>{await t.updateAccount(p,this.signal),this.editMode="",this.flash("profileSaved",this.msg.savedNote)})}startPassEdit(){this.newPass="",this.confirmPass="",this.newPassError="",this.passSaved="",this.profileSaved="",this.toast="",this.editMode="password"}async onChangePass(){const t=this.resolvedClient;if(!t)return;const e=this.settings??this.settingsCtl.settings,s=es(this.newPass,e==null?void 0:e.auth_settings.password_policy,this.msg);if(s){this.newPassError=s;return}if(this.newPass!==this.confirmPass){this.newPassError=this.msg.passwordMatchError;return}await this.run(async()=>{await t.changePassword({password:this.newPass},this.signal),this.editMode="",this.newPass="",this.confirmPass="",this.flash("passSaved",this.msg.passwordUpdatedNote)})}startEmailEdit(){this.emailStep="request",this.dNewEmail="",this.emailCode="",this.emailError="",this.emailSaved="",this.toast="",this.editMode="email"}async onRequestEmailCode(){const t=this.resolvedClient;if(!(!t||!this.user)){if(!this.dNewEmail.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(this.dNewEmail.toLowerCase()===this.user.email.toLowerCase()){this.emailError=this.msg.emailUnchangedError;return}await this.run(async()=>{await t.requestCode({email:this.user.email,purpose:"email_change"},this.signal),this.emailStep="confirm",this.emailError=""})}}async onConfirmEmailChange(){const t=this.resolvedClient;if(!(!t||!this.user)){if(this.emailCode.length<6){this.emailError=this.msg.codeIncompleteError;return}await this.run(async()=>{await t.changeEmail({email:this.user.email,code:this.emailCode,new_email:this.dNewEmail},this.signal),this.editMode="",this.emailCode="",this.dNewEmail="",this.flash("emailSaved",this.msg.emailUpdatedNote)})}}renderEmailSection(){var s;const t=this.editMode!=="email",e=this.editMode!==""&&this.editMode!=="email";return i.html`
|
|
23
|
+
<div class="rule"></div>
|
|
24
|
+
<div class="section">
|
|
25
|
+
<h3 class="sec-title">${this.msg.changeEmailTitle}</h3>
|
|
26
|
+
${t?i.html`
|
|
27
|
+
<div class="between">
|
|
28
|
+
<p class="hint">${((s=this.user)==null?void 0:s.email)??""}</p>
|
|
29
|
+
<div class="btn-row-end">
|
|
30
|
+
${this.emailSaved?i.html`<span role="status" class="saved-note">${this.emailSaved}</span>`:i.nothing}
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
class="edit-link"
|
|
34
|
+
?disabled=${e}
|
|
35
|
+
@click=${this.startEmailEdit}
|
|
36
|
+
>
|
|
37
|
+
${this.msg.changeEmailCtaShort}
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
`:this.emailStep==="request"?i.html`
|
|
42
|
+
<div class="edit-card">
|
|
43
|
+
<div class="field">
|
|
44
|
+
<label for=${this.uid("newemail")}>${this.msg.newEmailLabel}</label>
|
|
45
|
+
<input
|
|
46
|
+
id=${this.uid("newemail")}
|
|
47
|
+
type="email"
|
|
48
|
+
part="input"
|
|
49
|
+
.value=${this.dNewEmail}
|
|
50
|
+
placeholder=${this.msg.emailPlaceholder}
|
|
51
|
+
aria-invalid=${this.emailError?"true":"false"}
|
|
52
|
+
?disabled=${this.submitting}
|
|
53
|
+
@input=${r=>{this.dNewEmail=r.target.value,this.emailError=""}}
|
|
54
|
+
/>
|
|
55
|
+
<p class="hint">${this.msg.changeEmailHint}</p>
|
|
56
|
+
</div>
|
|
57
|
+
${this.emailError?i.html`<p class="err">${this.emailError}</p>`:i.nothing}
|
|
58
|
+
<div class="edit-actions">
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
class="primary-sm"
|
|
62
|
+
?disabled=${this.submitting}
|
|
63
|
+
@click=${this.onRequestEmailCode}
|
|
64
|
+
>
|
|
65
|
+
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
66
|
+
<span>${this.msg.changeEmailCta}</span>
|
|
67
|
+
</button>
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
class="ghost-sm"
|
|
71
|
+
@click=${()=>{this.editMode="",this.emailError=""}}
|
|
72
|
+
>
|
|
73
|
+
${this.msg.cancelCta}
|
|
74
|
+
</button>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`:i.html`
|
|
78
|
+
<div class="edit-card">
|
|
79
|
+
<p class="hint">${this.msg.codeSentNeutral}</p>
|
|
80
|
+
<div class="field">
|
|
81
|
+
<label for=${this.uid("emailcode")}>${this.msg.codeLabel}</label>
|
|
82
|
+
<input
|
|
83
|
+
id=${this.uid("emailcode")}
|
|
84
|
+
type="text"
|
|
85
|
+
inputmode="numeric"
|
|
86
|
+
autocomplete="one-time-code"
|
|
87
|
+
part="input"
|
|
88
|
+
.value=${this.emailCode}
|
|
89
|
+
placeholder="000000"
|
|
90
|
+
aria-invalid=${this.emailError?"true":"false"}
|
|
91
|
+
?disabled=${this.submitting}
|
|
92
|
+
@input=${r=>{this.emailCode=r.target.value.replace(/\D/g,"").slice(0,6),this.emailError=""}}
|
|
93
|
+
/>
|
|
94
|
+
<p class="hint">${this.msg.changeEmailConfirmHint} ${this.dNewEmail}</p>
|
|
95
|
+
</div>
|
|
96
|
+
${this.emailError?i.html`<p class="err">${this.emailError}</p>`:i.nothing}
|
|
97
|
+
<div class="edit-actions">
|
|
98
|
+
<button
|
|
99
|
+
type="button"
|
|
100
|
+
class="primary-sm"
|
|
101
|
+
?disabled=${this.submitting}
|
|
102
|
+
@click=${this.onConfirmEmailChange}
|
|
103
|
+
>
|
|
104
|
+
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
105
|
+
<span>${this.msg.confirmChangeCta}</span>
|
|
106
|
+
</button>
|
|
107
|
+
<button
|
|
108
|
+
type="button"
|
|
109
|
+
class="ghost-sm"
|
|
110
|
+
@click=${()=>{this.editMode="",this.emailError=""}}
|
|
111
|
+
>
|
|
112
|
+
${this.msg.cancelCta}
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
`}
|
|
117
|
+
</div>
|
|
118
|
+
`}async onSignOut(){const t=this.resolvedClient;t&&await this.run(async()=>{await t.signOut()})}async onConnectProvider(t){const e=this.resolvedClient,s=this.auth.state;!e||s.status!=="authenticated"||await this.run(async()=>{var p,m;const r=await e.createOAuthNonce(this.signal);(p=globalThis.sessionStorage)==null||p.setItem(this.nonceStorageKey,r),(m=globalThis.sessionStorage)==null||m.setItem(Pe(this.nonceStorageKey),t);const{oauth_redirect_url:d}=await e.startOAuth({provider:t,nonce:r,intent:"link",id_token:s.session.id_token,refresh_token:s.session.refresh_token},this.signal);globalThis.location.assign(d)})}get availableProviders(){return U(this.settings??this.settingsCtl.settings,"link")}renderIdentity(){const t=this.user,e=this.editMode!==""&&this.editMode!=="avatar",s=t!=null&&t.profile_photo&&t.profile_photo!==this.photoFailed?t.profile_photo:"";return i.html`
|
|
119
|
+
<div class="acct-nav">
|
|
120
|
+
<div class="acct-who">
|
|
121
|
+
<div class="avatar-col">
|
|
122
|
+
<div class="avatar ${s?"has-photo":""}" part="avatar">
|
|
123
|
+
${s?i.html`<img
|
|
124
|
+
src=${s}
|
|
125
|
+
alt=""
|
|
126
|
+
part="avatar-image"
|
|
127
|
+
@error=${()=>this.photoFailed=s}
|
|
128
|
+
/>`:this.initials}
|
|
129
|
+
</div>
|
|
130
|
+
<button
|
|
131
|
+
type="button"
|
|
132
|
+
class="edit-link"
|
|
133
|
+
style="font-size:12px"
|
|
134
|
+
?disabled=${this.photoBusy||e}
|
|
135
|
+
@click=${this.onChoosePhoto}
|
|
136
|
+
>
|
|
137
|
+
${this.photoBusy?this.msg.photoUploading:t!=null&&t.profile_photo?this.msg.changePhotoLink:this.msg.addPhotoLink}
|
|
138
|
+
</button>
|
|
139
|
+
<singlebase-uploader
|
|
140
|
+
style="display:none"
|
|
141
|
+
view="button"
|
|
142
|
+
max-files="1"
|
|
143
|
+
branding="false"
|
|
144
|
+
accept=${Cs}
|
|
145
|
+
.client=${this.uploadClient}
|
|
146
|
+
.options=${Es}
|
|
147
|
+
@singlebase-upload-selected=${this.onPhotoSelected}
|
|
148
|
+
@singlebase-upload-complete=${this.onPhotoUploaded}
|
|
149
|
+
@singlebase-upload-error=${this.onPhotoProblem}
|
|
150
|
+
@singlebase-upload-rejected=${this.onPhotoProblem}
|
|
151
|
+
></singlebase-uploader>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="acct-who-text">
|
|
154
|
+
<div class="acct-name">${this.fullName||"—"}</div>
|
|
155
|
+
<div class="acct-email">${(t==null?void 0:t.email)??""}</div>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
<button type="button" class="link-sm" ?disabled=${this.submitting} @click=${this.onSignOut}>
|
|
159
|
+
${this.msg.signOutCta}
|
|
160
|
+
</button>
|
|
161
|
+
</div>
|
|
162
|
+
`}renderProfileSection(){const t=this.user;if(!t)return i.nothing;const e=this.editMode!=="profile",s=this.editMode!==""&&this.editMode!=="profile",r=[[this.msg.firstNameLabel,t.first_name||"—"],[this.msg.lastNameLabel,t.last_name||"—"],[this.msg.phoneLabel,t.phone||"—"],[this.msg.emailLabel,t.email||"—"]];return i.html`
|
|
163
|
+
<div class="section">
|
|
164
|
+
${e?i.html`
|
|
165
|
+
<div class="sum-list">
|
|
166
|
+
${r.map(([d,p])=>i.html`
|
|
167
|
+
<div class="sum-row">
|
|
168
|
+
<span class="sum-label">${d}</span>
|
|
169
|
+
<span class="sum-value">${p}</span>
|
|
170
|
+
</div>
|
|
171
|
+
`)}
|
|
172
|
+
</div>
|
|
173
|
+
<div class="btn-row-end">
|
|
174
|
+
${this.profileSaved?i.html`<span role="status" class="saved-note">${this.profileSaved}</span>`:i.nothing}
|
|
175
|
+
<button
|
|
176
|
+
type="button"
|
|
177
|
+
class="edit-link"
|
|
178
|
+
?disabled=${s}
|
|
179
|
+
@click=${this.startProfileEdit}
|
|
180
|
+
>
|
|
181
|
+
${this.msg.editAccountCta}
|
|
182
|
+
</button>
|
|
183
|
+
</div>
|
|
184
|
+
`:i.html`
|
|
185
|
+
<div class="edit-card">
|
|
186
|
+
<div class="two-up">
|
|
187
|
+
<div class="field">
|
|
188
|
+
<label for=${this.uid("first")}>${this.msg.firstNameLabel}</label>
|
|
189
|
+
<input
|
|
190
|
+
id=${this.uid("first")}
|
|
191
|
+
type="text"
|
|
192
|
+
part="input"
|
|
193
|
+
.value=${this.dFirst}
|
|
194
|
+
placeholder=${this.msg.firstNamePlaceholder}
|
|
195
|
+
?disabled=${this.submitting}
|
|
196
|
+
@input=${d=>{this.dFirst=d.target.value,this.profileError=""}}
|
|
197
|
+
/>
|
|
198
|
+
</div>
|
|
199
|
+
<div class="field">
|
|
200
|
+
<label for=${this.uid("last")}>${this.msg.lastNameLabel}</label>
|
|
201
|
+
<input
|
|
202
|
+
id=${this.uid("last")}
|
|
203
|
+
type="text"
|
|
204
|
+
part="input"
|
|
205
|
+
.value=${this.dLast}
|
|
206
|
+
placeholder=${this.msg.lastNamePlaceholder}
|
|
207
|
+
?disabled=${this.submitting}
|
|
208
|
+
@input=${d=>{this.dLast=d.target.value,this.profileError=""}}
|
|
209
|
+
/>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
<div class="field">
|
|
213
|
+
<label for=${this.uid("phone")}>${this.msg.phoneLabel}</label>
|
|
214
|
+
<input
|
|
215
|
+
id=${this.uid("phone")}
|
|
216
|
+
type="tel"
|
|
217
|
+
part="input"
|
|
218
|
+
.value=${this.dPhone}
|
|
219
|
+
placeholder=${this.msg.phonePlaceholder}
|
|
220
|
+
?disabled=${this.submitting}
|
|
221
|
+
@input=${d=>{this.dPhone=d.target.value,this.profileError=""}}
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
<div class="field">
|
|
225
|
+
<label for=${this.uid("email")}>${this.msg.emailLabel}</label>
|
|
226
|
+
<input
|
|
227
|
+
id=${this.uid("email")}
|
|
228
|
+
type="email"
|
|
229
|
+
part="input"
|
|
230
|
+
.value=${this.dEmail}
|
|
231
|
+
disabled
|
|
232
|
+
title=${this.msg.notYetSupported}
|
|
233
|
+
/>
|
|
234
|
+
<p class="hint">${this.msg.changeEmailElsewhereHint}</p>
|
|
235
|
+
</div>
|
|
236
|
+
${this.profileError?i.html`<p class="err">${this.profileError}</p>`:i.nothing}
|
|
237
|
+
<div class="edit-actions">
|
|
238
|
+
<button
|
|
239
|
+
type="button"
|
|
240
|
+
class="primary-sm"
|
|
241
|
+
?disabled=${this.submitting}
|
|
242
|
+
@click=${this.onSaveProfile}
|
|
243
|
+
>
|
|
244
|
+
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
245
|
+
<span>${this.msg.saveChangesCta}</span>
|
|
246
|
+
</button>
|
|
247
|
+
<button
|
|
248
|
+
type="button"
|
|
249
|
+
class="ghost-sm"
|
|
250
|
+
@click=${()=>{this.editMode="",this.profileError=""}}
|
|
251
|
+
>
|
|
252
|
+
${this.msg.cancelCta}
|
|
253
|
+
</button>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
`}
|
|
257
|
+
</div>
|
|
258
|
+
`}renderPasswordSection(){var s,r;const t=this.editMode!=="password",e=this.editMode!==""&&this.editMode!=="password";return i.html`
|
|
259
|
+
<div class="rule"></div>
|
|
260
|
+
<div class="section">
|
|
261
|
+
<h3 class="sec-title">${this.msg.passwordSectionTitle}</h3>
|
|
262
|
+
${t?i.html`
|
|
263
|
+
<div class="between">
|
|
264
|
+
<p class="hint">${this.msg.passwordChangedHint}</p>
|
|
265
|
+
<div class="btn-row-end">
|
|
266
|
+
${this.passSaved?i.html`<span role="status" class="saved-note">${this.passSaved}</span>`:i.nothing}
|
|
267
|
+
<button
|
|
268
|
+
type="button"
|
|
269
|
+
class="edit-link"
|
|
270
|
+
?disabled=${e}
|
|
271
|
+
@click=${this.startPassEdit}
|
|
272
|
+
>
|
|
273
|
+
${this.msg.changePasswordCta}
|
|
274
|
+
</button>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
`:i.html`
|
|
278
|
+
<div class="edit-card">
|
|
279
|
+
<div class="field">
|
|
280
|
+
<label for=${this.uid("newpass")}>${this.msg.newPasswordLabel}</label>
|
|
281
|
+
<input
|
|
282
|
+
id=${this.uid("newpass")}
|
|
283
|
+
type="password"
|
|
284
|
+
part="input"
|
|
285
|
+
.value=${this.newPass}
|
|
286
|
+
placeholder=${ts((s=this.settings??this.settingsCtl.settings)==null?void 0:s.auth_settings.password_policy,this.msg)}
|
|
287
|
+
aria-invalid=${this.newPassError?"true":"false"}
|
|
288
|
+
?disabled=${this.submitting}
|
|
289
|
+
@input=${d=>{this.newPass=d.target.value,this.newPassError=""}}
|
|
290
|
+
/>
|
|
291
|
+
</div>
|
|
292
|
+
<div class="field">
|
|
293
|
+
<label for=${this.uid("confirmpass")}
|
|
294
|
+
>${this.msg.confirmNewPasswordLabel}</label
|
|
295
|
+
>
|
|
296
|
+
<input
|
|
297
|
+
id=${this.uid("confirmpass")}
|
|
298
|
+
type="password"
|
|
299
|
+
part="input"
|
|
300
|
+
.value=${this.confirmPass}
|
|
301
|
+
placeholder=${this.msg.confirmPasswordPlaceholder}
|
|
302
|
+
aria-invalid=${this.newPassError?"true":"false"}
|
|
303
|
+
?disabled=${this.submitting}
|
|
304
|
+
@input=${d=>{this.confirmPass=d.target.value,this.newPassError=""}}
|
|
305
|
+
/>
|
|
306
|
+
${ss((r=this.settings??this.settingsCtl.settings)==null?void 0:r.auth_settings.password_policy,this.msg)}
|
|
307
|
+
${this.newPassError?i.html`<p class="err">${this.newPassError}</p>`:i.nothing}
|
|
308
|
+
</div>
|
|
309
|
+
<div class="edit-actions">
|
|
310
|
+
<button
|
|
311
|
+
type="button"
|
|
312
|
+
class="primary-sm"
|
|
313
|
+
?disabled=${this.submitting}
|
|
314
|
+
@click=${this.onChangePass}
|
|
315
|
+
>
|
|
316
|
+
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
317
|
+
<span>${this.msg.updatePasswordCta}</span>
|
|
318
|
+
</button>
|
|
319
|
+
<button type="button" class="ghost-sm" @click=${()=>this.editMode=""}>
|
|
320
|
+
${this.msg.cancelCta}
|
|
321
|
+
</button>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
`}
|
|
325
|
+
</div>
|
|
326
|
+
`}renderTwoFactorSection(){return i.html`
|
|
327
|
+
<div class="rule"></div>
|
|
328
|
+
<div class="section">
|
|
329
|
+
<div class="between">
|
|
330
|
+
<div>
|
|
331
|
+
<h3 class="sec-title">${this.msg.twoFaTitle}</h3>
|
|
332
|
+
<p class="hint">${this.msg.twoFaHintOff}</p>
|
|
333
|
+
</div>
|
|
334
|
+
<button
|
|
335
|
+
type="button"
|
|
336
|
+
class="switch"
|
|
337
|
+
aria-pressed="false"
|
|
338
|
+
aria-label=${`${this.msg.twoFaTitle} (${this.msg.notYetSupported})`}
|
|
339
|
+
disabled
|
|
340
|
+
title=${this.msg.notYetSupported}
|
|
341
|
+
>
|
|
342
|
+
<span class="knob"></span>
|
|
343
|
+
</button>
|
|
344
|
+
</div>
|
|
345
|
+
<p class="disabled-note">
|
|
346
|
+
${this.msg.notYetSupported} — enrolling a second factor is not part of the current API.
|
|
347
|
+
</p>
|
|
348
|
+
</div>
|
|
349
|
+
`}renderConnectedSection(){const t=this.availableProviders;return t.length===0?i.nothing:i.html`
|
|
350
|
+
<div class="rule"></div>
|
|
351
|
+
<div class="section">
|
|
352
|
+
<h3 class="sec-title">${this.msg.connectedTitle}</h3>
|
|
353
|
+
<p class="hint">${this.msg.connectedHint}</p>
|
|
354
|
+
<span class="sub-label">${this.msg.addAnotherLabel}</span>
|
|
355
|
+
<div class="tile-grid">
|
|
356
|
+
${t.map(e=>i.html`
|
|
357
|
+
<button
|
|
358
|
+
type="button"
|
|
359
|
+
class="tile"
|
|
360
|
+
aria-label=${this.msg.connectProviderLabel.replace("{name}",e.name)}
|
|
361
|
+
?disabled=${this.submitting}
|
|
362
|
+
@click=${()=>this.onConnectProvider(e.id)}
|
|
363
|
+
>
|
|
364
|
+
<span class="tile-mark">${e.mark}</span>
|
|
365
|
+
<span class="tile-name">${e.name}</span>
|
|
366
|
+
<span class="tile-plus">+</span>
|
|
367
|
+
</button>
|
|
368
|
+
`)}
|
|
369
|
+
</div>
|
|
370
|
+
</div>
|
|
371
|
+
`}renderDangerSection(){return i.html`
|
|
372
|
+
<div class="rule"></div>
|
|
373
|
+
<div class="section">
|
|
374
|
+
${this.deleteStage===0?i.html`<button
|
|
375
|
+
type="button"
|
|
376
|
+
class="danger-link"
|
|
377
|
+
disabled
|
|
378
|
+
title=${this.msg.notYetSupported}
|
|
379
|
+
>
|
|
380
|
+
${this.msg.deleteAccountCta}
|
|
381
|
+
</button>`:i.nothing}
|
|
382
|
+
<p class="disabled-note">
|
|
383
|
+
${this.msg.notYetSupported} — account deletion is not part of the current API.
|
|
384
|
+
</p>
|
|
385
|
+
</div>
|
|
386
|
+
`}render(){return this.user?i.html`
|
|
387
|
+
<div class="acct-root">
|
|
388
|
+
${this.renderLogo()} ${this.renderIdentity()}
|
|
389
|
+
<div class="acct-body">
|
|
390
|
+
${this.toast?i.html`<div class="notice" role="status">${this.toast}</div>`:i.nothing}
|
|
391
|
+
${this.formError?i.html`<div class="banner" role="alert">${this.formError}</div>`:i.nothing}
|
|
392
|
+
${this.renderProfileSection()} ${this.renderEmailSection()}
|
|
393
|
+
${this.renderPasswordSection()}
|
|
394
|
+
${i.nothing}
|
|
395
|
+
${this.renderConnectedSection()}
|
|
396
|
+
${i.nothing}
|
|
397
|
+
</div>
|
|
398
|
+
</div>
|
|
399
|
+
`:i.html`<p class="disabled-note">${this.msg.notSignedInNote}</p>`}},G=new WeakMap,K=new WeakMap,V=new WeakMap,W=new WeakMap,Y=new WeakMap,z=new WeakMap,J=new WeakMap,Z=new WeakMap,Q=new WeakMap,X=new WeakMap,tt=new WeakMap,et=new WeakMap,st=new WeakMap,it=new WeakMap,nt=new WeakMap,at=new WeakMap,rt=new WeakMap,ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,Ke);b([o.property({attribute:"logo-text"})],exports.SinglebaseAccountScreen.prototype,"logoText",1);b([o.property({attribute:"logo-url"})],exports.SinglebaseAccountScreen.prototype,"logoUrl",1);b([o.property({attribute:!1})],exports.SinglebaseAccountScreen.prototype,"settings",1);b([o.property({attribute:"nonce-storage-key"})],exports.SinglebaseAccountScreen.prototype,"nonceStorageKey",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"editMode",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"toast",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"photoBusy",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"photoFailed",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"profileSaved",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"passSaved",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"profileError",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"newPassError",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"deleteStage",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"confirmText",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"dFirst",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"dLast",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"dPhone",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"dEmail",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"emailStep",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"dNewEmail",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"emailCode",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"emailError",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"emailSaved",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"newPass",1);b([o.state()],exports.SinglebaseAccountScreen.prototype,"confirmPass",1);exports.SinglebaseAccountScreen=b([o.customElement("singlebase-authui-account")],exports.SinglebaseAccountScreen);var Ps=Object.defineProperty,As=Object.getOwnPropertyDescriptor,y=(a,n,t,e)=>{for(var s=e>1?void 0:e?As(n,t):n,r=a.length-1,d;r>=0;r--)(d=a[r])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&Ps(n,t,s),s},mt,bt,ft,vt,wt,St,yt,Ve;exports.SinglebaseAuthButtons=(Ve=class extends Ce{constructor(){super(...arguments);h(this,mt,"signout");h(this,bt,"signin");h(this,ft,"");h(this,vt,"");h(this,wt,!1);h(this,St,null);h(this,yt,"singlebase-oauth-nonce");g(this,"settingsCtl",new Ae(this))}get type(){return l(this,mt)}set type(t){c(this,mt,t)}get intent(){return l(this,bt)}set intent(t){c(this,bt,t)}get provider(){return l(this,ft)}set provider(t){c(this,ft,t)}get providerName(){return l(this,vt)}set providerName(t){c(this,vt,t)}get embedded(){return l(this,wt)}set embedded(t){c(this,wt,t)}get settings(){return l(this,St)}set settings(t){c(this,St,t)}get nonceStorageKey(){return l(this,yt)}set nonceStorageKey(t){c(this,yt,t)}willUpdate(t){super.willUpdate(t),this.type!=="signout"&&this.settingsCtl.load(this.resolvedClient,this.settings)}get effectiveSettings(){return this.settings??this.settingsCtl.settings}get providers(){return U(this.effectiveSettings,this.intent)}async startOAuth(t,e,s=!1){const r=this.resolvedClient;if(!r)return;let d,p;if(s){const m=this.auth.state;if(m.status!=="authenticated"){this.formError=this.msg.linkRequiresSignIn,this.phase="error";return}d=m.session.id_token,p=m.session.refresh_token}await this.run(async()=>{var S,$,E;const m=await r.createOAuthNonce(this.signal);(S=globalThis.sessionStorage)==null||S.setItem(this.nonceStorageKey,m);const f=Pe(this.nonceStorageKey);s?($=globalThis.sessionStorage)==null||$.setItem(f,t):(E=globalThis.sessionStorage)==null||E.removeItem(f);const{oauth_redirect_url:w}=await r.startOAuth({provider:t,nonce:m,intent:fs(this.effectiveSettings,e),...s?{id_token:d,refresh_token:p}:{}},this.signal);globalThis.location.assign(w)})}renderOAuth(){const t=this.providers;if(t.length===0)return i.nothing;const[e,...s]=t;return i.html`
|
|
400
|
+
<div class="stack">
|
|
401
|
+
${this.formError?i.html`<div class="banner" part="banner" role="alert">${this.formError}</div>`:i.nothing}
|
|
402
|
+
|
|
403
|
+
<button
|
|
404
|
+
type="button"
|
|
405
|
+
class="oauth-primary"
|
|
406
|
+
part="oauth-button"
|
|
407
|
+
?disabled=${this.submitting}
|
|
408
|
+
@click=${()=>this.startOAuth(e.id,this.intent)}
|
|
409
|
+
>
|
|
410
|
+
<span class="g-mark">${e.mark}</span>
|
|
411
|
+
<span>${this.msg.oauthContinueWith} ${e.name}</span>
|
|
412
|
+
</button>
|
|
413
|
+
|
|
414
|
+
${s.length?i.html`
|
|
415
|
+
<div class="icon-row">
|
|
416
|
+
${s.map(r=>i.html`
|
|
417
|
+
<button
|
|
418
|
+
type="button"
|
|
419
|
+
class="icon-btn"
|
|
420
|
+
part="oauth-button"
|
|
421
|
+
aria-label=${`${this.msg.oauthContinueWith} ${r.name}`}
|
|
422
|
+
title=${`${this.msg.oauthContinueWith} ${r.name}`}
|
|
423
|
+
?disabled=${this.submitting}
|
|
424
|
+
@click=${()=>this.startOAuth(r.id,this.intent)}
|
|
425
|
+
>
|
|
426
|
+
<span class="tile-mark">${r.mark}</span>
|
|
427
|
+
</button>
|
|
428
|
+
`)}
|
|
429
|
+
</div>
|
|
430
|
+
`:i.nothing}
|
|
431
|
+
</div>
|
|
432
|
+
`}renderLink(){const t=this.effectiveSettings,e=U(t,"link").find(r=>r.id===this.provider);if(t&&!e)return i.nothing;const s=this.providerName||(e==null?void 0:e.name)||this.provider;return i.html`
|
|
433
|
+
<div class="stack">
|
|
434
|
+
${this.renderStatus()}
|
|
435
|
+
<button
|
|
436
|
+
type="button"
|
|
437
|
+
class="secondary"
|
|
438
|
+
part="oauth-button"
|
|
439
|
+
?disabled=${this.submitting}
|
|
440
|
+
@click=${()=>this.startOAuth(this.provider,"link",!0)}
|
|
441
|
+
>
|
|
442
|
+
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
443
|
+
<span>${this.msg.oauthContinueWith} ${s}</span>
|
|
444
|
+
</button>
|
|
445
|
+
</div>
|
|
446
|
+
`}async onSignOut(){const t=this.resolvedClient;t&&await this.run(async()=>{await t.signOut()})}renderSignOut(){return this.embedded?i.html`<button
|
|
447
|
+
type="button"
|
|
448
|
+
class="link-sm"
|
|
449
|
+
part="button-signout"
|
|
450
|
+
?disabled=${this.submitting}
|
|
451
|
+
@click=${this.onSignOut}
|
|
452
|
+
>
|
|
453
|
+
${this.msg.signOutCta}
|
|
454
|
+
</button>`:i.html`
|
|
455
|
+
<div class="stack">
|
|
456
|
+
${this.formError?i.html`<p class="banner" role="alert">${this.formError}</p>`:i.nothing}
|
|
457
|
+
<button
|
|
458
|
+
type="button"
|
|
459
|
+
class="link-sm"
|
|
460
|
+
part="button-signout"
|
|
461
|
+
?disabled=${this.submitting}
|
|
462
|
+
@click=${this.onSignOut}
|
|
463
|
+
>
|
|
464
|
+
${this.msg.signOutCta}
|
|
465
|
+
</button>
|
|
466
|
+
</div>
|
|
467
|
+
`}render(){return this.type==="oauth"?this.renderOAuth():this.type==="link"?this.renderLink():this.renderSignOut()}},mt=new WeakMap,bt=new WeakMap,ft=new WeakMap,vt=new WeakMap,wt=new WeakMap,St=new WeakMap,yt=new WeakMap,Ve);y([o.property()],exports.SinglebaseAuthButtons.prototype,"type",1);y([o.property()],exports.SinglebaseAuthButtons.prototype,"intent",1);y([o.property()],exports.SinglebaseAuthButtons.prototype,"provider",1);y([o.property({attribute:"provider-name"})],exports.SinglebaseAuthButtons.prototype,"providerName",1);y([o.property({type:Boolean})],exports.SinglebaseAuthButtons.prototype,"embedded",1);y([o.property({attribute:!1})],exports.SinglebaseAuthButtons.prototype,"settings",1);y([o.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthButtons.prototype,"nonceStorageKey",1);exports.SinglebaseAuthButtons=y([o.customElement("singlebase-authui-buttons")],exports.SinglebaseAuthButtons);var is=Object.defineProperty,_s=Object.getOwnPropertyDescriptor,ks=(a,n,t)=>n in a?is(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t,u=(a,n,t,e)=>{for(var s=e>1?void 0:e?_s(n,t):n,r=a.length-1,d;r>=0;r--)(d=a[r])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&is(n,t,s),s},Os=(a,n,t)=>ks(a,n+"",t);const Ne="oauth_denied",Le="oauth_error",Ts=/^[A-Z][A-Z0-9_]{0,63}$/,ns=["signin","signup","forgot","verify","otp","newpass","invite"],as=["account"],Ns=[...ns,...as,"oauth-callback"];function Me(a){return ns.includes(a)}function rs(a){return as.includes(a)}function Ie(a){return Ns.includes(a)}const _={fromAttribute:a=>a===null?!0:a!=="false",toAttribute:a=>a?null:"false"};var $t,Et,Ct,Pt,At,_t,kt,Ot,Tt,Nt,Lt,xt,Ut,Mt,It,Rt,Dt,Ft,Bt,Ht,qt,jt,Gt,Kt,Vt,Wt,Yt,zt,Jt,Zt,Qt,Xt,te,ee,se,ie,ne,ae,re,oe,le,he,ce,de,ue,pe,ge,me,We;exports.SinglebaseAuthScreen=(We=class extends v{constructor(){super(...arguments);h(this,$t,"signin");h(this,Et,"");h(this,Ct,!1);h(this,Pt,null);h(this,At,!0);h(this,_t,!0);h(this,kt,!0);h(this,Ot,!0);h(this,Tt,!0);h(this,Nt,!0);h(this,Lt,"card");h(this,xt,"bottom");h(this,Ut,!1);h(this,Mt,"");h(this,It,"");h(this,Rt,"");h(this,Dt,"");h(this,Ft,"");h(this,Bt,!0);h(this,Ht,"");h(this,qt,"");h(this,jt,"");h(this,Gt,"singlebase-oauth-nonce");h(this,Kt,"");h(this,Vt,"");h(this,Wt,"");h(this,Yt,0);h(this,zt,"");h(this,Jt,"");h(this,Zt,"");h(this,Qt,"");h(this,Xt,"");h(this,te,"");h(this,ee,"");h(this,se,"");h(this,ie,"");h(this,ne,["","","","","",""]);h(this,ae,"signin_code");h(this,re,!1);h(this,oe,"");h(this,le,"");h(this,he,"");h(this,ce,"");h(this,de,"");h(this,ue,!1);g(this,"settingsCtl",new Ae(this));g(this,"bridge",new ms(this));g(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);g(this,"gotoUnsubscribe");g(this,"gotoClient",null);h(this,pe,!1);h(this,ge,"");h(this,me,"");g(this,"abortController",null);g(this,"onContinue",()=>{this.followRedirect()||(this.dispatchEvent(new CustomEvent("singlebase-continue",{detail:{user:this.getUser()},bubbles:!0,composed:!0})),this.goto("account"))});g(this,"onInterstitialSignOut",async()=>{var t;await((t=this.resolvedClient)==null?void 0:t.logout()),this.goto("signin")})}get initialScreen(){return l(this,$t)}set initialScreen(t){c(this,$t,t)}get screen(){return l(this,Et)}set screen(t){c(this,Et,t)}get noAccountView(){return l(this,Ct)}set noAccountView(t){c(this,Ct,t)}get settings(){return l(this,Pt)}set settings(t){c(this,Pt,t)}get authEnabled(){return l(this,At)}set authEnabled(t){c(this,At,t)}get allowEmailSignin(){return l(this,_t)}set allowEmailSignin(t){c(this,_t,t)}get allowEmailSignup(){return l(this,kt)}set allowEmailSignup(t){c(this,kt,t)}get allowEmailOtp(){return l(this,Ot)}set allowEmailOtp(t){c(this,Ot,t)}get allowOauth(){return l(this,Tt)}set allowOauth(t){c(this,Tt,t)}get allowAccountCreation(){return l(this,Nt)}set allowAccountCreation(t){c(this,Nt,t)}get layout(){return l(this,Lt)}set layout(t){c(this,Lt,t)}get oauthPlacement(){return l(this,xt)}set oauthPlacement(t){c(this,xt,t)}get stepped(){return l(this,Ut)}set stepped(t){c(this,Ut,t)}get logoText(){return l(this,Mt)}set logoText(t){c(this,Mt,t)}get logoUrl(){return l(this,It)}set logoUrl(t){c(this,It,t)}get brandLine(){return l(this,Rt)}set brandLine(t){c(this,Rt,t)}get brandFoot(){return l(this,Dt)}set brandFoot(t){c(this,Dt,t)}get signInTitle(){return l(this,Ft)}set signInTitle(t){c(this,Ft,t)}get branding(){return l(this,Bt)}set branding(t){c(this,Bt,t)}get redirectUrl(){return l(this,Ht)}set redirectUrl(t){c(this,Ht,t)}get tosUrl(){return l(this,qt)}set tosUrl(t){c(this,qt,t)}get privacyUrl(){return l(this,jt)}set privacyUrl(t){c(this,jt,t)}get nonceStorageKey(){return l(this,Gt)}set nonceStorageKey(t){c(this,Gt,t)}get inviteEmail(){return l(this,Kt)}set inviteEmail(t){c(this,Kt,t)}get inviteOrg(){return l(this,Vt)}set inviteOrg(t){c(this,Vt,t)}get inviteCode(){return l(this,Wt)}set inviteCode(t){c(this,Wt,t)}get step(){return l(this,Yt)}set step(t){c(this,Yt,t)}get method(){return l(this,zt)}set method(t){c(this,zt,t)}get email(){return l(this,Jt)}set email(t){c(this,Jt,t)}get password(){return l(this,Zt)}set password(t){c(this,Zt,t)}get name(){return l(this,Qt)}set name(t){c(this,Qt,t)}get firstName(){return l(this,Xt)}set firstName(t){c(this,Xt,t)}get lastName(){return l(this,te)}set lastName(t){c(this,te,t)}get phone(){return l(this,ee)}set phone(t){c(this,ee,t)}get newPass(){return l(this,se)}set newPass(t){c(this,se,t)}get confirmPass(){return l(this,ie)}set confirmPass(t){c(this,ie,t)}get code(){return l(this,ne)}set code(t){c(this,ne,t)}get verifyNext(){return l(this,ae)}set verifyNext(t){c(this,ae,t)}get loading(){return l(this,re)}set loading(t){c(this,re,t)}get banner(){return l(this,oe)}set banner(t){c(this,oe,t)}get notice(){return l(this,le)}set notice(t){c(this,le,t)}get emailError(){return l(this,he)}set emailError(t){c(this,he,t)}get passError(){return l(this,ce)}set passError(t){c(this,ce,t)}get newPassError(){return l(this,de)}set newPassError(t){c(this,de,t)}get needsMfaCode(){return l(this,ue)}set needsMfaCode(t){c(this,ue,t)}uid(t){return`${this.uidBase}-${t}`}willUpdate(t){super.willUpdate(t),this.settingsCtl.load(this.resolvedClient,this.settings),this.bridge.bind(this.resolvedClient),this.bindGoto(this.resolvedClient)}disconnectedCallback(){var t,e;super.disconnectedCallback(),(t=this.gotoUnsubscribe)==null||t.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=null,(e=this.abortController)==null||e.abort()}bindGoto(t){var r;if(t===this.gotoClient||((r=this.gotoUnsubscribe)==null||r.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=t,!t))return;const e=t.on("goto",({screen:d})=>{Ie(d)&&this.goto(d)}),s=t.on("signin",()=>{this.followRedirect()});this.gotoUnsubscribe=()=>{e(),s()}}goto(t){this.screen!==t&&(this.screen=t,this.step=0,this.banner="",this.notice="",this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0})))}get cfg(){const t=this.settings??this.settingsCtl.settings;if(!t)return{authEnabled:this.authEnabled,allowEmailSignin:this.allowEmailSignin,allowEmailSignup:this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp,allowOauth:this.allowOauth,allowRecovery:this.allowEmailSignin,mfa:!1};const e=t.auth_settings,s=e.second_factor==="email_otp";return{authEnabled:t.enabled&&e.enabled&&this.authEnabled,allowEmailSignin:e.allow_signin&&this.allowEmailSignin,allowEmailSignup:e.allow_signup&&this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp&&e.allow_signin&&!s,allowOauth:Xe(t)&&this.allowOauth,allowRecovery:e.allow_signin&&this.allowEmailSignin&&e.password_recovery_verification==="email_otp",mfa:s}}get requestedScreen(){const t=this.screen||this.initialScreen||"signin";return Ie(t)?t:"signin"}get activeScreen(){const t=this.auth.state.status==="authenticated";if(this.isOAuthCallback||this.callbackPhase==="working"||this.callbackPhase==="failed"&&!t)return"oauth-callback";const e=this.requestedScreen;if(rs(e))return t?e:"signin";if(t)return this.screen!==""||this.initialScreen!=="signin"?e:"account";const s=this.cfg;let r=e;return r==="signup"&&!s.allowEmailSignup&&(r="signin"),(r==="forgot"||r==="newpass")&&!s.allowRecovery&&(r="signin"),r==="otp"&&!s.allowEmailOtp&&(r="signin"),r==="signin"&&!s.allowEmailSignin&&s.allowEmailOtp&&(r="otp"),r}get showsSignedInInterstitial(){return this.auth.state.status==="authenticated"&&Me(this.activeScreen)}get redirectTarget(){var t;return Je.resolveRedirectTarget(this.redirectUrl||this.redirectParam,(t=globalThis.location)==null?void 0:t.href,e=>console.warn(`[singlebase] ${e}`))}get redirectParam(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.get("redirect")??t.get("next")??""}followRedirect(){var e;const t=this.redirectTarget;return t?((e=globalThis.location)==null||e.assign(t),!0):!1}get isOAuthCallback(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.has("access_code")||t.get("error")===Ne||t.has(Le)}get callbackDone(){return l(this,pe)}set callbackDone(t){c(this,pe,t)}get callbackPhase(){return l(this,ge)}set callbackPhase(t){c(this,ge,t)}get linkNotice(){return l(this,me)}set linkNotice(t){c(this,me,t)}cleanCallbackUrl(){var s;const t=(s=globalThis.location)==null?void 0:s.href;if(!t||!globalThis.history)return;const e=new URL(t);e.searchParams.delete("access_code"),e.searchParams.delete(Le),e.searchParams.get("error")===Ne&&e.searchParams.delete("error"),globalThis.history.replaceState({},"",e.toString())}async handleOAuthCallback(){var w,S,$,E,N,L;if(this.callbackDone)return;const t=new URLSearchParams(((w=globalThis.location)==null?void 0:w.search)??""),e=t.get("access_code"),s=t.get("error")===Ne,r=t.get(Le),d=this.resolvedClient;if(e&&!d)return;if(this.callbackDone=!0,s||r||!e||!d){(S=globalThis.sessionStorage)==null||S.removeItem(this.nonceStorageKey),($=globalThis.sessionStorage)==null||$.removeItem(Pe(this.nonceStorageKey)),this.cleanCallbackUrl(),this.banner=s?this.msg.oauthDenied:this.describeOAuthError(r??""),this.callbackPhase="failed";return}const p=(E=globalThis.sessionStorage)==null?void 0:E.getItem(this.nonceStorageKey),m=Pe(this.nonceStorageKey),f=(N=globalThis.sessionStorage)==null?void 0:N.getItem(m);if((L=globalThis.sessionStorage)==null||L.removeItem(m),this.cleanCallbackUrl(),!p){this.banner=this.msg.genericErrorMessage,this.callbackPhase="failed";return}this.callbackPhase="working",await this.withLoading(async()=>{var x,C;if(await d.completeOAuth({access_code:e,nonce:p},this.signal()),(x=globalThis.sessionStorage)==null||x.removeItem(this.nonceStorageKey),f){const ke=this.settings??this.settingsCtl.settings,Oe=((C=U(ke,"link").find(Te=>Te.id===f))==null?void 0:C.name)??f;this.linkNotice=this.msg.providerConnectedNotice.replace("{name}",Oe)}}),this.callbackPhase=this.banner?"failed":""}renderLogo(){return this.logoUrl?i.html`<img class="logo-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}renderBrandMark(){return this.logoUrl?i.html`<img class="brand-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="brand-mark" part="logo">${this.logoText}</div>`:i.nothing}renderBranding(){return Re.renderBranding(this.branding,"Auth")}panel(t){return i.html`<div class="panel">${t}${this.renderBranding()}</div>`}renderOAuthCallback(){return i.html`
|
|
468
|
+
<div class="stack">
|
|
469
|
+
<div class="head">
|
|
470
|
+
${this.renderLogo()}
|
|
471
|
+
<h2 class="title" part="title">${this.msg.oauthCallbackTitle}</h2>
|
|
472
|
+
<p class="sub">${this.msg.oauthCallbackSub}</p>
|
|
473
|
+
</div>
|
|
474
|
+
${this.banner?i.html`<div class="banner" part="banner" role="alert">${this.banner}</div>`:i.html`<div class="stack" style="align-items:center;">
|
|
475
|
+
<span class="spinner" part="spinner"></span>
|
|
476
|
+
</div>`}
|
|
477
|
+
${this.banner?i.html`<button
|
|
478
|
+
type="button"
|
|
479
|
+
class="ghost"
|
|
480
|
+
@click=${()=>{this.callbackPhase="",this.goto("signin")}}
|
|
481
|
+
>
|
|
482
|
+
<span>${this.msg.backCta}</span>
|
|
483
|
+
</button>`:i.nothing}
|
|
484
|
+
</div>
|
|
485
|
+
`}setScreen(t,e={}){const s=this.screen!==t;this.screen=t,this.banner="",this.emailError="",this.passError="",Object.assign(this,e),s&&this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0}))}async withLoading(t){this.loading=!0,this.banner="";try{await t()}catch(e){this.banner=this.describeError(e)}finally{this.loading=!1}}describeError(t){return Ue(t,this.msg)}describeOAuthError(t){return Ts.test(t)?t==="INVALID_CREDENTIALS"?this.msg.oauthNoAccountMessage:Ue(new P.SinglebaseAuthError({type:"AUTH_ERROR",status:400,message:t}),this.msg):this.msg.genericErrorMessage}get passwordHint(){const t=this.settings??this.settingsCtl.settings;return ss(t==null?void 0:t.auth_settings.password_policy,this.msg)}get newPasswordHint(){const t=this.settings??this.settingsCtl.settings;return ts(t==null?void 0:t.auth_settings.password_policy,this.msg)}checkNewPassword(t){const e=this.settings??this.settingsCtl.settings;return es(t,e==null?void 0:e.auth_settings.password_policy,this.msg)}get codeValue(){return this.code.join("")}async onSubmit(t){t==null||t.preventDefault();const e=this.resolvedClient;if(!e)return;const s=this.activeScreen;if(this.cfg,s==="forgot"||s==="otp"){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}const r=s==="forgot"?"password_reset":"signin";await this.withLoading(async()=>{await e.requestCode({email:this.email,purpose:r},this.signal()),this.notice=this.msg.codeSentNeutral,this.screen="verify",this.verifyNext=s==="forgot"?"newpass":"signin_code",this.code=["","","","","",""]});return}if(s==="verify"){if(this.codeValue.length<6){this.banner=this.msg.codeIncompleteError;return}if(this.verifyNext==="newpass"){this.setScreen("newpass",{notice:""});return}await this.withLoading(async()=>{await e.signIn({email:this.email,grant_type:"code",code:this.codeValue},this.signal()),this.notice=""});return}if(s==="newpass"){const r=this.checkNewPassword(this.newPass);if(r){this.newPassError=r;return}if(this.newPass!==this.confirmPass){this.newPassError=this.msg.passwordMatchError;return}await this.withLoading(async()=>{await e.resetPassword({email:this.email,code:this.codeValue,new_password:this.newPass},this.signal()),this.newPass="",this.confirmPass=""});return}if(s==="invite"){const r=this.phone.trim();if(r&&r.replace(/\D/g,"").length<7){this.banner=this.msg.invalidPhoneError;return}const d=this.checkNewPassword(this.password);if(d){this.passError=d;return}const p=this.inviteCode||this.codeValue;if(p.length<6){this.banner=this.msg.codeIncompleteError;return}await this.withLoading(async()=>{await e.acceptInvite({email:this.inviteEmail,grant_type:"code",purpose:"invite",code:p,password:this.password,...r?{phone:r}:{}},this.signal());const m=this.firstName.trim(),f=this.lastName.trim();(m||f)&&await e.updateAccount({...m?{first_name:m}:{},...f?{last_name:f}:{}},this.signal()).catch(()=>{})});return}if(this.stepped&&(s==="signup"&&this.step<2||s==="signin"&&this.step<1)){if(s==="signup"&&this.step===0){if(!this.name.trim()){this.banner=this.msg.firstNameRequiredError;return}}else if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}this.banner="",this.step+=1;return}if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(s==="signup"){const[r="",...d]=this.name.trim().split(/\s+/);if(!r){this.banner=this.msg.firstNameRequiredError;return}const p=this.checkNewPassword(this.password);if(p){this.passError=p;return}const m=d.join(" ");await this.withLoading(async()=>{const f=await e.signUp({email:this.email,password:this.password,first_name:r,...m?{last_name:m}:{}},this.signal()),w=P.resolveScreen({next_action:f.next_action,next_operation:f.next_operation});this.setScreen("signin",{notice:this.msg.accountCreatedNotice,step:0,password:"",needsMfaCode:w==="signin_with_code"})});return}if(!this.password){this.passError=this.msg.requiredError;return}await this.withLoading(async()=>{try{await e.signIn({email:this.email,password:this.password,...this.needsMfaCode?{code:this.codeValue}:{}},this.signal()),this.step=0}catch(r){if(r instanceof P.SinglebaseAuthError&&r.code==="CODE_REQUIRED"){this.needsMfaCode=!0,await e.requestCode({email:this.email,purpose:"signin"},this.signal()),this.notice=this.msg.codeSentNeutral;return}if(r instanceof P.SinglebaseAuthError&&r.code==="INVALID_CREDENTIALS"){this.banner=this.msg.invalidCredentialsError;return}throw r}})}signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}onCodeInput(t,e){var m;const r=e.target.value.replace(/\D/g,"");if(r.length>1){this.fillCode(t,r);return}const d=r.slice(-1),p=this.code.slice();p[t]=d,this.code=p,this.banner="",d&&((m=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[t+1])==null||m.focus())}onCodePaste(t,e){var r;const s=(((r=e.clipboardData)==null?void 0:r.getData("text"))??"").replace(/\D/g,"");s&&(e.preventDefault(),this.fillCode(t,s))}fillCode(t,e){const s=this.code.slice();for(let d=0;d<e.length&&t+d<s.length;d+=1)s[t+d]=e[d];this.code=s,this.banner="";const r=Math.min(t+e.length,s.length-1);this.updateComplete.then(()=>{var p;(p=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[r])==null||p.focus()})}async onResend(){const t=this.resolvedClient;if(!t||this.loading)return;const e=this.verifyNext==="newpass"?"password_reset":"signin";await this.withLoading(async()=>{await t.requestCode({email:this.email,purpose:e},this.signal()),this.notice=this.msg.codeResentNotice,this.code=["","","","","",""]})}goBack(){if(this.step>0&&["forgot","verify","otp","newpass"].indexOf(this.activeScreen)<0){this.step-=1,this.banner="",this.notice="";return}this.setScreen("signin",{step:0,notice:"",code:["","","","","",""]})}titleFor(t){const e=this.msg;switch(t){case"signup":return e.signUpTitle;case"forgot":return e.forgotTitle;case"verify":return e.verifyTitle;case"otp":return e.otpTitle;case"newpass":return e.newPassTitle;case"invite":return e.inviteTitle;default:return this.signInTitle||e.signInTitle}}subFor(t){const e=this.msg,s=this.cfg;switch(t){case"signup":return e.signUpSub;case"forgot":return e.forgotSub;case"verify":return`We sent a 6-digit code to ${this.email||"your inbox"}. It expires in 10 minutes.`;case"otp":return e.otpSub;case"newpass":return`Your code is confirmed. Set a new password for ${this.email||"your account"}.`;case"invite":return`${this.inviteOrg||"Acme"} invited you to join. Set up your account to continue.`;default:return!s.allowEmailSignin&&!s.allowEmailOtp?e.signInSubOauthOnly:s.allowOauth?e.signInSubEmailAndOauth:e.signInSubEmailOnly}}ctaFor(t){const e=this.msg;if(this.stepped&&(t==="signup"&&this.step<2||t==="signin"&&this.step<1))return e.continueCta;switch(t){case"signup":return e.signUpCta;case"forgot":return e.forgotCta;case"verify":return e.verifyCta;case"otp":return e.otpCta;case"newpass":return e.newPassCta;case"invite":return e.inviteCta;default:return e.signInCta}}stepPct(){if(!this.stepped)return 100;const t=this.activeScreen==="signup"?3:2;return Math.round((this.step+1)/t*100)}renderPrimary(t){return i.html`
|
|
486
|
+
<button type="submit" class="primary" part="button-primary" ?disabled=${this.loading}>
|
|
487
|
+
${this.loading?i.html`<span class="spinner" part="spinner"></span>`:i.nothing}
|
|
488
|
+
<span>${t}</span>
|
|
489
|
+
</button>
|
|
490
|
+
`}renderEmailField(t){return i.html`
|
|
491
|
+
<div class="field">
|
|
492
|
+
<label for=${t}>${this.msg.emailLabel}</label>
|
|
493
|
+
<input
|
|
494
|
+
id=${t}
|
|
495
|
+
type="email"
|
|
496
|
+
part="input"
|
|
497
|
+
.value=${this.email}
|
|
498
|
+
placeholder=${this.msg.emailPlaceholder}
|
|
499
|
+
aria-invalid=${this.emailError?"true":"false"}
|
|
500
|
+
?disabled=${this.loading}
|
|
501
|
+
@input=${e=>{this.email=e.target.value,this.emailError="",this.banner=""}}
|
|
502
|
+
/>
|
|
503
|
+
${this.emailError?i.html`<p class="err">${this.emailError}</p>`:i.nothing}
|
|
504
|
+
</div>
|
|
505
|
+
`}renderPasswordField(t,e,s=!1){return i.html`
|
|
506
|
+
<div class="field">
|
|
507
|
+
<div class="label-row">
|
|
508
|
+
<label for=${t}>${this.msg.passwordLabel}</label>
|
|
509
|
+
${e?i.html`<button
|
|
510
|
+
type="button"
|
|
511
|
+
class="link-sm"
|
|
512
|
+
@click=${()=>this.setScreen("forgot",{step:0})}
|
|
513
|
+
>
|
|
514
|
+
${this.msg.forgotLink}
|
|
515
|
+
</button>`:i.nothing}
|
|
516
|
+
</div>
|
|
517
|
+
<input
|
|
518
|
+
id=${t}
|
|
519
|
+
type="password"
|
|
520
|
+
part="input"
|
|
521
|
+
.value=${this.password}
|
|
522
|
+
placeholder=${s?this.newPasswordHint:this.msg.passwordPlaceholder}
|
|
523
|
+
aria-invalid=${this.passError?"true":"false"}
|
|
524
|
+
?disabled=${this.loading}
|
|
525
|
+
@input=${r=>{this.password=r.target.value,this.passError="",this.banner=""}}
|
|
526
|
+
/>
|
|
527
|
+
${s?this.passwordHint:i.nothing}
|
|
528
|
+
${this.passError?i.html`<p class="err">${this.passError}</p>`:i.nothing}
|
|
529
|
+
</div>
|
|
530
|
+
`}renderCodeRow(t=!1){return i.html`
|
|
531
|
+
<div
|
|
532
|
+
class=${t?"code-row-sm":"code-row"}
|
|
533
|
+
role="group"
|
|
534
|
+
aria-label=${this.msg.codeLabel}
|
|
535
|
+
>
|
|
536
|
+
${this.code.map((e,s)=>i.html`
|
|
537
|
+
<input
|
|
538
|
+
type="text"
|
|
539
|
+
inputmode="numeric"
|
|
540
|
+
maxlength="1"
|
|
541
|
+
part="code-box"
|
|
542
|
+
aria-label=${this.msg.digitLabel.replace("{n}",String(s+1))}
|
|
543
|
+
autocomplete=${s===0?"one-time-code":"off"}
|
|
544
|
+
.value=${e}
|
|
545
|
+
?disabled=${this.loading}
|
|
546
|
+
@input=${r=>this.onCodeInput(s,r)}
|
|
547
|
+
@paste=${r=>this.onCodePaste(s,r)}
|
|
548
|
+
/>
|
|
549
|
+
`)}
|
|
550
|
+
</div>
|
|
551
|
+
`}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,r=t==="signup"&&(!s||this.step===0),d=t==="signup"&&(!s||this.step===1)||t==="signin"&&(!s||this.step===0)||t==="otp",p=t==="signup"&&(!s||this.step===2)||t==="signin"&&(!s||this.step===1),m=t==="signin"&&e.allowEmailSignin&&e.allowEmailOtp&&(!s||this.step===0);return i.html`
|
|
552
|
+
${r?i.html`
|
|
553
|
+
<div class="field">
|
|
554
|
+
<label for=${this.uid("name")}>${this.msg.fullNameLabel}</label>
|
|
555
|
+
<input
|
|
556
|
+
id=${this.uid("name")}
|
|
557
|
+
type="text"
|
|
558
|
+
part="input"
|
|
559
|
+
.value=${this.name}
|
|
560
|
+
placeholder=${this.msg.fullNamePlaceholder}
|
|
561
|
+
?disabled=${this.loading}
|
|
562
|
+
@input=${f=>this.name=f.target.value}
|
|
563
|
+
/>
|
|
564
|
+
</div>
|
|
565
|
+
`:i.nothing}
|
|
566
|
+
${d?this.renderEmailField(this.uid("email")):i.nothing}
|
|
567
|
+
${p?this.renderPasswordField(this.uid("pass"),e.allowRecovery&&t==="signin",t==="signup"):i.nothing}
|
|
568
|
+
${this.needsMfaCode&&t==="signin"?i.html`
|
|
569
|
+
<div class="field">
|
|
570
|
+
<span class="label">${this.msg.codeLabel}</span>
|
|
571
|
+
${this.renderCodeRow(!0)}
|
|
572
|
+
</div>
|
|
573
|
+
`:i.nothing}
|
|
574
|
+
${this.renderPrimary(this.ctaFor(t))}
|
|
575
|
+
${m?i.html`<button
|
|
576
|
+
type="button"
|
|
577
|
+
class="edit-link"
|
|
578
|
+
@click=${()=>this.setScreen("otp",{step:0})}
|
|
579
|
+
>
|
|
580
|
+
${this.msg.otpInsteadLink}
|
|
581
|
+
</button>`:i.nothing}
|
|
582
|
+
`}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,r=this.settings??this.settingsCtl.settings,d=U(r,t==="signup"?"signup":"signin"),p=e.allowOauth&&(!r||d.length>0);if(!s&&!p)return i.nothing;const m=s&&p,f=s?p&&this.method||"email":"oauth",w=f==="email",S=f==="oauth",$=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,E=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,N=(C,ke,Oe,Te,ls,He)=>i.html`
|
|
583
|
+
<div class="acc-item ${C?"open":""} ${m?"":"bare"}" part="acc-item">
|
|
584
|
+
${m?i.html`
|
|
585
|
+
<button
|
|
586
|
+
type="button"
|
|
587
|
+
class="acc-head"
|
|
588
|
+
aria-expanded=${C?"true":"false"}
|
|
589
|
+
aria-controls=${this.uid(`acc-${He}`)}
|
|
590
|
+
@click=${ls}
|
|
591
|
+
>
|
|
592
|
+
<span class="chev" aria-hidden="true">›</span>
|
|
593
|
+
<span class="acc-title">${ke}</span>
|
|
594
|
+
<span class="acc-meta">${Oe}</span>
|
|
595
|
+
</button>
|
|
596
|
+
`:i.nothing}
|
|
597
|
+
<div class="acc-body" id=${this.uid(`acc-${He}`)}>
|
|
598
|
+
<div class="acc-clip">
|
|
599
|
+
<div class="acc-inner">${Te}</div>
|
|
600
|
+
</div>
|
|
601
|
+
</div>
|
|
602
|
+
</div>
|
|
603
|
+
`,L=s?N(w,$,E,this.renderEmailMethodBody(t),()=>this.method=w?"":"email","email"):i.nothing,x=p?N(S,this.msg.oauthMethodTitle,d.length?d.map(C=>C.name).join(", "):this.msg.oauthMethodMeta,i.html`<singlebase-authui-buttons
|
|
604
|
+
type="oauth"
|
|
605
|
+
embedded
|
|
606
|
+
theme=${k.ifDefined(this.theme)}
|
|
607
|
+
density=${k.ifDefined(this.density)}
|
|
608
|
+
field-style=${k.ifDefined(this.fieldStyle)}
|
|
609
|
+
.client=${this.resolvedClient}
|
|
610
|
+
.messages=${this.messages}
|
|
611
|
+
.settings=${this.settings??this.settingsCtl.settings}
|
|
612
|
+
intent=${t==="signup"?"signup":"signin"}
|
|
613
|
+
></singlebase-authui-buttons>`,()=>this.method=S?"":"oauth","oauth"):i.nothing;return i.html`
|
|
614
|
+
<div class="acc-wrap">
|
|
615
|
+
${this.oauthPlacement==="top"?i.html`${x}${L}`:i.html`${L}${x}`}
|
|
616
|
+
</div>
|
|
617
|
+
`}renderScreenBody(t){return this.cfg,["signin","signup","otp"].indexOf(t)>=0?this.renderAccordion(t):t==="forgot"?i.html`<div class="fields">${this.renderEmailField(this.uid("reset"))}</div>`:t==="verify"?i.html`
|
|
618
|
+
${this.renderCodeRow()}
|
|
619
|
+
<div class="resend-row">
|
|
620
|
+
<span class="hint">${this.msg.resendQuestion}</span>
|
|
621
|
+
<button type="button" class="link-sm" ?disabled=${this.loading} @click=${this.onResend}>
|
|
622
|
+
${this.msg.resendCta}
|
|
623
|
+
</button>
|
|
624
|
+
</div>
|
|
625
|
+
`:t==="newpass"?i.html`
|
|
626
|
+
<div class="fields">
|
|
627
|
+
<div class="field">
|
|
628
|
+
<label for=${this.uid("newpass")}>${this.msg.newPasswordLabel}</label>
|
|
629
|
+
<input
|
|
630
|
+
id=${this.uid("newpass")}
|
|
631
|
+
type="password"
|
|
632
|
+
part="input"
|
|
633
|
+
.value=${this.newPass}
|
|
634
|
+
placeholder=${this.newPasswordHint}
|
|
635
|
+
aria-invalid=${this.newPassError?"true":"false"}
|
|
636
|
+
?disabled=${this.loading}
|
|
637
|
+
@input=${s=>{this.newPass=s.target.value,this.newPassError=""}}
|
|
638
|
+
/>
|
|
639
|
+
</div>
|
|
640
|
+
<div class="field">
|
|
641
|
+
<label for=${this.uid("confirmpass")}>${this.msg.confirmPasswordLabel}</label>
|
|
642
|
+
<input
|
|
643
|
+
id=${this.uid("confirmpass")}
|
|
644
|
+
type="password"
|
|
645
|
+
part="input"
|
|
646
|
+
.value=${this.confirmPass}
|
|
647
|
+
placeholder=${this.msg.confirmPasswordPlaceholder}
|
|
648
|
+
aria-invalid=${this.newPassError?"true":"false"}
|
|
649
|
+
?disabled=${this.loading}
|
|
650
|
+
@input=${s=>{this.confirmPass=s.target.value,this.newPassError=""}}
|
|
651
|
+
/>
|
|
652
|
+
${this.passwordHint}
|
|
653
|
+
${this.newPassError?i.html`<p class="err">${this.newPassError}</p>`:i.nothing}
|
|
654
|
+
</div>
|
|
655
|
+
</div>
|
|
656
|
+
`:t==="invite"?i.html`
|
|
657
|
+
<div class="fields">
|
|
658
|
+
<div class="invite-box">
|
|
659
|
+
<span class="invite-label">${this.msg.invitedEmailLabel}</span>
|
|
660
|
+
<span class="invite-email">${this.inviteEmail}</span>
|
|
661
|
+
</div>
|
|
662
|
+
${this.inviteCode?i.nothing:i.html`<div class="field">
|
|
663
|
+
<span class="label">${this.msg.inviteCodeLabel}</span>
|
|
664
|
+
${this.renderCodeRow(!0)}
|
|
665
|
+
</div>`}
|
|
666
|
+
<div class="two-up">
|
|
667
|
+
<div class="field">
|
|
668
|
+
<label for=${this.uid("first")}>${this.msg.firstNameLabel}</label>
|
|
669
|
+
<input
|
|
670
|
+
id=${this.uid("first")}
|
|
671
|
+
type="text"
|
|
672
|
+
part="input"
|
|
673
|
+
.value=${this.firstName}
|
|
674
|
+
placeholder=${this.msg.firstNamePlaceholder}
|
|
675
|
+
?disabled=${this.loading}
|
|
676
|
+
@input=${s=>this.firstName=s.target.value}
|
|
677
|
+
/>
|
|
678
|
+
</div>
|
|
679
|
+
<div class="field">
|
|
680
|
+
<label for=${this.uid("last")}>${this.msg.lastNameLabel}</label>
|
|
681
|
+
<input
|
|
682
|
+
id=${this.uid("last")}
|
|
683
|
+
type="text"
|
|
684
|
+
part="input"
|
|
685
|
+
.value=${this.lastName}
|
|
686
|
+
placeholder=${this.msg.lastNamePlaceholder}
|
|
687
|
+
?disabled=${this.loading}
|
|
688
|
+
@input=${s=>this.lastName=s.target.value}
|
|
689
|
+
/>
|
|
690
|
+
</div>
|
|
691
|
+
</div>
|
|
692
|
+
<div class="field">
|
|
693
|
+
<label for=${this.uid("phone")}>${this.msg.phoneLabel}</label>
|
|
694
|
+
<input
|
|
695
|
+
id=${this.uid("phone")}
|
|
696
|
+
type="tel"
|
|
697
|
+
part="input"
|
|
698
|
+
.value=${this.phone}
|
|
699
|
+
placeholder=${this.msg.phonePlaceholder}
|
|
700
|
+
?disabled=${this.loading}
|
|
701
|
+
@input=${s=>this.phone=s.target.value}
|
|
702
|
+
/>
|
|
703
|
+
</div>
|
|
704
|
+
<div class="field">
|
|
705
|
+
<label for=${this.uid("invitepass")}>${this.msg.passwordLabel}</label>
|
|
706
|
+
<input
|
|
707
|
+
id=${this.uid("invitepass")}
|
|
708
|
+
type="password"
|
|
709
|
+
part="input"
|
|
710
|
+
.value=${this.password}
|
|
711
|
+
placeholder=${this.newPasswordHint}
|
|
712
|
+
aria-invalid=${this.passError?"true":"false"}
|
|
713
|
+
?disabled=${this.loading}
|
|
714
|
+
@input=${s=>{this.password=s.target.value,this.passError=""}}
|
|
715
|
+
/>
|
|
716
|
+
${this.passwordHint}
|
|
717
|
+
${this.passError?i.html`<p class="err">${this.passError}</p>`:i.nothing}
|
|
718
|
+
</div>
|
|
719
|
+
</div>
|
|
720
|
+
`:i.nothing}renderGuest(t){const e=this.cfg,s=["forgot","verify","newpass","invite"].indexOf(t)>=0,r=this.stepped&&this.step>0||["forgot","verify","otp","newpass"].indexOf(t)>=0,d=t==="signin"&&e.allowEmailSignup||t==="signup"&&e.allowEmailSignin,p=this.stepped&&(t==="signin"||t==="signup");return i.html`
|
|
721
|
+
<form class="stack" @submit=${this.onSubmit} novalidate>
|
|
722
|
+
<div class="head">
|
|
723
|
+
${this.layout!=="split"?this.renderLogo():i.nothing}
|
|
724
|
+
<h2 class="title" part="title">${this.titleFor(t)}</h2>
|
|
725
|
+
<p class="sub">${this.subFor(t)}</p>
|
|
726
|
+
</div>
|
|
727
|
+
|
|
728
|
+
${p?i.html`<div class="step-bar">
|
|
729
|
+
<div class="step-fill" style="width:${this.stepPct()}%"></div>
|
|
730
|
+
</div>`:i.nothing}
|
|
731
|
+
${this.banner?i.html`<div class="banner" part="banner" role="alert">${this.banner}</div>`:i.nothing}
|
|
732
|
+
${this.notice?i.html`<div class="notice" part="notice" role="status">${this.notice}</div>`:i.nothing}
|
|
733
|
+
${this.renderScreenBody(t)}
|
|
734
|
+
${s||r?i.html`
|
|
735
|
+
<div class="actions">
|
|
736
|
+
${s?this.renderPrimary(this.ctaFor(t)):i.nothing}
|
|
737
|
+
${r?i.html`<button type="button" class="ghost" @click=${this.goBack}>
|
|
738
|
+
${this.msg.backCta}
|
|
739
|
+
</button>`:i.nothing}
|
|
740
|
+
</div>
|
|
741
|
+
`:i.nothing}
|
|
742
|
+
${d?i.html`
|
|
743
|
+
<p class="foot">
|
|
744
|
+
<span
|
|
745
|
+
>${t==="signup"?this.msg.footTextSignUp:this.msg.footTextSignIn}</span
|
|
746
|
+
>
|
|
747
|
+
<button
|
|
748
|
+
type="button"
|
|
749
|
+
class="link"
|
|
750
|
+
@click=${()=>this.setScreen(t==="signup"?"signin":"signup",{step:0,notice:""})}
|
|
751
|
+
>
|
|
752
|
+
${t==="signup"?this.msg.footActionSignUp:this.msg.footActionSignIn}
|
|
753
|
+
</button>
|
|
754
|
+
</p>
|
|
755
|
+
`:i.nothing}
|
|
756
|
+
${this.renderConsent()}
|
|
757
|
+
|
|
758
|
+
<span class="sr-only" role="status" aria-live="polite">
|
|
759
|
+
${this.loading?this.msg.submittingStatus:""}
|
|
760
|
+
</span>
|
|
761
|
+
</form>
|
|
762
|
+
`}renderBlocked(){const e=!this.cfg.authEnabled;return i.html`
|
|
763
|
+
<div class="stack">
|
|
764
|
+
<div class="head">
|
|
765
|
+
${this.layout!=="split"?this.renderLogo():i.nothing}
|
|
766
|
+
<h2 class="title" part="title">
|
|
767
|
+
${e?this.msg.blockedTitleDisabled:this.msg.blockedTitleUnavailable}
|
|
768
|
+
</h2>
|
|
769
|
+
<p class="sub">
|
|
770
|
+
${e?this.msg.blockedBodyDisabled:this.msg.blockedBodyUnavailable}
|
|
771
|
+
</p>
|
|
772
|
+
</div>
|
|
773
|
+
<div class="notice" part="notice" role="status">${this.msg.blockedHint}</div>
|
|
774
|
+
</div>
|
|
775
|
+
`}renderSignedIn(){const t=this.auth.state.status==="authenticated"?this.auth.state.user:null,e=this.redirectTarget;return i.html`
|
|
776
|
+
<div class="stack">
|
|
777
|
+
<div class="head">
|
|
778
|
+
${this.renderLogo()}
|
|
779
|
+
<h2 class="title" part="title">${this.msg.alreadySignedInTitle}</h2>
|
|
780
|
+
<p class="sub">
|
|
781
|
+
${t!=null&&t.email?`${this.msg.alreadySignedInSubPrefix} ${t.email}.`:this.msg.alreadySignedInSub}
|
|
782
|
+
</p>
|
|
783
|
+
</div>
|
|
784
|
+
|
|
785
|
+
<div class="actions">
|
|
786
|
+
<button type="button" class="primary" part="button-primary" @click=${this.onContinue}>
|
|
787
|
+
<span>${this.msg.continueCta}</span>
|
|
788
|
+
</button>
|
|
789
|
+
<button type="button" class="ghost" @click=${this.onInterstitialSignOut}>
|
|
790
|
+
<span>${this.msg.signOutCta}</span>
|
|
791
|
+
</button>
|
|
792
|
+
</div>
|
|
793
|
+
|
|
794
|
+
${e?i.nothing:i.html`<p class="hint">${this.msg.continueHint}</p>`}
|
|
795
|
+
</div>
|
|
796
|
+
`}renderConsent(){if(!this.tosUrl&&!this.privacyUrl)return i.nothing;const t=this.tosUrl?i.html`<a class="link-sm" href=${this.tosUrl} target="_blank" rel="noopener noreferrer"
|
|
797
|
+
>${this.msg.termsLabel}</a
|
|
798
|
+
>`:i.nothing,e=this.privacyUrl?i.html`<a class="link-sm" href=${this.privacyUrl} target="_blank" rel="noopener noreferrer"
|
|
799
|
+
>${this.msg.privacyLabel}</a
|
|
800
|
+
>`:i.nothing;return i.html`
|
|
801
|
+
<p class="hint consent" part="consent">
|
|
802
|
+
${this.msg.consentPrefix}
|
|
803
|
+
${t}${this.tosUrl&&this.privacyUrl?i.html` ${this.msg.consentJoin} `:i.nothing}${e}.
|
|
804
|
+
</p>
|
|
805
|
+
`}updated(t){super.updated(t),this.activeScreen==="oauth-callback"&&this.handleOAuthCallback()}render(){const t=this.activeScreen;if(t==="oauth-callback")return this.panel(this.renderOAuthCallback());if(t==="account"){if(this.noAccountView)return i.nothing;const d=this.callbackPhase==="failed"&&this.banner;return this.panel(i.html`
|
|
806
|
+
${d?i.html`<div class="banner" part="banner" role="alert">${this.banner}</div>`:i.nothing}
|
|
807
|
+
${this.linkNotice?i.html`<div class="notice" part="notice" role="status">${this.linkNotice}</div>`:i.nothing}
|
|
808
|
+
<singlebase-authui-account
|
|
809
|
+
theme=${k.ifDefined(this.theme)}
|
|
810
|
+
density=${k.ifDefined(this.density)}
|
|
811
|
+
field-style=${k.ifDefined(this.fieldStyle)}
|
|
812
|
+
.client=${this.resolvedClient}
|
|
813
|
+
.messages=${this.messages}
|
|
814
|
+
logo-text=${this.logoText}
|
|
815
|
+
logo-url=${this.logoUrl}
|
|
816
|
+
></singlebase-authui-account>
|
|
817
|
+
`)}if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,r=!e.authEnabled||s&&Me(t);return i.html`
|
|
818
|
+
${this.layout==="split"?i.html`
|
|
819
|
+
<div class="brand-panel">
|
|
820
|
+
${this.renderBrandMark()}
|
|
821
|
+
${this.brandLine?i.html`<div class="brand-copy">${this.brandLine}</div>`:i.nothing}
|
|
822
|
+
${this.brandFoot?i.html`<div class="brand-foot">${this.brandFoot}</div>`:i.nothing}
|
|
823
|
+
</div>
|
|
824
|
+
`:i.nothing}
|
|
825
|
+
${this.panel(r?this.renderBlocked():this.renderGuest(t))}
|
|
826
|
+
`}},$t=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,At=new WeakMap,_t=new WeakMap,kt=new WeakMap,Ot=new WeakMap,Tt=new WeakMap,Nt=new WeakMap,Lt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Mt=new WeakMap,It=new WeakMap,Rt=new WeakMap,Dt=new WeakMap,Ft=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Vt=new WeakMap,Wt=new WeakMap,Yt=new WeakMap,zt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,ie=new WeakMap,ne=new WeakMap,ae=new WeakMap,re=new WeakMap,oe=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,me=new WeakMap,We);Os(exports.SinglebaseAuthScreen,"styles",[...v.styles,Re.brandingStyles,i.css`
|
|
827
|
+
/* the mock's root */
|
|
828
|
+
:host {
|
|
829
|
+
display: flex;
|
|
830
|
+
width: 100%;
|
|
831
|
+
box-sizing: border-box;
|
|
832
|
+
background: var(--sb-surface, #ffffff);
|
|
833
|
+
color: var(--sb-ink, #16181a);
|
|
834
|
+
border: 1px solid var(--sb-border, #e4e6e9);
|
|
835
|
+
border-radius: calc((var(--sb-radius, 4px) + 4px) * var(--sb-radius-scale, 1));
|
|
836
|
+
overflow: hidden;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
.brand-panel {
|
|
840
|
+
flex: 0 0 40%;
|
|
841
|
+
display: flex;
|
|
842
|
+
flex-direction: column;
|
|
843
|
+
justify-content: space-between;
|
|
844
|
+
gap: 24px;
|
|
845
|
+
padding: var(--sb-pad, 20px);
|
|
846
|
+
background: var(--sb-surface-alt, #fafafa);
|
|
847
|
+
border-right: 1px solid var(--sb-border, #e4e6e9);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/* A flex column would stretch an image to full width and wreck its
|
|
851
|
+
aspect ratio, so both logos opt out of the cross-axis stretch. */
|
|
852
|
+
.logo-img {
|
|
853
|
+
display: block;
|
|
854
|
+
align-self: flex-start;
|
|
855
|
+
height: var(--sb-logo-height, 20px);
|
|
856
|
+
width: auto;
|
|
857
|
+
max-width: 100%;
|
|
858
|
+
margin-bottom: 6px;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
.brand-img {
|
|
862
|
+
display: block;
|
|
863
|
+
align-self: flex-start;
|
|
864
|
+
height: var(--sb-brand-logo-height, 28px);
|
|
865
|
+
width: auto;
|
|
866
|
+
max-width: 100%;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
.brand-mark {
|
|
870
|
+
font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
871
|
+
font-size: 13px;
|
|
872
|
+
letter-spacing: 0.08em;
|
|
873
|
+
text-transform: uppercase;
|
|
874
|
+
color: var(--sb-ink, #16181a);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
.brand-copy {
|
|
878
|
+
font-size: 20px;
|
|
879
|
+
line-height: 1.35;
|
|
880
|
+
letter-spacing: -0.01em;
|
|
881
|
+
color: var(--sb-ink, #16181a);
|
|
882
|
+
text-wrap: pretty;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
.brand-foot {
|
|
886
|
+
font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
887
|
+
font-size: 11px;
|
|
888
|
+
color: var(--sb-muted-ink, #61666c);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.branding {
|
|
892
|
+
margin-top: 18px;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/* the mock's panel */
|
|
896
|
+
.panel {
|
|
897
|
+
flex: 1;
|
|
898
|
+
min-width: 0;
|
|
899
|
+
padding: var(--sb-pad, 20px);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
@media (max-width: 520px) {
|
|
903
|
+
:host {
|
|
904
|
+
flex-direction: column;
|
|
905
|
+
}
|
|
906
|
+
.brand-panel {
|
|
907
|
+
flex: 0 0 auto;
|
|
908
|
+
border-right: none;
|
|
909
|
+
border-bottom: 1px solid var(--sb-border, #e4e6e9);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
`]);u([o.property({attribute:"initial-screen"})],exports.SinglebaseAuthScreen.prototype,"initialScreen",1);u([o.property({reflect:!0})],exports.SinglebaseAuthScreen.prototype,"screen",1);u([o.property({type:Boolean,attribute:"no-account-view"})],exports.SinglebaseAuthScreen.prototype,"noAccountView",1);u([o.property({attribute:!1})],exports.SinglebaseAuthScreen.prototype,"settings",1);u([o.property({converter:_,attribute:"auth-enabled"})],exports.SinglebaseAuthScreen.prototype,"authEnabled",1);u([o.property({converter:_,attribute:"allow-email-signin"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignin",1);u([o.property({converter:_,attribute:"allow-email-signup"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignup",1);u([o.property({converter:_,attribute:"allow-email-otp"})],exports.SinglebaseAuthScreen.prototype,"allowEmailOtp",1);u([o.property({converter:_,attribute:"allow-oauth"})],exports.SinglebaseAuthScreen.prototype,"allowOauth",1);u([o.property({converter:_,attribute:"allow-account-creation"})],exports.SinglebaseAuthScreen.prototype,"allowAccountCreation",1);u([o.property()],exports.SinglebaseAuthScreen.prototype,"layout",1);u([o.property({attribute:"oauth-placement"})],exports.SinglebaseAuthScreen.prototype,"oauthPlacement",1);u([o.property({type:Boolean})],exports.SinglebaseAuthScreen.prototype,"stepped",1);u([o.property({attribute:"logo-text"})],exports.SinglebaseAuthScreen.prototype,"logoText",1);u([o.property({attribute:"logo-url"})],exports.SinglebaseAuthScreen.prototype,"logoUrl",1);u([o.property({attribute:"brand-line"})],exports.SinglebaseAuthScreen.prototype,"brandLine",1);u([o.property({attribute:"brand-foot"})],exports.SinglebaseAuthScreen.prototype,"brandFoot",1);u([o.property({attribute:"sign-in-title"})],exports.SinglebaseAuthScreen.prototype,"signInTitle",1);u([o.property({converter:_,attribute:"branding"})],exports.SinglebaseAuthScreen.prototype,"branding",1);u([o.property({attribute:"redirect-url"})],exports.SinglebaseAuthScreen.prototype,"redirectUrl",1);u([o.property({attribute:"tos-url"})],exports.SinglebaseAuthScreen.prototype,"tosUrl",1);u([o.property({attribute:"privacy-url"})],exports.SinglebaseAuthScreen.prototype,"privacyUrl",1);u([o.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthScreen.prototype,"nonceStorageKey",1);u([o.property({attribute:"invite-email"})],exports.SinglebaseAuthScreen.prototype,"inviteEmail",1);u([o.property({attribute:"invite-org"})],exports.SinglebaseAuthScreen.prototype,"inviteOrg",1);u([o.property({attribute:"invite-code"})],exports.SinglebaseAuthScreen.prototype,"inviteCode",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"step",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"method",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"email",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"password",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"name",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"firstName",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"lastName",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"phone",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"newPass",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"confirmPass",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"code",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"verifyNext",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"loading",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"banner",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"notice",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"emailError",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"passError",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"newPassError",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"needsMfaCode",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"callbackDone",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"callbackPhase",1);u([o.state()],exports.SinglebaseAuthScreen.prototype,"linkNotice",1);exports.SinglebaseAuthScreen=u([o.customElement("singlebase-authui")],exports.SinglebaseAuthScreen);var Ls=Object.defineProperty,xs=Object.getOwnPropertyDescriptor,_e=(a,n,t,e)=>{for(var s=e>1?void 0:e?xs(n,t):n,r=a.length-1,d;r>=0;r--)(d=a[r])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&Ls(n,t,s),s};const Us=["loading","authenticated","unauthenticated"];var be,fe,ve,Ye;exports.SinglebaseAuthGuard=(Ye=class extends v{constructor(){super(...arguments);h(this,be,"");h(this,fe,null);h(this,ve,"unauthenticated");g(this,"warnedFor",null)}get slot(){return l(this,be)}set slot(t){c(this,be,t)}get predicate(){return l(this,fe)}set predicate(t){c(this,fe,t)}get onMismatch(){return l(this,ve)}set onMismatch(t){c(this,ve,t)}createRenderRoot(){return this}get activeState(){const t=this.auth.state.status;if(t==="loading")return"loading";if(t!=="authenticated")return"unauthenticated";if(!this.predicate)return"authenticated";this.warnOnce(this.predicate);const e=this.auth.state.user;return A.matchesPredicate(e,this.predicate)?"authenticated":this.onMismatch==="hidden"?"hidden":"unauthenticated"}warnOnce(t){const e=JSON.stringify(t);if(this.warnedFor!==e){this.warnedFor=e;for(const s of A.validatePredicate(t))console.warn(`[singlebase] <singlebase-authui-guard> predicate: ${s}`)}}render(){const t=this.activeState;if(this.slot){const e=Us.includes(this.slot)&&this.slot===t;return this.toggleAttribute("hidden",!e),i.html`<slot></slot>`}this.toggleAttribute("hidden",!1);for(const e of Array.from(this.children)){const s=e.getAttribute("slot");e.toggleAttribute("hidden",s!==t)}return i.html`<slot></slot>`}},be=new WeakMap,fe=new WeakMap,ve=new WeakMap,Ye);_e([o.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);_e([o.property({converter:{fromAttribute:a=>{if(!a)return null;try{return JSON.parse(a)}catch{return console.error("[singlebase] guard predicate is not valid JSON:",a),null}},toAttribute:a=>a?JSON.stringify(a):null}})],exports.SinglebaseAuthGuard.prototype,"predicate",1);_e([o.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=_e([o.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var os=Object.defineProperty,Ms=Object.getOwnPropertyDescriptor,Is=(a,n,t)=>n in a?os(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t,T=(a,n,t,e)=>{for(var s=e>1?void 0:e?Ms(n,t):n,r=a.length-1,d;r>=0;r--)(d=a[r])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&os(n,t,s),s},Rs=(a,n,t)=>Is(a,n+"",t);const Ds="profile_photo";var we,Se,ye,$e,Ee,ze;exports.SinglebaseAuthDisplay=(ze=class extends v{constructor(){super(...arguments);h(this,we,"");h(this,Se,"");h(this,ye,!1);h(this,$e,"");h(this,Ee,!1)}get path(){return l(this,we)}set path(t){c(this,we,t)}get fallback(){return l(this,Se)}set fallback(t){c(this,Se,t)}get avatar(){return l(this,ye)}set avatar(t){c(this,ye,t)}get alt(){return l(this,$e)}set alt(t){c(this,$e,t)}get imageFailed(){return l(this,Ee)}set imageFailed(t){c(this,Ee,t)}willUpdate(t){super.willUpdate(t),(t.has("path")||t.has("avatar"))&&(this.imageFailed=!1)}get profile(){const t=this.auth.state;return t.status==="authenticated"?t.user:null}get textValue(){const t=this.profile;if(!t||!this.path)return"";const e=A.getPath(t,this.path);return e==null||e===""?"":Array.isArray(e)?e.filter(s=>s!=null).join(", "):typeof e=="object"?"":String(e)}get avatarSrc(){const t=this.profile;if(!t)return"";const e=A.getPath(t,this.path||Ds);return typeof e=="string"?e:""}render(){if(this.auth.state.status==="loading")return i.nothing;if(this.avatar)return this.renderAvatar();const t=this.textValue;return t?i.html`<span part="text">${t}</span>`:this.fallback?i.html`<span part="text">${this.fallback}</span>`:i.nothing}renderAvatar(){const t=this.profile;if(!t)return i.nothing;const e=this.avatarSrc;return e&&!this.imageFailed?i.html`<img
|
|
913
|
+
part="avatar-image"
|
|
914
|
+
src=${e}
|
|
915
|
+
alt=${this.alt}
|
|
916
|
+
@error=${()=>this.imageFailed=!0}
|
|
917
|
+
/>`:i.html`<span
|
|
918
|
+
part="avatar-initials"
|
|
919
|
+
class="initials"
|
|
920
|
+
aria-hidden=${this.alt?"false":"true"}
|
|
921
|
+
>${Be(t)}</span
|
|
922
|
+
>`}},we=new WeakMap,Se=new WeakMap,ye=new WeakMap,$e=new WeakMap,Ee=new WeakMap,ze);Rs(exports.SinglebaseAuthDisplay,"styles",[...v.styles,i.css`
|
|
923
|
+
/* Text sits in a sentence; an avatar is a box the host sizes. */
|
|
924
|
+
:host {
|
|
925
|
+
display: inline;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
:host([avatar]) {
|
|
929
|
+
display: inline-block;
|
|
930
|
+
width: 42px;
|
|
931
|
+
height: 42px;
|
|
932
|
+
vertical-align: middle;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
img,
|
|
936
|
+
.initials {
|
|
937
|
+
display: block;
|
|
938
|
+
width: 100%;
|
|
939
|
+
height: 100%;
|
|
940
|
+
border-radius: inherit;
|
|
941
|
+
box-sizing: border-box;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
img {
|
|
945
|
+
object-fit: cover;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/* Matches the avatar in the account view. */
|
|
949
|
+
.initials {
|
|
950
|
+
display: flex;
|
|
951
|
+
align-items: center;
|
|
952
|
+
justify-content: center;
|
|
953
|
+
background: var(--sb-surface-alt, #fafafa);
|
|
954
|
+
border: 1px dashed var(--sb-border, #e4e6e9);
|
|
955
|
+
font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
956
|
+
font-size: 0.8em;
|
|
957
|
+
color: var(--sb-muted-ink, #61666c);
|
|
958
|
+
user-select: none;
|
|
959
|
+
}
|
|
960
|
+
`]);T([o.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);T([o.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);T([o.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);T([o.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);T([o.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=T([o.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=Ze;exports.SettingsController=Ae;exports.defaultMessages=xe;exports.fullNameOf=Fe;exports.initialsOf=Be;exports.isGuestScreen=Me;exports.isProtectedScreen=rs;exports.isScreen=Ie;exports.resolveMessages=Qe;
|
|
961
|
+
//# sourceMappingURL=authui-display-C2o9gApg.cjs.map
|