import useXComponentConfig from "../_utils/hooks/use-x-component-config.js";
import style_default from "./style/index.js";
import { computed, createVNode, defineComponent, isVNode, mergeProps, ref, useAttrs } from "vue";
import { useConfig } from "antdv-next/config-provider/context";
import { Typography } from "antdv-next";
//#region components/welcome/index.tsx
function _isSlot(s) {
	return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
function isImageUrl(icon) {
	return typeof icon === "string" && /^https?:\/\//.test(icon);
}
function hasContent(value) {
	return Array.isArray(value) ? value.length > 0 : value !== null && value !== void 0;
}
var XWelcome = /* @__PURE__ */ defineComponent({
	name: "AxWelcome",
	inheritAttrs: false,
	props: {
		prefixCls: {
			type: String,
			default: "antd-welcome"
		},
		style: {
			type: [
				String,
				Object,
				Array
			],
			default: void 0
		},
		styles: {
			type: Object,
			default: () => ({})
		},
		class: {
			type: [
				String,
				Array,
				Object
			],
			default: void 0
		},
		classes: {
			type: Object,
			default: () => ({})
		},
		rootClass: {
			type: String,
			default: ""
		},
		variant: {
			type: String,
			default: "filled"
		},
		icon: {
			type: [
				String,
				Number,
				Object
			],
			default: void 0
		},
		title: {
			type: [
				String,
				Number,
				Object
			],
			default: void 0
		},
		description: {
			type: [
				String,
				Number,
				Object
			],
			default: void 0
		},
		extra: {
			type: [
				String,
				Number,
				Object
			],
			default: void 0
		}
	},
	setup(props, { expose, slots }) {
		const configCtx = useConfig();
		const attrs = useAttrs();
		const contextConfig = useXComponentConfig("welcome");
		const rootRef = ref();
		const [hashId, cssVarCls] = style_default(computed(() => props.prefixCls));
		expose({ get nativeElement() {
			return rootRef.value;
		} });
		const domAttrs = computed(() => {
			const { class: _class, style: _style, ...rest } = attrs;
			return rest;
		});
		const mergedCls = computed(() => [
			props.prefixCls,
			props.rootClass,
			contextConfig.value.classes?.root,
			props.classes?.root,
			hashId.value,
			cssVarCls.value,
			attrs.class,
			props.class,
			`${props.prefixCls}-${props.variant}`,
			{ [`${props.prefixCls}-rtl`]: configCtx.value.direction === "rtl" }
		]);
		const iconNode = computed(() => {
			const iconContent = slots.icon?.() ?? props.icon;
			if (!hasContent(iconContent)) return null;
			const imageSrc = !slots.icon && isImageUrl(iconContent) ? iconContent : void 0;
			return createVNode("div", {
				"class": [
					`${props.prefixCls}-icon`,
					contextConfig.value.classes?.icon,
					props.classes?.icon
				],
				"style": [contextConfig.value.styles?.icon, props.styles?.icon]
			}, [imageSrc ? createVNode("img", {
				"src": imageSrc,
				"alt": "icon"
			}, null) : iconContent]);
		});
		const titleNode = computed(() => {
			const titleContent = slots.title?.() ?? props.title;
			if (!hasContent(titleContent)) return null;
			return createVNode(Typography.Title, {
				"level": 4,
				"class": [
					`${props.prefixCls}-title`,
					contextConfig.value.classes?.title,
					props.classes?.title
				],
				"style": [contextConfig.value.styles?.title, props.styles?.title]
			}, _isSlot(titleContent) ? titleContent : { default: () => [titleContent] });
		});
		const extraNode = computed(() => {
			const extraContent = slots.extra?.() ?? props.extra;
			if (!hasContent(extraContent)) return null;
			return createVNode("div", {
				"class": [
					`${props.prefixCls}-extra`,
					contextConfig.value.classes?.extra,
					props.classes?.extra
				],
				"style": [contextConfig.value.styles?.extra, props.styles?.extra]
			}, [extraContent]);
		});
		const descriptionNode = computed(() => {
			const descriptionContent = slots.description?.() ?? props.description;
			if (!hasContent(descriptionContent)) return null;
			return createVNode(Typography.Text, {
				"class": [
					`${props.prefixCls}-description`,
					contextConfig.value.classes?.description,
					props.classes?.description
				],
				"style": [contextConfig.value.styles?.description, props.styles?.description]
			}, _isSlot(descriptionContent) ? descriptionContent : { default: () => [descriptionContent] });
		});
		return () => createVNode("div", mergeProps({ "ref": rootRef }, domAttrs.value, {
			"class": mergedCls.value,
			"style": [
				contextConfig.value.style,
				contextConfig.value.styles?.root,
				props.styles?.root,
				attrs.style,
				props.style
			]
		}), [iconNode.value, createVNode("div", { "class": `${props.prefixCls}-content-wrapper` }, [extraNode.value ? createVNode("div", { "class": `${props.prefixCls}-title-wrapper` }, [titleNode.value, extraNode.value]) : titleNode.value, descriptionNode.value])]);
	}
});
//#endregion
export { XWelcome, XWelcome as default };
