plugins {
    id("com.android.application")
    alias(libs.plugins.compose.compiler)
    kotlin("plugin.serialization") version "2.3.0"
}

android {
    namespace = "com.img.rabbit"
    compileSdk = 36

    buildFeatures {
        compose = true
        buildConfig = true
        viewBinding = true
    }


    composeOptions {
        kotlinCompilerExtensionVersion = "1.4.8"
    }

    defaultConfig {
        applicationId = "com.img.rabbit"
        minSdk = 24
        targetSdk = 36
        versionCode = 2
        versionName = "1.1"


        setManifestPlaceholders(mapOf(
            "GETUI_APPID" to (project.findProperty("GETUI_APPID") as? String ?: ""),
            "GT_INSTALL_CHANNEL" to (project.findProperty("GT_INSTALL_CHANNEL") as? String ?: "GT_INSTALL_CHANNEL")
        ))
        ndk {
            abiFilters.addAll(listOf("arm64-v8a", "x86_64"))
        }

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

        vectorDrawables {
            useSupportLibrary = true
        }
        multiDexEnabled = true

        resConfigs("en", "zh-rCN")

        flavorDimensions.addAll(listOf("channel"))

        productFlavors {
            create("general") {
                dimension = "channel"
                manifestPlaceholders["UMENG_CHANNEL"] = "general"
            }
        }

        productFlavors.configureEach {
            dimension = "channel"
            manifestPlaceholders.putAll(mapOf("UMENG_CHANNEL" to name))
        }
        manifestPlaceholders.putAll(mapOf(
            "GETUI_APPID" to (project.findProperty("GETUI_APPID") as? String ?: ""),
            "GT_INSTALL_CHANNEL" to "general",
        ))
    }


    // 配置签名信息
    signingConfigs {
        create("config") {
            storeFile = file(project.findProperty("RELEASE_STORE_FILE") ?: "bidinfo.keystore")
            storePassword = project.findProperty("RELEASE_STORE_PASSWORD") as? String ?: ""
            keyAlias = project.findProperty("RELEASE_KEY_ALIAS") as? String ?: ""
            keyPassword = project.findProperty("RELEASE_KEY_PASSWORD") as? String ?: ""
            enableV1Signing = true
            enableV2Signing = true
            enableV3Signing = true
        }
    }

    buildTypes {
        getByName("debug") {
            isMinifyEnabled = false
            isShrinkResources = false
            signingConfig = signingConfigs.getByName("config")
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
        getByName("release") {
            isMinifyEnabled = false
            isShrinkResources = false
            signingConfig = signingConfigs.getByName("config")
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
}

dependencies {
    // 基础依赖
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.androidx.material)
    implementation(libs.androidx.activity)
    implementation(libs.androidx.constraintlayout)
    implementation(libs.androidx.core.splashscreen)
    
    // Compose 依赖
    implementation(platform(libs.androidx.compose.bom))
    implementation(libs.androidx.compose.ui)
    implementation(libs.androidx.compose.ui.tooling)
    implementation(libs.androidx.compose.ui.tooling.preview)
    implementation(libs.androidx.compose.material3)
    implementation(libs.androidx.compose.activity.compose)
    implementation(libs.androidx.compose.foundation)
    implementation(libs.androidx.navigation.runtime.ktx)

    // ViewModel 和 Lifecycle 依赖
    implementation(libs.androidx.compose.runtime.livedata)
    implementation(libs.androidx.compose.lifecycle.viewmodel)
    implementation(libs.androidx.compose.lifecycle.runtime.compose)
    implementation(libs.androidx.compose.runtime.livedata)

    // Kotlinx Serialization 依赖
    implementation(libs.kotlinx.serialization.json)
    implementation(libs.androidx.navigation.compose)
    implementation(libs.androidx.datastore.core)
    implementation(libs.androidx.datastore.preferences)
    implementation(libs.androidx.foundation)

    // 测试依赖
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.test.ext.junit)
    androidTestImplementation(libs.androidx.test.espresso.core)

    //个推一键认证
    implementation(libs.gysdk)
    implementation(libs.gson)
    implementation(libs.mmkv)
    implementation(libs.coil.compose)
    implementation(libs.coil.network.okhttp)
    implementation(libs.segmentation.selfie)
    implementation(libs.face.detection)
    implementation(libs.android.gif.drawable)
    implementation(libs.gif.encoder)
    //implementation("com.caverock:androidsvg:1.4")
    implementation(libs.pictureselector)
    implementation(libs.compress)
    implementation(libs.matisse)
    implementation(libs.cropify)
    //noinspection GradleDynamicVersion
    api("com.alipay.sdk:alipaysdk-android:+@aar")
    implementation(libs.wechat.sdk)  //微信
    //Retrofit 依赖
    implementation(libs.retrofit)
    implementation(libs.retrofit.kotlin.serialization)
    implementation (libs.retrofit.converter.gson)
    implementation(libs.okhttp)
    implementation(libs.okhttp.logging.interceptor)

    //友盟
    implementation (libs.umeng.umsdk.common)// 必选
    implementation (libs.umeng.umsdk.asms)// 必选
    implementation (libs.umeng.umsdk.apm) // U-APM包依赖(必选)
    implementation (libs.umeng.umsdk.share.core)//分享核心库，必选
    implementation (libs.umeng.umsdk.share.wx) //微信完整版
    //分包
    implementation (libs.tencent.helper)  //腾讯分包
    implementation (files("libs/channelsdk-0.2.2.aar"))  //快手分包
    implementation (files("libs/humesdk-1.0.0.aar"))  //巨量分包

    implementation(libs.android.cn.oaid)  //获取手机设备id
    implementation(libs.fastaes)  //解密
    implementation("com.google.accompanist:accompanist-permissions:0.32.0")

}