package or;

import com.amplifyframework.core.model.ModelIdentifier;
import com.amplifyframework.storage.ObjectMetadata;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import uq.c0;
import uq.y;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes5.dex */
public abstract class p {

    /* loaded from: classes5.dex */
    class a extends p {
        a() {
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // or.p
        /* renamed from: d, reason: merged with bridge method [inline-methods] */
        public void a(r rVar, Iterable iterable) {
            if (iterable == null) {
                return;
            }
            Iterator it = iterable.iterator();
            while (it.hasNext()) {
                p.this.a(rVar, it.next());
            }
        }
    }

    /* loaded from: classes5.dex */
    class b extends p {
        b() {
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            if (obj == null) {
                return;
            }
            int length = Array.getLength(obj);
            for (int i10 = 0; i10 < length; i10++) {
                p.this.a(rVar, Array.get(obj, i10));
            }
        }
    }

    /* loaded from: classes5.dex */
    static final class c extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31714a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31715b;

        /* renamed from: c, reason: collision with root package name */
        private final or.f f31716c;

        /* JADX INFO: Access modifiers changed from: package-private */
        public c(Method method, int i10, or.f fVar) {
            this.f31714a = method;
            this.f31715b = i10;
            this.f31716c = fVar;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            if (obj == null) {
                throw y.o(this.f31714a, this.f31715b, "Body parameter value must not be null.", new Object[0]);
            }
            try {
                rVar.l((c0) this.f31716c.convert(obj));
            } catch (IOException e10) {
                throw y.p(this.f31714a, e10, this.f31715b, "Unable to convert " + obj + " to RequestBody", new Object[0]);
            }
        }
    }

    /* loaded from: classes5.dex */
    static final class d extends p {

        /* renamed from: a, reason: collision with root package name */
        private final String f31717a;

        /* renamed from: b, reason: collision with root package name */
        private final or.f f31718b;

        /* renamed from: c, reason: collision with root package name */
        private final boolean f31719c;

        /* JADX INFO: Access modifiers changed from: package-private */
        public d(String str, or.f fVar, boolean z10) {
            Objects.requireNonNull(str, "name == null");
            this.f31717a = str;
            this.f31718b = fVar;
            this.f31719c = z10;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            String str;
            if (obj == null || (str = (String) this.f31718b.convert(obj)) == null) {
                return;
            }
            rVar.a(this.f31717a, str, this.f31719c);
        }
    }

    /* loaded from: classes5.dex */
    static final class e extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31720a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31721b;

        /* renamed from: c, reason: collision with root package name */
        private final or.f f31722c;

        /* renamed from: d, reason: collision with root package name */
        private final boolean f31723d;

        /* JADX INFO: Access modifiers changed from: package-private */
        public e(Method method, int i10, or.f fVar, boolean z10) {
            this.f31720a = method;
            this.f31721b = i10;
            this.f31722c = fVar;
            this.f31723d = z10;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // or.p
        /* renamed from: d, reason: merged with bridge method [inline-methods] */
        public void a(r rVar, Map map) {
            if (map == null) {
                throw y.o(this.f31720a, this.f31721b, "Field map was null.", new Object[0]);
            }
            for (Map.Entry entry : map.entrySet()) {
                String str = (String) entry.getKey();
                if (str == null) {
                    throw y.o(this.f31720a, this.f31721b, "Field map contained null key.", new Object[0]);
                }
                Object value = entry.getValue();
                if (value == null) {
                    throw y.o(this.f31720a, this.f31721b, "Field map contained null value for key '" + str + "'.", new Object[0]);
                }
                String str2 = (String) this.f31722c.convert(value);
                if (str2 == null) {
                    throw y.o(this.f31720a, this.f31721b, "Field map value '" + value + "' converted to null by " + this.f31722c.getClass().getName() + " for key '" + str + "'.", new Object[0]);
                }
                rVar.a(str, str2, this.f31723d);
            }
        }
    }

    /* loaded from: classes5.dex */
    static final class f extends p {

        /* renamed from: a, reason: collision with root package name */
        private final String f31724a;

        /* renamed from: b, reason: collision with root package name */
        private final or.f f31725b;

        /* JADX INFO: Access modifiers changed from: package-private */
        public f(String str, or.f fVar) {
            Objects.requireNonNull(str, "name == null");
            this.f31724a = str;
            this.f31725b = fVar;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            String str;
            if (obj == null || (str = (String) this.f31725b.convert(obj)) == null) {
                return;
            }
            rVar.b(this.f31724a, str);
        }
    }

    /* loaded from: classes5.dex */
    static final class g extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31726a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31727b;

