package com.ifpdos.udi.sdk.service.doc.mkdocs;

import com.ifpdos.udi.sdk.service.doc.base.Permission;
import com.seewo.sdk.internal.utils.Constants;
import f.a.y.a;
import g.c0.g;
import g.h0.c.l;
import g.i;
import g.m0.f;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/* JADX INFO: compiled from: DocRenderer.kt */
/* JADX INFO: loaded from: classes.dex */
@i
public final class ApiDefineWrapper {
    private final List<AlsoWrapper> also;
    private final ApiDefine api;
    private final String classification;
    private final List<DependInfo> depends;
    private final String dependsString;
    private final String deprecated;
    private final String description;
    private final List<String> functionBlocks;
    private final Integer getPermission;
    private final String getRequestClassName;
    private final List<FieldWrapper> getRequestWrapper;
    private final String getResponseClassName;
    private final List<FieldWrapper> getResponseWrapper;
    private final String getUrl;
    private final boolean hasAlso;
    private final boolean hasDepends;
    private final boolean hasDeprecated;
    private final boolean hasFunctionBlocks;
    private final Boolean hasGetRequest;
    private final Boolean hasGetResponse;
    private final Boolean hasNotify;
    private final boolean hasOpensdks;
    private final boolean hasPermission;
    private final Boolean hasPostRequest;
    private final Boolean hasPostResponse;
    private final boolean isGetSupport;
    private final boolean isNotifySupport;
    private final boolean isPostSupport;
    private final String noticeTarget;
    private final String notifyDataClass;
    private final Integer notifyPermission;
    private final List<FieldWrapper> notifyRequestWrapper;
    private final List<OpenSdkInfo> opensdks;
    private final Integer postPermission;
    private final String postRequestDataClass;
    private final List<FieldWrapper> postRequestWrapper;
    private final String postResponseDataClass;
    private final List<FieldWrapper> postResponseWrapper;
    private final String postUrl;
    private final String summary;

