package ae;

import android.os.Handler;
import android.os.Looper;
import com.google.android.gms.measurement.internal.u1;
import java.util.concurrent.CancellationException;
import kotlin.coroutines.h;
import kotlinx.coroutines.h0;
import kotlinx.coroutines.i1;
import kotlinx.coroutines.internal.n;
import kotlinx.coroutines.j0;
import kotlinx.coroutines.k1;
import kotlinx.coroutines.r1;
import kotlinx.coroutines.y;
import nb.g;

/* JADX INFO: loaded from: classes.dex */
public final class d extends e {

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final boolean f452e;

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

    public d(Handler handler, String str, boolean z10) {
        this.f450c = handler;
        this.f451d = str;
        this.f452e = z10;
        this.f453f = z10 ? this : new d(handler, str, true);
    }

    @Override // kotlinx.coroutines.t
    public final void L(h hVar, Runnable runnable) {
        if (this.f450c.post(runnable)) {
            return;
        }
        O(hVar, runnable);
    }

    @Override // kotlinx.coroutines.t
    public final boolean M(h hVar) {
        return (this.f452e && g.c(Looper.myLooper(), this.f450c.getLooper())) ? false : true;
    }

    public final void O(h hVar, Runnable runnable) {
        y.d(hVar, new CancellationException("The task was rejected, the handler underlying the dispatcher '" + this + "' was closed"));
        h0.f29441b.L(hVar, runnable);
    }

    public final boolean equals(Object obj) {
        if (obj instanceof d) {
            d dVar = (d) obj;
            if (dVar.f450c == this.f450c && dVar.f452e == this.f452e) {
                return true;
            }
        }
        return false;
    }

    public final int hashCode() {
        return System.identityHashCode(this.f450c) ^ (this.f452e ? 1231 : 1237);
    }

    @Override // kotlinx.coroutines.d0
    public final j0 k(long j10, final r1 r1Var, h hVar) {
        if (j10 > 4611686018427387903L) {
            j10 = 4611686018427387903L;
        }
        if (this.f450c.postDelayed(r1Var, j10)) {
            return new j0() { // from class: ae.c
                @Override // kotlinx.coroutines.j0
                public final void dispose() {
                    this.f448a.f450c.removeCallbacks(r1Var);
                }
            };
        }
        O(hVar, r1Var);
        return k1.f29507a;
    }

    @Override // kotlinx.coroutines.t
    public final String toString() {
        d dVar;
        String str;
        be.d dVar2 = h0.f29440a;
        i1 i1Var = n.f29483a;
        if (this == i1Var) {
            str = "Dispatchers.Main";
        } else {
            try {
                dVar = ((d) i1Var).f453f;
            } catch (UnsupportedOperationException unused) {
                dVar = null;
            }
            str = this == dVar ? "Dispatchers.Main.immediate" : null;
        }
        if (str != null) {
            return str;
        }
        String string = this.f451d;
        if (string == null) {
            string = this.f450c.toString();
        }
        return this.f452e ? u1.j(string, ".immediate") : string;
    }

    public d(Handler handler) {
        this(handler, null, false);
    }
}