        /* renamed from: c, reason: collision with root package name */
        private final or.f f31728c;

        /* JADX INFO: Access modifiers changed from: package-private */
        public g(Method method, int i10, or.f fVar) {
            this.f31726a = method;
            this.f31727b = i10;
            this.f31728c = fVar;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // or.p
        /* renamed from: d, reason: merged with bridge method [inline-methods] */
        public void a(r rVar, Map map) {
            if (map == null) {
                throw y.o(this.f31726a, this.f31727b, "Header map was null.", new Object[0]);
            }
            for (Map.Entry entry : map.entrySet()) {
                String str = (String) entry.getKey();
                if (str == null) {
                    throw y.o(this.f31726a, this.f31727b, "Header map contained null key.", new Object[0]);
                }
                Object value = entry.getValue();
                if (value == null) {
                    throw y.o(this.f31726a, this.f31727b, "Header map contained null value for key '" + str + "'.", new Object[0]);
                }
                rVar.b(str, (String) this.f31728c.convert(value));
            }
        }
    }

    /* loaded from: classes5.dex */
    static final class h extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31729a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31730b;

        /* JADX INFO: Access modifiers changed from: package-private */
        public h(Method method, int i10) {
            this.f31729a = method;
            this.f31730b = i10;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // or.p
        /* renamed from: d, reason: merged with bridge method [inline-methods] */
        public void a(r rVar, uq.u uVar) {
            if (uVar == null) {
                throw y.o(this.f31729a, this.f31730b, "Headers parameter must not be null.", new Object[0]);
            }
            rVar.c(uVar);
        }
    }

    /* loaded from: classes5.dex */
    static final class i extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31731a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31732b;

        /* renamed from: c, reason: collision with root package name */
        private final uq.u f31733c;

        /* renamed from: d, reason: collision with root package name */
        private final or.f f31734d;

