package com.google.android.material.navigation;

import android.content.Context;
import android.view.SubMenu;

/* JADX INFO: loaded from: classes2.dex */
public final class f extends k.p {
    public final Class A;
    public final int B;
    public final boolean C;

    public f(Context context, Class cls, int i10, boolean z10) {
        super(context);
        this.A = cls;
        this.B = i10;
        this.C = z10;
    }

    @Override // k.p
    public final k.r a(int i10, int i11, int i12, CharSequence charSequence) {
        int size = this.f28885f.size() + 1;
        int i13 = this.B;
        if (size <= i13) {
            y();
            k.r rVarA = super.a(i10, i11, i12, charSequence);
            x();
            return rVarA;
        }
        String simpleName = this.A.getSimpleName();
        StringBuilder sb = new StringBuilder("Maximum number of items supported by ");
        sb.append(simpleName);
        sb.append(" is ");
        sb.append(i13);
        sb.append(". Limit can be checked with ");
        throw new IllegalArgumentException(defpackage.e.o(sb, simpleName, "#getMaxItemCount()"));
    }

    @Override // k.p, android.view.Menu
    public final SubMenu addSubMenu(int i10, int i11, int i12, CharSequence charSequence) {
        if (!this.C) {
            throw new UnsupportedOperationException(this.A.getSimpleName().concat(" does not support submenus"));
        }
        k.r rVarA = a(i10, i11, i12, charSequence);
        k kVar = new k(this.f28880a, this, rVarA);
        rVarA.f28922o = kVar;
        kVar.setHeaderTitle(rVarA.f28912e);
        return kVar;
    }
}
