import { classNames } from "@v-c/util";
import { computed, createVNode, defineComponent, isVNode } from "vue";
import { Tooltip } from "antdv-next";
import { CloseOutlined } from "@antdv-next/icons";
//#region components/sender/components/Skill.tsx
function _isSlot(s) {
	return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
var Skill_default = /* @__PURE__ */ defineComponent({
	name: "SenderSkill",
	props: {
		prefixCls: {
			type: String,
			required: true
		},
		skill: {
			type: Object,
			required: true
		},
		removeSkill: {
			type: Function,
			required: true
		}
	},
	setup(props) {
		const componentCls = computed(() => `${props.prefixCls}-skill`);
		const closeNode = computed(() => {
			const closable = props.skill.closable;
			if (!closable) return null;
			const config = typeof closable === "boolean" ? {} : closable;
			const closeIcon = config.closeIcon ?? createVNode(CloseOutlined, { "class": `${componentCls.value}-close-icon` }, null);
			return createVNode("div", {
				"class": classNames([`${componentCls.value}-close`, { [`${componentCls.value}-close-disabled`]: config.disabled }]),
				"role": "button",
				"aria-label": "Close skill",
				"tabindex": 0,
				"onClick": (event) => {
					if (config.disabled) return;
					event.stopPropagation();
					props.removeSkill();
					config.onClose?.(event);
				}
			}, [closeIcon]);
		});
		return () => {
			const mergeTitle = props.skill.title ?? props.skill.value;
			const titleNode = props.skill.toolTip ? createVNode(Tooltip, props.skill.toolTip, _isSlot(mergeTitle) ? mergeTitle : { default: () => [mergeTitle] }) : mergeTitle;
			return createVNode("div", {
				"class": `${componentCls.value}-wrapper`,
				"contenteditable": false
			}, [createVNode("div", {
				"class": `${componentCls.value}-tag`,
				"contenteditable": false,
				"role": "button",
				"tabindex": 0
			}, [createVNode("span", { "class": `${componentCls.value}-tag-text` }, [titleNode]), closeNode.value]), createVNode("div", { "class": `${componentCls.value}-holder` }, null)]);
		};
	}
});
//#endregion
export { Skill_default as default };
