import { QSpace } from './QSpace-afce9c3e.js';
import { QForm, DefaultAuthLayout, AlignCenterMiddleWrap, LogoNameBox, _sfc_main as _sfc_main$7, QPage } from './QForm-3da35848.js';
import { _sfc_main as _sfc_main$8 } from './AuthSubtitle-9e685bca.js';
import { _sfc_main as _sfc_main$5 } from './DefaultTextField-237675b7.js';
import { useForgotStore, computed, openBlock, createBlock, unref, isRef, useAuthStore, useRouter, useRoute, useQuasar, onUnmounted, withCtx, renderSlot, createVNode, createBaseVNode } from './__federation_expose_Modules-a9c6a6fc.js';
import { passwordRules } from './validationUtil-531209ab.js';
import { _sfc_main as _sfc_main$6 } from './AuthBtn-d1b681f3.js';

const _sfc_main$4 = {
  __name: 'NewPasswordInput',
  setup(__props) {
    const forgotStore = useForgotStore();
    const newPassword = computed({
      get: () => forgotStore.newPassword,
      set: value => forgotStore.setNewPassword(value)
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(_sfc_main$5, {
        modelValue: unref(newPassword),
        "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => isRef(newPassword) ? newPassword.value = $event : null),
        label: "New Password",
        type: "password",
        rules: unref(passwordRules)
      }, null, 8, ["modelValue", "rules"]);
    };
  }
};

const _sfc_main$3 = {
  __name: 'NewPasswordConfirmInput',
  setup(__props) {
    const forgotStore = useForgotStore();
    const newPasswordConfirm = computed({
      get: () => forgotStore.newPasswordConfirm,
      set: value => forgotStore.setNewPasswordConfirm(value)
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(_sfc_main$5, {
        modelValue: unref(newPasswordConfirm),
        "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => isRef(newPasswordConfirm) ? newPasswordConfirm.value = $event : null),
        label: "New Password confirm",
        type: "password",
        rules: [v => !!v || '* Password confirm is required', v => v === unref(forgotStore).newPassword || '* Password confirm must be same as password']
      }, null, 8, ["modelValue", "rules"]);
    };
  }
};

const _sfc_main$2 = {
  __name: 'NewPasswordButton',
  setup(__props) {
    return (_ctx, _cache) => {
      return openBlock(), createBlock(_sfc_main$6, {
        label: "Reset password",
        color: "primary",
        type: "submit"
      });
    };
  }
};

const _sfc_main$1 = {
  __name: 'NewPasswordForm',
  setup(__props) {
    const forgotStore = useForgotStore();
    const authStore = useAuthStore();
    useRouter();
    const route = useRoute();
    const $q = useQuasar();
    const onSubmit = () => {
      const encodedId = route.params.id;
      authStore.setNewPassword(encodedId).then(() => {
        $q.notify({
          type: 'positive',
          message: 'Your password has been reset sucessfully. Please log in with your new password.'
        });
      });
    };
    onUnmounted(() => {
      forgotStore.reset();
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(QForm, {
        class: "signup-input-group q-mx-auto",
        onSubmit: onSubmit
      }, {
        default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
        _: 3
      });
    };
  }
};

const _hoisted_1 = /*#__PURE__*/createBaseVNode("div", null, null, -1);
const _sfc_main = {
  __name: 'NewPasswordForm',
  setup(__props) {
    return (_ctx, _cache) => {
      return openBlock(), createBlock(DefaultAuthLayout, null, {
        default: withCtx(() => [createVNode(QPage, {
          id: "d1__loginPage",
          class: "flex"
        }, {
          default: withCtx(() => [createVNode(AlignCenterMiddleWrap, null, {
            default: withCtx(() => [createVNode(LogoNameBox), createVNode(QSpace, {
              class: "q-py-md q-mt-xs"
            }), createVNode(_sfc_main$7, {
              title: "Reset account password"
            }), createVNode(QSpace, {
              class: "q-py-sm"
            }), createVNode(_sfc_main$8, {
              title: "Please enter your new password."
            }), createVNode(QSpace, {
              class: "q-py-md q-mt-xs"
            }), createVNode(_sfc_main$1, null, {
              default: withCtx(() => [createVNode(_sfc_main$4), createVNode(_sfc_main$3), createVNode(_sfc_main$2)]),
              _: 1
            }), createVNode(QSpace, {
              class: "q-py-md q-mt-xs"
            })]),
            _: 1
          })]),
          _: 1
        }), _hoisted_1]),
        _: 1
      });
    };
  }
};

export { _sfc_main as default };
