import { Module, forwardRef } from "@nestjs/common";
import { FreebitModule } from "@bff/integrations/freebit/freebit.module";
import { WhmcsModule } from "@bff/integrations/whmcs/whmcs.module";
import { MappingsModule } from "@bff/modules/id-mappings/mappings.module";
import { EmailModule } from "@bff/infra/email/email.module";
import { SimUsageStoreService } from "../sim-usage-store.service";
import { SubscriptionsService } from "../subscriptions.service";

// Import all SIM management services
import { SimOrchestratorService } from "./services/sim-orchestrator.service";
import { SimDetailsService } from "./services/sim-details.service";
import { SimUsageService } from "./services/sim-usage.service";
import { SimTopUpService } from "./services/sim-topup.service";
import { SimPlanService } from "./services/sim-plan.service";
import { SimCancellationService } from "./services/sim-cancellation.service";
import { EsimManagementService } from "./services/esim-management.service";
import { SimValidationService } from "./services/sim-validation.service";
import { SimNotificationService } from "./services/sim-notification.service";
import { SimVoiceOptionsService } from "./services/sim-voice-options.service";

@Module({
  imports: [forwardRef(() => FreebitModule), WhmcsModule, MappingsModule, EmailModule],
  providers: [
    // Core services that the SIM services depend on
    SimUsageStoreService,
    SubscriptionsService,

    // SIM management services
    SimValidationService,
    SimNotificationService,
    SimVoiceOptionsService,
    SimDetailsService,
    SimUsageService,
    SimTopUpService,
    SimPlanService,
    SimCancellationService,
    EsimManagementService,
    SimOrchestratorService,
    // Export with token for optional injection in Freebit module
    {
      provide: "SimVoiceOptionsService",
      useExisting: SimVoiceOptionsService,
    },
  ],
  exports: [
    SimOrchestratorService,
    // Export individual services in case they're needed elsewhere
    SimDetailsService,
    SimUsageService,
    SimTopUpService,
    SimPlanService,
    SimCancellationService,
    EsimManagementService,
    SimValidationService,
    SimNotificationService,
    SimVoiceOptionsService,
    "SimVoiceOptionsService", // Export the token
  ],
})
export class SimManagementModule {}
