# Consumer ProGuard Rules for SeineTime Universal SDK
# These rules are automatically applied to apps that depend on this SDK
# They ensure the SDK's public API and functionality work correctly with ProGuard/R8

##---------------Begin: proguard configuration for SeinetimeUniversalSDK  ----------

# ===== Attributes Required by SDK =====

# Keep generic signatures for proper serialization and reflection
-keepattributes Signature

# Keep all annotations for runtime processing
-keepattributes *Annotation*

# Preserve source file and line numbers for better crash reports
-keepattributes SourceFile,LineNumberTable

# ===== Public API Surface =====
# These classes and methods are part of the SDK's public API

# Main SDK entry point
-keep public class ai.seinetime.sdk.Seinetime {
    public <methods>;
    public <fields>;
}

# Setup result classes
-keep public class ai.seinetime.sdk.SeinetimeSetupResult {
    public *;
}
-keep public class ai.seinetime.sdk.SeinetimeSetupResult$* {
    *;
}

# Configuration API
-keep public class ai.seinetime.sdk.internal.Configuration {
    public <methods>;
    public <fields>;
}
-keep public class ai.seinetime.sdk.internal.Configuration$Builder {
    public <methods>;
}
-keep public class ai.seinetime.sdk.internal.Configuration$Environment {
    public *;
}

# Analytics API classes (used in track, identify, screen methods)
-keep public class ai.seinetime.sdk.analytics.Options {
    public <methods>;
    public <fields>;
}
-keep public class ai.seinetime.sdk.analytics.Traits {
    public <methods>;
    public <fields>;
}
-keep public class ai.seinetime.sdk.analytics.Traits$Cache {
    public <methods>;
}
-keep public class ai.seinetime.sdk.internal.Properties {
    public <methods>;
    public <fields>;
}

# ===== @Keep Annotation Support =====
# Honor @Keep annotations used throughout the SDK

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

# ===== SDK Internal Components =====
# Required for SDK functionality but not directly accessed by consumers

# JSON serialization (Cartographer)
-keep class ai.seinetime.sdk.internal.Cartographer {
    public <methods>;
}
-keep class ai.seinetime.sdk.internal.ValueMap {
    public <methods>;
    protected <methods>;
}

# Analytics context and payloads
-keep class ai.seinetime.sdk.analytics.AnalyticsContext {
    <init>(...);
}
-keep class ai.seinetime.sdk.analytics.AnalyticsContext$Device {
    <init>(...);
}
-keep class ai.seinetime.sdk.analytics.integrations.*Payload {
    <init>(...);
}
-keep class ai.seinetime.sdk.analytics.integrations.*Payload$Builder {
    <init>(...);
}

# Network models
-keep class ai.seinetime.sdk.analytics.integrations.UnifiedIDPayload {
    <fields>;
    <init>(...);
}

# ===== Reflection Support =====

# Google Play Services Advertising ID (optional)
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
    public static *** getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
    public *** getId();
    public *** isLimitAdTrackingEnabled();
}

# Don't warn if Google Play Services is not included
-dontwarn com.google.android.gms.ads.**

# ===== Gson Compatibility =====

# Suppress warnings about missing Gson internals
-dontwarn sun.misc.**

# Keep Gson adapters and serializers
-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

# Preserve fields annotated with @SerializedName
-keepclassmembers,allowobfuscation class * {
    @com.google.gson.annotations.SerializedName <fields>;
}

# Keep TypeToken for generic type preservation
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

# ===== Kotlin Compatibility =====

# Keep companion objects for SDK classes
-keepclassmembers class ai.seinetime.sdk.** {
    public static ** Companion;
}
-keepclassmembers class ai.seinetime.sdk.**$Companion {
    public <methods>;
}

# ===== AndroidX Startup =====
# Required for auto-initialization

-keep class ai.seinetime.sdk.SeinetimeInitializer {
    <init>();
}

##---------------End: proguard configuration for SeinetimeUniversalSDK  ----------