/**
 * docRoutes.ts
 * 
 * Maps Admin SPA routes to external documentation URLs.
 * Used by the DocLink component to provide contextual help.
 */
export const docRoutes: Record<string, string> = {
    // Marketing Suite
    // '/marketing': 'https://docs.woonoow.com/docs/marketing', // No general marketing doc yet
    '/marketing/coupons': 'https://docs.woonoow.com/docs/marketing/coupons',
    '/marketing/newsletter': 'https://docs.woonoow.com/docs/marketing/newsletter',
    '/marketing/wishlist': 'https://docs.woonoow.com/docs/marketing/wishlist',

    // Settings - Modules
    '/settings/modules/wishlist': 'https://docs.woonoow.com/docs/marketing/wishlist',
    '/settings/modules/newsletter': 'https://docs.woonoow.com/docs/marketing/newsletter',

    // Builder
    '/appearance/header': 'https://docs.woonoow.com/docs/builder/header-footer#header',
    '/appearance/footer': 'https://docs.woonoow.com/docs/builder/header-footer#footer',

    // Store Management
    '/products': 'https://docs.woonoow.com/docs/store/products',
    '/orders': 'https://docs.woonoow.com/docs/store/orders',
    '/customers': 'https://docs.woonoow.com/docs/store/customers',

    // Configuration
    '/settings': 'https://docs.woonoow.com/docs/configuration/general',
    '/settings/store': 'https://docs.woonoow.com/docs/configuration/general',
    '/settings/payments': 'https://docs.woonoow.com/docs/configuration/payment-shipping',
    '/settings/shipping': 'https://docs.woonoow.com/docs/configuration/payment-shipping',
    '/settings/tax': 'https://docs.woonoow.com/docs/configuration/general', // Fallback
    '/settings/customers': 'https://docs.woonoow.com/docs/store/customers',
    '/settings/security': 'https://docs.woonoow.com/docs/configuration/security',
    '/settings/notifications': 'https://docs.woonoow.com/docs/configuration/email',
    '/settings/modules': 'https://docs.woonoow.com/docs/configuration/modules',
    '/appearance/themes': 'https://docs.woonoow.com/docs/configuration/appearance',
};

/**
 * Helper to get doc URL for a specific path
 * 
 * Can be enhanced with regex matching if needed
 */
export const getDocUrl = (path: string): string | null => {
    // 1. Direct match
    if (docRoutes[path]) return docRoutes[path];

    // 2. Partial match (longest match first)
    const sortedKeys = Object.keys(docRoutes).sort((a, b) => b.length - a.length);
    for (const key of sortedKeys) {
        if (path.startsWith(key)) {
            return docRoutes[key];
        }
    }

    return null;
};
