package com.google.maps.android.compose;

import androidx.compose.runtime.AbstractApplier;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.GroundOverlay;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.Polyline;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;

/* JADX INFO: compiled from: MapApplier.kt */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0010!\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\n\b\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u001f\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u0012\u0006\u0010\u0005\u001a\u00020\u0006\u0012\u0006\u0010\u0007\u001a\u00020\b¢\u0006\u0004\b\t\u0010\nJ\b\u0010\u0013\u001a\u00020\u0014H\u0014J\u0018\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u0002H\u0016J\u0018\u0010\u0019\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u0002H\u0016J \u0010\u001a\u001a\u00020\u00142\u0006\u0010\u001b\u001a\u00020\u00172\u0006\u0010\u001c\u001a\u00020\u00172\u0006\u0010\u001d\u001a\u00020\u0017H\u0016J\u0018\u0010\u001e\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u001d\u001a\u00020\u0017H\u0016J\r\u0010\u001f\u001a\u00020\u0014H\u0000¢\u0006\u0002\b R\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR\u0014\u0010\u0005\u001a\u00020\u0006X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\r\u0010\u000eR\u0011\u0010\u0007\u001a\u00020\b¢\u0006\b\n\u0000\u001a\u0004\b\u000f\u0010\u0010R\u0014\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00020\u0012X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006!"}, d2 = {"Lcom/google/maps/android/compose/MapApplier;", "Landroidx/compose/runtime/AbstractApplier;", "Lcom/google/maps/android/compose/MapNode;", "map", "Lcom/google/android/gms/maps/GoogleMap;", "mapView", "Lcom/google/android/gms/maps/MapView;", "mapClickListeners", "Lcom/google/maps/android/compose/MapClickListeners;", "<init>", "(Lcom/google/android/gms/maps/GoogleMap;Lcom/google/android/gms/maps/MapView;Lcom/google/maps/android/compose/MapClickListeners;)V", "getMap", "()Lcom/google/android/gms/maps/GoogleMap;", "getMapView$maps_compose_release", "()Lcom/google/android/gms/maps/MapView;", "getMapClickListeners", "()Lcom/google/maps/android/compose/MapClickListeners;", "decorations", "", "onClear", "", "insertBottomUp", "index", "", "instance", "insertTopDown", "move", "from", "to", "count", "remove", "attachClickListeners", "attachClickListeners$maps_compose_release", "maps-compose_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public final class MapApplier extends AbstractApplier<MapNode> {
    public static final int $stable = 8;
    private final List<MapNode> decorations;
    private final GoogleMap map;
    private final MapClickListeners mapClickListeners;
    private final MapView mapView;

    @Override // androidx.compose.runtime.Applier
    public void insertTopDown(int index, MapNode instance) {
        Intrinsics.checkNotNullParameter(instance, "instance");
    }

    public final GoogleMap getMap() {
        return this.map;
    }

    /* JADX INFO: renamed from: getMapView$maps_compose_release, reason: from getter */
    public final MapView getMapView() {
        return this.mapView;
    }

    public final MapClickListeners getMapClickListeners() {
        return this.mapClickListeners;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public MapApplier(GoogleMap map, MapView mapView, MapClickListeners mapClickListeners) {
        super(MapNodeRoot.INSTANCE);
        Intrinsics.checkNotNullParameter(map, "map");
        Intrinsics.checkNotNullParameter(mapView, "mapView");
        Intrinsics.checkNotNullParameter(mapClickListeners, "mapClickListeners");
        this.map = map;
        this.mapView = mapView;
        this.mapClickListeners = mapClickListeners;
        this.decorations = new ArrayList();
        attachClickListeners$maps_compose_release();
    }

    @Override // androidx.compose.runtime.AbstractApplier
    protected void onClear() {
        this.map.clear();
        Iterator<T> it = this.decorations.iterator();
        while (it.hasNext()) {
            ((MapNode) it.next()).onCleared();
        }
        this.decorations.clear();
    }

    @Override // androidx.compose.runtime.Applier
    public void insertBottomUp(int index, MapNode instance) {
        Intrinsics.checkNotNullParameter(instance, "instance");
        this.decorations.add(index, instance);
        instance.onAttached();
    }

    @Override // androidx.compose.runtime.Applier
    public void move(int from, int to, int count) {
        move(this.decorations, from, to, count);
    }

    @Override // androidx.compose.runtime.Applier
    public void remove(int index, int count) {
        for (int i = 0; i < count; i++) {
            this.decorations.get(index + i).onRemoved();
        }
        remove(this.decorations, index, count);
    }

    public final void attachClickListeners$maps_compose_release() {
        this.map.setOnCircleClickListener(new GoogleMap.OnCircleClickListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda0
            @Override // com.google.android.gms.maps.GoogleMap.OnCircleClickListener
            public final void onCircleClick(Circle circle) {
                MapApplier.attachClickListeners$lambda$5(this.f$0, circle);
            }
        });
        this.map.setOnGroundOverlayClickListener(new GoogleMap.OnGroundOverlayClickListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda1
            @Override // com.google.android.gms.maps.GoogleMap.OnGroundOverlayClickListener
            public final void onGroundOverlayClick(GroundOverlay groundOverlay) {
                MapApplier.attachClickListeners$lambda$9(this.f$0, groundOverlay);
            }
        });
        this.map.setOnPolygonClickListener(new GoogleMap.OnPolygonClickListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda2
            @Override // com.google.android.gms.maps.GoogleMap.OnPolygonClickListener
            public final void onPolygonClick(Polygon polygon) {
                MapApplier.attachClickListeners$lambda$13(this.f$0, polygon);
            }
        });
        this.map.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda3
            @Override // com.google.android.gms.maps.GoogleMap.OnPolylineClickListener
            public final void onPolylineClick(Polyline polyline) {
                MapApplier.attachClickListeners$lambda$17(this.f$0, polyline);
            }
        });
        this.map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda4
            @Override // com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
            public final boolean onMarkerClick(Marker marker) {
                return MapApplier.attachClickListeners$lambda$21(this.f$0, marker);
            }
        });
        this.map.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda5
            @Override // com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener
            public final void onInfoWindowClick(Marker marker) {
                MapApplier.attachClickListeners$lambda$25(this.f$0, marker);
            }
        });
        this.map.setOnInfoWindowCloseListener(new GoogleMap.OnInfoWindowCloseListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda6
            @Override // com.google.android.gms.maps.GoogleMap.OnInfoWindowCloseListener
            public final void onInfoWindowClose(Marker marker) {
                MapApplier.attachClickListeners$lambda$29(this.f$0, marker);
            }
        });
        this.map.setOnInfoWindowLongClickListener(new GoogleMap.OnInfoWindowLongClickListener() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda7
            @Override // com.google.android.gms.maps.GoogleMap.OnInfoWindowLongClickListener
            public final void onInfoWindowLongClick(Marker marker) {
                MapApplier.attachClickListeners$lambda$33(this.f$0, marker);
            }
        });
        this.map.setOnMarkerDragListener(new MapApplier$attachClickListeners$9(this));
        this.map.setInfoWindowAdapter(new ComposeInfoWindowAdapter(this.mapView, new Function1() { // from class: com.google.maps.android.compose.MapApplier$$ExternalSyntheticLambda8
            @Override // kotlin.jvm.functions.Function1
            public final Object invoke(Object obj) {
                return MapApplier.attachClickListeners$lambda$35(this.f$0, (Marker) obj);
            }
        }));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void attachClickListeners$lambda$5(MapApplier this$0, Circle circle) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(circle, "circle");
        for (MapNode mapNode : this$0.decorations) {
            if (mapNode instanceof CircleNode) {
                CircleNode circleNode = (CircleNode) mapNode;
                if (Intrinsics.areEqual(circleNode.getCircle(), circle)) {
                    Function1<Circle, Unit> onCircleClick = circleNode.getOnCircleClick();
                    if (onCircleClick != null ? Intrinsics.areEqual((Object) onCircleClick.invoke(circle), (Object) true) : false) {
                        return;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<Circle, Unit> onCircleClick2 = ((InputHandlerNode) mapNode).getOnCircleClick();
                if (onCircleClick2 != null ? Intrinsics.areEqual((Object) onCircleClick2.invoke(circle), (Object) true) : false) {
                    return;
                }
            } else {
                continue;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void attachClickListeners$lambda$9(MapApplier this$0, GroundOverlay groundOverlay) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(groundOverlay, "groundOverlay");
        for (MapNode mapNode : this$0.decorations) {
            if (mapNode instanceof GroundOverlayNode) {
                GroundOverlayNode groundOverlayNode = (GroundOverlayNode) mapNode;
                if (Intrinsics.areEqual(groundOverlayNode.getGroundOverlay(), groundOverlay)) {
                    Function1<GroundOverlay, Unit> onGroundOverlayClick = groundOverlayNode.getOnGroundOverlayClick();
                    if (onGroundOverlayClick != null ? Intrinsics.areEqual((Object) onGroundOverlayClick.invoke(groundOverlay), (Object) true) : false) {
                        return;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<GroundOverlay, Unit> onGroundOverlayClick2 = ((InputHandlerNode) mapNode).getOnGroundOverlayClick();
                if (onGroundOverlayClick2 != null ? Intrinsics.areEqual((Object) onGroundOverlayClick2.invoke(groundOverlay), (Object) true) : false) {
                    return;
                }
            } else {
                continue;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void attachClickListeners$lambda$13(MapApplier this$0, Polygon polygon) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(polygon, "polygon");
        for (MapNode mapNode : this$0.decorations) {
            if (mapNode instanceof PolygonNode) {
                PolygonNode polygonNode = (PolygonNode) mapNode;
                if (Intrinsics.areEqual(polygonNode.getPolygon(), polygon)) {
                    Function1<Polygon, Unit> onPolygonClick = polygonNode.getOnPolygonClick();
                    if (onPolygonClick != null ? Intrinsics.areEqual((Object) onPolygonClick.invoke(polygon), (Object) true) : false) {
                        return;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<Polygon, Unit> onPolygonClick2 = ((InputHandlerNode) mapNode).getOnPolygonClick();
                if (onPolygonClick2 != null ? Intrinsics.areEqual((Object) onPolygonClick2.invoke(polygon), (Object) true) : false) {
                    return;
                }
            } else {
                continue;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void attachClickListeners$lambda$17(MapApplier this$0, Polyline polyline) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(polyline, "polyline");
        for (MapNode mapNode : this$0.decorations) {
            if (mapNode instanceof PolylineNode) {
                PolylineNode polylineNode = (PolylineNode) mapNode;
                if (Intrinsics.areEqual(polylineNode.getPolyline(), polyline)) {
                    Function1<Polyline, Unit> onPolylineClick = polylineNode.getOnPolylineClick();
                    if (onPolylineClick != null ? Intrinsics.areEqual((Object) onPolylineClick.invoke(polyline), (Object) true) : false) {
                        return;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<Polyline, Unit> onPolylineClick2 = ((InputHandlerNode) mapNode).getOnPolylineClick();
                if (onPolylineClick2 != null ? Intrinsics.areEqual((Object) onPolylineClick2.invoke(polyline), (Object) true) : false) {
                    return;
                }
            } else {
                continue;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final boolean attachClickListeners$lambda$21(MapApplier this$0, Marker marker) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(marker, "marker");
        Iterator<T> it = this$0.decorations.iterator();
        while (true) {
            if (!it.hasNext()) {
                return false;
            }
            MapNode mapNode = (MapNode) it.next();
            if (mapNode instanceof MarkerNode) {
                MarkerNode markerNode = (MarkerNode) mapNode;
                if (Intrinsics.areEqual(markerNode.getMarker(), marker)) {
                    Function1<Marker, Boolean> onMarkerClick = markerNode.getOnMarkerClick();
                    if (onMarkerClick != null ? Intrinsics.areEqual((Object) onMarkerClick.invoke(marker), (Object) true) : false) {
                        break;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<Marker, Boolean> onMarkerClick2 = ((InputHandlerNode) mapNode).getOnMarkerClick();
                if (onMarkerClick2 != null ? Intrinsics.areEqual((Object) onMarkerClick2.invoke(marker), (Object) true) : false) {
                    break;
                }
            } else {
                continue;
            }
        }
        return true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void attachClickListeners$lambda$25(MapApplier this$0, Marker marker) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(marker, "marker");
        for (MapNode mapNode : this$0.decorations) {
            if (mapNode instanceof MarkerNode) {
                MarkerNode markerNode = (MarkerNode) mapNode;
                if (Intrinsics.areEqual(markerNode.getMarker(), marker)) {
                    Function1<Marker, Unit> onInfoWindowClick = markerNode.getOnInfoWindowClick();
                    if (onInfoWindowClick != null ? Intrinsics.areEqual((Object) onInfoWindowClick.invoke(marker), (Object) true) : false) {
                        return;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<Marker, Unit> onInfoWindowClick2 = ((InputHandlerNode) mapNode).getOnInfoWindowClick();
                if (onInfoWindowClick2 != null ? Intrinsics.areEqual((Object) onInfoWindowClick2.invoke(marker), (Object) true) : false) {
                    return;
                }
            } else {
                continue;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void attachClickListeners$lambda$29(MapApplier this$0, Marker marker) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(marker, "marker");
        for (MapNode mapNode : this$0.decorations) {
            if (mapNode instanceof MarkerNode) {
                MarkerNode markerNode = (MarkerNode) mapNode;
                if (Intrinsics.areEqual(markerNode.getMarker(), marker)) {
                    Function1<Marker, Unit> onInfoWindowClose = markerNode.getOnInfoWindowClose();
                    if (onInfoWindowClose != null ? Intrinsics.areEqual((Object) onInfoWindowClose.invoke(marker), (Object) true) : false) {
                        return;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<Marker, Unit> onInfoWindowClose2 = ((InputHandlerNode) mapNode).getOnInfoWindowClose();
                if (onInfoWindowClose2 != null ? Intrinsics.areEqual((Object) onInfoWindowClose2.invoke(marker), (Object) true) : false) {
                    return;
                }
            } else {
                continue;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void attachClickListeners$lambda$33(MapApplier this$0, Marker marker) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(marker, "marker");
        for (MapNode mapNode : this$0.decorations) {
            if (mapNode instanceof MarkerNode) {
                MarkerNode markerNode = (MarkerNode) mapNode;
                if (Intrinsics.areEqual(markerNode.getMarker(), marker)) {
                    Function1<Marker, Unit> onInfoWindowLongClick = markerNode.getOnInfoWindowLongClick();
                    if (onInfoWindowLongClick != null ? Intrinsics.areEqual((Object) onInfoWindowLongClick.invoke(marker), (Object) true) : false) {
                        return;
                    }
                }
            }
            if (mapNode instanceof InputHandlerNode) {
                Function1<Marker, Unit> onInfoWindowLongClick2 = ((InputHandlerNode) mapNode).getOnInfoWindowLongClick();
                if (onInfoWindowLongClick2 != null ? Intrinsics.areEqual((Object) onInfoWindowLongClick2.invoke(marker), (Object) true) : false) {
                    return;
                }
            } else {
                continue;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final MarkerNode attachClickListeners$lambda$35(MapApplier this$0, Marker marker) {
        Object next;
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(marker, "marker");
        Iterator<T> it = this$0.decorations.iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            }
            next = it.next();
            MapNode mapNode = (MapNode) next;
            if ((mapNode instanceof MarkerNode) && Intrinsics.areEqual(((MarkerNode) mapNode).getMarker(), marker)) {
                break;
            }
        }
        return (MarkerNode) next;
    }
}