package androidx.compose.ui.window;

import android.content.Context;
import android.view.View;
import android.view.Window;
import kotlin.jvm.internal.v;
import rm.n0;
import y0.l2;
import y0.q1;
import y0.s3;
import y0.x2;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class h extends androidx.compose.ui.platform.a implements j {
    private boolean A;

    /* renamed from: x, reason: collision with root package name */
    private final Window f2962x;

    /* renamed from: y, reason: collision with root package name */
    private final q1 f2963y;

    /* renamed from: z, reason: collision with root package name */
    private boolean f2964z;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends v implements dn.p {

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ int f2966q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(int i10) {
            super(2);
            this.f2966q = i10;
        }

        public final void a(y0.m mVar, int i10) {
            h.this.a(mVar, l2.a(this.f2966q | 1));
        }

        @Override // dn.p
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2) {
            a((y0.m) obj, ((Number) obj2).intValue());
            return n0.f34904a;
        }
    }

    public h(Context context, Window window) {
        super(context, null, 0, 6, null);
        q1 d10;
        this.f2962x = window;
        d10 = s3.d(f.f2956a.a(), null, 2, null);
        this.f2963y = d10;
    }

    private final dn.p getContent() {
        return (dn.p) this.f2963y.getValue();
    }

    private final int getDisplayHeight() {
        return Math.round(getContext().getResources().getConfiguration().screenHeightDp * getContext().getResources().getDisplayMetrics().density);
    }

    private final int getDisplayWidth() {
        return Math.round(getContext().getResources().getConfiguration().screenWidthDp * getContext().getResources().getDisplayMetrics().density);
    }

    private final void setContent(dn.p pVar) {
        this.f2963y.setValue(pVar);
    }

    @Override // androidx.compose.ui.platform.a
    public void a(y0.m mVar, int i10) {
        int i11;
        y0.m r10 = mVar.r(1735448596);
        if ((i10 & 6) == 0) {
            i11 = (r10.m(this) ? 4 : 2) | i10;
        } else {
            i11 = i10;
        }
        if ((i11 & 3) == 2 && r10.v()) {
            r10.A();
        } else {
            if (y0.p.H()) {
                y0.p.Q(1735448596, i11, -1, "androidx.compose.ui.window.DialogLayout.Content (AndroidDialog.android.kt:280)");
            }
            getContent().invoke(r10, 0);
            if (y0.p.H()) {
                y0.p.P();
            }
        }
        x2 y10 = r10.y();
        if (y10 != null) {
            y10.a(new a(i10));
        }
    }

    @Override // androidx.compose.ui.platform.a
    public void g(boolean z10, int i10, int i11, int i12, int i13) {
        View childAt;
        super.g(z10, i10, i11, i12, i13);
        if (this.f2964z || (childAt = getChildAt(0)) == null) {
            return;
        }
        getWindow().setLayout(childAt.getMeasuredWidth(), childAt.getMeasuredHeight());
    }

    @Override // androidx.compose.ui.platform.a
    protected boolean getShouldCreateCompositionOnAttachedToWindow() {
        return this.A;
    }

    @Override // androidx.compose.ui.window.j
    public Window getWindow() {
        return this.f2962x;
    }

    @Override // androidx.compose.ui.platform.a
    public void h(int i10, int i11) {
        if (this.f2964z) {
            super.h(i10, i11);
        } else {
            super.h(View.MeasureSpec.makeMeasureSpec(getDisplayWidth(), Integer.MIN_VALUE), View.MeasureSpec.makeMeasureSpec(getDisplayHeight(), Integer.MIN_VALUE));
        }
    }

    public final boolean k() {
        return this.f2964z;
    }

    public final void l(y0.r rVar, dn.p pVar) {
        setParentCompositionContext(rVar);
        setContent(pVar);
        this.A = true;
        d();
    }

    public final void m(boolean z10) {
        this.f2964z = z10;
    }
}
