import { useTemplateRef, ref, mergeProps, unref, withCtx, createTextVNode, toDisplayString, isRef, createVNode, openBlock, createBlock, createCommentVNode, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate } from 'vue/server-renderer';
import { z as useNuxtApp, y as useI18n, b as VBtn } from './server.mjs';
import { V as VDialog } from './VDialog-CiQ-ZFmd.mjs';
import { V as VCard, a as VCardTitle } from './VCard-CJXaLaw7.mjs';
import { V as VCardText } from './VCardText-D-diyBaj.mjs';
import { V as VTextarea } from './VTextarea-5Pqvwz9q.mjs';
import { V as VCardActions } from './VCardActions-BYFaScU5.mjs';
import { V as VSpacer } from './VSpacer-ClGQoN2i.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 './VOverlay-DatVsI3B.mjs';
import './animation-Ilk0LvxU.mjs';
import './index-1z1zC4K2.mjs';
import './VAvatar-oghuaLjs.mjs';
import './createSimpleFunctional-eaVhl3I5.mjs';
import './VDivider-D3it--C7.mjs';
import './forwardRefs-C3iWxc5z.mjs';
import './autofocus-DtAziIxK.mjs';
import './form-B9qqVmvI.mjs';

const _sfc_main = {
  __name: "CoreDialog",
  __ssrInlineRender: true,
  setup(__props) {
    const { $on, $emit } = useNuxtApp();
    const { t } = useI18n();
    const cancelBtn = useTemplateRef("cancelBtn");
    const type = ref("confirmDialog");
    const msg = ref("");
    const visible = ref(false);
    const userInput = ref("");
    const name = ref("");
    const title = ref("");
    function result(value) {
      visible.value = false;
      if (type.value === "confirmDialog") {
        $emit("confirmDialog:result", value);
      } else {
        $emit("promptDialog:result", value && userInput.value);
        userInput.value = "";
      }
    }
    function toggle(val) {
      if (!val && visible.value) {
        result(false);
      }
    }
    return (_ctx, _push, _parent, _attrs) => {
      _push(ssrRenderComponent(VDialog, mergeProps({
        "model-value": unref(visible),
        "max-width": "550",
        "onUpdate:modelValue": toggle
      }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VCard, { class: "border-0" }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VCardTitle, {
                    class: { "bg-error": unref(type) === "confirmDialog" }
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`${ssrInterpolate(unref(title) || _ctx.$t("common.confirm"))}`);
                      } else {
                        return [
                          createTextVNode(toDisplayString(unref(title) || _ctx.$t("common.confirm")), 1)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(ssrRenderComponent(VCardText, null, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`<div${_scopeId3}>${unref(msg) ?? ""}</div>`);
                        if (unref(type) === "promptDialog") {
                          _push4(ssrRenderComponent(VTextarea, {
                            modelValue: unref(userInput),
                            "onUpdate:modelValue": ($event) => isRef(userInput) ? userInput.value = $event : null,
                            variant: "underlined",
                            label: unref(name)
                          }, null, _parent4, _scopeId3));
                        } else {
                          _push4(`<!---->`);
                        }
                      } else {
                        return [
                          createVNode("div", { innerHTML: unref(msg) }, null, 8, ["innerHTML"]),
                          unref(type) === "promptDialog" ? (openBlock(), createBlock(VTextarea, {
                            key: 0,
                            modelValue: unref(userInput),
                            "onUpdate:modelValue": ($event) => isRef(userInput) ? userInput.value = $event : null,
                            variant: "underlined",
                            label: unref(name)
                          }, null, 8, ["modelValue", "onUpdate:modelValue", "label"])) : createCommentVNode("", true)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(ssrRenderComponent(VCardActions, null, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(ssrRenderComponent(VBtn, {
                          ref_key: "cancelBtn",
                          ref: cancelBtn,
                          variant: "flat",
                          onClick: ($event) => result(false)
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(`${ssrInterpolate(_ctx.$t("common.cancel"))}`);
                            } else {
                              return [
                                createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                        _push4(ssrRenderComponent(VSpacer, null, null, _parent4, _scopeId3));
                        _push4(ssrRenderComponent(VBtn, {
                          color: unref(type) === "confirmDialog" ? "error" : "primary",
                          variant: "outlined",
                          onClick: ($event) => result(true)
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(`${ssrInterpolate(_ctx.$t("common.ok"))}`);
                            } else {
                              return [
                                createTextVNode(toDisplayString(_ctx.$t("common.ok")), 1)
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                      } else {
                        return [
                          createVNode(VBtn, {
                            ref_key: "cancelBtn",
                            ref: cancelBtn,
                            variant: "flat",
                            onClick: ($event) => result(false)
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                            ]),
                            _: 1
                          }, 8, ["onClick"]),
                          createVNode(VSpacer),
                          createVNode(VBtn, {
                            color: unref(type) === "confirmDialog" ? "error" : "primary",
                            variant: "outlined",
                            onClick: ($event) => result(true)
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("common.ok")), 1)
                            ]),
                            _: 1
                          }, 8, ["color", "onClick"])
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VCardTitle, {
                      class: { "bg-error": unref(type) === "confirmDialog" }
                    }, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(unref(title) || _ctx.$t("common.confirm")), 1)
                      ]),
                      _: 1
                    }, 8, ["class"]),
                    createVNode(VCardText, null, {
                      default: withCtx(() => [
                        createVNode("div", { innerHTML: unref(msg) }, null, 8, ["innerHTML"]),
                        unref(type) === "promptDialog" ? (openBlock(), createBlock(VTextarea, {
                          key: 0,
                          modelValue: unref(userInput),
                          "onUpdate:modelValue": ($event) => isRef(userInput) ? userInput.value = $event : null,
                          variant: "underlined",
                          label: unref(name)
                        }, null, 8, ["modelValue", "onUpdate:modelValue", "label"])) : createCommentVNode("", true)
                      ]),
                      _: 1
                    }),
                    createVNode(VCardActions, null, {
                      default: withCtx(() => [
                        createVNode(VBtn, {
                          ref_key: "cancelBtn",
                          ref: cancelBtn,
                          variant: "flat",
                          onClick: ($event) => result(false)
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                          ]),
                          _: 1
                        }, 8, ["onClick"]),
                        createVNode(VSpacer),
                        createVNode(VBtn, {
                          color: unref(type) === "confirmDialog" ? "error" : "primary",
                          variant: "outlined",
                          onClick: ($event) => result(true)
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(_ctx.$t("common.ok")), 1)
                          ]),
                          _: 1
                        }, 8, ["color", "onClick"])
                      ]),
                      _: 1
                    })
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(VCard, { class: "border-0" }, {
                default: withCtx(() => [
                  createVNode(VCardTitle, {
                    class: { "bg-error": unref(type) === "confirmDialog" }
                  }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(unref(title) || _ctx.$t("common.confirm")), 1)
                    ]),
                    _: 1
                  }, 8, ["class"]),
                  createVNode(VCardText, null, {
                    default: withCtx(() => [
                      createVNode("div", { innerHTML: unref(msg) }, null, 8, ["innerHTML"]),
                      unref(type) === "promptDialog" ? (openBlock(), createBlock(VTextarea, {
                        key: 0,
                        modelValue: unref(userInput),
                        "onUpdate:modelValue": ($event) => isRef(userInput) ? userInput.value = $event : null,
                        variant: "underlined",
                        label: unref(name)
                      }, null, 8, ["modelValue", "onUpdate:modelValue", "label"])) : createCommentVNode("", true)
                    ]),
                    _: 1
                  }),
                  createVNode(VCardActions, null, {
                    default: withCtx(() => [
                      createVNode(VBtn, {
                        ref_key: "cancelBtn",
                        ref: cancelBtn,
                        variant: "flat",
                        onClick: ($event) => result(false)
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                        ]),
                        _: 1
                      }, 8, ["onClick"]),
                      createVNode(VSpacer),
                      createVNode(VBtn, {
                        color: unref(type) === "confirmDialog" ? "error" : "primary",
                        variant: "outlined",
                        onClick: ($event) => result(true)
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.ok")), 1)
                        ]),
                        _: 1
                      }, 8, ["color", "onClick"])
                    ]),
                    _: 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("components/Core/Dialog.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
