package com.bytedance.sdk.component.wsy.ro;

import android.text.TextUtils;
import androidx.media3.exoplayer.dash.DashMediaSource;
import com.bytedance.sdk.component.ro.fm.duv;
import com.bytedance.sdk.component.ro.fm.ku;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes.dex */
public abstract class lb {
    int ajl;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    protected com.bytedance.sdk.openadsdk.gof.yz f6700ef;
    String jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    protected ku f6701lb;
    private List<String> ro;
    protected String yz = null;
    protected final Map<String, String> wsy = new HashMap();
    protected String wu = null;
    private String fm = null;
    private long ku = DashMediaSource.DEFAULT_FALLBACK_TARGET_LIVE_OFFSET_MS;
    protected boolean vt = false;

    public lb(ku kuVar) {
        this.f6701lb = kuVar;
        try {
            yz(UUID.randomUUID().toString());
        } catch (Throwable th) {
            th.getMessage();
        }
    }

    public String ajl() {
        return this.wu;
    }

    public void ef() {
        if (this.f6700ef == null) {
            return;
        }
        try {
            ku kuVar = this.f6701lb;
            if (kuVar == null || kuVar.fm() == null) {
                return;
            }
            this.f6701lb.fm().lb(this.f6700ef);
        } catch (Throwable unused) {
        }
    }

    public abstract com.bytedance.sdk.component.wsy.ro fm();

    public void fm(int i10) {
        this.ajl = i10;
    }

    public abstract void fm(com.bytedance.sdk.component.wsy.fm.fm fmVar);

    /* JADX WARN: Removed duplicated region for block: B:8:0x0013 A[Catch: all -> 0x0018, TRY_LEAVE, TryCatch #1 {all -> 0x0018, blocks: (B:5:0x0009, B:7:0x000f, B:8:0x0013), top: B:17:0x0009 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final com.bytedance.sdk.component.wsy.ro jnr() {
        com.bytedance.sdk.component.wsy.ro roVarFm;
        wsy();
        try {
            roVarFm = fm();
            if (roVarFm != null) {
                try {
                    if (roVarFm.ajl()) {
                        wu();
                    } else {
                        ef();
                    }
                } catch (Throwable unused) {
                    ef();
                }
            }
        } catch (Throwable unused2) {
            roVarFm = null;
        }
        return roVarFm;
    }

    public String lb() {
        return this.fm;
    }

    public void ro(String str) {
        this.jnr = str;
    }

    public void wsy() {
        if (this.f6700ef == null) {
            return;
        }
        try {
            ku kuVar = this.f6701lb;
            if (kuVar == null || kuVar.fm() == null) {
                return;
            }
            this.f6701lb.fm().fm(this.f6700ef);
        } catch (Throwable unused) {
        }
    }

    public void wu() {
        if (this.f6700ef == null) {
            return;
        }
        try {
            ku kuVar = this.f6701lb;
            if (kuVar == null || kuVar.fm() == null) {
                return;
            }
            this.f6701lb.fm().ro(this.f6700ef);
        } catch (Throwable unused) {
        }
    }

    public String yz() {
        return this.yz;
    }

    public void fm(com.bytedance.sdk.openadsdk.gof.yz yzVar) {
        this.f6700ef = yzVar;
    }

    public void lb(String str) {
        this.wu = str;
    }

    public void ro(String str, String str2) {
        this.wsy.put(str, str2);
    }

    public void yz(String str) {
        this.yz = str;
    }

    public void fm(String str) {
        this.fm = str;
    }

    public void ro() {
        ku kuVar;
        if (this.yz == null || (kuVar = this.f6701lb) == null) {
            return;
        }
        com.bytedance.sdk.component.ro.fm.yz yzVarRo = kuVar.ro();
        synchronized (yzVarRo) {
            try {
                for (com.bytedance.sdk.component.ro.fm.ro roVar : yzVarRo.lb()) {
                    if (this.yz.equals(roVar.fm().lb())) {
                        roVar.lb();
                    }
                }
                for (com.bytedance.sdk.component.ro.fm.ro roVar2 : yzVarRo.yz()) {
                    if (this.yz.equals(roVar2.fm().lb())) {
                        roVar2.lb();
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public void yz(Map<String, String> map) {
        if (map != null) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                this.wsy.put(entry.getKey(), entry.getValue());
            }
        }
    }

    public void fm(List<String> list) {
        this.ro = list;
    }

    public void fm(long j10, TimeUnit timeUnit) {
        this.ku = timeUnit.toMillis(j10);
    }

    public void fm(duv.fm fmVar) {
        if (com.bytedance.sdk.component.wsy.fm.ajl()) {
            List<String> list = this.ro;
            if (list != null && !list.isEmpty()) {
                fmVar.fm(this.ro);
            }
            fmVar.fm(this.ku);
        }
    }

    public final void ro(final com.bytedance.sdk.component.wsy.fm.fm fmVar) {
        wsy();
        fm(new com.bytedance.sdk.component.wsy.fm.fm() { // from class: com.bytedance.sdk.component.wsy.ro.lb.1
            @Override // com.bytedance.sdk.component.wsy.fm.fm
            public void fm(lb lbVar, com.bytedance.sdk.component.wsy.ro roVar) {
                if (roVar == null || !roVar.ajl()) {
                    lb.this.ef();
                } else {
                    lb.this.wu();
                }
                com.bytedance.sdk.component.wsy.fm.fm fmVar2 = fmVar;
                if (fmVar2 != null) {
                    fmVar2.fm(lbVar, roVar);
                }
            }

            @Override // com.bytedance.sdk.component.wsy.fm.fm
            public void fm(lb lbVar, IOException iOException) {
                lb.this.ef();
                com.bytedance.sdk.component.wsy.fm.fm fmVar2 = fmVar;
                if (fmVar2 != null) {
                    fmVar2.fm(lbVar, iOException);
                }
            }
        });
    }

    public void ro(duv.fm fmVar) {
        if (fmVar != null && this.wsy.size() > 0) {
            for (Map.Entry<String, String> entry : this.wsy.entrySet()) {
                String key = entry.getKey();
                if (!TextUtils.isEmpty(key)) {
                    String value = entry.getValue();
                    if (value == null) {
                        value = "";
                    }
                    fmVar.ro(key, value);
                }
            }
        }
    }
}
