import { isDefined, keyIn } from "ts-extras";
const isSelectorObject = (value) => typeof value === "object" && value !== null && keyIn(value, "selector");
/**
 * Normalize a selector option into a selector entry object.
 */
export const normalizeSyntaxSelector = (selector) => {
    if (isSelectorObject(selector)) {
        if (!isDefined(selector.message)) {
            return {
                selector: selector.selector,
            };
        }
        return {
            message: selector.message,
            selector: selector.selector,
        };
    }
    return {
        selector,
    };
};
/**
 * Build ESLint selector listeners from selector entries.
 */
export const buildRestrictedSyntaxListeners = (entries, report) => {
    // eslint-disable-next-line etc-misc/typescript/prefer-readonly-record -- Local builder object is mutated during listener collection before returning readonly view.
    const listeners = {};
    for (const entry of entries) {
        listeners[entry.selector] = (node) => {
            report(node, entry);
        };
    }
    return listeners;
};
//# sourceMappingURL=syntax-selectors.js.map