'use client';
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),j=require("react"),b=require("./sign-in-card.cjs"),p=require("./sign-in-form.cjs"),v=require("./sign-in-modal.cjs"),y=e=>e&&e.__esModule?e:{default:e},c=y(j);function g({mode:e="form",modalProps:a={},cardProps:f={},formProps:o={},autoMode:r=!1,organizationFlow:s=!1,showOrganizationSelector:l=!1,autoSelectOrganization:u=!1,...i}){const d=c.default.useMemo(()=>r?typeof window<"u"&&document.querySelector("[data-modal-backdrop]")?"modal":typeof window<"u"&&document.querySelector("[data-card-container]")?"card":"form":e,[r,e]),t=r?d:e,m=c.default.useMemo(()=>{if(!u)return i.organizationId;if(typeof window<"u"){const h=new URLSearchParams(window.location.search),x=h.get("org")||h.get("organization_id");if(x)return x;const I=window.location.hostname.split(".")[0];if(I&&I!=="www"&&I!=="app")return I}return i.organizationId},[u,i.organizationId]),S={...i,organizationId:m,showOrganizationSelector:s?l:!1},w={...o,showOrganizationSelector:s?l:o.showOrganizationSelector,variant:s?"default":o.variant};switch(t){case"modal":return n.jsx(v.SignInModal,{...S,...a,showOrganizationSelector:s?l:a.showOrganizationSelector});case"card":return n.jsx(b.SignInCard,{...S,...f,showOrganizationBranding:s});default:return n.jsx(p.SignInForm,{...S,...w})}}function z({organizationId:e,organizationName:a,organizationLogo:f,allowOrganizationSwitching:o=!1,showOrganizationInfo:r=!0,organizationWelcomeMessage:s,organizationAuthMethods:l,title:u,subtitle:i,methods:d,...t}){const m=u||(a?`Welcome to ${a}`:"Welcome back"),S=i||s||"Sign in to your account",w=l||d||["password","oauth","sso"];return n.jsx(g,{...t,organizationId:e,organizationFlow:!0,title:m,subtitle:S,methods:w,showOrganizationSelector:o,showBranding:r})}function O({organizations:e=[],defaultOrganizationId:a,showOrganizationLogos:f=!0,allowCreateOrganization:o=!1,onOrganizationSelected:r,...s}){const[l,u]=c.default.useState(a);return c.default.useCallback(i=>{u(i),r?.(i)},[r]),n.jsx(g,{...s,organizationId:l,organizationFlow:!0,showOrganizationSelector:!0,autoSelectOrganization:!1})}function C({organizationId:e,...a}){return n.jsx(z,{...a,organizationId:e,organizationAuthMethods:["sso","password"],title:"Single Sign-On",subtitle:"Sign in with your organization's SSO provider"})}function N(e){return n.jsx(g,{...e,methods:["magic-link","passkey","oauth","sso"],title:"Sign in securely",subtitle:"No password required"})}function k(e){return n.jsx(g,{...e,methods:["passkey","password","sso"],title:"Secure Sign In",subtitle:"Sign in with enhanced security"})}function M(e){return n.jsx(g,{...e,organizationFlow:!0,autoSelectOrganization:!0,showBranding:!0})}function B(e){return n.jsx(g,{...e,organizationFlow:!0,autoSelectOrganization:!0,showOrganizationSelector:!0})}function q({invitationToken:e,organizationName:a,inviterInfo:f,autoCreateAccount:o=!0,title:r,subtitle:s,onSuccess:l,...u}){const i=c.default.useMemo(()=>{try{const h=atob(e);return JSON.parse(h)}catch{return null}},[e]),d=a||i?.orgName||"the organization",t=f?.name||i?.inviterName,m=r||`Join ${d}`,S=s||(t?`${t} invited you to sign in to ${d}`:`You've been invited to sign in to ${d}`),w=c.default.useCallback(h=>{l?.(h)},[l]);return n.jsx(g,{...u,organizationId:i?.orgId,organizationFlow:!0,title:m,subtitle:S,showBranding:!0,onSuccess:w,formProps:{...u.formProps,footer:n.jsx("div",{className:"text-center text-sm text-default-500",children:o&&n.jsx("p",{children:"Don't have an account? One will be created for you."})})}})}function F({onSuccess:e,...a}){const[f,o]=c.default.useState("organization"),[r,s]=c.default.useState(a.organizationId),[l,u]=c.default.useState(null),i=c.default.useCallback(t=>{s(t),o("credentials")},[]),d=c.default.useCallback(t=>{t.status==="complete"?(o("complete"),e?.(t)):t.status==="needs_mfa"?(u(t),o("mfa")):e?.(t)},[e]);switch(c.default.useCallback(t=>{o("complete"),e?.(t)},[e]),f){case"organization":return r?(o("credentials"),null):n.jsx(O,{...a,onOrganizationSelected:i});case"mfa":return n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h2",{className:"text-xl font-semibold",children:"Two-Factor Authentication"}),n.jsx("p",{className:"text-default-500",children:"Complete your sign-in with MFA"})]})});case"complete":return n.jsxs("div",{className:"text-center space-y-4",children:[n.jsx("div",{className:"text-success-600 text-xl",children:"✓"}),n.jsx("h2",{className:"text-xl font-semibold",children:"Welcome back!"}),n.jsx("p",{className:"text-default-500",children:"You have been successfully signed in."})]});default:return n.jsx(z,{...a,organizationId:r,onSuccess:d})}}exports.InvitationSignIn=q;exports.MultiOrganizationSignIn=O;exports.OrganizationSignIn=z;exports.PasswordlessSignIn=N;exports.ProgressiveSignIn=F;exports.SSOSignIn=C;exports.SecureSignIn=k;exports.SignIn=g;exports.SubdomainSignIn=M;exports.URLBasedSignIn=B;
//# sourceMappingURL=sign-in.cjs.map
