@singlebase/elements 0.5.0 → 0.6.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-BCZBP7HR.js → authui-display-CKfGK5va.js} +519 -503
- package/dist/authui-display-CKfGK5va.js.map +1 -0
- package/dist/{authui-display-CLGFSqRi.cjs → authui-display-aWNht0cW.cjs} +38 -58
- package/dist/authui-display-aWNht0cW.cjs.map +1 -0
- package/dist/authui.cjs +1 -1
- package/dist/authui.js +2 -2
- package/dist/chat-C-gsskho.cjs +3258 -0
- package/dist/chat-C-gsskho.cjs.map +1 -0
- package/dist/{chat-bXaRWel7.js → chat-CEh6RygY.js} +1957 -1137
- package/dist/chat-CEh6RygY.js.map +1 -0
- package/dist/chat-messages.d.ts +11 -5
- package/dist/chat.cjs +1 -1
- package/dist/chat.d.ts +4 -3
- package/dist/chat.js +8 -6
- package/dist/elements/authui-base.d.ts +2 -0
- package/dist/elements/authui-buttons.d.ts +1 -1
- package/dist/elements/authui-display.d.ts +1 -1
- package/dist/elements/authui.d.ts +5 -1
- package/dist/elements/chat.d.ts +153 -10
- package/dist/elements/uploader.d.ts +14 -0
- package/dist/{files-BOwtpYyQ.js → files-DDJWPzZW.js} +82 -35
- package/dist/files-DDJWPzZW.js.map +1 -0
- package/dist/files-DyxcjZsx.cjs +75 -0
- package/dist/files-DyxcjZsx.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +24 -22
- package/dist/singlebase-elements.min.js +3799 -2892
- package/dist/singlebase-elements.min.js.map +1 -1
- package/dist/styles/branding.d.ts +5 -0
- package/dist/styles/tokens.d.ts +2 -0
- package/dist/{uploader-DGV2y9uT.cjs → uploader-660JIgIN.cjs} +53 -76
- package/dist/uploader-660JIgIN.cjs.map +1 -0
- package/dist/{uploader-abQoem5q.js → uploader-vfczkX51.js} +294 -271
- package/dist/uploader-vfczkX51.js.map +1 -0
- package/dist/uploader.cjs +1 -1
- package/dist/uploader.js +2 -2
- package/dist/utils/branding.d.ts +8 -0
- package/dist/utils/markdown.d.ts +69 -12
- package/dist/utils/svg.d.ts +10 -0
- package/package.json +3 -3
- package/dist/authui-display-BCZBP7HR.js.map +0 -1
- package/dist/authui-display-CLGFSqRi.cjs.map +0 -1
- package/dist/chat-DRenTJlI.cjs +0 -3001
- package/dist/chat-DRenTJlI.cjs.map +0 -1
- package/dist/chat-bXaRWel7.js.map +0 -1
- package/dist/files-BOwtpYyQ.js.map +0 -1
- package/dist/files-DW8A4Jl-.cjs +0 -38
- package/dist/files-DW8A4Jl-.cjs.map +0 -1
- package/dist/uploader-DGV2y9uT.cjs.map +0 -1
- package/dist/uploader-abQoem5q.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Je=Object.defineProperty;var Oe=o=>{throw TypeError(o)};var Qe=(o,a,t)=>a in o?Je(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t;var p=(o,a,t)=>Qe(o,typeof a!="symbol"?a+"":a,t),xe=(o,a,t)=>a.has(o)||Oe("Cannot "+t);var l=(o,a,t)=>(xe(o,a,"read from private field"),t?t.call(o):a.get(o)),h=(o,a,t)=>a.has(o)?Oe("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(o):a.set(o,t),c=(o,a,t,e)=>(xe(o,a,"write to private field"),e?e.call(o,t):a.set(o,t),t);const i=require("lit"),r=require("lit/decorators.js"),E=require("lit/directives/if-defined.js"),y=require("@singlebase/singlebase-sdk"),Ie=require("./uploader-DGV2y9uT.cjs"),S=require("@singlebase/core"),Xe=require("./files-DW8A4Jl-.cjs");class Fe{constructor(a){p(this,"host");p(this,"client",null);p(this,"unsubscribe",null);p(this,"state",{status:"loading",session:null,user:null});this.host=a,a.addController(this)}bind(a){var t;a!==this.client&&((t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.client=a,a&&(this.state=a.getState(),this.unsubscribe=a.subscribe(e=>{this.state=e,this.host.requestUpdate()}),this.host.requestUpdate()))}hostDisconnected(){var a;(a=this.unsubscribe)==null||a.call(this),this.unsubscribe=null}}const ve={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:"Google, GitHub, and more",fullNameLabel:"Full name",fullNamePlaceholder:"Ada Lovelace",emailLabel:"Email",emailPlaceholder:"you@company.com",passwordLabel:"Password",passwordPlaceholder:"••••••••",newPasswordLabel:"New password",newPasswordPlaceholder:"At least 10 characters",confirmPasswordLabel:"Confirm password",confirmPasswordPlaceholder:"Repeat it",currentPasswordLabel:"Current password",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",oauthPrimaryLabel:"Continue with Google",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. Try again in 5 minutes or reset your password.",codeSentNeutral:"If an eligible account exists, a code has been sent.",invalidEmailError:"Enter a valid email address.",requiredError:"This cannot be empty.",passwordMinError:"Use at least 10 characters.",passwordMatchError:"Both passwords must match.",codeIncompleteError:"Enter all six digits.",invalidPhoneError:"Enter a valid phone number.",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",brandingLabel:"Auth by Singlebase",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."};function Be(o){return o?{...ve,...o}:ve}var Ze=Object.defineProperty,ts=Object.getOwnPropertyDescriptor,pe=(o,a,t,e)=>{for(var s=ts(a,t),n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=d(a,t,s)||s);return s&&Ze(a,t,s),s},P,A,k,_,O;class f extends i.LitElement{constructor(){super(...arguments);h(this,P,null);h(this,A,{});h(this,k);h(this,_);h(this,O);p(this,"auth",new Fe(this));p(this,"appliedConfig",new Set)}get client(){return l(this,P)}set client(t){c(this,P,t)}get messages(){return l(this,A)}set messages(t){c(this,A,t)}get theme(){return l(this,k)}set theme(t){c(this,k,t)}get density(){return l(this,_)}set density(t){c(this,_,t)}get fieldStyle(){return l(this,O)}set fieldStyle(t){c(this,O,t)}get resolvedClient(){var t;return this.client?this.client:((t=S.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 Be(t?{...t,...this.messages}:this.messages)}applyUIConfig(){const t=this.uiConfig;if(t){for(const e of S.AUTHUI_PROP_KEYS){const s=t[e];s!==void 0&&e in this&&(this.hasAttribute(S.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()}}P=new WeakMap,A=new WeakMap,k=new WeakMap,_=new WeakMap,O=new WeakMap,p(f,"styles",[Xe.tokenDefaults,Ie.sharedStyles]);pe([r.property({attribute:!1})],f.prototype,"client");pe([r.property({attribute:!1})],f.prototype,"messages");pe([r.property({reflect:!0})],f.prototype,"theme");pe([r.property({reflect:!0})],f.prototype,"density");pe([r.property({reflect:!0,attribute:"field-style"})],f.prototype,"fieldStyle");class be{constructor(a){p(this,"host");p(this,"client",null);p(this,"cache",new WeakMap);p(this,"settings",null);p(this,"error",null);this.host=a,a.addController(this)}hostConnected(){}load(a,t){if(t){this.settings=t;return}if(!a||a===this.client)return;this.client=a;let e=this.cache.get(a);e||(e=a.getSettings(),this.cache.set(a,e)),e.then(s=>{this.settings=s,this.error=null,this.host.requestUpdate()}).catch(s=>{this.error=s,this.host.requestUpdate()})}}const es=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],ss={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 Te(o){return"on"+o.replace(/(^|-)([a-z])/g,(a,t,e)=>e.toUpperCase())}class is{constructor(a){p(this,"unsubscribes",[]);p(this,"client",null);this.host=a,a.addController(this)}bind(a){a!==this.client&&(this.release(),this.client=a,a&&(this.unsubscribes=es.map(t=>a.on(t,e=>this.publish(t,e)))))}publish(a,t){const e=this.host[Te(a)];if(typeof e=="function")try{e.call(this.host,t)}catch(d){console.error(`[singlebase] ${Te(a)} threw:`,d)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${a}`,s));const n=ss[a];n&&this.host.dispatchEvent(new CustomEvent(n,s))}release(){this.unsubscribes.forEach(a=>a()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var ns=Object.defineProperty,as=Object.getOwnPropertyDescriptor,Se=(o,a,t,e)=>{for(var s=as(a,t),n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=d(a,t,s)||s);return s&&ns(a,t,s),s},x,T,U;class ge extends f{constructor(){super(...arguments);h(this,x,"idle");h(this,T,"");h(this,U,"");p(this,"abortController",null)}get phase(){return l(this,x)}set phase(t){c(this,x,t)}get formError(){return l(this,T)}set formError(t){c(this,T,t)}get noticeMessage(){return l(this,U)}set noticeMessage(t){c(this,U,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){if(t instanceof y.SinglebaseAuthError){const e=y.mapErrorToHint(t.code);return e==="disable_retry_show_rate_limited"?this.msg.rateLimitedMessage:e==="generic_credentials_message"?this.msg.genericErrorMessage:this.msg.genericErrorMessage}return this.msg.genericErrorMessage}get submitting(){return this.phase==="submitting"}renderStatus(){return i.html`
|
|
1
|
+
"use strict";var ts=Object.defineProperty;var Le=d=>{throw TypeError(d)};var es=(d,a,t)=>a in d?ts(d,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[a]=t;var p=(d,a,t)=>es(d,typeof a!="symbol"?a+"":a,t),Me=(d,a,t)=>a.has(d)||Le("Cannot "+t);var o=(d,a,t)=>(Me(d,a,"read from private field"),t?t.call(d):a.get(d)),l=(d,a,t)=>a.has(d)?Le("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(d):a.set(d,t),h=(d,a,t,e)=>(Me(d,a,"write to private field"),e?e.call(d,t):a.set(d,t),t);const i=require("lit"),r=require("lit/decorators.js"),E=require("lit/directives/if-defined.js"),y=require("@singlebase/singlebase-sdk"),je=require("./uploader-660JIgIN.cjs"),Ce=require("./files-DyxcjZsx.cjs"),S=require("@singlebase/core");class qe{constructor(a){p(this,"host");p(this,"client",null);p(this,"unsubscribe",null);p(this,"state",{status:"loading",session:null,user:null});this.host=a,a.addController(this)}bind(a){var t;a!==this.client&&((t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.client=a,a&&(this.state=a.getState(),this.unsubscribe=a.subscribe(e=>{this.state=e,this.host.requestUpdate()}),this.host.requestUpdate()))}hostDisconnected(){var a;(a=this.unsubscribe)==null||a.call(this),this.unsubscribe=null}}const Se={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:"Google, GitHub, and more",fullNameLabel:"Full name",fullNamePlaceholder:"Ada Lovelace",emailLabel:"Email",emailPlaceholder:"you@company.com",passwordLabel:"Password",passwordPlaceholder:"••••••••",newPasswordLabel:"New password",newPasswordPlaceholder:"At least 10 characters",confirmPasswordLabel:"Confirm password",confirmPasswordPlaceholder:"Repeat it",currentPasswordLabel:"Current password",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",oauthPrimaryLabel:"Continue with Google",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. Try again in 5 minutes or reset your password.",codeSentNeutral:"If an eligible account exists, a code has been sent.",invalidEmailError:"Enter a valid email address.",requiredError:"This cannot be empty.",passwordMinError:"Use at least 10 characters.",passwordMatchError:"Both passwords must match.",codeIncompleteError:"Enter all six digits.",invalidPhoneError:"Enter a valid phone number.",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",brandingLabel:"Auth by Singlebase",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."};function He(d){return d?{...Se,...d}:Se}var ss=Object.defineProperty,is=Object.getOwnPropertyDescriptor,C=(d,a,t,e)=>{for(var s=is(a,t),n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=c(a,t,s)||s);return s&&ss(a,t,s),s},A,k,_,O,T,x;class f extends i.LitElement{constructor(){super(...arguments);l(this,A,null);l(this,k,{});l(this,_);l(this,O);l(this,T);l(this,x);p(this,"auth",new qe(this));p(this,"appliedConfig",new Set)}get client(){return o(this,A)}set client(t){h(this,A,t)}get messages(){return o(this,k)}set messages(t){h(this,k,t)}get theme(){return o(this,_)}set theme(t){h(this,_,t)}get density(){return o(this,O)}set density(t){h(this,O,t)}get fieldStyle(){return o(this,T)}set fieldStyle(t){h(this,T,t)}get radius(){return o(this,x)}set radius(t){h(this,x,t)}get resolvedClient(){var t;return this.client?this.client:((t=S.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 He(t?{...t,...this.messages}:this.messages)}applyUIConfig(){const t=this.uiConfig;if(t){for(const e of S.AUTHUI_PROP_KEYS){const s=t[e];s!==void 0&&e in this&&(this.hasAttribute(S.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()}}A=new WeakMap,k=new WeakMap,_=new WeakMap,O=new WeakMap,T=new WeakMap,x=new WeakMap,p(f,"styles",[Ce.tokenDefaults,je.sharedStyles]);C([r.property({attribute:!1})],f.prototype,"client");C([r.property({attribute:!1})],f.prototype,"messages");C([r.property({reflect:!0})],f.prototype,"theme");C([r.property({reflect:!0})],f.prototype,"density");C([r.property({reflect:!0,attribute:"field-style"})],f.prototype,"fieldStyle");C([r.property({reflect:!0})],f.prototype,"radius");class we{constructor(a){p(this,"host");p(this,"client",null);p(this,"cache",new WeakMap);p(this,"settings",null);p(this,"error",null);this.host=a,a.addController(this)}hostConnected(){}load(a,t){if(t){this.settings=t;return}if(!a||a===this.client)return;this.client=a;let e=this.cache.get(a);e||(e=a.getSettings(),this.cache.set(a,e)),e.then(s=>{this.settings=s,this.error=null,this.host.requestUpdate()}).catch(s=>{this.error=s,this.host.requestUpdate()})}}const ns=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],as={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 Ne(d){return"on"+d.replace(/(^|-)([a-z])/g,(a,t,e)=>e.toUpperCase())}class rs{constructor(a){p(this,"unsubscribes",[]);p(this,"client",null);this.host=a,a.addController(this)}bind(a){a!==this.client&&(this.release(),this.client=a,a&&(this.unsubscribes=ns.map(t=>a.on(t,e=>this.publish(t,e)))))}publish(a,t){const e=this.host[Ne(a)];if(typeof e=="function")try{e.call(this.host,t)}catch(c){console.error(`[singlebase] ${Ne(a)} threw:`,c)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${a}`,s));const n=as[a];n&&this.host.dispatchEvent(new CustomEvent(n,s))}release(){this.unsubscribes.forEach(a=>a()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var os=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,Pe=(d,a,t,e)=>{for(var s=ls(a,t),n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=c(a,t,s)||s);return s&&os(a,t,s),s},U,L,M;class fe extends f{constructor(){super(...arguments);l(this,U,"idle");l(this,L,"");l(this,M,"");p(this,"abortController",null)}get phase(){return o(this,U)}set phase(t){h(this,U,t)}get formError(){return o(this,L)}set formError(t){h(this,L,t)}get noticeMessage(){return o(this,M)}set noticeMessage(t){h(this,M,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){if(t instanceof y.SinglebaseAuthError){const e=y.mapErrorToHint(t.code);return e==="disable_retry_show_rate_limited"?this.msg.rateLimitedMessage:e==="generic_credentials_message"?this.msg.genericErrorMessage:this.msg.genericErrorMessage}return this.msg.genericErrorMessage}get submitting(){return this.phase==="submitting"}renderStatus(){return i.html`
|
|
2
2
|
<div
|
|
3
3
|
role="status"
|
|
4
4
|
aria-live="polite"
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
</div>
|
|
10
10
|
${this.formError?i.html`<p class="banner" role="alert">${this.formError}</p>`:null}
|
|
11
11
|
${this.noticeMessage?i.html`<p class="notice" role="status">${this.noticeMessage}</p>`:null}
|
|
12
|
-
`}}
|
|
12
|
+
`}}U=new WeakMap,L=new WeakMap,M=new WeakMap;Pe([r.state()],fe.prototype,"phase");Pe([r.state()],fe.prototype,"formError");Pe([r.state()],fe.prototype,"noticeMessage");function Ae(d){return[d==null?void 0:d.first_name,d==null?void 0:d.last_name].filter(Boolean).join(" ").trim()}function ke(d){const a=Ae(d);if(a)return a.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();const t=(d==null?void 0:d.email)??"";return t?t[0].toUpperCase():"·"}var hs=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,g=(d,a,t,e)=>{for(var s=e>1?void 0:e?ds(a,t):a,n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=(e?c(a,t,s):c(s))||s);return e&&s&&hs(a,t,s),s};const cs={profile_photo:!0},us=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp";var N,D,I,F,B,R,j,q,H,G,V,K,Y,W,z,J,Q,X,Z,tt,et,st,it,nt,at,rt,De;exports.SinglebaseAccountScreen=(De=class extends fe{constructor(){super(...arguments);l(this,N,"");l(this,D,"");l(this,I,null);l(this,F,"singlebase-oauth-nonce");l(this,B,"");l(this,R,"");l(this,j,!1);l(this,q,"");l(this,H,"");l(this,G,"");l(this,V,"");l(this,K,"");l(this,Y,0);l(this,W,"");l(this,z,"");l(this,J,"");l(this,Q,"");l(this,X,"");l(this,Z,"request");l(this,tt,"");l(this,et,"");l(this,st,"");l(this,it,"");l(this,nt,"");l(this,at,"");l(this,rt,"");p(this,"settingsCtl",new we(this));p(this,"flashTimer");p(this,"uidBase",`sb-acct-${Math.random().toString(36).slice(2,8)}`);p(this,"uploadClientFor",null);p(this,"uploadClientCache",null);p(this,"onChoosePhoto",()=>{var t;this.formError="",(t=this.renderRoot.querySelector("singlebase-uploader"))==null||t.open()});p(this,"onPhotoSelected",()=>{this.photoBusy=!0,this.toast=""});p(this,"onPhotoUploaded",async t=>{var n;const{completed:e,failed:s}=t.detail;try{e.length?(await((n=this.resolvedClient)==null?void 0:n.getAccount()),this.photoFailed="",this.toast=this.msg.photoUpdated):s.length&&(this.formError=s[0].error||this.msg.genericErrorMessage)}catch(c){this.formError=this.describeError(c)}finally{this.photoBusy=!1}});p(this,"onPhotoProblem",t=>{this.photoBusy=!1,this.formError=t.detail.message})}get logoText(){return o(this,N)}set logoText(t){h(this,N,t)}get logoUrl(){return o(this,D)}set logoUrl(t){h(this,D,t)}get settings(){return o(this,I)}set settings(t){h(this,I,t)}get nonceStorageKey(){return o(this,F)}set nonceStorageKey(t){h(this,F,t)}get editMode(){return o(this,B)}set editMode(t){h(this,B,t)}get toast(){return o(this,R)}set toast(t){h(this,R,t)}get photoBusy(){return o(this,j)}set photoBusy(t){h(this,j,t)}get photoFailed(){return o(this,q)}set photoFailed(t){h(this,q,t)}get profileSaved(){return o(this,H)}set profileSaved(t){h(this,H,t)}get passSaved(){return o(this,G)}set passSaved(t){h(this,G,t)}get profileError(){return o(this,V)}set profileError(t){h(this,V,t)}get newPassError(){return o(this,K)}set newPassError(t){h(this,K,t)}get deleteStage(){return o(this,Y)}set deleteStage(t){h(this,Y,t)}get confirmText(){return o(this,W)}set confirmText(t){h(this,W,t)}get dFirst(){return o(this,z)}set dFirst(t){h(this,z,t)}get dLast(){return o(this,J)}set dLast(t){h(this,J,t)}get dPhone(){return o(this,Q)}set dPhone(t){h(this,Q,t)}get dEmail(){return o(this,X)}set dEmail(t){h(this,X,t)}get emailStep(){return o(this,Z)}set emailStep(t){h(this,Z,t)}get dNewEmail(){return o(this,tt)}set dNewEmail(t){h(this,tt,t)}get emailCode(){return o(this,et)}set emailCode(t){h(this,et,t)}get emailError(){return o(this,st)}set emailError(t){h(this,st,t)}get emailSaved(){return o(this,it)}set emailSaved(t){h(this,it,t)}get curPass(){return o(this,nt)}set curPass(t){h(this,nt,t)}get newPass(){return o(this,at)}set newPass(t){h(this,at,t)}get confirmPass(){return o(this,rt)}set confirmPass(t){h(this,rt,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
|
|
13
13
|
part="logo"
|
|
14
14
|
src=${this.logoUrl}
|
|
15
15
|
alt=${this.logoText}
|
|
16
16
|
style="display:block;align-self:flex-start;height:var(--sb-logo-height,20px);width:auto;max-width:100%"
|
|
17
|
-
/>`: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
|
|
17
|
+
/>`: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 Ae(this.user)}get initials(){return ke(this.user)}get uploadClient(){const t=this.resolvedClient;return t?(this.uploadClientFor!==t&&(this.uploadClientFor=t,this.uploadClientCache={files:y.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){if(!this.dFirst.trim()||!this.dLast.trim()){this.profileError="First and last name cannot be empty.";return}if(this.dPhone.replace(/\D/g,"").length<7){this.profileError=this.msg.invalidPhoneError;return}await this.run(async()=>{await t.updateAccount({first_name:this.dFirst,last_name:this.dLast,phone:this.dPhone},this.signal),this.editMode="",this.flash("profileSaved",this.msg.savedNote)})}}startPassEdit(){this.curPass="",this.newPass="",this.confirmPass="",this.newPassError="",this.passSaved="",this.profileSaved="",this.toast="",this.editMode="password"}async onChangePass(){const t=this.resolvedClient;if(t){if(!this.curPass){this.newPassError="Enter your current password.";return}if(this.newPass.length<10){this.newPassError=this.msg.passwordMinError;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.curPass="",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`
|
|
18
18
|
<div class="rule"></div>
|
|
19
19
|
<div class="section">
|
|
20
20
|
<h3 class="sec-title">${this.msg.changeEmailTitle}</h3>
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
</div>
|
|
111
111
|
`}
|
|
112
112
|
</div>
|
|
113
|
-
`}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 m;const n=await e.createOAuthNonce(this.signal);(m=globalThis.sessionStorage)==null||m.setItem(this.nonceStorageKey,n);const{oauth_redirect_url:
|
|
113
|
+
`}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 m;const n=await e.createOAuthNonce(this.signal);(m=globalThis.sessionStorage)==null||m.setItem(this.nonceStorageKey,n);const{oauth_redirect_url:c}=await e.startOAuth({provider:t,nonce:n,intent:"link",id_token:s.session.id_token,refresh_token:s.session.refresh_token},this.signal);globalThis.location.assign(c)})}get availableProviders(){const t=this.settings??this.settingsCtl.settings;if(!t||!t.oauth_settings.enabled)return[];const e={google:"G",github:"GH",linkedin:"in",facebook:"f"};return Object.entries(t.oauth_providers).filter(([,s])=>s.enabled).map(([s,n])=>({id:s,name:n.provider_name,mark:e[s]??n.provider_name.slice(0,2)}))}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`
|
|
114
114
|
<div class="acct-nav">
|
|
115
115
|
<div class="acct-who">
|
|
116
116
|
<div class="avatar-col">
|
|
@@ -136,9 +136,9 @@
|
|
|
136
136
|
view="button"
|
|
137
137
|
max-files="1"
|
|
138
138
|
branding="false"
|
|
139
|
-
accept=${
|
|
139
|
+
accept=${us}
|
|
140
140
|
.client=${this.uploadClient}
|
|
141
|
-
.options=${
|
|
141
|
+
.options=${cs}
|
|
142
142
|
@singlebase-upload-selected=${this.onPhotoSelected}
|
|
143
143
|
@singlebase-upload-complete=${this.onPhotoUploaded}
|
|
144
144
|
@singlebase-upload-error=${this.onPhotoProblem}
|
|
@@ -158,9 +158,9 @@
|
|
|
158
158
|
<div class="section">
|
|
159
159
|
${e?i.html`
|
|
160
160
|
<div class="sum-list">
|
|
161
|
-
${n.map(([
|
|
161
|
+
${n.map(([c,m])=>i.html`
|
|
162
162
|
<div class="sum-row">
|
|
163
|
-
<span class="sum-label">${
|
|
163
|
+
<span class="sum-label">${c}</span>
|
|
164
164
|
<span class="sum-value">${m}</span>
|
|
165
165
|
</div>
|
|
166
166
|
`)}
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
.value=${this.dFirst}
|
|
189
189
|
placeholder=${this.msg.firstNamePlaceholder}
|
|
190
190
|
?disabled=${this.submitting}
|
|
191
|
-
@input=${
|
|
191
|
+
@input=${c=>{this.dFirst=c.target.value,this.profileError=""}}
|
|
192
192
|
/>
|
|
193
193
|
</div>
|
|
194
194
|
<div class="field">
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
.value=${this.dLast}
|
|
201
201
|
placeholder=${this.msg.lastNamePlaceholder}
|
|
202
202
|
?disabled=${this.submitting}
|
|
203
|
-
@input=${
|
|
203
|
+
@input=${c=>{this.dLast=c.target.value,this.profileError=""}}
|
|
204
204
|
/>
|
|
205
205
|
</div>
|
|
206
206
|
</div>
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
.value=${this.dPhone}
|
|
214
214
|
placeholder=${this.msg.phonePlaceholder}
|
|
215
215
|
?disabled=${this.submitting}
|
|
216
|
-
@input=${
|
|
216
|
+
@input=${c=>{this.dPhone=c.target.value,this.profileError=""}}
|
|
217
217
|
/>
|
|
218
218
|
</div>
|
|
219
219
|
<div class="field">
|
|
@@ -404,7 +404,7 @@
|
|
|
404
404
|
${i.nothing}
|
|
405
405
|
</div>
|
|
406
406
|
</div>
|
|
407
|
-
`:i.html`<p class="disabled-note">Not signed in.</p>`}},
|
|
407
|
+
`:i.html`<p class="disabled-note">Not signed in.</p>`}},N=new WeakMap,D=new WeakMap,I=new WeakMap,F=new WeakMap,B=new WeakMap,R=new WeakMap,j=new WeakMap,q=new WeakMap,H=new WeakMap,G=new WeakMap,V=new WeakMap,K=new WeakMap,Y=new WeakMap,W=new WeakMap,z=new WeakMap,J=new WeakMap,Q=new WeakMap,X=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,st=new WeakMap,it=new WeakMap,nt=new WeakMap,at=new WeakMap,rt=new WeakMap,De);g([r.property({attribute:"logo-text"})],exports.SinglebaseAccountScreen.prototype,"logoText",1);g([r.property({attribute:"logo-url"})],exports.SinglebaseAccountScreen.prototype,"logoUrl",1);g([r.property({attribute:!1})],exports.SinglebaseAccountScreen.prototype,"settings",1);g([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAccountScreen.prototype,"nonceStorageKey",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"editMode",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"toast",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"photoBusy",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"photoFailed",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"profileSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"passSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"profileError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"newPassError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"deleteStage",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"confirmText",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dFirst",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dLast",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dPhone",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dEmail",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailStep",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dNewEmail",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailCode",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"curPass",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"newPass",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"confirmPass",1);exports.SinglebaseAccountScreen=g([r.customElement("singlebase-authui-account")],exports.SinglebaseAccountScreen);var ps=Object.defineProperty,gs=Object.getOwnPropertyDescriptor,w=(d,a,t,e)=>{for(var s=e>1?void 0:e?gs(a,t):a,n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=(e?c(a,t,s):c(s))||s);return e&&s&&ps(a,t,s),s},ot,lt,ht,dt,ct,ut,pt,Ie;exports.SinglebaseAuthButtons=(Ie=class extends fe{constructor(){super(...arguments);l(this,ot,"signout");l(this,lt,"signin");l(this,ht,"");l(this,dt,"");l(this,ct,!1);l(this,ut,null);l(this,pt,"singlebase-oauth-nonce");p(this,"settingsCtl",new we(this))}get type(){return o(this,ot)}set type(t){h(this,ot,t)}get intent(){return o(this,lt)}set intent(t){h(this,lt,t)}get provider(){return o(this,ht)}set provider(t){h(this,ht,t)}get providerName(){return o(this,dt)}set providerName(t){h(this,dt,t)}get embedded(){return o(this,ct)}set embedded(t){h(this,ct,t)}get settings(){return o(this,ut)}set settings(t){h(this,ut,t)}get nonceStorageKey(){return o(this,pt)}set nonceStorageKey(t){h(this,pt,t)}willUpdate(t){super.willUpdate(t),this.type==="oauth"&&this.settingsCtl.load(this.resolvedClient,this.settings)}get effectiveSettings(){return this.settings??this.settingsCtl.settings}get providers(){const t=this.effectiveSettings;if(!t||!t.oauth_settings.enabled)return[];if(!(this.intent==="signup"?t.oauth_settings.allow_signup:t.oauth_settings.allow_signin)&&this.intent!=="link")return[];const s={google:"G",github:"GH",linkedin:"in",facebook:"f"};return Object.entries(t.oauth_providers).filter(([,n])=>n.enabled).map(([n,c])=>({id:n,name:c.provider_name,mark:s[n]??c.provider_name.slice(0,2)}))}async startOAuth(t,e,s=!1){const n=this.resolvedClient;if(!n)return;let c,m;if(s){const b=this.auth.state;if(b.status!=="authenticated"){this.formError=this.msg.linkRequiresSignIn,this.phase="error";return}c=b.session.id_token,m=b.session.refresh_token}await this.run(async()=>{var ve;const b=await n.createOAuthNonce(this.signal);(ve=globalThis.sessionStorage)==null||ve.setItem(this.nonceStorageKey,b);const{oauth_redirect_url:v}=await n.startOAuth({provider:t,nonce:b,intent:e,...s?{id_token:c,refresh_token:m}:{}},this.signal);globalThis.location.assign(v)})}renderOAuth(){const t=this.providers;if(t.length===0)return i.nothing;const[e,...s]=t;return i.html`
|
|
408
408
|
<div class="stack">
|
|
409
409
|
${this.formError?i.html`<div class="banner" part="banner" role="alert">${this.formError}</div>`:i.nothing}
|
|
410
410
|
|
|
@@ -472,11 +472,7 @@
|
|
|
472
472
|
${this.msg.signOutCta}
|
|
473
473
|
</button>
|
|
474
474
|
</div>
|
|
475
|
-
`}render(){return this.type==="oauth"?this.renderOAuth():this.type==="link"?this.renderLink():this.renderSignOut()}},at=new WeakMap,rt=new WeakMap,ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,Le);w([r.property()],exports.SinglebaseAuthButtons.prototype,"type",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"intent",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"provider",1);w([r.property({attribute:"provider-name"})],exports.SinglebaseAuthButtons.prototype,"providerName",1);w([r.property({type:Boolean})],exports.SinglebaseAuthButtons.prototype,"embedded",1);w([r.property({attribute:!1})],exports.SinglebaseAuthButtons.prototype,"settings",1);w([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthButtons.prototype,"nonceStorageKey",1);exports.SinglebaseAuthButtons=w([r.customElement("singlebase-authui-buttons")],exports.SinglebaseAuthButtons);var Re=Object.defineProperty,us=Object.getOwnPropertyDescriptor,ps=(o,a,t)=>a in o?Re(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t,u=(o,a,t,e)=>{for(var s=e>1?void 0:e?us(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&Re(a,t,s),s},gs=(o,a,t)=>ps(o,a+"",t);const je=["signin","signup","forgot","verify","otp","newpass","invite"],qe=["account"],ms=[...je,...qe,"oauth-callback"];function we(o){return je.includes(o)}function Ge(o){return qe.includes(o)}function ye(o){return ms.includes(o)}const $={fromAttribute:o=>o===null?!0:o!=="false",toAttribute:o=>o?null:"false"};var ut,pt,gt,mt,bt,ft,vt,wt,yt,St,$t,Et,Ct,Pt,At,kt,_t,Ot,xt,Tt,Ut,Lt,Mt,Nt,Dt,It,Ft,Bt,Rt,jt,qt,Gt,Ht,Vt,Kt,Yt,Wt,zt,Jt,Qt,Xt,Zt,te,ee,se,ie,ne,Me;exports.SinglebaseAuthScreen=(Me=class extends f{constructor(){super(...arguments);h(this,ut,"signin");h(this,pt,"");h(this,gt,!1);h(this,mt,null);h(this,bt,!0);h(this,ft,!0);h(this,vt,!0);h(this,wt,!0);h(this,yt,!0);h(this,St,!0);h(this,$t,"card");h(this,Et,"bottom");h(this,Ct,!1);h(this,Pt,"");h(this,At,"");h(this,kt,"");h(this,_t,"");h(this,Ot,"");h(this,xt,!0);h(this,Tt,"");h(this,Ut,"");h(this,Lt,"");h(this,Mt,"singlebase-oauth-nonce");h(this,Nt,"");h(this,Dt,"");h(this,It,"");h(this,Ft,0);h(this,Bt,"");h(this,Rt,"");h(this,jt,"");h(this,qt,"");h(this,Gt,"");h(this,Ht,"");h(this,Vt,"");h(this,Kt,"");h(this,Yt,"");h(this,Wt,["","","","","",""]);h(this,zt,"signin_code");h(this,Jt,!1);h(this,Qt,"");h(this,Xt,"");h(this,Zt,"");h(this,te,"");h(this,ee,"");h(this,se,0);h(this,ie,!1);p(this,"settingsCtl",new be(this));p(this,"bridge",new is(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);h(this,ne,!1);p(this,"abortController",null);p(this,"onContinue",()=>{this.followRedirect()||(this.dispatchEvent(new CustomEvent("singlebase-continue",{detail:{user:this.getUser()},bubbles:!0,composed:!0})),this.goto("account"))});p(this,"onInterstitialSignOut",async()=>{var t;await((t=this.resolvedClient)==null?void 0:t.logout()),this.goto("signin")})}get initialScreen(){return l(this,ut)}set initialScreen(t){c(this,ut,t)}get screen(){return l(this,pt)}set screen(t){c(this,pt,t)}get noAccountView(){return l(this,gt)}set noAccountView(t){c(this,gt,t)}get settings(){return l(this,mt)}set settings(t){c(this,mt,t)}get authEnabled(){return l(this,bt)}set authEnabled(t){c(this,bt,t)}get allowEmailSignin(){return l(this,ft)}set allowEmailSignin(t){c(this,ft,t)}get allowEmailSignup(){return l(this,vt)}set allowEmailSignup(t){c(this,vt,t)}get allowEmailOtp(){return l(this,wt)}set allowEmailOtp(t){c(this,wt,t)}get allowOauth(){return l(this,yt)}set allowOauth(t){c(this,yt,t)}get allowAccountCreation(){return l(this,St)}set allowAccountCreation(t){c(this,St,t)}get layout(){return l(this,$t)}set layout(t){c(this,$t,t)}get oauthPlacement(){return l(this,Et)}set oauthPlacement(t){c(this,Et,t)}get stepped(){return l(this,Ct)}set stepped(t){c(this,Ct,t)}get logoText(){return l(this,Pt)}set logoText(t){c(this,Pt,t)}get logoUrl(){return l(this,At)}set logoUrl(t){c(this,At,t)}get brandLine(){return l(this,kt)}set brandLine(t){c(this,kt,t)}get brandFoot(){return l(this,_t)}set brandFoot(t){c(this,_t,t)}get signInTitle(){return l(this,Ot)}set signInTitle(t){c(this,Ot,t)}get branding(){return l(this,xt)}set branding(t){c(this,xt,t)}get redirectUrl(){return l(this,Tt)}set redirectUrl(t){c(this,Tt,t)}get tosUrl(){return l(this,Ut)}set tosUrl(t){c(this,Ut,t)}get privacyUrl(){return l(this,Lt)}set privacyUrl(t){c(this,Lt,t)}get nonceStorageKey(){return l(this,Mt)}set nonceStorageKey(t){c(this,Mt,t)}get inviteEmail(){return l(this,Nt)}set inviteEmail(t){c(this,Nt,t)}get inviteOrg(){return l(this,Dt)}set inviteOrg(t){c(this,Dt,t)}get inviteCode(){return l(this,It)}set inviteCode(t){c(this,It,t)}get step(){return l(this,Ft)}set step(t){c(this,Ft,t)}get method(){return l(this,Bt)}set method(t){c(this,Bt,t)}get email(){return l(this,Rt)}set email(t){c(this,Rt,t)}get password(){return l(this,jt)}set password(t){c(this,jt,t)}get name(){return l(this,qt)}set name(t){c(this,qt,t)}get firstName(){return l(this,Gt)}set firstName(t){c(this,Gt,t)}get lastName(){return l(this,Ht)}set lastName(t){c(this,Ht,t)}get phone(){return l(this,Vt)}set phone(t){c(this,Vt,t)}get newPass(){return l(this,Kt)}set newPass(t){c(this,Kt,t)}get confirmPass(){return l(this,Yt)}set confirmPass(t){c(this,Yt,t)}get code(){return l(this,Wt)}set code(t){c(this,Wt,t)}get verifyNext(){return l(this,zt)}set verifyNext(t){c(this,zt,t)}get loading(){return l(this,Jt)}set loading(t){c(this,Jt,t)}get banner(){return l(this,Qt)}set banner(t){c(this,Qt,t)}get notice(){return l(this,Xt)}set notice(t){c(this,Xt,t)}get emailError(){return l(this,Zt)}set emailError(t){c(this,Zt,t)}get passError(){return l(this,te)}set passError(t){c(this,te,t)}get newPassError(){return l(this,ee)}set newPassError(t){c(this,ee,t)}get attempts(){return l(this,se)}set attempts(t){c(this,se,t)}get needsMfaCode(){return l(this,ie)}set needsMfaCode(t){c(this,ie,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 n;if(t===this.gotoClient||((n=this.gotoUnsubscribe)==null||n.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=t,!t))return;const e=t.on("goto",({screen:d})=>{ye(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,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:t.oauth_settings.enabled&&this.allowOauth,mfa:s}}get requestedScreen(){const t=this.screen||this.initialScreen||"signin";return ye(t)?t:"signin"}get activeScreen(){if(this.isOAuthCallback)return"oauth-callback";const t=this.auth.state.status==="authenticated",e=this.requestedScreen;if(Ge(e))return t?e:"signin";if(t)return this.screen!==""||this.initialScreen!=="signin"?e:"account";const s=this.cfg;let n=e;return n==="signup"&&!s.allowEmailSignup&&(n="signin"),(n==="forgot"||n==="newpass")&&!s.allowEmailSignin&&(n="signin"),n==="otp"&&!s.allowEmailOtp&&(n="signin"),n==="signin"&&!s.allowEmailSignin&&s.allowEmailOtp&&(n="otp"),n}get showsSignedInInterstitial(){return this.auth.state.status==="authenticated"&&we(this.activeScreen)}get redirectTarget(){var t;return Ie.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.has("error")}get callbackDone(){return l(this,ne)}set callbackDone(t){c(this,ne,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("error"),globalThis.history.replaceState({},"",e.toString())}async handleOAuthCallback(){var m,b;if(this.callbackDone)return;this.callbackDone=!0;const t=new URLSearchParams(((m=globalThis.location)==null?void 0:m.search)??""),e=t.get("access_code"),s=t.get("error"),n=this.resolvedClient;if(s){this.cleanCallbackUrl(),this.banner=this.msg.oauthDenied;return}if(!e||!n)return;const d=(b=globalThis.sessionStorage)==null?void 0:b.getItem(this.nonceStorageKey);if(this.cleanCallbackUrl(),!d){this.banner=this.msg.genericErrorMessage;return}await this.withLoading(async()=>{var v;await n.completeOAuth({access_code:e,nonce:d},this.signal()),(v=globalThis.sessionStorage)==null||v.removeItem(this.nonceStorageKey)})}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 this.branding?i.html`<div class="branding" part="branding">
|
|
476
|
-
<a href="https://singlebase.cloud" target="_blank" rel="noopener noreferrer"
|
|
477
|
-
>${this.msg.brandingLabel}</a
|
|
478
|
-
>
|
|
479
|
-
</div>`:i.nothing}panel(t){return i.html`<div class="panel">${t}${this.renderBranding()}</div>`}renderOAuthCallback(){return i.html`
|
|
475
|
+
`}render(){return this.type==="oauth"?this.renderOAuth():this.type==="link"?this.renderLink():this.renderSignOut()}},ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,pt=new WeakMap,Ie);w([r.property()],exports.SinglebaseAuthButtons.prototype,"type",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"intent",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"provider",1);w([r.property({attribute:"provider-name"})],exports.SinglebaseAuthButtons.prototype,"providerName",1);w([r.property({type:Boolean})],exports.SinglebaseAuthButtons.prototype,"embedded",1);w([r.property({attribute:!1})],exports.SinglebaseAuthButtons.prototype,"settings",1);w([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthButtons.prototype,"nonceStorageKey",1);exports.SinglebaseAuthButtons=w([r.customElement("singlebase-authui-buttons")],exports.SinglebaseAuthButtons);var Ge=Object.defineProperty,ms=Object.getOwnPropertyDescriptor,bs=(d,a,t)=>a in d?Ge(d,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[a]=t,u=(d,a,t,e)=>{for(var s=e>1?void 0:e?ms(a,t):a,n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=(e?c(a,t,s):c(s))||s);return e&&s&&Ge(a,t,s),s},fs=(d,a,t)=>bs(d,a+"",t);const Ve=["signin","signup","forgot","verify","otp","newpass","invite"],Ke=["account"],vs=[...Ve,...Ke,"oauth-callback"];function $e(d){return Ve.includes(d)}function Ye(d){return Ke.includes(d)}function Ee(d){return vs.includes(d)}const $={fromAttribute:d=>d===null?!0:d!=="false",toAttribute:d=>d?null:"false"};var gt,mt,bt,ft,vt,wt,yt,St,$t,Et,Ct,Pt,At,kt,_t,Ot,Tt,xt,Ut,Lt,Mt,Nt,Dt,It,Ft,Bt,Rt,jt,qt,Ht,Gt,Vt,Kt,Yt,Wt,zt,Jt,Qt,Xt,Zt,te,ee,se,ie,ne,ae,re,oe,le,Fe;exports.SinglebaseAuthScreen=(Fe=class extends f{constructor(){super(...arguments);l(this,gt,"signin");l(this,mt,"");l(this,bt,!1);l(this,ft,null);l(this,vt,!0);l(this,wt,!0);l(this,yt,!0);l(this,St,!0);l(this,$t,!0);l(this,Et,!0);l(this,Ct,"card");l(this,Pt,"bottom");l(this,At,!1);l(this,kt,"");l(this,_t,"");l(this,Ot,"");l(this,Tt,"");l(this,xt,"");l(this,Ut,!0);l(this,Lt,"");l(this,Mt,"");l(this,Nt,"");l(this,Dt,"");l(this,It,"");l(this,Ft,"singlebase-oauth-nonce");l(this,Bt,"");l(this,Rt,"");l(this,jt,"");l(this,qt,0);l(this,Ht,"");l(this,Gt,"");l(this,Vt,"");l(this,Kt,"");l(this,Yt,"");l(this,Wt,"");l(this,zt,"");l(this,Jt,"");l(this,Qt,"");l(this,Xt,["","","","","",""]);l(this,Zt,"signin_code");l(this,te,!1);l(this,ee,"");l(this,se,"");l(this,ie,"");l(this,ne,"");l(this,ae,"");l(this,re,0);l(this,oe,!1);p(this,"settingsCtl",new we(this));p(this,"bridge",new rs(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);l(this,le,!1);p(this,"abortController",null);p(this,"onContinue",()=>{this.followRedirect()||(this.dispatchEvent(new CustomEvent("singlebase-continue",{detail:{user:this.getUser()},bubbles:!0,composed:!0})),this.goto("account"))});p(this,"onInterstitialSignOut",async()=>{var t;await((t=this.resolvedClient)==null?void 0:t.logout()),this.goto("signin")})}get initialScreen(){return o(this,gt)}set initialScreen(t){h(this,gt,t)}get screen(){return o(this,mt)}set screen(t){h(this,mt,t)}get noAccountView(){return o(this,bt)}set noAccountView(t){h(this,bt,t)}get settings(){return o(this,ft)}set settings(t){h(this,ft,t)}get authEnabled(){return o(this,vt)}set authEnabled(t){h(this,vt,t)}get allowEmailSignin(){return o(this,wt)}set allowEmailSignin(t){h(this,wt,t)}get allowEmailSignup(){return o(this,yt)}set allowEmailSignup(t){h(this,yt,t)}get allowEmailOtp(){return o(this,St)}set allowEmailOtp(t){h(this,St,t)}get allowOauth(){return o(this,$t)}set allowOauth(t){h(this,$t,t)}get allowAccountCreation(){return o(this,Et)}set allowAccountCreation(t){h(this,Et,t)}get layout(){return o(this,Ct)}set layout(t){h(this,Ct,t)}get oauthPlacement(){return o(this,Pt)}set oauthPlacement(t){h(this,Pt,t)}get stepped(){return o(this,At)}set stepped(t){h(this,At,t)}get logoText(){return o(this,kt)}set logoText(t){h(this,kt,t)}get logoUrl(){return o(this,_t)}set logoUrl(t){h(this,_t,t)}get brandLine(){return o(this,Ot)}set brandLine(t){h(this,Ot,t)}get brandFoot(){return o(this,Tt)}set brandFoot(t){h(this,Tt,t)}get signInTitle(){return o(this,xt)}set signInTitle(t){h(this,xt,t)}get branding(){return o(this,Ut)}set branding(t){h(this,Ut,t)}get brandingText(){return o(this,Lt)}set brandingText(t){h(this,Lt,t)}get brandingUrl(){return o(this,Mt)}set brandingUrl(t){h(this,Mt,t)}get redirectUrl(){return o(this,Nt)}set redirectUrl(t){h(this,Nt,t)}get tosUrl(){return o(this,Dt)}set tosUrl(t){h(this,Dt,t)}get privacyUrl(){return o(this,It)}set privacyUrl(t){h(this,It,t)}get nonceStorageKey(){return o(this,Ft)}set nonceStorageKey(t){h(this,Ft,t)}get inviteEmail(){return o(this,Bt)}set inviteEmail(t){h(this,Bt,t)}get inviteOrg(){return o(this,Rt)}set inviteOrg(t){h(this,Rt,t)}get inviteCode(){return o(this,jt)}set inviteCode(t){h(this,jt,t)}get step(){return o(this,qt)}set step(t){h(this,qt,t)}get method(){return o(this,Ht)}set method(t){h(this,Ht,t)}get email(){return o(this,Gt)}set email(t){h(this,Gt,t)}get password(){return o(this,Vt)}set password(t){h(this,Vt,t)}get name(){return o(this,Kt)}set name(t){h(this,Kt,t)}get firstName(){return o(this,Yt)}set firstName(t){h(this,Yt,t)}get lastName(){return o(this,Wt)}set lastName(t){h(this,Wt,t)}get phone(){return o(this,zt)}set phone(t){h(this,zt,t)}get newPass(){return o(this,Jt)}set newPass(t){h(this,Jt,t)}get confirmPass(){return o(this,Qt)}set confirmPass(t){h(this,Qt,t)}get code(){return o(this,Xt)}set code(t){h(this,Xt,t)}get verifyNext(){return o(this,Zt)}set verifyNext(t){h(this,Zt,t)}get loading(){return o(this,te)}set loading(t){h(this,te,t)}get banner(){return o(this,ee)}set banner(t){h(this,ee,t)}get notice(){return o(this,se)}set notice(t){h(this,se,t)}get emailError(){return o(this,ie)}set emailError(t){h(this,ie,t)}get passError(){return o(this,ne)}set passError(t){h(this,ne,t)}get newPassError(){return o(this,ae)}set newPassError(t){h(this,ae,t)}get attempts(){return o(this,re)}set attempts(t){h(this,re,t)}get needsMfaCode(){return o(this,oe)}set needsMfaCode(t){h(this,oe,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 n;if(t===this.gotoClient||((n=this.gotoUnsubscribe)==null||n.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=t,!t))return;const e=t.on("goto",({screen:c})=>{Ee(c)&&this.goto(c)}),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,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:t.oauth_settings.enabled&&this.allowOauth,mfa:s}}get requestedScreen(){const t=this.screen||this.initialScreen||"signin";return Ee(t)?t:"signin"}get activeScreen(){if(this.isOAuthCallback)return"oauth-callback";const t=this.auth.state.status==="authenticated",e=this.requestedScreen;if(Ye(e))return t?e:"signin";if(t)return this.screen!==""||this.initialScreen!=="signin"?e:"account";const s=this.cfg;let n=e;return n==="signup"&&!s.allowEmailSignup&&(n="signin"),(n==="forgot"||n==="newpass")&&!s.allowEmailSignin&&(n="signin"),n==="otp"&&!s.allowEmailOtp&&(n="signin"),n==="signin"&&!s.allowEmailSignin&&s.allowEmailOtp&&(n="otp"),n}get showsSignedInInterstitial(){return this.auth.state.status==="authenticated"&&$e(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.has("error")}get callbackDone(){return o(this,le)}set callbackDone(t){h(this,le,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("error"),globalThis.history.replaceState({},"",e.toString())}async handleOAuthCallback(){var m,b;if(this.callbackDone)return;this.callbackDone=!0;const t=new URLSearchParams(((m=globalThis.location)==null?void 0:m.search)??""),e=t.get("access_code"),s=t.get("error"),n=this.resolvedClient;if(s){this.cleanCallbackUrl(),this.banner=this.msg.oauthDenied;return}if(!e||!n)return;const c=(b=globalThis.sessionStorage)==null?void 0:b.getItem(this.nonceStorageKey);if(this.cleanCallbackUrl(),!c){this.banner=this.msg.genericErrorMessage;return}await this.withLoading(async()=>{var v;await n.completeOAuth({access_code:e,nonce:c},this.signal()),(v=globalThis.sessionStorage)==null||v.removeItem(this.nonceStorageKey)})}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 Ce.renderBranding(this.branding,this.brandingText,this.msg.brandingLabel,this.brandingUrl)}panel(t){return i.html`<div class="panel">${t}${this.renderBranding()}</div>`}renderOAuthCallback(){return i.html`
|
|
480
476
|
<div class="stack">
|
|
481
477
|
<div class="head">
|
|
482
478
|
${this.renderLogo()}
|
|
@@ -490,7 +486,7 @@
|
|
|
490
486
|
<span>${this.msg.backCta}</span>
|
|
491
487
|
</button>`:i.nothing}
|
|
492
488
|
</div>
|
|
493
|
-
`}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){if(t instanceof y.SinglebaseAuthError){if(t.code==="AUTH_RATE_LIMITED")return this.msg.rateLimitedMessage;if(t.code==="INVALID_TOKEN")return"That code is not valid. Check it and try again."}return this.msg.genericErrorMessage}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 n=s==="forgot"?"password_reset":"signin";await this.withLoading(async()=>{await e.requestCode({email:this.email,purpose:n},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"){if(this.newPass.length<10){this.newPassError=this.msg.passwordMinError;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"){if(!this.firstName.trim()||!this.lastName.trim()){this.banner="Enter your first and last name.";return}if(this.phone.replace(/\D/g,"").length<7){this.banner=this.msg.invalidPhoneError;return}if(this.password.length<10){this.passError=this.msg.passwordMinError;return}const n=this.inviteCode||this.codeValue;if(n.length<6){this.banner=this.msg.codeIncompleteError;return}await this.withLoading(async()=>{await e.acceptInvite({email:this.inviteEmail,grant_type:"code",purpose:"invite",code:n,password:this.password,phone:this.phone},this.signal())});return}if(this.stepped&&(s==="signup"&&this.step<2||s==="signin"&&this.step<1)){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}this.step+=1;return}if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(s==="signup"){if(this.password.length<8){this.passError="Password must be at least 8 characters.";return}const[n,...
|
|
489
|
+
`}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){if(t instanceof y.SinglebaseAuthError){if(t.code==="AUTH_RATE_LIMITED")return this.msg.rateLimitedMessage;if(t.code==="INVALID_TOKEN")return"That code is not valid. Check it and try again."}return this.msg.genericErrorMessage}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 n=s==="forgot"?"password_reset":"signin";await this.withLoading(async()=>{await e.requestCode({email:this.email,purpose:n},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"){if(this.newPass.length<10){this.newPassError=this.msg.passwordMinError;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"){if(!this.firstName.trim()||!this.lastName.trim()){this.banner="Enter your first and last name.";return}if(this.phone.replace(/\D/g,"").length<7){this.banner=this.msg.invalidPhoneError;return}if(this.password.length<10){this.passError=this.msg.passwordMinError;return}const n=this.inviteCode||this.codeValue;if(n.length<6){this.banner=this.msg.codeIncompleteError;return}await this.withLoading(async()=>{await e.acceptInvite({email:this.inviteEmail,grant_type:"code",purpose:"invite",code:n,password:this.password,phone:this.phone},this.signal())});return}if(this.stepped&&(s==="signup"&&this.step<2||s==="signin"&&this.step<1)){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}this.step+=1;return}if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(s==="signup"){if(this.password.length<8){this.passError="Password must be at least 8 characters.";return}const[n,...c]=this.name.trim().split(/\s+/);await this.withLoading(async()=>{const m=await e.signUp({email:this.email,password:this.password,first_name:n||this.name,last_name:c.join(" ")||"—"},this.signal()),b=y.resolveScreen({next_action:m.next_action,next_operation:m.next_operation});this.setScreen("signin",{notice:"Account created. Sign in to continue.",step:0,password:"",needsMfaCode:b==="signin_with_code"})});return}if(this.password.length<8){this.attempts+=1,this.passError="Password must be at least 8 characters.",this.banner=this.attempts>=3?this.msg.rateLimitedMessage:"";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(n){if(n instanceof y.SinglebaseAuthError&&n.code==="CODE_REQUIRED"){this.needsMfaCode=!0,await e.requestCode({email:this.email,purpose:"signin"},this.signal()),this.notice=this.msg.codeSentNeutral;return}if(n instanceof y.SinglebaseAuthError&&n.code==="INVALID_CREDENTIALS"){this.attempts+=1,this.banner=this.attempts>=3?this.msg.rateLimitedMessage:"That email and password do not match.";return}throw n}})}signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}onCodeInput(t,e){var b;const n=e.target.value.replace(/\D/g,"");if(n.length>1){this.fillCode(t,n);return}const c=n.slice(-1),m=this.code.slice();m[t]=c,this.code=m,this.banner="",c&&((b=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[t+1])==null||b.focus())}onCodePaste(t,e){var n;const s=(((n=e.clipboardData)==null?void 0:n.getData("text"))??"").replace(/\D/g,"");s&&(e.preventDefault(),this.fillCode(t,s))}fillCode(t,e){const s=this.code.slice();for(let c=0;c<e.length&&t+c<s.length;c+=1)s[t+c]=e[c];this.code=s,this.banner="";const n=Math.min(t+e.length,s.length-1);this.updateComplete.then(()=>{var m;(m=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[n])==null||m.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="New code sent.",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`
|
|
494
490
|
<button type="submit" class="primary" part="button-primary" ?disabled=${this.loading}>
|
|
495
491
|
${this.loading?i.html`<span class="spinner" part="spinner"></span>`:i.nothing}
|
|
496
492
|
<span>${t}</span>
|
|
@@ -551,7 +547,7 @@
|
|
|
551
547
|
/>
|
|
552
548
|
`)}
|
|
553
549
|
</div>
|
|
554
|
-
`}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,n=t==="signup"&&(!s||this.step===0),
|
|
550
|
+
`}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,n=t==="signup"&&(!s||this.step===0),c=t==="signup"&&(!s||this.step===1)||t==="signin"&&(!s||this.step===0)||t==="otp",m=t==="signup"&&(!s||this.step===2)||t==="signin"&&(!s||this.step===1),b=t==="signin"&&e.allowEmailSignin&&e.allowEmailOtp&&(!s||this.step===0);return i.html`
|
|
555
551
|
${n?i.html`
|
|
556
552
|
<div class="field">
|
|
557
553
|
<label for=${this.uid("name")}>${this.msg.fullNameLabel}</label>
|
|
@@ -566,7 +562,7 @@
|
|
|
566
562
|
/>
|
|
567
563
|
</div>
|
|
568
564
|
`:i.nothing}
|
|
569
|
-
${
|
|
565
|
+
${c?this.renderEmailField(this.uid("email")):i.nothing}
|
|
570
566
|
${m?this.renderPasswordField(this.uid("pass"),e.allowEmailSignin&&t==="signin"):i.nothing}
|
|
571
567
|
${this.needsMfaCode&&t==="signin"?i.html`
|
|
572
568
|
<div class="field">
|
|
@@ -582,28 +578,28 @@
|
|
|
582
578
|
>
|
|
583
579
|
${this.msg.otpInsteadLink}
|
|
584
580
|
</button>`:i.nothing}
|
|
585
|
-
`}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,n=e.allowOauth;if(!s&&!n)return i.nothing;const
|
|
586
|
-
<div class="acc-item ${
|
|
587
|
-
${
|
|
581
|
+
`}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,n=e.allowOauth;if(!s&&!n)return i.nothing;const c=s&&n,m=s?n&&this.method||"email":"oauth",b=m==="email",v=m==="oauth",ve=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,ze=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,_e=(xe,Je,Qe,Xe,Ze,Ue)=>i.html`
|
|
582
|
+
<div class="acc-item ${xe?"open":""} ${c?"":"bare"}" part="acc-item">
|
|
583
|
+
${c?i.html`
|
|
588
584
|
<button
|
|
589
585
|
type="button"
|
|
590
586
|
class="acc-head"
|
|
591
|
-
aria-expanded=${
|
|
592
|
-
aria-controls=${this.uid(`acc-${
|
|
593
|
-
@click=${
|
|
587
|
+
aria-expanded=${xe?"true":"false"}
|
|
588
|
+
aria-controls=${this.uid(`acc-${Ue}`)}
|
|
589
|
+
@click=${Ze}
|
|
594
590
|
>
|
|
595
591
|
<span class="chev" aria-hidden="true">›</span>
|
|
596
|
-
<span class="acc-title">${
|
|
597
|
-
<span class="acc-meta">${
|
|
592
|
+
<span class="acc-title">${Je}</span>
|
|
593
|
+
<span class="acc-meta">${Qe}</span>
|
|
598
594
|
</button>
|
|
599
595
|
`:i.nothing}
|
|
600
|
-
<div class="acc-body" id=${this.uid(`acc-${
|
|
596
|
+
<div class="acc-body" id=${this.uid(`acc-${Ue}`)}>
|
|
601
597
|
<div class="acc-clip">
|
|
602
|
-
<div class="acc-inner">${
|
|
598
|
+
<div class="acc-inner">${Xe}</div>
|
|
603
599
|
</div>
|
|
604
600
|
</div>
|
|
605
601
|
</div>
|
|
606
|
-
`,
|
|
602
|
+
`,Oe=s?_e(b,ve,ze,this.renderEmailMethodBody(t),()=>this.method=b?"":"email","email"):i.nothing,Te=n?_e(v,this.msg.oauthMethodTitle,this.msg.oauthMethodMeta,i.html`<singlebase-authui-buttons
|
|
607
603
|
type="oauth"
|
|
608
604
|
embedded
|
|
609
605
|
theme=${E.ifDefined(this.theme)}
|
|
@@ -615,7 +611,7 @@
|
|
|
615
611
|
intent=${t==="signup"?"signup":"signin"}
|
|
616
612
|
></singlebase-authui-buttons>`,()=>this.method=v?"":"oauth","oauth"):i.nothing;return i.html`
|
|
617
613
|
<div class="acc-wrap">
|
|
618
|
-
${this.oauthPlacement==="top"?i.html`${
|
|
614
|
+
${this.oauthPlacement==="top"?i.html`${Te}${Oe}`:i.html`${Oe}${Te}`}
|
|
619
615
|
</div>
|
|
620
616
|
`}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`
|
|
621
617
|
${this.renderCodeRow()}
|
|
@@ -718,7 +714,7 @@
|
|
|
718
714
|
${this.passError?i.html`<p class="err">${this.passError}</p>`:i.nothing}
|
|
719
715
|
</div>
|
|
720
716
|
</div>
|
|
721
|
-
`:i.nothing}renderGuest(t){const e=this.cfg,s=["forgot","verify","newpass","invite"].indexOf(t)>=0,n=this.stepped&&this.step>0||["forgot","verify","otp","newpass"].indexOf(t)>=0,
|
|
717
|
+
`:i.nothing}renderGuest(t){const e=this.cfg,s=["forgot","verify","newpass","invite"].indexOf(t)>=0,n=this.stepped&&this.step>0||["forgot","verify","otp","newpass"].indexOf(t)>=0,c=t==="signin"&&e.allowEmailSignup||t==="signup"&&e.allowEmailSignin,m=this.stepped&&(t==="signin"||t==="signup");return i.html`
|
|
722
718
|
<form class="stack" @submit=${this.onSubmit} novalidate>
|
|
723
719
|
<div class="head">
|
|
724
720
|
${this.layout!=="split"?this.renderLogo():i.nothing}
|
|
@@ -740,7 +736,7 @@
|
|
|
740
736
|
</button>`:i.nothing}
|
|
741
737
|
</div>
|
|
742
738
|
`:i.nothing}
|
|
743
|
-
${
|
|
739
|
+
${c?i.html`
|
|
744
740
|
<p class="foot">
|
|
745
741
|
<span
|
|
746
742
|
>${t==="signup"?this.msg.footTextSignUp:this.msg.footTextSignIn}</span
|
|
@@ -813,7 +809,7 @@
|
|
|
813
809
|
logo-text=${this.logoText}
|
|
814
810
|
logo-url=${this.logoUrl}
|
|
815
811
|
></singlebase-authui-account>
|
|
816
|
-
`);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,n=!e.authEnabled||s
|
|
812
|
+
`);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,n=!e.authEnabled||s&&$e(t);return i.html`
|
|
817
813
|
${this.layout==="split"?i.html`
|
|
818
814
|
<div class="brand-panel">
|
|
819
815
|
${this.renderBrandMark()}
|
|
@@ -822,7 +818,7 @@
|
|
|
822
818
|
</div>
|
|
823
819
|
`:i.nothing}
|
|
824
820
|
${this.panel(n?this.renderBlocked():this.renderGuest(t))}
|
|
825
|
-
`}},
|
|
821
|
+
`}},gt=new WeakMap,mt=new WeakMap,bt=new WeakMap,ft=new WeakMap,vt=new WeakMap,wt=new WeakMap,yt=new WeakMap,St=new WeakMap,$t=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,At=new WeakMap,kt=new WeakMap,_t=new WeakMap,Ot=new WeakMap,Tt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Lt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap,Dt=new WeakMap,It=new WeakMap,Ft=new WeakMap,Bt=new WeakMap,Rt=new WeakMap,jt=new WeakMap,qt=new WeakMap,Ht=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=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,Fe);fs(exports.SinglebaseAuthScreen,"styles",[...f.styles,Ce.brandingStyles,i.css`
|
|
826
822
|
/* the mock's root */
|
|
827
823
|
:host {
|
|
828
824
|
display: flex;
|
|
@@ -831,7 +827,7 @@
|
|
|
831
827
|
background: var(--sb-surface, #ffffff);
|
|
832
828
|
color: var(--sb-ink, #16181a);
|
|
833
829
|
border: 1px solid var(--sb-border, #e4e6e9);
|
|
834
|
-
border-radius: calc(var(--sb-radius, 4px) + 4px);
|
|
830
|
+
border-radius: calc((var(--sb-radius, 4px) + 4px) * var(--sb-radius-scale, 1));
|
|
835
831
|
overflow: hidden;
|
|
836
832
|
}
|
|
837
833
|
|
|
@@ -889,22 +885,6 @@
|
|
|
889
885
|
|
|
890
886
|
.branding {
|
|
891
887
|
margin-top: 18px;
|
|
892
|
-
text-align: center;
|
|
893
|
-
font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
894
|
-
font-size: 10.5px;
|
|
895
|
-
letter-spacing: 0.06em;
|
|
896
|
-
color: var(--sb-muted-ink, #61666c);
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
.branding a {
|
|
900
|
-
color: inherit;
|
|
901
|
-
text-decoration: none;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
.branding a:hover {
|
|
905
|
-
color: var(--sb-ink, #16181a);
|
|
906
|
-
text-decoration: underline;
|
|
907
|
-
text-underline-offset: 3px;
|
|
908
888
|
}
|
|
909
889
|
|
|
910
890
|
/* the mock's panel */
|
|
@@ -924,7 +904,7 @@
|
|
|
924
904
|
border-bottom: 1px solid var(--sb-border, #e4e6e9);
|
|
925
905
|
}
|
|
926
906
|
}
|
|
927
|
-
`]);u([r.property({attribute:"initial-screen"})],exports.SinglebaseAuthScreen.prototype,"initialScreen",1);u([r.property({reflect:!0})],exports.SinglebaseAuthScreen.prototype,"screen",1);u([r.property({type:Boolean,attribute:"no-account-view"})],exports.SinglebaseAuthScreen.prototype,"noAccountView",1);u([r.property({attribute:!1})],exports.SinglebaseAuthScreen.prototype,"settings",1);u([r.property({converter:$,attribute:"auth-enabled"})],exports.SinglebaseAuthScreen.prototype,"authEnabled",1);u([r.property({converter:$,attribute:"allow-email-signin"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignin",1);u([r.property({converter:$,attribute:"allow-email-signup"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignup",1);u([r.property({converter:$,attribute:"allow-email-otp"})],exports.SinglebaseAuthScreen.prototype,"allowEmailOtp",1);u([r.property({converter:$,attribute:"allow-oauth"})],exports.SinglebaseAuthScreen.prototype,"allowOauth",1);u([r.property({converter:$,attribute:"allow-account-creation"})],exports.SinglebaseAuthScreen.prototype,"allowAccountCreation",1);u([r.property()],exports.SinglebaseAuthScreen.prototype,"layout",1);u([r.property({attribute:"oauth-placement"})],exports.SinglebaseAuthScreen.prototype,"oauthPlacement",1);u([r.property({type:Boolean})],exports.SinglebaseAuthScreen.prototype,"stepped",1);u([r.property({attribute:"logo-text"})],exports.SinglebaseAuthScreen.prototype,"logoText",1);u([r.property({attribute:"logo-url"})],exports.SinglebaseAuthScreen.prototype,"logoUrl",1);u([r.property({attribute:"brand-line"})],exports.SinglebaseAuthScreen.prototype,"brandLine",1);u([r.property({attribute:"brand-foot"})],exports.SinglebaseAuthScreen.prototype,"brandFoot",1);u([r.property({attribute:"sign-in-title"})],exports.SinglebaseAuthScreen.prototype,"signInTitle",1);u([r.property({converter:$,attribute:"branding"})],exports.SinglebaseAuthScreen.prototype,"branding",1);u([r.property({attribute:"redirect-url"})],exports.SinglebaseAuthScreen.prototype,"redirectUrl",1);u([r.property({attribute:"tos-url"})],exports.SinglebaseAuthScreen.prototype,"tosUrl",1);u([r.property({attribute:"privacy-url"})],exports.SinglebaseAuthScreen.prototype,"privacyUrl",1);u([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthScreen.prototype,"nonceStorageKey",1);u([r.property({attribute:"invite-email"})],exports.SinglebaseAuthScreen.prototype,"inviteEmail",1);u([r.property({attribute:"invite-org"})],exports.SinglebaseAuthScreen.prototype,"inviteOrg",1);u([r.property({attribute:"invite-code"})],exports.SinglebaseAuthScreen.prototype,"inviteCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"step",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"method",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"email",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"password",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"name",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"firstName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"lastName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"phone",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"confirmPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"code",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"verifyNext",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"loading",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"banner",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"notice",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"emailError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"passError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPassError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"attempts",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"needsMfaCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"callbackDone",1);exports.SinglebaseAuthScreen=u([r.customElement("singlebase-authui")],exports.SinglebaseAuthScreen);var
|
|
907
|
+
`]);u([r.property({attribute:"initial-screen"})],exports.SinglebaseAuthScreen.prototype,"initialScreen",1);u([r.property({reflect:!0})],exports.SinglebaseAuthScreen.prototype,"screen",1);u([r.property({type:Boolean,attribute:"no-account-view"})],exports.SinglebaseAuthScreen.prototype,"noAccountView",1);u([r.property({attribute:!1})],exports.SinglebaseAuthScreen.prototype,"settings",1);u([r.property({converter:$,attribute:"auth-enabled"})],exports.SinglebaseAuthScreen.prototype,"authEnabled",1);u([r.property({converter:$,attribute:"allow-email-signin"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignin",1);u([r.property({converter:$,attribute:"allow-email-signup"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignup",1);u([r.property({converter:$,attribute:"allow-email-otp"})],exports.SinglebaseAuthScreen.prototype,"allowEmailOtp",1);u([r.property({converter:$,attribute:"allow-oauth"})],exports.SinglebaseAuthScreen.prototype,"allowOauth",1);u([r.property({converter:$,attribute:"allow-account-creation"})],exports.SinglebaseAuthScreen.prototype,"allowAccountCreation",1);u([r.property()],exports.SinglebaseAuthScreen.prototype,"layout",1);u([r.property({attribute:"oauth-placement"})],exports.SinglebaseAuthScreen.prototype,"oauthPlacement",1);u([r.property({type:Boolean})],exports.SinglebaseAuthScreen.prototype,"stepped",1);u([r.property({attribute:"logo-text"})],exports.SinglebaseAuthScreen.prototype,"logoText",1);u([r.property({attribute:"logo-url"})],exports.SinglebaseAuthScreen.prototype,"logoUrl",1);u([r.property({attribute:"brand-line"})],exports.SinglebaseAuthScreen.prototype,"brandLine",1);u([r.property({attribute:"brand-foot"})],exports.SinglebaseAuthScreen.prototype,"brandFoot",1);u([r.property({attribute:"sign-in-title"})],exports.SinglebaseAuthScreen.prototype,"signInTitle",1);u([r.property({converter:$,attribute:"branding"})],exports.SinglebaseAuthScreen.prototype,"branding",1);u([r.property({attribute:"branding-text"})],exports.SinglebaseAuthScreen.prototype,"brandingText",1);u([r.property({attribute:"branding-url"})],exports.SinglebaseAuthScreen.prototype,"brandingUrl",1);u([r.property({attribute:"redirect-url"})],exports.SinglebaseAuthScreen.prototype,"redirectUrl",1);u([r.property({attribute:"tos-url"})],exports.SinglebaseAuthScreen.prototype,"tosUrl",1);u([r.property({attribute:"privacy-url"})],exports.SinglebaseAuthScreen.prototype,"privacyUrl",1);u([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthScreen.prototype,"nonceStorageKey",1);u([r.property({attribute:"invite-email"})],exports.SinglebaseAuthScreen.prototype,"inviteEmail",1);u([r.property({attribute:"invite-org"})],exports.SinglebaseAuthScreen.prototype,"inviteOrg",1);u([r.property({attribute:"invite-code"})],exports.SinglebaseAuthScreen.prototype,"inviteCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"step",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"method",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"email",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"password",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"name",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"firstName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"lastName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"phone",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"confirmPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"code",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"verifyNext",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"loading",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"banner",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"notice",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"emailError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"passError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPassError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"attempts",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"needsMfaCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"callbackDone",1);exports.SinglebaseAuthScreen=u([r.customElement("singlebase-authui")],exports.SinglebaseAuthScreen);var ws=Object.defineProperty,ys=Object.getOwnPropertyDescriptor,ye=(d,a,t,e)=>{for(var s=e>1?void 0:e?ys(a,t):a,n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=(e?c(a,t,s):c(s))||s);return e&&s&&ws(a,t,s),s};const Ss=["loading","authenticated","unauthenticated"];var he,de,ce,Be;exports.SinglebaseAuthGuard=(Be=class extends f{constructor(){super(...arguments);l(this,he,"");l(this,de,null);l(this,ce,"unauthenticated");p(this,"warnedFor",null)}get slot(){return o(this,he)}set slot(t){h(this,he,t)}get predicate(){return o(this,de)}set predicate(t){h(this,de,t)}get onMismatch(){return o(this,ce)}set onMismatch(t){h(this,ce,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 S.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 S.validatePredicate(t))console.warn(`[singlebase] <singlebase-authui-guard> predicate: ${s}`)}}render(){const t=this.activeState;if(this.slot){const e=Ss.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>`}},he=new WeakMap,de=new WeakMap,ce=new WeakMap,Be);ye([r.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);ye([r.property({converter:{fromAttribute:d=>{if(!d)return null;try{return JSON.parse(d)}catch{return console.error("[singlebase] guard predicate is not valid JSON:",d),null}},toAttribute:d=>d?JSON.stringify(d):null}})],exports.SinglebaseAuthGuard.prototype,"predicate",1);ye([r.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=ye([r.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var We=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,Es=(d,a,t)=>a in d?We(d,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[a]=t,P=(d,a,t,e)=>{for(var s=e>1?void 0:e?$s(a,t):a,n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=(e?c(a,t,s):c(s))||s);return e&&s&&We(a,t,s),s},Cs=(d,a,t)=>Es(d,a+"",t);const Ps="profile_photo";var ue,pe,ge,me,be,Re;exports.SinglebaseAuthDisplay=(Re=class extends f{constructor(){super(...arguments);l(this,ue,"");l(this,pe,"");l(this,ge,!1);l(this,me,"");l(this,be,!1)}get path(){return o(this,ue)}set path(t){h(this,ue,t)}get fallback(){return o(this,pe)}set fallback(t){h(this,pe,t)}get avatar(){return o(this,ge)}set avatar(t){h(this,ge,t)}get alt(){return o(this,me)}set alt(t){h(this,me,t)}get imageFailed(){return o(this,be)}set imageFailed(t){h(this,be,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=S.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=S.getPath(t,this.path||Ps);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
|
|
928
908
|
part="avatar-image"
|
|
929
909
|
src=${e}
|
|
930
910
|
alt=${this.alt}
|
|
@@ -933,8 +913,8 @@
|
|
|
933
913
|
part="avatar-initials"
|
|
934
914
|
class="initials"
|
|
935
915
|
aria-hidden=${this.alt?"false":"true"}
|
|
936
|
-
>${
|
|
937
|
-
>`}},
|
|
916
|
+
>${ke(t)}</span
|
|
917
|
+
>`}},ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,me=new WeakMap,be=new WeakMap,Re);Cs(exports.SinglebaseAuthDisplay,"styles",[...f.styles,i.css`
|
|
938
918
|
/* Text sits in a sentence; an avatar is a box the host sizes. */
|
|
939
919
|
:host {
|
|
940
920
|
display: inline;
|
|
@@ -972,5 +952,5 @@
|
|
|
972
952
|
color: var(--sb-muted-ink, #61666c);
|
|
973
953
|
user-select: none;
|
|
974
954
|
}
|
|
975
|
-
`]);
|
|
976
|
-
//# sourceMappingURL=authui-display-
|
|
955
|
+
`]);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);P([r.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);P([r.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=P([r.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=qe;exports.SettingsController=we;exports.defaultMessages=Se;exports.fullNameOf=Ae;exports.initialsOf=ke;exports.isGuestScreen=$e;exports.isProtectedScreen=Ye;exports.isScreen=Ee;exports.resolveMessages=He;
|
|
956
|
+
//# sourceMappingURL=authui-display-aWNht0cW.cjs.map
|