        /* JADX INFO: Access modifiers changed from: package-private */
        public i(Method method, int i10, uq.u uVar, or.f fVar) {
            this.f31731a = method;
            this.f31732b = i10;
            this.f31733c = uVar;
            this.f31734d = fVar;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            if (obj == null) {
                return;
            }
            try {
                rVar.d(this.f31733c, (c0) this.f31734d.convert(obj));
            } catch (IOException e10) {
                throw y.o(this.f31731a, this.f31732b, "Unable to convert " + obj + " to RequestBody", e10);
            }
        }
    }

    /* loaded from: classes5.dex */
    static final class j extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31735a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31736b;

        /* renamed from: c, reason: collision with root package name */
        private final or.f f31737c;

        /* renamed from: d, reason: collision with root package name */
        private final String f31738d;

        /* JADX INFO: Access modifiers changed from: package-private */
        public j(Method method, int i10, or.f fVar, String str) {
            this.f31735a = method;
            this.f31736b = i10;
            this.f31737c = fVar;
            this.f31738d = str;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // or.p
        /* renamed from: d, reason: merged with bridge method [inline-methods] */
        public void a(r rVar, Map map) {
            if (map == null) {
                throw y.o(this.f31735a, this.f31736b, "Part map was null.", new Object[0]);
            }
            for (Map.Entry entry : map.entrySet()) {
                String str = (String) entry.getKey();
                if (str == null) {
                    throw y.o(this.f31735a, this.f31736b, "Part map contained null key.", new Object[0]);
                }
                Object value = entry.getValue();
                if (value == null) {
                    throw y.o(this.f31735a, this.f31736b, "Part map contained null value for key '" + str + "'.", new Object[0]);
                }
                rVar.d(uq.u.z(ObjectMetadata.CONTENT_DISPOSITION, "form-data; name=\"" + str + ModelIdentifier.Helper.PRIMARY_KEY_ENCAPSULATE_CHAR, "Content-Transfer-Encoding", this.f31738d), (c0) this.f31737c.convert(value));
            }
        }
    }

    /* loaded from: classes5.dex */
    static final class k extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31739a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31740b;

        /* renamed from: c, reason: collision with root package name */
        private final String f31741c;

        /* renamed from: d, reason: collision with root package name */
        private final or.f f31742d;

        /* renamed from: e, reason: collision with root package name */
        private final boolean f31743e;

        /* JADX INFO: Access modifiers changed from: package-private */
        public k(Method method, int i10, String str, or.f fVar, boolean z10) {
            this.f31739a = method;
            this.f31740b = i10;
            Objects.requireNonNull(str, "name == null");
            this.f31741c = str;
            this.f31742d = fVar;
            this.f31743e = z10;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            if (obj != null) {
                rVar.f(this.f31741c, (String) this.f31742d.convert(obj), this.f31743e);
                return;
            }
            throw y.o(this.f31739a, this.f31740b, "Path parameter \"" + this.f31741c + "\" value must not be null.", new Object[0]);
        }
    }

    /* loaded from: classes5.dex */
    static final class l extends p {

        /* renamed from: a, reason: collision with root package name */
        private final String f31744a;

        /* renamed from: b, reason: collision with root package name */
        private final or.f f31745b;

        /* renamed from: c, reason: collision with root package name */
        private final boolean f31746c;

        /* JADX INFO: Access modifiers changed from: package-private */
        public l(String str, or.f fVar, boolean z10) {
            Objects.requireNonNull(str, "name == null");
            this.f31744a = str;
            this.f31745b = fVar;
            this.f31746c = z10;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            String str;
            if (obj == null || (str = (String) this.f31745b.convert(obj)) == null) {
                return;
            }
            rVar.g(this.f31744a, str, this.f31746c);
        }
    }

    /* loaded from: classes5.dex */
    static final class m extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31747a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31748b;

        /* renamed from: c, reason: collision with root package name */
        private final or.f f31749c;

        /* renamed from: d, reason: collision with root package name */
        private final boolean f31750d;

        /* JADX INFO: Access modifiers changed from: package-private */
        public m(Method method, int i10, or.f fVar, boolean z10) {
            this.f31747a = method;
            this.f31748b = i10;
            this.f31749c = fVar;
            this.f31750d = z10;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // or.p
        /* renamed from: d, reason: merged with bridge method [inline-methods] */
        public void a(r rVar, Map map) {
            if (map == null) {
                throw y.o(this.f31747a, this.f31748b, "Query map was null", new Object[0]);
            }
            for (Map.Entry entry : map.entrySet()) {
                String str = (String) entry.getKey();
                if (str == null) {
                    throw y.o(this.f31747a, this.f31748b, "Query map contained null key.", new Object[0]);
                }
                Object value = entry.getValue();
                if (value == null) {
                    throw y.o(this.f31747a, this.f31748b, "Query map contained null value for key '" + str + "'.", new Object[0]);
                }
                String str2 = (String) this.f31749c.convert(value);
                if (str2 == null) {
                    throw y.o(this.f31747a, this.f31748b, "Query map value '" + value + "' converted to null by " + this.f31749c.getClass().getName() + " for key '" + str + "'.", new Object[0]);
                }
                rVar.g(str, str2, this.f31750d);
            }
        }
    }

    /* loaded from: classes5.dex */
    static final class n extends p {

        /* renamed from: a, reason: collision with root package name */
        private final or.f f31751a;

        /* renamed from: b, reason: collision with root package name */
        private final boolean f31752b;

        /* JADX INFO: Access modifiers changed from: package-private */
        public n(or.f fVar, boolean z10) {
            this.f31751a = fVar;
            this.f31752b = z10;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            if (obj == null) {
                return;
            }
            rVar.g((String) this.f31751a.convert(obj), null, this.f31752b);
        }
    }

    /* loaded from: classes5.dex */
    static final class o extends p {

        /* renamed from: a, reason: collision with root package name */
        static final o f31753a = new o();

        private o() {
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // or.p
        /* renamed from: d, reason: merged with bridge method [inline-methods] */
        public void a(r rVar, y.c cVar) {
            if (cVar != null) {
                rVar.e(cVar);
            }
        }
    }

    /* renamed from: or.p$p, reason: collision with other inner class name */
    /* loaded from: classes5.dex */
    static final class C0731p extends p {

        /* renamed from: a, reason: collision with root package name */
        private final Method f31754a;

        /* renamed from: b, reason: collision with root package name */
        private final int f31755b;

        /* JADX INFO: Access modifiers changed from: package-private */
        public C0731p(Method method, int i10) {
            this.f31754a = method;
            this.f31755b = i10;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            if (obj == null) {
                throw y.o(this.f31754a, this.f31755b, "@Url parameter is null.", new Object[0]);
            }
            rVar.m(obj);
        }
    }

    /* loaded from: classes5.dex */
    static final class q extends p {

        /* renamed from: a, reason: collision with root package name */
        final Class f31756a;

        /* JADX INFO: Access modifiers changed from: package-private */
        public q(Class cls) {
            this.f31756a = cls;
        }

        @Override // or.p
        void a(r rVar, Object obj) {
            rVar.h(this.f31756a, obj);
        }
    }

    p() {
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public abstract void a(r rVar, Object obj);

    /* JADX INFO: Access modifiers changed from: package-private */
    public final p b() {
        return new b();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final p c() {
        return new a();
    }
}
