import { ref, withCtx, unref, createTextVNode, toDisplayString, createVNode, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate } from 'vue/server-renderer';
import { be as useNuxtApp, bv as useUserSession, j as VContainer, V as VBtn, aJ as navigateTo } from './server.mjs';
import { V as VCard, b as VCardTitle } from './VCard-D86CughW.mjs';
import { V as VCardText } from './VCardText-KkYigSmQ.mjs';
import { V as VDivider } from './VDivider-akc4E5rx.mjs';
import { V as VAlert } from './VAlert-B_mtyJh1.mjs';
import '../nitro/nitro.mjs';
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 '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 './VCardActions-B8o0qNQf.mjs';
import './createSimpleFunctional-D4PbVxKo.mjs';
import './VAvatar-DZc9zgUD.mjs';

const _sfc_main = {
  __name: "settings",
  __ssrInlineRender: true,
  setup(__props) {
    const loading = ref(false);
    const { $confirm, $notify } = useNuxtApp();
    const { user, clear: clearSession } = useUserSession();
    async function forgot() {
      loading.value = true;
      await $fetch("/api/user/recover", { method: "POST", body: { email: user.value.email } });
      loading.value = false;
      $notify("login.check_email");
    }
    async function removeAccount() {
      const ret = await $confirm("settings.remove_account_confirm");
      if (!ret) return;
      $fetch("/api/user", { method: "DELETE" });
      clearSession();
      navigateTo("/");
    }
    return (_ctx, _push, _parent, _attrs) => {
      _push(ssrRenderComponent(VContainer, _attrs, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VCard, null, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VCardTitle, { class: "mb-4" }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`${ssrInterpolate(unref(user).email)}`);
                      } else {
                        return [
                          createTextVNode(toDisplayString(unref(user).email), 1)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(ssrRenderComponent(VCardText, null, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`<div class="text-h6 mb-4"${_scopeId3}>${ssrInterpolate(_ctx.$t("login.forgot_password"))}</div>`);
                        _push4(ssrRenderComponent(VBtn, {
                          variant: "outlined",
                          "prepend-icon": "mdi-email-outline",
                          onClick: forgot
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(`${ssrInterpolate(_ctx.$t("common.recover_password"))}`);
                            } else {
                              return [
                                createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                        _push4(ssrRenderComponent(VDivider, { class: "my-6" }, null, _parent4, _scopeId3));
                        _push4(`<div class="text-h6 mb-4 text-error"${_scopeId3}>${ssrInterpolate(_ctx.$t("settings.danger_section"))}</div>`);
                        _push4(ssrRenderComponent(VAlert, {
                          type: "error",
                          icon: false,
                          border: false,
                          rounded: ""
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(`<div class="mb-3"${_scopeId4}>${ssrInterpolate(_ctx.$t("settings.remove_account"))}</div>`);
                              _push5(ssrRenderComponent(VBtn, {
                                variant: "outlined",
                                color: "error",
                                onClick: removeAccount
                              }, {
                                default: withCtx((_5, _push6, _parent6, _scopeId5) => {
                                  if (_push6) {
                                    _push6(`${ssrInterpolate(_ctx.$t("common.remove"))}`);
                                  } else {
                                    return [
                                      createTextVNode(toDisplayString(_ctx.$t("common.remove")), 1)
                                    ];
                                  }
                                }),
                                _: 1
                              }, _parent5, _scopeId4));
                            } else {
                              return [
                                createVNode("div", { class: "mb-3" }, toDisplayString(_ctx.$t("settings.remove_account")), 1),
                                createVNode(VBtn, {
                                  variant: "outlined",
                                  color: "error",
                                  onClick: removeAccount
                                }, {
                                  default: withCtx(() => [
                                    createTextVNode(toDisplayString(_ctx.$t("common.remove")), 1)
                                  ]),
                                  _: 1
                                })
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                      } else {
                        return [
                          createVNode("div", { class: "text-h6 mb-4" }, toDisplayString(_ctx.$t("login.forgot_password")), 1),
                          createVNode(VBtn, {
                            variant: "outlined",
                            "prepend-icon": "mdi-email-outline",
                            onClick: forgot
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                            ]),
                            _: 1
                          }),
                          createVNode(VDivider, { class: "my-6" }),
                          createVNode("div", { class: "text-h6 mb-4 text-error" }, toDisplayString(_ctx.$t("settings.danger_section")), 1),
                          createVNode(VAlert, {
                            type: "error",
                            icon: false,
                            border: false,
                            rounded: ""
                          }, {
                            default: withCtx(() => [
                              createVNode("div", { class: "mb-3" }, toDisplayString(_ctx.$t("settings.remove_account")), 1),
                              createVNode(VBtn, {
                                variant: "outlined",
                                color: "error",
                                onClick: removeAccount
                              }, {
                                default: withCtx(() => [
                                  createTextVNode(toDisplayString(_ctx.$t("common.remove")), 1)
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          })
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VCardTitle, { class: "mb-4" }, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(unref(user).email), 1)
                      ]),
                      _: 1
                    }),
                    createVNode(VCardText, null, {
                      default: withCtx(() => [
                        createVNode("div", { class: "text-h6 mb-4" }, toDisplayString(_ctx.$t("login.forgot_password")), 1),
                        createVNode(VBtn, {
                          variant: "outlined",
                          "prepend-icon": "mdi-email-outline",
                          onClick: forgot
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                          ]),
                          _: 1
                        }),
                        createVNode(VDivider, { class: "my-6" }),
                        createVNode("div", { class: "text-h6 mb-4 text-error" }, toDisplayString(_ctx.$t("settings.danger_section")), 1),
                        createVNode(VAlert, {
                          type: "error",
                          icon: false,
                          border: false,
                          rounded: ""
                        }, {
                          default: withCtx(() => [
                            createVNode("div", { class: "mb-3" }, toDisplayString(_ctx.$t("settings.remove_account")), 1),
                            createVNode(VBtn, {
                              variant: "outlined",
                              color: "error",
                              onClick: removeAccount
                            }, {
                              default: withCtx(() => [
                                createTextVNode(toDisplayString(_ctx.$t("common.remove")), 1)
                              ]),
                              _: 1
                            })
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(VCard, null, {
                default: withCtx(() => [
                  createVNode(VCardTitle, { class: "mb-4" }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(unref(user).email), 1)
                    ]),
                    _: 1
                  }),
                  createVNode(VCardText, null, {
                    default: withCtx(() => [
                      createVNode("div", { class: "text-h6 mb-4" }, toDisplayString(_ctx.$t("login.forgot_password")), 1),
                      createVNode(VBtn, {
                        variant: "outlined",
                        "prepend-icon": "mdi-email-outline",
                        onClick: forgot
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.recover_password")), 1)
                        ]),
                        _: 1
                      }),
                      createVNode(VDivider, { class: "my-6" }),
                      createVNode("div", { class: "text-h6 mb-4 text-error" }, toDisplayString(_ctx.$t("settings.danger_section")), 1),
                      createVNode(VAlert, {
                        type: "error",
                        icon: false,
                        border: false,
                        rounded: ""
                      }, {
                        default: withCtx(() => [
                          createVNode("div", { class: "mb-3" }, toDisplayString(_ctx.$t("settings.remove_account")), 1),
                          createVNode(VBtn, {
                            variant: "outlined",
                            color: "error",
                            onClick: removeAccount
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("common.remove")), 1)
                            ]),
                            _: 1
                          })
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ];
          }
        }),
        _: 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/settings.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
