'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var en_US = require('../../locale/lang/en_US.js');
var ConfirmDialog = require('../ConfirmDialog.js');
var context = require('../../config-provider/context.js');
var LocaleReceiver = require('../../locale-provider/LocaleReceiver.js');
var initDefaultProps = require('../../_util/props-util/initDefaultProps.js');

const comfirmFuncProps = () => ({
  config: Object,
  afterClose: Function,
  destroyAction: Function,
  open: Boolean
});
var HookModal = /* @__PURE__ */ vue.defineComponent({
  name: "HookModal",
  inheritAttrs: false,
  props: initDefaultProps.default(comfirmFuncProps(), {
    config: {
      width: 520,
      okType: "primary"
    }
  }),
  setup(props, {
    expose
  }) {
    var _a;
    const open = vue.computed(() => props.open);
    const innerConfig = vue.computed(() => props.config);
    const {
      direction,
      getPrefixCls
    } = context.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] = LocaleReceiver.useLocaleReceiver("Modal", en_US.default.Modal);
    return () => vue.createVNode(ConfirmDialog.default, vue.mergeProps({
      "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);
  }
});

exports.default = HookModal;
//# sourceMappingURL=HookModal.js.map
