import { defineComponent, computed, createVNode } from 'vue';
import '../../../../utils/index.mjs';
import '../../../../locale/index.mjs';
import ConfirmDialog from '../ConfirmDialog.mjs';
import '../../../config-provider/index.mjs';
import '../../../locale-provider/index.mjs';
import { initDefaultProps } from '../../../../utils/vue/initDefaultProps.mjs';
import { useConfigContextInject } from '../../../config-provider/src/context/context.mjs';
import { useLocaleReceiver } from '../../../locale-provider/src/useLocaleReceiver.mjs';
import localeValues from '../../../../locale/lang/en_US.mjs';

function comfirmFuncProps() {
  return {
    config: Object,
    afterClose: Function,
    destroyAction: Function,
    open: Boolean
  };
}
var HookModal = /* @__PURE__ */ defineComponent({
  name: "HookModal",
  inheritAttrs: false,
  props: initDefaultProps(comfirmFuncProps(), {
    config: {
      width: 520,
      okType: "primary"
    }
  }),
  setup(props, {
    expose
  }) {
    var _a;
    const open = computed(() => props.open);
    const innerConfig = computed(() => props.config);
    const {
      direction,
      getPrefixCls
    } = useConfigContextInject();
    const prefixCls = getPrefixCls("modal");
    const rootPrefixCls = getPrefixCls();
    const afterClose = () => {
      var _a2, _b;
      props == null ? void 0 : props.afterClose();
      (_b = (_a2 = innerConfig.value).afterClose) == null ? void 0 : _b.call(_a2);
    };
    const close = (...args) => {
      props.destroyAction(...args);
    };
    expose({
      destroy: close
    });
    const mergedOkCancel = (_a = innerConfig.value.okCancel) != null ? _a : innerConfig.value.type === "confirm";
    const [contextLocale] = useLocaleReceiver("Modal", localeValues.Modal);
    return () => createVNode(ConfirmDialog, {
      "prefixCls": prefixCls,
      "rootPrefixCls": rootPrefixCls,
      ...innerConfig.value,
      "close": close,
      "open": open.value,
      "afterClose": afterClose,
      "okText": innerConfig.value.okText || (mergedOkCancel ? contextLocale == null ? void 0 : contextLocale.value.okText : contextLocale == null ? void 0 : contextLocale.value.justOkText),
      "direction": innerConfig.value.direction || direction.value,
      "cancelText": innerConfig.value.cancelText || (contextLocale == null ? void 0 : contextLocale.value.cancelText)
    }, null);
  }
});

export { HookModal as default };
//# sourceMappingURL=HookModal.mjs.map
