import { c as V, p as W, f as A, g as Pt, e as dt, b as v, d as j, u as J, a as R, i as q, t as $t, r as at, h as vt, o as K, n as Qt } from "./AssetItem-BxjLUzNd.js";
import { o as kt, a as Mt } from "./index-client-C5PXnhDi.js";
import { t as z, w as L, x as O, r as U, l as X, p as I, C as H, A as qt, y as nt, E as g, z as N, n as At, D as M, m as rt, v as et, o as Dt, V as ut, bp as Et, bq as ct, br as Tt, J as ot, I as Rt, L as It, bs as Ht, G as Nt, a1 as lt, N as Vt, O as jt } from "./index-BBXAtvZr.js";
import { L as st } from "./Loader-Byv7_nwE.js";
import { C as Jt } from "./ContentHeader-CNIXuMji.js";
import { e as zt, i as Ut } from "./each-D1jTQ_vC.js";
import { C as Bt } from "./App-BwT5MYkN.js";
import { h as Gt } from "./html-BVy6qQOC.js";
import { P as Ft, s as Kt } from "./svg-D5FtkcEe.js";
var Wt = A(`<button class="crtw-w-full crtw-text-center crtw-h-11 crtw-font-medium
   crtw-rounded-sm crtw-text-[13px] sm:crtw-text-sm crtw-items-center crtw-bg-black
crtw-text-white crtw-mt-[5px] crtw-justify-center crtw-flex"><!></button>`);
function ft(i, e) {
  if (new.target) return V({ component: ft, ...i });
  z(e, !1);
  let r = W(e, "handler", 12);
  var o = {
    get handler() {
      return r();
    },
    set handler(c) {
      r(c), X();
    },
    $set: J,
    $on: (c, f) => j(e, c, f)
  }, u = Wt(), b = L(u);
  return Pt(b, e, "default", {}), O(u), dt("click", u, function(...c) {
    r()?.apply(this, c);
  }), v(i, u), U(o);
}
var Xt = A('<div class="crtw-text-center crtw-text-gray-500 crtw-text-sm">No login methods available for this client.</div>'), Yt = A('<div class="crtw-m-5"><!></div>');
function pt(i, e) {
  if (new.target) return V({ component: pt, ...i });
  z(e, !1);
  let r = W(e, "options", 12), { loginMethods: o, handleLogin: u, isLoading: b } = r();
  var c = {
    get options() {
      return r();
    },
    set options(a) {
      r(a), X();
    },
    $set: J,
    $on: (a, l) => j(e, a, l)
  }, f = R(), S = I(f);
  {
    var p = (a) => {
      Bt(a, {
        children: (l, t) => {
          var n = R(), m = I(n);
          {
            var P = (h) => {
              var _ = Xt();
              v(h, _);
            }, D = (h) => {
              var _ = R(), w = I(_);
              zt(w, 1, () => o, Ut, (E, d) => {
                ft(E, {
                  handler: () => u(g(d)),
                  children: ($, B) => {
                    qt();
                    var G = $t();
                    nt(() => at(G, `Continue with ${g(d), H(() => g(d).text) ?? ""}`)), v($, G);
                  },
                  $$slots: { default: !0 }
                });
              }), v(h, _);
            };
            q(m, (h) => {
              H(() => o.length === 0) ? h(P) : h(D, !1);
            });
          }
          v(l, n);
        },
        $$slots: { default: !0 }
      });
    }, y = (a) => {
      var l = Yt(), t = L(l);
      st(t, {}), O(l), v(a, l);
    };
    q(S, (a) => {
      b ? a(y, !1) : a(p);
    });
  }
  return v(i, f), U(c);
}
var Zt = A("<div><!></div>"), te = A('<div class="crtw-mt-4"><span class="crtw-text-sm">Cached QR is available. <span class="crtw-cursor-pointer crtw-text-warningTextColor" role="button" tabindex="0"> </span></span> <!></div>');
function gt(i, e) {
  if (new.target) return V({ component: gt, ...i });
  z(e, !1);
  let r = W(e, "options", 12), { qrCodeSvg: o, showQr: u, hideQr: b } = r();
  var c = {
    get options() {
      return r();
    },
    set options(t) {
      r(t), X();
    },
    $set: J,
    $on: (t, n) => j(e, t, n)
  }, f = te(), S = L(f), p = N(L(S)), y = L(p, !0);
  O(p), O(S);
  var a = N(S, 2);
  {
    var l = (t) => {
      var n = Zt(), m = L(n);
      Gt(m, () => o), O(n), v(t, n);
    };
    q(a, (t) => {
      o && t(l);
    });
  }
  return O(f), nt(() => at(y, o ? "Hide QR!" : "Show QR!")), dt("click", p, function(...t) {
    (o ? b : u)?.apply(this, t);
  }), v(i, f), U(c);
}
var ee = A('<p class="crtw-text-center crtw-text-xs crtw-text-gray-700"> </p>'), oe = A('<div class="crtw-flex crtw-flex-col crtw-gap-14 crtw-items-center crtw-w-full"><div class="crtw-flex crtw-flex-col crtw-gap-3 crtw-items-center crtw-w-full"><!> <!></div> <!> <!></div>');
function mt(i, e) {
  if (new.target) return V({ component: mt, ...i });
  z(e, !1);
  const r = rt();
  let o = W(e, "options", 12), { authTitle: u, authDescription: b, qrOptions: c, authOptions: f } = o();
  At(() => et(o()), () => {
    M(r, o().isLoading);
  }), Dt();
  var S = {
    get options() {
      return o();
    },
    set options(t) {
      o(t), X();
    },
    $set: J,
    $on: (t, n) => j(e, t, n)
  };
  vt();
  var p = R(), y = I(p);
  {
    var a = (t) => {
      st(t, {});
    }, l = (t) => {
      var n = oe(), m = L(n), P = L(m);
      Jt(P, {
        get text() {
          return u;
        },
        get description() {
          return b;
        }
      });
      var D = N(P, 2);
      {
        var h = (d) => {
          var $ = ee(), B = L($, !0);
          O($), nt(() => at(B, (et(o()), H(() => o().infoText)))), v(d, $);
        };
        q(D, (d) => {
          et(o()), H(() => o().infoText) && d(h);
        });
      }
      O(m);
      var _ = N(m, 2);
      {
        let d = ut(() => (g(r), H(() => ({ ...f, isLoading: g(r) }))));
        pt(_, {
          get options() {
            return g(d);
          }
        });
      }
      var w = N(_, 2);
      {
        var E = (d) => {
          gt(d, {
            get options() {
              return c;
            }
          });
        };
        q(w, (d) => {
          c && d(E);
        });
      }
      O(n), v(t, n);
    };
    q(y, (t) => {
      g(r) ? t(a) : t(l, !1);
    });
  }
  return v(i, p), U(S);
}
const re = (i) => {
  const e = Et.evm.isEvmProvider();
  return {
    oauth: {
      provider: ct.OAUTH,
      text: "credenza auth",
      condition: i.some((r) => r !== "evm")
    },
    evm: {
      provider: ct.EVM,
      text: "EVM",
      condition: i.includes("evm") && e
    }
  };
};
function ae(i, e) {
  if (new.target) return V({ component: ae, ...i });
  z(e, !1);
  const r = () => K(Vt, "$forcedPage", c), o = () => K(jt, "$pageStore", c), u = () => K(Nt, "$cloakStore", c), b = () => K(lt, "$clientPublicStore", c), [c, f] = Qt();
  var S = this && this.__awaiter || function(s, x, Q, C) {
    function Ct(T) {
      return T instanceof Q ? T : new Q(function(F) {
        F(T);
      });
    }
    return new (Q || (Q = Promise))(function(T, F) {
      function Lt(k) {
        try {
          Z(C.next(k));
        } catch (tt) {
          F(tt);
        }
      }
      function Ot(k) {
        try {
          Z(C.throw(k));
        } catch (tt) {
          F(tt);
        }
      }
      function Z(k) {
        k.done ? T(k.value) : Ct(k.value).then(Lt, Ot);
      }
      Z((C = C.apply(s, x || [])).next());
    });
  }, p, y, a, l, t, n;
  const m = localStorage.getItem(Tt.QR_CODE);
  let P = rt();
  const D = () => {
    if (!m) return;
    const s = JSON.parse(m), x = Ft(JSON.stringify(s));
    M(P, Kt(x, { width: 250, height: 250 }));
  }, h = () => M(P, "");
  let _ = ot(Rt), w = rt(!1);
  const { login: E, close: d } = ot(It), $ = (s) => S(void 0, [s], void 0, function* ({ provider: x }) {
    try {
      M(w, !0), yield E(x), M(w, !1), !r() && !o() && d();
    } catch {
      M(w, !1);
    }
  }), B = () => {
    const s = re(ot(lt).available_login_types);
    return Object.entries(s).filter(([Q, C]) => C.condition !== void 0 ? C.condition : !0).map(([Q, C]) => Object.assign({}, C));
  }, G = (a = (y = (p = _.content) === null || p === void 0 ? void 0 : p.auth) === null || y === void 0 ? void 0 : y.title) !== null && a !== void 0 ? a : "Let’s get started", ht = (n = (t = (l = _.content) === null || l === void 0 ? void 0 : l.auth) === null || t === void 0 ? void 0 : t.description) !== null && n !== void 0 ? n : "Confirm your account to connect.", _t = Ht.subscribe((s) => M(w, s));
  kt(_t);
  const Y = B();
  Mt(() => {
    !g(w) && !u() && Y.length === 1 && $(Y[0]);
  });
  var wt = {
    $set: J,
    $on: (s, x) => j(e, s, x)
  };
  vt();
  var it = R(), xt = I(it);
  {
    var bt = (s) => {
      {
        let x = ut(() => ({
          isLoading: g(w),
          authTitle: G,
          authDescription: ht,
          qrOptions: { qrCodeSvg: g(P), showQr: D, hideQr: h },
          authOptions: { loginMethods: Y, handleLogin: $ }
        }));
        mt(s, {
          get options() {
            return g(x);
          }
        });
      }
    }, St = (s) => {
      st(s, {});
    };
    q(xt, (s) => {
      b() ? s(bt) : s(St, !1);
    });
  }
  v(i, it);
  var yt = U(wt);
  return f(), yt;
}
export {
  ae as default
};
//# sourceMappingURL=Login-jY8QSuMc.js.map
