package com.google.android.gms.internal.ads;

import android.content.Context;
import android.text.TextUtils;
import android.webkit.CookieManager;
import androidx.annotation.Nullable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes2.dex */
public final class u90 implements k90 {

    @Nullable
    private final CookieManager zza;

    public u90(Context context) {
        this.zza = m7.n.C.f30467f.zza(context);
    }

    @Override // com.google.android.gms.internal.ads.k90
    public final void a(HashMap map) {
        CookieManager cookieManager = this.zza;
        if (cookieManager == null) {
            return;
        }
        if (((String) map.get("clear")) == null) {
            String str = (String) map.get("cookie");
            if (TextUtils.isEmpty(str)) {
                return;
            }
            cookieManager.setCookie((String) n7.y.f31093e.f31096c.b(ao.f8944l1), str);
            return;
        }
        String str2 = (String) n7.y.f31093e.f31096c.b(ao.f8944l1);
        String cookie = cookieManager.getCookie(str2);
        if (cookie != null) {
            List listN = ru.c(new kq1(';')).n(cookie);
            for (int i10 = 0; i10 < listN.size(); i10++) {
                String str3 = (String) listN.get(i10);
                ru ruVarC = ru.c(new kq1('='));
                str3.getClass();
                Iterator it = new rq1(ruVarC, str3).iterator();
                it.getClass();
                if (!it.hasNext()) {
                    StringBuilder sb = new StringBuilder(String.valueOf(0).length() + 70);
                    sb.append("position (0) must be less than the number of elements that remained (0)");
                    throw new IndexOutOfBoundsException(sb.toString());
                }
                cookieManager.setCookie(str2, String.valueOf((String) it.next()).concat(String.valueOf((String) n7.y.f31093e.f31096c.b(ao.X0))));
            }
        }
    }
}
