package com.revenuecat.purchases;

import S4.v;
import com.revenuecat.purchases.UiConfig;
import i5.g;
import j5.d;
import kotlin.jvm.internal.o;
import l5.C;
import l5.k;
import l5.m;
import l5.n;
import l5.y;

/* JADX INFO: loaded from: classes3.dex */
@InternalRevenueCatAPI
public final class CustomVariableDefinitionSerializer implements g5.a {
    public static final CustomVariableDefinitionSerializer INSTANCE = new CustomVariableDefinitionSerializer();
    private static final g descriptor = W.a.R("CustomVariableDefinition", new g[0], CustomVariableDefinitionSerializer$descriptor$1.INSTANCE);

    private CustomVariableDefinitionSerializer() {
    }

    @Override // g5.a
    public g getDescriptor() {
        return descriptor;
    }

    /* JADX WARN: Removed duplicated region for block: B:42:0x00a0  */
    @Override // g5.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public UiConfig.CustomVariableDefinition deserialize(j5.c decoder) {
        String strG;
        Object objR0;
        o.h(decoder, "decoder");
        if (!(decoder instanceof k)) {
            throw new IllegalArgumentException("CustomVariableDefinition can only be deserialized from JSON");
        }
        y yVarG = n.g(((k) decoder).l());
        m mVar = (m) yVarG.get("type");
        if (mVar == null || (strG = n.h(mVar).g()) == null) {
            strG = "string";
        }
        Object obj = yVarG.get("default_value");
        Boolean bool = null;
        C c6 = obj instanceof C ? (C) obj : null;
        if (c6 == null) {
            return new UiConfig.CustomVariableDefinition(strG, "");
        }
        int iHashCode = strG.hashCode();
        if (iHashCode != -1034364087) {
            if (iHashCode != -891985903) {
                if (iHashCode == 64711720 && strG.equals("boolean")) {
                    objR0 = n.d(c6);
                    if (objR0 == null) {
                        String strG2 = c6.g();
                        o.h(strG2, "<this>");
                        if (strG2.equals("true")) {
                            bool = Boolean.TRUE;
                        } else if (strG2.equals("false")) {
                            bool = Boolean.FALSE;
                        }
                        objR0 = bool == null ? c6.g() : bool;
                    }
                } else {
                    objR0 = c6.g();
                }
            } else if (strG.equals("string")) {
                objR0 = c6.g();
            }
        } else if (strG.equals("number")) {
            objR0 = v.r0(c6.g());
            if (objR0 == null && (objR0 = v.r0(c6.g())) == null) {
                objR0 = c6.g();
            }
        }
        return new UiConfig.CustomVariableDefinition(strG, objR0);
    }

    @Override // g5.a
    public void serialize(d encoder, UiConfig.CustomVariableDefinition value) {
        o.h(encoder, "encoder");
        o.h(value, "value");
        throw new IllegalStateException("Serialization of CustomVariableDefinition is not implemented as it is not needed.");
    }
}
