import { PrecalculatedBot , Bot , PrecalculatedTags , BotSpace , hasValue , BotSignatures , CompiledBotListeners , RuntimeBot , } from '../bots' ; import { v4 as uuid } from 'uuid' ; /**
 * Defines bots state that contains compiled bots.
 */ export interface CompiledBotsState { [ id ] : CompiledBot ; } /**
 * A bot that has been pre-compiled so that running tag listeners or formulas is quick.
 */ export interface CompiledBot extends PrecalculatedBot { /**
     * The tags that are listeners and have been compiled into functions.
     */ listeners : CompiledBotListeners ; /**
     * The script bot that the compiled bot has been setup to use.
     */ script : RuntimeBot ; } param id param values param tags param space param compiledValues param listeners export function createCompiledBot ( id = uuid ( ) , values = { } , tags ? , space ? , listeners = { } , signatures ? ) { if ( hasValue ( space ) ) { return { id , space , precalculated : true , tags : tags || values , values , listeners : listeners , signatures , script : null , } ; } return { id , precalculated : true , tags : tags || values , values , listeners : listeners , signatures , script : null , } ; }