<?php
// components/routes.php
use Components\Router;

// Define common URL sync parameters (always included)
Router::setUrlSyncCommon([Router::tabParam()]);

// Register app routes in one place
Router::add('dashboard', 'pages/dashboard.php');
Router::add('trigger', 'pages/trigger.php', [
    'capability' => ['type' => 'license', 'module' => 'winback_advanced'],
    'fallbackPath' => 'pages/trigger_promo.php',
]);
Router::add('trigger_sort', 'pages/trigger_sort.php');
Router::add('newsletter', 'pages/newsletter.php', [
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'mb_newsletter']
        ]
    ],
    'fallbackPath' => 'pages/newsletter_promo.php',
]);
Router::add('doi_flow', 'pages/doi_flow.php', [
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'mb_newsletter']
        ]
    ],
    'fallbackPath' => 'pages/doi_flow_promo.php',
]);
Router::add('email_preview', 'pages/email_preview.php', ['urlSyncParams' => ['url', 'device']]);
Router::add('email_editor', 'pages/email_editor.php', ['urlSyncParams' => ['module', 'lng_id']]);
Router::add('datasources', 'pages/datasources.php');
Router::add('module_config', 'pages/module_configuration.php');
Router::add('config_submenu', 'pages/submenu/configuration.php');
Router::add('configuration', 'pages/configuration.php');
Router::add('coupons', 'pages/coupons.php',[
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'winback_advanced'],
        ]
    ],
    'fallbackPath' => 'pages/coupons_promo.php',
]);
Router::add('reviews', 'pages/reviews.php');
Router::add('license', 'pages/license.php');
Router::add('config_modal_docs', 'pages/components/config_modal_docs.php');
Router::add('site_panel_docs', 'pages/components/site_panel_docs.php');
Router::add('sitebeez_integration_code', 'pages/components/sitebeez_integration_code.php');
Router::add('mode', 'pages/components/mode.php');
Router::add('plan_info', 'pages/components/plan_info.php');
Router::add('template_usage', 'pages/components/template_usage.php', ['urlSyncParams' => ['maintemplate_id', 'title']]);
Router::add('template_action_confirm', 'pages/components/template_action_confirm.php', ['urlSyncParams' => []]);
Router::add('dashboard_summary', 'pages/components/dashboard_summary.php');
Router::add('buttongroup_demo', 'pages/components/buttongroup.php');
Router::add('calendar', 'pages/calendar.php', [
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'winback_advanced'],
        ]
    ],
    'fallbackPath' => 'pages/calendar_promo.php',
]);
Router::add('calendar_view', 'pages/components/calendar_view.php');
Router::add('calendar_subscribe_popover', 'pages/components/calendar_subscribe_popover.php');
Router::add('calendar_rotate_token', 'pages/components/calendar_rotate_token.php');
Router::add('calendar_rotate_token_confirm', 'pages/components/calendar_rotate_token_confirm.php');
Router::add('toggle_module_status', 'pages/components/toggle_module_status.php');
Router::add('save_module_config', 'pages/components/save_module_config.php');
Router::add('save_ui_open_bulk', 'pages/components/save_ui_open_bulk.php');
Router::add('save_column_state_bulk', 'pages/components/save_column_state_bulk.php');
Router::add('save_ui_list_layout', 'pages/components/save_ui_list_layout.php');
Router::add('save_ui_list_per_page', 'pages/components/save_ui_list_per_page.php');
Router::add('trigger_module', 'pages/components/trigger_module_route.php');
Router::add('trigger_install_dialog', 'pages/components/trigger_install_dialog.php');
Router::add('trigger_install', 'pages/components/trigger_install.php');
Router::add('module_uninstall_confirm', 'pages/components/module_uninstall_confirm.php');
Router::add('switch_to_legacy', 'pages/components/switch_to_legacy.php');
Router::add('hide_notification', 'pages/components/hide_notification.php', ['urlSyncParams' => ['id']]);
Router::add('notifications_count', 'pages/components/notifications_count.php');
Router::add('notification_hub', 'pages/components/notification_hub.php');
Router::add('health_count', 'pages/components/health_count.php');
Router::add('health_hub', 'pages/components/health_hub.php');
Router::add('license_check', 'pages/components/license_check.php');
Router::add('notification_dismiss', 'pages/components/notification_dismiss.php', ['urlSyncParams' => ['id']]);
Router::add('notification_dismiss_all', 'pages/components/notification_dismiss_all.php');
Router::add('updates_check', 'pages/components/updates_check.php');
Router::add('updates_ui', 'pages/components/updates_ui.php');

// Wizard and its steps
Router::add('wizard', 'pages/wizard.php');
Router::add('wizard_goals', 'pages/wizard/goals.php');
Router::add('wizard_step_goal', 'pages/wizard/step_goal.php');
Router::add('wizard_step_newsletter', 'pages/wizard/step_newsletter.php');
Router::add('wizard_step_automation', 'pages/wizard/step_automation.php');
Router::add('wizard_step_remarketing', 'pages/wizard/step_remarketing.php');

