import { useSenderContext } from "./context.js";
import { Transition, computed, createVNode, defineComponent, vShow, withDirectives } from "vue";
import { useConfig } from "antdv-next/config-provider/context";
import { Button } from "antdv-next";
import { CloseOutlined } from "@antdv-next/icons";
//#region components/sender/SenderHeader.tsx
var SenderHeader_default = /* @__PURE__ */ defineComponent({
	name: "AxSenderHeader",
	props: {
		open: {
			type: Boolean,
			default: false
		},
		onOpenChange: {
			type: Function,
			default: void 0
		},
		title: {
			type: [String, Object],
			default: void 0
		},
		prefixCls: {
			type: String,
			default: void 0
		},
		class: {
			type: String,
			default: void 0
		},
		style: {
			type: [String, Object],
			default: void 0
		},
		classNames: {
			type: Object,
			default: () => ({})
		},
		styles: {
			type: Object,
			default: () => ({})
		},
		closable: {
			type: Boolean,
			default: true
		},
		forceRender: {
			type: Boolean,
			default: false
		}
	},
	setup(props, { slots }) {
		const configCtx = useConfig();
		const senderCtx = useSenderContext();
		const prefixCls = computed(() => {
			const senderPrefix = senderCtx.value.prefixCls;
			return `${props.prefixCls ?? senderPrefix ?? "antd-sender"}-header`;
		});
		const direction = computed(() => configCtx.value.direction);
		return () => {
			const headerCls = prefixCls.value;
			const contentNode = createVNode("div", {
				"class": [
					headerCls,
					props.class,
					{ [`${headerCls}-rtl`]: direction.value === "rtl" }
				],
				"style": props.style
			}, [(props.closable || props.title) && createVNode("div", {
				"class": [`${headerCls}-header`, props.classNames.header],
				"style": props.styles.header
			}, [createVNode("div", { "class": `${headerCls}-title` }, [slots.title?.() ?? props.title]), props.closable && createVNode("div", { "class": `${headerCls}-close` }, [createVNode(Button, {
				"type": "text",
				"icon": createVNode(CloseOutlined, null, null),
				"size": "small",
				"onClick": () => props.onOpenChange?.(!props.open)
			}, null)])]), slots.default && createVNode("div", {
				"class": [`${headerCls}-content`, props.classNames.content],
				"style": props.styles.content
			}, [slots.default()])]);
			return createVNode(Transition, {
				"name": `${headerCls}-motion`,
				"onBeforeEnter": (el) => {
					el.style.height = "0px";
					el.style.overflow = "hidden";
				},
				"onEnter": (el) => {
					el.style.height = `${el.scrollHeight}px`;
				},
				"onAfterEnter": (el) => {
					el.style.height = "";
					el.style.overflow = "";
				},
				"onBeforeLeave": (el) => {
					el.style.height = `${el.scrollHeight}px`;
					el.style.overflow = "hidden";
				},
				"onLeave": (el) => {
					el.offsetHeight;
					el.style.height = "0px";
				},
				"onAfterLeave": (el) => {
					el.style.height = "";
					el.style.overflow = "";
				}
			}, { default: () => [props.forceRender ? withDirectives(contentNode, [[vShow, props.open]]) : props.open && contentNode] });
		};
	}
});
//#endregion
export { SenderHeader_default as default };
