import { createComponent } from '@lit/react';
import React, { useRef, useEffect } from 'react';
import { AtomicAriaLive as AtomicAriaLive$1, AtomicAutomaticFacet as AtomicAutomaticFacet$1, AtomicAutomaticFacetGenerator as AtomicAutomaticFacetGenerator$1, AtomicBreadbox as AtomicBreadbox$1, AtomicCategoryFacet as AtomicCategoryFacet$1, AtomicColorFacet as AtomicColorFacet$1, AtomicComponentError as AtomicComponentError$1, AtomicDidYouMean as AtomicDidYouMean$1, AtomicExternal as AtomicExternal$1, AtomicFacet as AtomicFacet$1, AtomicFacetManager as AtomicFacetManager$1, AtomicFocusTrap as AtomicFocusTrap$1, AtomicFormatCurrency as AtomicFormatCurrency$1, AtomicFormatNumber as AtomicFormatNumber$1, AtomicFormatUnit as AtomicFormatUnit$1, AtomicGeneratedAnswer as AtomicGeneratedAnswer$1, AtomicGeneratedAnswerFeedbackModal as AtomicGeneratedAnswerFeedbackModal$1, AtomicHtml as AtomicHtml$1, AtomicIcon as AtomicIcon$1, AtomicLayoutSection as AtomicLayoutSection$1, AtomicLoadMoreResults as AtomicLoadMoreResults$1, AtomicNoResults as AtomicNoResults$1, AtomicNotifications as AtomicNotifications$1, AtomicNumericFacet as AtomicNumericFacet$1, AtomicNumericRange as AtomicNumericRange$1, AtomicPager as AtomicPager$1, AtomicPopover as AtomicPopover$1, AtomicQueryError as AtomicQueryError$1, AtomicQuerySummary as AtomicQuerySummary$1, AtomicQuickview as AtomicQuickview$1, AtomicQuickviewModal as AtomicQuickviewModal$1, AtomicRatingFacet as AtomicRatingFacet$1, AtomicRatingRangeFacet as AtomicRatingRangeFacet$1, AtomicRecsError as AtomicRecsError$1, AtomicRecsInterface as AtomicRecsInterface$1, AtomicRecsList as AtomicRecsList$1, AtomicRecsResult as AtomicRecsResult$1, AtomicRefineModal as AtomicRefineModal$1, AtomicRefineToggle as AtomicRefineToggle$1, AtomicResult as AtomicResult$1, AtomicResultBadge as AtomicResultBadge$1, AtomicResultChildren as AtomicResultChildren$1, AtomicResultChildrenTemplate as AtomicResultChildrenTemplate$1, AtomicResultDate as AtomicResultDate$1, AtomicResultFieldsList as AtomicResultFieldsList$1, AtomicResultHtml as AtomicResultHtml$1, AtomicResultIcon as AtomicResultIcon$1, AtomicResultImage as AtomicResultImage$1, AtomicResultLink as AtomicResultLink$1, AtomicResultLocalizedText as AtomicResultLocalizedText$1, AtomicResultMultiValueText as AtomicResultMultiValueText$1, AtomicResultNumber as AtomicResultNumber$1, AtomicResultPrintableUri as AtomicResultPrintableUri$1, AtomicResultRating as AtomicResultRating$1, AtomicResultSectionActions as AtomicResultSectionActions$1, AtomicResultSectionBadges as AtomicResultSectionBadges$1, AtomicResultSectionBottomMetadata as AtomicResultSectionBottomMetadata$1, AtomicResultSectionChildren as AtomicResultSectionChildren$1, AtomicResultSectionEmphasized as AtomicResultSectionEmphasized$1, AtomicResultSectionExcerpt as AtomicResultSectionExcerpt$1, AtomicResultSectionTitle as AtomicResultSectionTitle$1, AtomicResultSectionTitleMetadata as AtomicResultSectionTitleMetadata$1, AtomicResultSectionVisual as AtomicResultSectionVisual$1, AtomicResultsPerPage as AtomicResultsPerPage$1, AtomicResultText as AtomicResultText$1, AtomicResultTimespan as AtomicResultTimespan$1, AtomicSearchBox as AtomicSearchBox$1, AtomicSearchBoxQuerySuggestions as AtomicSearchBoxQuerySuggestions$1, AtomicSearchBoxRecentQueries as AtomicSearchBoxRecentQueries$1, AtomicSearchLayout as AtomicSearchLayout$1, AtomicSegmentedFacet as AtomicSegmentedFacet$1, AtomicSegmentedFacetScrollable as AtomicSegmentedFacetScrollable$1, AtomicSmartSnippet as AtomicSmartSnippet$1, AtomicSmartSnippetFeedbackModal as AtomicSmartSnippetFeedbackModal$1, AtomicSmartSnippetSuggestions as AtomicSmartSnippetSuggestions$1, AtomicSortDropdown as AtomicSortDropdown$1, AtomicSortExpression as AtomicSortExpression$1, AtomicTab as AtomicTab$1, AtomicTableElement as AtomicTableElement$1, AtomicTabManager as AtomicTabManager$1, AtomicText as AtomicText$1, AtomicTimeframe as AtomicTimeframe$1, AtomicTimeframeFacet as AtomicTimeframeFacet$1, AtomicFoldedResultList as AtomicFoldedResultList$1, AtomicResultList as AtomicResultList$1, AtomicSearchBoxInstantResults as AtomicSearchBoxInstantResults$1, AtomicSearchInterface as AtomicSearchInterface$1 } from '@coveo/atomic/components';
import { flushSync } from 'react-dom';
import { createRoot } from 'react-dom/client';
import { buildSearchEngine, getSampleSearchEngineConfiguration } from '@coveo/headless';

