import { render as f, defineComponent as v, createVNode as r, Fragment as w, mergeProps as P, h as y } from "vue";
import { Drawer as A } from "@aplus-frontend/antdv";
import { omit as D } from "lodash-unified";
import { getModalGlobalAppContext as E } from "../../ap-modal/utils/util.mjs";
import { ConfigProvider as N, globalConfigCached as O } from "../../config-provider/config-provider.mjs";
import "../components/ApDrawerClose.vue.mjs";
import V from "../components/ApDrawerClose.vue2.mjs";
const T = (n) => {
  let o, s;
  const {
    destroyOnClose: p = !0
  } = n;
  function i() {
    o && o(!1), setTimeout(() => {
      f(null, t), t.parentElement?.removeChild(t);
    }, 500);
  }
  function h() {
    o && o(!0);
  }
  function a() {
    o && o(!1);
  }
  function C(e) {
    s && s(e);
  }
  const u = /* @__PURE__ */ v({
    data() {
      return {
        open: p,
        props: n
      };
    },
    created() {
      o = (e) => {
        this.open = e;
      }, s = (e) => {
        this.props = {
          ...this.props,
          ...e
        };
      };
    },
    methods: {
      async handleClose() {
        if (this.props?.onClose) {
          const e = this.props?.content?.component?.exposed ?? void 0;
          await this.props?.onClose(e);
        }
        p ? i() : a();
      }
    },
    render() {
      const e = D(this.props, ["onClose", "extra", "footer", "visible", "onUpdate:visible", "afterVisibleChange", "onAfterVisibleOChange", "open", "onUpdate:open", "getContainer"]), c = this.props?.content?.component?.exposed ?? void 0, m = () => p ? i() : a(), d = r(V, {
        onClose: this.handleClose
      }, null), b = r(w, null, [d]);
      return r(N, O.value, {
        default: () => [r(A, P({
          open: this.open,
          onClose: this.handleClose,
          closeIcon: this.props?.closeIcon ?? null,
          extra: this.props?.extra ? this.props?.extra?.(c, m, {
            originNode: b,
            extra: {
              cancelBtn: d
            }
          }) : d,
          footer: this.props?.footer?.(c, m)
        }, e), {
          default: () => [this.props?.content]
        })]
      });
    }
  }), x = n.getContainer || document.body, t = document.createElement("div");
  x.appendChild(t);
  const l = y(u), g = E();
  return l.appContext = n.appContext || g || l.appContext, f(l, t), {
    destroy: i,
    update: C,
    open: h,
    close: a
  };
};
export {
  T as createDrawer
};
