import { defineComponent, ref, reactive, openBlock, createElementBlock, createElementVNode, withModifiers, createVNode, unref, withCtx } from "vue";
import { u as useI18n, k as useAuthService, j as useRouter, D as DxForm_1, m as DxGroupItem_1, f as DxSimpleItem_1, g as DxLabel_1, p as DxRequiredRule_1, r as DxEmailRule_1, h as DxButtonItem_1, q as DxButtonOptions_1, n as notify } from "./index-67606569.mjs";
const _hoisted_1 = { class: "row justify-content-center mt-4" };
const _hoisted_2 = { class: "col-lg-5 col-md-5" };
const _hoisted_3 = { class: "card bg-secondary border-0 mb-0" };
const _hoisted_4 = { class: "card-body p-5" };
const _hoisted_5 = ["onSubmit"];
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "Recovery",
  setup(__props) {
    const { t } = useI18n();
    const authService = useAuthService();
    const router = useRouter();
    const form = ref(null);
    const recovery = reactive({});
    const onFormSubmit = async () => {
      const error = await authService.sendResetLink(recovery.email);
      if (error) {
        notify(t(`validation.${error}`), "error");
      } else {
        router.push({
          name: "login",
          query: { username: recovery.email }
        });
        notify(t("message.emailRecoverySent"), "success");
      }
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          createElementVNode("div", _hoisted_3, [
            createElementVNode("div", _hoisted_4, [
              createElementVNode("form", {
                onSubmit: withModifiers(onFormSubmit, ["prevent"])
              }, [
                createVNode(unref(DxForm_1), {
                  ref_key: "form",
                  ref: form,
                  "label-location": "top",
                  "form-data": recovery
                }, {
                  default: withCtx(() => [
                    createVNode(unref(DxGroupItem_1), {
                      caption: unref(t)("passwordRecovery")
                    }, {
                      default: withCtx(() => [
                        createVNode(unref(DxSimpleItem_1), {
                          "data-field": "email",
                          "editor-type": "dxTextBox",
                          "editor-options": {
                            mode: "email"
                          }
                        }, {
                          default: withCtx(() => [
                            createVNode(unref(DxLabel_1), {
                              text: unref(t)("attributes.email")
                            }, null, 8, ["text"]),
                            createVNode(unref(DxRequiredRule_1)),
                            createVNode(unref(DxEmailRule_1))
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    }, 8, ["caption"]),
                    createVNode(unref(DxButtonItem_1), null, {
                      default: withCtx(() => [
                        createVNode(unref(DxButtonOptions_1), {
                          width: "100%",
                          type: "default",
                          text: unref(t)("send"),
                          "use-submit-behavior": true
                        }, null, 8, ["text"])
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                }, 8, ["form-data"])
              ], 40, _hoisted_5)
            ])
          ])
        ])
      ]);
    };
  }
});
export {
  _sfc_main as default
};
