# ==================== Screw SDK ProGuard Rules ====================
# SDK Version: 4.0.5

# ==================== 1. Keep Public API ====================
-keep public class com.twist.screw.master.sdk.ScrewGameSDK {
    public <methods>;
    public <fields>;
}

# ✅ Keep public interfaces and classes
-keep public interface com.twist.screw.master.sdk.** { *; }
-keep public class com.twist.screw.master.sdk.** { *; }

# ✅ Keep wrapper classes and typealiases (critical for compilation)
-keep class com.twist.screw.master.sdk.wrapper.** { *; }
-keep interface com.twist.screw.master.sdk.wrapper.** { *; }

# ✅ Keep AnalyticsKeysConfig inner classes (EventNames, ParamKeys, AliLogKeys)
-keep class com.applovia.mediation.gamemoven.AnalyticsKeysConfig$EventNames { *; }
-keep class com.applovia.mediation.gamemoven.AnalyticsKeysConfig$ParamKeys { *; }
-keep class com.applovia.mediation.gamemoven.AnalyticsKeysConfig$AliLogKeys { *; }

# ✅ Keep AdType enum and its Companion object (for fromName method)
-keep class com.applovia.mediation.gamemoven.ads.AdType { *; }
-keep class com.applovia.mediation.gamemoven.ads.AdType$Companion { *; }

# ✅ Keep CocosNativeParams class and all its methods
-keep class com.applovia.mediation.gamemoven.bridge.cocos.CocosNativeParams { *; }

# ✅ Keep IConverterDelegate interface
-keep interface com.applovia.mediation.gamemoven.bridge.IConverterDelegate { *; }

# ✅ Keep IAdStatusHandler interface
-keep interface com.applovia.mediation.gamemoven.callback.IAdStatusHandler { *; }

# ✅ Keep IAlertManager interface
-keep interface com.applovia.mediation.gamemoven.callback.IAlertManager { *; }

# ✅ Keep DefaultCocosCallback and DefaultUICallback classes
-keep class com.applovia.mediation.gamemoven.callback.DefaultCocosCallback { *; }
-keep class com.applovia.mediation.gamemoven.callback.DefaultUICallback { *; }

# ✅ Keep VibratorType enum
-keep enum com.applovia.mediation.gamemoven.utils.VibratorType { *; }

# ==================== 2. String Encryption Support ====================
# Obfuscate StringEncryptor to protect decryption logic
-keep,allowobfuscation class com.twist.screw.master.sdk.wrapper.ScrewStringEncryptor { *; }
-keepclassmembers,allowobfuscation class com.twist.screw.master.sdk.wrapper.ScrewStringEncryptor {
    public static java.lang.String decrypt(java.lang.String);
}
-dontwarn java.util.Base64

# ✅ Keep annotations
-keepattributes *Annotation*

# ==================== 2. Obfuscate Internal Implementation ====================
# Allow obfuscation of wrapper classes (they are internal implementation)
-keep,allowobfuscation class com.twist.screw.master.sdk.wrapper.** { *; }

# ==================== 3. Aggressive Obfuscation Options ====================
-overloadaggressively
-repackageclasses ''
-allowaccessmodification
-mergeinterfacesaggressively
-optimizationpasses 5

# ==================== 4. Custom Obfuscation Dictionary ====================
# ⚠️ IMPORTANT: Dictionary configuration is removed from consumer rules
# Dictionary is only used during local SDK build (see proguard-rules-local.pro)
# This prevents "NoSuchFileException" errors in consumer applications

# ==================== 5. Custom Seed ====================
-adaptclassstrings screw_unique_seed_2024_v1

# ==================== 6. Keep Debug Metadata ====================
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# ==================== 7. Kotlin Related ====================
-keep class kotlin.Metadata { *; }
-keepclassmembernames class kotlinx.** {
    volatile <fields>;
}

# ==================== 8. Keep Android Components ====================
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

# ==================== 9. Cocos Engine Protection (Critical! Prevents NoSuchMethodError at runtime) ====================
-keep class com.cocos.** { *; }
-keep class org.cocos2dx.** { *; }
-keep class com.cocos.lib.** { *; }
-keep class com.cocos.service.** { *; }

# Specifically keep JS bridge classes (prevents runtime errors from obfuscation)
-keepclassmembers class com.cocos.lib.CocosJavascriptJavaBridge {
    public static <methods>;
}
-keepclassmembers class com.cocos.lib.CocosHelper {
    public static <methods>;
}

# ==================== 10. Third-party SDK Rules ====================
-dontwarn **

# ==================== 11. Keep Annotation Markers ====================
-keep class * {
    @androidx.annotation.Keep *;
}

-keepclassmembers class * {
    @androidx.annotation.Keep *;
}