// Assistant view
Router::add('assistant', 'components/Assistant/views/index.php', ['urlSyncParams' => ['module', 'flow']]);
// Assistant internal endpoints (partial views)
Router::add('assistant_step', 'components/Assistant/views/step.php', ['urlSyncParams' => ['module', 'flow']]);
Router::add('assistant_answer', 'components/Assistant/views/answer.php', ['urlSyncParams' => ['module', 'flow']]);
Router::add('assistant_back', 'components/Assistant/views/back.php', ['urlSyncParams' => ['module', 'flow']]);
Router::add('assistant_finish', 'components/Assistant/views/finish.php', ['urlSyncParams' => ['module', 'flow']]);
// Playground: model-based flow collections demo
Router::add('flow_collections_model', 'pages/playground/flow_collections_model.php');
Router::add('newsletter_collection_list', 'pages/components/newsletter_collection_list.php');
Router::add('newsletter_collection_modal', 'pages/components/newsletter_collection_modal.php');
Router::add('newsletter_collection_archive', 'pages/components/newsletter_collection_archive.php');
Router::add('newsletter_collection_delete', 'pages/components/newsletter_collection_delete.php');
Router::add('newsletter_smart_config_toggle', 'pages/components/newsletter_smart_config_toggle.php');
Router::add('newsletter_collections_config_toggle', 'pages/components/newsletter_collections_config_toggle.php');
Router::add('newsletter_ui_state_save', 'pages/components/newsletter_ui_state_save.php');
Router::add('coupons_list', 'pages/components/coupons_list.php');
Router::add('coupon_batches_list', 'pages/components/coupon_batches_list.php');
Router::add('template_coupons_grid', 'pages/components/template_coupons_grid.php');
Router::add('coupon_batch_delete', 'pages/components/coupon_batch_delete.php');
Router::add('coupon_export', 'pages/components/coupon_export.php');
Router::add('coupon_export_modal', 'pages/components/coupon_export_modal.php');
Router::add('coupon_modal', 'pages/components/coupon_modal.php');
Router::add('coupon_template_selection_modal', 'pages/components/coupon_template_selection_modal.php');
Router::add('coupon_generate_modal', 'pages/components/coupon_generate_modal.php');
Router::add('newsletter_items_list', 'pages/components/newsletter_items_list.php');
Router::add('newsletter_audience_selection_modal', 'pages/components/newsletter_audience_selection_modal.php');
Router::add('newsletter_template_selection_modal', 'pages/components/newsletter_template_selection_modal.php');
Router::add('main_template_gallery_selection_modal', 'pages/components/main_template_gallery_selection_modal.php');
Router::add('newsletter_item_modal', 'pages/components/newsletter_item_modal.php');
Router::add('newsletter_item_created_success', 'pages/components/newsletter_item_created_success.php');
Router::add('newsletter_item_delete', 'pages/components/newsletter_item_delete.php');
Router::add('newsletter_item_flow', 'pages/components/newsletter_item_flow.php');
Router::add('newsletter_item_row', 'pages/components/newsletter_item_row.php');
Router::add('newsletter_item_create_followup', 'pages/components/newsletter_item_create_followup.php');
Router::add('newsletter_item_deepcopy', 'pages/components/newsletter_item_deepcopy.php');
Router::add('newsletter_item_reactivate', 'pages/components/newsletter_item_reactivate.php');
Router::add('newsletter_item_toggle', 'pages/components/newsletter_item_toggle.php');
Router::add('newsletter_item_favorite_toggle', 'pages/components/newsletter_item_favorite_toggle.php');

// Email editor helpers
Router::add('email_editor_undo_redo', 'pages/components/email_editor_undo_redo.php');
Router::add('email_editor_assign_maintemplate', 'pages/components/email_editor_assign_maintemplate.php');
Router::add('email_editor_lock_unlock_modal', 'pages/components/email_editor_lock_unlock_modal.php');

Router::add('editor_templates', 'pages/editor_templates.php',[
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'winback_advanced']
        ]
    ],
    'fallbackPath' => 'pages/editor_promo.php',
]);Router::add('editor_templates_newsletter', 'pages/editor_templates_newsletter.php',[
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'mb_newsletter']
        ]
    ],
    'fallbackPath' => 'pages/editor_promo.php',
]);
Router::add('editor_templates_module', 'pages/editor_templates_module.php', ['urlSyncParams' => []]);

Router::add('audience', 'pages/audience.php', [
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'mb_newsletter']
        ]
    ],
    'fallbackPath' => 'pages/audience_promo.php',
]);
Router::add('audience_lists', 'pages/components/audience_lists.php');
Router::add('audience_list_modal', 'pages/components/audience_list_modal.php');
Router::add('audience_list_delete', 'pages/components/audience_list_delete.php');
Router::add('audience_list_flow', 'pages/components/audience_list_flow.php');
Router::add('audience_list_count', 'pages/components/audience_list_count.php');
Router::add('audience_refresh_counts', 'pages/components/audience_refresh_counts.php');
Router::add('audience_favorite_toggle', 'pages/components/audience_favorite_toggle.php');
Router::add('audience_export_modal', 'pages/components/audience_export_modal.php');
Router::add('audience_export', 'pages/components/audience_export.php');
Router::add('invalidate_flow_cache', 'pages/components/invalidate_flow_cache.php');

Router::add('topics', 'pages/topics.php', [
    'capability' => [
        'all' => [
            ['type' => 'license', 'module' => 'mb_newsletter']
        ]
    ],
    'fallbackPath' => 'pages/topics_promo.php',
]);
Router::add('topics_list', 'pages/components/topics_list.php');
Router::add('topic_modal', 'pages/components/topic_modal.php');
Router::add('reviews_list', 'pages/components/reviews_list.php');
Router::add('review_modal', 'pages/components/review_modal.php');
Router::add('promo_test', 'pages/trigger_promo.php');
Router::add('dev_icons', 'pages/dev_icons.php');
