import { defineComponent as w, computed as d, reactive as r, markRaw as b, openBlock as u, createElementBlock as f, createElementVNode as c, toDisplayString as q, Fragment as x, renderList as C, createBlock as D, resolveDynamicComponent as L, createVNode as B } from "vue";
import { E as H, e as z, a as R, p as V, b as $, c as N } from "./index-eb672ab3.mjs";
import "pinia";
import "dayjs";
const A = { class: "cds-auth__body" }, F = ["textContent"], I = { class: "cds-auth__form" }, S = { class: "cds-auth__action" }, J = /* @__PURE__ */ w({
  __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(_, { emit: p }) {
    const v = _, t = d(() => v.lang), i = d(() => v.disabled), y = r({
      disabled: i.value,
      card: !1,
      inline: !1,
      iconEnd: !0,
      size: "large"
    }), o = r([
      {
        icon: H,
        validate: z,
        iconEnd: !1,
        label: t.value.emailLabel,
        hint: t.value.emailHint,
        params: { autocomplete: "email", type: "email" },
        required: !0,
        key: "email",
        value: "",
        component: b(R)
      },
      {
        icon: null,
        validate: V,
        iconEnd: !1,
        label: t.value.passwordLabel,
        hint: t.value.passwordHint,
        type: null,
        params: { autocomplete: "current-password" },
        required: !0,
        key: "password",
        value: "",
        component: b($)
      }
    ]), s = r({
      email: { value: "", valid: !1 },
      password: { value: "", valid: !1 }
    }), h = d(() => {
      let n = [];
      for (let a in s)
        n = [...n, s[a].valid];
      return n.every((a) => a);
    }), m = (n) => {
      const { key: a, valid: e, value: l } = n;
      if (!a)
        return;
      const g = o.findIndex((E) => E.key === a);
      o[g].value = l, s[a] = { value: l, valid: e }, e && p("update", { key: a, valid: e, value: l });
    }, k = () => p("auth-email", s);
    return (n, a) => (u(), f("div", A, [
      c("div", {
        class: "cds-auth__title",
        textContent: q(t.value.title)
      }, null, 8, F),
      c("div", I, [
        (u(!0), f(x, null, C(o, (e) => (u(), D(L(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: y,
          disabled: i.value,
          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) => m(l)),
          onUpdateData: a[1] || (a[1] = (l) => m(l))
        }, null, 40, ["base", "decorations", "disabled", "hint", "icon", "label", "name", "params", "required", "validate", "value"]))), 256))
      ]),
      c("div", S, [
        B(N, {
          disabled: !h.value || i.value,
          fill: !0,
          label: t.value.submit,
          color: "success",
          size: "large",
          type: "submit",
          onClick: k
        }, null, 8, ["disabled", "label"])
      ])
    ]));
  }
});
export {
  J as default
};
//# sourceMappingURL=AuthEmail-fa29cc14.mjs.map
