import { defineComponent, ref, withAsyncContext, withCtx, isRef, unref, createTextVNode, toDisplayString, createVNode, openBlock, createBlock, createCommentVNode, Fragment, withModifiers, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate } from 'vue/server-renderer';
import { y as useI18n, t as useRoute$2, s as useState, x as useHead, z as useNuxtApp, r as VContainer, b as VBtn, A as navigateTo } from './server.mjs';
import { b7 as Statuses } from '../nitro/nitro.mjs';
import { V as VForm } from './VForm--N0YDif_.mjs';
import { V as VRow, a as VCol } from './VRow-VMupnUgs.mjs';
import { V as VCard, a as VCardTitle, b as VCardSubtitle } from './VCard-CJXaLaw7.mjs';
import { V as VCardText } from './VCardText-D-diyBaj.mjs';
import { V as VTextField } from './VTextField-Cxy8Koxy.mjs';
import { V as VAlert } from './VAlert-BaT0SM-1.mjs';
import { V as VCardActions } from './VCardActions-BYFaScU5.mjs';
import { V as VSpacer } from './VSpacer-ClGQoN2i.mjs';
import 'perfect-debounce';
import 'v-calendar';
import 'linkifyjs';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import 'luxon';
import '@sequelize/core';
import 'html-to-text';
import 'zod';
import 'crypto';
import 'node:fs';
import 'sharp';
import 'path';
import 'node:stream';
import 'jsdom';
import 'dompurify';
import 'mime-types';
import 'fs';
import 'fs/promises';
import 'linkify-html';
import '@peertube/http-signature';
import 'jsonld';
import 'lodash.intersection';
import 'email-templates';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'node:events';
import 'node:buffer';
import 'node:path';
import 'vue-router';
import 'dotenv';
import 'url';
import 'bcryptjs';
import 'slugify';
import 'umzug';
import 'consola';
import '@sequelize/core/decorators-legacy';
import 'util';
import 'mitt';
import 'ical.js';
import 'node:url';
import 'fast-xml-parser';
import './form-B9qqVmvI.mjs';
import './forwardRefs-C3iWxc5z.mjs';
import './createSimpleFunctional-eaVhl3I5.mjs';
import './VAvatar-oghuaLjs.mjs';
import './autofocus-DtAziIxK.mjs';
import './index-1z1zC4K2.mjs';
import './animation-Ilk0LvxU.mjs';

