import { localStorageProp as re, prop as E, Use as P, html as i, OnDispose as U, attr as t, on as T, When as L, coalesce as h, Ensure as N, computedOf as f, bind as ie, ForEach as ce, Value as Q, OneOfValue as le, Fragment as A } from "@tempots/dom";
import { t as me, a as ee, u as R, S as q, b as se, c as $, P as M, E as W, N as G } from "../notice-CQZseCQs.js";
import { s as I, o as H, b as D, M as ue } from "../modal-BD76Rve3.js";
import { AuthI18n as x } from "../translations-DXLmnUiB.js";
import { B as O, T as de, I as pe } from "../translations-djDSPqdb.js";
import { classes as he } from "@tempots/ui";
const j = {
  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 ge(e) {
  return j[e]?.name || e;
}
function $e(e) {
  return j[e]?.icon || "mdi:account";
}
function Ie(e) {
  return j[e]?.color || "#666";
}
function Te(e, o = "Continue with {provider}") {
  return o.replace("{provider}", ge(e));
}
const B = {
  minLength: 8,
  requireUppercase: !0,
  requireLowercase: !0,
  requireNumbers: !0,
  requireSymbols: !1
};
function Ae(e) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
}
function fe(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 Ce(e, o, c, m = [], l = {}) {
  const a = {
    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"
  }, s = {
    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 = a[e];
  if (!n)
    throw new Error(`Unsupported provider: ${e}`);
  const u = m.length > 0 ? m : s[e], r = fe(), w = new URLSearchParams({
    client_id: o,
    redirect_uri: c,
    scope: u.join(" "),
    state: r,
    response_type: "code",
    ...l
  });
  return `${n}?${w.toString()}`;
}
function ze(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 a = setInterval(() => {
    l.closed && (clearInterval(a), m?.(new Error("Login cancelled")));
  }, 1e3), s = (n) => {
    n.origin === window.location.origin && (n.data.type === "SOCIAL_LOGIN_SUCCESS" ? (clearInterval(a), l.close(), window.removeEventListener("message", s), c?.(n.data.result)) : n.data.type === "SOCIAL_LOGIN_ERROR" && (clearInterval(a), l.close(), window.removeEventListener("message", s), m?.(new Error(n.data.error))));
  };
  window.addEventListener("message", s);
}
function Ee(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 Ue() {
  return typeof window < "u" && typeof document < "u";
}
function X({
  task: e,
  message: o,
  onStart: c,
  onEnd: m
}) {
  return async (l) => {
    c?.();
    const a = await me({
      task: e != null ? () => e(l) : async () => null,
      errorMessage: o,
      errorPath: ["root"],
      validation: (s) => s != null ? ee.invalid({ message: s }) : ee.valid
    });
    return m?.(), a;
  };
}
function Y(e = B) {
  let o = I();
  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 V = I().min(1, "Email is required").email("Please enter a valid email address");
function Z(e) {
  const o = e ? Y(e) : I().refine(
    (c) => c.length > 0 ? null : "Password is required"
  );
  return H({
    email: V,
    password: o,
    rememberMe: D().default(!1)
  }).schema();
}
function J(e = B, o) {
  const c = Y(e), m = o?.showNameField !== !1, l = o?.showConfirmPassword !== !1, a = o?.showAcceptTermsAndConditions !== !1, s = {
    name: m ? I().min(1, "Name is required").optional() : I().optional(),
    email: V,
    password: c,
    // Always require confirmPassword as string to match SignUpData interface
    // When not shown, it should accept any value (including empty string)
    confirmPassword: l ? I().min(1, "Please confirm your password") : I(),
    // Accept any string value when not shown
    acceptTerms: a ? D().refine(
      (u) => u === !0,
      "You must accept the terms and conditions"
    ) : D().default(!0)
    // Default to true when not shown
  }, n = H(s);
  return l ? n.refine(
    (u) => u.password === u.confirmPassword ? null : "Passwords don't match",
    { path: ["confirmPassword"] }
  ).schema() : n.schema();
}
const ne = H({
  email: V
}).schema(), Oe = Z(), Ve = J(), Fe = {
  signIn: Z,
  signUp: J,
  resetPassword: () => ne
};
function Me(e) {
  const o = V.validate(e);
  return o.success ? null : o.errors[0]?.message || "Invalid email";
}
function De(e, o = B) {
  const m = Y(o).validate(e);
  return m.success ? null : m.errors[0]?.message || "Invalid password";
}
function K(e, o = B) {
  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, a = m > 0 ? Math.round(l / m * 100) : 0;
  let s;
  return a < 40 ? s = "weak" : a < 60 ? s = "fair" : a < 80 ? s = "good" : s = "strong", { strength: s, score: a, checks: c };
}
const ae = () => re({
  key: "bui_auth_email",
  defaultValue: null
});
function be({
  onSignIn: e,
  passwordRules: o,
  labels: c,
  showRememberMe: m
}) {
  const l = E(!1), a = ae(), s = Z(o), n = R({
    schema: s,
    onSubmit: X({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        l.set(!0), n.controller.disable();
      },
      onEnd: () => {
        l.set(!1), n.controller.enable();
      }
    }),
    initialValue: {
      email: "",
      password: ""
    }
  }), { controller: u, submit: r } = n;
  l.on(u.setDisabled);
  const w = u.field("email"), _ = u.field("password");
  return a.on((g) => {
    g != null && w.change(g);
  }), w.signal.on((g) => {
    a.value != null && (a.value = g);
  }), P(
    x,
    (g) => (
      // Email/Password form
      i.form(
        U(u.dispose, a.dispose, l.dispose),
        t.class("bc-auth-form__form"),
        T.submit(r),
        q(
          t.class("bc-auth-form__fields"),
          N(
            u.error,
            (b) => G(
              { variant: "danger", tone: "prominent", role: "alert" },
              i.div(b)
            )
          ),
          // Email field
          $(W, {
            controller: w,
            label: h(c?.emailLabel, g.$.emailLabel)
          }),
          // Password field
          $(M, {
            controller: _,
            label: h(c?.passwordLabel, g.$.passwordLabel)
          }),
          // Remember me checkbox
          L(
            m ?? !0,
            () => i.div(
              t.class("bc-auth-form__remember-me"),
              i.label(
                t.class("bc-auth-form__checkbox-label"),
                se({
                  value: a.map((b) => b != null),
                  after: i.span(
                    h(c?.rememberMeLabel, g.$.rememberMeLabel)
                  ),
                  onChange: (b) => {
                    b ? a.value = w.signal.value ?? "" : a.value = null;
                  }
                })
              )
            )
          )
        ),
        // Submit button
        O(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: l,
            disabled: u.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(c?.signInButton, g.$.signInButton)
        )
      )
    )
  );
}
function we({
  password: e,
  rules: o = B,
  showLabel: c = !0,
  className: m
}) {
  const l = f(e)((r) => !r || r.length === 0 ? {
    strength: "weak",
    score: 0,
    checks: {
      length: !1,
      uppercase: !1,
      lowercase: !1,
      numbers: !1,
      symbols: !1,
      custom: !1
    }
  } : K(r, o)), a = l.map((r) => r.strength), s = l.map((r) => r.score), n = l.map((r) => r.checks), u = f(
    a,
    m
  )((r, w) => [
    "bc-password-strength",
    `bc-password-strength--${r}`,
    w
  ].filter(Boolean).join(" "));
  return i.div(
    t.class(u),
    // Strength bar
    i.div(
      t.class("bc-password-strength__bar"),
      i.div(
        t.class("bc-password-strength__fill"),
        t.style(s.map((r) => `width: ${r}%`))
      )
    ),
    // Strength label (optional)
    L(
      c,
      () => P(
        x,
        (r) => i.div(
          t.class("bc-password-strength__label"),
          f(
            a,
            r
          )((w, _) => {
            switch (w) {
              case "weak":
                return _.passwordStrengthWeak;
              case "fair":
                return _.passwordStrengthFair;
              case "good":
                return _.passwordStrengthGood;
              case "strong":
                return _.passwordStrengthStrong;
              default:
                return _.passwordStrengthWeak;
            }
          })
        )
      )
    ),
    // Requirements checklist
    i.div(
      t.class("bc-password-strength__requirements"),
      // Length requirement
      L(
        o.minLength !== void 0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            f(n)(
              (r) => r.length ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            f(n)((r) => r.length ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            `At least ${o.minLength} characters`
          )
        )
      ),
      // Uppercase requirement
      L(
        o.requireUppercase === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            f(n)(
              (r) => r.uppercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            f(n)((r) => r.uppercase ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One uppercase letter"
          )
        )
      ),
      // Lowercase requirement
      L(
        o.requireLowercase === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            f(n)(
              (r) => r.lowercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            f(n)((r) => r.lowercase ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One lowercase letter"
          )
        )
      ),
      // Numbers requirement
      L(
        o.requireNumbers === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            f(n)(
              (r) => r.numbers ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            f(n)((r) => r.numbers ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One number"
          )
        )
      ),
      // Symbols requirement
      L(
        o.requireSymbols === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            f(n)(
              (r) => r.symbols ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            f(n)((r) => r.symbols ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One special character"
          )
        )
      )
    )
  );
}
function Ne({
  password: e,
  rules: o = B,
  className: c
}) {
  const m = f(e)((n) => !n || n.length === 0 ? { strength: "weak", score: 0 } : K(n, o)), l = m.map((n) => n.strength), a = m.map((n) => n.score), s = f(
    l,
    c
  )((n, u) => [
    "bc-password-strength-bar",
    `bc-password-strength-bar--${n}`,
    u
  ].filter(Boolean).join(" "));
  return i.div(
    t.class(s),
    i.div(
      t.class("bc-password-strength-bar__fill"),
      t.style(a.map((n) => `width: ${n}%`))
    )
  );
}
function Re({
  password: e,
  rules: o = B,
  className: c
}) {
  const m = f(e)((a) => !a || a.length === 0 ? "weak" : K(a, o).strength), l = f(
    m,
    c
  )((a, s) => [
    "bc-password-strength-text",
    `bc-password-strength-text--${a}`,
    s
  ].filter(Boolean).join(" "));
  return P(
    x,
    (a) => i.span(
      t.class(l),
      f(
        m,
        a
      )((s, n) => {
        switch (s) {
          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 _e({
  passwordRules: e,
  labels: o,
  showPasswordStrength: c,
  onSignUp: m,
  showNameField: l,
  showConfirmPassword: a,
  showAcceptTermsAndConditions: s,
  termsAndConditions: n
}) {
  const u = E(!1), r = e || B, w = J(r, {
    showNameField: l !== !1,
    showConfirmPassword: a !== !1,
    showAcceptTermsAndConditions: s !== !1
  }), _ = R({
    schema: w,
    onSubmit: X({
      task: m != null ? (S) => m({
        email: S.email,
        password: S.password,
        name: S.name
      }) : void 0,
      message: "Reset password failed",
      onStart: () => {
        u.set(!0), _.controller.disable();
      },
      onEnd: () => {
        u.set(!1), _.controller.enable();
      }
    }),
    initialValue: {
      name: "",
      email: "",
      password: "",
      confirmPassword: "",
      acceptTerms: !1
    }
  }), { controller: g, submit: b } = _;
  u.on(g.setDisabled);
  const v = g.field("name"), C = g.field("email"), z = g.field("password"), F = g.field("confirmPassword"), y = g.field("acceptTerms");
  return P(
    x,
    (S) => (
      // Registration form
      i.form(
        U(g.dispose, u.dispose),
        t.class("bc-auth-form__form"),
        T.submit(b),
        q(
          t.class("bc-auth-form__fields"),
          N(
            g.error,
            (k) => G(
              { variant: "danger", tone: "prominent", role: "alert" },
              i.div(k)
            )
          ),
          // Name field (optional)
          L(
            l !== !1,
            () => $(de, {
              controller: v.transform(
                (k) => k ?? "",
                (k) => k === "" ? void 0 : k
              ),
              label: h(o?.nameLabel, S.$.nameLabel)
            })
          ),
          // Email field
          $(W, {
            controller: C,
            label: h(o?.emailLabel, S.$.emailLabel)
          }),
          // Password field
          $(M, {
            controller: z,
            label: h(o?.passwordLabel, S.$.passwordLabel)
          }),
          // Password strength indicator
          L(
            c ?? !1,
            () => we({
              password: z.signal,
              rules: r,
              showLabel: !0
            })
          ),
          // Confirm password field
          L(
            a ?? !1,
            () => $(M, {
              controller: F,
              label: h(
                o?.confirmPasswordLabel,
                S.$.confirmPasswordLabel
              )
            })
          ),
          // Terms acceptance checkbox
          L(
            s ?? !1,
            () => i.div(
              t.class("bc-auth-form__terms"),
              i.label(
                t.class("bc-auth-form__checkbox-label"),
                se({
                  value: y.signal.map((k) => k ?? !1),
                  onChange: (k) => y.change(k)
                }),
                i.span(
                  n || h(o?.acceptTermsLabel, S.$.acceptTermsLabel)
                )
              ),
              L(
                y.errorVisible,
                () => i.div(
                  t.class("bc-auth-form__field-error"),
                  y.error.map((k) => k || "")
                )
              )
            )
          )
        ),
        // Submit button
        O(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: u,
            disabled: g.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(o?.signUpButton, S.$.signUpButton)
        )
      )
    )
  );
}
function Le({
  onResetPassword: e,
  labels: o = {}
}) {
  const c = ae(), m = E(!1), l = R({
    schema: ne,
    onSubmit: X({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        m.set(!0), l.controller.disable();
      },
      onEnd: () => {
        m.set(!1), l.controller.enable();
      }
    }),
    initialValue: {
      email: ""
    }
  }), { controller: a, submit: s } = l;
  m.on(a.setDisabled);
  const n = a.field("email");
  return c.on((u) => {
    u != null && n.change(u);
  }), P(
    x,
    (u) => (
      // Reset password form
      i.form(
        U(a.dispose, c.dispose, m.dispose),
        t.class("bc-auth-form__form"),
        N(
          a.error,
          (r) => G(
            { variant: "danger", tone: "prominent", role: "alert" },
            i.div(r)
          )
        ),
        // Description
        i.p(
          t.class("bc-auth-form__description"),
          h(o?.resetPasswordDescription, u.$.resetPasswordDescription)
        ),
        T.submit(s),
        q(
          t.class("bc-auth-form__fields"),
          // Email field
          $(W, {
            controller: n,
            label: h(o?.emailLabel, u.$.emailLabel)
          })
        ),
        // Submit button
        O(
          {
            loading: m,
            type: "submit",
            variant: "filled",
            color: "primary",
            disabled: a.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(o?.resetPasswordButton, u.$.resetPasswordButton)
        )
      )
    )
  );
}
function p({
  provider: e,
  onClick: o,
  size: c = "md",
  name: m,
  icon: l,
  color: a,
  flow: s,
  labels: n
}) {
  return O(
    {
      type: "button",
      variant: "filled",
      size: c,
      color: a,
      onClick: async () => {
        if (o)
          try {
            s === "popup" ? await o() : await o();
          } catch (r) {
            console.error(
              `Social login error for ${e} (${s || "redirect"} flow):`,
              r
            );
          }
      },
      roundedness: "full"
    },
    t.class("bc-social-login-button"),
    t.class(
      f(e)((r) => `bc-social-login-button--${r}`)
    ),
    i.span(
      t.class("bc-social-login-button__inner"),
      i.span(
        t.class("bc-social-login-button__icon"),
        pe({ icon: l, size: c }, t.class("bc-social-login-button__icon-inner"))
      ),
      P(
        x,
        (r) => i.span(
          t.class("bc-social-login-button__label"),
          ie(
            h(n?.continueWithProvider, r.$.continueWithProvider)
          )(m)
        )
      )
    )
  );
}
function ke({
  providers: e,
  onProviderClick: o,
  size: c = "md",
  className: m
}) {
  return q(
    t.class("bc-social-login-buttons"),
    t.class(m),
    ce(
      e,
      (l) => p({
        provider: l.$.provider,
        flow: l.$.flow,
        color: l.map(
          ({ provider: a }) => d[a].color
        ),
        name: l.map(({ provider: a }) => d[a].name),
        icon: l.map(({ provider: a }) => d[a].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)
  }
}, We = (e) => p({
  ...e,
  ...d.google,
  provider: "google"
}), Ge = (e) => p({
  ...e,
  ...d.github,
  provider: "github"
}), He = (e) => p({
  ...e,
  ...d.apple,
  provider: "apple"
}), je = (e) => p({
  ...e,
  ...d.facebook,
  provider: "facebook"
}), Xe = (e) => p({
  ...e,
  ...d.x,
  provider: "x"
}), Ye = (e) => p({
  ...e,
  ...d.twitter,
  provider: "twitter"
}), Ze = (e) => p({
  ...e,
  ...d.microsoft,
  provider: "microsoft"
}), Je = (e) => p({
  ...e,
  ...d.discord,
  provider: "discord"
}), Ke = (e) => p({
  ...e,
  ...d.linkedin,
  provider: "linkedin"
}), Qe = (e) => p({
  ...e,
  ...d.instagram,
  provider: "instagram"
}), eo = (e) => p({
  ...e,
  ...d.tiktok,
  provider: "tiktok"
}), oo = (e) => p({
  ...e,
  ...d.snapchat,
  provider: "snapchat"
}), to = (e) => p({
  ...e,
  ...d.reddit,
  provider: "reddit"
}), so = (e) => p({
  ...e,
  ...d.pinterest,
  provider: "pinterest"
}), no = (e) => p({
  ...e,
  ...d.twitch,
  provider: "twitch"
}), ao = (e) => p({
  ...e,
  ...d.steam,
  provider: "steam"
}), ro = (e) => p({
  ...e,
  ...d.epic,
  provider: "epic"
}), io = (e) => p({
  ...e,
  ...d.playstation,
  provider: "playstation"
}), co = (e) => p({
  ...e,
  ...d.xbox,
  provider: "xbox"
}), lo = (e) => p({
  ...e,
  ...d.whatsapp,
  provider: "whatsapp"
}), mo = (e) => p({
  ...e,
  ...d.wechat,
  provider: "wechat"
}), uo = (e) => p({
  ...e,
  ...d.amazon,
  provider: "amazon"
}), po = (e) => p({
  ...e,
  ...d.yahoo,
  provider: "yahoo"
}), ho = (e) => p({
  ...e,
  ...d.paypal,
  provider: "paypal"
});
function oe({ providers: e }) {
  return q(
    ke({
      providers: e
    })
  );
}
function ve({
  mode: e,
  socialProviders: o,
  passwordRules: c,
  showRememberMe: m,
  showSocialDivider: l,
  showPasswordStrength: a,
  labels: s,
  onSignIn: n,
  onSignUp: u,
  onResetPassword: r,
  onModeChange: w,
  // onSocialLogin,
  showContainer: _
}, ...g) {
  const b = e != null ? Q.deriveProp(e) : E("signin");
  return b.on((v) => w?.(v)), P(x, (v) => {
    function C() {
      const y = h(s?.hasAccountLink, v.$.hasAccountLink);
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        T.click(() => b.set("signin")),
        y
      );
    }
    function z() {
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        T.click(() => b.set("signup")),
        h(s?.noAccountLink, v.$.noAccountLink)
      );
    }
    function F() {
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        T.click(() => b.set("reset-password")),
        h(s?.forgotPasswordLink, v.$.forgotPasswordLink)
      );
    }
    return i.div(
      he({
        "bc-auth-container": !0,
        "bc-auth-container--styled": Q.map(_ ?? !0, (y) => y)
      }),
      t.class(b.map((y) => `bc-auth-container--${y}`)),
      t.class("bc-auth-form"),
      U(b.dispose),
      le(b, {
        signin: () => A(
          i.h2(
            t.class("bc-auth-form__title"),
            h(s?.signInTitle, v.$.signInTitle)
          ),
          o != null ? A(
            oe({ providers: o }),
            L(l ?? !1, te)
          ) : null,
          be({
            onSignIn: n,
            showRememberMe: m,
            passwordRules: c,
            labels: {
              emailLabel: s?.emailLabel,
              passwordLabel: s?.passwordLabel,
              rememberMeLabel: s?.rememberMeLabel,
              signInButton: s?.signInButton,
              forgotPasswordLink: s?.forgotPasswordLink,
              noAccountLink: s?.noAccountLink
            }
          }),
          q(
            t.class("bc-auth-form__footer"),
            z(),
            F()
          )
        ),
        signup: () => A(
          i.h2(
            t.class("bc-auth-form__title"),
            h(s?.signUpTitle, v.$.signUpTitle)
          ),
          o != null ? A(
            oe({ providers: o }),
            L(l ?? !1, te)
          ) : null,
          _e({
            labels: {
              nameLabel: s?.nameLabel,
              emailLabel: s?.emailLabel,
              passwordLabel: s?.passwordLabel,
              confirmPasswordLabel: s?.confirmPasswordLabel,
              acceptTermsLabel: s?.acceptTermsLabel,
              signUpButton: s?.signUpButton,
              hasAccountLink: s?.hasAccountLink
            },
            onSignUp: u,
            passwordRules: c,
            showPasswordStrength: a
          }),
          q(t.class("bc-auth-form__footer"), C())
        ),
        "reset-password": () => A(
          i.h2(
            t.class("bc-auth-form__title"),
            h(s?.resetPasswordTitle, v.$.resetPasswordTitle)
          ),
          Le({
            labels: {
              backToSignInLink: s?.backToSignInLink,
              emailLabel: s?.emailLabel,
              resetPasswordButton: s?.resetPasswordButton,
              resetPasswordDescription: s?.resetPasswordDescription
            },
            onResetPassword: r
          }),
          q(t.class("bc-auth-form__footer"), C())
        )
      }),
      ...g
    );
  });
}
function go(e) {
  return ue(
    {
      size: "sm",
      dismissable: !0,
      showCloseButton: !0
    },
    (o, c) => e(
      (m) => o({
        body: ve({ showContainer: !1, ...m }),
        header: P(
          x,
          (l) => h(m.modalTitle, l.$.authenticationTitle)
        )
      })
    )
  );
}
function te({
  labels: e,
  className: o
} = {}) {
  return i.div(
    t.class("bc-auth-divider"),
    t.class(o),
    i.div(t.class("bc-auth-divider__line")),
    P(
      x,
      (c) => i.span(
        t.class("bc-auth-divider__text"),
        h(e?.text, c.$.orDivider)
      )
    ),
    i.div(t.class("bc-auth-divider__line"))
  );
}
export {
  uo as AmazonLoginButton,
  He as AppleLoginButton,
  ve as AuthContainer,
  te as AuthDivider,
  go as AuthModal,
  Je as DiscordLoginButton,
  ro as EpicLoginButton,
  je as FacebookLoginButton,
  Ge as GitHubLoginButton,
  We as GoogleLoginButton,
  Qe as InstagramLoginButton,
  Ke as LinkedInLoginButton,
  Ze as MicrosoftLoginButton,
  Ne as PasswordStrengthBar,
  we as PasswordStrengthIndicator,
  Re as PasswordStrengthText,
  ho as PayPalLoginButton,
  so as PinterestLoginButton,
  io as PlayStationLoginButton,
  to as RedditLoginButton,
  Le as ResetPasswordForm,
  be as SignInForm,
  _e as SignUpForm,
  oo as SnapchatLoginButton,
  p as SocialLoginButton,
  ke as SocialLoginButtons,
  oe as SocialProviders,
  ao as SteamLoginButton,
  eo as TiktokLoginButton,
  no as TwitchLoginButton,
  Ye as TwitterLoginButton,
  mo as WeChatLoginButton,
  lo as WhatsAppLoginButton,
  Xe as XLoginButtin,
  co as XboxLoginButton,
  po as YahooLoginButton,
  Fe as authSchemas,
  K as calculatePasswordStrength,
  Y as createPasswordSchema,
  Z as createSignInSchema,
  J as createSignUpSchema,
  Ce as createSocialLoginUrl,
  B as defaultPasswordRules,
  Oe as defaultSignInSchema,
  Ve as defaultSignUpSchema,
  V as emailSchema,
  Ee as formatAuthError,
  ge as formatProviderName,
  Te as formatSocialLoginText,
  fe as generateRandomString,
  Ie as getProviderColor,
  $e as getProviderIcon,
  Ue as isBrowser,
  Ae as isValidEmail,
  ze as openSocialLoginPopup,
  j as providerInfo,
  X as requestToControllerValidation,
  ne as resetPasswordSchema,
  d as socialProviderInfo,
  ae as useAuthEmailProp,
  Me as validateEmail,
  De as validatePassword
};
