'use strict';

/**
 * 点击外部检测工具
 * 统一管理 document click 事件监听，用于下拉/弹出组件的关闭逻辑
 */
/**
 * 创建点击外部处理器
 * 返回清理函数，用于在 disconnectedCallback 中移除监听
 */
function createClickOutsideHandler(options) {
    const handler = (e) => {
        if (!options.isOpen())
            return;
        const target = e.target;
        if (!options.host.contains(target)) {
            options.onClose();
        }
    };
    const connect = () => document.addEventListener('click', handler);
    const disconnect = () => document.removeEventListener('click', handler);
    return { connect, disconnect };
}

exports.createClickOutsideHandler = createClickOutsideHandler;

//# sourceMappingURL=click-outside-3fcc00dd.js.map