import { isVNode } from 'vue';
import { isFunction } from '@vue/shared';
import { isString } from '../../../../utils/src/is.mjs';
import { ElMessage } from 'element-plus';
import { useGlobalConfig } from '../../../../hooks/base/useGlobalConfig/index.mjs';

const messageTypes = ["success", "info", "warning", "error"];
const normalizeMessageOptions = (params) => {
  const normalized = !params || isString(params) || isVNode(params) || isFunction(params) ? { message: params } : params;
  return normalized;
};
const message = (options = {}, context) => {
  const normalized = normalizeMessageOptions(options);
  const messageGlobalConfig = useGlobalConfig("message") ?? {};
  return ElMessage(
    {
      grouping: true,
      plain: messageGlobalConfig.value?.plain,
      //   duration: 5 * 1000,
      ...normalized
    },
    context
  );
};
message.closeAll = ElMessage.closeAll;
message.closeAllByPlacement = ElMessage.closeAllByPlacement;
message._context = ElMessage._context;
messageTypes.forEach((type) => {
  message[type] = (options = {}, appContext) => {
    const normalized = normalizeMessageOptions(options);
    return message({ ...normalized, type }, appContext);
  };
});

export { message as default, messageTypes, normalizeMessageOptions };
//# sourceMappingURL=method.mjs.map