const AtomicAriaLive = /*@__PURE__*/ createComponent({
    tagName: 'atomic-aria-live',
    react: React,
    elementClass: AtomicAriaLive$1,
});
const AtomicAutomaticFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-automatic-facet',
    react: React,
    elementClass: AtomicAutomaticFacet$1,
});
const AtomicAutomaticFacetGenerator = /*@__PURE__*/ createComponent({
    tagName: 'atomic-automatic-facet-generator',
    react: React,
    elementClass: AtomicAutomaticFacetGenerator$1,
});
const AtomicBreadbox = /*@__PURE__*/ createComponent({
    tagName: 'atomic-breadbox',
    react: React,
    elementClass: AtomicBreadbox$1,
});
const AtomicCategoryFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-category-facet',
    react: React,
    elementClass: AtomicCategoryFacet$1,
});
const AtomicColorFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-color-facet',
    react: React,
    elementClass: AtomicColorFacet$1,
});
const AtomicComponentError = /*@__PURE__*/ createComponent({
    tagName: 'atomic-component-error',
    react: React,
    elementClass: AtomicComponentError$1,
});
const AtomicDidYouMean = /*@__PURE__*/ createComponent({
    tagName: 'atomic-did-you-mean',
    react: React,
    elementClass: AtomicDidYouMean$1,
});
const AtomicExternal = /*@__PURE__*/ createComponent({
    tagName: 'atomic-external',
    react: React,
    elementClass: AtomicExternal$1,
});
const AtomicFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-facet',
    react: React,
    elementClass: AtomicFacet$1,
});
const AtomicFacetManager = /*@__PURE__*/ createComponent({
    tagName: 'atomic-facet-manager',
    react: React,
    elementClass: AtomicFacetManager$1,
});
const AtomicFocusTrap = /*@__PURE__*/ createComponent({
    tagName: 'atomic-focus-trap',
    react: React,
    elementClass: AtomicFocusTrap$1,
});
const AtomicFoldedResultList = /*@__PURE__*/ createComponent({
    tagName: 'atomic-folded-result-list',
    react: React,
    elementClass: AtomicFoldedResultList$1,
});
const AtomicFormatCurrency = /*@__PURE__*/ createComponent({
    tagName: 'atomic-format-currency',
    react: React,
    elementClass: AtomicFormatCurrency$1,
});
const AtomicFormatNumber = /*@__PURE__*/ createComponent({
    tagName: 'atomic-format-number',
    react: React,
    elementClass: AtomicFormatNumber$1,
});
const AtomicFormatUnit = /*@__PURE__*/ createComponent({
    tagName: 'atomic-format-unit',
    react: React,
    elementClass: AtomicFormatUnit$1,
});
const AtomicGeneratedAnswer = /*@__PURE__*/ createComponent({
    tagName: 'atomic-generated-answer',
    react: React,
    elementClass: AtomicGeneratedAnswer$1,
});
const AtomicGeneratedAnswerFeedbackModal = /*@__PURE__*/ createComponent({
    tagName: 'atomic-generated-answer-feedback-modal',
    react: React,
    elementClass: AtomicGeneratedAnswerFeedbackModal$1,
});
const AtomicHtml = /*@__PURE__*/ createComponent({
    tagName: 'atomic-html',
    react: React,
    elementClass: AtomicHtml$1,
});
const AtomicIcon = /*@__PURE__*/ createComponent({
    tagName: 'atomic-icon',
    react: React,
    elementClass: AtomicIcon$1,
});
const AtomicLayoutSection = /*@__PURE__*/ createComponent({
    tagName: 'atomic-layout-section',
    react: React,
    elementClass: AtomicLayoutSection$1,
});
const AtomicLoadMoreResults = /*@__PURE__*/ createComponent({
    tagName: 'atomic-load-more-results',
    react: React,
    elementClass: AtomicLoadMoreResults$1,
});
const AtomicNoResults = /*@__PURE__*/ createComponent({
    tagName: 'atomic-no-results',
    react: React,
    elementClass: AtomicNoResults$1,
});
const AtomicNotifications = /*@__PURE__*/ createComponent({
    tagName: 'atomic-notifications',
    react: React,
    elementClass: AtomicNotifications$1,
});
const AtomicNumericFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-numeric-facet',
    react: React,
    elementClass: AtomicNumericFacet$1,
});
const AtomicNumericRange = /*@__PURE__*/ createComponent({
    tagName: 'atomic-numeric-range',
    react: React,
    elementClass: AtomicNumericRange$1,
});
const AtomicPager = /*@__PURE__*/ createComponent({
    tagName: 'atomic-pager',
    react: React,
    elementClass: AtomicPager$1,
});
const AtomicPopover = /*@__PURE__*/ createComponent({
    tagName: 'atomic-popover',
    react: React,
    elementClass: AtomicPopover$1,
});
const AtomicQueryError = /*@__PURE__*/ createComponent({
    tagName: 'atomic-query-error',
    react: React,
    elementClass: AtomicQueryError$1,
});
const AtomicQuerySummary = /*@__PURE__*/ createComponent({
    tagName: 'atomic-query-summary',
    react: React,
    elementClass: AtomicQuerySummary$1,
});
const AtomicQuickview = /*@__PURE__*/ createComponent({
    tagName: 'atomic-quickview',
    react: React,
    elementClass: AtomicQuickview$1,
});
const AtomicQuickviewModal = /*@__PURE__*/ createComponent({
    tagName: 'atomic-quickview-modal',
    react: React,
    elementClass: AtomicQuickviewModal$1,
});
const AtomicRatingFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-rating-facet',
    react: React,
    elementClass: AtomicRatingFacet$1,
});
const AtomicRatingRangeFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-rating-range-facet',
    react: React,
    elementClass: AtomicRatingRangeFacet$1,
});
const AtomicRecsError = /*@__PURE__*/ createComponent({
    tagName: 'atomic-recs-error',
    react: React,
    elementClass: AtomicRecsError$1,
});
const AtomicRecsInterface = /*@__PURE__*/ createComponent({
    tagName: 'atomic-recs-interface',
    react: React,
    elementClass: AtomicRecsInterface$1,
});
const AtomicRecsList = /*@__PURE__*/ createComponent({
    tagName: 'atomic-recs-list',
    react: React,
    elementClass: AtomicRecsList$1,
});
const AtomicRecsResult = /*@__PURE__*/ createComponent({
    tagName: 'atomic-recs-result',
    react: React,
    elementClass: AtomicRecsResult$1,
});
const AtomicRefineModal = /*@__PURE__*/ createComponent({
    tagName: 'atomic-refine-modal',
    react: React,
    elementClass: AtomicRefineModal$1,
});
const AtomicRefineToggle = /*@__PURE__*/ createComponent({
    tagName: 'atomic-refine-toggle',
    react: React,
    elementClass: AtomicRefineToggle$1,
});
const AtomicResult = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result',
    react: React,
    elementClass: AtomicResult$1,
});
const AtomicResultBadge = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-badge',
    react: React,
    elementClass: AtomicResultBadge$1,
});
const AtomicResultChildren = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-children',
    react: React,
    elementClass: AtomicResultChildren$1,
});
const AtomicResultChildrenTemplate = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-children-template',
    react: React,
    elementClass: AtomicResultChildrenTemplate$1,
});
const AtomicResultDate = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-date',
    react: React,
    elementClass: AtomicResultDate$1,
});
const AtomicResultFieldsList = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-fields-list',
    react: React,
    elementClass: AtomicResultFieldsList$1,
});
const AtomicResultHtml = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-html',
    react: React,
    elementClass: AtomicResultHtml$1,
});
const AtomicResultIcon = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-icon',
    react: React,
    elementClass: AtomicResultIcon$1,
});
const AtomicResultImage = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-image',
    react: React,
    elementClass: AtomicResultImage$1,
});
const AtomicResultLink = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-link',
    react: React,
    elementClass: AtomicResultLink$1,
});
const AtomicResultList = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-list',
    react: React,
    elementClass: AtomicResultList$1,
});
const AtomicResultLocalizedText = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-localized-text',
    react: React,
    elementClass: AtomicResultLocalizedText$1,
});
const AtomicResultMultiValueText = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-multi-value-text',
    react: React,
    elementClass: AtomicResultMultiValueText$1,
});
const AtomicResultNumber = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-number',
    react: React,
    elementClass: AtomicResultNumber$1,
});
const AtomicResultPrintableUri = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-printable-uri',
    react: React,
    elementClass: AtomicResultPrintableUri$1,
});
const AtomicResultRating = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-rating',
    react: React,
    elementClass: AtomicResultRating$1,
});
const AtomicResultSectionActions = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-actions',
    react: React,
    elementClass: AtomicResultSectionActions$1,
});
const AtomicResultSectionBadges = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-badges',
    react: React,
    elementClass: AtomicResultSectionBadges$1,
});
const AtomicResultSectionBottomMetadata = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-bottom-metadata',
    react: React,
    elementClass: AtomicResultSectionBottomMetadata$1,
});
const AtomicResultSectionChildren = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-children',
    react: React,
    elementClass: AtomicResultSectionChildren$1,
});
const AtomicResultSectionEmphasized = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-emphasized',
    react: React,
    elementClass: AtomicResultSectionEmphasized$1,
});
const AtomicResultSectionExcerpt = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-excerpt',
    react: React,
    elementClass: AtomicResultSectionExcerpt$1,
});
const AtomicResultSectionTitle = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-title',
    react: React,
    elementClass: AtomicResultSectionTitle$1,
});
const AtomicResultSectionTitleMetadata = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-title-metadata',
    react: React,
    elementClass: AtomicResultSectionTitleMetadata$1,
});
const AtomicResultSectionVisual = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-section-visual',
    react: React,
    elementClass: AtomicResultSectionVisual$1,
});
const AtomicResultsPerPage = /*@__PURE__*/ createComponent({
    tagName: 'atomic-results-per-page',
    react: React,
    elementClass: AtomicResultsPerPage$1,
});
const AtomicResultText = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-text',
    react: React,
    elementClass: AtomicResultText$1,
});
const AtomicResultTimespan = /*@__PURE__*/ createComponent({
    tagName: 'atomic-result-timespan',
    react: React,
    elementClass: AtomicResultTimespan$1,
});
const AtomicSearchBox = /*@__PURE__*/ createComponent({
    tagName: 'atomic-search-box',
    react: React,
    elementClass: AtomicSearchBox$1,
});
const AtomicSearchBoxInstantResults = /*@__PURE__*/ createComponent({
    tagName: 'atomic-search-box-instant-results',
    react: React,
    elementClass: AtomicSearchBoxInstantResults$1,
});
const AtomicSearchBoxQuerySuggestions = /*@__PURE__*/ createComponent({
    tagName: 'atomic-search-box-query-suggestions',
    react: React,
    elementClass: AtomicSearchBoxQuerySuggestions$1,
});
const AtomicSearchBoxRecentQueries = /*@__PURE__*/ createComponent({
    tagName: 'atomic-search-box-recent-queries',
    react: React,
    elementClass: AtomicSearchBoxRecentQueries$1,
});
const AtomicSearchInterface = /*@__PURE__*/ createComponent({
    tagName: 'atomic-search-interface',
    react: React,
    elementClass: AtomicSearchInterface$1,
});
const AtomicSearchLayout = /*@__PURE__*/ createComponent({
    tagName: 'atomic-search-layout',
    react: React,
    elementClass: AtomicSearchLayout$1,
});
const AtomicSegmentedFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-segmented-facet',
    react: React,
    elementClass: AtomicSegmentedFacet$1,
});
const AtomicSegmentedFacetScrollable = /*@__PURE__*/ createComponent({
    tagName: 'atomic-segmented-facet-scrollable',
    react: React,
    elementClass: AtomicSegmentedFacetScrollable$1,
});
const AtomicSmartSnippet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-smart-snippet',
    react: React,
    elementClass: AtomicSmartSnippet$1,
});
const AtomicSmartSnippetFeedbackModal = /*@__PURE__*/ createComponent({
    tagName: 'atomic-smart-snippet-feedback-modal',
    react: React,
    elementClass: AtomicSmartSnippetFeedbackModal$1,
});
const AtomicSmartSnippetSuggestions = /*@__PURE__*/ createComponent({
    tagName: 'atomic-smart-snippet-suggestions',
    react: React,
    elementClass: AtomicSmartSnippetSuggestions$1,
});
const AtomicSortDropdown = /*@__PURE__*/ createComponent({
    tagName: 'atomic-sort-dropdown',
    react: React,
    elementClass: AtomicSortDropdown$1,
});
const AtomicSortExpression = /*@__PURE__*/ createComponent({
    tagName: 'atomic-sort-expression',
    react: React,
    elementClass: AtomicSortExpression$1,
});
const AtomicTab = /*@__PURE__*/ createComponent({
    tagName: 'atomic-tab',
    react: React,
    elementClass: AtomicTab$1,
});
const AtomicTableElement = /*@__PURE__*/ createComponent({
    tagName: 'atomic-table-element',
    react: React,
    elementClass: AtomicTableElement$1,
});
const AtomicTabManager = /*@__PURE__*/ createComponent({
    tagName: 'atomic-tab-manager',
    react: React,
    elementClass: AtomicTabManager$1,
});
const AtomicText = /*@__PURE__*/ createComponent({
    tagName: 'atomic-text',
    react: React,
    elementClass: AtomicText$1,
});
const AtomicTimeframe = /*@__PURE__*/ createComponent({
    tagName: 'atomic-timeframe',
    react: React,
    elementClass: AtomicTimeframe$1,
});
const AtomicTimeframeFacet = /*@__PURE__*/ createComponent({
    tagName: 'atomic-timeframe-facet',
    react: React,
    elementClass: AtomicTimeframeFacet$1,
});

