import { EventInput } from './event-parse' ; import { EventStore , parseEvents } from './event-store' ; import { CalendarContext } from '../CalendarContext' ; export type BusinessHoursInput = boolean | EventInput | EventInput [ ] ; const DEF_DEFAULTS = { startTime : '09:00' , endTime : '17:00' , daysOfWeek : [ 1 , 2 , 3 , 4 , 5 ] , display : 'inverse-background' , classNames : 'fc-non-business' , groupId : '_businessHours' , } ; export function parseBusinessHours ( input , context ) { return parseEvents ( refineInputs ( input ) , null , context ) ; } function refineInputs ( input ) { let rawDefs ; if ( input === true ) { rawDefs = [ { } ] ; } else if ( Array . isArray ( input ) ) { rawDefs = input . filter ( ( rawDef ) => rawDef . daysOfWeek ) ; } else if ( typeof input === 'object' && input ) { rawDefs = [ input ] ; } else { rawDefs = [ ] ; } rawDefs = rawDefs . map ( ( rawDef ) => ( { ... DEF_DEFAULTS , ... rawDef } ) ) ; return rawDefs ; }