################################################################################
# DoorstepAI Tracking SDK — consumer ProGuard / R8 keep rules.
#
# Shipped INSIDE the AAR (see `consumerProguardFiles` in build.gradle.kts) so a
# host app that enables R8 / minification in its own release build cannot strip
# or rename the SDK's reflection-dependent code or its public API. These rules
# are applied automatically in the integrator's build — the SDK library itself
# is not minified.
#
# Covered reflective surfaces:
#   - kotlinx.serialization @Serializable models + generated $$serializer classes
#   - Room @Entity / @Dao / @Database + generated *_Impl classes
#   - WorkManager ListenableWorker subclasses (constructed reflectively)
#   - the public DoorstepAI API surface host apps call into
################################################################################

# ---- Public API surface (host apps reference these directly) -----------------
# The public façade package (NOT `.internal.**`, which may be shrunk/renamed
# freely except where the rules below keep specific reflective classes).
-keep public class com.doorstepai.sdks.tracking.* { public protected *; }
-keep public class com.doorstepai.sdks.tracking.*$* { public protected *; }
# Enums are frequently used as serialized values / public parameters — keep them.
-keep public enum com.doorstepai.sdks.tracking.** { *; }

# ---- kotlinx.serialization ---------------------------------------------------
# kotlinx-serialization-json ships its own framework keep rules; these protect
# the SDK's OWN @Serializable classes and their compiler-generated serializers.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault,InnerClasses
-if @kotlinx.serialization.Serializable class com.doorstepai.sdks.tracking.**
-keep,allowobfuscation,allowshrinking class <1>
-keepclassmembers class com.doorstepai.sdks.tracking.** {
    *** Companion;
    kotlinx.serialization.KSerializer serializer(...);
}
-keep,includedescriptorclasses class com.doorstepai.sdks.tracking.**$$serializer { *; }

# ---- Room --------------------------------------------------------------------
# Room ships its own consumer rules; these are belt-and-suspenders for the SDK's
# own entities / DAOs / database and the generated implementation classes.
-keep @androidx.room.Entity class com.doorstepai.sdks.tracking.** { *; }
-keep @androidx.room.Dao class com.doorstepai.sdks.tracking.** { *; }
-keep @androidx.room.Database class com.doorstepai.sdks.tracking.** { *; }
-keep class com.doorstepai.sdks.tracking.**_Impl { *; }

# ---- WorkManager -------------------------------------------------------------
# Workers are instantiated reflectively by WorkManager via their
# (Context, WorkerParameters) constructor.
-keep class com.doorstepai.sdks.tracking.** extends androidx.work.ListenableWorker {
    public <init>(android.content.Context, androidx.work.WorkerParameters);
}

# ---- SDK BuildConfig ---------------------------------------------------------
# Read at runtime for the fallback base URLs and SDK version.
-keep class com.doorstepai.sdks.tracking.BuildConfig { *; }
