package e9;

import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.r1;
import com.google.android.material.carousel.CarouselLayoutManager;

/* JADX INFO: loaded from: classes2.dex */
public final class g extends q1.f {

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ CarouselLayoutManager f25591d;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ g(int i10, CarouselLayoutManager carouselLayoutManager, int i11) {
        super(i10, (Object) null);
        this.f25590c = i11;
        this.f25591d = carouselLayoutManager;
    }

    public final void h(RectF rectF, RectF rectF2, RectF rectF3) {
        switch (this.f25590c) {
            case 0:
                float f10 = rectF2.top;
                float f11 = rectF3.top;
                if (f10 < f11 && rectF2.bottom > f11) {
                    float f12 = f11 - f10;
                    rectF.top += f12;
                    rectF3.top += f12;
                }
                float f13 = rectF2.bottom;
                float f14 = rectF3.bottom;
                if (f13 > f14 && rectF2.top < f14) {
                    float f15 = f13 - f14;
                    rectF.bottom = Math.max(rectF.bottom - f15, rectF.top);
                    rectF2.bottom = Math.max(rectF2.bottom - f15, rectF2.top);
                    break;
                }
                break;
            default:
                float f16 = rectF2.left;
                float f17 = rectF3.left;
                if (f16 < f17 && rectF2.right > f17) {
                    float f18 = f17 - f16;
                    rectF.left += f18;
                    rectF2.left += f18;
                }
                float f19 = rectF2.right;
                float f20 = rectF3.right;
                if (f19 > f20 && rectF2.left < f20) {
                    float f21 = f19 - f20;
                    rectF.right = Math.max(rectF.right - f21, rectF.left);
                    rectF2.right = Math.max(rectF2.right - f21, rectF2.left);
                    break;
                }
                break;
        }
    }

    public final int i(View view) {
        int i10 = this.f25590c;
        CarouselLayoutManager carouselLayoutManager = this.f25591d;
        switch (i10) {
            case 0:
                r1 r1Var = (r1) view.getLayoutParams();
                return carouselLayoutManager.getDecoratedMeasuredWidth(view) + ((ViewGroup.MarginLayoutParams) r1Var).leftMargin + ((ViewGroup.MarginLayoutParams) r1Var).rightMargin;
            default:
                r1 r1Var2 = (r1) view.getLayoutParams();
                return carouselLayoutManager.getDecoratedMeasuredHeight(view) + ((ViewGroup.MarginLayoutParams) r1Var2).topMargin + ((ViewGroup.MarginLayoutParams) r1Var2).bottomMargin;
        }
    }

    public final RectF j(float f10, float f11, float f12, float f13) {
        switch (this.f25590c) {
            case 0:
                return new RectF(0.0f, f12, f11, f10 - f12);
            default:
                return new RectF(f13, 0.0f, f11 - f13, f10);
        }
    }

    public final int k() {
        int i10 = this.f25590c;
        CarouselLayoutManager carouselLayoutManager = this.f25591d;
        switch (i10) {
            case 0:
                return carouselLayoutManager.getHeight();
            default:
                return carouselLayoutManager.getHeight() - carouselLayoutManager.getPaddingBottom();
        }
    }

    public final int l() {
        int i10 = this.f25590c;
        CarouselLayoutManager carouselLayoutManager = this.f25591d;
        switch (i10) {
            case 0:
                return carouselLayoutManager.getWidth() - carouselLayoutManager.getPaddingRight();
            default:
                return carouselLayoutManager.getWidth();
        }
    }

    public final int m() {
        CarouselLayoutManager carouselLayoutManager = this.f25591d;
        int i10 = this.f25590c;
        switch (i10) {
            case 0:
                switch (i10) {
                    case 0:
                        return 0;
                    default:
                        return carouselLayoutManager.getPaddingTop();
                }
            default:
                if (carouselLayoutManager.D()) {
                    return l();
                }
                switch (i10) {
                    case 0:
                        return carouselLayoutManager.getPaddingLeft();
                    default:
                        return 0;
                }
        }
    }

    public final void n(View view, int i10, int i11) {
        int paddingLeft = 0;
        CarouselLayoutManager carouselLayoutManager = this.f25591d;
        int i12 = this.f25590c;
        switch (i12) {
            case 0:
                switch (i12) {
                    case 0:
                        paddingLeft = carouselLayoutManager.getPaddingLeft();
                        break;
                }
                int i13 = paddingLeft;
                this.f25591d.layoutDecoratedWithMargins(view, i13, i10, i(view) + i13, i11);
                break;
            default:
                switch (i12) {
                    case 0:
                        break;
                    default:
                        paddingLeft = carouselLayoutManager.getPaddingTop();
                        break;
                }
                int i14 = paddingLeft;
                this.f25591d.layoutDecoratedWithMargins(view, i10, i14, i11, i(view) + i14);
                break;
        }
    }

    public final void o(RectF rectF, RectF rectF2, RectF rectF3) {
        switch (this.f25590c) {
            case 0:
                if (rectF2.bottom <= rectF3.top) {
                    float fFloor = ((float) Math.floor(rectF.bottom)) - 1.0f;
                    rectF.bottom = fFloor;
                    rectF.top = Math.min(rectF.top, fFloor);
                }
                if (rectF2.top >= rectF3.bottom) {
                    float fCeil = ((float) Math.ceil(rectF.top)) + 1.0f;
                    rectF.top = fCeil;
                    rectF.bottom = Math.max(fCeil, rectF.bottom);
                }
                break;
            default:
                if (rectF2.right <= rectF3.left) {
                    float fFloor2 = ((float) Math.floor(rectF.right)) - 1.0f;
                    rectF.right = fFloor2;
                    rectF.left = Math.min(rectF.left, fFloor2);
                }
                if (rectF2.left >= rectF3.right) {
                    float fCeil2 = ((float) Math.ceil(rectF.left)) + 1.0f;
                    rectF.left = fCeil2;
                    rectF.right = Math.max(fCeil2, rectF.right);
                }
                break;
        }
    }

    public final void p(float f10, float f11, Rect rect, View view) {
        switch (this.f25590c) {
            case 0:
                view.offsetTopAndBottom((int) (f11 - (rect.top + f10)));
                break;
            default:
                view.offsetLeftAndRight((int) (f11 - (rect.left + f10)));
                break;
        }
    }
}
