package com.revenuecat.purchases.ui.revenuecatui.components.stack;

import B.AbstractC0057e;
import B.E;
import B.U0;
import J4.f;
import J4.h;
import androidx.compose.runtime.Composable;
import androidx.compose.runtime.ComposableInferredTarget;
import androidx.compose.runtime.ComposableTarget;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.internal.ComposableLambdaKt;
import com.revenuecat.purchases.paywalls.components.properties.FlexDistribution;
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint;
import com.revenuecat.purchases.ui.revenuecatui.components.style.ComponentStyle;
import i0.C2252p;
import java.util.Iterator;
import java.util.List;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import w4.C3137A;
import x4.AbstractC3252r;

/* JADX INFO: loaded from: classes3.dex */
final class VerticalStackScopeImpl implements VerticalStackScope {
    private f columnContent;
    private final FlexDistribution distribution;
    private final f fillSpaceSpacer;
    private boolean hasAnyItemsWithFillHeight;
    private final SizeConstraint height;
    private final float spacing;

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.stack.VerticalStackScopeImpl$items$2, reason: invalid class name */
    public static final class AnonymousClass2 extends p implements f {
        final /* synthetic */ h $itemContent;
        final /* synthetic */ List<ComponentStyle> $items;
        final /* synthetic */ VerticalStackScopeImpl this$0;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        /* JADX WARN: Multi-variable type inference failed */
        public AnonymousClass2(List<? extends ComponentStyle> list, h hVar, VerticalStackScopeImpl verticalStackScopeImpl) {
            super(3);
            this.$items = list;
            this.$itemContent = hVar;
            this.this$0 = verticalStackScopeImpl;
        }

        @Override // J4.f
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2, Object obj3) {
            invoke((E) obj, (Composer) obj2, ((Number) obj3).intValue());
            return C3137A.f25453a;
        }

        @ComposableTarget(applier = "androidx.compose.ui.UiComposable")
        @Composable
        public final void invoke(E e6, Composer composer, int i6) {
            o.h(e6, "$this$null");
            int i7 = (i6 & 6) == 0 ? i6 | (composer.changed(e6) ? 4 : 2) : i6;
            if ((i7 & 19) == 18 && composer.getSkipping()) {
                composer.skipToGroupEnd();
                return;
            }
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventStart(552023703, i7, -1, "com.revenuecat.purchases.ui.revenuecatui.components.stack.VerticalStackScopeImpl.items.<anonymous> (VerticalStack.kt:96)");
            }
            List<ComponentStyle> list = this.$items;
            h hVar = this.$itemContent;
            VerticalStackScopeImpl verticalStackScopeImpl = this.this$0;
            int i8 = 0;
            for (Object obj : list) {
                int i9 = i8 + 1;
                if (i8 < 0) {
                    AbstractC3252r.F();
                    throw null;
                }
                ComponentStyle componentStyle = (ComponentStyle) obj;
                boolean z6 = i8 == list.size() - 1;
                hVar.invoke(e6, Integer.valueOf(i8), componentStyle, composer, Integer.valueOf(i7 & 14));
                composer.startReplaceGroup(-1867284347);
                if (StackComponentViewKt.getUsesAllAvailableSpace(verticalStackScopeImpl.distribution) && !z6) {
                    AbstractC0057e.g(U0.j(C2252p.f18820a, verticalStackScopeImpl.spacing, 0.0f, 2), composer, 0);
                    if (verticalStackScopeImpl.getShouldApplyFillSpacers()) {
                        verticalStackScopeImpl.fillSpaceSpacer.invoke(Float.valueOf(verticalStackScopeImpl.distribution == FlexDistribution.SPACE_AROUND ? 2.0f : 1.0f), composer, 0);
                    }
                }
                composer.endReplaceGroup();
                i8 = i9;
            }
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventEnd();
            }
        }
    }

    public /* synthetic */ VerticalStackScopeImpl(FlexDistribution flexDistribution, float f6, f fVar, SizeConstraint sizeConstraint, kotlin.jvm.internal.h hVar) {
        this(flexDistribution, f6, fVar, sizeConstraint);
    }

    public final f getColumnContent() {
        return this.columnContent;
    }

    public final boolean getShouldApplyFillSpacers() {
        return (o.c(this.height, SizeConstraint.Fit.INSTANCE) || this.hasAnyItemsWithFillHeight) ? false : true;
    }

    @Override // com.revenuecat.purchases.ui.revenuecatui.components.stack.VerticalStackScope
    @ComposableInferredTarget(scheme = "[_[androidx.compose.ui.UiComposable]]")
    public void items(List<? extends ComponentStyle> items, h itemContent) {
        o.h(items, "items");
        o.h(itemContent, "itemContent");
        boolean z6 = false;
        if (!items.isEmpty()) {
            Iterator<T> it = items.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                } else if (o.c(((ComponentStyle) it.next()).getSize().getHeight(), SizeConstraint.Fill.INSTANCE)) {
                    z6 = true;
                    break;
                }
            }
        }
        this.hasAnyItemsWithFillHeight = z6;
        this.columnContent = ComposableLambdaKt.composableLambdaInstance(552023703, true, new AnonymousClass2(items, itemContent, this));
    }

    public final void setColumnContent(f fVar) {
        o.h(fVar, "<set-?>");
        this.columnContent = fVar;
    }

    private VerticalStackScopeImpl(FlexDistribution distribution, float f6, f fillSpaceSpacer, SizeConstraint height) {
        o.h(distribution, "distribution");
        o.h(fillSpaceSpacer, "fillSpaceSpacer");
        o.h(height, "height");
        this.distribution = distribution;
        this.spacing = f6;
        this.fillSpaceSpacer = fillSpaceSpacer;
        this.height = height;
        this.columnContent = ComposableSingletons$VerticalStackKt.INSTANCE.m764getLambda1$revenuecatui_defaultsBc8Release();
    }
}