/**
 * This component serves as a wrapper for the core AtomicResultList.
 *
 * @param props
 * @returns
 */
const FoldedResultListWrapper = (props) => {
    const { template, ...otherProps } = props;
    const foldedResultListRef = useRef(null);
    useEffect(() => {
        foldedResultListRef.current?.setRenderFunction((foldedResult, root) => {
            flushSync(() => {
                createRoot(root).render(template(foldedResult));
            });
            return root.innerHTML;
        });
    }, [template]);
    return (React.createElement(AtomicFoldedResultList, { ref: foldedResultListRef, ...otherProps }));
};

/**
 * This component serves as a wrapper for the core AtomicResultList.
 *
 * @param props
 * @returns
 */
const ResultListWrapper = (props) => {
    const { template, ...otherProps } = props;
    const resultListRef = useRef(null);
    useEffect(() => {
        resultListRef.current?.setRenderFunction((result, root, linkContainer) => {
            const templateResult = template(result);
            if (isTemplate(templateResult)) {
                return renderTemplate(linkContainer, templateResult, root);
            }
            else {
                return renderJSXTemplate(linkContainer, root, templateResult, otherProps.display);
            }
        });
    }, [otherProps.display, template]);
    return React.createElement(AtomicResultList, { ref: resultListRef, ...otherProps });
};
const isTemplate = (template) => {
    return template.linkTemplate !== undefined;
};
function renderJSXTemplate(linkContainer, root, templateResult, display) {
    const contentRoot = createRoot(root);
    const linkRoot = linkContainer ? createRoot(linkContainer) : null;
    flushSync(() => {
        contentRoot.render(templateResult);
        if (!linkRoot) {
            return;
        }
        display === 'grid'
            ? linkRoot.render(React.createElement(AtomicResultLink, null))
            : // oxlint-disable-next-line react/jsx-no-useless-fragment -- <>
                linkRoot.render(React.createElement(React.Fragment, null));
    });
    return root.innerHTML;
}
function renderTemplate(linkContainer, templateResult, root) {
    const linkRoot = createRoot(linkContainer);
    const contentRoot = createRoot(root);
    flushSync(() => {
        linkRoot.render(templateResult.linkTemplate);
        contentRoot.render(templateResult.contentTemplate);
    });
    return root.innerHTML;
}

