/**
 * Copyright Aquera Inc 2025
 *
 * This source code is licensed under the BSD-3-Clause license found in the
 * LICENSE file in the root directory of this source tree.
 */
export class VirtualSelectSearchManager {
    static filterVirtualOptions(searchValue, originalOptionItems, data, renderItemFunction, getItemDescription, descriptionSearchEnabled, getSearchText) {
        if (originalOptionItems.length === 0 && data.length > 0) {
            return {
                filteredItems: [...data],
                showNoResults: false
            };
        }
        if (!originalOptionItems || originalOptionItems.length === 0) {
            return {
                filteredItems: [],
                showNoResults: true
            };
        }
        if (!searchValue || searchValue.trim() === '') {
            return {
                filteredItems: [...originalOptionItems],
                showNoResults: false
            };
        }
        const lowerCaseSearchValue = searchValue.toLowerCase();
        const searchTextFn = getSearchText || renderItemFunction;
        const filteredItems = originalOptionItems.filter((item) => {
            const itemValue = searchTextFn(item);
            const lowerCaseItemValue = itemValue.toLowerCase();
            const itemDescription = getItemDescription(item);
            if (descriptionSearchEnabled && itemDescription) {
                return lowerCaseItemValue.includes(lowerCaseSearchValue) || itemDescription.includes(lowerCaseSearchValue);
            }
            return lowerCaseItemValue.includes(lowerCaseSearchValue);
        });
        return {
            filteredItems,
            showNoResults: filteredItems.length === 0
        };
    }
}
//# sourceMappingURL=search-manager.js.map