import { createSelector } from 'reselect' ; import { constants , isNight , ThemePair } from '@devhub/core' ; import { Appearance } from '../../libs/appearence' ; import { EMPTY_OBJ } from '../../utils/constants' ; import { loadTheme } from '../../utils/helpers/theme' ; import { RootState } from '../types' ; const s = ( state ) => state . config || EMPTY_OBJ ; export const themePairSelector = ( state ) => s ( state ) . theme || constants . DEFAULT_THEME_PAIR ; const defaultPreferredDarkThemePair = { id : constants . DEFAULT_DARK_THEME , } ; export const preferredDarkThemePairSelector = ( state ) => s ( state ) . preferredDarkTheme || defaultPreferredDarkThemePair ; const defaultPreferredLightThemePair = { id : constants . DEFAULT_LIGHT_THEME , } ; export const preferredLightThemePairSelector = ( state ) => s ( state ) . preferredLightTheme || defaultPreferredLightThemePair ; export const themeSelector = createSelector ( themePairSelector , preferredDarkThemePairSelector , preferredLightThemePairSelector , ( ) => Appearance . getColorScheme ( ) , ( ) => isNight ( ) , ( theme , preferredDarkTheme , preferredLightTheme , _colorScheme , _isNight ) => { return loadTheme ( theme , { preferredDarkTheme , preferredLightTheme } ) ; } ) ;