import { InjectionToken, inject } from '@angular/core';
import { ConfigProvider } from './config-provider.interface';
import { MockBootstrapProvider } from '../bootstrap/providers/mock-bootstrap.provider';
import { ApiBootstrapProvider } from '../bootstrap/providers/api-bootstrap.provider';
import { RuntimeProviderStrategyService } from '../providers/runtime-provider-strategy.service';

export const CONFIG_PROVIDER = new InjectionToken<ConfigProvider>('CONFIG_PROVIDER', {
  providedIn: 'root',
  factory: () => {
    const strategy = inject(RuntimeProviderStrategyService);
    const mockProvider = inject(MockBootstrapProvider);
    const apiProvider = inject(ApiBootstrapProvider);

    switch (strategy.getBootstrapProviderMode()) {
      case 'mock':
        return mockProvider;
      case 'remote-config':
      case 'api':
      default:
        return apiProvider;
    }
  }
});
