"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WORKFLOW_RULES = exports.WORKFLOW_STATUSES = void 0;
exports.isRunnableWorkflowState = isRunnableWorkflowState;
exports.isSameWorkflowStateSnapshot = isSameWorkflowStateSnapshot;
exports.WORKFLOW_STATUSES = {
    aiReady: "ai-ready",
    aiRunning: "ai-running",
    aiNeedsHuman: "ai-needs-human",
    aiWorkingInPr: "ai-working-in-pr",
    aiRecurring: "ai-recurring",
    aiScheduled: "ai-scheduled",
};
exports.WORKFLOW_RULES = {
    aiDisabled: "ai-disabled",
};
function isRunnableWorkflowState(snapshot) {
    return (snapshot.status === exports.WORKFLOW_STATUSES.aiReady &&
        !snapshot.rules.includes(exports.WORKFLOW_RULES.aiDisabled));
}
function isSameWorkflowStateSnapshot(left, right) {
    if (left.status !== right.status) {
        return false;
    }
    const leftRules = [...left.rules].sort();
    const rightRules = [...right.rules].sort();
    if (leftRules.length !== rightRules.length) {
        return false;
    }
    return leftRules.every((rule, index) => rule === rightRules[index]);
}
