import { c as N, m as ae, p as z, f as L, r as ie, s as se, b, d as R, u as q, h as Z, i as Y, t as J, o as K } from "./AssetItem-CFsdMEwW.js";
import { v as H, x as ee, y as te, z as F, t as V, n as M, r as P, A as C, D as j, I as d, Y as ne, m as D, C as Q, G as T, M as W, O as le, E as de, F as ce, by as ue, T as U, bz as ve, S as pe } from "./index-BxjwuJ6T.js";
import { C as fe } from "./App-pmcYlKkW.js";
import { C as me } from "./ContentHeader-IUWmor6Y.js";
import { B as _e } from "./Button-S2OwL6nP.js";
import { B as ge } from "./ButtonLink-Cq6T9Cl0.js";
import { L as X } from "./Label-DamsCZ57.js";
import { b as he } from "./input-BnNaXS4t.js";
var xe = L('<div class="crtw-flex crtw-justify-center"><input type="number" min="0" max="99999" class="crtw-w-full crtw-mb-1.5 phone crtw-border crtw-rounded crtw-px-2 crtw-outline-none crtw-mt-2.5 crtw-h-[50px] crtw-text-xs svelte-10xd7vj" name="code"/></div>');
const we = {
  hash: "svelte-10xd7vj",
  code: `input.svelte-10xd7vj::-webkit-outer-spin-button,
  input.svelte-10xd7vj::-webkit-inner-spin-button {-webkit-appearance:none;margin:0;}input[type="number"].svelte-10xd7vj {appearance:textfield;-moz-appearance:textfield;}`
};
function G(p, s) {
  if (new.target) return N({ component: G, ...p });
  H(s, !1), ae(p, we);
  let e = z(s, "value", 12), _ = z(s, "placeholder", 12, "Code");
  var $ = {
    get value() {
      return e();
    },
    set value(n) {
      e(n), M();
    },
    get placeholder() {
      return _();
    },
    set placeholder(n) {
      _(n), M();
    },
    $set: q,
    $on: (n, c) => R(s, n, c)
  }, o = xe(), g = ee(o);
  return ie(g), te(o), F(() => se(g, "placeholder", _())), he(g, e), b(p, o), V($);
}
var be = L("<!> <!>", 1), Ce = L("<!> <!>", 1), $e = L("<!> <!> <!>", 1), ye = L('<!> <!> <div class="crtw-mt-4"><!></div>', 1);
function oe(p, s) {
  if (new.target) return N({ component: oe, ...p });
  H(s, !1);
  let e = z(s, "options", 12), { onBackClick: _, onSubmit: $, pending: o, isLoading: g } = e(), n = D(), c = D();
  var y = {
    get options() {
      return e();
    },
    set options(r) {
      e(r), M();
    },
    $set: q,
    $on: (r, l) => R(s, r, l)
  };
  Z();
  var O = ye(), A = P(O);
  me(A, { text: "Before we start please verify your personal data" });
  var B = C(A, 2);
  fe(B, {
    children: (r, l) => {
      var m = $e(), a = P(m);
      {
        var v = (t) => {
          var f = be(), k = P(f);
          X(k, {
            for: "code",
            children: (w, re) => {
              Q();
              var E = J();
              F(() => K(E, `Enter your code sent to ${j(() => o?.phone) ?? ""}`)), b(w, E);
            },
            $$slots: { default: !0 }
          });
          var I = C(k, 2);
          G(I, {
            placeholder: "SMS Code",
            get value() {
              return d(n);
            },
            set value(w) {
              T(n, w);
            },
            $$legacy: !0
          }), b(t, f);
        };
        Y(a, (t) => {
          j(() => o?.phone) && t(v);
        });
      }
      var i = C(a, 2);
      {
        var x = (t) => {
          var f = Ce(), k = P(f);
          X(k, {
            for: "code",
            children: (w, re) => {
              Q();
              var E = J();
              F(() => K(E, `Enter your code sent to ${j(() => o?.email) ?? ""}`)), b(w, E);
            },
            $$slots: { default: !0 }
          });
          var I = C(k, 2);
          G(I, {
            placeholder: "Email Code",
            get value() {
              return d(c);
            },
            set value(w) {
              T(c, w);
            },
            $$legacy: !0
          }), b(t, f);
        };
        Y(i, (t) => {
          j(() => o?.email) && t(x);
        });
      }
      var S = C(i, 2);
      {
        let t = ne(() => (d(n), d(c), j(() => g || !!(o?.phone && String(d(n)).length !== 6) || !!(o?.email && String(d(c)).length !== 6))));
        _e(S, {
          text: "Verify",
          onClick: () => $({
            confirmPhoneCode: d(n),
            confirmEmailCode: d(c)
          }),
          get disabled() {
            return d(t);
          }
        });
      }
      b(r, m);
    },
    $$slots: { default: !0 }
  });
  var u = C(B, 2), h = ee(u);
  return ge(h, {
    text: "Update your account details",
    get onClick() {
      return _;
    }
  }), te(u), b(p, O), V(y);
}
function Se(p, s) {
  if (new.target) return N({ component: Se, ...p });
  H(s, !1);
  const e = () => ce(ve, "$userStore", _), [_, $] = de();
  var o = this && this.__awaiter || function(u, h, r, l) {
    function m(a) {
      return a instanceof r ? a : new r(function(v) {
        v(a);
      });
    }
    return new (r || (r = Promise))(function(a, v) {
      function i(t) {
        try {
          S(l.next(t));
        } catch (f) {
          v(f);
        }
      }
      function x(t) {
        try {
          S(l.throw(t));
        } catch (f) {
          v(f);
        }
      }
      function S(t) {
        t.done ? a(t.value) : m(t.value).then(i, x);
      }
      S((l = l.apply(u, h || [])).next());
    });
  };
  const { confirmAccount: g, close: n, toastAlert: c } = W(le);
  let y = D(!1);
  const O = (u) => o(void 0, [u], void 0, function* ({ confirmEmailCode: h, confirmPhoneCode: r }) {
    var l, m, a, v;
    T(y, !0);
    try {
      const i = yield g(Object.assign(Object.assign({}, !((l = e() === null || e() === void 0 ? void 0 : e().pending) === null || l === void 0) && l.email ? { emailCode: String(h) } : {}), !((m = e() === null || e() === void 0 ? void 0 : e().pending) === null || m === void 0) && m.phone ? { phoneCode: String(r) } : {}));
      if (!((a = e() === null || e() === void 0 ? void 0 : e().pending) === null || a === void 0) && a.phone && !i.phone || !((v = e() === null || e() === void 0 ? void 0 : e().pending) === null || v === void 0) && v.email && !i.email) throw new Error("The code is invalid.");
      const x = W(pe);
      (!x || x === U.CONFIRM_ACCOUNT || x === U.LOGOUT) && n(), c("Account has been confirmed successfully.", "success");
    } catch (i) {
      c(i?.message || i, "failure");
    }
    T(y, !1);
  });
  var A = {
    $set: q,
    $on: (u, h) => R(s, u, h)
  };
  Z();
  {
    let u = ne(() => ({
      isLoading: d(y),
      onBackClick: () => ue.set(U.UPDATE_PROFILE),
      onSubmit: O,
      pending: e()?.pending
    }));
    oe(p, {
      get options() {
        return d(u);
      }
    });
  }
  var B = V(A);
  return $(), B;
}
export {
  Se as default
};
//# sourceMappingURL=ConfirmAccount-ByKibHw0.js.map
