import * as vue from "vue";
import { defineComponent, mergeProps, useSSRContext } from "vue";
import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate, ssrRenderSlot } from "vue/server-renderer";
import { o as onEvent } from "../mount.js";
import "path-browserify";
import "deepmerge";
import "fast-safe-stringify";
import "spark-md5";
import "is-plain-object";
import "js-cookie";
import "events";
import "http";
import "@medv/finder";
import "front-matter";
import "markdown-it";
import "markdown-it-anchor";
import "markdown-it-implicit-figures";
import "markdown-it-link-attributes";
import "markdown-it-video";
import "remove-markdown";
import "./index.2544f8a4.js";
import "body-parser";
import "dotenv";
import "compression";
import "serve-favicon";
import "serve-static";
import "html-minifier";
import "vite";
import "@vue/server-renderer";
import "fs";
import "enquirer";
import "semver";
import "glob";
import "minimist";
import "handlebars";
import "execa";
import "multer";
import "sharp";
import "@vitejs/plugin-vue";
import _sfc_main$1 from "./ElSpinner.1083576f.js";
import "express";
import "axios";
import "knex";
import "dompurify";
import "dayjs";
import "chalk";
import "dayjs/plugin/relativeTime.js";
import "dayjs/plugin/utc.js";
import "dayjs/plugin/timezone.js";
import "dayjs/plugin/updateLocale.js";
import "dayjs/plugin/weekOfYear.js";
import "nanoid";
import "prettyoutput";
import "consola";
import "validator";
import "@vueuse/head";
import "node-fetch";
import "vue-router";
import "jsonwebtoken";
import "fs-extra";
import "bcrypt";
import "knex-stringcase";
import "@sinclair/typebox";
import "nodemailer";
import "nodemailer-html-to-text";
import "@tailwindcss/forms";
import "unocss/vite";
import "@unocss/preset-icons";
import "nodemon";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "ElForm",
  __ssrInlineRender: true,
  props: {
    save: { type: Boolean, default: false },
    valid: { type: Boolean, default: false },
    data: { type: Object, default: () => {
    } },
    notify: { type: String, default: "" },
    loading: { type: Boolean, default: false }
  },
  emits: ["submit", "update:valid"],
  setup(__props, { emit }) {
    const props = __props;
    const form = vue.ref();
    const submitForm = () => {
      const el = form.value;
      if (el) {
        const valid = el.reportValidity();
        if (valid)
          emit("submit");
      }
    };
    const setValid = () => {
      const el = form.value;
      if (el) {
        const valid = el.checkValidity();
        emit("update:valid", valid);
      }
    };
    vue.onMounted(() => {
      setTimeout(() => {
        setValid();
        const el = form.value;
        if (el) {
          const els = el.querySelectorAll(
            "input, select, checkbox, .f-input, textarea"
          );
          els.forEach((el2) => el2.addEventListener("blur", () => setValid()));
        }
      }, 300);
    });
    vue.watch(
      () => props.data,
      () => {
        setTimeout(() => {
          setValid();
        }, 50);
      },
      { deep: true }
    );
    onEvent("submit", () => {
      submitForm();
    });
    return (_ctx, _push, _parent, _attrs) => {
      _push(`<form${ssrRenderAttrs(mergeProps({
        ref_key: "form",
        ref: form,
        class: "wrap-form",
        autocomplete: "on"
      }, _attrs))}>`);
      if (__props.loading) {
        _push(`<div class="flex items-center justify-center p-12 text-slate-300">`);
        _push(ssrRenderComponent(_sfc_main$1, { class: "h-6 w-6" }, null, _parent));
        _push(`</div>`);
      } else {
        _push(`<!--[-->`);
        if (__props.notify) {
          _push(`<div class="amy-4 rounded-md bg-yellow-50 p-4"><div class="flex"><div class="shrink-0"><!-- Heroicon name: solid/exclamation --><svg class="h-5 w-5 text-yellow-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"></path></svg></div><div class="ml-3"><h3 class="text-sm font-medium text-yellow-800">${ssrInterpolate(__props.notify)}</h3></div></div></div>`);
        } else {
          _push(`<!---->`);
        }
        ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent);
        _push(`<input class="submit hidden" type="submit" value=""><!--]-->`);
      }
      _push(`</form>`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("../ui/ElForm.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export {
  _sfc_main as default
};
