@singlebase/elements 0.5.0 → 0.7.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.
Files changed (52) hide show
  1. package/dist/{authui-display-BCZBP7HR.js → authui-display-BM_F3-5e.js} +426 -436
  2. package/dist/authui-display-BM_F3-5e.js.map +1 -0
  3. package/dist/{authui-display-CLGFSqRi.cjs → authui-display-CMVHTNFz.cjs} +45 -65
  4. package/dist/authui-display-CMVHTNFz.cjs.map +1 -0
  5. package/dist/authui.cjs +1 -1
  6. package/dist/authui.js +2 -2
  7. package/dist/{chat-bXaRWel7.js → chat-BH_3e1jT.js} +2081 -1121
  8. package/dist/chat-BH_3e1jT.js.map +1 -0
  9. package/dist/chat-ezUmd9II.cjs +3281 -0
  10. package/dist/chat-ezUmd9II.cjs.map +1 -0
  11. package/dist/chat-messages.d.ts +19 -6
  12. package/dist/chat.cjs +1 -1
  13. package/dist/chat.d.ts +4 -3
  14. package/dist/chat.js +8 -6
  15. package/dist/elements/authui-base.d.ts +2 -0
  16. package/dist/elements/authui-buttons.d.ts +1 -1
  17. package/dist/elements/authui-display.d.ts +1 -1
  18. package/dist/elements/authui.d.ts +1 -1
  19. package/dist/elements/chat.d.ts +192 -11
  20. package/dist/elements/uploader.d.ts +8 -0
  21. package/dist/files-4T62wkwj.cjs +77 -0
  22. package/dist/files-4T62wkwj.cjs.map +1 -0
  23. package/dist/{files-BOwtpYyQ.js → files-DS-H-3yN.js} +93 -47
  24. package/dist/files-DS-H-3yN.js.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +24 -22
  27. package/dist/messages.d.ts +0 -2
  28. package/dist/singlebase-elements.min.js +3838 -2844
  29. package/dist/singlebase-elements.min.js.map +1 -1
  30. package/dist/styles/branding.d.ts +5 -0
  31. package/dist/styles/tokens.d.ts +2 -0
  32. package/dist/upload-messages.d.ts +0 -1
  33. package/dist/{uploader-DGV2y9uT.cjs → uploader-COP8PkJ6.cjs} +53 -76
  34. package/dist/uploader-COP8PkJ6.cjs.map +1 -0
  35. package/dist/{uploader-abQoem5q.js → uploader-tdMU9Gxv.js} +249 -253
  36. package/dist/uploader-tdMU9Gxv.js.map +1 -0
  37. package/dist/uploader.cjs +1 -1
  38. package/dist/uploader.js +2 -2
  39. package/dist/utils/branding.d.ts +8 -0
  40. package/dist/utils/markdown.d.ts +69 -12
  41. package/dist/utils/svg.d.ts +10 -0
  42. package/package.json +3 -3
  43. package/dist/authui-display-BCZBP7HR.js.map +0 -1
  44. package/dist/authui-display-CLGFSqRi.cjs.map +0 -1
  45. package/dist/chat-DRenTJlI.cjs +0 -3001
  46. package/dist/chat-DRenTJlI.cjs.map +0 -1
  47. package/dist/chat-bXaRWel7.js.map +0 -1
  48. package/dist/files-BOwtpYyQ.js.map +0 -1
  49. package/dist/files-DW8A4Jl-.cjs +0 -38
  50. package/dist/files-DW8A4Jl-.cjs.map +0 -1
  51. package/dist/uploader-DGV2y9uT.cjs.map +0 -1
  52. 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 Xe=Object.defineProperty;var xe=o=>{throw TypeError(o)};var Ze=(o,n,t)=>n in o?Xe(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var p=(o,n,t)=>Ze(o,typeof n!="symbol"?n+"":n,t),Ue=(o,n,t)=>n.has(o)||xe("Cannot "+t);var l=(o,n,t)=>(Ue(o,n,"read from private field"),t?t.call(o):n.get(o)),h=(o,n,t)=>n.has(o)?xe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(o):n.set(o,t),c=(o,n,t,e)=>(Ue(o,n,"write to private field"),e?e.call(o,t):n.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"),Be=require("./uploader-COP8PkJ6.cjs"),$e=require("./files-4T62wkwj.cjs"),S=require("@singlebase/core");class Re{constructor(n){p(this,"host");p(this,"client",null);p(this,"unsubscribe",null);p(this,"state",{status:"loading",session:null,user:null});this.host=n,n.addController(this)}bind(n){var t;n!==this.client&&((t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.client=n,n&&(this.state=n.getState(),this.unsubscribe=n.subscribe(e=>{this.state=e,this.host.requestUpdate()}),this.host.requestUpdate()))}hostDisconnected(){var n;(n=this.unsubscribe)==null||n.call(this),this.unsubscribe=null}}const we={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",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 je(o){return o?{...we,...o}:we}var ts=Object.defineProperty,es=Object.getOwnPropertyDescriptor,C=(o,n,t,e)=>{for(var s=es(n,t),a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=d(n,t,s)||s);return s&&ts(n,t,s),s},A,k,_,O,T,x;class f extends i.LitElement{constructor(){super(...arguments);h(this,A,null);h(this,k,{});h(this,_);h(this,O);h(this,T);h(this,x);p(this,"auth",new Re(this));p(this,"appliedConfig",new Set)}get client(){return l(this,A)}set client(t){c(this,A,t)}get messages(){return l(this,k)}set messages(t){c(this,k,t)}get theme(){return l(this,_)}set theme(t){c(this,_,t)}get density(){return l(this,O)}set density(t){c(this,O,t)}get fieldStyle(){return l(this,T)}set fieldStyle(t){c(this,T,t)}get radius(){return l(this,x)}set radius(t){c(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 je(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",[$e.tokenDefaults,Be.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 fe{constructor(n){p(this,"host");p(this,"client",null);p(this,"cache",new WeakMap);p(this,"settings",null);p(this,"error",null);this.host=n,n.addController(this)}hostConnected(){}load(n,t){if(t){this.settings=t;return}if(!n||n===this.client)return;this.client=n;let e=this.cache.get(n);e||(e=n.getSettings(),this.cache.set(n,e)),e.then(s=>{this.settings=s,this.error=null,this.host.requestUpdate()}).catch(s=>{this.error=s,this.host.requestUpdate()})}}const ss=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],is={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 Le(o){return"on"+o.replace(/(^|-)([a-z])/g,(n,t,e)=>e.toUpperCase())}class as{constructor(n){p(this,"unsubscribes",[]);p(this,"client",null);this.host=n,n.addController(this)}bind(n){n!==this.client&&(this.release(),this.client=n,n&&(this.unsubscribes=ss.map(t=>n.on(t,e=>this.publish(t,e)))))}publish(n,t){const e=this.host[Le(n)];if(typeof e=="function")try{e.call(this.host,t)}catch(d){console.error(`[singlebase] ${Le(n)} threw:`,d)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${n}`,s));const a=is[n];a&&this.host.dispatchEvent(new CustomEvent(a,s))}release(){this.unsubscribes.forEach(n=>n()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var ns=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,Ee=(o,n,t,e)=>{for(var s=rs(n,t),a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=d(n,t,s)||s);return s&&ns(n,t,s),s},U,L,M;class me extends f{constructor(){super(...arguments);h(this,U,"idle");h(this,L,"");h(this,M,"");p(this,"abortController",null)}get phase(){return l(this,U)}set phase(t){c(this,U,t)}get formError(){return l(this,L)}set formError(t){c(this,L,t)}get noticeMessage(){return l(this,M)}set noticeMessage(t){c(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
- `}}x=new WeakMap,T=new WeakMap,U=new WeakMap;Se([r.state()],ge.prototype,"phase");Se([r.state()],ge.prototype,"formError");Se([r.state()],ge.prototype,"noticeMessage");function $e(o){return[o==null?void 0:o.first_name,o==null?void 0:o.last_name].filter(Boolean).join(" ").trim()}function Ee(o){const a=$e(o);if(a)return a.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();const t=(o==null?void 0:o.email)??"";return t?t[0].toUpperCase():"·"}var rs=Object.defineProperty,os=Object.getOwnPropertyDescriptor,g=(o,a,t,e)=>{for(var s=e>1?void 0:e?os(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&&rs(a,t,s),s};const ls={profile_photo:!0},hs=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp";var L,M,N,D,I,F,B,R,j,q,G,H,V,K,Y,W,z,J,Q,X,Z,tt,et,st,it,nt,Ue;exports.SinglebaseAccountScreen=(Ue=class extends ge{constructor(){super(...arguments);h(this,L,"");h(this,M,"");h(this,N,null);h(this,D,"singlebase-oauth-nonce");h(this,I,"");h(this,F,"");h(this,B,!1);h(this,R,"");h(this,j,"");h(this,q,"");h(this,G,"");h(this,H,"");h(this,V,0);h(this,K,"");h(this,Y,"");h(this,W,"");h(this,z,"");h(this,J,"");h(this,Q,"request");h(this,X,"");h(this,Z,"");h(this,tt,"");h(this,et,"");h(this,st,"");h(this,it,"");h(this,nt,"");p(this,"settingsCtl",new be(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(d){this.formError=this.describeError(d)}finally{this.photoBusy=!1}});p(this,"onPhotoProblem",t=>{this.photoBusy=!1,this.formError=t.detail.message})}get logoText(){return l(this,L)}set logoText(t){c(this,L,t)}get logoUrl(){return l(this,M)}set logoUrl(t){c(this,M,t)}get settings(){return l(this,N)}set settings(t){c(this,N,t)}get nonceStorageKey(){return l(this,D)}set nonceStorageKey(t){c(this,D,t)}get editMode(){return l(this,I)}set editMode(t){c(this,I,t)}get toast(){return l(this,F)}set toast(t){c(this,F,t)}get photoBusy(){return l(this,B)}set photoBusy(t){c(this,B,t)}get photoFailed(){return l(this,R)}set photoFailed(t){c(this,R,t)}get profileSaved(){return l(this,j)}set profileSaved(t){c(this,j,t)}get passSaved(){return l(this,q)}set passSaved(t){c(this,q,t)}get profileError(){return l(this,G)}set profileError(t){c(this,G,t)}get newPassError(){return l(this,H)}set newPassError(t){c(this,H,t)}get deleteStage(){return l(this,V)}set deleteStage(t){c(this,V,t)}get confirmText(){return l(this,K)}set confirmText(t){c(this,K,t)}get dFirst(){return l(this,Y)}set dFirst(t){c(this,Y,t)}get dLast(){return l(this,W)}set dLast(t){c(this,W,t)}get dPhone(){return l(this,z)}set dPhone(t){c(this,z,t)}get dEmail(){return l(this,J)}set dEmail(t){c(this,J,t)}get emailStep(){return l(this,Q)}set emailStep(t){c(this,Q,t)}get dNewEmail(){return l(this,X)}set dNewEmail(t){c(this,X,t)}get emailCode(){return l(this,Z)}set emailCode(t){c(this,Z,t)}get emailError(){return l(this,tt)}set emailError(t){c(this,tt,t)}get emailSaved(){return l(this,et)}set emailSaved(t){c(this,et,t)}get curPass(){return l(this,st)}set curPass(t){c(this,st,t)}get newPass(){return l(this,it)}set newPass(t){c(this,it,t)}get confirmPass(){return l(this,nt)}set confirmPass(t){c(this,nt,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
12
+ `}}U=new WeakMap,L=new WeakMap,M=new WeakMap;Ee([r.state()],me.prototype,"phase");Ee([r.state()],me.prototype,"formError");Ee([r.state()],me.prototype,"noticeMessage");function Ce(o){return[o==null?void 0:o.first_name,o==null?void 0:o.last_name].filter(Boolean).join(" ").trim()}function Pe(o){const n=Ce(o);if(n)return n.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();const t=(o==null?void 0:o.email)??"";return t?t[0].toUpperCase():"·"}var os=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,g=(o,n,t,e)=>{for(var s=e>1?void 0:e?ls(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&os(n,t,s),s};const hs={profile_photo:!0},cs=".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,at,nt,rt,Me;exports.SinglebaseAccountScreen=(Me=class extends me{constructor(){super(...arguments);h(this,N,"");h(this,D,"");h(this,I,null);h(this,F,"singlebase-oauth-nonce");h(this,B,"");h(this,R,"");h(this,j,!1);h(this,q,"");h(this,H,"");h(this,G,"");h(this,V,"");h(this,K,"");h(this,Y,0);h(this,W,"");h(this,z,"");h(this,J,"");h(this,Q,"");h(this,X,"");h(this,Z,"request");h(this,tt,"");h(this,et,"");h(this,st,"");h(this,it,"");h(this,at,"");h(this,nt,"");h(this,rt,"");p(this,"settingsCtl",new fe(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 a;const{completed:e,failed:s}=t.detail;try{e.length?(await((a=this.resolvedClient)==null?void 0:a.getAccount()),this.photoFailed="",this.toast=this.msg.photoUpdated):s.length&&(this.formError=s[0].error||this.msg.genericErrorMessage)}catch(d){this.formError=this.describeError(d)}finally{this.photoBusy=!1}});p(this,"onPhotoProblem",t=>{this.photoBusy=!1,this.formError=t.detail.message})}get logoText(){return l(this,N)}set logoText(t){c(this,N,t)}get logoUrl(){return l(this,D)}set logoUrl(t){c(this,D,t)}get settings(){return l(this,I)}set settings(t){c(this,I,t)}get nonceStorageKey(){return l(this,F)}set nonceStorageKey(t){c(this,F,t)}get editMode(){return l(this,B)}set editMode(t){c(this,B,t)}get toast(){return l(this,R)}set toast(t){c(this,R,t)}get photoBusy(){return l(this,j)}set photoBusy(t){c(this,j,t)}get photoFailed(){return l(this,q)}set photoFailed(t){c(this,q,t)}get profileSaved(){return l(this,H)}set profileSaved(t){c(this,H,t)}get passSaved(){return l(this,G)}set passSaved(t){c(this,G,t)}get profileError(){return l(this,V)}set profileError(t){c(this,V,t)}get newPassError(){return l(this,K)}set newPassError(t){c(this,K,t)}get deleteStage(){return l(this,Y)}set deleteStage(t){c(this,Y,t)}get confirmText(){return l(this,W)}set confirmText(t){c(this,W,t)}get dFirst(){return l(this,z)}set dFirst(t){c(this,z,t)}get dLast(){return l(this,J)}set dLast(t){c(this,J,t)}get dPhone(){return l(this,Q)}set dPhone(t){c(this,Q,t)}get dEmail(){return l(this,X)}set dEmail(t){c(this,X,t)}get emailStep(){return l(this,Z)}set emailStep(t){c(this,Z,t)}get dNewEmail(){return l(this,tt)}set dNewEmail(t){c(this,tt,t)}get emailCode(){return l(this,et)}set emailCode(t){c(this,et,t)}get emailError(){return l(this,st)}set emailError(t){c(this,st,t)}get emailSaved(){return l(this,it)}set emailSaved(t){c(this,it,t)}get curPass(){return l(this,at)}set curPass(t){c(this,at,t)}get newPass(){return l(this,nt)}set newPass(t){c(this,nt,t)}get confirmPass(){return l(this,rt)}set confirmPass(t){c(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 $e(this.user)}get initials(){return Ee(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`
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 Ce(this.user)}get initials(){return Pe(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>
@@ -45,7 +45,7 @@
45
45
  placeholder=${this.msg.emailPlaceholder}
46
46
  aria-invalid=${this.emailError?"true":"false"}
47
47
  ?disabled=${this.submitting}
48
- @input=${n=>{this.dNewEmail=n.target.value,this.emailError=""}}
48
+ @input=${a=>{this.dNewEmail=a.target.value,this.emailError=""}}
49
49
  />
50
50
  <p class="hint">${this.msg.changeEmailHint}</p>
51
51
  </div>
@@ -84,7 +84,7 @@
84
84
  placeholder="000000"
85
85
  aria-invalid=${this.emailError?"true":"false"}
86
86
  ?disabled=${this.submitting}
87
- @input=${n=>{this.emailCode=n.target.value.replace(/\D/g,"").slice(0,6),this.emailError=""}}
87
+ @input=${a=>{this.emailCode=a.target.value.replace(/\D/g,"").slice(0,6),this.emailError=""}}
88
88
  />
89
89
  <p class="hint">${this.msg.changeEmailConfirmHint} ${this.dNewEmail}</p>
90
90
  </div>
@@ -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:d}=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(d)})}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`
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 a=await e.createOAuthNonce(this.signal);(m=globalThis.sessionStorage)==null||m.setItem(this.nonceStorageKey,a);const{oauth_redirect_url:d}=await e.startOAuth({provider:t,nonce:a,intent:"link",id_token:s.session.id_token,refresh_token:s.session.refresh_token},this.signal);globalThis.location.assign(d)})}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,a])=>({id:s,name:a.provider_name,mark:e[s]??a.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=${hs}
139
+ accept=${cs}
140
140
  .client=${this.uploadClient}
141
- .options=${ls}
141
+ .options=${hs}
142
142
  @singlebase-upload-selected=${this.onPhotoSelected}
143
143
  @singlebase-upload-complete=${this.onPhotoUploaded}
144
144
  @singlebase-upload-error=${this.onPhotoProblem}
@@ -154,11 +154,11 @@
154
154
  ${this.msg.signOutCta}
155
155
  </button>
156
156
  </div>
157
- `}renderProfileSection(){const t=this.user;if(!t)return i.nothing;const e=this.editMode!=="profile",s=this.editMode!==""&&this.editMode!=="profile",n=[[this.msg.firstNameLabel,t.first_name||"—"],[this.msg.lastNameLabel,t.last_name||"—"],[this.msg.phoneLabel,t.phone||"—"],[this.msg.emailLabel,t.email||"—"]];return i.html`
157
+ `}renderProfileSection(){const t=this.user;if(!t)return i.nothing;const e=this.editMode!=="profile",s=this.editMode!==""&&this.editMode!=="profile",a=[[this.msg.firstNameLabel,t.first_name||"—"],[this.msg.lastNameLabel,t.last_name||"—"],[this.msg.phoneLabel,t.phone||"—"],[this.msg.emailLabel,t.email||"—"]];return i.html`
158
158
  <div class="section">
159
159
  ${e?i.html`
160
160
  <div class="sum-list">
161
- ${n.map(([d,m])=>i.html`
161
+ ${a.map(([d,m])=>i.html`
162
162
  <div class="sum-row">
163
163
  <span class="sum-label">${d}</span>
164
164
  <span class="sum-value">${m}</span>
@@ -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>`}},L=new WeakMap,M=new WeakMap,N=new WeakMap,D=new WeakMap,I=new WeakMap,F=new WeakMap,B=new WeakMap,R=new WeakMap,j=new WeakMap,q=new WeakMap,G=new WeakMap,H=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,Ue);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 cs=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,w=(o,a,t,e)=>{for(var s=e>1?void 0:e?ds(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&&cs(a,t,s),s},at,rt,ot,lt,ht,ct,dt,Le;exports.SinglebaseAuthButtons=(Le=class extends ge{constructor(){super(...arguments);h(this,at,"signout");h(this,rt,"signin");h(this,ot,"");h(this,lt,"");h(this,ht,!1);h(this,ct,null);h(this,dt,"singlebase-oauth-nonce");p(this,"settingsCtl",new be(this))}get type(){return l(this,at)}set type(t){c(this,at,t)}get intent(){return l(this,rt)}set intent(t){c(this,rt,t)}get provider(){return l(this,ot)}set provider(t){c(this,ot,t)}get providerName(){return l(this,lt)}set providerName(t){c(this,lt,t)}get embedded(){return l(this,ht)}set embedded(t){c(this,ht,t)}get settings(){return l(this,ct)}set settings(t){c(this,ct,t)}get nonceStorageKey(){return l(this,dt)}set nonceStorageKey(t){c(this,dt,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,d])=>({id:n,name:d.provider_name,mark:s[n]??d.provider_name.slice(0,2)}))}async startOAuth(t,e,s=!1){const n=this.resolvedClient;if(!n)return;let d,m;if(s){const b=this.auth.state;if(b.status!=="authenticated"){this.formError=this.msg.linkRequiresSignIn,this.phase="error";return}d=b.session.id_token,m=b.session.refresh_token}await this.run(async()=>{var me;const b=await n.createOAuthNonce(this.signal);(me=globalThis.sessionStorage)==null||me.setItem(this.nonceStorageKey,b);const{oauth_redirect_url:v}=await n.startOAuth({provider:t,nonce:b,intent:e,...s?{id_token:d,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`
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,at=new WeakMap,nt=new WeakMap,rt=new WeakMap,Me);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 ds=Object.defineProperty,us=Object.getOwnPropertyDescriptor,w=(o,n,t,e)=>{for(var s=e>1?void 0:e?us(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&ds(n,t,s),s},ot,lt,ht,ct,dt,ut,pt,Ne;exports.SinglebaseAuthButtons=(Ne=class extends me{constructor(){super(...arguments);h(this,ot,"signout");h(this,lt,"signin");h(this,ht,"");h(this,ct,"");h(this,dt,!1);h(this,ut,null);h(this,pt,"singlebase-oauth-nonce");p(this,"settingsCtl",new fe(this))}get type(){return l(this,ot)}set type(t){c(this,ot,t)}get intent(){return l(this,lt)}set intent(t){c(this,lt,t)}get provider(){return l(this,ht)}set provider(t){c(this,ht,t)}get providerName(){return l(this,ct)}set providerName(t){c(this,ct,t)}get embedded(){return l(this,dt)}set embedded(t){c(this,dt,t)}get settings(){return l(this,ut)}set settings(t){c(this,ut,t)}get nonceStorageKey(){return l(this,pt)}set nonceStorageKey(t){c(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(([,a])=>a.enabled).map(([a,d])=>({id:a,name:d.provider_name,mark:s[a]??d.provider_name.slice(0,2)}))}async startOAuth(t,e,s=!1){const a=this.resolvedClient;if(!a)return;let d,m;if(s){const b=this.auth.state;if(b.status!=="authenticated"){this.formError=this.msg.linkRequiresSignIn,this.phase="error";return}d=b.session.id_token,m=b.session.refresh_token}await this.run(async()=>{var be;const b=await a.createOAuthNonce(this.signal);(be=globalThis.sessionStorage)==null||be.setItem(this.nonceStorageKey,b);const{oauth_redirect_url:v}=await a.startOAuth({provider:t,nonce:b,intent:e,...s?{id_token:d,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
 
@@ -421,17 +421,17 @@
421
421
 
422
422
  ${s.length?i.html`
423
423
  <div class="icon-row">
424
- ${s.map(n=>i.html`
424
+ ${s.map(a=>i.html`
425
425
  <button
426
426
  type="button"
427
427
  class="icon-btn"
428
428
  part="oauth-button"
429
- aria-label=${`${this.msg.oauthContinueWith} ${n.name}`}
430
- title=${`${this.msg.oauthContinueWith} ${n.name}`}
429
+ aria-label=${`${this.msg.oauthContinueWith} ${a.name}`}
430
+ title=${`${this.msg.oauthContinueWith} ${a.name}`}
431
431
  ?disabled=${this.submitting}
432
- @click=${()=>this.startOAuth(n.id,this.intent)}
432
+ @click=${()=>this.startOAuth(a.id,this.intent)}
433
433
  >
434
- <span class="tile-mark">${n.mark}</span>
434
+ <span class="tile-mark">${a.mark}</span>
435
435
  </button>
436
436
  `)}
437
437
  </div>
@@ -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,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,Ne);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 qe=Object.defineProperty,ps=Object.getOwnPropertyDescriptor,gs=(o,n,t)=>n in o?qe(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,u=(o,n,t,e)=>{for(var s=e>1?void 0:e?ps(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&qe(n,t,s),s},ms=(o,n,t)=>gs(o,n+"",t);const He=["signin","signup","forgot","verify","otp","newpass","invite"],Ge=["account"],bs=[...He,...Ge,"oauth-callback"];function ye(o){return He.includes(o)}function Ve(o){return Ge.includes(o)}function Se(o){return bs.includes(o)}const $={fromAttribute:o=>o===null?!0:o!=="false",toAttribute:o=>o?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,ae,ne,re,De;exports.SinglebaseAuthScreen=(De=class extends f{constructor(){super(...arguments);h(this,gt,"signin");h(this,mt,"");h(this,bt,!1);h(this,ft,null);h(this,vt,!0);h(this,wt,!0);h(this,yt,!0);h(this,St,!0);h(this,$t,!0);h(this,Et,!0);h(this,Ct,"card");h(this,Pt,"bottom");h(this,At,!1);h(this,kt,"");h(this,_t,"");h(this,Ot,"");h(this,Tt,"");h(this,xt,"");h(this,Ut,!0);h(this,Lt,"");h(this,Mt,"");h(this,Nt,"");h(this,Dt,"singlebase-oauth-nonce");h(this,It,"");h(this,Ft,"");h(this,Bt,"");h(this,Rt,0);h(this,jt,"");h(this,qt,"");h(this,Ht,"");h(this,Gt,"");h(this,Vt,"");h(this,Kt,"");h(this,Yt,"");h(this,Wt,"");h(this,zt,"");h(this,Jt,["","","","","",""]);h(this,Qt,"signin_code");h(this,Xt,!1);h(this,Zt,"");h(this,te,"");h(this,ee,"");h(this,se,"");h(this,ie,"");h(this,ae,0);h(this,ne,!1);p(this,"settingsCtl",new fe(this));p(this,"bridge",new as(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);h(this,re,!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,gt)}set initialScreen(t){c(this,gt,t)}get screen(){return l(this,mt)}set screen(t){c(this,mt,t)}get noAccountView(){return l(this,bt)}set noAccountView(t){c(this,bt,t)}get settings(){return l(this,ft)}set settings(t){c(this,ft,t)}get authEnabled(){return l(this,vt)}set authEnabled(t){c(this,vt,t)}get allowEmailSignin(){return l(this,wt)}set allowEmailSignin(t){c(this,wt,t)}get allowEmailSignup(){return l(this,yt)}set allowEmailSignup(t){c(this,yt,t)}get allowEmailOtp(){return l(this,St)}set allowEmailOtp(t){c(this,St,t)}get allowOauth(){return l(this,$t)}set allowOauth(t){c(this,$t,t)}get allowAccountCreation(){return l(this,Et)}set allowAccountCreation(t){c(this,Et,t)}get layout(){return l(this,Ct)}set layout(t){c(this,Ct,t)}get oauthPlacement(){return l(this,Pt)}set oauthPlacement(t){c(this,Pt,t)}get stepped(){return l(this,At)}set stepped(t){c(this,At,t)}get logoText(){return l(this,kt)}set logoText(t){c(this,kt,t)}get logoUrl(){return l(this,_t)}set logoUrl(t){c(this,_t,t)}get brandLine(){return l(this,Ot)}set brandLine(t){c(this,Ot,t)}get brandFoot(){return l(this,Tt)}set brandFoot(t){c(this,Tt,t)}get signInTitle(){return l(this,xt)}set signInTitle(t){c(this,xt,t)}get branding(){return l(this,Ut)}set branding(t){c(this,Ut,t)}get redirectUrl(){return l(this,Lt)}set redirectUrl(t){c(this,Lt,t)}get tosUrl(){return l(this,Mt)}set tosUrl(t){c(this,Mt,t)}get privacyUrl(){return l(this,Nt)}set privacyUrl(t){c(this,Nt,t)}get nonceStorageKey(){return l(this,Dt)}set nonceStorageKey(t){c(this,Dt,t)}get inviteEmail(){return l(this,It)}set inviteEmail(t){c(this,It,t)}get inviteOrg(){return l(this,Ft)}set inviteOrg(t){c(this,Ft,t)}get inviteCode(){return l(this,Bt)}set inviteCode(t){c(this,Bt,t)}get step(){return l(this,Rt)}set step(t){c(this,Rt,t)}get method(){return l(this,jt)}set method(t){c(this,jt,t)}get email(){return l(this,qt)}set email(t){c(this,qt,t)}get password(){return l(this,Ht)}set password(t){c(this,Ht,t)}get name(){return l(this,Gt)}set name(t){c(this,Gt,t)}get firstName(){return l(this,Vt)}set firstName(t){c(this,Vt,t)}get lastName(){return l(this,Kt)}set lastName(t){c(this,Kt,t)}get phone(){return l(this,Yt)}set phone(t){c(this,Yt,t)}get newPass(){return l(this,Wt)}set newPass(t){c(this,Wt,t)}get confirmPass(){return l(this,zt)}set confirmPass(t){c(this,zt,t)}get code(){return l(this,Jt)}set code(t){c(this,Jt,t)}get verifyNext(){return l(this,Qt)}set verifyNext(t){c(this,Qt,t)}get loading(){return l(this,Xt)}set loading(t){c(this,Xt,t)}get banner(){return l(this,Zt)}set banner(t){c(this,Zt,t)}get notice(){return l(this,te)}set notice(t){c(this,te,t)}get emailError(){return l(this,ee)}set emailError(t){c(this,ee,t)}get passError(){return l(this,se)}set passError(t){c(this,se,t)}get newPassError(){return l(this,ie)}set newPassError(t){c(this,ie,t)}get attempts(){return l(this,ae)}set attempts(t){c(this,ae,t)}get needsMfaCode(){return l(this,ne)}set needsMfaCode(t){c(this,ne,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 a;if(t===this.gotoClient||((a=this.gotoUnsubscribe)==null||a.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=t,!t))return;const e=t.on("goto",({screen:d})=>{Se(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 Se(t)?t:"signin"}get activeScreen(){if(this.isOAuthCallback)return"oauth-callback";const t=this.auth.state.status==="authenticated",e=this.requestedScreen;if(Ve(e))return t?e:"signin";if(t)return this.screen!==""||this.initialScreen!=="signin"?e:"account";const s=this.cfg;let a=e;return a==="signup"&&!s.allowEmailSignup&&(a="signin"),(a==="forgot"||a==="newpass")&&!s.allowEmailSignin&&(a="signin"),a==="otp"&&!s.allowEmailOtp&&(a="signin"),a==="signin"&&!s.allowEmailSignin&&s.allowEmailOtp&&(a="otp"),a}get showsSignedInInterstitial(){return this.auth.state.status==="authenticated"&&ye(this.activeScreen)}get redirectTarget(){var t;return Be.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,re)}set callbackDone(t){c(this,re,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"),a=this.resolvedClient;if(s){this.cleanCallbackUrl(),this.banner=this.msg.oauthDenied;return}if(!e||!a)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 a.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 $e.renderBranding(this.branding,"Auth")}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,...d]=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:d.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 d=n.slice(-1),m=this.code.slice();m[t]=d,this.code=m,this.banner="",d&&((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 d=0;d<e.length&&t+d<s.length;d+=1)s[t+d]=e[d];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`
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 a=s==="forgot"?"password_reset":"signin";await this.withLoading(async()=>{await e.requestCode({email:this.email,purpose:a},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 a=this.inviteCode||this.codeValue;if(a.length<6){this.banner=this.msg.codeIncompleteError;return}await this.withLoading(async()=>{await e.acceptInvite({email:this.inviteEmail,grant_type:"code",purpose:"invite",code:a,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[a,...d]=this.name.trim().split(/\s+/);await this.withLoading(async()=>{const m=await e.signUp({email:this.email,password:this.password,first_name:a||this.name,last_name:d.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(a){if(a instanceof y.SinglebaseAuthError&&a.code==="CODE_REQUIRED"){this.needsMfaCode=!0,await e.requestCode({email:this.email,purpose:"signin"},this.signal()),this.notice=this.msg.codeSentNeutral;return}if(a instanceof y.SinglebaseAuthError&&a.code==="INVALID_CREDENTIALS"){this.attempts+=1,this.banner=this.attempts>=3?this.msg.rateLimitedMessage:"That email and password do not match.";return}throw a}})}signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}onCodeInput(t,e){var b;const a=e.target.value.replace(/\D/g,"");if(a.length>1){this.fillCode(t,a);return}const d=a.slice(-1),m=this.code.slice();m[t]=d,this.code=m,this.banner="",d&&((b=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[t+1])==null||b.focus())}onCodePaste(t,e){var a;const s=(((a=e.clipboardData)==null?void 0:a.getData("text"))??"").replace(/\D/g,"");s&&(e.preventDefault(),this.fillCode(t,s))}fillCode(t,e){const s=this.code.slice();for(let d=0;d<e.length&&t+d<s.length;d+=1)s[t+d]=e[d];this.code=s,this.banner="";const a=Math.min(t+e.length,s.length-1);this.updateComplete.then(()=>{var m;(m=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[a])==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>
@@ -546,13 +542,13 @@
546
542
  autocomplete=${s===0?"one-time-code":"off"}
547
543
  .value=${e}
548
544
  ?disabled=${this.loading}
549
- @input=${n=>this.onCodeInput(s,n)}
550
- @paste=${n=>this.onCodePaste(s,n)}
545
+ @input=${a=>this.onCodeInput(s,a)}
546
+ @paste=${a=>this.onCodePaste(s,a)}
551
547
  />
552
548
  `)}
553
549
  </div>
554
- `}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,n=t==="signup"&&(!s||this.step===0),d=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
- ${n?i.html`
550
+ `}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,a=t==="signup"&&(!s||this.step===0),d=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`
551
+ ${a?i.html`
556
552
  <div class="field">
557
553
  <label for=${this.uid("name")}>${this.msg.fullNameLabel}</label>
558
554
  <input
@@ -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 d=s&&n,m=s?n&&this.method||"email":"oauth",b=m==="email",v=m==="oauth",me=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,Ve=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,Ce=(ke,Ke,Ye,We,ze,_e)=>i.html`
586
- <div class="acc-item ${ke?"open":""} ${d?"":"bare"}" part="acc-item">
581
+ `}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,a=e.allowOauth;if(!s&&!a)return i.nothing;const d=s&&a,m=s?a&&this.method||"email":"oauth",b=m==="email",v=m==="oauth",be=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,Ye=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,Ae=(Oe,We,ze,Je,Qe,Te)=>i.html`
582
+ <div class="acc-item ${Oe?"open":""} ${d?"":"bare"}" part="acc-item">
587
583
  ${d?i.html`
588
584
  <button
589
585
  type="button"
590
586
  class="acc-head"
591
- aria-expanded=${ke?"true":"false"}
592
- aria-controls=${this.uid(`acc-${_e}`)}
593
- @click=${ze}
587
+ aria-expanded=${Oe?"true":"false"}
588
+ aria-controls=${this.uid(`acc-${Te}`)}
589
+ @click=${Qe}
594
590
  >
595
591
  <span class="chev" aria-hidden="true">›</span>
596
- <span class="acc-title">${Ke}</span>
597
- <span class="acc-meta">${Ye}</span>
592
+ <span class="acc-title">${We}</span>
593
+ <span class="acc-meta">${ze}</span>
598
594
  </button>
599
595
  `:i.nothing}
600
- <div class="acc-body" id=${this.uid(`acc-${_e}`)}>
596
+ <div class="acc-body" id=${this.uid(`acc-${Te}`)}>
601
597
  <div class="acc-clip">
602
- <div class="acc-inner">${We}</div>
598
+ <div class="acc-inner">${Je}</div>
603
599
  </div>
604
600
  </div>
605
601
  </div>
606
- `,Pe=s?Ce(b,me,Ve,this.renderEmailMethodBody(t),()=>this.method=b?"":"email","email"):i.nothing,Ae=n?Ce(v,this.msg.oauthMethodTitle,this.msg.oauthMethodMeta,i.html`<singlebase-authui-buttons
602
+ `,ke=s?Ae(b,be,Ye,this.renderEmailMethodBody(t),()=>this.method=b?"":"email","email"):i.nothing,_e=a?Ae(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`${Ae}${Pe}`:i.html`${Pe}${Ae}`}
614
+ ${this.oauthPlacement==="top"?i.html`${_e}${ke}`:i.html`${ke}${_e}`}
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,d=t==="signin"&&e.allowEmailSignup||t==="signup"&&e.allowEmailSignin,m=this.stepped&&(t==="signin"||t==="signup");return i.html`
717
+ `:i.nothing}renderGuest(t){const e=this.cfg,s=["forgot","verify","newpass","invite"].indexOf(t)>=0,a=this.stepped&&this.step>0||["forgot","verify","otp","newpass"].indexOf(t)>=0,d=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}
@@ -732,10 +728,10 @@
732
728
  ${this.banner?i.html`<div class="banner" part="banner" role="alert">${this.banner}</div>`:i.nothing}
733
729
  ${this.notice?i.html`<div class="notice" part="notice" role="status">${this.notice}</div>`:i.nothing}
734
730
  ${this.renderScreenBody(t)}
735
- ${s||n?i.html`
731
+ ${s||a?i.html`
736
732
  <div class="actions">
737
733
  ${s?this.renderPrimary(this.ctaFor(t)):i.nothing}
738
- ${n?i.html`<button type="button" class="ghost" @click=${this.goBack}>
734
+ ${a?i.html`<button type="button" class="ghost" @click=${this.goBack}>
739
735
  ${this.msg.backCta}
740
736
  </button>`:i.nothing}
741
737
  </div>
@@ -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&&we(t);return i.html`
812
+ `);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,a=!e.authEnabled||s&&ye(t);return i.html`
817
813
  ${this.layout==="split"?i.html`
818
814
  <div class="brand-panel">
819
815
  ${this.renderBrandMark()}
@@ -821,8 +817,8 @@
821
817
  ${this.brandFoot?i.html`<div class="brand-foot">${this.brandFoot}</div>`:i.nothing}
822
818
  </div>
823
819
  `:i.nothing}
824
- ${this.panel(n?this.renderBlocked():this.renderGuest(t))}
825
- `}},ut=new WeakMap,pt=new WeakMap,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,xt=new WeakMap,Tt=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,Gt=new WeakMap,Ht=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,Me);gs(exports.SinglebaseAuthScreen,"styles",[...f.styles,i.css`
820
+ ${this.panel(a?this.renderBlocked():this.renderGuest(t))}
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,ae=new WeakMap,ne=new WeakMap,re=new WeakMap,De);ms(exports.SinglebaseAuthScreen,"styles",[...f.styles,$e.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 bs=Object.defineProperty,fs=Object.getOwnPropertyDescriptor,fe=(o,a,t,e)=>{for(var s=e>1?void 0:e?fs(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&&bs(a,t,s),s};const vs=["loading","authenticated","unauthenticated"];var ae,re,oe,Ne;exports.SinglebaseAuthGuard=(Ne=class extends f{constructor(){super(...arguments);h(this,ae,"");h(this,re,null);h(this,oe,"unauthenticated");p(this,"warnedFor",null)}get slot(){return l(this,ae)}set slot(t){c(this,ae,t)}get predicate(){return l(this,re)}set predicate(t){c(this,re,t)}get onMismatch(){return l(this,oe)}set onMismatch(t){c(this,oe,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=vs.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>`}},ae=new WeakMap,re=new WeakMap,oe=new WeakMap,Ne);fe([r.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);fe([r.property({converter:{fromAttribute:o=>{if(!o)return null;try{return JSON.parse(o)}catch{return console.error("[singlebase] guard predicate is not valid JSON:",o),null}},toAttribute:o=>o?JSON.stringify(o):null}})],exports.SinglebaseAuthGuard.prototype,"predicate",1);fe([r.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=fe([r.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var He=Object.defineProperty,ws=Object.getOwnPropertyDescriptor,ys=(o,a,t)=>a in o?He(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t,C=(o,a,t,e)=>{for(var s=e>1?void 0:e?ws(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&&He(a,t,s),s},Ss=(o,a,t)=>ys(o,a+"",t);const $s="profile_photo";var le,he,ce,de,ue,De;exports.SinglebaseAuthDisplay=(De=class extends f{constructor(){super(...arguments);h(this,le,"");h(this,he,"");h(this,ce,!1);h(this,de,"");h(this,ue,!1)}get path(){return l(this,le)}set path(t){c(this,le,t)}get fallback(){return l(this,he)}set fallback(t){c(this,he,t)}get avatar(){return l(this,ce)}set avatar(t){c(this,ce,t)}get alt(){return l(this,de)}set alt(t){c(this,de,t)}get imageFailed(){return l(this,ue)}set imageFailed(t){c(this,ue,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||$s);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
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:"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 fs=Object.defineProperty,vs=Object.getOwnPropertyDescriptor,ve=(o,n,t,e)=>{for(var s=e>1?void 0:e?vs(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&fs(n,t,s),s};const ws=["loading","authenticated","unauthenticated"];var oe,le,he,Ie;exports.SinglebaseAuthGuard=(Ie=class extends f{constructor(){super(...arguments);h(this,oe,"");h(this,le,null);h(this,he,"unauthenticated");p(this,"warnedFor",null)}get slot(){return l(this,oe)}set slot(t){c(this,oe,t)}get predicate(){return l(this,le)}set predicate(t){c(this,le,t)}get onMismatch(){return l(this,he)}set onMismatch(t){c(this,he,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=ws.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>`}},oe=new WeakMap,le=new WeakMap,he=new WeakMap,Ie);ve([r.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);ve([r.property({converter:{fromAttribute:o=>{if(!o)return null;try{return JSON.parse(o)}catch{return console.error("[singlebase] guard predicate is not valid JSON:",o),null}},toAttribute:o=>o?JSON.stringify(o):null}})],exports.SinglebaseAuthGuard.prototype,"predicate",1);ve([r.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=ve([r.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var Ke=Object.defineProperty,ys=Object.getOwnPropertyDescriptor,Ss=(o,n,t)=>n in o?Ke(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,P=(o,n,t,e)=>{for(var s=e>1?void 0:e?ys(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&Ke(n,t,s),s},$s=(o,n,t)=>Ss(o,n+"",t);const Es="profile_photo";var ce,de,ue,pe,ge,Fe;exports.SinglebaseAuthDisplay=(Fe=class extends f{constructor(){super(...arguments);h(this,ce,"");h(this,de,"");h(this,ue,!1);h(this,pe,"");h(this,ge,!1)}get path(){return l(this,ce)}set path(t){c(this,ce,t)}get fallback(){return l(this,de)}set fallback(t){c(this,de,t)}get avatar(){return l(this,ue)}set avatar(t){c(this,ue,t)}get alt(){return l(this,pe)}set alt(t){c(this,pe,t)}get imageFailed(){return l(this,ge)}set imageFailed(t){c(this,ge,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||Es);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
- >${Ee(t)}</span
937
- >`}},le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,De);Ss(exports.SinglebaseAuthDisplay,"styles",[...f.styles,i.css`
916
+ >${Pe(t)}</span
917
+ >`}},ce=new WeakMap,de=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,Fe);$s(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
- `]);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);C([r.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);C([r.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=C([r.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=Fe;exports.SettingsController=be;exports.defaultMessages=ve;exports.fullNameOf=$e;exports.initialsOf=Ee;exports.isGuestScreen=we;exports.isProtectedScreen=Ge;exports.isScreen=ye;exports.resolveMessages=Be;
976
- //# sourceMappingURL=authui-display-CLGFSqRi.cjs.map
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=Re;exports.SettingsController=fe;exports.defaultMessages=we;exports.fullNameOf=Ce;exports.initialsOf=Pe;exports.isGuestScreen=ye;exports.isProtectedScreen=Ve;exports.isScreen=Se;exports.resolveMessages=je;
956
+ //# sourceMappingURL=authui-display-CMVHTNFz.cjs.map