##--------------- Rules shipped with the SDK AAR and get auto-applied to consumer apps. ---------------

# Keep the IAB TCF libraries classes
-keep class io.didomi.iabtcf.** { *; }
-keep class io.didomi.sdk.** { *; }

##--------------- Begin: Didomi custom dependency injection ---------------
# The DI system resolves the generated InjectionMetadata via Class.forName() and
# reads runtime annotations (@Inject + @Qualifier) by reflection as a fallback.
# Under R8 full mode these are stripped/repackaged unless explicitly kept, which
# breaks qualified bindings (e.g. @IoDispatcher CoroutineDispatcher) -> the
# fallback loses the qualifier and resolution fails with "No DI binding".

# Keep the generated metadata class loaded by name (Class.forName) and its members.
# Only InjectionMetadata is loaded reflectively; the rest of io.didomi.sdk.** is already
# kept by the broad rule above. The exact name must survive so Class.forName resolves.
-keep class io.didomi.sdk.core.injection.generated.InjectionMetadata { *; }

# Keep the qualifier annotation classes and the @Qualifier meta-annotation so the
# reflection fallback (findQualifierAnnotation) can still detect them.
-keep @interface io.didomi.sdk.core.injection.annotation.Qualifier
-keep @interface io.didomi.sdk.core.injection.annotation.Inject
-keep @io.didomi.sdk.core.injection.annotation.Qualifier @interface * { *; }

# Keep runtime-visible annotations on injected members (R8 full mode strips these
# from members of kept classes otherwise), so @Inject/@<Qualifier> survive on fields.
-keepattributes RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeVisibleTypeAnnotations,AnnotationDefault
##--------------- End: Didomi custom dependency injection ---------------

# Prevent a bug in some proguard versions
# See https://sourceforge.net/p/proguard/bugs/643/
-keep,allowshrinking,allowobfuscation enum io.didomi.iabtcf.decoder.v2.RestrictionType

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}

# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
# Source: https://r8.googlesource.com/r8/+/refs/heads/main/compatibility-faq.md#troubleshooting-gson-gson
-keep class com.google.gson.reflect.TypeToken { *; }
-keep class * extends com.google.gson.reflect.TypeToken
##---------------End: proguard configuration for Gson  ----------

-dontwarn com.eclipsesource.v8.V8

# Prevent issues in some configurations
-dontwarn kotlinx.parcelize.Parcelize

# Firebase Consent Mode v2 — preserve symbols invoked via reflection by Didomi's GCM integration
-dontwarn com.google.firebase.analytics.FirebaseAnalytics
#noinspection ShrinkerUnresolvedReference
-keep class com.google.firebase.analytics.FirebaseAnalytics$ConsentType { *; }
#noinspection ShrinkerUnresolvedReference
-keep class com.google.firebase.analytics.FirebaseAnalytics$ConsentStatus { *; }
#noinspection ShrinkerUnresolvedReference
-keepclassmembers class com.google.firebase.analytics.FirebaseAnalytics {
    public void setConsent(java.util.Map);
}
