import { commerceCategoryFacetSearchSetReducer as categoryFacetSearchSet } from '../../../../../features/commerce/facets/facet-search-set/category/commerce-category-facet-search-set-slice.js';
import { executeCommerceFacetSearch, executeCommerceFieldSuggest, } from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js';
import { loadReducerError } from '../../../../../utils/errors.js';
import { buildCoreCategoryFacetSearch, } from '../../../../core/facets/facet-search/category/headless-category-facet-search.js';
export function buildCategoryFacetSearch(engine, props) {
    if (!loadCategoryFacetSearchReducers(engine)) {
        throw loadReducerError;
    }
    const { state: _state, updateCaptions: _updateCaptions, ...restOfFacetSearch } = buildCoreCategoryFacetSearch(engine, {
        ...props,
        executeFacetSearchActionCreator: (facetId) => executeCommerceFacetSearch({
            facetId,
            facetSearchType: props.options.type,
        }),
        executeFieldSuggestActionCreator: (facetId) => executeCommerceFieldSuggest({
            facetId,
            facetSearchType: props.options.type,
        }),
    });
    return restOfFacetSearch;
}
function loadCategoryFacetSearchReducers(engine) {
    engine.addReducers({ categoryFacetSearchSet });
    return true;
}
