Rewrite nested urls for custom post type

I find a solution thank you to the plugin:

Monkeyman Rewrite Rule

With this plugin I find when the rule failed, then I corrected it with these lines of code:

add_action( 'init', 'ab_category_rewrite_rules' );

function ab_category_rewrite_rules() {
    add_rewrite_tag( '%category%', '([^/]+)', 'category=' );
    add_permastruct( 'category', '/catalogs/%catalog%/%category%', false );
    add_rewrite_rule( '^category/([^/]+)/([^/]+)/?$', 'index.php?category=$matches[2]', 'top' );
}

add_action( 'init', 'ab_product_rewrite_rules' );

function ab_product_rewrite_rules() {
    add_rewrite_tag( '%product%', '([^/]+)', 'product=" );
    add_permastruct( "product', '/catalogs/%catalog%/%category%/%product%', false );
    add_rewrite_rule( '^product/([^/]+)/([^/]+)/?$', 'index.php?product=$matches[2]', 'top' );
}

I also removed the rewrite option config on my custom post type registration function (for category and product type).