const SearchBoxInstantResultsWrapper = ({ maxResultsPerQuery, density, imageSize, template, ariaLabelGenerator, }) => {
    const ref = useRef(null);
    useEffect(() => {
        if (ref.current?.setRenderFunction) {
            ref.current.setRenderFunction((result, root) => {
                const templateResult = template(result);
                const contentRoot = createRoot(root);
                flushSync(() => {
                    contentRoot.render(templateResult);
                });
                return root.innerHTML;
            });
        }
    }, [template]);
    useEffect(() => {
        if (ref.current && ariaLabelGenerator) {
            ref.current.ariaLabelGenerator = ariaLabelGenerator;
        }
    }, [ariaLabelGenerator]);
    return (React.createElement(AtomicSearchBoxInstantResults
    // oxlint-disable-next-line @typescript-eslint/no-explicit-any -- Ref typing for web component
    , { 
        // oxlint-disable-next-line @typescript-eslint/no-explicit-any -- Ref typing for web component
        ref: ref, maxResultsPerQuery: maxResultsPerQuery, imageSize: imageSize, density: density }));
};

const DefaultProps = {
    onReady: (executeFirstRequest) => {
        return executeFirstRequest ? executeFirstRequest() : Promise.resolve();
    },
    localization: () => { },
};
/**
 * This component serves as a wrapper for the core AtomicSearchInterface.
 * @param props
 * @returns
 */
