import { isFinalSuccess } from '../../../../modules/setup-wizard/entities/stepOutcome/stepOutcome.js';
export function createInitialState(now) {
    const ts = now().toISOString();
    return {
        version: 1,
        startedAt: ts,
        updatedAt: ts,
        steps: {},
    };
}
export function markStep(state, stepId, outcome, now) {
    return {
        ...state,
        updatedAt: now().toISOString(),
        steps: { ...state.steps, [stepId]: outcome },
    };
}
export function findFirstIncomplete(state, orderedStepIds) {
    for (const stepId of orderedStepIds) {
        const outcome = state.steps[stepId];
        if (!outcome || !isFinalSuccess(outcome)) {
            return stepId;
        }
    }
    return null;
}
export function isComplete(state, orderedStepIds) {
    return findFirstIncomplete(state, orderedStepIds) === null;
}
//# sourceMappingURL=setupState.js.map