package XnFJ5_9;

import androidx.recyclerview.widget.RecyclerView;
import com.wang.avi.BuildConfig;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import okhttp3.internal.publicsuffix.PublicSuffixDatabase;
/* compiled from: Cookie.java */
/* loaded from: classes.dex */
public final class JZJr_16 {

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final long f1649KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final String f1650KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final boolean f1651KQgRr5e_0;

    /* renamed from: Mqv2r_3  reason: collision with other field name */
    public final String f1652Mqv2r_3;

    /* renamed from: Mqv2r_3  reason: collision with other field name */
    public final boolean f1653Mqv2r_3;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public final String f1654PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public final boolean f1655PGPF6hQ_2;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final String f1656QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final boolean f1657QxJ9d_1;
    public static final Pattern KQgRr5e_0 = Pattern.compile("(\\d{2,4})[^\\d]*");
    public static final Pattern QxJ9d_1 = Pattern.compile("(?i)(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec).*");
    public static final Pattern PGPF6hQ_2 = Pattern.compile("(\\d{1,2})[^\\d]*");

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public static final Pattern f3402Mqv2r_3 = Pattern.compile("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})[^\\d]*");

    public JZJr_16(String str, String str2, long j, String str3, String str4, boolean z, boolean z2, boolean z3, boolean z4) {
        this.f1650KQgRr5e_0 = str;
        this.f1656QxJ9d_1 = str2;
        this.f1649KQgRr5e_0 = j;
        this.f1654PGPF6hQ_2 = str3;
        this.f1652Mqv2r_3 = str4;
        this.f1651KQgRr5e_0 = z;
        this.f1657QxJ9d_1 = z2;
        this.f1653Mqv2r_3 = z3;
        this.f1655PGPF6hQ_2 = z4;
    }

    public String KQgRr5e_0() {
        return this.f1650KQgRr5e_0;
    }

    public String QxJ9d_1() {
        return this.f1656QxJ9d_1;
    }

    public boolean equals(@Nullable Object obj) {
        if (obj instanceof JZJr_16) {
            JZJr_16 jZJr_16 = (JZJr_16) obj;
            return jZJr_16.f1650KQgRr5e_0.equals(this.f1650KQgRr5e_0) && jZJr_16.f1656QxJ9d_1.equals(this.f1656QxJ9d_1) && jZJr_16.f1654PGPF6hQ_2.equals(this.f1654PGPF6hQ_2) && jZJr_16.f1652Mqv2r_3.equals(this.f1652Mqv2r_3) && jZJr_16.f1649KQgRr5e_0 == this.f1649KQgRr5e_0 && jZJr_16.f1651KQgRr5e_0 == this.f1651KQgRr5e_0 && jZJr_16.f1657QxJ9d_1 == this.f1657QxJ9d_1 && jZJr_16.f1655PGPF6hQ_2 == this.f1655PGPF6hQ_2 && jZJr_16.f1653Mqv2r_3 == this.f1653Mqv2r_3;
        }
        return false;
    }

    public int hashCode() {
        long j = this.f1649KQgRr5e_0;
        return ((((((((((((((((527 + this.f1650KQgRr5e_0.hashCode()) * 31) + this.f1656QxJ9d_1.hashCode()) * 31) + this.f1654PGPF6hQ_2.hashCode()) * 31) + this.f1652Mqv2r_3.hashCode()) * 31) + ((int) (j ^ (j >>> 32)))) * 31) + (!this.f1651KQgRr5e_0 ? 1 : 0)) * 31) + (!this.f1657QxJ9d_1 ? 1 : 0)) * 31) + (!this.f1655PGPF6hQ_2 ? 1 : 0)) * 31) + (!this.f1653Mqv2r_3 ? 1 : 0);
    }

    public String toString() {
        return KQgRr5e_0(false);
    }

    public static boolean KQgRr5e_0(String str, String str2) {
        if (str.equals(str2)) {
            return true;
        }
        return str.endsWith(str2) && str.charAt((str.length() - str2.length()) - 1) == '.' && !XnFJ5_9.Ft6VRog_36.X6FRs_4.QxJ9d_1(str);
    }

