import { c as q, p as V, f as T, g as pt, e as rt, b as p, d as E, u as z, a as F, i as A, t as gt, r as X, h as at, n as wt, o as tt } from "./AssetItem-ufNA-vj9.js";
import { o as _t } from "./index-client-DOkVNeOk.js";
import { t as N, w as b, x as y, r as U, l as W, p as K, C as I, A as mt, y as Z, E as L, z as M, n as ht, D as H, m as ot, v as J, o as xt, F as nt, I as et, W as bt, K as yt, bk as Lt, Y as Ct, M as St, N as $t } from "./index-DRgrWhNH.js";
import { C as Tt } from "./ContentHeader-B8i-EqEU.js";
import { L as st } from "./Loader-Cz9tCQ0T.js";
import { e as kt, i as At } from "./each-C_AuyVTL.js";
import { C as Qt } from "./App-C7TSmMh1.js";
import { h as Dt } from "./html-C8LCprZP.js";
var Ot = T(`<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 it(c, a) {
  if (new.target) return q({ component: it, ...c });
  N(a, !1);
  let o = V(a, "handler", 12);
  var e = {
    get handler() {
      return o();
    },
    set handler(l) {
      o(l), W();
    },
    $set: z,
    $on: (l, d) => E(a, l, d)
  }, v = Ot(), _ = b(v);
  return pt(_, a, "default", {}), y(v), rt("click", v, function(...l) {
    o()?.apply(this, l);
  }), p(c, v), U(e);
}
var Pt = T('<div class="crtw-text-center crtw-text-gray-500 crtw-text-sm">No login methods available for this client.</div>'), Rt = T('<div class="crtw-m-5"><!></div>');
function ct(c, a) {
  if (new.target) return q({ component: ct, ...c });
  N(a, !1);
  let o = V(a, "options", 12), { loginMethods: e, handleLogin: v, isLoading: _ } = o();
  var l = {
    get options() {
      return o();
    },
    set options(n) {
      o(n), W();
    },
    $set: z,
    $on: (n, s) => E(a, n, s)
  }, d = F(), g = K(d);
  {
    var f = (n) => {
      Qt(n, {
        children: (s, t) => {
          var r = F(), h = K(r);
          {
            var k = (w) => {
              var x = Pt();
              p(w, x);
            }, Q = (w) => {
              var x = F(), D = K(x);
              kt(D, 1, () => e, At, (O, i) => {
                it(O, {
                  handler: () => v(L(i)),
                  children: (S, u) => {
                    mt();
                    var C = gt();
                    Z(() => X(C, `Continue with ${L(i), I(() => L(i).text) ?? ""}`)), p(S, C);
                  },
                  $$slots: { default: !0 }
                });
              }), p(w, x);
            };
            A(h, (w) => {
              I(() => e.length === 0) ? w(k) : w(Q, !1);
            });
          }
          p(s, r);
        },
        $$slots: { default: !0 }
      });
    }, m = (n) => {
      var s = Rt(), t = b(s);
      st(t, {}), y(s), p(n, s);
    };
    A(g, (n) => {
      _ ? n(m, !1) : n(f);
    });
  }
  return p(c, d), U(l);
}
var Ht = T("<div><!></div>"), It = T('<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 lt(c, a) {
  if (new.target) return q({ component: lt, ...c });
  N(a, !1);
  let o = V(a, "options", 12), { qrCodeSvg: e, showQr: v, hideQr: _ } = o();
  var l = {
    get options() {
      return o();
    },
    set options(t) {
      o(t), W();
    },
    $set: z,
    $on: (t, r) => E(a, t, r)
  }, d = It(), g = b(d), f = M(b(g)), m = b(f, !0);
  y(f), y(g);
  var n = M(g, 2);
  {
    var s = (t) => {
      var r = Ht(), h = b(r);
      Dt(h, () => e), y(r), p(t, r);
    };
    A(n, (t) => {
      e && t(s);
    });
  }
  return y(d), Z(() => X(m, e ? "Hide QR!" : "Show QR!")), rt("click", f, function(...t) {
    (e ? _ : v)?.apply(this, t);
  }), p(c, d), U(l);
}
var Mt = T('<p class="crtw-text-center crtw-text-xs crtw-text-gray-700"> </p>'), qt = T('<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 dt(c, a) {
  if (new.target) return q({ component: dt, ...c });
  N(a, !1);
  const o = ot();
  let e = V(a, "options", 12), { authTitle: v, authDescription: _, qrOptions: l, authOptions: d } = e();
  ht(() => J(e()), () => {
    H(o, e().isLoading);
  }), xt();
  var g = {
    get options() {
      return e();
    },
    set options(t) {
      e(t), W();
    },
    $set: z,
    $on: (t, r) => E(a, t, r)
  };
  at();
  var f = F(), m = K(f);
  {
    var n = (t) => {
      st(t, {});
    }, s = (t) => {
      var r = qt(), h = b(r), k = b(h);
      Tt(k, {
        get text() {
          return v;
        },
        get description() {
          return _;
        }
      });
      var Q = M(k, 2);
      {
        var w = (i) => {
          var S = Mt(), u = b(S, !0);
          y(S), Z(() => X(u, (J(e()), I(() => e().infoText)))), p(i, S);
        };
        A(Q, (i) => {
          J(e()), I(() => e().infoText) && i(w);
        });
      }
      y(h);
      var x = M(h, 2);
      {
        let i = nt(() => (L(o), I(() => ({ ...d, isLoading: L(o) }))));
        ct(x, {
          get options() {
            return L(i);
          }
        });
      }
      var D = M(x, 2);
      {
        var O = (i) => {
          lt(i, {
            get options() {
              return l;
            }
          });
        };
        A(D, (i) => {
          l && i(O);
        });
      }
      y(r), p(t, r);
    };
    A(m, (t) => {
      L(o) ? t(n) : t(s, !1);
    });
  }
  return p(c, f), U(g);
}
function Et(c, a) {
  if (new.target) return q({ component: Et, ...c });
  N(a, !1);
  const o = () => tt(St, "$forcedPage", v), e = () => tt($t, "$pageStore", v), [v, _] = wt();
  var l = this && this.__awaiter || function(u, C, P, j) {
    function vt(R) {
      return R instanceof P ? R : new P(function(B) {
        B(R);
      });
    }
    return new (P || (P = Promise))(function(R, B) {
      function ft($) {
        try {
          Y(j.next($));
        } catch (G) {
          B(G);
        }
      }
      function ut($) {
        try {
          Y(j.throw($));
        } catch (G) {
          B(G);
        }
      }
      function Y($) {
        $.done ? R($.value) : vt($.value).then(ft, ut);
      }
      Y((j = j.apply(u, C || [])).next());
    });
  }, d, g, f, m, n, s;
  let t = et(bt), r = ot(!1);
  const { login: h, close: k, toastAlert: Q } = et(yt), w = (u) => l(void 0, [u], void 0, function* ({ provider: C }) {
    try {
      H(r, !0), yield h(C), H(r, !1), !o() && !e() && k();
    } catch {
      Q("Error during login process", "failure"), H(r, !1);
    }
  }), x = (f = (g = (d = t.content) === null || d === void 0 ? void 0 : d.auth) === null || g === void 0 ? void 0 : g.title) !== null && f !== void 0 ? f : "Let’s get started", D = (s = (n = (m = t.content) === null || m === void 0 ? void 0 : m.auth) === null || n === void 0 ? void 0 : n.description) !== null && s !== void 0 ? s : "Confirm your account to connect.", O = Lt.subscribe((u) => H(r, u));
  _t(O);
  var i = {
    $set: z,
    $on: (u, C) => E(a, u, C)
  };
  at();
  {
    let u = nt(() => ({
      isLoading: L(r),
      authTitle: x,
      authDescription: D,
      authOptions: {
        loginMethods: [{ provider: Ct.OAUTH, text: "credenza auth" }],
        handleLogin: w
      }
    }));
    dt(c, {
      get options() {
        return L(u);
      }
    });
  }
  var S = U(i);
  return _(), S;
}
export {
  Et as default
};
//# sourceMappingURL=Login-CaMMR2FW.js.map
