package com.optix.android.domain.model

data class AiProviderConfig(
    val provider: AiProviderType = AiProviderType.OPENROUTER,
    val apiKey: String = "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",
    val baseUrl: String = "https://openrouter.ai/api/v1",           // used by Ollama / OpenRouter
    val model: String = "openrouter/free",
    val systemPrompt: String = DEFAULT_SYSTEM_PROMPT,
)

enum class AiProviderType {
    OFFLINE, GEMINI, OPENAI, ANTHROPIC, GROQ, MISTRAL, OPENROUTER;

    val displayName: String get() = when (this) {
        OFFLINE     -> "Offline (Mock Brain)"
        GEMINI      -> "Gemini"
        OPENAI      -> "OpenAI"
        ANTHROPIC   -> "Anthropic"
        GROQ        -> "Groq"
        MISTRAL     -> "Mistral"
        OPENROUTER  -> "OpenRouter"
    }

    val defaultModel: String get() = when (this) {
        GEMINI      -> "gemini-2.0-flash"
        OPENAI      -> "gpt-4o"
        ANTHROPIC   -> "claude-3-5-sonnet-20241022"
        GROQ        -> "llama-3.3-70b-versatile"
        MISTRAL     -> "mistral-large-latest"
        OPENROUTER  -> "openrouter/free"
        OFFLINE     -> ""
    }
}

data class AppSettings(
    val darkTheme: Boolean = true,
    val accentColor: String = "#00FF88",
    val maxToolTimeoutSeconds: Int = 180,
    val streamingEnabled: Boolean = true,
    val favorites: Set<String> = emptySet(),
)

data class NetworkSettings(
    val defaultScanTimeout: String = "400",
    val defaultPortRange: String = "1-9999",
    val nmapFlags: String = "-sV",
    val autoScanOnOpen: Boolean = true,
    val aggressiveScan: Boolean = false,
    val proxyHost: String = "",
    val proxyPort: String = "",
    val useTor: Boolean = false,
    val termuxPath: String = "/data/data/com.termux/files/usr/bin",
    val autoInstallTools: Boolean = false,
    val autoSaveSessions: Boolean = true,
)

const val DEFAULT_SYSTEM_PROMPT =
    "You are Ori-on Brain, a specialized network security AI assistant embedded in the Optix mobile pentesting platform. " +
    "You have access to 36 network security tools across 4 categories:\n" +
    "• Network & Scanning (14): network_scanner, port_scanner, lan_scanner, netbios_scanner, wifi_scanner, traceroute, packet_sniffer, rping3_termux, nmap_termux, masscan_termux, arp_scan, ssh_audit, legion_termux, network_topology\n" +
    "• DNS & Web (11): dns_recon, subdomain_enum, http_inspector, directory_fuzzer, sqli_tester, xss_scanner, nikto_termux, sqlmap_termux, cors_checker, security_headers, jwt_analyzer\n" +
    "• Exploitation (7): brute_force, arp_spoofer, hydra_termux, metasploit_termux, msfvenom_termux, evil_twin, deauth_attack\n" +
    "• Payloads & Utilities (9): payload_generator, reverse_shell_gen, hash_cracker, password_generator, encoder_tool, subnet_calculator, hash_generator, cipher_tool, regex_tester\n\n" +
    "When a user asks you to perform a network or security task, call the appropriate tool using its exact snake_case name. " +
    "Always remind users to only test systems they have explicit permission to test. " +
    "Provide educational context alongside results — explain what findings mean for beginners. " +
    "Suggest tool chains: e.g. nmap → port_scanner → ssh_audit → hydra for a full host assessment. " +
    "Be concise, technical, and direct. Format results clearly."
