# OSMOS SDK Consumer ProGuard Rules
# Rules for apps that integrate the OSMOS SDK

# ==================== SDK PUBLIC API ====================
# Keep main SDK entry point and its public methods
-keep public class com.ai.osmos.core.OsmosSDK {
    public *;
}

# Complete preservation of all nested classes in OsmosSDK (includes Companion, Builder, etc.)
-keep class com.ai.osmos.core.OsmosSDK$* {
    *;
}

# Keep specific public manager classes and their public methods
-keep public class com.ai.osmos.ads.views.managers.BannerAdViewManager {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.CarouselAdViewManager {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.InterstitialAdViewManager {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.PIPAdViewManager {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.MultiAdCarouselViewManager {
    public *;
}

# Keep specific public interfaces that consumer apps will use
-keep public interface com.ai.osmos.ads.views.interfaces.BannerAdViewInterface {
    public *;
}
-keep public interface com.ai.osmos.ads.views.interfaces.CarouselAdViewInterface {
    public *;
}
-keep public interface com.ai.osmos.ads.views.interfaces.InterstitialAdViewInterface {
    public *;
}
-keep public interface com.ai.osmos.ads.views.interfaces.MultiAdCarouselViewInterface {
    public *;
}
-keep public interface com.ai.osmos.ads.views.interfaces.PIPAdViewInterface {
    public *;
}

# Keep specific renderer interface that apps use
-keep public interface com.ai.osmos.ads.renderer.AdRendererInterface {
    public *;
}

# Keep error callback interface
-keep public interface com.ai.osmos.utils.error.ErrorCallback {
    public *;
}

# Model classes are covered by specific rules above - no broad wildcard needed
# This prevents exposing internal model classes unnecessarily

# Keep TargetingParams interface and implementations
-keep public interface com.ai.osmos.models.ads.TargetingParams {
    public *;
}
-keep public class com.ai.osmos.models.ads.PlatformTargeting {
    public *;
}
-keep public class com.ai.osmos.models.ads.MerchandiseTargeting {
    public *;
}
-keep public class com.ai.osmos.models.ads.GeoTargeting {
    public *;
}
-keep public class com.ai.osmos.models.ads.ContextTargeting {
    public *;
}
-keep public class com.ai.osmos.models.ads.CustomLabelTargeting {
    public *;
}


# Keep ProductAdsFilter and its companion object
-keep public class com.ai.osmos.models.ads.ProductAdsFilter {
    public *;
}

# Keep ProductAdsFilter companion object and all its factory methods
-keep class com.ai.osmos.models.ads.ProductAdsFilter$* {
    *;
}

# Keep specific public enum classes that consumer apps actually use
-keep public enum com.ai.osmos.models.enums.DisplayAdFormat {
    *;
}

-keep public enum com.ai.osmos.models.events.VideoActionType {
    *;
}

# ==================== SETTINGS AND CONFIGURATION CLASSES ====================
# Keep specific settings classes used by consumer apps
-keep public class com.ai.osmos.ads.views.managers.BannerAdSettings {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.CarouselAdSettings {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.InterstitialAdSettings {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.PIPAdSettings {
    public *;
}
-keep public class com.ai.osmos.ads.views.managers.MultiAdCarouselSettings {
    public *;
}

# Keep public styling classes (used by consumer apps)
-keep public class com.ai.osmos.ads.views.style.** {
    public *;
}

# ==================== SDK INTERNAL (Don't obfuscate for debugging) ====================
# Keep internal SDK classes to help with debugging consumer integration issues
-keep class com.ai.osmos.ads.fetcher.** { *; }

# Keep public event tracking APIs (used by consumer apps)
-keep public interface com.ai.osmos.tracking.events.RegisterEventInterface {
    public *;
}
-keep public class com.ai.osmos.models.events.TrackingParams {
    public *;
}
-keep public class com.ai.osmos.models.events.TrackingParams$Builder {
    public *;
}

# Keep TrackingParams companion object and all its factory methods
-keep class com.ai.osmos.models.events.TrackingParams$* {
    *;
}

# Ad view classes are internal - consumers use Manager classes instead
# No need to keep ad view constructors as they're not directly instantiated by apps

# ==================== THIRD-PARTY DEPENDENCIES ====================
# Media3/ExoPlayer - needed for video ads
-keep class androidx.media3.** { *; }
-dontwarn androidx.media3.**

# RecyclerView - needed for carousel and list ads
-keep class androidx.recyclerview.** { *; }
-dontwarn androidx.recyclerview.**

# WorkManager - needed for background tracking
-keep class androidx.work.** { *; }
-dontwarn androidx.work.**

# OkHttp - needed for networking
-dontwarn okhttp3.**
-dontwarn okio.**

# ==================== REFLECTION SUPPORT ====================
# Keep reflection methods only for specific public API classes that need them
-keepclassmembers public class com.ai.osmos.models.events.TrackingParams {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}
-keepclassmembers public class com.ai.osmos.models.events.TrackingParams$Builder {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}
-keepclassmembers public class com.ai.osmos.models.ads.PlatformTargeting {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}
-keepclassmembers public class com.ai.osmos.models.ads.MerchandiseTargeting {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}
-keepclassmembers public class com.ai.osmos.models.ads.GeoTargeting {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}
-keepclassmembers public class com.ai.osmos.models.ads.ContextTargeting {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}
-keepclassmembers public class com.ai.osmos.models.ads.CustomLabelTargeting {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}
-keepclassmembers public class com.ai.osmos.models.ads.ProductAdsFilter {
    public <init>(...);
    public void set*(...);
    public * get*(...);
}

# Keep companion objects only for public API classes (that already have 'public static *;')
# This ensures Kotlin consumers can access companion methods via ClassName.method() syntax
-keepclassmembers public class com.ai.osmos.models.events.TrackingParams {
    public *** Companion;
}
# Note: Enum companion objects are already covered by enum rules above
-keepclassmembers public class com.ai.osmos.models.ads.PlatformTargeting {
    public *** Companion;
}
-keepclassmembers public class com.ai.osmos.models.ads.MerchandiseTargeting {
    public *** Companion;
}
-keepclassmembers public class com.ai.osmos.models.ads.GeoTargeting {
    public *** Companion;
}
-keepclassmembers public class com.ai.osmos.models.ads.ContextTargeting {
    public *** Companion;
}
-keepclassmembers public class com.ai.osmos.models.ads.CustomLabelTargeting {
    public *** Companion;
}
-keepclassmembers public class com.ai.osmos.models.ads.ProductAdsFilter {
    public *** Companion;
}

# ==================== CUSTOM VIEW SUPPORT ====================
# Keep SDK ad view constructors (programmatic creation only)
-keep class com.ai.osmos.ads.views.** extends android.view.View {
    public <init>(android.content.Context, ...);
}

# ==================== KOTLIN COROUTINES ====================
# Keep coroutines classes (SDK uses coroutines extensively)
-keep class kotlinx.coroutines.** { *; }
-dontwarn kotlinx.coroutines.**

# ==================== WARNING SUPPRESSIONS ====================
-dontwarn java.lang.invoke.StringConcatFactory
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**

# ==================== CONSUMER APP GUIDANCE ====================
# Consumer apps should add these rules to their proguard-rules.pro:
#
# # If using custom error callbacks
# -keep class * implements com.ai.osmos.utils.error.ErrorCallback { *; }
#
# # If using custom views with SDK
# -keep class * extends com.ai.osmos.ads.views.** { *; }
#
# # If implementing SDK interfaces
# -keep class * implements com.ai.osmos.ads.views.interfaces.** { *; }
