import { defaultExtractor, search } from "./utils.js";
/**
 * @since 6.2.0
 * @internal
 */ const DEFAULT_EXTRACTOR = defaultExtractor("caseInsensitiveSearch");
/**
 * @since 6.0.0
 */ export function isCaseInsensitiveMatch(options) {
    const { query, value, startsWith } = options;
    const matchIndex = value.indexOf(query);
    if (startsWith) {
        return matchIndex === 0;
    }
    return matchIndex !== -1;
}
export function caseInsensitiveSearch(options) {
    const { list, type = "filter", query, extractor = DEFAULT_EXTRACTOR, startsWith, whitespace } = options;
    return search({
        type,
        list,
        query,
        extractor,
        whitespace,
        filter (q, value) {
            return isCaseInsensitiveMatch({
                query: q,
                value,
                startsWith
            });
        }
    });
}

//# sourceMappingURL=caseInsensitive.js.map