const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "[code]",
  __ssrInlineRender: true,
  async setup(__props) {
    let __temp, __restore;
    const { t } = useI18n();
    const route = useRoute$2();
    const settings = useState("settings");
    useHead({ title: `${settings.value.title} - ${t("common.recover_password")}` });
    const recoverCode = route.params.code;
    const newPassword = ref("");
    const valid = ref(false);
    const user = ([__temp, __restore] = withAsyncContext(() => $fetch("/api/user/check_recover_code", {
      method: "POST",
      body: { recover_code: recoverCode }
    }).catch(() => {
    })), __temp = await __temp, __restore(), __temp);
    const { $notify } = useNuxtApp();
    async function changePassword() {
      try {
        await $fetch("/api/user/recover_password", {
          method: "POST",
          body: { recover_code: recoverCode, password: newPassword.value }
        });
        $notify("common.password_updated");
        navigateTo("/login");
      } catch (e) {
        $notify(e, Statuses.WARNING);
      }
    }
    return (_ctx, _push, _parent, _attrs) => {
      _push(ssrRenderComponent(VContainer, _attrs, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VForm, {
              modelValue: unref(valid),
              "onUpdate:modelValue": ($event) => isRef(valid) ? valid.value = $event : null,
              onSubmit: changePassword
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VRow, {
                    class: "mt-5",
                    align: "center",
                    justify: "center"
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(ssrRenderComponent(VCol, {
                          cols: "12",
                          md: "6",
                          lg: "5",
                          xl: "4"
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(ssrRenderComponent(VCard, null, {
                                default: withCtx((_5, _push6, _parent6, _scopeId5) => {
                                  if (_push6) {
                                    _push6(ssrRenderComponent(VCardTitle, null, {
                                      default: withCtx((_6, _push7, _parent7, _scopeId6) => {
                                        if (_push7) {
                                          _push7(`${ssrInterpolate(_ctx.$t("common.recover_password"))}`);
                                        } else {
                                          return [
                                            createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                                          ];
                                        }
                                      }),
                                      _: 1
                                    }, _parent6, _scopeId5));
                                    if (unref(user)) {
                                      _push6(`<!--[-->`);
                                      _push6(ssrRenderComponent(VCardSubtitle, null, {
                                        default: withCtx((_6, _push7, _parent7, _scopeId6) => {
                                          if (_push7) {
                                            _push7(`${ssrInterpolate(unref(user).email)}`);
                                          } else {
                                            return [
                                              createTextVNode(toDisplayString(unref(user).email), 1)
                                            ];
                                          }
                                        }),
                                        _: 1
                                      }, _parent6, _scopeId5));
                                      _push6(ssrRenderComponent(VCardText, null, {
                                        default: withCtx((_6, _push7, _parent7, _scopeId6) => {
                                          if (_push7) {
                                            _push7(ssrRenderComponent(VTextField, {
                                              modelValue: unref(newPassword),
                                              "onUpdate:modelValue": ($event) => isRef(newPassword) ? newPassword.value = $event : null,
                                              type: "password",
                                              rules: [_ctx.$valid.password],
                                              autofocus: "",
                                              placeholder: _ctx.$t("common.new_password")
                                            }, null, _parent7, _scopeId6));
                                          } else {
                                            return [
                                              createVNode(VTextField, {
                                                modelValue: unref(newPassword),
                                                "onUpdate:modelValue": ($event) => isRef(newPassword) ? newPassword.value = $event : null,
                                                type: "password",
                                                rules: [_ctx.$valid.password],
                                                autofocus: "",
                                                placeholder: _ctx.$t("common.new_password")
                                              }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "placeholder"])
                                            ];
                                          }
                                        }),
                                        _: 1
                                      }, _parent6, _scopeId5));
                                      _push6(`<!--]-->`);
                                    } else {
                                      _push6(ssrRenderComponent(VCardText, null, {
                                        default: withCtx((_6, _push7, _parent7, _scopeId6) => {
                                          if (_push7) {
                                            _push7(ssrRenderComponent(VAlert, {
                                              type: "error",
                                              icon: "mdi-alert"
                                            }, {
                                              default: withCtx((_7, _push8, _parent8, _scopeId7) => {
                                                if (_push8) {
                                                  _push8(`${ssrInterpolate(_ctx.$t("recover.not_valid_code"))}`);
                                                } else {
                                                  return [
                                                    createTextVNode(toDisplayString(_ctx.$t("recover.not_valid_code")), 1)
                                                  ];
                                                }
                                              }),
                                              _: 1
                                            }, _parent7, _scopeId6));
                                          } else {
                                            return [
                                              createVNode(VAlert, {
                                                type: "error",
                                                icon: "mdi-alert"
                                              }, {
                                                default: withCtx(() => [
                                                  createTextVNode(toDisplayString(_ctx.$t("recover.not_valid_code")), 1)
                                                ]),
                                                _: 1
                                              })
                                            ];
                                          }
                                        }),
                                        _: 1
                                      }, _parent6, _scopeId5));
                                    }
                                    _push6(ssrRenderComponent(VCardActions, null, {
                                      default: withCtx((_6, _push7, _parent7, _scopeId6) => {
                                        if (_push7) {
                                          _push7(ssrRenderComponent(VSpacer, null, null, _parent7, _scopeId6));
                                          if (unref(user)) {
                                            _push7(ssrRenderComponent(VBtn, {
                                              variant: "outlined",
                                              color: "primary",
                                              type: "submit",
                                              disabled: !unref(valid)
                                            }, {
                                              default: withCtx((_7, _push8, _parent8, _scopeId7) => {
                                                if (_push8) {
                                                  _push8(`${ssrInterpolate(_ctx.$t("common.send"))}`);
                                                } else {
                                                  return [
                                                    createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                                  ];
                                                }
                                              }),
                                              _: 1
                                            }, _parent7, _scopeId6));
                                          } else {
                                            _push7(`<!---->`);
                                          }
                                        } else {
                                          return [
                                            createVNode(VSpacer),
                                            unref(user) ? (openBlock(), createBlock(VBtn, {
                                              key: 0,
                                              variant: "outlined",
                                              color: "primary",
                                              type: "submit",
                                              disabled: !unref(valid)
                                            }, {
                                              default: withCtx(() => [
                                                createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                              ]),
                                              _: 1
                                            }, 8, ["disabled"])) : createCommentVNode("", true)
                                          ];
                                        }
                                      }),
                                      _: 1
                                    }, _parent6, _scopeId5));
                                  } else {
                                    return [
                                      createVNode(VCardTitle, null, {
                                        default: withCtx(() => [
                                          createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                                        ]),
                                        _: 1
                                      }),
                                      unref(user) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                                        createVNode(VCardSubtitle, null, {
                                          default: withCtx(() => [
                                            createTextVNode(toDisplayString(unref(user).email), 1)
                                          ]),
                                          _: 1
                                        }),
                                        createVNode(VCardText, null, {
                                          default: withCtx(() => [
                                            createVNode(VTextField, {
                                              modelValue: unref(newPassword),
                                              "onUpdate:modelValue": ($event) => isRef(newPassword) ? newPassword.value = $event : null,
                                              type: "password",
                                              rules: [_ctx.$valid.password],
                                              autofocus: "",
                                              placeholder: _ctx.$t("common.new_password")
                                            }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "placeholder"])
                                          ]),
                                          _: 1
                                        })
                                      ], 64)) : (openBlock(), createBlock(VCardText, { key: 1 }, {
                                        default: withCtx(() => [
                                          createVNode(VAlert, {
                                            type: "error",
                                            icon: "mdi-alert"
                                          }, {
                                            default: withCtx(() => [
                                              createTextVNode(toDisplayString(_ctx.$t("recover.not_valid_code")), 1)
                                            ]),
                                            _: 1
                                          })
                                        ]),
                                        _: 1
                                      })),
                                      createVNode(VCardActions, null, {
                                        default: withCtx(() => [
                                          createVNode(VSpacer),
                                          unref(user) ? (openBlock(), createBlock(VBtn, {
                                            key: 0,
                                            variant: "outlined",
                                            color: "primary",
                                            type: "submit",
                                            disabled: !unref(valid)
                                          }, {
                                            default: withCtx(() => [
                                              createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                            ]),
                                            _: 1
                                          }, 8, ["disabled"])) : createCommentVNode("", true)
                                        ]),
                                        _: 1
                                      })
                                    ];
                                  }
                                }),
                                _: 1
                              }, _parent5, _scopeId4));
                            } else {
                              return [
                                createVNode(VCard, null, {
                                  default: withCtx(() => [
                                    createVNode(VCardTitle, null, {
                                      default: withCtx(() => [
                                        createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                                      ]),
                                      _: 1
                                    }),
                                    unref(user) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                                      createVNode(VCardSubtitle, null, {
                                        default: withCtx(() => [
                                          createTextVNode(toDisplayString(unref(user).email), 1)
                                        ]),
                                        _: 1
                                      }),
                                      createVNode(VCardText, null, {
                                        default: withCtx(() => [
                                          createVNode(VTextField, {
                                            modelValue: unref(newPassword),
                                            "onUpdate:modelValue": ($event) => isRef(newPassword) ? newPassword.value = $event : null,
                                            type: "password",
                                            rules: [_ctx.$valid.password],
                                            autofocus: "",
                                            placeholder: _ctx.$t("common.new_password")
                                          }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "placeholder"])
                                        ]),
                                        _: 1
                                      })
                                    ], 64)) : (openBlock(), createBlock(VCardText, { key: 1 }, {
                                      default: withCtx(() => [
                                        createVNode(VAlert, {
                                          type: "error",
                                          icon: "mdi-alert"
                                        }, {
                                          default: withCtx(() => [
                                            createTextVNode(toDisplayString(_ctx.$t("recover.not_valid_code")), 1)
                                          ]),
                                          _: 1
                                        })
                                      ]),
                                      _: 1
                                    })),
                                    createVNode(VCardActions, null, {
                                      default: withCtx(() => [
                                        createVNode(VSpacer),
                                        unref(user) ? (openBlock(), createBlock(VBtn, {
                                          key: 0,
                                          variant: "outlined",
                                          color: "primary",
                                          type: "submit",
                                          disabled: !unref(valid)
                                        }, {
                                          default: withCtx(() => [
                                            createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                          ]),
                                          _: 1
                                        }, 8, ["disabled"])) : createCommentVNode("", true)
                                      ]),
                                      _: 1
                                    })
                                  ]),
                                  _: 1
                                })
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                      } else {
                        return [
                          createVNode(VCol, {
                            cols: "12",
                            md: "6",
                            lg: "5",
                            xl: "4"
                          }, {
                            default: withCtx(() => [
                              createVNode(VCard, null, {
                                default: withCtx(() => [
                                  createVNode(VCardTitle, null, {
                                    default: withCtx(() => [
                                      createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                                    ]),
                                    _: 1
                                  }),
                                  unref(user) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                                    createVNode(VCardSubtitle, null, {
                                      default: withCtx(() => [
                                        createTextVNode(toDisplayString(unref(user).email), 1)
                                      ]),
                                      _: 1
                                    }),
                                    createVNode(VCardText, null, {
                                      default: withCtx(() => [
                                        createVNode(VTextField, {
                                          modelValue: unref(newPassword),
                                          "onUpdate:modelValue": ($event) => isRef(newPassword) ? newPassword.value = $event : null,
                                          type: "password",
                                          rules: [_ctx.$valid.password],
                                          autofocus: "",
                                          placeholder: _ctx.$t("common.new_password")
                                        }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "placeholder"])
                                      ]),
                                      _: 1
                                    })
                                  ], 64)) : (openBlock(), createBlock(VCardText, { key: 1 }, {
                                    default: withCtx(() => [
                                      createVNode(VAlert, {
                                        type: "error",
                                        icon: "mdi-alert"
                                      }, {
                                        default: withCtx(() => [
                                          createTextVNode(toDisplayString(_ctx.$t("recover.not_valid_code")), 1)
                                        ]),
                                        _: 1
                                      })
                                    ]),
                                    _: 1
                                  })),
                                  createVNode(VCardActions, null, {
                                    default: withCtx(() => [
                                      createVNode(VSpacer),
                                      unref(user) ? (openBlock(), createBlock(VBtn, {
                                        key: 0,
                                        variant: "outlined",
                                        color: "primary",
                                        type: "submit",
                                        disabled: !unref(valid)
                                      }, {
                                        default: withCtx(() => [
                                          createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                        ]),
                                        _: 1
                                      }, 8, ["disabled"])) : createCommentVNode("", true)
                                    ]),
                                    _: 1
                                  })
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          })
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VRow, {
                      class: "mt-5",
                      align: "center",
                      justify: "center"
                    }, {
                      default: withCtx(() => [
                        createVNode(VCol, {
                          cols: "12",
                          md: "6",
                          lg: "5",
                          xl: "4"
                        }, {
                          default: withCtx(() => [
                            createVNode(VCard, null, {
                              default: withCtx(() => [
                                createVNode(VCardTitle, null, {
                                  default: withCtx(() => [
                                    createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                                  ]),
                                  _: 1
                                }),
                                unref(user) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                                  createVNode(VCardSubtitle, null, {
                                    default: withCtx(() => [
                                      createTextVNode(toDisplayString(unref(user).email), 1)
                                    ]),
                                    _: 1
                                  }),
                                  createVNode(VCardText, null, {
                                    default: withCtx(() => [
                                      createVNode(VTextField, {
                                        modelValue: unref(newPassword),
                                        "onUpdate:modelValue": ($event) => isRef(newPassword) ? newPassword.value = $event : null,
                                        type: "password",
                                        rules: [_ctx.$valid.password],
                                        autofocus: "",
                                        placeholder: _ctx.$t("common.new_password")
                                      }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "placeholder"])
                                    ]),
                                    _: 1
                                  })
                                ], 64)) : (openBlock(), createBlock(VCardText, { key: 1 }, {
                                  default: withCtx(() => [
                                    createVNode(VAlert, {
                                      type: "error",
                                      icon: "mdi-alert"
                                    }, {
                                      default: withCtx(() => [
                                        createTextVNode(toDisplayString(_ctx.$t("recover.not_valid_code")), 1)
                                      ]),
                                      _: 1
                                    })
                                  ]),
                                  _: 1
                                })),
                                createVNode(VCardActions, null, {
                                  default: withCtx(() => [
                                    createVNode(VSpacer),
                                    unref(user) ? (openBlock(), createBlock(VBtn, {
                                      key: 0,
                                      variant: "outlined",
                                      color: "primary",
                                      type: "submit",
                                      disabled: !unref(valid)
                                    }, {
                                      default: withCtx(() => [
                                        createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                      ]),
                                      _: 1
                                    }, 8, ["disabled"])) : createCommentVNode("", true)
                                  ]),
                                  _: 1
                                })
                              ]),
                              _: 1
                            })
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(VForm, {
                modelValue: unref(valid),
                "onUpdate:modelValue": ($event) => isRef(valid) ? valid.value = $event : null,
                onSubmit: withModifiers(changePassword, ["prevent"])
              }, {
                default: withCtx(() => [
                  createVNode(VRow, {
                    class: "mt-5",
                    align: "center",
                    justify: "center"
                  }, {
                    default: withCtx(() => [
                      createVNode(VCol, {
                        cols: "12",
                        md: "6",
                        lg: "5",
                        xl: "4"
                      }, {
                        default: withCtx(() => [
                          createVNode(VCard, null, {
                            default: withCtx(() => [
                              createVNode(VCardTitle, null, {
                                default: withCtx(() => [
                                  createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                                ]),
                                _: 1
                              }),
                              unref(user) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                                createVNode(VCardSubtitle, null, {
                                  default: withCtx(() => [
                                    createTextVNode(toDisplayString(unref(user).email), 1)
                                  ]),
                                  _: 1
                                }),
                                createVNode(VCardText, null, {
                                  default: withCtx(() => [
                                    createVNode(VTextField, {
                                      modelValue: unref(newPassword),
                                      "onUpdate:modelValue": ($event) => isRef(newPassword) ? newPassword.value = $event : null,
                                      type: "password",
                                      rules: [_ctx.$valid.password],
                                      autofocus: "",
                                      placeholder: _ctx.$t("common.new_password")
                                    }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "placeholder"])
                                  ]),
                                  _: 1
                                })
                              ], 64)) : (openBlock(), createBlock(VCardText, { key: 1 }, {
                                default: withCtx(() => [
                                  createVNode(VAlert, {
                                    type: "error",
                                    icon: "mdi-alert"
                                  }, {
                                    default: withCtx(() => [
                                      createTextVNode(toDisplayString(_ctx.$t("recover.not_valid_code")), 1)
                                    ]),
                                    _: 1
                                  })
                                ]),
                                _: 1
                              })),
                              createVNode(VCardActions, null, {
                                default: withCtx(() => [
                                  createVNode(VSpacer),
                                  unref(user) ? (openBlock(), createBlock(VBtn, {
                                    key: 0,
                                    variant: "outlined",
                                    color: "primary",
                                    type: "submit",
                                    disabled: !unref(valid)
                                  }, {
                                    default: withCtx(() => [
                                      createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                    ]),
                                    _: 1
                                  }, 8, ["disabled"])) : createCommentVNode("", true)
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          })
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              }, 8, ["modelValue", "onUpdate:modelValue"])
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/recover/[code].vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
