"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const lodash_get_1 = tslib_1.__importDefault(require("lodash.get"));
const core_1 = require("@bluebase/core");
exports.resolveRouteOptions = (route, navigator, mainNavigator, ctx) => {
    // // Extract screenProps
    // const screenProps: ScreenProps = {
    // 	...mainNavigator.screenProps,
    // 	...params.screenProps
    // };
    // Create navigationOptions from main navigation configs
    let navigationOptions = core_1.resolveThunk(lodash_get_1.default(mainNavigator, 'defaultNavigationOptions', {}), Object.assign(Object.assign({}, ctx), { navigationOptions: {} }));
    // Create navigationOptions from navigatior defaultNavigationOptions
    navigationOptions = core_1.resolveThunk(lodash_get_1.default(navigator, 'defaultNavigationOptions', navigationOptions), Object.assign(Object.assign({}, ctx), { navigationOptions }));
    // Now, create navigationOptions from route's navigationOptions object
    navigationOptions = core_1.resolveThunk(route.options || route.navigationOptions || navigationOptions, Object.assign(Object.assign({}, ctx), { navigationOptions }));
    // And finally, create navigationOptions from route.screen NavigationOptions
    navigationOptions = core_1.resolveThunk((route.screen && route.screen.navigationOptions) || navigationOptions, Object.assign(Object.assign({}, ctx), { navigationOptions }));
    // Phew...
    return navigationOptions;
};
