/** Resolve one saved Builder design into a validated model tree. */
export const modelOf = ( designs, id ) => {
	if ( ! id ) return null;
	const design = designs?.[ String( id ) ];
	if ( ! design ) return null;
	let model = design.model;
	if ( typeof model === 'string' ) {
		try {
			model = JSON.parse( model );
		} catch ( error ) {
			return null;
		}
	}
	return model && Array.isArray( model.rows ) ? model : null;
};
