import { ObjectDirective } from 'vue';

declare const clickoutside: ObjectDirective<ClickOutsideElement, ClickOutsideHandler>;
export default clickoutside;

declare type ClickOutsideElement = HTMLElement & {
    _handler?: (e: MouseEvent) => void;
    _handlerDocs?: Document[];
};

/**
 * Determine whether a click occurred outside the referenced
 * element(s) or not. Trigger the directive's handler if so.
 *
 * Listens on the element's own document and every same-origin ancestor document up to
 * the top window. This covers iframe-mounted elements: clicks inside the iframe (own
 * doc) and clicks in the surrounding parent shell (ancestor doc) both reach the
 * handler. Cross-origin ancestors are skipped — accessing them would throw.
 */
declare type ClickOutsideHandler = (e: MouseEvent) => void;

export { }
