# TMK Translation SDK consumer rules。
# 该文件会被打入 AAR，供宿主 App 开启 R8/ProGuard 时使用。

# 保留 Kotlin/泛型/注解元信息，避免 Retrofit、Gson、回调和泛型结果解析异常。
-keepattributes Signature,InnerClasses,EnclosingMethod,*Annotation*

# 宿主直接调用的公开 API 必须稳定。
-keep class co.timekettle.translation.TmkTranslationSDK { public *; }
-keep class co.timekettle.translation.TmkTranslationChannel { public *; }
-keep interface co.timekettle.translation.Cancelable { *; }
-keep class co.timekettle.translation.TmkTranslationException { public *; }
-keep class co.timekettle.translation.TmkTranslationException$ErrorCodes { *; }
-keep class co.timekettle.translation.config.TmkTransChannelConfig { public *; }
-keep class co.timekettle.translation.config.TmkTransChannelConfig$Builder { public *; }
-keep class co.timekettle.translation.config.TmkTranslationRoomConfig { public *; }
-keep class co.timekettle.translation.config.TmkTranslationRoomConfig$Builder { public *; }
-keep class co.timekettle.translation.config.** { public *; }
-keep class co.timekettle.translation.enums.TmkOfflineAudioChannelMode { *; }
-keep class co.timekettle.translation.enums.TmkOnlineTranslateEngine { *; }
-keep class co.timekettle.translation.enums.TmkRoomScenario { *; }
-keep class co.timekettle.translation.enums.** { *; }
-keep interface co.timekettle.translation.listener.** { *; }
-keep class co.timekettle.translation.model.Result { public *; }
-keep class co.timekettle.translation.model.Result$Builder { public *; }
-keep class co.timekettle.translation.model.TmkTranslationRoom { public *; }
-keep class co.timekettle.translation.model.TmkTranslationRoomDialogResponse { public *; }
-keep class co.timekettle.translation.model.TmkTranslationRoomDialogResponse$* { *; }
-keep class co.timekettle.translation.model.TmkTranslationRoomJoinState { *; }
-keep class co.timekettle.translation.model.TmkSpeaker { public *; }
-keep class co.timekettle.translation.model.SpeakerChannel { *; }
-keep class co.timekettle.translation.model.SpeakerGender { *; }
-keep class co.timekettle.translation.model.TmkTranslationChannelState { *; }
-keep class co.timekettle.translation.model.TmkTranslationChannelStateReason { *; }
-keep class co.timekettle.translation.model.TmkTranslationChannelStateSnapshot { public *; }
-keep class co.timekettle.translation.core.AbstractChannelEngine { public *; }

# 埋点模块 SPI：保持统一入口稳定；具体 lingcast 编排实现仍允许 R8 混淆。
-keep class co.timekettle.sdk.trackevent.TmkTrackEvent { public *; }
-keep interface co.timekettle.sdk.trackevent.TmkTrackEventClient { *; }
-keep class co.timekettle.sdk.trackevent.TmkTrackEventConfig { public *; }

# Demo 兼容 API：当前宿主 Demo 仍直接引用这些辅助类，宿主二次 R8 时也必须保持可见。
-keep class co.timekettle.translation.OnlineLanguageService { public *; }
-keep class co.timekettle.translation.model.BubbleRowData { public *; }
-keep class co.timekettle.translation.model.BaseBubbleManager { public *; }
-keep class co.timekettle.translation.model.OnlineBubbleManager { public *; }
-keep class co.timekettle.translation.model.OfflineBubbleManager { public *; }
-keep class co.timekettle.translation.utils.RingBuffer { public *; }
-keep class co.timekettle.translation.lingcast.common.enums.TransModeType { *; }

# 离线模型与离线 SDK 对外入口。
-keep class co.timekettle.offlinesdk.OfflineModelManager { public *; }
-keep class co.timekettle.translation.offlinemodel.TmkOfflineModelPackageInfo { public *; }
-keep class co.timekettle.translation.offlinemodel.TmkOfflineModelPackageState { *; }
-keep interface co.timekettle.translation.offlinemodel.TmkOfflineModelDownloadListener { *; }
-keep class co.timekettle.offlinesdk.OfflineAuthManager { public *; }
-keep class co.timekettle.offlinesdk.TmkOfflineSdk { public *; }
-keep class co.timekettle.offlinesdk.*Config { public *; }
-keep class co.timekettle.offlinesdk.*Result { public *; }
-keep interface co.timekettle.offlinesdk.*Callback { *; }
-keep class co.timekettle.offlinesdk.ErrorCodes { *; }
-keep class co.timekettle.offlinesdk.ModelPaths { public *; }
-keep class co.timekettle.offlinesdk.vad.VadDetector { public *; }
-keep class co.timekettle.offlinesdk.vad.VadDetector$* { *; }
-keep class co.timekettle.offlinesdk.diagnosis.SdkDiagnosisManager { public *; }

# 内嵌离线 native SDK 使用静态 native 方法桥接，宿主二次 R8 时必须保持类名和 native 方法签名。
-keep class co.timekettle.offline.TmkOfflineSdk { *; }
-keep class co.timekettle.offline.TmkOfflineSdk$* { *; }

# 网络协议模型通过 @SerializedName 固定 JSON key；宿主混淆时允许改名。
# 包名规则兼容源码/AAR 未预混淆场景；通用注解字段规则兼容预混淆后的 o.* 类。
-keep,allowobfuscation class co.timekettle.translation.auth.**
-keep,allowobfuscation class co.timekettle.translation.auth.network.**
-keep,allowobfuscation class co.timekettle.translation.lingcast.net.model.**
-keep,allowobfuscation class co.timekettle.translation.lingcast.common.models.**
-keep,allowobfuscation class co.timekettle.translation.OnlineLanguageService$*

-keepclassmembers,allowobfuscation class * {
    @com.google.gson.annotations.SerializedName <fields>;
}
-keep interface co.timekettle.translation.lingcast.net.api.ApiService { *; }

# JNI 桥接规则：静态 JNI 名称和 native 句柄字段必须保持。
-keep class co.timekettle.speech.jni.AudioVadJni { *; }
-keepclasseswithmembernames class * {
    native <methods>;
}

-keep class * extends android.os.Parcelable { public static final android.os.Parcelable$Creator *; }
-keep class com.google.gson.reflect.TypeToken { *; }
-keep,allowobfuscation class * extends com.google.gson.reflect.TypeToken { *; }

# Consumer rules for app projects that depend on this AAR.
# JNI registration and platform callbacks use exact JVM names, but these
# implementation details must not become public SDK API.
-keep class co.timekettle.offline.LicensePlatformBridge { *; }
-keepclasseswithmembers class co.timekettle.offline.NativeBridge {
    native <methods>;
}

