import { getText } from "../../../locales/index.js";
import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import React from "react";
import { Drawer, Dropdown, Modal } from "antd";
import { CloseOutlined } from "@ant-design/icons";
//#region src/components/pisellLookup/components/LookupResultHost.tsx
/**
* LookupResultHost 组件
* 结果承载层：根据展示类型渲染不同的容器
*/
const LookupResultHost = (props) => {
	const { displayType, visible, onClose, children, modalWidth = 834, modalStyle, getContainer, drawerWidth = 378, drawerPlacement = "right", popupWidth, containerStyle, containerClassName, mask = false, maskClosable = true, zIndex, onAfterOpen } = props;
	/**
	* 渲染 Inline 模式
	*/
	const renderInline = () => {
		if (!visible) return null;
		if (!children) return null;
		return /* @__PURE__ */ React.createElement("div", {
			className: `pisell-lookup-result-inline ${containerClassName || ""}`,
			style: containerStyle
		}, children);
	};
	/**
	* 渲染 Popup 模式
	*/
	const renderPopup = () => {
		if (!visible || !children) return null;
		return /* @__PURE__ */ React.createElement(Dropdown, {
			open: visible,
			onOpenChange: (open) => {
				if (!open) onClose();
			},
			dropdownRender: () => /* @__PURE__ */ React.createElement("div", {
				className: `pisell-lookup-result-popup ${containerClassName || ""}`,
				style: _objectSpread2({
					width: popupWidth,
					background: "#fff",
					borderRadius: 8,
					boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)"
				}, containerStyle)
			}, children),
			trigger: ["click"]
		}, /* @__PURE__ */ React.createElement("div", null));
	};
	/**
	* 渲染 Modal 模式
	*/
	const renderModal = () => {
		const effectiveMaskClosable = mask ? maskClosable : false;
		const hasCustomContainer = getContainer !== void 0;
		const modalClassName = [
			"pisell-lookup-modal-container",
			!mask ? "pisell-lookup-modal-no-mask" : "",
			containerClassName || ""
		].filter(Boolean).join(" ");
		const wrapClassName = hasCustomContainer ? "pisell-lookup-modal-custom-container" : "";
		return /* @__PURE__ */ React.createElement(Modal, {
			open: visible,
			onCancel: onClose,
			footer: null,
			width: modalWidth,
			style: _objectSpread2({ top: 8 }, modalStyle),
			getContainer,
			mask,
			maskClosable: effectiveMaskClosable,
			zIndex,
			className: modalClassName,
			wrapClassName,
			closeIcon: null,
			destroyOnClose: true,
			title: null,
			afterOpenChange: (open) => {
				if (open && onAfterOpen) onAfterOpen();
			}
		}, /* @__PURE__ */ React.createElement("div", {
			className: "pisell-lookup-modal-wrapper",
			style: containerStyle
		}, children));
	};
	/**
	* 渲染 Drawer 模式
	*/
	const renderDrawer = () => {
		const effectiveMaskClosable = mask ? maskClosable : false;
		const drawerClassName = `pisell-lookup-drawer-container ${!mask ? "pisell-lookup-drawer-no-mask" : ""} ${containerClassName || ""}`;
		return /* @__PURE__ */ React.createElement(Drawer, {
			open: visible,
			onClose,
			width: drawerWidth,
			placement: drawerPlacement,
			mask,
			maskClosable: effectiveMaskClosable,
			zIndex,
			className: drawerClassName,
			closeIcon: /* @__PURE__ */ React.createElement(CloseOutlined, null),
			destroyOnClose: true,
			title: getText("pisell-lookup-confirm-button-text"),
			afterOpenChange: (open) => {
				if (open && onAfterOpen) onAfterOpen();
			}
		}, /* @__PURE__ */ React.createElement("div", {
			className: "pisell-lookup-drawer-content",
			style: containerStyle
		}, children));
	};
	/**
	* 渲染 Detached 模式
	*/
	const renderDetached = () => {
		if (!visible) return null;
		if (!children) return null;
		return /* @__PURE__ */ React.createElement("div", {
			className: `pisell-lookup-result-detached ${containerClassName || ""}`,
			style: containerStyle
		}, children);
	};
	switch (displayType) {
		case "inline": return renderInline();
		case "popup": return renderPopup();
		case "modal": return renderModal();
		case "drawer": return renderDrawer();
		case "detached": return renderDetached();
		default: return renderInline();
	}
};
LookupResultHost.displayName = "LookupResultHost";
//#endregion
export { LookupResultHost };
