package com.jiooption.trading.utils

import com.jiooption.trading.BuildConfig

/**
 * App-wide constants
 */
object Constants {

    // Server URLs
    val BASE_URL: String = BuildConfig.BASE_URL
    val WEB_URL: String = BASE_URL
    val API_URL: String = "$BASE_URL/api"

    // WebView page URLs
    fun dashboardUrl() = "$WEB_URL/user/dashboard.php"
    fun tradeUrl() = "$WEB_URL/user/trade.php"
    fun depositUrl() = "$WEB_URL/user/deposit.php"
    fun withdrawUrl() = "$WEB_URL/user/withdraw.php"
    fun profileUrl() = "$WEB_URL/user/profile.php"
    fun historyUrl() = "$WEB_URL/user/history.php"
    fun supportUrl() = "$WEB_URL/user/support.php"
    fun liveChatUrl() = "$WEB_URL/user/live-chat.php"
    fun kycUrl() = "$WEB_URL/user/kyc-submit.php"
    fun referralUrl() = "$WEB_URL/user/referral.php"
    fun loginUrl() = "$WEB_URL/user/login.php"
    fun registerUrl() = "$WEB_URL/user/register.php"

    // API endpoints
    const val API_LOGIN = "/user/login.php"
    const val API_REGISTER = "/user/register.php"
    const val API_BALANCE = "/user/balance.php"
    const val API_TRADE_PLACE = "/trade/place.php"
    const val API_TRADE_ACTIVE = "/trade/active.php"
    const val API_TRADE_CLOSE = "/trade/close.php"
    const val API_PAYMENT_CREATE = "/payment/create.php"
    const val API_PAYMENT_CHECK = "/payment/check.php"
    const val API_GOOGLE_PLAY_VERIFY = "/payment/google-play-verify.php"
    const val API_DEVICE_REGISTER = "/user/device-register.php"
    const val API_DEVICE_UNREGISTER = "/user/device-unregister.php"
    const val API_APP_CONFIG = "/user/app-config.php"
    const val API_NOTIFICATIONS_LIST = "/notifications/list.php"
    const val API_NOTIFICATIONS_MARK_READ = "/notifications/mark-read.php"

    // Google Play Billing - Product IDs
    val DEPOSIT_PRODUCTS = listOf(
        "deposit_100" to 100,
        "deposit_500" to 500,
        "deposit_1000" to 1000,
        "deposit_2000" to 2000,
        "deposit_5000" to 5000,
        "deposit_10000" to 10000,
        "deposit_25000" to 25000,
        "deposit_50000" to 50000,
        "deposit_100000" to 100000
    )

    fun getProductIds(): List<String> = DEPOSIT_PRODUCTS.map { it.first }

    fun getAmountForProduct(productId: String): Int {
        return DEPOSIT_PRODUCTS.find { it.first == productId }?.second ?: 0
    }

    // SharedPreferences keys
    const val PREF_AUTH_TOKEN = "auth_token"
    const val PREF_SESSION_COOKIE = "session_cookie"
    const val PREF_USER_ID = "user_id"
    const val PREF_USER_NAME = "user_name"
    const val PREF_USER_EMAIL = "user_email"
    const val PREF_IS_LOGGED_IN = "is_logged_in"
    const val PREF_BIOMETRIC_ENABLED = "biometric_enabled"
    const val PREF_FCM_TOKEN = "fcm_token"
    const val PREF_REMEMBER_ME = "remember_me"

    // Notification channels
    const val CHANNEL_DEFAULT = "binarypro_default"
    const val CHANNEL_TRADES = "binarypro_trades"
    const val CHANNEL_DEPOSITS = "binarypro_deposits"
    const val CHANNEL_WITHDRAWALS = "binarypro_withdrawals"
    const val CHANNEL_PROMO = "binarypro_promo"

    // Request codes
    const val RC_BIOMETRIC = 1001
    const val RC_NOTIFICATION_PERMISSION = 1002

    // Timeouts
    const val CONNECT_TIMEOUT = 30L // seconds
    const val READ_TIMEOUT = 30L
    const val WRITE_TIMEOUT = 30L

    // Package
    const val PACKAGE_NAME = "com.jiooption.trading"
}
