package e.a.r.y;

import com.seewo.libmcuservice.constant.ITVStateConstants;

/* JADX INFO: compiled from: JsonExceptions.kt */
/* JADX INFO: loaded from: classes.dex */
@d.n
public final class y {
    public static final u a(Number number, String str, String str2) {
        d.n0.c.s.e(number, ITVStateConstants.KEY_VOICE_VALUE);
        d.n0.c.s.e(str, "key");
        d.n0.c.s.e(str2, "output");
        return d(-1, j(number, str, str2));
    }

    public static final w b(Number number, String str) {
        d.n0.c.s.e(number, ITVStateConstants.KEY_VOICE_VALUE);
        d.n0.c.s.e(str, "output");
        return new w("Unexpected special floating-point value " + number + ". By default, non-finite floating point values are prohibited because they do not conform JSON specification. It is possible to deserialize them using 'JsonBuilder.allowSpecialFloatingPointValues = true'\nCurrent output: " + ((Object) h(str, 0, 1, null)));
    }

    public static final w c(e.a.o.f fVar) {
        d.n0.c.s.e(fVar, "keyDescriptor");
        return new w("Value of type '" + fVar.a() + "' can't be used in JSON as a key in the map. It should have either primitive or enum kind, but its kind is '" + fVar.e() + "'.\nUse 'allowStructuredMapKeys = true' in 'Json {}' builder to convert such maps to [key1, value1, key2, value2,...] arrays.");
    }

    public static final u d(int i, String str) {
        d.n0.c.s.e(str, "message");
        if (i >= 0) {
            str = "Unexpected JSON token at offset " + i + ": " + str;
        }
        return new u(str);
    }

    public static final u e(int i, String str, CharSequence charSequence) {
        d.n0.c.s.e(str, "message");
        d.n0.c.s.e(charSequence, "input");
        return d(i, str + "\nJSON input: " + ((Object) g(charSequence, i)));
    }

    public static final u f(String str, String str2) {
        d.n0.c.s.e(str, "key");
        d.n0.c.s.e(str2, "input");
        return d(-1, "Encountered unknown key '" + str + "'.\nUse 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.\nCurrent input: " + ((Object) h(str2, 0, 1, null)));
    }

    private static final CharSequence g(CharSequence charSequence, int i) {
        if (charSequence.length() < 200) {
            return charSequence;
        }
        if (i == -1) {
            int length = charSequence.length() - 60;
            if (length <= 0) {
                return charSequence;
            }
            return "....." + charSequence.subSequence(length, charSequence.length()).toString();
        }
        int i2 = i - 30;
        int i3 = i + 30;
        return (i2 <= 0 ? "" : ".....") + charSequence.subSequence(d.p0.n.b(i2, 0), d.p0.n.c(i3, charSequence.length())).toString() + (i3 >= charSequence.length() ? "" : ".....");
    }

    static /* synthetic */ CharSequence h(CharSequence charSequence, int i, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            i = -1;
        }
        return g(charSequence, i);
    }

    public static final Void i(a aVar, Number number) {
        d.n0.c.s.e(aVar, "<this>");
        d.n0.c.s.e(number, "result");
        a.y(aVar, "Unexpected special floating-point value " + number + ". By default, non-finite floating point values are prohibited because they do not conform JSON specification", 0, "It is possible to deserialize them using 'JsonBuilder.allowSpecialFloatingPointValues = true'", 2, null);
        throw new d.h();
    }

    private static final String j(Number number, String str, String str2) {
        return "Unexpected special floating-point value " + number + " with key " + str + ". By default, non-finite floating point values are prohibited because they do not conform JSON specification. It is possible to deserialize them using 'JsonBuilder.allowSpecialFloatingPointValues = true'\nCurrent output: " + ((Object) h(str2, 0, 1, null));
    }
}