const SearchInterfaceWrapper = (props) => {
    const mergedProps = { ...DefaultProps, ...props };
    if (!mergedProps.engine) {
        mergedProps.engine = buildSearchEngine({
            configuration: getSampleSearchEngineConfiguration(),
        });
    }
    const { engine, localization, onReady, ...allOtherProps } = mergedProps;
    const searchInterfaceRef = useRef(null);
    let initialization = null;
    useEffect(() => {
        const searchInterfaceAtomic = searchInterfaceRef.current;
        if (!initialization) {
            initialization = searchInterfaceAtomic.initializeWithSearchEngine(engine);
            initialization.then(() => {
                localization(searchInterfaceAtomic.i18n);
                onReady(searchInterfaceAtomic.executeFirstSearch.bind(searchInterfaceAtomic));
            });
        }
    }, [engine, initialization, localization, onReady]);
    return (React.createElement(AtomicSearchInterface, { ref: searchInterfaceRef, ...allOtherProps }, props.children));
};

export { AtomicAriaLive, AtomicAutomaticFacet, AtomicAutomaticFacetGenerator, AtomicBreadbox, AtomicCategoryFacet, AtomicColorFacet, AtomicComponentError, AtomicDidYouMean, AtomicExternal, AtomicFacet, AtomicFacetManager, AtomicFocusTrap, FoldedResultListWrapper as AtomicFoldedResultList, AtomicFormatCurrency, AtomicFormatNumber, AtomicFormatUnit, AtomicGeneratedAnswer, AtomicGeneratedAnswerFeedbackModal, AtomicHtml, AtomicIcon, AtomicLayoutSection, AtomicLoadMoreResults, AtomicNoResults, AtomicNotifications, AtomicNumericFacet, AtomicNumericRange, AtomicPager, AtomicPopover, AtomicQueryError, AtomicQuerySummary, AtomicQuickview, AtomicQuickviewModal, AtomicRatingFacet, AtomicRatingRangeFacet, AtomicRecsError, AtomicRecsInterface, AtomicRecsList, AtomicRecsResult, AtomicRefineModal, AtomicRefineToggle, AtomicResult, AtomicResultBadge, AtomicResultChildren, AtomicResultChildrenTemplate, AtomicResultDate, AtomicResultFieldsList, AtomicResultHtml, AtomicResultIcon, AtomicResultImage, AtomicResultLink, ResultListWrapper as AtomicResultList, AtomicResultLocalizedText, AtomicResultMultiValueText, AtomicResultNumber, AtomicResultPrintableUri, AtomicResultRating, AtomicResultSectionActions, AtomicResultSectionBadges, AtomicResultSectionBottomMetadata, AtomicResultSectionChildren, AtomicResultSectionEmphasized, AtomicResultSectionExcerpt, AtomicResultSectionTitle, AtomicResultSectionTitleMetadata, AtomicResultSectionVisual, AtomicResultText, AtomicResultTimespan, AtomicResultsPerPage, AtomicSearchBox, SearchBoxInstantResultsWrapper as AtomicSearchBoxInstantResults, AtomicSearchBoxQuerySuggestions, AtomicSearchBoxRecentQueries, SearchInterfaceWrapper as AtomicSearchInterface, AtomicSearchLayout, AtomicSegmentedFacet, AtomicSegmentedFacetScrollable, AtomicSmartSnippet, AtomicSmartSnippetFeedbackModal, AtomicSmartSnippetSuggestions, AtomicSortDropdown, AtomicSortExpression, AtomicTab, AtomicTabManager, AtomicTableElement, AtomicText, AtomicTimeframe, AtomicTimeframeFacet };
//# sourceMappingURL=atomic-react.mjs.map
