import { ref, reactive, mergeProps, withCtx, isRef, unref, createTextVNode, toDisplayString, createVNode, withModifiers, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate } from 'vue/server-renderer';
import { br as useState, b9 as useI18n, b8 as useHead, be as useNuxtApp, j as VContainer, V as VBtn, aJ as navigateTo } from './server.mjs';
import { S as Statuses } from '../nitro/nitro.mjs';
import { a as VRow, V as VCol } from './VRow-DwC6p4O-.mjs';
import { V as VForm } from './VForm-BuIr7lQn.mjs';
import { V as VCard, b as VCardTitle } from './VCard-D86CughW.mjs';
import { V as VCardText } from './VCardText-KkYigSmQ.mjs';
import { V as VTextField } from './VTextField-DFD0D30-.mjs';
import { V as VTextarea } from './VTextarea-D5gjRx3P.mjs';
import { V as VCardActions } from './VCardActions-B8o0qNQf.mjs';
import { V as VSpacer } from './VSpacer-D6kTsy1m.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-Q_oG-_Ip.mjs';
import './forwardRefs-C3iWxc5z.mjs';
import './createSimpleFunctional-D4PbVxKo.mjs';
import './VAvatar-DZc9zgUD.mjs';
import './autofocus-BUnCw2TG.mjs';
import './index-0tjXFI7F.mjs';
import './animation-DMtpo1PO.mjs';

