package ca.canadapost.core.common.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import h7.i;
import h7.j;
import h7.n;
import kotlin.Metadata;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;
import w8.d0;

@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0005\b\u0007\u0018\u00002\u00020\u0001B1\b\u0007\u0012\u0006\u0010\u0012\u001a\u00020\u0011\u0012\n\b\u0002\u0010\u0014\u001a\u0004\u0018\u00010\u0013\u0012\b\b\u0002\u0010\u0016\u001a\u00020\u0015\u0012\b\b\u0002\u0010\u0017\u001a\u00020\u0015¢\u0006\u0004\b\u0018\u0010\u0019J\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0002J\b\u0010\u0006\u001a\u00020\u0004H\u0014R(\u0010\r\u001a\u0004\u0018\u00010\u00072\b\u0010\b\u001a\u0004\u0018\u00010\u00078F@BX\u0086\u000e¢\u0006\f\n\u0004\b\t\u0010\n\u001a\u0004\b\u000b\u0010\fR\u0014\u0010\u0010\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000e\u0010\u000f¨\u0006\u001a"}, d2 = {"Lca/canadapost/core/common/ui/CpcDialogFragmentView;", "Landroid/widget/LinearLayout;", "Landroid/view/View;", "child", "Lrm/n0;", "a", "onFinishInflate", "Lu7/c;", "<set-?>", "p", "Lu7/c;", "getAppBarBinding", "()Lu7/c;", "appBarBinding", "q", "Landroid/view/View;", "dialogFragmentView", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "", "defStyle", "defStyleRes", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "core_common_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes.dex */
public final class CpcDialogFragmentView extends LinearLayout {

    /* renamed from: p, reason: collision with root package name and from kotlin metadata */
    private u7.c appBarBinding;

    /* renamed from: q, reason: collision with root package name and from kotlin metadata */
    private final View dialogFragmentView;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public CpcDialogFragmentView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0, 0, 12, null);
        t.g(context, "context");
    }

    private final void a(View view) {
        removeView(view);
        ((ViewGroup) findViewById(i.f21070s)).addView(view, view.getLayoutParams());
    }

    public final u7.c getAppBarBinding() {
        if (this.appBarBinding == null) {
            this.appBarBinding = u7.c.U(findViewById(i.f21040d));
        }
        return this.appBarBinding;
    }

    @Override // android.view.View
    protected void onFinishInflate() {
        CpcToolbar cpcToolbar;
        super.onFinishInflate();
        int i10 = 0;
        while (i10 < getChildCount()) {
            View childAt = getChildAt(i10);
            if (t.b(childAt, this.dialogFragmentView)) {
                i10++;
            } else {
                t.d(childAt);
                a(childAt);
            }
        }
        u7.c appBarBinding = getAppBarBinding();
        if (appBarBinding == null || (cpcToolbar = appBarBinding.B) == null) {
            return;
        }
        d0.k(cpcToolbar);
    }

    public /* synthetic */ CpcDialogFragmentView(Context context, AttributeSet attributeSet, int i10, int i11, int i12, k kVar) {
        this(context, (i12 & 2) != 0 ? null : attributeSet, (i12 & 4) != 0 ? 0 : i10, (i12 & 8) != 0 ? 0 : i11);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public CpcDialogFragmentView(Context context, AttributeSet attributeSet, int i10, int i11) {
        super(context, attributeSet, i10, i11);
        boolean z10;
        boolean z11;
        int i12;
        t.g(context, "context");
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, n.f21289i0, 0, 0);
            t.f(obtainStyledAttributes, "obtainStyledAttributes(...)");
            z10 = obtainStyledAttributes.getBoolean(n.f21294j0, true);
            z11 = obtainStyledAttributes.getBoolean(n.f21299k0, false);
            obtainStyledAttributes.recycle();
        } else {
            z10 = true;
            z11 = false;
        }
        setOrientation(1);
        LayoutInflater from = LayoutInflater.from(context);
        if (z10) {
            i12 = j.f21095j;
        } else {
            i12 = j.f21094i;
        }
        View inflate = from.inflate(i12, (ViewGroup) this, false);
        t.f(inflate, "inflate(...)");
        this.dialogFragmentView = inflate;
        if (z11) {
            inflate.setBackgroundColor(0);
        }
        addView(inflate);
    }
}
