import { ref as f, defineAsyncComponent as v, defineComponent as h, h as d, createApp as y } from "vue";
function A({ component: l, attrs: s, Modal: u, modalAttrs: m }) {
  return new Promise((i) => {
    const n = document.createElement("div");
    document.body.appendChild(n);
    const e = f({}), o = () => {
      a.unmount(), document.body.removeChild(n);
    }, t = () => {
      o(), i(e.value);
    }, p = (r) => {
      Object.keys(r).forEach((c) => {
        e.value[c] = r[c];
      });
    }, C = v(() => l), b = h({
      render() {
        return d(
          u,
          {
            ...m,
            // Блокируем OK, пока форма невалидна (или валидность ещё не известна)
            okDisabled: !(e.value && e.value.isValid === !0),
            onClose: o,
            onSubmit: t
          },
          {
            default: () => d(C, {
              ...s,
              onChange: p,
              onSubmit: t,
              onClose: o
            })
          }
        );
      }
    }), a = y(b);
    a.mount(n);
  });
}
export {
  A as useModal
};