    public ApiDefineWrapper(ApiDefine apiDefine, String str, String str2) {
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        ArrayList arrayList6;
        List<FieldInfo> notify;
        List<FieldInfo> notify2;
        String notifyClassName;
        List<FieldInfo> response;
        List<FieldInfo> request;
        List<FieldInfo> response2;
        String responseClassName;
        List<FieldInfo> request2;
        String requestClassName;
        List<FieldInfo> response3;
        List<FieldInfo> request3;
        List<FieldInfo> response4;
        List<FieldInfo> request4;
        String responseClassName2;
        String requestClassName2;
        Permission permission;
        Permission permission2;
        Permission permission3;
        l.f(apiDefine, "api");
        this.api = apiDefine;
        this.getUrl = str;
        this.postUrl = str2;
        this.summary = apiDefine.getSummary();
        this.description = apiDefine.getComment().getDescription();
        NotifyDefine notify3 = apiDefine.getNotify();
        Boolean boolValueOf = null;
        this.noticeTarget = notify3 != null ? notify3.getNotifyClassName() : null;
        this.opensdks = parserOpenSdk(apiDefine);
        this.hasOpensdks = !r11.isEmpty();
        this.functionBlocks = parserFunctionBlocks(apiDefine);
        this.hasFunctionBlocks = !r11.isEmpty();
        this.classification = getClassification(apiDefine);
        List<String> list = apiDefine.getComment().getAnnotations().get("see");
        if (list != null) {
            arrayList = new ArrayList(a.C(list, 10));
            Iterator<T> it = list.iterator();
            while (it.hasNext()) {
                arrayList.add(new AlsoWrapper((String) it.next()));
            }
        } else {
            arrayList = null;
        }
        this.also = arrayList;
        this.hasAlso = arrayList != null && (arrayList.isEmpty() ^ true);
        String str3 = parserDeprecated(this.api);
        this.deprecated = str3;
        this.hasDeprecated = str3.length() > 0;
        boolean z = this.api.getGet() != null;
        this.isGetSupport = z;
        RequestDefine get = this.api.getGet();
        this.getPermission = (get == null || (permission3 = get.getPermission()) == null) ? null : Integer.valueOf(permission3.getPermission());
        boolean z2 = this.api.getPost() != null;
        this.isPostSupport = z2;
        RequestDefine post = this.api.getPost();
        this.postPermission = (post == null || (permission2 = post.getPermission()) == null) ? null : Integer.valueOf(permission2.getPermission());
        boolean z3 = this.api.getNotify() != null;
        this.isNotifySupport = z3;
        NotifyDefine notify4 = this.api.getNotify();
        this.notifyPermission = (notify4 == null || (permission = notify4.getPermission()) == null) ? null : Integer.valueOf(permission.getPermission());
        this.hasPermission = z || z2 || z3;
        List<DependInfo> list2 = parserDepends(this.api);
        this.depends = list2;
        this.dependsString = toJson(list2);
        this.hasDepends = !list2.isEmpty();
        RequestDefine get2 = this.api.getGet();
        String str4 = (get2 == null || (requestClassName2 = get2.getRequestClassName()) == null) ? null : (String) g.t(f.E(requestClassName2, new String[]{"."}, false, 0, 6));
        this.getRequestClassName = (str4 == null || l.a(str4, "EmptyBody")) ? null : DocRendererKt.getGenericSimpleNameWithoutPackage(this.api.getGet().getRequestClassName());
        RequestDefine get3 = this.api.getGet();
        String str5 = (get3 == null || (responseClassName2 = get3.getResponseClassName()) == null) ? null : (String) g.t(f.E(responseClassName2, new String[]{"."}, false, 0, 6));
        this.getResponseClassName = (str5 == null || l.a(str5, "EmptyBody")) ? null : DocRendererKt.getLink(DocRendererKt.getGenericSimpleNameWithoutPackage(this.api.getGet().getResponseClassName()));
        RequestDefine get4 = this.api.getGet();
        if (get4 == null || (request4 = get4.getRequest()) == null) {
            arrayList2 = null;
        } else {
            arrayList2 = new ArrayList(a.C(request4, 10));
            Iterator<T> it2 = request4.iterator();
            while (it2.hasNext()) {
                arrayList2.add(new FieldWrapper(this.api.getUri(), (FieldInfo) it2.next()));
            }
        }
        this.getRequestWrapper = arrayList2;
        RequestDefine get5 = this.api.getGet();
        if (get5 == null || (response4 = get5.getResponse()) == null) {
            arrayList3 = null;
        } else {
            arrayList3 = new ArrayList(a.C(response4, 10));
            Iterator<T> it3 = response4.iterator();
            while (it3.hasNext()) {
                arrayList3.add(new FieldWrapper(this.api.getUri(), (FieldInfo) it3.next()));
            }
        }
        this.getResponseWrapper = arrayList3;
        RequestDefine get6 = this.api.getGet();
        this.hasGetRequest = (get6 == null || (request3 = get6.getRequest()) == null) ? null : Boolean.valueOf(!request3.isEmpty());
        RequestDefine get7 = this.api.getGet();
        this.hasGetResponse = (get7 == null || (response3 = get7.getResponse()) == null) ? null : Boolean.valueOf(!response3.isEmpty());
        RequestDefine post2 = this.api.getPost();
        String str6 = (post2 == null || (requestClassName = post2.getRequestClassName()) == null) ? null : (String) g.t(f.E(requestClassName, new String[]{"."}, false, 0, 6));
        this.postRequestDataClass = (str6 == null || l.a(str6, "EmptyBody")) ? null : DocRendererKt.getGenericSimpleNameWithoutPackage(this.api.getPost().getRequestClassName());
        RequestDefine post3 = this.api.getPost();
        if (post3 == null || (request2 = post3.getRequest()) == null) {
            arrayList4 = null;
        } else {
            arrayList4 = new ArrayList(a.C(request2, 10));
            Iterator<T> it4 = request2.iterator();
            while (it4.hasNext()) {
                arrayList4.add(new FieldWrapper(this.api.getUri(), (FieldInfo) it4.next()));
            }
        }
        this.postRequestWrapper = arrayList4;
        RequestDefine post4 = this.api.getPost();
        String str7 = (post4 == null || (responseClassName = post4.getResponseClassName()) == null) ? null : (String) g.t(f.E(responseClassName, new String[]{"."}, false, 0, 6));
        this.postResponseDataClass = (str7 == null || l.a(str7, "EmptyBody")) ? null : DocRendererKt.getGenericSimpleNameWithoutPackage(this.api.getPost().getResponseClassName());
        RequestDefine post5 = this.api.getPost();
        if (post5 == null || (response2 = post5.getResponse()) == null) {
            arrayList5 = null;
        } else {
            arrayList5 = new ArrayList(a.C(response2, 10));
            Iterator<T> it5 = response2.iterator();
            while (it5.hasNext()) {
                arrayList5.add(new FieldWrapper(this.api.getUri(), (FieldInfo) it5.next()));
            }
        }
        this.postResponseWrapper = arrayList5;
        RequestDefine post6 = this.api.getPost();
        this.hasPostRequest = (post6 == null || (request = post6.getRequest()) == null) ? null : Boolean.valueOf(!request.isEmpty());
        RequestDefine post7 = this.api.getPost();
        this.hasPostResponse = (post7 == null || (response = post7.getResponse()) == null) ? null : Boolean.valueOf(!response.isEmpty());
        NotifyDefine notify5 = this.api.getNotify();
        String str8 = (notify5 == null || (notifyClassName = notify5.getNotifyClassName()) == null) ? null : (String) g.t(f.E(notifyClassName, new String[]{"."}, false, 0, 6));
        this.notifyDataClass = (str8 == null || l.a(str8, "EmptyBody")) ? null : DocRendererKt.getLink(DocRendererKt.getGenericSimpleNameWithoutPackage(this.api.getNotify().getNotifyClassName()));
        NotifyDefine notify6 = this.api.getNotify();
        if (notify6 == null || (notify2 = notify6.getNotify()) == null) {
            arrayList6 = null;
        } else {
            arrayList6 = new ArrayList(a.C(notify2, 10));
            Iterator<T> it6 = notify2.iterator();
            while (it6.hasNext()) {
                arrayList6.add(new FieldWrapper(this.api.getUri(), (FieldInfo) it6.next()));
            }
        }
        this.notifyRequestWrapper = arrayList6;
        NotifyDefine notify7 = this.api.getNotify();
        if (notify7 != null && (notify = notify7.getNotify()) != null) {
            boolValueOf = Boolean.valueOf(!notify.isEmpty());
        }
        this.hasNotify = boolValueOf;
    }

