'use client';

import { useEffect, type ReactNode } from 'react';
import { AuthProvider } from '@/lib/auth-context';
import { ThemeProvider } from '@/lib/theme-context';
import { ProductProvider } from '@/lib/product-context';
import { initTelemetry } from '@/lib/telemetry';

import { CSPostHogProvider } from '@/components/posthog-provider';

export function Providers({ children }: { children: ReactNode }) {
  useEffect(() => {
    initTelemetry();
  }, []);

  return (
    <CSPostHogProvider>
      <ThemeProvider>
        <ProductProvider>
          <AuthProvider>{children}</AuthProvider>
        </ProductProvider>
      </ThemeProvider>
    </CSPostHogProvider>
  );
}
