import React, { Suspense } from 'react';
import { WixPatternsTestProvider } from '../components';
import { Page, WixStyleReactEnvironmentProvider } from '@wix/design-system';
import { WixPatternsContainerProvider } from '@wix/bex-core/react';
import { EssentialsProvider } from '@wix/fe-essentials/react';
import { EntityPage } from '../components/EntityPage';
import { CollectionPage } from '../components/CollectionPageNew';
import { PageWrapper } from '../components/PageWrapper/PageWrapper';
const CairoTestAppRouter = React.lazy(() => import('./CairoTestAppRouter').then((module) => ({
    default: module.CairoTestAppRouter,
})));
export function CairoTestApp({ children, driver, page, scrollElement, entityPageState, collectionPageState, routerParams, collectionPageHeaderProps, }) {
    let child = children;
    switch (page) {
        case 'wsr':
            child = (React.createElement(Page, null,
                React.createElement(Page.Header, { title: "Page Title" }),
                React.createElement(Page.Content, null, children)));
            break;
        case 'entity':
            child = (React.createElement(Page, null,
                React.createElement(Page.Content, null, children)));
            break;
        case 'none':
            child = (React.createElement("div", { ref: scrollElement, "data-hook": "custom-scroll-container", style: { height: '200px', overflow: 'auto' } }, child));
            break;
        case 'entity-page':
            if (!entityPageState) {
                throw new Error('Page state was not initialized');
            }
            child = (React.createElement(EntityPage, { state: entityPageState, dataHook: page }, children));
            break;
        case 'collection-page':
            if (!collectionPageState) {
                throw new Error('Page state was not initialized');
            }
            child = (React.createElement(CollectionPage, { dataHook: page },
                React.createElement(CollectionPage.Header, { title: {
                        text: collectionPageState.pageTitle || 'Title',
                        hideTotal: collectionPageState.hideHeaderTotal,
                    }, ...collectionPageHeaderProps }),
                React.createElement(CollectionPage.Content, null, children)));
            break;
        case 'router':
            if (!routerParams) {
                throw new Error('Router params were not initialized');
            }
            child = (React.createElement(Suspense, { fallback: React.createElement("div", null, "Loading router...") },
                React.createElement(CairoTestAppRouter, null, children)));
            break;
        default:
            child = (React.createElement(PageWrapper, null,
                React.createElement(Page, null,
                    React.createElement(Page.Content, null, children))));
            break;
    }
    return (React.createElement(EssentialsProvider, { essentials: driver.testContext },
        React.createElement(WixStyleReactEnvironmentProvider, { locale: driver.testContext.environment.language },
            React.createElement(WixPatternsTestProvider, null,
                React.createElement(WixPatternsContainerProvider, { value: driver.container }, child)))));
}
//# sourceMappingURL=CairoTestApp.js.map