    @Nullable
    public static JZJr_16 KQgRr5e_0(G83uNX_24 g83uNX_24, String str) {
        return KQgRr5e_0(System.currentTimeMillis(), g83uNX_24, str);
    }

    /* JADX WARN: Removed duplicated region for block: B:58:0x00ed  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x00f0  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x0128  */
    @Nullable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static JZJr_16 KQgRr5e_0(long j, G83uNX_24 g83uNX_24, String str) {
        long j2;
        String IFxWkV_52;
        JZJr_16 jZJr_16;
        String str2;
        String substring;
        int length = str.length();
        char c = ';';
        int KQgRr5e_02 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, 0, length, ';');
        char c2 = '=';
        int KQgRr5e_03 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, 0, KQgRr5e_02, '=');
        if (KQgRr5e_03 == KQgRr5e_02) {
            return null;
        }
        String m729KQgRr5e_0 = XnFJ5_9.Ft6VRog_36.X6FRs_4.m729KQgRr5e_0(str, 0, KQgRr5e_03);
        if (m729KQgRr5e_0.isEmpty() || XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(m729KQgRr5e_0) != -1) {
            return null;
        }
        String m729KQgRr5e_02 = XnFJ5_9.Ft6VRog_36.X6FRs_4.m729KQgRr5e_0(str, KQgRr5e_03 + 1, KQgRr5e_02);
        if (XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(m729KQgRr5e_02) != -1) {
            return null;
        }
        int i = KQgRr5e_02 + 1;
        String str3 = null;
        String str4 = null;
        long j3 = -1;
        long j4 = 253402300799999L;
        boolean z = false;
        boolean z2 = false;
        boolean z3 = true;
        boolean z4 = false;
        while (i < length) {
            int KQgRr5e_04 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, i, length, c);
            int KQgRr5e_05 = XnFJ5_9.Ft6VRog_36.X6FRs_4.KQgRr5e_0(str, i, KQgRr5e_04, c2);
            String m729KQgRr5e_03 = XnFJ5_9.Ft6VRog_36.X6FRs_4.m729KQgRr5e_0(str, i, KQgRr5e_05);
            String m729KQgRr5e_04 = KQgRr5e_05 < KQgRr5e_04 ? XnFJ5_9.Ft6VRog_36.X6FRs_4.m729KQgRr5e_0(str, KQgRr5e_05 + 1, KQgRr5e_04) : BuildConfig.FLAVOR;
            if (m729KQgRr5e_03.equalsIgnoreCase("expires")) {
                try {
                    j4 = KQgRr5e_0(m729KQgRr5e_04, 0, m729KQgRr5e_04.length());
                } catch (NumberFormatException | IllegalArgumentException unused) {
                }
            } else if (m729KQgRr5e_03.equalsIgnoreCase("max-age")) {
                j3 = KQgRr5e_0(m729KQgRr5e_04);
            } else {
                if (m729KQgRr5e_03.equalsIgnoreCase("domain")) {
                    str4 = m762KQgRr5e_0(m729KQgRr5e_04);
                    z3 = false;
                } else if (m729KQgRr5e_03.equalsIgnoreCase("path")) {
                    str3 = m729KQgRr5e_04;
                } else if (m729KQgRr5e_03.equalsIgnoreCase("secure")) {
                    z = true;
                } else if (m729KQgRr5e_03.equalsIgnoreCase("httponly")) {
                    z2 = true;
                }
                i = KQgRr5e_04 + 1;
                c = ';';
                c2 = '=';
            }
            z4 = true;
            i = KQgRr5e_04 + 1;
            c = ';';
            c2 = '=';
        }
        long j5 = Long.MIN_VALUE;
        if (j3 != Long.MIN_VALUE) {
            if (j3 != -1) {
                j5 = j + (j3 <= 9223372036854775L ? j3 * 1000 : RecyclerView.FOREVER_NS);
                if (j5 < j || j5 > 253402300799999L) {
                    j2 = 253402300799999L;
                }
            } else {
                j2 = j4;
            }
            IFxWkV_52 = g83uNX_24.IFxWkV_5();
            if (str4 != null) {
                str2 = IFxWkV_52;
                jZJr_16 = null;
            } else if (!KQgRr5e_0(IFxWkV_52, str4)) {
                return null;
            } else {
                jZJr_16 = null;
                str2 = str4;
            }
            if (IFxWkV_52.length() == str2.length() && PublicSuffixDatabase.KQgRr5e_0().KQgRr5e_0(str2) == null) {
                return jZJr_16;
            }
            if (str3 == null && str3.startsWith("/")) {
                substring = str3;
            } else {
                String PGPF6hQ_22 = g83uNX_24.PGPF6hQ_2();
                int lastIndexOf = PGPF6hQ_22.lastIndexOf(47);
                substring = lastIndexOf != 0 ? PGPF6hQ_22.substring(0, lastIndexOf) : "/";
            }
            return new JZJr_16(m729KQgRr5e_0, m729KQgRr5e_02, j2, str2, substring, z, z2, z3, z4);
        }
        j2 = j5;
        IFxWkV_52 = g83uNX_24.IFxWkV_5();
        if (str4 != null) {
        }
        if (IFxWkV_52.length() == str2.length()) {
        }
        if (str3 == null) {
        }
        String PGPF6hQ_222 = g83uNX_24.PGPF6hQ_2();
        int lastIndexOf2 = PGPF6hQ_222.lastIndexOf(47);
        substring = lastIndexOf2 != 0 ? PGPF6hQ_222.substring(0, lastIndexOf2) : "/";
        return new JZJr_16(m729KQgRr5e_0, m729KQgRr5e_02, j2, str2, substring, z, z2, z3, z4);
    }

    public static long KQgRr5e_0(String str, int i, int i2) {
        int KQgRr5e_02 = KQgRr5e_0(str, i, i2, false);
        Matcher matcher = f3402Mqv2r_3.matcher(str);
        int i3 = -1;
        int i4 = -1;
        int i5 = -1;
        int i6 = -1;
        int i7 = -1;
        int i8 = -1;
        while (KQgRr5e_02 < i2) {
            int KQgRr5e_03 = KQgRr5e_0(str, KQgRr5e_02 + 1, i2, true);
            matcher.region(KQgRr5e_02, KQgRr5e_03);
            if (i4 == -1 && matcher.usePattern(f3402Mqv2r_3).matches()) {
                i4 = Integer.parseInt(matcher.group(1));
                i7 = Integer.parseInt(matcher.group(2));
                i8 = Integer.parseInt(matcher.group(3));
            } else if (i5 == -1 && matcher.usePattern(PGPF6hQ_2).matches()) {
                i5 = Integer.parseInt(matcher.group(1));
            } else if (i6 == -1 && matcher.usePattern(QxJ9d_1).matches()) {
                i6 = QxJ9d_1.pattern().indexOf(matcher.group(1).toLowerCase(Locale.US)) / 4;
            } else if (i3 == -1 && matcher.usePattern(KQgRr5e_0).matches()) {
                i3 = Integer.parseInt(matcher.group(1));
            }
            KQgRr5e_02 = KQgRr5e_0(str, KQgRr5e_03 + 1, i2, false);
        }
        if (i3 >= 70 && i3 <= 99) {
            i3 += 1900;
        }
        if (i3 >= 0 && i3 <= 69) {
            i3 += RecyclerView.MAX_SCROLL_DURATION;
        }
        if (i3 >= 1601) {
            if (i6 != -1) {
                if (i5 < 1 || i5 > 31) {
                    throw new IllegalArgumentException();
                }
                if (i4 < 0 || i4 > 23) {
                    throw new IllegalArgumentException();
                }
                if (i7 < 0 || i7 > 59) {
                    throw new IllegalArgumentException();
                }
                if (i8 >= 0 && i8 <= 59) {
                    GregorianCalendar gregorianCalendar = new GregorianCalendar(XnFJ5_9.Ft6VRog_36.X6FRs_4.f1615KQgRr5e_0);
                    gregorianCalendar.setLenient(false);
                    gregorianCalendar.set(1, i3);
                    gregorianCalendar.set(2, i6 - 1);
                    gregorianCalendar.set(5, i5);
                    gregorianCalendar.set(11, i4);
                    gregorianCalendar.set(12, i7);
                    gregorianCalendar.set(13, i8);
                    gregorianCalendar.set(14, 0);
                    return gregorianCalendar.getTimeInMillis();
                }
                throw new IllegalArgumentException();
            }
            throw new IllegalArgumentException();
        }
        throw new IllegalArgumentException();
    }

    public static int KQgRr5e_0(String str, int i, int i2, boolean z) {
        while (i < i2) {
            char charAt = str.charAt(i);
            if (((charAt < ' ' && charAt != '\t') || charAt >= 127 || (charAt >= '0' && charAt <= '9') || ((charAt >= 'a' && charAt <= 'z') || ((charAt >= 'A' && charAt <= 'Z') || charAt == ':'))) == (!z)) {
                return i;
            }
            i++;
        }
        return i2;
    }

    public static long KQgRr5e_0(String str) {
        try {
            long parseLong = Long.parseLong(str);
            if (parseLong <= 0) {
                return Long.MIN_VALUE;
            }
            return parseLong;
        } catch (NumberFormatException e) {
            if (str.matches("-?\\d+")) {
                if (str.startsWith("-")) {
                    return Long.MIN_VALUE;
                }
                return RecyclerView.FOREVER_NS;
            }
            throw e;
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static String m762KQgRr5e_0(String str) {
        if (!str.endsWith(".")) {
            if (str.startsWith(".")) {
                str = str.substring(1);
            }
            String m728KQgRr5e_0 = XnFJ5_9.Ft6VRog_36.X6FRs_4.m728KQgRr5e_0(str);
            if (m728KQgRr5e_0 != null) {
                return m728KQgRr5e_0;
            }
            throw new IllegalArgumentException();
        }
        throw new IllegalArgumentException();
    }

    public static List<JZJr_16> KQgRr5e_0(G83uNX_24 g83uNX_24, SI64pbG_23 sI64pbG_23) {
        List<String> m770KQgRr5e_0 = sI64pbG_23.m770KQgRr5e_0("Set-Cookie");
        int size = m770KQgRr5e_0.size();
        ArrayList arrayList = null;
        for (int i = 0; i < size; i++) {
            JZJr_16 KQgRr5e_02 = KQgRr5e_0(g83uNX_24, m770KQgRr5e_0.get(i));
            if (KQgRr5e_02 != null) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                arrayList.add(KQgRr5e_02);
            }
        }
        if (arrayList != null) {
            return Collections.unmodifiableList(arrayList);
        }
        return Collections.emptyList();
    }

    public String KQgRr5e_0(boolean z) {
        StringBuilder sb = new StringBuilder();
        sb.append(this.f1650KQgRr5e_0);
        sb.append('=');
        sb.append(this.f1656QxJ9d_1);
        if (this.f1655PGPF6hQ_2) {
            if (this.f1649KQgRr5e_0 == Long.MIN_VALUE) {
                sb.append("; max-age=0");
            } else {
                sb.append("; expires=");
                sb.append(XnFJ5_9.Ft6VRog_36.Xgtqvk_8.Mqv2r_3.KQgRr5e_0(new Date(this.f1649KQgRr5e_0)));
            }
        }
        if (!this.f1653Mqv2r_3) {
            sb.append("; domain=");
            if (z) {
                sb.append(".");
            }
            sb.append(this.f1654PGPF6hQ_2);
        }
        sb.append("; path=");
        sb.append(this.f1652Mqv2r_3);
        if (this.f1651KQgRr5e_0) {
            sb.append("; secure");
        }
        if (this.f1657QxJ9d_1) {
            sb.append("; httponly");
        }
        return sb.toString();
    }
}
