import { getConf } from './configuration';

const screens = getConf('screens', {});

// IMPORTANT
// FIXME: after babel update (to 7) use conditional compilation to skip import (reduce bundle size)
// use the package babel-plugin-conditional-compile or babel-plugin-conditional-compilation

// import base Screens if not replaced in custom project
// note: require should be used here to avoid importing the screen when it's not used

if (!screens.ItemOverview) {
    const { ItemOverviewScreen } = require('./Screens/ItemOverview/Screen');
    screens.ItemOverview = ItemOverviewScreen;
}
if (!screens.Configurator) {
    const { ConnectedConfiguratorScreen } = require('./Screens/Configurator/Screen');
    screens.Configurator = ConnectedConfiguratorScreen;
}
if (!screens.CalculationWidget) {
    const { ConnectedCalculationWidgetScreen } = require('./Screens/Configurator/CalculationWidgetScreen');
    screens.CalculationWidget = ConnectedCalculationWidgetScreen;
}
if (!screens.DesignerProductPreview) {
    const { ConnectedDesignerProductPreviewScreen } = require('./Screens/DesignerProductPreview/Screen');
    screens.DesignerProductPreview = ConnectedDesignerProductPreviewScreen;
}

if (!screens.Configurator) {
    throw new Error('The Configurator Screen component must be specified in the application configuration!');
}

export default screens;
