package n6;

import N1.p0;
import P6.g;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import com.rubensousa.dpadrecyclerview.DpadRecyclerView;
import e6.C0889a;

/* JADX INFO: loaded from: classes.dex */
public final class a extends c {

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final int f15525c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final int f15526d;

    public a(int i, int i5, int i8, int i9) {
        this.f15523a = i;
        this.f15524b = i5;
        this.f15525c = i8;
        this.f15526d = i9;
    }

    public static a e(a aVar, int i, int i5, int i8, int i9, int i10) {
        if ((i10 & 1) != 0) {
            i = aVar.f15523a;
        }
        if ((i10 & 2) != 0) {
            i5 = aVar.f15524b;
        }
        if ((i10 & 4) != 0) {
            i8 = aVar.f15525c;
        }
        if ((i10 & 8) != 0) {
            i9 = aVar.f15526d;
        }
        aVar.getClass();
        return new a(i, i5, i8, i9);
    }

    @Override // n6.c
    public final void d(Rect rect, View view, int i, DpadRecyclerView dpadRecyclerView, p0 p0Var) {
        g.e(rect, "outRect");
        g.e(view, "view");
        g.e(dpadRecyclerView, "parent");
        g.e(p0Var, "state");
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        g.c(layoutParams, "null cannot be cast to non-null type com.rubensousa.dpadrecyclerview.layoutmanager.DpadLayoutParams");
        C0889a c0889a = (C0889a) layoutParams;
        int i5 = c0889a.f12496w;
        if (i5 == -1) {
            return;
        }
        int spanCount = dpadRecyclerView.getSpanCount();
        boolean z8 = dpadRecyclerView.z0().f11236G.f12507j;
        int iB = p0Var.b();
        int i8 = c0889a.f12495v;
        int i9 = !z8 ? i5 : (spanCount - 1) - i5;
        boolean z9 = c0889a.f12497x == 0;
        boolean z10 = ((spanCount - i5) - i8) + i >= iB - 1;
        int orientation = dpadRecyclerView.getOrientation();
        int i10 = this.f15525c;
        int i11 = this.f15524b;
        int i12 = this.f15526d;
        int i13 = this.f15523a;
        if (orientation == 1) {
            int i14 = spanCount - i9;
            int i15 = i9 + i8;
            float f3 = i13;
            float f7 = spanCount;
            rect.left = (int) ((i14 / f7) * f3);
            rect.right = (int) ((i15 / f7) * f3);
            if (z9) {
                if (z8) {
                    rect.bottom = i11;
                    rect.top = i12;
                    return;
                } else {
                    rect.top = i11;
                    rect.bottom = i12;
                    return;
                }
            }
            if (z10) {
                if (z8) {
                    rect.top = i10;
                    return;
                } else {
                    rect.bottom = i10;
                    return;
                }
            }
            if (z8) {
                rect.top = i12;
                return;
            } else {
                rect.bottom = i12;
                return;
            }
        }
        int i16 = spanCount - i9;
        int i17 = i9 + i8;
        float f8 = i13;
        float f9 = spanCount;
        rect.top = (int) ((i16 / f9) * f8);
        rect.bottom = (int) ((i17 / f9) * f8);
        if (z9) {
            if (z8) {
                rect.right = i11;
                rect.left = i12;
                return;
            } else {
                rect.left = i11;
                rect.right = i12;
                return;
            }
        }
        if (z10) {
            if (z8) {
                rect.left = i10;
                return;
            } else {
                rect.right = i10;
                return;
            }
        }
        if (z8) {
            rect.left = i12;
        } else {
            rect.right = i12;
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof a)) {
            return false;
        }
        a aVar = (a) obj;
        return this.f15523a == aVar.f15523a && this.f15524b == aVar.f15524b && this.f15525c == aVar.f15525c && this.f15526d == aVar.f15526d;
    }

    public final int hashCode() {
        return (((((this.f15523a * 31) + this.f15524b) * 31) + this.f15525c) * 31) + this.f15526d;
    }

    public final String toString() {
        return "DpadGridSpacingDecoration(itemSpacing=" + this.f15523a + ", minEdgeSpacing=" + this.f15524b + ", maxEdgeSpacing=" + this.f15525c + ", perpendicularItemSpacing=" + this.f15526d + ")";
    }
}
