import { i18n } from '@osd/i18n' ; import { get } from 'lodash' ; import { ExpressionFunctionDefinition } from '../types' ; interface Arguments { variable : string ; default : string | number | boolean ; } type Output = any ; export type ExpressionFunctionTheme = ExpressionFunctionDefinition < 'theme' , null , Arguments , Output > ; export const theme = { name : 'theme' , aliases : [ ] , help : i18n . translate ( 'expressions.functions.themeHelpText' , { defaultMessage : 'Reads a theme setting.' , } ) , inputTypes : [ 'null' ] , args : { variable : { aliases : [ '_' ] , help : i18n . translate ( 'expressions.functions.theme.args.variableHelpText' , { defaultMessage : 'Name of the theme variable to read.' , } ) , required : true , types : [ 'string' ] , } , default : { help : i18n . translate ( 'expressions.functions.theme.args.defaultHelpText' , { defaultMessage : 'default value in case theming info is not available.' , } ) , } , } , fn : ( input , args , handlers ) => { const vars = handlers . variables . theme || { } ; return get ( vars , args . variable , args . default ) ; } , } ;