import { defineComponent as q, computed as r, reactive as u, markRaw as f, openBlock as c, createElementBlock as _, createElementVNode as p, toDisplayString as x, unref as i, Fragment as C, renderList as D, createBlock as L, resolveDynamicComponent as B, createVNode as H } from "vue";
import { E as z, i as R, a as V, p as $, j as N, k as j } from "./index-ec8bc9b4.mjs";
import "pinia";
import "dayjs";
const A = { class: "cds-auth__body" }, F = ["textContent"], I = { class: "cds-auth__form" }, S = { class: "cds-auth__action" }, K = /* @__PURE__ */ q({
  __name: "AuthEmail",
  props: {
    disabled: { type: Boolean, default: !1 },
    lang: { default: {
      title: "Войти по email",
      submit: "Войти",
      emailLabel: "Email",
      emailHint: "name@company.org",
      passwordLabel: "Пароль",
      passwordHint: "оЧеньсЛожНыйПароЛь"
    } }
  },
  emits: ["update", "auth-email"],
  setup(y, { emit: m }) {
    const v = y, t = r(() => v.lang), o = r(() => v.disabled), h = u({
      disabled: o.value,
      card: !1,
      inline: !1,
      iconEnd: !0,
      size: "large"
    }), d = u([
      {
        icon: z,
        validate: R,
        iconEnd: !1,
        label: t.value.emailLabel,
        hint: t.value.emailHint,
        params: { autocomplete: "email", type: "email" },
        required: !0,
        key: "email",
        value: "",
        component: f(V)
      },
      {
        icon: null,
        validate: $,
        iconEnd: !1,
        label: t.value.passwordLabel,
        hint: t.value.passwordHint,
        type: null,
        params: { autocomplete: "current-password" },
        required: !0,
        key: "password",
        value: "",
        component: f(N)
      }
    ]), s = u({
      email: { value: "", valid: !1 },
      password: { value: "", valid: !1 }
    }), k = r(() => {
      let n = [];
      for (let a in s)
        n = [...n, s[a].valid];
      return n.every((a) => a);
    }), b = (n) => {
      const { key: a, valid: e, value: l } = n;
      if (!a)
        return;
      const E = d.findIndex((w) => w.key === a);
      d[E].value = l, s[a] = { value: l, valid: e }, e && m("update", { key: a, valid: e, value: l });
    }, g = () => m("auth-email", s);
    return (n, a) => (c(), _("div", A, [
      p("div", {
        class: "cds-auth__title",
        textContent: x(i(t).title)
      }, null, 8, F),
      p("div", I, [
        (c(!0), _(C, null, D(d, (e) => (c(), L(B(e.component), {
          base: {
            key: e.key,
            autocapitalizationType: !1,
            hint: e.hint,
            icon: e.icon,
            label: e.label,
            required: e.required,
            validate: e.validate,
            value: e.value
          },
          decorations: h,
          disabled: i(o),
          hint: e.hint,
          icon: e.icon,
          iconEnd: !0,
          inline: !1,
          label: e.label,
          name: e.key,
          params: e.params,
          required: e.required,
          validate: e.validate,
          value: e.value,
          onChangeData: a[0] || (a[0] = (l) => b(l)),
          onUpdateData: a[1] || (a[1] = (l) => b(l))
        }, null, 40, ["base", "decorations", "disabled", "hint", "icon", "label", "name", "params", "required", "validate", "value"]))), 256))
      ]),
      p("div", S, [
        H(j, {
          disabled: !i(k) || i(o),
          fill: !0,
          label: i(t).submit,
          color: "success",
          size: "large",
          type: "submit",
          onClick: g
        }, null, 8, ["disabled", "label"])
      ])
    ]));
  }
});
export {
  K as default
};
//# sourceMappingURL=AuthEmail-3dc6e551.mjs.map
