########################################################################
###Beacon specific config

-keepattributes InnerClasses
#keep the R classes so the webview can see R and the res raw dir
-keepclassmembers class **.R$* {public static <fields>;}
-keep class **.R$*

#keep the models needed for moshi
# API
-keepclassmembers class com.helpscout.beacon.internal.domain.model.** {
  <init>(...);
  <fields>;
}
-keep class com.helpscout.beacon.internal.domain.model.** { *; }
-keepnames @kotlin.Metadata class com.helpscout.beacon.internal.domain.model.**

# Core Models (for Moshi/API serialization)
-keepclassmembers class com.helpscout.beacon.internal.core.model.** {
  <init>(...);
  <fields>;
}
-keep class com.helpscout.beacon.internal.core.model.** { *; }
-keepnames @kotlin.Metadata class com.helpscout.beacon.internal.core.model.**

-keepclassmembers class com.helpscout.beacon.model.** {
  <init>(...);
  <fields>;
}
-keep class com.helpscout.beacon.model.** { *; }
-keepnames @kotlin.Metadata class com.helpscout.beacon.model.**

# Keep public UI classes
-keep class com.helpscout.beacon.ui.BeaconActivity { *; }
-keep class com.helpscout.beacon.ui.BeaconEventLifecycleHandler { *; }
-keep interface com.helpscout.beacon.ui.BeaconOnOpenedListener { *; }
-keep interface com.helpscout.beacon.ui.BeaconOnClosedListener { *; }
-keep class com.helpscout.beacon.ui.BeaconPushNotificationsProcessor { *; }

#keep extension classes
-keep class com.helpscout.beacon.internal.presentation.extension.* {*;}
-keep class com.helpscout.beacon.internal.domain.extension.* {*;}

#keep Enum classes (issue encouted making SDK proguard-optimised compatible
-keepclassmembers class * extends java.lang.Enum {
    <fields>;
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Keep WebView class name (so inner class stays BeaconWebView$BeaconJsBridge) and JS bridge method names.
-keepnames class com.helpscout.beacon.internal.presentation.webview.BeaconWebView
-keep class com.helpscout.beacon.internal.presentation.webview.BeaconWebView$BeaconJsBridge { *; }
-keepclassmembers class com.helpscout.beacon.internal.presentation.webview.BeaconWebView$BeaconJsBridge {
    @android.webkit.JavascriptInterface <methods>;
}

########################################################################
### KOTLIN
-keepattributes *Annotation*
-dontwarn org.jetbrains.annotations.**
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.CallableDescriptor
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.ClassDescriptor
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.ClassifierDescriptorWithTypeParameters
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.annotations.AnnotationDescriptor
-dontwarn kotlin.reflect.jvm.internal.impl.descriptors.impl.PropertyDescriptorImpl
-dontwarn kotlin.reflect.jvm.internal.impl.load.java.JavaClassFinder
-dontwarn kotlin.reflect.jvm.internal.impl.resolve.OverridingUtil
-dontwarn kotlin.reflect.jvm.internal.impl.types.DescriptorSubstitutor
-dontwarn kotlin.reflect.jvm.internal.impl.types.DescriptorSubstitutor
-dontwarn kotlin.reflect.jvm.internal.impl.types.TypeConstructor
-dontwarn kotlin.reflect.jvm.internal.DefaultConstructorMaker
-keep class kotlin.Unit { *; }
-keep class kotlin.collections.CollectionsKt { *; }

# The Android pre-handler for exceptions is loaded reflectively (via ServiceLoader).
# https://github.com/Kotlin/kotlinx.coroutines/issues/214
-keep class kotlinx.coroutines.android.AndroidExceptionPreHandler { *; }
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}

-keepclassmembernames class kotlinx.** {
    volatile <fields>;
}

########################################################################
### MOSHI
-keep class kotlin.Metadata { *; }

-dontwarn okio.**
-dontwarn javax.annotation.**

-keepclasseswithmembers class * {
    @com.squareup.moshi.* <methods>;
}

-keepnames @com.squareup.moshi.JsonClass class *

-keep @com.squareup.moshi.JsonQualifier interface *

# Enum field names are used by the integrated EnumJsonAdapter.
# values() is synthesized by the Kotlin compiler and is used by EnumJsonAdapter indirectly
# Annotate enums with @JsonClass(generateAdapter = false) to use them with Moshi.
-keepclassmembers @com.squareup.moshi.JsonClass class * extends java.lang.Enum {
    <fields>;
    **[] values();
}

-keepclassmembers class * {
    @com.squareup.moshi.FromJson <methods>;
    @com.squareup.moshi.ToJson <methods>;
}

# moshi-kotlin
-keep class kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoaderImpl

-keepclassmembers class kotlin.Metadata {
    public <methods>;
}

########################################################################
### OKHttp
-dontnote android.net.http.*
-dontnote org.apache.commons.codec.**
-dontnote org.apache.http.**
-dontwarn okhttp3.**
-dontwarn okio.**

########################################################################
### Retrofit

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

 # Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
 -keep,allowobfuscation,allowshrinking interface retrofit2.Call
 -keep,allowobfuscation,allowshrinking class retrofit2.Response

 # With R8 full mode generic signatures are stripped for classes that are not
 # kept. Suspend functions are wrapped in continuations where the type argument
 # is used.
 -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation

# This is generated automatically by the Android Gradle plugin.
-dontwarn java.lang.invoke.StringConcatFactory
-dontwarn org.slf4j.impl.StaticLoggerBinder
-dontwarn kotlinx.parcelize.Parcelize
