package com.pichillilorenzo.flutter_inappwebview_android.proxy;

import androidx.annotation.NonNull;
import com.pichillilorenzo.flutter_inappwebview_android.ISettings;
import com.pichillilorenzo.flutter_inappwebview_android.types.ProxyRuleExt;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
import z3.c;
import z3.d;

/* JADX INFO: loaded from: classes.dex */
public class ProxySettings implements ISettings<d> {
    List<String> bypassRules = new ArrayList();
    List<String> directs = new ArrayList();
    List<ProxyRuleExt> proxyRules = new ArrayList();
    Boolean bypassSimpleHostnames = null;
    Boolean removeImplicitRules = null;
    Boolean reverseBypassEnabled = Boolean.FALSE;

    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    public /* bridge */ /* synthetic */ ISettings<d> parse(@NonNull Map map) {
        return parse2((Map<String, Object>) map);
    }

    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    public Map<String, Object> toMap() {
        ArrayList arrayList = new ArrayList();
        Iterator<ProxyRuleExt> it = this.proxyRules.iterator();
        while (it.hasNext()) {
            arrayList.add(it.next().toMap());
        }
        HashMap map = new HashMap();
        map.put("bypassRules", this.bypassRules);
        map.put("directs", this.directs);
        map.put("proxyRules", arrayList);
        map.put("bypassSimpleHostnames", this.bypassSimpleHostnames);
        map.put("removeImplicitRules", this.removeImplicitRules);
        map.put("reverseBypassEnabled", this.reverseBypassEnabled);
        return map;
    }

    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    public Map<String, Object> getRealSettings(@NonNull d dVar) {
        Map<String, Object> map = toMap();
        ArrayList arrayList = new ArrayList();
        for (c cVar : Collections.unmodifiableList(dVar.f37036a)) {
            HashMap map2 = new HashMap();
            map2.put(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL, cVar.f37035b);
            map2.put("schemeFilter", cVar.f37034a);
            arrayList.add(map2);
        }
        map.put("bypassRules", Collections.unmodifiableList(dVar.f37037b));
        map.put("proxyRules", arrayList);
        map.put("reverseBypassEnabled", Boolean.valueOf(dVar.f37038c));
        return map;
    }

    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    /* JADX INFO: renamed from: parse, reason: avoid collision after fix types in other method */
    public ISettings<d> parse2(@NonNull Map<String, Object> map) {
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (value != null) {
                key.getClass();
                switch (key) {
                    case "bypassSimpleHostnames":
                        this.bypassSimpleHostnames = (Boolean) value;
                        break;
                    case "proxyRules":
                        this.proxyRules = new ArrayList();
                        Iterator it = ((List) value).iterator();
                        while (it.hasNext()) {
                            ProxyRuleExt proxyRuleExtFromMap = ProxyRuleExt.fromMap((Map) it.next());
                            if (proxyRuleExtFromMap != null) {
                                this.proxyRules.add(proxyRuleExtFromMap);
                            }
                        }
                        break;
                    case "reverseBypassEnabled":
                        this.reverseBypassEnabled = (Boolean) value;
                        break;
                    case "removeImplicitRules":
                        this.removeImplicitRules = (Boolean) value;
                        break;
                    case "bypassRules":
                        this.bypassRules = (List) value;
                        break;
                    case "directs":
                        this.directs = (List) value;
                        break;
                }
            }
        }
        return this;
    }
}
