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