    public static /* synthetic */ ApiDefineWrapper copy$default(ApiDefineWrapper apiDefineWrapper, ApiDefine apiDefine, String str, String str2, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            apiDefine = apiDefineWrapper.api;
        }
        if ((i2 & 2) != 0) {
            str = apiDefineWrapper.getUrl;
        }
        if ((i2 & 4) != 0) {
            str2 = apiDefineWrapper.postUrl;
        }
        return apiDefineWrapper.copy(apiDefine, str, str2);
    }

    private final List<DependInfo> parserDepends(ApiDefine apiDefine) {
        List<String> list = apiDefine.getComment().getAnnotations().get("depend");
        if (list == null) {
            return g.c0.l.f4067b;
        }
        ArrayList arrayList = new ArrayList();
        Iterator<T> it = list.iterator();
        while (it.hasNext()) {
            List listE = f.E((String) it.next(), new String[]{" "}, false, 2, 2);
            String str = (String) listE.get(0);
            String str2 = (String) listE.get(1);
            List listE2 = f.E(f.A(str, "[", "", false, 4), new String[]{"]"}, false, 0, 6);
            List listE3 = f.E(str2, new String[]{":"}, false, 2, 2);
            Iterator it2 = f.E((String) listE2.get(0), new String[]{","}, false, 0, 6).iterator();
            while (it2.hasNext()) {
                arrayList.add(new DependInfo(listE2.size() > 2 ? (String) listE2.get(2) : "", (String) it2.next(), (String) listE2.get(1), (String) listE3.get(0), listE3.size() > 1 ? (String) listE3.get(1) : ""));
            }
        }
        return arrayList;
    }

    private final String parserDeprecated(ApiDefine apiDefine) {
        List<String> list = apiDefine.getComment().getAnnotations().get("deprecated");
        return (list == null || list.isEmpty()) ? "" : list.get(0);
    }

    private final List<String> parserFunctionBlocks(ApiDefine apiDefine) {
        List<String> list = apiDefine.getComment().getAnnotations().get("funblk");
        if (list == null) {
            list = g.c0.l.f4067b;
        }
        if (list.isEmpty() && l.a(getClassification(apiDefine), "工具接口")) {
            return a.w0("IFP_FUNBLK-1380");
        }
        ArrayList arrayList = new ArrayList();
        Iterator<T> it = list.iterator();
        while (it.hasNext()) {
            arrayList.add(f.R((String) it.next()).toString());
        }
        return arrayList;
    }

    private final List<OpenSdkInfo> parserOpenSdk(ApiDefine apiDefine) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        List<String> list = apiDefine.getComment().getAnnotations().get(Constants.SDK_SERVICE);
        if (list == null) {
            return g.c0.l.f4067b;
        }
        Iterator<T> it = list.iterator();
        while (it.hasNext()) {
            List listE = f.E((String) it.next(), new String[]{"]"}, false, 2, 2);
            String strSubstring = f.R((String) listE.get(0)).toString().substring(1);
            l.e(strSubstring, "this as java.lang.String).substring(startIndex)");
            String string = f.R((String) f.E((String) listE.get(1), new String[]{":"}, false, 2, 2).get(0)).toString();
            if (linkedHashMap.containsKey(strSubstring)) {
                List list2 = (List) linkedHashMap.get(strSubstring);
                if (list2 != null) {
                    list2.add(string);
                }
            } else {
                linkedHashMap.put(strSubstring, g.w(string));
            }
        }
        ArrayList arrayList = new ArrayList(linkedHashMap.size());
        for (Map.Entry entry : linkedHashMap.entrySet()) {
            arrayList.add(new OpenSdkInfo((String) entry.getKey(), g.r((Iterable) entry.getValue(), ",", null, null, 0, null, null, 62)));
        }
        return arrayList;
    }

    private final String toJson(List<DependInfo> list) throws IOException {
        return '[' + g.r(list, ",", null, null, 0, null, ApiDefineWrapper$toJson$list$1.INSTANCE, 30) + ']';
    }

    public final ApiDefine component1() {
        return this.api;
    }

    public final String component2() {
        return this.getUrl;
    }

    public final String component3() {
        return this.postUrl;
    }

    public final ApiDefineWrapper copy(ApiDefine apiDefine, String str, String str2) {
        l.f(apiDefine, "api");
        return new ApiDefineWrapper(apiDefine, str, str2);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof ApiDefineWrapper)) {
            return false;
        }
        ApiDefineWrapper apiDefineWrapper = (ApiDefineWrapper) obj;
        return l.a(this.api, apiDefineWrapper.api) && l.a(this.getUrl, apiDefineWrapper.getUrl) && l.a(this.postUrl, apiDefineWrapper.postUrl);
    }

    public final List<AlsoWrapper> getAlso() {
        return this.also;
    }

    public final ApiDefine getApi() {
        return this.api;
    }

    public final String getClassification() {
        return this.classification;
    }

    public final List<DependInfo> getDepends() {
        return this.depends;
    }

    public final String getDependsString() {
        return this.dependsString;
    }

    public final String getDeprecated() {
        return this.deprecated;
    }

    public final String getDescription() {
        return this.description;
    }

    public final List<String> getFunctionBlocks() {
        return this.functionBlocks;
    }

    public final Integer getGetPermission() {
        return this.getPermission;
    }

    public final String getGetRequestClassName() {
        return this.getRequestClassName;
    }

    public final List<FieldWrapper> getGetRequestWrapper() {
        return this.getRequestWrapper;
    }

    public final String getGetResponseClassName() {
        return this.getResponseClassName;
    }

    public final List<FieldWrapper> getGetResponseWrapper() {
        return this.getResponseWrapper;
    }

    public final String getGetUrl() {
        return this.getUrl;
    }

    public final boolean getHasAlso() {
        return this.hasAlso;
    }

    public final boolean getHasDepends() {
        return this.hasDepends;
    }

    public final boolean getHasDeprecated() {
        return this.hasDeprecated;
    }

    public final boolean getHasFunctionBlocks() {
        return this.hasFunctionBlocks;
    }

    public final Boolean getHasGetRequest() {
        return this.hasGetRequest;
    }

    public final Boolean getHasGetResponse() {
        return this.hasGetResponse;
    }

    public final Boolean getHasNotify() {
        return this.hasNotify;
    }

    public final boolean getHasOpensdks() {
        return this.hasOpensdks;
    }

    public final boolean getHasPermission() {
        return this.hasPermission;
    }

    public final Boolean getHasPostRequest() {
        return this.hasPostRequest;
    }

    public final Boolean getHasPostResponse() {
        return this.hasPostResponse;
    }

    public final String getNoticeTarget() {
        return this.noticeTarget;
    }

    public final String getNotifyDataClass() {
        return this.notifyDataClass;
    }

    public final Integer getNotifyPermission() {
        return this.notifyPermission;
    }

    public final List<FieldWrapper> getNotifyRequestWrapper() {
        return this.notifyRequestWrapper;
    }

    public final List<OpenSdkInfo> getOpensdks() {
        return this.opensdks;
    }

    public final Integer getPostPermission() {
        return this.postPermission;
    }

    public final String getPostRequestDataClass() {
        return this.postRequestDataClass;
    }

    public final List<FieldWrapper> getPostRequestWrapper() {
        return this.postRequestWrapper;
    }

    public final String getPostResponseDataClass() {
        return this.postResponseDataClass;
    }

    public final List<FieldWrapper> getPostResponseWrapper() {
        return this.postResponseWrapper;
    }

    public final String getPostUrl() {
        return this.postUrl;
    }

    public final String getSummary() {
        return this.summary;
    }

    public int hashCode() {
        int iHashCode = this.api.hashCode() * 31;
        String str = this.getUrl;
        int iHashCode2 = (iHashCode + (str == null ? 0 : str.hashCode())) * 31;
        String str2 = this.postUrl;
        return iHashCode2 + (str2 != null ? str2.hashCode() : 0);
    }

    public final boolean isGetSupport() {
        return this.isGetSupport;
    }

    public final boolean isNotifySupport() {
        return this.isNotifySupport;
    }

    public final boolean isPostSupport() {
        return this.isPostSupport;
    }

    public String toString() {
        StringBuilder sbB = d.b.a.a.a.B("ApiDefineWrapper(api=");
        sbB.append(this.api);
        sbB.append(", getUrl=");
        sbB.append(this.getUrl);
        sbB.append(", postUrl=");
        return d.b.a.a.a.u(sbB, this.postUrl, ')');
    }

    private final String getClassification(ApiDefine apiDefine) {
        List<String> list = apiDefine.getComment().getAnnotations().get("classification");
        return list == null ? "" : list.get(0);
    }
}
