package y4;

import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.fasterxml.jackson.core.JsonFactory;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.lang.ref.WeakReference;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.jvm.internal.t;
import rm.c0;
import rm.v;
import v4.j;
import v4.o;

/* loaded from: classes.dex */
public abstract class a implements j.c {

    /* renamed from: a, reason: collision with root package name */
    private final Context f51974a;

    /* renamed from: b, reason: collision with root package name */
    private final Set f51975b;

    /* renamed from: c, reason: collision with root package name */
    private final WeakReference f51976c;

    /* renamed from: d, reason: collision with root package name */
    private k.b f51977d;

    /* renamed from: e, reason: collision with root package name */
    private ValueAnimator f51978e;

    public a(Context context, d configuration) {
        t.g(context, "context");
        t.g(configuration, "configuration");
        this.f51974a = context;
        this.f51975b = configuration.c();
        configuration.b();
        this.f51976c = null;
    }

    private final void b(boolean z10) {
        k.b bVar = this.f51977d;
        v a10 = bVar == null ? null : c0.a(bVar, Boolean.TRUE);
        if (a10 == null) {
            k.b bVar2 = new k.b(this.f51974a);
            this.f51977d = bVar2;
            a10 = c0.a(bVar2, Boolean.FALSE);
        }
        k.b bVar3 = (k.b) a10.a();
        boolean booleanValue = ((Boolean) a10.b()).booleanValue();
        c(bVar3, z10 ? h.f51988b : h.f51987a);
        float f10 = z10 ? BitmapDescriptorFactory.HUE_RED : 1.0f;
        if (!booleanValue) {
            bVar3.setProgress(f10);
            return;
        }
        float a11 = bVar3.a();
        ValueAnimator valueAnimator = this.f51978e;
        if (valueAnimator != null) {
            valueAnimator.cancel();
        }
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(bVar3, "progress", a11, f10);
        this.f51978e = ofFloat;
        if (ofFloat == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.animation.ObjectAnimator");
        }
        ofFloat.start();
    }

    @Override // v4.j.c
    public void a(v4.j controller, o destination, Bundle bundle) {
        t.g(controller, "controller");
        t.g(destination, "destination");
        if (destination instanceof v4.d) {
            return;
        }
        WeakReference weakReference = this.f51976c;
        if (weakReference != null) {
            android.support.v4.media.session.b.a(weakReference.get());
        }
        if (this.f51976c != null) {
            controller.e0(this);
            return;
        }
        CharSequence E = destination.E();
        if (E != null) {
            StringBuffer stringBuffer = new StringBuffer();
            Matcher matcher = Pattern.compile("\\{(.+?)\\}").matcher(E);
            while (matcher.find()) {
                String group = matcher.group(1);
                if (bundle == null || !bundle.containsKey(group)) {
                    throw new IllegalArgumentException("Could not find \"" + ((Object) group) + "\" in " + bundle + " to fill label \"" + ((Object) E) + JsonFactory.DEFAULT_QUOTE_CHAR);
                }
                matcher.appendReplacement(stringBuffer, "");
                stringBuffer.append(String.valueOf(bundle.get(group)));
            }
            matcher.appendTail(stringBuffer);
            d(stringBuffer);
        }
        if (g.b(destination, this.f51975b)) {
            c(null, 0);
        } else {
            b(false);
        }
    }

    protected abstract void c(Drawable drawable, int i10);

    protected abstract void d(CharSequence charSequence);
}
