import { localStorageProp as ie, prop as V, Use as x, html as i, attr as t, on as z, When as b, coalesce as h, Ensure as D, computedOf as g, Fragment as C, bind as ce, ForEach as le, Value as ee, OneOfValue as me } from "@tempots/dom";
import { t as ue, a as oe, u as W, S as $, b as se, c as T, P as N, E as G, N as H } from "../notice-Cpso9PgQ.js";
import { s as A, o as j, b as R, M as de } from "../modal-DJDeFIxV.js";
import { AuthI18n as q } from "../translations-ConAsIH1.js";
import { B as F, T as pe, I as he } from "../translations-g3qGTkzw.js";
import { classes as ge } from "@tempots/ui";
const X = {
  google: { name: "Google", icon: "logos:google-icon", color: "#4285f4" },
  github: { name: "GitHub", icon: "logos:github-icon", color: "#333" },
  apple: { name: "Apple", icon: "logos:apple", color: "#000" },
  facebook: { name: "Facebook", icon: "logos:facebook", color: "#1877f2" },
  twitter: { name: "Twitter", icon: "logos:twitter", color: "#1da1f2" },
  microsoft: {
    name: "Microsoft",
    icon: "logos:microsoft-icon",
    color: "#00a4ef"
  },
  discord: { name: "Discord", icon: "logos:discord-icon", color: "#5865f2" },
  linkedin: { name: "LinkedIn", icon: "logos:linkedin-icon", color: "#0077b5" },
  instagram: {
    name: "Instagram",
    icon: "logos:instagram-icon",
    color: "#e4405f"
  },
  tiktok: { name: "TikTok", icon: "logos:tiktok-icon", color: "#000" },
  snapchat: { name: "Snapchat", icon: "logos:snapchat-icon", color: "#fffc00" },
  reddit: { name: "Reddit", icon: "logos:reddit-icon", color: "#ff4500" },
  pinterest: {
    name: "Pinterest",
    icon: "logos:pinterest-icon",
    color: "#bd081c"
  },
  twitch: { name: "Twitch", icon: "logos:twitch", color: "#9146ff" },
  steam: { name: "Steam", icon: "logos:steam-icon", color: "#000" },
  epic: {
    name: "Epic Games",
    icon: "simple-icons:epicgames",
    color: "#313131"
  },
  playstation: {
    name: "PlayStation",
    icon: "logos:playstation-icon",
    color: "#003791"
  },
  xbox: { name: "Xbox", icon: "logos:xbox-icon", color: "#107c10" },
  whatsapp: { name: "WhatsApp", icon: "logos:whatsapp-icon", color: "#25d366" },
  wechat: { name: "WeChat", icon: "logos:wechat-icon", color: "#1aad19" },
  amazon: { name: "Amazon", icon: "logos:amazon-icon", color: "#ff9900" },
  yahoo: { name: "Yahoo", icon: "logos:yahoo-icon", color: "#720e9e" },
  paypal: { name: "PayPal", icon: "logos:paypal", color: "#0070ba" },
  x: { name: "X", icon: "simple-icons:x", color: "#000" }
};
function fe(e) {
  return X[e]?.name || e;
}
function Ie(e) {
  return X[e]?.icon || "mdi:account";
}
function Te(e) {
  return X[e]?.color || "#666";
}
function Ae(e, o = "Continue with {provider}") {
  return o.replace("{provider}", fe(e));
}
const I = {
  minLength: 8,
  requireUppercase: !0,
  requireLowercase: !0,
  requireNumbers: !0,
  requireSymbols: !1
};
function Ce(e) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
}
function be(e = 32) {
  const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  let c = "";
  for (let m = 0; m < e; m++)
    c += o.charAt(Math.floor(Math.random() * o.length));
  return c;
}
function ze(e, o, c, m = [], l = {}) {
  const s = {
    google: "https://accounts.google.com/oauth/authorize",
    github: "https://github.com/login/oauth/authorize",
    apple: "https://appleid.apple.com/auth/authorize",
    facebook: "https://www.facebook.com/v18.0/dialog/oauth",
    twitter: "https://twitter.com/i/oauth2/authorize",
    microsoft: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
    discord: "https://discord.com/api/oauth2/authorize",
    linkedin: "https://www.linkedin.com/oauth/v2/authorization",
    instagram: "https://api.instagram.com/oauth/authorize",
    tiktok: "https://www.tiktok.com/v2/auth/authorize",
    snapchat: "https://accounts.snapchat.com/accounts/oauth2/authorize",
    reddit: "https://www.reddit.com/api/v1/authorize",
    pinterest: "https://api.pinterest.com/oauth/",
    twitch: "https://id.twitch.tv/oauth2/authorize",
    steam: "https://steamcommunity.com/oauth/authorize",
    epic: "https://auth.epicgames.com/authorize",
    playstation: "https://auth.api.sonyentertainmentnetwork.com/oauth/authorize",
    xbox: "https://login.live.com/oauth20_authorize.srf",
    whatsapp: "https://web.whatsapp.com/oauth/authorize",
    wechat: "https://open.weixin.qq.com/connect/qrconnect",
    amazon: "https://www.amazon.com/ap/oa",
    yahoo: "https://api.login.yahoo.com/oauth2/request_auth",
    paypal: "https://www.paypal.com/signin/authorize",
    x: "https://api.twitter.com/oauth2/authorize"
  }, u = {
    google: ["openid", "email", "profile"],
    github: ["user:email"],
    apple: ["email", "name"],
    facebook: ["email"],
    twitter: ["users.read"],
    microsoft: ["openid", "email", "profile"],
    discord: ["identify", "email"],
    linkedin: ["r_liteprofile", "r_emailaddress"],
    instagram: ["user_profile", "user_media"],
    tiktok: ["user.info.basic", "user.external.id"],
    snapchat: ["user.info.basic", "user.external.id"],
    reddit: ["identity", "email"],
    pinterest: ["read_public", "read_relationships"],
    twitch: ["openid", "email", "profile"],
    steam: ["openid", "email", "profile"],
    epic: ["openid", "email", "profile"],
    playstation: ["openid", "email", "profile"],
    xbox: ["openid", "email", "profile"],
    whatsapp: ["openid", "email", "profile"],
    wechat: ["openid", "email", "profile"],
    amazon: ["openid", "email", "profile"],
    yahoo: ["openid", "email", "profile"],
    paypal: ["openid", "email", "profile"],
    x: ["openid", "email", "profile"]
  }, n = s[e];
  if (!n)
    throw new Error(`Unsupported provider: ${e}`);
  const r = m.length > 0 ? m : u[e], a = be(), f = new URLSearchParams({
    client_id: o,
    redirect_uri: c,
    scope: r.join(" "),
    state: a,
    response_type: "code",
    ...l
  });
  return `${n}?${f.toString()}`;
}
function Ee(e, o, c, m) {
  const l = window.open(
    e,
    `${o}_login`,
    "width=500,height=600,scrollbars=yes,resizable=yes"
  );
  if (!l) {
    m?.(new Error("Failed to open popup window"));
    return;
  }
  const s = setInterval(() => {
    l.closed && (clearInterval(s), m?.(new Error("Login cancelled")));
  }, 1e3), u = (n) => {
    n.origin === window.location.origin && (n.data.type === "SOCIAL_LOGIN_SUCCESS" ? (clearInterval(s), l.close(), window.removeEventListener("message", u), c?.(n.data.result)) : n.data.type === "SOCIAL_LOGIN_ERROR" && (clearInterval(s), l.close(), window.removeEventListener("message", u), m?.(new Error(n.data.error))));
  };
  window.addEventListener("message", u);
}
function Ue(e) {
  return e instanceof Error ? e.message : typeof e == "string" ? e : e && typeof e == "object" && "message" in e ? String(e.message) : "An unexpected error occurred";
}
function Ve() {
  return typeof window < "u" && typeof document < "u";
}
function Y({
  task: e,
  message: o,
  onStart: c,
  onEnd: m
}) {
  return async (l) => {
    c?.();
    const s = await ue({
      task: e != null ? () => e(l) : async () => null,
      errorMessage: o,
      errorPath: ["root"],
      validation: (u) => u != null ? oe.invalid({ message: u }) : oe.valid
    });
    return m?.(), s;
  };
}
function Z(e = I) {
  let o = A();
  return e.minLength && (o = o.min(
    e.minLength,
    `Password must be at least ${e.minLength} characters`
  )), e.requireUppercase && (o = o.regex(
    /[A-Z]/,
    "Password must contain at least one uppercase letter"
  )), e.requireLowercase && (o = o.regex(
    /[a-z]/,
    "Password must contain at least one lowercase letter"
  )), e.requireNumbers && (o = o.regex(
    /[0-9]/,
    "Password must contain at least one number"
  )), e.requireSymbols && (o = o.regex(
    /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,
    "Password must contain at least one special character"
  )), e.customValidation && (o = o.refine((c) => e.customValidation(c))), o;
}
const M = A().min(1, "Email is required").email("Please enter a valid email address");
function J(e) {
  const o = e ? Z(e) : A().refine(
    (c) => c.length > 0 ? null : "Password is required"
  );
  return j({
    email: M,
    password: o,
    rememberMe: R().default(!1)
  }).schema();
}
function K(e = I, o) {
  const c = Z(e), m = o?.showNameField !== !1, l = o?.showConfirmPassword !== !1, s = o?.showAcceptTermsAndConditions !== !1, u = {
    name: m ? A().min(1, "Name is required").optional() : A().optional(),
    email: M,
    password: c,
    // Always require confirmPassword as string to match SignUpData interface
    // When not shown, it should accept any value (including empty string)
    confirmPassword: l ? A().min(1, "Please confirm your password") : A(),
    // Accept any string value when not shown
    acceptTerms: s ? R().refine(
      (r) => r === !0,
      "You must accept the terms and conditions"
    ) : R().default(!0)
    // Default to true when not shown
  }, n = j(u);
  return l ? n.refine(
    (r) => r.password === r.confirmPassword ? null : "Passwords don't match",
    { path: ["confirmPassword"] }
  ).schema() : n.schema();
}
const ae = j({
  email: M
}).schema(), Fe = J(), Me = K(), Oe = {
  signIn: J,
  signUp: K,
  resetPassword: () => ae
};
function Ne(e) {
  const o = M.validate(e);
  return o.success ? null : o.errors[0]?.message || "Invalid email";
}
function Re(e, o = I) {
  const m = Z(o).validate(e);
  return m.success ? null : m.errors[0]?.message || "Invalid password";
}
function Q(e, o = I) {
  const c = {
    length: e.length >= (o.minLength || 8),
    uppercase: /[A-Z]/.test(e),
    lowercase: /[a-z]/.test(e),
    numbers: /[0-9]/.test(e),
    symbols: /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(e),
    custom: o.customValidation ? o.customValidation(e) === null : e.length > 0
    // For consistency, fail if password is empty
  }, m = [
    !0,
    // length is always enabled
    o.requireUppercase,
    o.requireLowercase,
    o.requireNumbers,
    o.requireSymbols,
    !!o.customValidation
  ].filter(Boolean).length, l = [
    c.length,
    o.requireUppercase ? c.uppercase : null,
    o.requireLowercase ? c.lowercase : null,
    o.requireNumbers ? c.numbers : null,
    o.requireSymbols ? c.symbols : null,
    o.customValidation ? c.custom : null
  ].filter((n) => n === !0).length, s = m > 0 ? Math.round(l / m * 100) : 0;
  let u;
  return s < 40 ? u = "weak" : s < 60 ? u = "fair" : s < 80 ? u = "good" : u = "strong", { strength: u, score: s, checks: c };
}
const re = () => ie({
  key: "bui_auth_email",
  defaultValue: null
});
function we({
  onSignIn: e,
  passwordRules: o,
  labels: c,
  showRememberMe: m
}) {
  const l = V(!1), s = re(), u = J(o), n = W({
    schema: u,
    onSubmit: Y({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        l.set(!0), n.controller.disable();
      },
      onEnd: () => {
        l.set(!1), n.controller.enable();
      }
    }),
    initialValue: {
      email: "",
      password: ""
    }
  }), { controller: r, submit: a } = n;
  l.on(r.setDisabled);
  const f = r.field("email"), w = r.field("password");
  return s.on((_) => {
    _ != null && f.change(_);
  }), f.signal.on((_) => {
    s.value != null && (s.value = _);
  }), x(
    q,
    (_) => (
      // Email/Password form
      i.form(
        t.class("bc-auth-form__form"),
        z.submit(a),
        $(
          t.class("bc-auth-form__fields"),
          D(
            r.error,
            (k) => H(
              { variant: "danger", tone: "prominent", role: "alert" },
              i.div(k)
            )
          ),
          // Email field
          T(G, {
            controller: f,
            label: h(c?.emailLabel, _.$.emailLabel)
          }),
          // Password field
          T(N, {
            controller: w,
            label: h(c?.passwordLabel, _.$.passwordLabel)
          }),
          // Remember me checkbox
          b(
            m ?? !0,
            () => i.div(
              t.class("bc-auth-form__remember-me"),
              i.label(
                t.class("bc-auth-form__checkbox-label"),
                se({
                  value: s.map((k) => k != null),
                  after: i.span(
                    h(c?.rememberMeLabel, _.$.rememberMeLabel)
                  ),
                  onChange: (k) => {
                    k ? s.value = f.signal.value ?? "" : s.value = null;
                  }
                })
              )
            )
          )
        ),
        // Submit button
        F(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: l,
            disabled: r.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(c?.signInButton, _.$.signInButton)
        )
      )
    )
  );
}
function _e({
  password: e,
  rules: o = I,
  showLabel: c = !0,
  className: m
}) {
  const l = g(e)((a) => !a || a.length === 0 ? {
    strength: "weak",
    score: 0,
    checks: {
      length: !1,
      uppercase: !1,
      lowercase: !1,
      numbers: !1,
      symbols: !1,
      custom: !1
    }
  } : Q(a, o)), s = l.map((a) => a.strength), u = l.map((a) => a.score), n = l.map((a) => a.checks), r = g(
    s,
    m
  )((a, f) => [
    "bc-password-strength",
    `bc-password-strength--${a}`,
    f
  ].filter(Boolean).join(" "));
  return i.div(
    t.class(r),
    // Strength bar
    i.div(
      t.class("bc-password-strength__bar"),
      i.div(
        t.class("bc-password-strength__fill"),
        t.style(u.map((a) => `width: ${a}%`))
      )
    ),
    // Strength label (optional)
    b(
      c,
      () => x(
        q,
        (a) => i.div(
          t.class("bc-password-strength__label"),
          g(
            s,
            a
          )((f, w) => {
            switch (f) {
              case "weak":
                return w.passwordStrengthWeak;
              case "fair":
                return w.passwordStrengthFair;
              case "good":
                return w.passwordStrengthGood;
              case "strong":
                return w.passwordStrengthStrong;
              default:
                return w.passwordStrengthWeak;
            }
          })
        )
      )
    ),
    // Requirements checklist
    i.div(
      t.class("bc-password-strength__requirements"),
      // Length requirement
      b(
        o.minLength !== void 0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(n)(
              (a) => a.length ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(n)((a) => a.length ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            `At least ${o.minLength} characters`
          )
        )
      ),
      // Uppercase requirement
      b(
        o.requireUppercase === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(n)(
              (a) => a.uppercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(n)((a) => a.uppercase ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One uppercase letter"
          )
        )
      ),
      // Lowercase requirement
      b(
        o.requireLowercase === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(n)(
              (a) => a.lowercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(n)((a) => a.lowercase ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One lowercase letter"
          )
        )
      ),
      // Numbers requirement
      b(
        o.requireNumbers === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(n)(
              (a) => a.numbers ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(n)((a) => a.numbers ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One number"
          )
        )
      ),
      // Symbols requirement
      b(
        o.requireSymbols === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(n)(
              (a) => a.symbols ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(n)((a) => a.symbols ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One special character"
          )
        )
      )
    )
  );
}
function De({
  password: e,
  rules: o = I,
  className: c
}) {
  const m = g(e)((n) => !n || n.length === 0 ? { strength: "weak", score: 0 } : Q(n, o)), l = m.map((n) => n.strength), s = m.map((n) => n.score), u = g(
    l,
    c
  )((n, r) => [
    "bc-password-strength-bar",
    `bc-password-strength-bar--${n}`,
    r
  ].filter(Boolean).join(" "));
  return i.div(
    t.class(u),
    i.div(
      t.class("bc-password-strength-bar__fill"),
      t.style(s.map((n) => `width: ${n}%`))
    )
  );
}
function We({
  password: e,
  rules: o = I,
  className: c
}) {
  const m = g(e)((s) => !s || s.length === 0 ? "weak" : Q(s, o).strength), l = g(
    m,
    c
  )((s, u) => [
    "bc-password-strength-text",
    `bc-password-strength-text--${s}`,
    u
  ].filter(Boolean).join(" "));
  return C(
    x(
      q,
      (s) => i.span(
        t.class(l),
        g(
          m,
          s
        )((u, n) => {
          switch (u) {
            case "weak":
              return n.passwordStrengthWeak;
            case "fair":
              return n.passwordStrengthFair;
            case "good":
              return n.passwordStrengthGood;
            case "strong":
              return n.passwordStrengthStrong;
            default:
              return n.passwordStrengthWeak;
          }
        })
      )
    )
  );
}
function Le({
  passwordRules: e,
  labels: o,
  initialEmail: c,
  initialName: m,
  showPasswordStrength: l,
  onSignUp: s,
  showNameField: u,
  showConfirmPassword: n,
  showAcceptTermsAndConditions: r,
  termsAndConditions: a
}) {
  const f = V(!1), w = e || I, _ = K(w, {
    showNameField: u !== !1,
    showConfirmPassword: n !== !1,
    showAcceptTermsAndConditions: r !== !1
  }), k = W({
    schema: _,
    onSubmit: Y({
      task: s != null ? (v) => s({
        email: v.email,
        password: v.password,
        name: v.name,
        acceptTerms: v.acceptTerms
      }) : void 0,
      message: "Reset password failed",
      onStart: () => {
        f.set(!0), k.controller.disable();
      },
      onEnd: () => {
        f.set(!1), k.controller.enable();
      }
    }),
    initialValue: {
      name: m ?? "",
      email: c ?? "",
      password: "",
      confirmPassword: "",
      acceptTerms: !1
    }
  }), { controller: y, submit: B } = k;
  f.on(y.setDisabled);
  const S = y.field("name"), E = y.field("email"), U = y.field("password"), O = y.field("confirmPassword"), P = y.field("acceptTerms");
  return x(
    q,
    (v) => (
      // Registration form
      i.form(
        t.class("bc-auth-form__form"),
        z.submit(B),
        $(
          t.class("bc-auth-form__fields"),
          D(
            y.error,
            (L) => H(
              { variant: "danger", tone: "prominent", role: "alert" },
              i.div(L)
            )
          ),
          // Name field (optional)
          b(
            u !== !1,
            () => T(pe, {
              controller: S.transform(
                (L) => L ?? "",
                (L) => L === "" ? void 0 : L
              ),
              label: h(o?.nameLabel, v.$.nameLabel)
            })
          ),
          // Email field
          T(G, {
            controller: E,
            label: h(o?.emailLabel, v.$.emailLabel)
          }),
          // Password field
          T(N, {
            controller: U,
            label: h(o?.passwordLabel, v.$.passwordLabel)
          }),
          // Password strength indicator
          b(
            l ?? !1,
            () => _e({
              password: U.signal,
              rules: w,
              showLabel: !0
            })
          ),
          // Confirm password field
          b(
            n ?? !1,
            () => T(N, {
              controller: O,
              label: h(
                o?.confirmPasswordLabel,
                v.$.confirmPasswordLabel
              )
            })
          ),
          // Terms acceptance checkbox
          b(
            r ?? !1,
            () => i.div(
              t.class("bc-auth-form__terms"),
              i.label(
                t.class("bc-auth-form__checkbox-label"),
                se({
                  value: P.signal.map((L) => L ?? !1),
                  onChange: (L) => P.change(L)
                }),
                i.span(
                  a || h(o?.acceptTermsLabel, v.$.acceptTermsLabel)
                )
              ),
              b(
                P.errorVisible,
                () => i.div(
                  t.class("bc-auth-form__field-error"),
                  P.error.map((L) => L || "")
                )
              )
            )
          )
        ),
        // Submit button
        F(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: f,
            disabled: y.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(o?.signUpButton, v.$.signUpButton)
        )
      )
    )
  );
}
function ke({
  onResetPassword: e,
  labels: o = {}
}) {
  const c = re(), m = V(!1), l = W({
    schema: ae,
    onSubmit: Y({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        m.set(!0), l.controller.disable();
      },
      onEnd: () => {
        m.set(!1), l.controller.enable();
      }
    }),
    initialValue: {
      email: ""
    }
  }), { controller: s, submit: u } = l;
  m.on(s.setDisabled);
  const n = s.field("email");
  return c.on((r) => {
    r != null && n.change(r);
  }), x(
    q,
    (r) => (
      // Reset password form
      i.form(
        t.class("bc-auth-form__form"),
        D(
          s.error,
          (a) => H(
            { variant: "danger", tone: "prominent", role: "alert" },
            i.div(a)
          )
        ),
        // Description
        i.p(
          t.class("bc-auth-form__description"),
          h(o?.resetPasswordDescription, r.$.resetPasswordDescription)
        ),
        z.submit(u),
        $(
          t.class("bc-auth-form__fields"),
          // Email field
          T(G, {
            controller: n,
            label: h(o?.emailLabel, r.$.emailLabel)
          })
        ),
        // Submit button
        F(
          {
            loading: m,
            type: "submit",
            variant: "filled",
            color: "primary",
            disabled: s.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(o?.resetPasswordButton, r.$.resetPasswordButton)
        )
      )
    )
  );
}
function p({
  provider: e,
  onClick: o,
  size: c = "md",
  name: m,
  icon: l,
  color: s,
  flow: u,
  labels: n
}) {
  return F(
    {
      type: "button",
      variant: "filled",
      size: c,
      color: s,
      onClick: async () => {
        if (o)
          try {
            u === "popup" ? await o() : await o();
          } catch (a) {
            console.error(
              `Social login error for ${e} (${u || "redirect"} flow):`,
              a
            );
          }
      },
      roundedness: "full"
    },
    t.class("bc-social-login-button"),
    t.class(
      g(e)((a) => `bc-social-login-button--${a}`)
    ),
    i.span(
      t.class("bc-social-login-button__inner"),
      i.span(
        t.class("bc-social-login-button__icon"),
        he({ icon: l, size: c }, t.class("bc-social-login-button__icon-inner"))
      ),
      x(
        q,
        (a) => i.span(
          t.class("bc-social-login-button__label"),
          ce(
            h(n?.continueWithProvider, a.$.continueWithProvider)
          )(m)
        )
      )
    )
  );
}
function ve({
  providers: e,
  onProviderClick: o,
  size: c = "md",
  className: m
}) {
  return $(
    t.class("bc-social-login-buttons"),
    t.class(m),
    le(
      e,
      (l) => p({
        provider: l.$.provider,
        flow: l.$.flow,
        color: l.map(
          ({ provider: s }) => d[s].color
        ),
        name: l.map(({ provider: s }) => d[s].name),
        icon: l.map(({ provider: s }) => d[s].icon),
        onClick: async () => {
          o && await o(l.$.provider.value);
        },
        size: c
      })
    )
  );
}
const d = {
  // Core
  google: {
    name: "Google",
    icon: "logos:google-icon",
    color: "red"
  },
  github: {
    name: "GitHub",
    icon: "logos:github-icon",
    color: "black"
  },
  apple: {
    name: "Apple",
    icon: "logos:apple",
    color: "stone"
    // using stone to differentiate from GitHub/X
  },
  facebook: {
    name: "Facebook",
    icon: "logos:facebook",
    color: "blue"
  },
  twitter: {
    name: "Twitter",
    icon: "logos:twitter",
    color: "sky"
  },
  x: {
    name: "X",
    icon: "logos:x",
    color: "zinc"
    // avoids duplicate black
  },
  microsoft: {
    name: "Microsoft",
    icon: "logos:microsoft-icon",
    color: "amber"
  },
  discord: {
    name: "Discord",
    icon: "logos:discord-icon",
    color: "indigo"
  },
  linkedin: {
    name: "LinkedIn",
    icon: "logos:linkedin-icon",
    color: "cyan"
  },
  // Social / Media
  instagram: {
    name: "Instagram",
    icon: "logos:instagram-icon",
    color: "fuchsia"
  },
  tiktok: {
    name: "TikTok",
    icon: "logos:tiktok-icon",
    color: "teal"
  },
  snapchat: {
    name: "Snapchat",
    icon: "streamline-logos:snapchat-logo-solid",
    color: "yellow"
  },
  reddit: {
    name: "Reddit",
    icon: "logos:reddit-icon",
    color: "orange"
  },
  pinterest: {
    name: "Pinterest",
    icon: "logos:pinterest",
    color: "rose"
  },
  // Gaming / Entertainment
  twitch: {
    name: "Twitch",
    icon: "logos:twitch",
    color: "purple"
  },
  steam: {
    name: "Steam",
    icon: "logos:steam",
    color: "slate"
  },
  epic: {
    name: "Epic Games",
    icon: "streamline-logos:epic-games-logo-solid",
    color: "neutral"
  },
  playstation: {
    name: "PlayStation",
    icon: "streamline-logos:playstation-logo-solid",
    color: "violet"
  },
  xbox: {
    name: "Xbox",
    icon: "streamline-logos:xbox-live-logo-solid",
    color: "green"
  },
  // Messaging
  whatsapp: {
    name: "WhatsApp",
    icon: "logos:whatsapp-icon",
    color: "emerald"
  },
  wechat: {
    name: "WeChat",
    icon: "streamline-logos:wechat-logo",
    color: "lime"
  },
  // Other Identity
  amazon: {
    name: "Amazon",
    icon: "streamline-logos:amazon-logo-solid",
    color: "red"
    // distinct warm tone (not used elsewhere here)
  },
  yahoo: {
    name: "Yahoo",
    icon: "logos:yahoo",
    color: "rose"
    // unique variation for Yahoo
  },
  paypal: {
    name: "PayPal",
    icon: "logos:paypal",
    color: "blue"
    // distinct deep blue tone (not Facebook’s exact blue)
  }
}, Ge = (e) => p({
  ...e,
  ...d.google,
  provider: "google"
}), He = (e) => p({
  ...e,
  ...d.github,
  provider: "github"
}), je = (e) => p({
  ...e,
  ...d.apple,
  provider: "apple"
}), Xe = (e) => p({
  ...e,
  ...d.facebook,
  provider: "facebook"
}), Ye = (e) => p({
  ...e,
  ...d.x,
  provider: "x"
}), Ze = (e) => p({
  ...e,
  ...d.twitter,
  provider: "twitter"
}), Je = (e) => p({
  ...e,
  ...d.microsoft,
  provider: "microsoft"
}), Ke = (e) => p({
  ...e,
  ...d.discord,
  provider: "discord"
}), Qe = (e) => p({
  ...e,
  ...d.linkedin,
  provider: "linkedin"
}), eo = (e) => p({
  ...e,
  ...d.instagram,
  provider: "instagram"
}), oo = (e) => p({
  ...e,
  ...d.tiktok,
  provider: "tiktok"
}), to = (e) => p({
  ...e,
  ...d.snapchat,
  provider: "snapchat"
}), no = (e) => p({
  ...e,
  ...d.reddit,
  provider: "reddit"
}), so = (e) => p({
  ...e,
  ...d.pinterest,
  provider: "pinterest"
}), ao = (e) => p({
  ...e,
  ...d.twitch,
  provider: "twitch"
}), ro = (e) => p({
  ...e,
  ...d.steam,
  provider: "steam"
}), io = (e) => p({
  ...e,
  ...d.epic,
  provider: "epic"
}), co = (e) => p({
  ...e,
  ...d.playstation,
  provider: "playstation"
}), lo = (e) => p({
  ...e,
  ...d.xbox,
  provider: "xbox"
}), mo = (e) => p({
  ...e,
  ...d.whatsapp,
  provider: "whatsapp"
}), uo = (e) => p({
  ...e,
  ...d.wechat,
  provider: "wechat"
}), po = (e) => p({
  ...e,
  ...d.amazon,
  provider: "amazon"
}), ho = (e) => p({
  ...e,
  ...d.yahoo,
  provider: "yahoo"
}), go = (e) => p({
  ...e,
  ...d.paypal,
  provider: "paypal"
});
function te({ providers: e }) {
  return $(
    ve({
      providers: e
    })
  );
}
function ye({
  mode: e,
  socialProviders: o,
  initialName: c,
  initialEmail: m,
  passwordRules: l,
  showRememberMe: s,
  showSocialDivider: u,
  showPasswordStrength: n,
  labels: r,
  onSignIn: a,
  onSignUp: f,
  onResetPassword: w,
  onModeChange: _,
  // onSocialLogin,
  showContainer: k
}, ...y) {
  const B = e != null ? ee.deriveProp(e) : V("signin");
  return B.on((S) => _?.(S)), x(q, (S) => {
    function E() {
      const P = h(r?.hasAccountLink, S.$.hasAccountLink);
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        z.click(() => B.set("signin")),
        P
      );
    }
    function U() {
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        z.click(() => B.set("signup")),
        h(r?.noAccountLink, S.$.noAccountLink)
      );
    }
    function O() {
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        z.click(() => B.set("reset-password")),
        h(r?.forgotPasswordLink, S.$.forgotPasswordLink)
      );
    }
    return i.div(
      ge({
        "bc-auth-container": !0,
        "bc-auth-container--styled": ee.map(k ?? !0, (P) => P)
      }),
      t.class(B.map((P) => `bc-auth-container--${P}`)),
      t.class("bc-auth-form"),
      me(B, {
        signin: () => C(
          i.h2(
            t.class("bc-auth-form__title"),
            h(r?.signInTitle, S.$.signInTitle)
          ),
          o != null ? C(
            te({ providers: o }),
            b(u ?? !1, ne)
          ) : null,
          we({
            onSignIn: a,
            showRememberMe: s,
            passwordRules: l,
            labels: {
              emailLabel: r?.emailLabel,
              passwordLabel: r?.passwordLabel,
              rememberMeLabel: r?.rememberMeLabel,
              signInButton: r?.signInButton,
              forgotPasswordLink: r?.forgotPasswordLink,
              noAccountLink: r?.noAccountLink
            }
          }),
          $(
            t.class("bc-auth-form__footer"),
            U(),
            O()
          )
        ),
        signup: () => C(
          i.h2(
            t.class("bc-auth-form__title"),
            h(r?.signUpTitle, S.$.signUpTitle)
          ),
          o != null ? C(
            te({ providers: o }),
            b(u ?? !1, ne)
          ) : null,
          Le({
            labels: {
              nameLabel: r?.nameLabel,
              emailLabel: r?.emailLabel,
              passwordLabel: r?.passwordLabel,
              confirmPasswordLabel: r?.confirmPasswordLabel,
              acceptTermsLabel: r?.acceptTermsLabel,
              signUpButton: r?.signUpButton,
              hasAccountLink: r?.hasAccountLink
            },
            initialEmail: m,
            initialName: c,
            onSignUp: f,
            passwordRules: l,
            showPasswordStrength: n
          }),
          $(t.class("bc-auth-form__footer"), E())
        ),
        "reset-password": () => C(
          i.h2(
            t.class("bc-auth-form__title"),
            h(r?.resetPasswordTitle, S.$.resetPasswordTitle)
          ),
          ke({
            labels: {
              backToSignInLink: r?.backToSignInLink,
              emailLabel: r?.emailLabel,
              resetPasswordButton: r?.resetPasswordButton,
              resetPasswordDescription: r?.resetPasswordDescription
            },
            onResetPassword: w
          }),
          $(t.class("bc-auth-form__footer"), E())
        )
      }),
      ...y
    );
  });
}
function fo(e) {
  return de(
    {
      size: "sm",
      dismissable: !0,
      showCloseButton: !0
    },
    (o, c) => e(
      (m) => o({
        body: ye({ showContainer: !1, ...m }),
        header: x(
          q,
          (l) => h(m.modalTitle, l.$.authenticationTitle)
        )
      })
    )
  );
}
function ne({
  labels: e,
  className: o
} = {}) {
  return i.div(
    t.class("bc-auth-divider"),
    t.class(o),
    i.div(t.class("bc-auth-divider__line")),
    x(
      q,
      (c) => i.span(
        t.class("bc-auth-divider__text"),
        h(e?.text, c.$.orDivider)
      )
    ),
    i.div(t.class("bc-auth-divider__line"))
  );
}
export {
  po as AmazonLoginButton,
  je as AppleLoginButton,
  ye as AuthContainer,
  ne as AuthDivider,
  fo as AuthModal,
  Ke as DiscordLoginButton,
  io as EpicLoginButton,
  Xe as FacebookLoginButton,
  He as GitHubLoginButton,
  Ge as GoogleLoginButton,
  eo as InstagramLoginButton,
  Qe as LinkedInLoginButton,
  Je as MicrosoftLoginButton,
  De as PasswordStrengthBar,
  _e as PasswordStrengthIndicator,
  We as PasswordStrengthText,
  go as PayPalLoginButton,
  so as PinterestLoginButton,
  co as PlayStationLoginButton,
  no as RedditLoginButton,
  ke as ResetPasswordForm,
  we as SignInForm,
  Le as SignUpForm,
  to as SnapchatLoginButton,
  p as SocialLoginButton,
  ve as SocialLoginButtons,
  te as SocialProviders,
  ro as SteamLoginButton,
  oo as TiktokLoginButton,
  ao as TwitchLoginButton,
  Ze as TwitterLoginButton,
  uo as WeChatLoginButton,
  mo as WhatsAppLoginButton,
  Ye as XLoginButtin,
  lo as XboxLoginButton,
  ho as YahooLoginButton,
  Oe as authSchemas,
  Q as calculatePasswordStrength,
  Z as createPasswordSchema,
  J as createSignInSchema,
  K as createSignUpSchema,
  ze as createSocialLoginUrl,
  I as defaultPasswordRules,
  Fe as defaultSignInSchema,
  Me as defaultSignUpSchema,
  M as emailSchema,
  Ue as formatAuthError,
  fe as formatProviderName,
  Ae as formatSocialLoginText,
  be as generateRandomString,
  Te as getProviderColor,
  Ie as getProviderIcon,
  Ve as isBrowser,
  Ce as isValidEmail,
  Ee as openSocialLoginPopup,
  X as providerInfo,
  Y as requestToControllerValidation,
  ae as resetPasswordSchema,
  d as socialProviderInfo,
  re as useAuthEmailProp,
  Ne as validateEmail,
  Re as validatePassword
};
