package com.optix.android.di

import com.optix.android.tools.osint.HIBPTool
import com.optix.android.tools.osint.HarvesterTool
import com.optix.android.tools.osint.HunterIoTool
import com.optix.android.tools.osint.OpenCTIIntegration
import com.optix.android.tools.osint.ShodanHostTool
import com.optix.android.tools.osint.ShodanSearchTool
import com.optix.android.tools.exploit.ArpSpooferTool
import com.optix.android.tools.exploit.BruteForceTool
import com.optix.android.tools.exploit.DeauthAttackTool
import com.optix.android.tools.exploit.EvilTwinTool
import com.optix.android.tools.exploit.HydraTool
import com.optix.android.tools.exploit.MetasploitTool
import com.optix.android.tools.exploit.MsfVenomTool
import com.optix.android.tools.exploit.BloodhoundTool
import com.optix.android.tools.exploit.CMETool
import com.optix.android.tools.exploit.LinPEASTool
import com.optix.android.tools.exploit.RubeusTool
import com.optix.android.tools.exploit.WinPEASTool
import com.optix.android.tools.network.NativeSnmpWalkTool
import com.optix.android.tools.network.NativeSmbScannerTool
import com.optix.android.tools.network.ArpScanTool
import com.optix.android.tools.web.GobusterTool
import com.optix.android.tools.web.NativeWhatWebTool
import com.optix.android.tools.web.NativeWpScanTool
import com.optix.android.tools.network.LanScannerTool
import com.optix.android.tools.network.LegionTool
import com.optix.android.tools.network.MasscanTool
import com.optix.android.tools.network.NetbiosScannerTool
import com.optix.android.tools.network.NetworkScannerTool
import com.optix.android.tools.network.NetworkTopologyTool
import com.optix.android.tools.network.NmapTool
import com.optix.android.tools.network.PacketSnifferTool
import com.optix.android.tools.network.PortScannerTool
import com.optix.android.tools.network.Rping3Tool
import com.optix.android.tools.network.SSHAuditTool
import com.optix.android.tools.network.TracerouteTool
import com.optix.android.tools.network.WifiScannerTool
import com.optix.android.tools.registry.ToolRegistry
import com.optix.android.tools.utility.CipherTool
import com.optix.android.tools.utility.EncoderTool
import com.optix.android.tools.utility.HashCrackerTool
import com.optix.android.tools.utility.HashGeneratorTool
import com.optix.android.tools.utility.PasswordGeneratorTool
import com.optix.android.tools.utility.PayloadGeneratorTool
import com.optix.android.tools.utility.RegexTesterTool
import com.optix.android.tools.utility.ReverseShellGenTool
import com.optix.android.tools.utility.SubnetCalculatorTool
import com.optix.android.tools.cloud.KubeReconTool
import com.optix.android.tools.cloud.DockerInspectTool
import com.optix.android.tools.ai.LlmPromptInjectionTool
import com.optix.android.tools.ai.AiModelEnumTool
import com.optix.android.tools.web.CORSCheckerTool
import com.optix.android.tools.web.DirectoryFuzzerTool
import com.optix.android.tools.web.DnsReconTool
import com.optix.android.tools.web.HttpInspectorTool
import com.optix.android.tools.web.JwtAnalyzerTool
import com.optix.android.tools.web.NiktoTool
import com.optix.android.tools.web.SecurityHeadersTool
import com.optix.android.tools.web.SqliTesterTool
import com.optix.android.tools.web.NucleiTool

import com.optix.android.tools.web.SqlmapTool
import com.optix.android.tools.web.SubdomainEnumTool
import com.optix.android.tools.web.XssScannerTool
import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ToolModule {

    @Provides
    @Singleton
    fun provideToolRegistry(
        okHttpClient: OkHttpClient,
        @ApplicationContext context: Context,
        providerFactory: com.optix.android.ai.providers.AiProviderFactory,
        shell: com.optix.android.tools.engine.ShellExecutor,
    ): ToolRegistry {
        val registry = ToolRegistry()

        // ── Network & Scanning ───────────────────────────────────────────────
        registry.register(NetworkScannerTool())
        registry.register(PortScannerTool())
        registry.register(LanScannerTool())
        registry.register(NetbiosScannerTool())
        registry.register(WifiScannerTool(context))
        registry.register(TracerouteTool())
        registry.register(PacketSnifferTool())
        registry.register(Rping3Tool())
        registry.register(NmapTool())
        registry.register(MasscanTool())
        registry.register(ArpScanTool())
        registry.register(SSHAuditTool())
        registry.register(LegionTool())
        registry.register(NetworkTopologyTool(okHttpClient))
        registry.register(NativeSnmpWalkTool())
        registry.register(NativeSmbScannerTool())

        // ── DNS & Web ────────────────────────────────────────────────────────
        registry.register(DnsReconTool())
        registry.register(SubdomainEnumTool(okHttpClient))
        registry.register(HttpInspectorTool(okHttpClient))
        registry.register(DirectoryFuzzerTool(okHttpClient))
        registry.register(SqliTesterTool(okHttpClient))
        registry.register(XssScannerTool(okHttpClient))
        registry.register(NiktoTool())
        registry.register(SqlmapTool())
        registry.register(CORSCheckerTool(okHttpClient))
        registry.register(SecurityHeadersTool(okHttpClient))
        registry.register(JwtAnalyzerTool())
        registry.register(GobusterTool())
        registry.register(NativeWhatWebTool(okHttpClient))
        registry.register(NativeWpScanTool(okHttpClient))

        // ── OSINT ────────────────────────────────────────────────────────────
        registry.register(ShodanHostTool(okHttpClient))
        registry.register(ShodanSearchTool(okHttpClient))
        registry.register(HarvesterTool())
        registry.register(HIBPTool(okHttpClient))
        registry.register(HunterIoTool(okHttpClient))
        registry.register(OpenCTIIntegration(okHttpClient))

        // ── Exploitation ─────────────────────────────────────────────────────
        registry.register(BruteForceTool(okHttpClient))
        registry.register(ArpSpooferTool())
        registry.register(HydraTool())
        registry.register(MetasploitTool())
        registry.register(MsfVenomTool())
        registry.register(EvilTwinTool())
        registry.register(DeauthAttackTool())

        // ── LPE & Lateral Movement ────────────────────────────────────────────
        registry.register(LinPEASTool())
        registry.register(WinPEASTool())
        registry.register(BloodhoundTool())
        registry.register(CMETool())
        registry.register(RubeusTool())
        registry.register(NucleiTool())

        // ── Container & Kubernetes Security ─────────────────────────────────
        registry.register(KubeReconTool(shell))
        registry.register(DockerInspectTool(shell))

        // ── AI Security & Red Team ─────────────────────────────────────────
        registry.register(LlmPromptInjectionTool(providerFactory))
        registry.register(AiModelEnumTool(providerFactory))

        // ── Payloads & Utilities ─────────────────────────────────────────────
        registry.register(PayloadGeneratorTool())
        registry.register(ReverseShellGenTool())
        registry.register(HashCrackerTool(okHttpClient))
        registry.register(PasswordGeneratorTool())
        registry.register(EncoderTool())
        registry.register(SubnetCalculatorTool())
        registry.register(HashGeneratorTool())
        registry.register(CipherTool())
        registry.register(RegexTesterTool())

        return registry
    }
}
