"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@bluebase/core");
const navigators_1 = require("../navigators");
const react_1 = tslib_1.__importDefault(require("react"));
function renderNavigator(navigator, BB) {
    const { type, routes } = navigator;
    // If routes is a thunk, resolve it
    const resolvedRoutes = core_1.resolveThunk(routes, BB);
    let NavigatorComponent;
    switch (type) {
        case 'switch':
            NavigatorComponent = navigators_1.SwitchNavigator;
            break;
        case 'stack':
            NavigatorComponent = navigators_1.StackNavigator;
            break;
        case 'tab':
        case 'tabs':
        case 'top-navigation':
        case 'bottom-navigation':
            NavigatorComponent = navigators_1.TabNavigator;
            break;
        case 'drawer':
            NavigatorComponent = navigators_1.DrawerNavigator;
            break;
        default:
            NavigatorComponent = navigators_1.SwitchNavigator;
            break;
    }
    if (!NavigatorComponent) {
        return null;
    }
    return (react_1.default.createElement(NavigatorComponent, Object.assign({}, navigator, { routes: resolvedRoutes })));
}
exports.renderNavigator = renderNavigator;
