export function isRedoStackEntry(operation) {
    return operation.undone === true || operation.canRedo === true;
}
/**
 * Persisting any new operation removes all undone operations for that session
 * on the server. Apply the same rule before deciding whether the new operation
 * belongs in the currently visible history scope.
 */
export function reconcileNewHistoryOperation(history, newOperation, includeNewOperation) {
    const historyWithValidRedoStack = newOperation.sessionId && !isRedoStackEntry(newOperation)
        ? history.filter((operation) => operation.sessionId !== newOperation.sessionId ||
            !isRedoStackEntry(operation))
        : history;
    return includeNewOperation
        ? [newOperation, ...historyWithValidRedoStack]
        : historyWithValidRedoStack;
}
export function isMissingEditOperationResult(result) {
    if (result.response.status !== 404)
        return false;
    return [result.summary, result.details, result.rawDetails]
        .filter((value) => typeof value === "string")
        .some((value) => /operation not found\s*:/i.test(value));
}
//# sourceMappingURL=editHistoryReconciliation.js.map