import { type DateRange } from '@dereekb/date'; import { type StringOrder, type Maybe, type DayOfWeek, type DecisionFunction, type FilterFunction, type IndexRange, type EnabledDays, type ArrayOrValue, type TimezoneStringRef, type Days, type DateRelativeDirection } from '@dereekb/util'; import { type DateCell, type DateCellDurationSpan, type DateCellIndex, type DateCellTiming, type DateCellTimingDateRange, type DateCellTimingStartsAtEndRange, type FullDateCellTiming, type DateCellTimingEventStartsAt, type DateCellTimingTimezoneInput, type DateCellIndexDatePair } from './date.cell'; import { type DateCellTimingRelativeIndexFactoryInput, type DateCellTimingExpansionFactory, type DateCellTimingRelativeIndexFactory } from './date.cell.factory'; import { type DateCellRangeOrDateRange, type DateCellRangeWithRange } from './date.cell.index'; import { type DateTimezoneUtcNormalInstance } from './date.timezone'; import { type YearWeekCodeConfig } from './date.week'; /** * Encodes days of the week as numeric codes for use in schedule filtering. * * Values 1-7 map to individual days (offset by +1 from DayOfWeek), while * 8 and 9 serve as shorthand for all weekdays or weekend days respectively. */ export declare enum DateCellScheduleDayCode { /** * Special no-op/unused code */ NONE = 0, SUNDAY = 1,// Day.SUNDAY + 1 MONDAY = 2, TUESDAY = 3, WEDNESDAY = 4, THURSDAY = 5, FRIDAY = 6, SATURDAY = 7, /** * All weekdays (Mon-Fri) */ WEEKDAY = 8, /** * All weekend days (Sat/Sun) */ WEEKEND = 9 } /** * Returns day codes representing all seven days of the week using the WEEKDAY and WEEKEND shorthand codes. * * @returns Array containing WEEKDAY and WEEKEND codes. */ export declare function fullWeekDateCellScheduleDayCodes(): DateCellScheduleDayCode[]; /** * Returns individual day codes for Monday through Friday. * * @returns Array of five weekday codes. */ export declare function weekdayDateCellScheduleDayCodes(): DateCellScheduleDayCode[]; /** * Returns individual day codes for Saturday and Sunday. * * @returns Array of two weekend codes. */ export declare function weekendDateCellScheduleDayCodes(): DateCellScheduleDayCode[]; /** * Creates an EnabledDays from the input by expanding schedule day codes to their corresponding days of the week. * * @param input - Schedule day codes to convert (WEEKDAY/WEEKEND shorthand codes are expanded) * @returns An EnabledDays object with boolean flags for each day. */ export declare function enabledDaysFromDateCellScheduleDayCodes(input: Maybe>): EnabledDays; /** * Creates an array of simplified DateCellScheduleDayCode values from the input EnabledDays, using shorthand codes (WEEKDAY/WEEKEND) where possible. * * @param input - Enabled days to convert back to schedule day codes. * @returns Simplified array of day codes. */ export declare function dateCellScheduleDayCodesFromEnabledDays(input: Maybe): DateCellScheduleDayCode[]; /** * Compact, sortable string encoding of the seven days of the week using {@link DateCellScheduleDayCode} digits. * * The string contains zero or more single-character digits in ascending order, where each digit is a single * {@link DateCellScheduleDayCode} value. The empty string represents "no days selected". * * Digit meanings: * - `1` SUNDAY, `2` MONDAY, `3` TUESDAY, `4` WEDNESDAY, `5` THURSDAY, `6` FRIDAY, `7` SATURDAY * - `8` WEEKDAY shorthand (replaces the individual `23456` digits) * - `9` WEEKEND shorthand (replaces the individual `17` digits) * * Use {@link dateCellScheduleEncodedWeek} to build a simplified encoding from an iterable of day codes, * {@link isDateCellScheduleEncodedWeek} as a runtime type guard, and {@link DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX} * for a loose regex check. The type uses {@link StringOrder} to constrain digits to ascending order at the type * level; the regex itself does not enforce ordering or uniqueness. * * @example * ```ts * const empty: DateCellScheduleEncodedWeek = ''; // no days * const monWed: DateCellScheduleEncodedWeek = '24'; // Monday + Wednesday * const weekdays: DateCellScheduleEncodedWeek = '8'; // Mon-Fri via WEEKDAY shorthand * const everyDay: DateCellScheduleEncodedWeek = '89'; // WEEKDAY + WEEKEND * ``` */ export type DateCellScheduleEncodedWeek = '' | StringOrder<`${DateCellScheduleDayCode}`, ''>; /** * Regex that loosely validates a {@link DateCellScheduleEncodedWeek}. * * Matches zero-to-nine digit characters (any of `0-9`). Does not enforce ascending order or uniqueness of * digits — use {@link isDateCellScheduleEncodedWeek} for a runtime check that mirrors the type, or * {@link dateCellScheduleEncodedWeek} to build a guaranteed-valid encoding from {@link DateCellScheduleDayCode} * values. * * @dbxUtil * @dbxUtilCategory date * @dbxUtilKind const * @dbxUtilTags date, schedule, encoded, week, regex, validate, days * @dbxUtilRelated is-date-cell-schedule-encoded-week, date-cell-schedule-encoded-week */ export declare const DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX: RegExp; /** * Type guard that returns true if the input matches the {@link DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX} encoded-week format. * * The regex check is loose — it allows duplicate digits and any digit ordering. To produce a canonically simplified * encoding, use {@link dateCellScheduleEncodedWeek}. * * @param input - String to validate against the encoded week regex. * @returns Whether the string matches the encoded week format. * * @dbxUtil * @dbxUtilCategory date * @dbxUtilTags date, schedule, encoded, week, type-guard, validate, check, days * @dbxUtilRelated date-cell-schedule-encoded-week-regex, is-empty-date-cell-schedule-encoded-week, date-cell-schedule-encoded-week * * @example * ```ts * isDateCellScheduleEncodedWeek('24'); // true (Mon + Wed) * isDateCellScheduleEncodedWeek('8'); // true (WEEKDAY shorthand) * isDateCellScheduleEncodedWeek(''); // true (no days) * isDateCellScheduleEncodedWeek('abc'); // false * ``` */ export declare function isDateCellScheduleEncodedWeek(input: string): input is DateCellScheduleEncodedWeek; /** * Returns true if the input represents an empty (no days selected) {@link DateCellScheduleEncodedWeek}. * * Both the empty string `''` and `'0'` are treated as empty since `0` corresponds to * {@link DateCellScheduleDayCode.NONE}, the no-op day code. * * @param input - String to check for emptiness. * @returns Whether the encoded week represents no selected days. * * @dbxUtil * @dbxUtilCategory date * @dbxUtilTags date, schedule, encoded, week, empty, check, type-guard, days * @dbxUtilRelated is-date-cell-schedule-encoded-week, date-cell-schedule-encoded-week * * @example * ```ts * isEmptyDateCellScheduleEncodedWeek(''); // true * isEmptyDateCellScheduleEncodedWeek('0'); // true (NONE code) * isEmptyDateCellScheduleEncodedWeek('8'); // false (WEEKDAY) * isEmptyDateCellScheduleEncodedWeek('24'); // false (Mon + Wed) * ``` */ export declare function isEmptyDateCellScheduleEncodedWeek(input: string): input is DateCellScheduleEncodedWeek; /** * Creates a simplified {@link DateCellScheduleEncodedWeek} from an iterable of {@link DateCellScheduleDayCode} values. * * Codes are passed through {@link simplifyDateCellScheduleDayCodes} so redundant individual day codes are collapsed * into shorthand (e.g. Mon-Fri becomes WEEKDAY `8`, Sat+Sun becomes WEEKEND `9`) and digits are emitted in ascending order. * * @param codes - Day codes to encode into the compact string representation. * @returns The encoded week string. * * @dbxUtil * @dbxUtilCategory date * @dbxUtilTags date, schedule, encoded, week, encode, days, simplify, weekday, weekend * @dbxUtilRelated is-date-cell-schedule-encoded-week, simplify-date-cell-schedule-day-codes, expand-date-cell-schedule-day-codes * * @example * ```ts * // Encode weekdays only — collapses into the WEEKDAY shorthand * dateCellScheduleEncodedWeek([DateCellScheduleDayCode.MONDAY, DateCellScheduleDayCode.TUESDAY, DateCellScheduleDayCode.WEDNESDAY, DateCellScheduleDayCode.THURSDAY, DateCellScheduleDayCode.FRIDAY]); * // Returns '8' * * // Encode specific days * dateCellScheduleEncodedWeek([DateCellScheduleDayCode.MONDAY, DateCellScheduleDayCode.WEDNESDAY]); * // Returns '24' * * // Encode the full week * dateCellScheduleEncodedWeek([DateCellScheduleDayCode.WEEKDAY, DateCellScheduleDayCode.WEEKEND]); * // Returns '89' * ``` */ export declare function dateCellScheduleEncodedWeek(codes: Iterable): DateCellScheduleEncodedWeek; /** * Reduces/merges any day codes into more simplified day codes. * * For instance, if all five weekdays are selected, they will be reduced to WEEKDAY (8). * Similarly, Saturday + Sunday becomes WEEKEND (9). * * @param codes - Day codes to simplify. * @returns Simplified array with shorthand codes where applicable. * * @example * ```ts * // All weekdays collapse to WEEKDAY * simplifyDateCellScheduleDayCodes([2, 3, 4, 5, 6]); * // Returns [DateCellScheduleDayCode.WEEKDAY] // [8] * * // Saturday + Sunday collapses to WEEKEND * simplifyDateCellScheduleDayCodes([1, 7]); * // Returns [DateCellScheduleDayCode.WEEKEND] // [9] * * // Mixed: partial weekdays remain individual * simplifyDateCellScheduleDayCodes([2, 4]); * // Returns [DateCellScheduleDayCode.MONDAY, DateCellScheduleDayCode.WEDNESDAY] // [2, 4] * ``` */ export declare function simplifyDateCellScheduleDayCodes(codes: Iterable): DateCellScheduleDayCode[]; /** * Flexible input type for day codes: accepts an encoded week string, a single code, an array, or a Set. */ export type DateCellScheduleDayCodesInput = DateCellScheduleEncodedWeek | ArrayOrValue | Set; /** * Expands the input DateCellScheduleDayCodesInput to a Set of DayOfWeek values, converting from the +1 offset used by schedule day codes back to standard DayOfWeek. * * @param input - Day codes to expand (shorthand codes like WEEKDAY are expanded to individual days) * @returns Set of DayOfWeek values. */ export declare function expandDateCellScheduleDayCodesToDayOfWeekSet(input: DateCellScheduleDayCodesInput): Set; /** * Converts DayOfWeek values to their corresponding DateCellScheduleDayCode values (offset by +1). * * @param input - Days of the week to convert. * @returns Set of individual schedule day codes (no shorthand grouping applied) */ export declare function dateCellScheduleDayCodesSetFromDaysOfWeek(input: Iterable): Set; /** * Expands the input into a sorted array of individual DateCellScheduleDayCode values. * * Shorthand codes (WEEKDAY, WEEKEND) are expanded to their constituent day codes, sorted ascending. * * @param input - Day codes to expand. * @returns Sorted array of individual day codes (1-7 only, no shorthand) */ export declare function expandDateCellScheduleDayCodes(input: DateCellScheduleDayCodesInput): DateCellScheduleDayCode[]; /** * Expands the input DateCellScheduleDayCodesInput to a Set of individual DateCellScheduleDayCode values (1-7), expanding shorthand codes like WEEKDAY and WEEKEND. * * @param input - Day codes to expand into a set. * @returns Set of individual day codes with shorthand codes resolved. */ export declare function expandDateCellScheduleDayCodesToDayCodesSet(input: DateCellScheduleDayCodesInput): Set; /** * Converts the input to an array of DateCellScheduleDayCode values without expanding shorthand codes (WEEKDAY/WEEKEND remain as-is). * * Filters out the NONE (0) code. * * @param input - Day codes input in any supported format. * @returns Raw array of day codes with NONE values removed. */ export declare function rawDateCellScheduleDayCodes(input: DateCellScheduleDayCodesInput): DateCellScheduleDayCode[]; /** * Used to convert the input dates into a DateCellScheduleDayCode. */ export type DateCellScheduleDayCodeFactory = (date: Date) => DateCellScheduleDayCode; /** * Configuration for creating a DateCellScheduleDayCodeFactory, specifying the timezone context. */ export type DateCellScheduleDayCodeConfig = Pick; /** * Creates a DateCellScheduleDayCodeFactory that converts dates to their corresponding day code, accounting for timezone normalization. * * @param config - Optional timezone configuration; defaults to system timezone if not provided. * @returns A factory function that maps a Date to its DateCellScheduleDayCode. * * @__NO_SIDE_EFFECTS__ */ export declare function dateCellScheduleDayCodeFactory(config?: DateCellScheduleDayCodeConfig): DateCellScheduleDayCodeFactory; /** * Returns true if both inputs, when fully expanded to individual day codes, represent the same set of days. * * @param a - First day codes input to compare. * @param b - Second day codes input to compare. * @returns Whether both inputs resolve to the same days of the week. */ export declare function dateCellScheduleDayCodesAreSetsEquivalent(a: DateCellScheduleDayCodesInput, b: DateCellScheduleDayCodesInput): boolean; /** * Schedule configuration used to control which DateCell values are active for a recurring event. * * Combines weekly recurrence patterns (via encoded week days) with explicit include/exclude lists * for fine-grained control over individual date cell indices. */ export interface DateCellSchedule { /** * Days of the week to include. */ w: DateCellScheduleEncodedWeek; /** * Specific DateCellIndex values to include. */ d?: DateCellIndex[]; /** * Specific DateCellIndex values to exclude. */ ex?: DateCellIndex[]; } /** * Returns true if the input is structurally a DateCellSchedule (has the expected shape). * * @param input - Object to check. * @returns Whether the input matches the DateCellSchedule structure. */ export declare function isDateCellSchedule(input: object): input is DateCellSchedule; /** * Returns true if both schedules have the same encoded week, included indices, and excluded indices. * * @param a - First schedule to compare. * @param b - Second schedule to compare. * @returns Whether both schedules are equivalent. */ export declare function isSameDateCellSchedule(a: Maybe, b: Maybe): boolean; /** * A DateCellSchedule combined with a DateRange and timezone, bounding the schedule to a specific date window. */ export interface DateCellScheduleDateRange extends DateCellSchedule, DateCellTimingDateRange { } /** * A special DateCellScheduleDateRange that has both the start and end times at the start of the day in the target timezone for their given ranges. */ export type DateCellScheduleStartOfDayDateRange = DateCellScheduleDateRange; /** * Returns true if the input is possibly a DateCellScheduleDateRange (has schedule fields and valid start/end dates). * * Does not check that the input is a valid FullDateCellScheduleRange. * * @param input - Object to check. * @returns Whether the input has the structure of a DateCellScheduleDateRange. */ export declare function isDateCellScheduleDateRange(input: object): input is DateCellScheduleDateRange; /** * Returns true if the input is a DateCellScheduleDateRange whose start and end are both at the start of day in its timezone, and has no duration or startsAt fields. * * @param input - Object to check. * @returns Whether the input is a start-of-day schedule date range. */ export declare function isDateCellScheduleStartOfDayDateRange(input: object): input is DateCellScheduleStartOfDayDateRange; /** * Returns true if both inputs have the same schedule and date range. * * @param a - First schedule date range to compare. * @param b - Second schedule date range to compare. * @returns Whether both have identical date ranges and schedules. */ export declare function isSameDateCellScheduleDateRange(a: Maybe, b: Maybe): boolean; /** * Input for dateCellScheduleDateRange(). * * It should be comprised of parts of a valid DateCellScheduleDateRange already. This means the start/end or startsAt/end is valid and for the given timezone. * * Invalid input has undetermined behavior. */ export type DateCellScheduleDateRangeInput = DateCellSchedule & Partial; /** * Creates a DateCellScheduleDateRange from the input, normalizing the start date to the start of day in the target timezone. * * Accepts either a start/end pair or a startsAt/end pair. If no end is provided, defaults to one minute after start. * * @param input - Schedule and partial date range information to assemble. * @returns A fully resolved schedule date range with timezone-aware start/end. * @throws {Error} When neither `start`, `startsAt`, nor `end` is provided in the input. */ export declare function dateCellScheduleDateRange(input: DateCellScheduleDateRangeInput): DateCellScheduleDateRange; /** * Changes any input DateCellScheduleDateRange to a new DateCellScheduleDateRange in the configured timezone. */ export type ChangeDateCellScheduleDateRangeToTimezoneFunction = ((dateRange: DateCellScheduleDateRange) => DateCellScheduleDateRange) & { readonly _normalInstance: DateTimezoneUtcNormalInstance; }; /** * Creates a reusable function that converts any DateCellScheduleDateRange to the specified target timezone while preserving the same wall-clock day boundaries. * * @param timezoneInput - The target timezone to convert ranges into. * @returns A conversion function with the internal normal instance exposed as `_normalInstance` * * @__NO_SIDE_EFFECTS__ */ export declare function changeDateCellScheduleDateRangeToTimezoneFunction(timezoneInput: DateCellTimingTimezoneInput): ChangeDateCellScheduleDateRangeToTimezoneFunction; /** * Convenience function for calling changeDateCellScheduleDateRangeToTimezoneFunction() and passing the new timing and timezone. * * @param timing - The schedule date range to convert. * @param timezone - The target timezone. * @returns The schedule date range re-expressed in the target timezone. */ export declare function changeDateCellScheduleDateRangeToTimezone(timing: DateCellScheduleDateRange, timezone: DateCellTimingTimezoneInput): DateCellScheduleDateRange; /** * A DateCellScheduleDateRange that also includes the event's startsAt time. */ export interface DateCellScheduleEventRange extends DateCellScheduleDateRange, DateCellTimingEventStartsAt { } /** * Returns true if both inputs have the same schedule, date range, and event startsAt. * * @param a - First event range to compare. * @param b - Second event range to compare. * @returns Whether both event ranges are equivalent. */ export declare function isSameDateCellScheduleEventRange(a: Maybe, b: Maybe): boolean; /** * A DateCellScheduleEventRange that includes the duration and implements FullDateCellTiming. */ export interface FullDateCellScheduleRange extends DateCellScheduleEventRange, FullDateCellTiming { } /** * Returns true if the input is possibly a FullDateCellScheduleRange (has schedule fields and full timing fields). * * Does not check that the input is a valid FullDateCellScheduleRange. * * @param input - Object to check. * @returns Whether the input has the structure of a FullDateCellScheduleRange. */ export declare function isFullDateCellScheduleDateRange(input: object): input is FullDateCellScheduleRange; /** * Returns true if both inputs have the same FullDateCellScheduleRange (schedule, date range, startsAt, and duration). * * @param a - First full schedule range to compare. * @param b - Second full schedule range to compare. * @returns Whether both full schedule ranges are equivalent. */ export declare function isSameFullDateCellScheduleDateRange(a: Maybe, b: Maybe): boolean; /** * Union of schedule range types accepted by fullDateCellScheduleRange(), ordered from most complete (FullDateCellScheduleRange) to partial (DateCellScheduleDateRangeInput). */ export type FullDateCellScheduleRangeInputDateRange = DateCellScheduleDateRange | DateCellScheduleEventRange | FullDateCellScheduleRange | DateCellScheduleDateRangeInput; export interface FullDateCellScheduleRangeInput { /** * Input schedule range to expand from. */ readonly dateCellScheduleRange: FullDateCellScheduleRangeInputDateRange; /** * (Optional) Duration of the timing to use. * * If a duration is provided in the timing, this is ignored unless updateWithDefaults is true. */ readonly duration?: number; /** * (Optional) Hours/Minutes to copy from when setting the inital startsAt. * * This will not change the timing's start/end date range, but it will update the end date. * * If a startsAt is provided in the timing, this is ignored unless updateWithDefaults is true. */ readonly startsAtTime?: Date; /** * Whether or not to always update the range with the default duration/startsAt time */ readonly updateWithDefaults?: boolean; } /** * If a duration is not set, this is the default used. */ export declare const DEFAULT_FULL_DATE_SCHEDULE_RANGE_DURATION = 1; /** * Creates a FullDateCellScheduleRange from the input, filling in missing startsAt, duration, and end values with defaults. * * If the input already has full timing info, it is used as-is unless `updateWithDefaults` forces overrides. * When startsAt or duration are missing, they are derived from the start date or use a 1-minute default duration. * * @param input - Configuration with the schedule range and optional default overrides. * @returns A fully populated schedule range with timing, duration, and schedule data. * * @example * ```ts * const range = fullDateCellScheduleRange({ * dateCellScheduleRange: { * w: '89', // all week * start: startDate, * end: endDate, * timezone: 'America/Denver' * }, * startsAtTime: new Date('2025-01-01T09:00:00Z'), * duration: 60 * }); * // range now has startsAt, duration, and correctly adjusted end date * ``` */ export declare function fullDateCellScheduleRange(input: FullDateCellScheduleRangeInput): FullDateCellScheduleRange; /** * Input for a DateCellScheduleDateFilter: accepts either a Date or a DateCellIndex to test against the schedule. */ export type DateCellScheduleDateFilterInput = DateCellTimingRelativeIndexFactoryInput; /** * Returns true if the date falls within the schedule. */ export type DateCellScheduleDateFilter = DecisionFunction & { readonly _dateCellTimingRelativeIndexFactory: DateCellTimingRelativeIndexFactory; }; /** * dateCellScheduleDateFilter() configuration. */ export interface DateCellScheduleDateFilterConfig extends DateCellSchedule, Partial { /** * The min/max date range for the filter. */ readonly minMaxDateRange?: Maybe>; /** * Whether or not to restrict the start as the min date if a min date is not set in minMaxDateRange. True by default. */ readonly setStartAsMinDate?: boolean; } /** * Creates a shallow copy of a DateCellScheduleDateFilterConfig, useful for preserving configuration before mutation. * * @param inputFilter - The filter config to copy. * @returns A new config object with the same values. */ export declare function copyDateCellScheduleDateFilterConfig(inputFilter: DateCellScheduleDateFilterConfig): DateCellScheduleDateFilterConfig; /** * Creates a DateCellScheduleDateFilter that decides whether a given date or index falls within the schedule. * * The filter checks: (1) allowed days of the week from the encoded week, (2) explicit include/exclude lists, * and (3) optional min/max date boundaries. The filter accounts for timezone normalization. * * PRECEDENCE: an index is in the schedule when it matches the weekly pattern (within the min/max bounds) OR * appears in `d`, and is then NOT in `ex`. So: * - `ex` BEATS `d`. This mirrors RFC 5545 3.8.5.1, where the recurrence set is the union of RRULE and RDATE * and the EXDATE values are subtracted from that union. It is what lets this filter and a generated * RRULE/RDATE/EXDATE triple agree on the same occurrences. * - `d` still escapes the min/max bounds, which is also RFC behavior: UNTIL/COUNT bound the rule, not RDATE. * * @param config - Schedule, timing, and boundary configuration. * @returns A decision function that returns true when the input date/index is within the schedule. * * @example * ```ts * const filter = dateCellScheduleDateFilter({ * w: '8', // weekdays only * startsAt: new Date('2025-01-06T09:00:00Z'), * end: new Date('2025-01-31T10:00:00Z'), * timezone: 'America/Denver', * ex: [2] // exclude index 2 (Wednesday Jan 8) * }); * * filter(0); // true (Monday Jan 6) * filter(2); // false (excluded) * filter(5); // false (Saturday Jan 11) * ``` */ export declare function dateCellScheduleDateFilter(config: DateCellScheduleDateFilterConfig): DateCellScheduleDateFilter; /** * Configuration for findNextDateInDateCellScheduleFilter(). */ export interface FindNextDateInDateCellScheduleFilterInput { /** * Starting date or index to search from. */ readonly date: DateCellScheduleDateFilterInput; /** * The schedule filter to test against. */ readonly filter: DateCellScheduleDateFilter; /** * Direction to search: 'past' moves backward, 'future' moves forward. */ readonly direction: DateRelativeDirection; /** * Maximum number of days to search before giving up. */ readonly maxDistance: Days; /** * Whether or not to exclude the input date. False by default. */ readonly excludeInputDate?: boolean; } /** * Searches forward or backward from a starting date/index to find the next date cell index that passes the schedule filter. * * Returns null if no matching date is found within the maxDistance limit. * * @param config - Search parameters including start date, filter, direction, and distance limit. * @returns The matching index/date pair, or null if none found within range. * * @example * ```ts * const filter = dateCellScheduleDateFilter({ * w: '8', // weekdays * startsAt: mondayDate, * end: endDate, * timezone: 'America/Denver' * }); * * // Find next weekday from a Saturday * const next = findNextDateInDateCellScheduleFilter({ * date: saturdayDate, * filter, * direction: 'future', * maxDistance: 7 * }); * // next.date is the following Monday * ``` */ export declare function findNextDateInDateCellScheduleFilter(config: FindNextDateInDateCellScheduleFilterInput): Maybe; /** * A decision function that filters DateCell blocks based on a schedule applied to a specific timing. */ export type DateCellScheduleDateCellTimingFilter = DecisionFunction; /** * Configuration for dateCellScheduleDateCellTimingFilter() */ export interface DateCellScheduleDateCellTimingFilterConfig { /** * Timing to filter with. */ readonly timing: DateCellTiming; /** * Schedule to filter with. */ readonly schedule: DateCellSchedule; /** * Wether or not to expand on the inverse of the schedule, returning blocks that are not in the schedule. * * Other date filtering behaves the same (I.E. onlyBlocksNotYetStarted, etc.) */ readonly invertSchedule?: boolean; /** * (Optional) date to use when filtering from now. */ readonly now?: Date; /** * (Optional) filters in blocks that have started. Can be combined with the other filters. */ readonly onlyBlocksThatHaveStarted?: boolean; /** * (Optional) filters in blocks that have ended. Can be combined with the other filters. */ readonly onlyBlocksThatHaveEnded?: boolean; /** * (Optional) filters in blocks that have not yet started. Can be combined with the other filters. */ readonly onlyBlocksNotYetStarted?: boolean; /** * (Optional) filters in blocks that have not yet ended. Can be combined with the other filters. */ readonly onlyBlocksNotYetEnded?: boolean; /** * (Optional) custom filter function. Can be combined with the other filters. */ readonly durationSpanFilter?: FilterFunction>; /** * (Optional) Maximum number of blocks to return. */ readonly maxDateCellsToReturn?: number; } /** * Creates a DateCellScheduleDateCellTimingFilter that tests whether a DateCell block's index is allowed by the schedule within the given timing. * * @param config - Timing and schedule to build the filter from. * @param config.timing - The DateCellTiming that defines the date range and event times for the filter. * @param config.schedule - The DateCellSchedule that controls which day codes and indices are included or excluded. * @returns A decision function returning true for allowed blocks. */ export declare function dateCellScheduleDateCellTimingFilter({ timing, schedule }: DateCellScheduleDateCellTimingFilterConfig): DateCellScheduleDateCellTimingFilter; /** * Creates a DateCellTimingExpansionFactory that expands date cell ranges into duration spans, filtered by a schedule and optional time-based criteria (started, ended, etc.). * * @param config - Timing, schedule, and optional temporal/custom filters. * @returns An expansion factory that converts DateCellRange arrays into filtered DateCellDurationSpan arrays. * * @__NO_SIDE_EFFECTS__ */ export declare function expandDateCellScheduleFactory(config: DateCellScheduleDateCellTimingFilterConfig): DateCellTimingExpansionFactory; /** * Input for expandDateCellSchedule(), extending the filter config with an optional index range limit. */ export interface ExpandDateCellScheduleInput extends DateCellScheduleDateCellTimingFilterConfig { /** * Index range to limit the expansion to. Capped to the timing's own range. */ readonly limitIndexRange?: IndexRange; } /** * Expands a DateCellTiming and DateCellSchedule into concrete DateCellDurationSpan values representing each active block in the event. * * Only blocks whose indices pass the schedule filter (and any time-based filters) are included. * An optional limitIndexRange further restricts which indices are expanded, capped to the timing's own range. * * @param input - Timing, schedule, and optional filters/range limit. * @returns Array of duration spans for each active date cell. * * @example * ```ts * const spans = expandDateCellSchedule({ * timing: myTiming, * schedule: { w: '8', ex: [3] } // weekdays, excluding index 3 * }); * // Returns DateCellDurationSpan[] for each weekday block except index 3 * ``` */ export declare function expandDateCellSchedule(input: ExpandDateCellScheduleInput): DateCellDurationSpan[]; /** * Input for expandDateCellScheduleRange(), which derives both timing and schedule from a single schedule range. */ export interface ExpandDateCellScheduleRangeInput extends Omit { readonly dateCellScheduleRange: FullDateCellScheduleRangeInputDateRange; /** * (Optional) Duration of the timing to replace the dateCellScheduleRange's duration. */ readonly duration?: number; /** * (Optional) Hours/Minutes to replace the dateCellScheduleRange's startsAt time. * * Note, this will modify the timing's end date to be a valid time. */ readonly startsAtTime?: Date; } /** * Expands a schedule range into concrete DateCellDurationSpan values by first building a FullDateCellScheduleRange from the input, then expanding it. * * Allows overriding the duration and startsAt time on the schedule range before expansion. * * @param input - Schedule range and optional override values. * @returns Array of duration spans for each active date cell in the range. */ export declare function expandDateCellScheduleRange(input: ExpandDateCellScheduleRangeInput): DateCellDurationSpan[]; /** * Alias for ExpandDateCellScheduleRangeInput used when the goal is to produce DateCellRange groups. */ export type ExpandDateCellScheduleRangeToDateCellRangeInput = ExpandDateCellScheduleRangeInput; /** * Expands a schedule range and groups the resulting duration spans into contiguous DateCellRangeWithRange values. * * @param input - Schedule range expansion configuration. * @returns Grouped date cell ranges with their associated date ranges. */ export declare function expandDateCellScheduleRangeToDateCellRanges(input: ExpandDateCellScheduleRangeToDateCellRangeInput): DateCellRangeWithRange[];