package com.adealink.weparty.debug

import android.net.Uri
import com.adealink.frame.base.AppBase
import com.adealink.weparty.network.DEBUG_HOST_CN
import com.adealink.weparty.network.RELEASE_HOSTS
import com.adealink.weparty.network.getLocalHost

fun isTestEnv(): Boolean {
    return when {
        AppBase.isRelease -> false
        DebugPrefs.httpUrl.isEmpty() -> {
            getLocalHost() == DEBUG_HOST_CN
        }
        else -> {
            Uri.parse(DebugPrefs.httpUrl).host == DEBUG_HOST_CN
        }
    }
}

fun envName(): String {
    if (AppBase.isRelease) {
        return "生产"
    }

    val host = Uri.parse(DebugPrefs.httpUrl).host
    return when {
        RELEASE_HOSTS.contains(host) -> "生产"
        host == DEBUG_HOST_CN -> "国内测试"
        else -> "未知"
    }
}

interface OnReturnValue{
    fun clickValue(type: String, value: String? = null)
}