# These rules are added to the customer app obfuscation
# If you do something with reflection, chance your rule should be here

# keep protobuf generated message lite
-keepnames class com.google.protobuf.GeneratedMessageLite { *;}
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
    <fields>;
}

# Keep classes implementing StartableModule interface, see ModuleStarter.kt
-keep class * implements com.contentsquare.android.core.communication.StartableModule {
    public <init>(...);
}

# Keep class names for all Views
-keepnames class * extends android.view.View

# Keep Jetpack Compose classes used in the tree view path
-keepnames class androidx.compose.foundation.lazy.layout.LazyLayoutSemanticState { *; }

# Keep Jetpack Compose classes and fields resolved by reflection
-keep class androidx.compose.foundation.lazy.LazyDslKt { *; }
-keep class androidx.compose.foundation.lazy.LazyListScope { *; }
-keep class androidx.compose.foundation.lazy.LazyListState { *; }
-keep class androidx.compose.foundation.lazy.grid.LazyGridDslKt { *; }
-keep class androidx.compose.foundation.lazy.grid.LazyGridScope { *; }
-keep class androidx.compose.foundation.lazy.grid.LazyGridState { *; }
-keep class androidx.compose.foundation.OverscrollKt { *; }
-keep class androidx.compose.foundation.OverscrollEffect { *; }

# ComposeInternals
# Note: These methods have a suffix added by Kotlin/Compose compiler based on build variant
# Common suffixes: $ui_release (release builds), $ui_debug (debug builds)
# We include both variants to ensure compatibility across different build types. We also keep the raw name
# just in case.
-keepclassmembers class androidx.compose.ui.Modifier$Node {
    int getKindSet();
    int getKindSet$ui();
    int getKindSet$ui_release();
    int getKindSet$ui_debug();
    androidx.compose.ui.Modifier$Node getChild();
    androidx.compose.ui.Modifier$Node getChild$ui();
    androidx.compose.ui.Modifier$Node getChild$ui_release();
    androidx.compose.ui.Modifier$Node getChild$ui_debug();
    androidx.compose.ui.node.NodeCoordinator getCoordinator();
    androidx.compose.ui.node.NodeCoordinator getCoordinator$ui();
    androidx.compose.ui.node.NodeCoordinator getCoordinator$ui_release();
    androidx.compose.ui.node.NodeCoordinator getCoordinator$ui_debug();
}
-keepclassmembers class androidx.compose.ui.semantics.SemanticsNode {
    androidx.compose.ui.node.LayoutNode getLayoutNode();
    androidx.compose.ui.node.LayoutNode getLayoutNode$ui();
    androidx.compose.ui.node.LayoutNode getLayoutNode$ui_release();
    androidx.compose.ui.node.LayoutNode getLayoutNode$ui_debug();
}
-keepclassmembers class androidx.compose.ui.node.DelegatingNode {
    androidx.compose.ui.Modifier$Node getDelegate();
    androidx.compose.ui.Modifier$Node getDelegate$ui();
    androidx.compose.ui.Modifier$Node getDelegate$ui_release();
    androidx.compose.ui.Modifier$Node getDelegate$ui_debug();
}
-keepclassmembers class androidx.compose.ui.node.NodeChain {
    androidx.compose.ui.Modifier$Node getHead();
    androidx.compose.ui.Modifier$Node getHead$ui();
    androidx.compose.ui.Modifier$Node getHead$ui_release();
    androidx.compose.ui.Modifier$Node getHead$ui_debug();
    void headToTail(...);
    void headToTail$ui(...);
    void headToTail$ui_release(...);
    void headToTail$ui_debug(...);
    void headToTailExclusive(...);
    void headToTailExclusive$ui(...);
    void headToTailExclusive$ui_release(...);
    void headToTailExclusive$ui_debug(...);
}
-keepclassmembers class androidx.compose.ui.node.LayoutNode {
    void draw(...);
    void draw$ui(...);
    void draw$ui_release(...);
    void draw$ui_debug(...);
    androidx.compose.ui.node.LayoutNode getParent();
    androidx.compose.ui.node.LayoutNode getParent$ui();
    androidx.compose.ui.node.LayoutNode getParent$ui_release();
    androidx.compose.ui.node.LayoutNode getParent$ui_debug();
    androidx.compose.ui.node.NodeChain getNodes();
    androidx.compose.ui.node.NodeChain getNodes$ui();
    androidx.compose.ui.node.NodeChain getNodes$ui_release();
    androidx.compose.ui.node.NodeChain getNodes$ui_debug();
    androidx.compose.ui.node.Owner getOwner();
    androidx.compose.ui.node.Owner getOwner$ui();
    androidx.compose.ui.node.Owner getOwner$ui_release();
    androidx.compose.ui.node.Owner getOwner$ui_debug();
    java.util.List getChildren();
    java.util.List getChildren$ui();
    java.util.List getChildren$ui_release();
    java.util.List getChildren$ui_debug();
}
-keepclassmembers class androidx.compose.ui.ZIndexElement {
    float zIndex;
}
-keepclassmembers class androidx.compose.ui.graphics.GraphicsLayerElement {
    float alpha;
}
-keepnames class androidx.compose.foundation.BackgroundNode { <fields>; }
-keepnames class androidx.compose.ui.graphics.SimpleGraphicsLayerModifier
-keepnames class androidx.compose.ui.graphics.BlockGraphicsLayerModifier
-keepnames class androidx.compose.foundation.layout.InsetsPaddingModifier
-keepnames class androidx.compose.ui.graphics.layer.GraphicsLayer
-keepnames class androidx.compose.material.DraggableAnchorsElement

# Keep classes, methods and fields resolved by reflection
-keepnames class com.google.android.material.appbar.AppBarLayout {
    void setExpanded(boolean, boolean);
}
-keepclassmembernames class androidx.viewpager.widget.ViewPager$LayoutParams {
    int position;
}
-keepnames class androidx.viewpager2.widget.ViewPager2 {
    int getCurrentItem();
}

# Keep API classes used by cross-platform
-keep class com.contentsquare.android.api.bridge.logmonitor.LogMonitorInterface { *; }
-keep class com.contentsquare.android.api.bridge.telemetry.TelemetryInterface { *; }
-keep class com.contentsquare.android.api.bridge.flutter.FlutterInterface { *; }
-keep class com.contentsquare.android.api.bridge.xpf.XpfInterface { *; }
-keep interface com.contentsquare.android.api.bridge.xpf.ExternalBridgeInterface { *; }
-keep class com.contentsquare.android.api.bridge.xpf.ExternalBridgeType { *; }

-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt
-keepclassmembers @kotlinx.serialization.Serializable class ** {
    *** Companion;
}
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1>$Companion {
    kotlinx.serialization.KSerializer serializer(...);
}
-keepclasseswithmembers class **$$serializer {
    *** INSTANCE;
}

# prevent deleting SessionReplayStartStopController ref as it's not used but needed
-keep class **.ContentsquareModule {
    private static <fields>;
}

#This rule is added to prevent deleting Heap method ref in case comsumer app don't call them directly
-keep class io.heap.core.Heap {
    public static java.lang.String getSessionId();
    public static java.lang.String getUserId();
    public static java.lang.String getEnvironmentId();
}

-keep class androidx.appcompat.view.menu.ListMenuItemView {
    * mItemData;
}

-keep class com.android.internal.view.menu.ListMenuItemView {
    * mItemData;
}