import { useComponentBaseConfig } from "../config-provider/context.js";
import { pureAttrs, useMergeSemantic, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
import { toPropsRefs } from "../_util/tools.js";
import useCSSVarCls_default from "../config-provider/hooks/useCSSVarCls.js";
import style_default from "./style/index.js";
import { Fragment, computed, createVNode, defineComponent, mergeProps } from "vue";
import { clsx } from "@v-c/util";
import { CheckCircleFilled, CloseCircleFilled, ExclamationCircleFilled, InfoCircleFilled, LoadingOutlined } from "@antdv-next/icons";
import { omit } from "es-toolkit";
import { Notification } from "@v-c/notification";

//#region src/message/PurePanel.tsx
const TypeIcon = {
	info: InfoCircleFilled,
	success: CheckCircleFilled,
	error: CloseCircleFilled,
	warning: ExclamationCircleFilled,
	loading: LoadingOutlined
};
/**
* Mirrors ant-design 6.4 `getMessageIcon`. Returns a renderable icon vnode for
* the type, allowing a custom `icon` to take precedence. The notice element
* wraps it with `${prefixCls}-notice-icon`, so the returned vnode does NOT
* need the `${prefixCls}-icon` class anymore.
*/
function resolveMessageIcon(_prefixCls, icon, type) {
	if (icon !== void 0 && icon !== null) return icon;
	const IconNode = type ? TypeIcon[type] : null;
	return IconNode ? createVNode(IconNode, null, null) : null;
}
const PureContent = /* @__PURE__ */ defineComponent((props, { slots }) => {
	return () => {
		const { prefixCls, type, icon } = props;
		return createVNode(Fragment, null, [resolveMessageIcon(prefixCls, icon, type), slots.default?.()]);
	};
}, {
	props: {
		prefixCls: {
			type: String,
			required: true
		},
		type: {
			type: String,
			required: false
		},
		icon: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		classNames: {
			type: Object,
			required: false
		},
		styles: {
			type: Object,
			required: false
		}
	},
	name: "MessagePureContent",
	inheritAttrs: false
});
const omitKeys = [
	"prefixCls",
	"type",
	"icon",
	"content",
	"classes",
	"styles",
	"class"
];
/** @private Internal Component. Do not use in your production. */
const PurePanel = /* @__PURE__ */ defineComponent((props, { attrs }) => {
	const { classes: messageClassNames, styles } = toPropsRefs(props, "classes", "styles");
	const { getPrefixCls, class: contextClassName, style: contextStyle, classes: contextClassNames, styles: contextStyles } = useComponentBaseConfig("message", props);
	const prefixCls = computed(() => props.prefixCls ?? getPrefixCls("message"));
	const mergedProps = computed(() => props);
	const rootCls = useCSSVarCls_default(prefixCls);
	const [hashId, cssVarCls] = style_default(prefixCls, rootCls);
	const [mergedClassNames, mergedStyles] = useMergeSemantic(useToArr(contextClassNames, messageClassNames), useToArr(contextStyles, styles), useToProps(mergedProps));
	return () => {
		const restProps = omit(props, omitKeys);
		const noticePrefixCls = `${prefixCls.value}-notice`;
		const iconNode = resolveMessageIcon(prefixCls.value, props.icon, props.type);
		const typeIconCls = props.type ? `${noticePrefixCls}-icon-${props.type}` : void 0;
		return createVNode(Notification, mergeProps(pureAttrs(attrs), restProps, {
			"prefixCls": prefixCls.value,
			"duration": null,
			"classNames": {
				wrapper: clsx(props.type && `${prefixCls.value}-${props.type}`, mergedClassNames.value?.wrapper),
				icon: clsx(typeIconCls, mergedClassNames.value?.icon),
				title: mergedClassNames.value?.title
			},
			"styles": {
				wrapper: mergedStyles.value?.wrapper,
				icon: mergedStyles.value?.icon,
				title: mergedStyles.value?.title
			},
			"class": clsx(contextClassName.value, mergedClassNames.value?.root, props.class, hashId.value, cssVarCls.value, rootCls.value, `${prefixCls.value}-notice-pure-panel`, props.type && `${noticePrefixCls}-${props.type}`),
			"style": {
				...mergedStyles.value.root,
				...contextStyle.value,
				...attrs.style
			},
			"icon": iconNode,
			"title": props.content
		}), null);
	};
}, {
	props: {
		content: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		duration: {
			type: [
				Number,
				Boolean,
				null
			],
			required: false,
			default: void 0
		},
		showProgress: {
			type: Boolean,
			required: false,
			default: void 0
		},
		pauseOnHover: {
			type: Boolean,
			required: false,
			default: void 0
		},
		closable: {
			type: [Boolean, Object],
			required: false,
			default: void 0
		},
		closeIcon: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		props: {
			type: Object,
			required: false
		},
		onClose: { required: false },
		onClick: {
			type: Function,
			required: false
		},
		prefixCls: {
			type: String,
			required: false
		},
		class: {
			type: String,
			required: false
		},
		classes: {
			type: [Object, Function],
			required: false
		},
		styles: {
			type: [Object, Function],
			required: false
		},
		type: {
			type: String,
			required: false
		},
		icon: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		}
	},
	name: "MessagePurePanel",
	inheritAttrs: false
});
var PurePanel_default = PurePanel;

//#endregion
export { PureContent, TypeIcon, PurePanel_default as default, resolveMessageIcon };