# =============================================================================
# CONSUMER ProGuard/R8 rules — merged into the HOST APP's single R8 run (shipped
# inside the AAR as `proguard.txt`). KEEP THIS MINIMAL and `no.kindly`-scoped.
#
# Rules here apply app-wide and the host CANNOT override or suppress an individual
# library's consumer rules (pre-AGP-9). So NEVER add here:
#   * global directives: -repackageclasses, -flattenpackagehierarchy,
#     -allowaccessmodification, -keepattributes
#   * whole-program member keeps: -keepclassmembers class * { ... } / enum * { ... }
#   * -keep class * extends android.app.*   (host components)
#   * blanket third-party keeps: okhttp3 / kotlinx.coroutines / io.sentry /
#     org.slf4j / androidx.{room,lifecycle,navigation,compose}.** — every one of
#     those libraries already ships its own narrow consumer rules.
# Over-broad consumer rules degrade the host's R8 across its whole app — Boozt
# measured ~10% of all retained code attributable to this SDK (SDK-374).
# SDK-internal / global rules belong in `sdk-internal-proguard-rules.pro`.
# =============================================================================

# The SDK ships PRE-MINIFIED but still-renamable bytecode. The host's R8 must not
# re-obfuscate or shrink it, or these break at runtime:
#   - manifest-declared components the framework loads by name
#     (no.kindly.chatsdk.chat.presentation.ChatSDKActivity, ...core.ChatSdkFileProvider)
#   - Parcelable CREATORs (e.g. OEmbedData @Parcelize) crossing the Activity/nav boundary
#   - kotlinx.serialization $$serializer synthetics paired with their data classes
#   - the public API the host links against (KindlySDK/EntryPoint, models, theme, callbacks)
# Scoped to `no.kindly` only — this costs the host nothing outside our namespace.
-keep class no.kindly.chatsdk.** { *; }

# That single rule is the entire legitimate consumer surface. Everything the SDK
# needs from its third-party dependencies is kept by THOSE libraries' own consumer
# rules, which R8 applies to the host automatically from the transitive classpath
# (verified against the exact resolved versions, SDK-374):
#   okhttp 4.12.0        -> META-INF/proguard/okhttp3.pro
#   coroutines 1.8.1     -> META-INF/proguard/coroutines.pro (+ com.android.tools/*)
#   serialization 1.7.3  -> META-INF/proguard/kotlinx-serialization-common.pro (+ r8)
#   lifecycle 2.7.0      -> AAR proguard.txt
#   navigation 2.7.7     -> navigation-common AAR proguard.txt (Kindly uses string routes, no SafeArgs reflection)
#   sentry-android 8.46.0-> AAR proguard.txt (Kindly calls Sentry by direct symbol, not reflection)
#   pusher 2.4.4         -> META-INF/proguard/pusher.pro keeps its GSON-reflected DTOs
#                           (com.pusher.client.{channel,user}.impl.message.**) incl. AuthResponse
# Kindly itself uses NO GSON / Class.forName / ServiceLoader, so nothing else here is needed.
# gson (2.9.1) ships no rules, but Kindly never reflects into it.

# --- slf4j missing-binder suppression (the ONE legitimate third-party rule here) ---
# pusher-java-client 2.4.4 pulls slf4j-api (1.7.x) in transitively — via its
# Java-WebSocket (org.java-websocket:Java-WebSocket:1.5.3) dependency, whose socket
# classes log through slf4j. slf4j-api's LoggerFactory / MDC / MarkerFactory reference
# org.slf4j.impl.StaticLoggerBinder / StaticMDCBinder / StaticMarkerBinder —
# binder classes that live in a SEPARATE logging-backend artifact
# that neither the SDK nor most hosts bundle (by design: we don't force a logging
# backend on integrators). In a MINIFIED host build R8's missing-class check then hard-
# errors ("Missing class org.slf4j.impl.StaticLoggerBinder ... referenced from
# org.slf4j.LoggerFactory.bind()"), failing the host's minify<Variant>WithR8 task.
# Debug builds skip R8, so this only bites minified consumers.
#
# This is a transitive MISSING-CLASS reference, not reflection — so a -dontwarn is the
# right tool, and unlike a -keep it suppresses the error without retaining anything, so
# it has ZERO effect on the host's shrinking/obfuscation (does not violate the
# minimalism rule above). It is the canonical, safe slf4j R8 rule; R8 itself emits it
# in missing_rules.txt. Verified: with this line removed, :kindlysample:minifyReleaseWithR8
# fails with the exact customer error; with it, the build passes.
#
# History: shipped in the consumer file until SDK-374 dropped it (reasoning "Kindly
# never reflects into slf4j" — true, but the failure is a missing-class ref, not
# reflection), which regressed minified customers on 2.0.3+ (Boozt). Restored here.
-dontwarn org.slf4j.**

# --- kotlin-parcelize compile-time annotation suppression ---
# The SDK applies the `org.jetbrains.kotlin.plugin.parcelize` plugin and uses `@Parcelize`
# on `no.kindly.chatsdk.chat.sdk.data.entity.OEmbedData`. The `@Parcelize` annotation
# (`kotlinx.parcelize.Parcelize`) lives in `kotlin-parcelize-runtime`, which the plugin
# puts on the SDK's OWN compile classpath but does NOT propagate to consumers (it's a
# build-time annotation, BINARY-retention, never read at runtime — the plugin generates
# the Parcelable CREATOR/writeToParcel at compile time). Our `-keep class no.kindly...`
# retains OEmbedData, whose bytecode still carries the annotation reference, so a MINIFIED
# consumer that does NOT itself apply kotlin-parcelize hits R8's missing-class check:
# "Missing class kotlinx.parcelize.Parcelize (referenced from OEmbedData)" — failing
# minify<Variant>WithR8 exactly like slf4j. Reproduced in android-test (a bare Compose
# consumer without the parcelize plugin) against the published 2.0.8.
# A -dontwarn is the correct, zero-runtime-cost fix (R8 itself emits it in missing_rules.txt);
# the generated Parcelable code works without the annotation class present.
-dontwarn kotlinx.parcelize.**
