package l1;

import F1.AbstractC0195y;
import F1.F;
import F1.InterfaceC0187p;
import F1.m0;
import J0.AbstractC0342a;
import J0.C0387u0;
import android.content.Context;
import android.os.Build;
import android.view.View;
import android.view.Window;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.ScopeUpdateScope;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import java.lang.reflect.Field;
import k1.C2371a;

/* JADX INFO: loaded from: classes.dex */
public final class u extends AbstractC0342a implements InterfaceC0187p {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Window f20208a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final MutableState f20209b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f20210c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f20211d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f20212e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f20213f;

    public u(Context context, Window window) {
        super(context);
        this.f20208a = window;
        this.f20209b = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(s.f20206a, null, 2, null);
        Field field = F.f1367a;
        AbstractC0195y.c(this, this);
        F.e(this, new C2371a(this, 1));
    }

    @Override // J0.AbstractC0342a
    public final void Content(Composer composer, int i6) {
        int i7;
        Composer composerStartRestartGroup = composer.startRestartGroup(1735448596);
        if ((i6 & 6) == 0) {
            i7 = (composerStartRestartGroup.changedInstance(this) ? 4 : 2) | i6;
        } else {
            i7 = i6;
        }
        if (composerStartRestartGroup.shouldExecute((i7 & 3) != 2, i7 & 1)) {
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventStart(1735448596, i7, -1, "androidx.compose.ui.window.DialogLayout.Content (AndroidDialog.android.kt:454)");
            }
            ((J4.e) this.f20209b.getValue()).invoke(composerStartRestartGroup, 0);
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventEnd();
            }
        } else {
            composerStartRestartGroup.skipToGroupEnd();
        }
        ScopeUpdateScope scopeUpdateScopeEndRestartGroup = composerStartRestartGroup.endRestartGroup();
        if (scopeUpdateScopeEndRestartGroup != null) {
            scopeUpdateScopeEndRestartGroup.updateScope(new C0387u0(i6, 2, this));
        }
    }

    @Override // F1.InterfaceC0187p
    public final m0 a(View view, m0 m0Var) {
        if (!this.f20211d) {
            View childAt = getChildAt(0);
            int iMax = Math.max(0, childAt.getLeft());
            int iMax2 = Math.max(0, childAt.getTop());
            int iMax3 = Math.max(0, getWidth() - childAt.getRight());
            int iMax4 = Math.max(0, getHeight() - childAt.getBottom());
            if (iMax != 0 || iMax2 != 0 || iMax3 != 0 || iMax4 != 0) {
                return m0Var.f1458a.n(iMax, iMax2, iMax3, iMax4);
            }
        }
        return m0Var;
    }

    @Override // J0.AbstractC0342a
    public final boolean getShouldCreateCompositionOnAttachedToWindow() {
        return this.f20213f;
    }

    @Override // J0.AbstractC0342a
    public final void internalOnLayout$ui(boolean z6, int i6, int i7, int i8, int i9) {
        View childAt = getChildAt(0);
        if (childAt == null) {
            return;
        }
        int paddingRight = getPaddingRight() + getPaddingLeft();
        int paddingBottom = getPaddingBottom() + getPaddingTop();
        int i10 = i8 - i6;
        int i11 = i9 - i7;
        int measuredWidth = childAt.getMeasuredWidth();
        int measuredHeight = childAt.getMeasuredHeight();
        int paddingLeft = (((i10 - measuredWidth) - paddingRight) / 2) + getPaddingLeft();
        int paddingTop = (((i11 - measuredHeight) - paddingBottom) / 2) + getPaddingTop();
        childAt.layout(paddingLeft, paddingTop, measuredWidth + paddingLeft, measuredHeight + paddingTop);
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0049  */
    @Override // J0.AbstractC0342a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void internalOnMeasure$ui(int i6, int i7) {
        int iA;
        View childAt = getChildAt(0);
        if (childAt == null) {
            super.internalOnMeasure$ui(i6, i7);
            return;
        }
        int size = View.MeasureSpec.getSize(i6);
        int size2 = View.MeasureSpec.getSize(i7);
        int mode = View.MeasureSpec.getMode(i7);
        Window window = this.f20208a;
        if (mode != Integer.MIN_VALUE || this.f20210c || window.getAttributes().height != -2) {
            iA = size2;
        } else if (this.f20211d) {
            int i8 = Build.VERSION.SDK_INT;
            if (i8 < 30) {
                iA = o.f20200a.a(window);
            } else if (i8 < 32) {
                iA = q.f20202a.a(window);
            }
        } else {
            iA = size2 + 1;
        }
        int paddingRight = getPaddingRight() + getPaddingLeft();
        int paddingBottom = getPaddingBottom() + getPaddingTop();
        int i9 = size - paddingRight;
        if (i9 < 0) {
            i9 = 0;
        }
        int i10 = iA - paddingBottom;
        int i11 = i10 >= 0 ? i10 : 0;
        int mode2 = View.MeasureSpec.getMode(i6);
        if (mode2 != 0) {
            i6 = View.MeasureSpec.makeMeasureSpec(i9, Integer.MIN_VALUE);
        }
        if (mode != 0) {
            i7 = View.MeasureSpec.makeMeasureSpec(i11, Integer.MIN_VALUE);
        }
        childAt.measure(i6, i7);
        if (mode2 == Integer.MIN_VALUE) {
            size = Math.min(size, childAt.getMeasuredWidth() + paddingRight);
        } else if (mode2 != 1073741824) {
            size = childAt.getMeasuredWidth() + paddingRight;
        }
        setMeasuredDimension(size, mode != Integer.MIN_VALUE ? mode != 1073741824 ? childAt.getMeasuredHeight() + paddingBottom : size2 : Math.min(size2, childAt.getMeasuredHeight() + paddingBottom));
        if (this.f20211d || childAt.getMeasuredHeight() + paddingBottom <= size2 || window.getAttributes().height != -2) {
            return;
        }
        window.addFlags(Integer.MIN_VALUE);
        if (this.f20210c) {
            return;
        }
        window.setLayout(-1, -1);
    }
}
