package j$.time;

import androidx.media3.common.C;
import j$.time.chrono.ChronoLocalDate;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.math.BigInteger;

/* JADX INFO: loaded from: classes2.dex */
public final class f implements j$.time.temporal.r, Comparable, Serializable {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final f f19189c = new f(0, 0);
    private static final long serialVersionUID = 3078945930695997490L;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final long f19190a;

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

    @Override // java.lang.Comparable
    public final int compareTo(Object obj) {
        f fVar = (f) obj;
        int iCompare = Long.compare(this.f19190a, fVar.f19190a);
        return iCompare != 0 ? iCompare : this.f19191b - fVar.f19191b;
    }

    static {
        BigInteger.valueOf(C.NANOS_PER_SECOND);
    }

    public static f J(long j4) {
        return r(j4, 0);
    }

    public static f U(long j4, long j6) {
        return r(Math.addExact(j4, Math.floorDiv(j6, C.NANOS_PER_SECOND)), (int) Math.floorMod(j6, C.NANOS_PER_SECOND));
    }

    private static f r(long j4, int i6) {
        if ((((long) i6) | j4) == 0) {
            return f19189c;
        }
        return new f(j4, i6);
    }

    private f(long j4, int i6) {
        this.f19190a = j4;
        this.f19191b = i6;
    }

    public final long B() {
        return this.f19190a;
    }

    @Override // j$.time.temporal.r
    public final j$.time.temporal.m p(ChronoLocalDate chronoLocalDate) {
        long j4 = this.f19190a;
        ChronoLocalDate chronoLocalDateB = chronoLocalDate;
        if (j4 != 0) {
            chronoLocalDateB = chronoLocalDate.b(j4, (j$.time.temporal.v) j$.time.temporal.b.SECONDS);
        }
        int i6 = this.f19191b;
        return i6 != 0 ? chronoLocalDateB.b(i6, (j$.time.temporal.v) j$.time.temporal.b.NANOS) : chronoLocalDateB;
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof f) {
            f fVar = (f) obj;
            if (this.f19190a == fVar.f19190a && this.f19191b == fVar.f19191b) {
                return true;
            }
        }
        return false;
    }

    public final int hashCode() {
        long j4 = this.f19190a;
        return (this.f19191b * 51) + ((int) (j4 ^ (j4 >>> 32)));
    }

    public final String toString() {
        if (this == f19189c) {
            return "PT0S";
        }
        long j4 = this.f19190a;
        int i6 = this.f19191b;
        long j6 = (j4 >= 0 || i6 <= 0) ? j4 : 1 + j4;
        long j7 = j6 / 3600;
        int i7 = (int) ((j6 % 3600) / 60);
        int i8 = (int) (j6 % 60);
        StringBuilder sb = new StringBuilder(24);
        sb.append("PT");
        if (j7 != 0) {
            sb.append(j7);
            sb.append('H');
        }
        if (i7 != 0) {
            sb.append(i7);
            sb.append('M');
        }
        if (i8 == 0 && i6 == 0 && sb.length() > 2) {
            return sb.toString();
        }
        if (j4 < 0 && i6 > 0 && i8 == 0) {
            sb.append("-0");
        } else {
            sb.append(i8);
        }
        if (i6 > 0) {
            int length = sb.length();
            if (j4 < 0) {
                sb.append(2000000000 - ((long) i6));
            } else {
                sb.append(((long) i6) + C.NANOS_PER_SECOND);
            }
            while (sb.charAt(sb.length() - 1) == '0') {
                sb.setLength(sb.length() - 1);
            }
            sb.setCharAt(length, '.');
        }
        sb.append('S');
        return sb.toString();
    }

    private Object writeReplace() {
        return new t((byte) 1, this);
    }

    private void readObject(ObjectInputStream objectInputStream) throws InvalidObjectException {
        throw new InvalidObjectException("Deserialization via serialization delegate");
    }

    final void writeExternal(ObjectOutput objectOutput) throws IOException {
        objectOutput.writeLong(this.f19190a);
        objectOutput.writeInt(this.f19191b);
    }
}
