'use client';

import { ThemeProvider } from '@/core/theme';
import { I18nProvider } from '@/core/i18n';
import { StorageProvider } from '@/core/storage';
import { FeatureFlagProvider } from '@/core/feature-flags';
import { AuthProvider } from '@/core/auth';
import { VersionWatcher } from '@/core/version/version-watcher';
import { DEFAULT_FLAGS } from '@/config/flags';

// Ensure module registry is populated
import '@/config/modules';

interface ProvidersProps {
  children: React.ReactNode;
}

export function Providers({ children }: ProvidersProps) {
  return (
    <ThemeProvider>
      <I18nProvider>
        <StorageProvider>
          <FeatureFlagProvider flagDefinitions={DEFAULT_FLAGS}>
            <AuthProvider>
              {children}
              <VersionWatcher />
            </AuthProvider>
          </FeatureFlagProvider>
        </StorageProvider>
      </I18nProvider>
    </ThemeProvider>
  );
}