const _sfc_main = {
  __name: "register",
  __ssrInlineRender: true,
  setup(__props) {
    const settings = useState("settings");
    const { t } = useI18n();
    useHead({
      title: `${settings.value.title} - ${t("common.register")}`
    });
    const form = ref();
    const email = ref();
    const loading = ref(false);
    const user = reactive({ email: "", password: "", description: "" });
    const valid = ref(false);
    const { $notify } = useNuxtApp();
    const register = async () => {
      const valid2 = await form.value.validate();
      if (!valid2) {
        return;
      }
      try {
        loading.value = true;
        const createdUser = await $fetch("/api/user/register", { method: "POST", body: user });
        const isFirstUser = createdUser && createdUser.role === "admin" && createdUser.is_active;
        $notify(isFirstUser ? "register.first_user" : "register.complete");
        navigateTo("/");
      } catch (e) {
        $notify(e, Statuses.ERROR);
      }
      loading.value = false;
    };
    return (_ctx, _push, _parent, _attrs) => {
      _push(ssrRenderComponent(VContainer, mergeProps({ class: "pa-0 pa-md-3" }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VRow, {
              class: "mt-md-5 ma-0",
              align: "center",
              justify: "center"
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VCol, {
                    class: "pa-0 pa-md-3",
                    cols: "12",
                    md: "6",
                    lg: "5",
                    xl: "4"
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(ssrRenderComponent(VForm, {
                          ref_key: "form",
                          ref: form,
                          modelValue: unref(valid),
                          "onUpdate:modelValue": ($event) => isRef(valid) ? valid.value = $event : null,
                          onSubmit: register
                        }, {
                          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.register"))}`);
                                        } else {
                                          return [
                                            createTextVNode(toDisplayString(_ctx.$t("common.register")), 1)
                                          ];
                                        }
                                      }),
                                      _: 1
                                    }, _parent6, _scopeId5));
                                    _push6(ssrRenderComponent(VCardText, null, {
                                      default: withCtx((_6, _push7, _parent7, _scopeId6) => {
                                        if (_push7) {
                                          _push7(`<p${_scopeId6}>${_ctx.$t("register.description") ?? ""}</p>`);
                                          _push7(ssrRenderComponent(VTextField, {
                                            ref_key: "email",
                                            ref: email,
                                            modelValue: unref(user).email,
                                            "onUpdate:modelValue": ($event) => unref(user).email = $event,
                                            type: "email",
                                            rules: _ctx.$valid.email,
                                            label: _ctx.$t("common.email"),
                                            autocomplete: "email"
                                          }, null, _parent7, _scopeId6));
                                          _push7(ssrRenderComponent(VTextField, {
                                            modelValue: unref(user).password,
                                            "onUpdate:modelValue": ($event) => unref(user).password = $event,
                                            type: "password",
                                            rules: [_ctx.$valid.password],
                                            label: _ctx.$t("common.password")
                                          }, null, _parent7, _scopeId6));
                                          _push7(ssrRenderComponent(VTextarea, {
                                            modelValue: unref(user).description,
                                            "onUpdate:modelValue": ($event) => unref(user).description = $event,
                                            rules: [_ctx.$valid.required(_ctx.$t("common.description"))],
                                            label: _ctx.$t("common.description")
                                          }, null, _parent7, _scopeId6));
                                        } else {
                                          return [
                                            createVNode("p", {
                                              innerHTML: _ctx.$t("register.description")
                                            }, null, 8, ["innerHTML"]),
                                            createVNode(VTextField, {
                                              ref_key: "email",
                                              ref: email,
                                              modelValue: unref(user).email,
                                              "onUpdate:modelValue": ($event) => unref(user).email = $event,
                                              type: "email",
                                              rules: _ctx.$valid.email,
                                              label: _ctx.$t("common.email"),
                                              autocomplete: "email"
                                            }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                            createVNode(VTextField, {
                                              modelValue: unref(user).password,
                                              "onUpdate:modelValue": ($event) => unref(user).password = $event,
                                              type: "password",
                                              rules: [_ctx.$valid.password],
                                              label: _ctx.$t("common.password")
                                            }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                            createVNode(VTextarea, {
                                              modelValue: unref(user).description,
                                              "onUpdate:modelValue": ($event) => unref(user).description = $event,
                                              rules: [_ctx.$valid.required(_ctx.$t("common.description"))],
                                              label: _ctx.$t("common.description")
                                            }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"])
                                          ];
                                        }
                                      }),
                                      _: 1
                                    }, _parent6, _scopeId5));
                                    _push6(ssrRenderComponent(VCardActions, null, {
                                      default: withCtx((_6, _push7, _parent7, _scopeId6) => {
                                        if (_push7) {
                                          _push7(ssrRenderComponent(VSpacer, null, null, _parent7, _scopeId6));
                                          _push7(ssrRenderComponent(VBtn, {
                                            type: "submit",
                                            variant: "outlined",
                                            "append-icon": "mdi-chevron-right",
                                            disabled: !unref(valid) || unref(loading),
                                            loading: unref(loading),
                                            color: "primary"
                                          }, {
                                            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 {
                                          return [
                                            createVNode(VSpacer),
                                            createVNode(VBtn, {
                                              type: "submit",
                                              variant: "outlined",
                                              "append-icon": "mdi-chevron-right",
                                              disabled: !unref(valid) || unref(loading),
                                              loading: unref(loading),
                                              color: "primary"
                                            }, {
                                              default: withCtx(() => [
                                                createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                              ]),
                                              _: 1
                                            }, 8, ["disabled", "loading"])
                                          ];
                                        }
                                      }),
                                      _: 1
                                    }, _parent6, _scopeId5));
                                  } else {
                                    return [
                                      createVNode(VCardTitle, null, {
                                        default: withCtx(() => [
                                          createTextVNode(toDisplayString(_ctx.$t("common.register")), 1)
                                        ]),
                                        _: 1
                                      }),
                                      createVNode(VCardText, null, {
                                        default: withCtx(() => [
                                          createVNode("p", {
                                            innerHTML: _ctx.$t("register.description")
                                          }, null, 8, ["innerHTML"]),
                                          createVNode(VTextField, {
                                            ref_key: "email",
                                            ref: email,
                                            modelValue: unref(user).email,
                                            "onUpdate:modelValue": ($event) => unref(user).email = $event,
                                            type: "email",
                                            rules: _ctx.$valid.email,
                                            label: _ctx.$t("common.email"),
                                            autocomplete: "email"
                                          }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                          createVNode(VTextField, {
                                            modelValue: unref(user).password,
                                            "onUpdate:modelValue": ($event) => unref(user).password = $event,
                                            type: "password",
                                            rules: [_ctx.$valid.password],
                                            label: _ctx.$t("common.password")
                                          }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                          createVNode(VTextarea, {
                                            modelValue: unref(user).description,
                                            "onUpdate:modelValue": ($event) => unref(user).description = $event,
                                            rules: [_ctx.$valid.required(_ctx.$t("common.description"))],
                                            label: _ctx.$t("common.description")
                                          }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"])
                                        ]),
                                        _: 1
                                      }),
                                      createVNode(VCardActions, null, {
                                        default: withCtx(() => [
                                          createVNode(VSpacer),
                                          createVNode(VBtn, {
                                            type: "submit",
                                            variant: "outlined",
                                            "append-icon": "mdi-chevron-right",
                                            disabled: !unref(valid) || unref(loading),
                                            loading: unref(loading),
                                            color: "primary"
                                          }, {
                                            default: withCtx(() => [
                                              createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                            ]),
                                            _: 1
                                          }, 8, ["disabled", "loading"])
                                        ]),
                                        _: 1
                                      })
                                    ];
                                  }
                                }),
                                _: 1
                              }, _parent5, _scopeId4));
                            } else {
                              return [
                                createVNode(VCard, null, {
                                  default: withCtx(() => [
                                    createVNode(VCardTitle, null, {
                                      default: withCtx(() => [
                                        createTextVNode(toDisplayString(_ctx.$t("common.register")), 1)
                                      ]),
                                      _: 1
                                    }),
                                    createVNode(VCardText, null, {
                                      default: withCtx(() => [
                                        createVNode("p", {
                                          innerHTML: _ctx.$t("register.description")
                                        }, null, 8, ["innerHTML"]),
                                        createVNode(VTextField, {
                                          ref_key: "email",
                                          ref: email,
                                          modelValue: unref(user).email,
                                          "onUpdate:modelValue": ($event) => unref(user).email = $event,
                                          type: "email",
                                          rules: _ctx.$valid.email,
                                          label: _ctx.$t("common.email"),
                                          autocomplete: "email"
                                        }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                        createVNode(VTextField, {
                                          modelValue: unref(user).password,
                                          "onUpdate:modelValue": ($event) => unref(user).password = $event,
                                          type: "password",
                                          rules: [_ctx.$valid.password],
                                          label: _ctx.$t("common.password")
                                        }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                        createVNode(VTextarea, {
                                          modelValue: unref(user).description,
                                          "onUpdate:modelValue": ($event) => unref(user).description = $event,
                                          rules: [_ctx.$valid.required(_ctx.$t("common.description"))],
                                          label: _ctx.$t("common.description")
                                        }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"])
                                      ]),
                                      _: 1
                                    }),
                                    createVNode(VCardActions, null, {
                                      default: withCtx(() => [
                                        createVNode(VSpacer),
                                        createVNode(VBtn, {
                                          type: "submit",
                                          variant: "outlined",
                                          "append-icon": "mdi-chevron-right",
                                          disabled: !unref(valid) || unref(loading),
                                          loading: unref(loading),
                                          color: "primary"
                                        }, {
                                          default: withCtx(() => [
                                            createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                          ]),
                                          _: 1
                                        }, 8, ["disabled", "loading"])
                                      ]),
                                      _: 1
                                    })
                                  ]),
                                  _: 1
                                })
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                      } else {
                        return [
                          createVNode(VForm, {
                            ref_key: "form",
                            ref: form,
                            modelValue: unref(valid),
                            "onUpdate:modelValue": ($event) => isRef(valid) ? valid.value = $event : null,
                            onSubmit: withModifiers(register, ["prevent"])
                          }, {
                            default: withCtx(() => [
                              createVNode(VCard, null, {
                                default: withCtx(() => [
                                  createVNode(VCardTitle, null, {
                                    default: withCtx(() => [
                                      createTextVNode(toDisplayString(_ctx.$t("common.register")), 1)
                                    ]),
                                    _: 1
                                  }),
                                  createVNode(VCardText, null, {
                                    default: withCtx(() => [
                                      createVNode("p", {
                                        innerHTML: _ctx.$t("register.description")
                                      }, null, 8, ["innerHTML"]),
                                      createVNode(VTextField, {
                                        ref_key: "email",
                                        ref: email,
                                        modelValue: unref(user).email,
                                        "onUpdate:modelValue": ($event) => unref(user).email = $event,
                                        type: "email",
                                        rules: _ctx.$valid.email,
                                        label: _ctx.$t("common.email"),
                                        autocomplete: "email"
                                      }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                      createVNode(VTextField, {
                                        modelValue: unref(user).password,
                                        "onUpdate:modelValue": ($event) => unref(user).password = $event,
                                        type: "password",
                                        rules: [_ctx.$valid.password],
                                        label: _ctx.$t("common.password")
                                      }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                      createVNode(VTextarea, {
                                        modelValue: unref(user).description,
                                        "onUpdate:modelValue": ($event) => unref(user).description = $event,
                                        rules: [_ctx.$valid.required(_ctx.$t("common.description"))],
                                        label: _ctx.$t("common.description")
                                      }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"])
                                    ]),
                                    _: 1
                                  }),
                                  createVNode(VCardActions, null, {
                                    default: withCtx(() => [
                                      createVNode(VSpacer),
                                      createVNode(VBtn, {
                                        type: "submit",
                                        variant: "outlined",
                                        "append-icon": "mdi-chevron-right",
                                        disabled: !unref(valid) || unref(loading),
                                        loading: unref(loading),
                                        color: "primary"
                                      }, {
                                        default: withCtx(() => [
                                          createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                        ]),
                                        _: 1
                                      }, 8, ["disabled", "loading"])
                                    ]),
                                    _: 1
                                  })
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          }, 8, ["modelValue", "onUpdate:modelValue"])
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VCol, {
                      class: "pa-0 pa-md-3",
                      cols: "12",
                      md: "6",
                      lg: "5",
                      xl: "4"
                    }, {
                      default: withCtx(() => [
                        createVNode(VForm, {
                          ref_key: "form",
                          ref: form,
                          modelValue: unref(valid),
                          "onUpdate:modelValue": ($event) => isRef(valid) ? valid.value = $event : null,
                          onSubmit: withModifiers(register, ["prevent"])
                        }, {
                          default: withCtx(() => [
                            createVNode(VCard, null, {
                              default: withCtx(() => [
                                createVNode(VCardTitle, null, {
                                  default: withCtx(() => [
                                    createTextVNode(toDisplayString(_ctx.$t("common.register")), 1)
                                  ]),
                                  _: 1
                                }),
                                createVNode(VCardText, null, {
                                  default: withCtx(() => [
                                    createVNode("p", {
                                      innerHTML: _ctx.$t("register.description")
                                    }, null, 8, ["innerHTML"]),
                                    createVNode(VTextField, {
                                      ref_key: "email",
                                      ref: email,
                                      modelValue: unref(user).email,
                                      "onUpdate:modelValue": ($event) => unref(user).email = $event,
                                      type: "email",
                                      rules: _ctx.$valid.email,
                                      label: _ctx.$t("common.email"),
                                      autocomplete: "email"
                                    }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                    createVNode(VTextField, {
                                      modelValue: unref(user).password,
                                      "onUpdate:modelValue": ($event) => unref(user).password = $event,
                                      type: "password",
                                      rules: [_ctx.$valid.password],
                                      label: _ctx.$t("common.password")
                                    }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                    createVNode(VTextarea, {
                                      modelValue: unref(user).description,
                                      "onUpdate:modelValue": ($event) => unref(user).description = $event,
                                      rules: [_ctx.$valid.required(_ctx.$t("common.description"))],
                                      label: _ctx.$t("common.description")
                                    }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"])
                                  ]),
                                  _: 1
                                }),
                                createVNode(VCardActions, null, {
                                  default: withCtx(() => [
                                    createVNode(VSpacer),
                                    createVNode(VBtn, {
                                      type: "submit",
                                      variant: "outlined",
                                      "append-icon": "mdi-chevron-right",
                                      disabled: !unref(valid) || unref(loading),
                                      loading: unref(loading),
                                      color: "primary"
                                    }, {
                                      default: withCtx(() => [
                                        createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                      ]),
                                      _: 1
                                    }, 8, ["disabled", "loading"])
                                  ]),
                                  _: 1
                                })
                              ]),
                              _: 1
                            })
                          ]),
                          _: 1
                        }, 8, ["modelValue", "onUpdate:modelValue"])
                      ]),
                      _: 1
                    })
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(VRow, {
                class: "mt-md-5 ma-0",
                align: "center",
                justify: "center"
              }, {
                default: withCtx(() => [
                  createVNode(VCol, {
                    class: "pa-0 pa-md-3",
                    cols: "12",
                    md: "6",
                    lg: "5",
                    xl: "4"
                  }, {
                    default: withCtx(() => [
                      createVNode(VForm, {
                        ref_key: "form",
                        ref: form,
                        modelValue: unref(valid),
                        "onUpdate:modelValue": ($event) => isRef(valid) ? valid.value = $event : null,
                        onSubmit: withModifiers(register, ["prevent"])
                      }, {
                        default: withCtx(() => [
                          createVNode(VCard, null, {
                            default: withCtx(() => [
                              createVNode(VCardTitle, null, {
                                default: withCtx(() => [
                                  createTextVNode(toDisplayString(_ctx.$t("common.register")), 1)
                                ]),
                                _: 1
                              }),
                              createVNode(VCardText, null, {
                                default: withCtx(() => [
                                  createVNode("p", {
                                    innerHTML: _ctx.$t("register.description")
                                  }, null, 8, ["innerHTML"]),
                                  createVNode(VTextField, {
                                    ref_key: "email",
                                    ref: email,
                                    modelValue: unref(user).email,
                                    "onUpdate:modelValue": ($event) => unref(user).email = $event,
                                    type: "email",
                                    rules: _ctx.$valid.email,
                                    label: _ctx.$t("common.email"),
                                    autocomplete: "email"
                                  }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                  createVNode(VTextField, {
                                    modelValue: unref(user).password,
                                    "onUpdate:modelValue": ($event) => unref(user).password = $event,
                                    type: "password",
                                    rules: [_ctx.$valid.password],
                                    label: _ctx.$t("common.password")
                                  }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"]),
                                  createVNode(VTextarea, {
                                    modelValue: unref(user).description,
                                    "onUpdate:modelValue": ($event) => unref(user).description = $event,
                                    rules: [_ctx.$valid.required(_ctx.$t("common.description"))],
                                    label: _ctx.$t("common.description")
                                  }, null, 8, ["modelValue", "onUpdate:modelValue", "rules", "label"])
                                ]),
                                _: 1
                              }),
                              createVNode(VCardActions, null, {
                                default: withCtx(() => [
                                  createVNode(VSpacer),
                                  createVNode(VBtn, {
                                    type: "submit",
                                    variant: "outlined",
                                    "append-icon": "mdi-chevron-right",
                                    disabled: !unref(valid) || unref(loading),
                                    loading: unref(loading),
                                    color: "primary"
                                  }, {
                                    default: withCtx(() => [
                                      createTextVNode(toDisplayString(_ctx.$t("common.send")), 1)
                                    ]),
                                    _: 1
                                  }, 8, ["disabled", "loading"])
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          })
                        ]),
                        _: 1
                      }, 8, ["modelValue", "onUpdate:modelValue"])
                    ]),
                    _: 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/register.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
