import { OptionalNullable } from '@humand-packages/common';
import { RunNode } from './ruleAst';
import { TimeTrackingCategorizedHourWithCategoryData } from './timeTrackingCategorizedHour';

/**
 * Result of an on-demand "explain" of how all hour categories were evaluated for a
 * single (user, date). The categorization engine is recomputed in memory and the
 * resulting trace is reassembled into an AST.
 *
 * `run` reflects the recomputed evaluation. `categorizedHours` reflects what is currently
 * stored in the database (any status — including PENDING, REJECTED and admin-overridden
 * rows). When entries have been edited or an admin has overridden a status, the two will
 * diverge; the UI is expected to surface the delta.
 */
export class CategorizationExplanation {
    constructor(props: OptionalNullable<CategorizationExplanation>) {
        this.run = props.run;
        this.categorizedHours = props.categorizedHours;
        this.computedAt = props.computedAt;
    }

    readonly run: RunNode;
    readonly categorizedHours: TimeTrackingCategorizedHourWithCategoryData[];
    readonly computedAt: Date;
}
