package com.ifpdos.udi.sdk.service.compile;

import com.github.mustachejava.DefaultMustacheFactory;
import com.ifpdos.udi.sdk.kotlin.comment.parser.Comment;
import com.ifpdos.udi.sdk.kotlin.comment.parser.CommentDetails;
import com.ifpdos.udi.sdk.kotlin.comment.parser.CommentParser;
import com.ifpdos.udi.sdk.service.doc.base.ApiInfo;
import com.ifpdos.udi.sdk.service.doc.base.ClassParser;
import com.ifpdos.udi.sdk.service.doc.base.IClassWrapper;
import com.ifpdos.udi.sdk.service.doc.base.IDocGenerator;
import com.ifpdos.udi.sdk.service.doc.base.IFieldWrapper;
import com.ifpdos.udi.sdk.service.doc.base.Request;
import com.ifpdos.udi.sdk.service.doc.base.Uri;
import com.ifpdos.udi.sdk.service.doc.base.Utils;
import com.seewo.vcommons.constants.SeewoIntent;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.TuplesKt;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.collections.MapsKt;
import kotlin.io.CloseableKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.TypeIntrinsics;
import kotlin.ranges.RangesKt;
import kotlin.text.Charsets;
import kotlin.text.StringsKt;
import kotlin.text.Typography;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;

/* JADX INFO: compiled from: ApiProcessor.kt */
/* JADX INFO: loaded from: classes.dex */
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@Metadata(d1 = {"\u0000ä\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\"\n\u0002\b\u0005\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u001e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010 \n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010#\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0007\u0018\u0000 q2\u00020\u0001:\u0002pqB\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0012\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u0010H\u0002J\u0012\u0010\u0014\u001a\u00020\u00152\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0002J@\u0010\u0018\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u00102\u0012\u0010\u001b\u001a\u000e\u0012\u0004\u0012\u00020\u001d\u0012\u0004\u0012\u00020\u001e0\u001c2\f\u0010\u001f\u001a\b\u0012\u0004\u0012\u00020\u001d0 2\f\u0010!\u001a\b\u0012\u0004\u0012\u00020\u001d0 H\u0002J,\u0010\"\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u00102\f\u0010\u001f\u001a\b\u0012\u0004\u0012\u00020\u001d0 2\f\u0010!\u001a\b\u0012\u0004\u0012\u00020\u001d0 H\u0002J\u0018\u0010#\u001a\u00020\u00102\u0006\u0010$\u001a\u00020\u00102\u0006\u0010%\u001a\u00020&H\u0002J \u0010#\u001a\u00020\u00192\u0006\u0010$\u001a\u00020\u00102\u0006\u0010%\u001a\u00020&2\u0006\u0010'\u001a\u00020\u0010H\u0002J\u001e\u0010(\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u00102\f\u0010)\u001a\b\u0012\u0004\u0012\u00020\u001e0*H\u0002J\u0018\u0010+\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00102\u0006\u0010,\u001a\u00020-H\u0002J\u0018\u0010.\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00102\u0006\u0010/\u001a\u00020-H\u0002J\u0010\u00100\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u0010H\u0002J\u0016\u00101\u001a\u00020\u00192\f\u00102\u001a\b\u0012\u0004\u0012\u00020\u001e0*H\u0002J6\u00103\u001a\u000e\u0012\u0004\u0012\u00020\u001d\u0012\u0004\u0012\u00020\u001e0\u001c2\f\u0010)\u001a\b\u0012\u0004\u0012\u00020\u001d0 2\u0012\u00104\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u0002050\u001cH\u0002J\u000e\u00106\u001a\u00020\u00102\u0006\u00107\u001a\u000208J\u000e\u00106\u001a\u00020\u00102\u0006\u00107\u001a\u000209JP\u0010:\u001a\u001a\u0012\u0004\u0012\u00020\u001d\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u001d\u0012\u0004\u0012\u00020;0\u001c0\u001c2\u0012\u0010)\u001a\u000e\u0012\u0004\u0012\u00020\u001d\u0012\u0004\u0012\u00020\u001e0\u001c2\f\u0010\u001f\u001a\b\u0012\u0004\u0012\u00020\u001d0 2\f\u0010!\u001a\b\u0012\u0004\u0012\u00020\u001d0 H\u0002J)\u0010<\u001a\u00020\f2\u0006\u0010=\u001a\u00020\f2\u0012\u0010>\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u00100?\"\u00020\u0010H\u0002¢\u0006\u0002\u0010@J\u0014\u0010A\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020B0\u001cH\u0002J\b\u0010C\u001a\u00020\fH\u0002J\b\u0010D\u001a\u00020\fH\u0002J\u001c\u0010E\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020\u00100\u001c2\u0006\u0010F\u001a\u00020\u0010H\u0002J\u0016\u0010G\u001a\b\u0012\u0004\u0012\u00020\u00100H2\u0006\u0010I\u001a\u00020\u001dH\u0002J\u0018\u0010J\u001a\u00020\u00102\u0006\u0010K\u001a\u00020L2\u0006\u0010M\u001a\u00020\u0010H\u0002J\u0012\u0010N\u001a\u0004\u0018\u00010\u00102\u0006\u0010O\u001a\u00020PH\u0002J$\u0010Q\u001a\u00020\u00102\u0006\u0010K\u001a\u00020\u00102\u0012\u0010R\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020\u00100\u001cH\u0002J$\u0010S\u001a\u00020\u00102\u0006\u0010K\u001a\u00020\u00102\u0012\u0010R\u001a\u000e\u0012\u0004\u0012\u00020\u0010\u0012\u0004\u0012\u00020\u00100\u001cH\u0002J\u001c\u0010T\u001a\b\u0012\u0004\u0012\u00020\u001e0*2\f\u0010)\u001a\b\u0012\u0004\u0012\u00020\u001e0*H\u0002J\u0010\u0010U\u001a\u00020\u00102\u0006\u0010V\u001a\u00020\fH\u0002J\u0012\u0010W\u001a\u0004\u0018\u00010\f2\u0006\u0010X\u001a\u00020YH\u0002J<\u0010Z\u001a\u00020\u00102\b\u0010I\u001a\u0004\u0018\u00010\u001d2\u0006\u0010K\u001a\u00020L2\u0006\u0010[\u001a\u00020\u00102\u0006\u0010\\\u001a\u00020\u00102\u0006\u0010,\u001a\u00020-2\b\u0010]\u001a\u0004\u0018\u00010\u0010H\u0002J\u0018\u0010^\u001a\u00020\u00102\u0006\u0010K\u001a\u00020L2\u0006\u0010M\u001a\u00020\u0010H\u0002J\u0010\u0010_\u001a\u00020`2\u0006\u0010I\u001a\u00020aH\u0002J\u0010\u0010b\u001a\u00020\u00192\u0006\u0010c\u001a\u00020YH\u0016J\u0010\u0010d\u001a\u00020\u00152\u0006\u0010\u0013\u001a\u00020eH\u0002J\u0010\u0010f\u001a\u00020\u00152\u0006\u0010\u0013\u001a\u00020eH\u0002J\u0010\u0010g\u001a\u00020\u00152\u0006\u0010\u0013\u001a\u00020eH\u0002J\u0010\u0010h\u001a\u00020\u00152\u0006\u0010\u0013\u001a\u00020eH\u0002J$\u0010i\u001a\u00020\u00152\u0010\u0010j\u001a\f\u0012\u0006\b\u0001\u0012\u00020l\u0018\u00010k2\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0016J3\u0010m\u001a\u0004\u0018\u00010\f2\u0006\u0010n\u001a\u00020\u00102\u0006\u0010=\u001a\u00020\f2\u0012\u0010>\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u00100?\"\u00020\u0010H\u0002¢\u0006\u0002\u0010oR\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u000f\u001a\u0004\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\fX\u0082.¢\u0006\u0002\n\u0000¨\u0006r"}, d2 = {"Lcom/ifpdos/udi/sdk/service/compile/ApiProcessor;", "Ljavax/annotation/processing/AbstractProcessor;", "()V", "classParser", "Lcom/ifpdos/udi/sdk/service/doc/base/ClassParser;", "commentProvider", "Lcom/ifpdos/udi/sdk/service/compile/CommentProvider;", "elementUtils", "Ljavax/lang/model/util/Elements;", "filer", "Ljavax/annotation/processing/Filer;", "kotlinGenerated", "Ljava/io/File;", "messager", "Ljavax/annotation/processing/Messager;", "moduleName", "", "projectDir", "covertToKotlinType", SeewoIntent.KEY_FILE_TYPE, "doProcess", "", "env", "Ljavax/annotation/processing/RoundEnvironment;", "genApi", "", "packageName", "allApiInfo", "", "Ljavax/lang/model/element/Element;", "Lcom/ifpdos/udi/sdk/service/doc/base/ApiInfo;", "getters", "", "setters", "genApiBinder", "genCode", "template", "scope", "", "codeFileName", "genOnlyNotifyApiBinder", "apis", "", "genRequestCode", "request", "Lcom/ifpdos/udi/sdk/service/doc/base/Request;", "genResponseCode", "response", "genUtilsCode", "genXml", "apiInfo", "getAllApiInfo", "orders", "", "getApi", "handler", "Lcom/ifpdos/udi/sdk/service/compile/GetterHandler;", "Lcom/ifpdos/udi/sdk/service/compile/SetterHandler;", "getApiReceivers", "Lcom/ifpdos/udi/sdk/service/compile/ApiProcessor$ApiHandlerInfo;", "getChildFile", "dir", "children", "", "(Ljava/io/File;[Ljava/lang/String;)Ljava/io/File;", "getCommentFromDependentModules", "Lcom/ifpdos/udi/sdk/kotlin/comment/parser/CommentDetails;", "getCurrentModuleDir", "getDocDir", "getFieldsTypeMap", "clazz", "getGenericParameterTypes", "", "element", "getJsonFromUriQueryPart", SeewoIntent.KEY_FILE_URI, "Lcom/ifpdos/udi/sdk/service/doc/base/Uri;", "requestClass", "getNotify", "api", "Lcom/ifpdos/udi/sdk/service/compile/Api;", "getNotifyFuncParams", "typeMap", "getNotifyUri", "getOnlyNotifyApi", "getPackage", "srcProtocolDefine", "getProjectDir", "processingEnv", "Ljavax/annotation/processing/ProcessingEnvironment;", "getRequestAdapterCode", "wrapperRequestClass", "wrapperResponseClass", "receiverClass", "getUriParamsCodeFromRestfulUri", "handlerFromElement", "Lcom/ifpdos/udi/sdk/service/doc/base/Request$Handler;", "Ljavax/lang/model/element/ExecutableElement;", "init", "processingEnvironment", "isNotifyProtocolInterface", "Ljavax/lang/model/type/TypeMirror;", "isOnlyGetterProtocolInterface", "isOnlySetterProtocolInterface", "isProtocolInterface", "process", "set", "", "Ljavax/lang/model/element/TypeElement;", "searchCodeFile", "fileName", "(Ljava/lang/String;Ljava/io/File;[Ljava/lang/String;)Ljava/io/File;", "ApiHandlerInfo", "Companion", "compile"}, k = 1, mv = {1, 6, 0}, xi = 48)
@SupportedAnnotationTypes({"com.ifpdos.udi.sdk.service.compile.GetterHandler", "com.ifpdos.udi.sdk.service.compile.SetterHandler", "com.ifpdos.udi.sdk.service.compile.Api"})
public final class ApiProcessor extends AbstractProcessor {
    private static final String PARAM_KAPT_KOTLIN_GENERATED_OPTION = "kapt.kotlin.generated";
    private static final String PARAM_MODULE_NAME = "udi.sdk.module.name";
    private static final String PROTOCOL_DEFINE_FILE = "ProtocolDefine.kt";
    private static final String UDI_STATIC_API_XML_FILE = "udi_service_apis.xml";
    private final ClassParser classParser = new ClassParser();
    private CommentProvider commentProvider;
    private Elements elementUtils;
    private Filer filer;
    private File kotlinGenerated;
    private Messager messager;
    private String moduleName;
    private File projectDir;

    private final File getProjectDir(ProcessingEnvironment processingEnv) {
        if (((String) processingEnv.getOptions().get(PARAM_KAPT_KOTLIN_GENERATED_OPTION)) == null) {
            System.out.println((Object) "Can't find the project dir");
            return null;
        }
        File file = new File((String) processingEnv.getOptions().get(PARAM_KAPT_KOTLIN_GENERATED_OPTION));
        while (true) {
            String[] list = file.list();
            Intrinsics.checkNotNullExpressionValue(list, "dir.list()");
            if (!ArraysKt.contains(list, "settings.gradle")) {
                String[] list2 = file.list();
                Intrinsics.checkNotNullExpressionValue(list2, "dir.list()");
                if (ArraysKt.contains(list2, "pubspec.yaml")) {
                    break;
                }
                file = file.getParentFile();
                Intrinsics.checkNotNullExpressionValue(file, "dir.parentFile");
            } else {
                break;
            }
        }
        String[] list3 = file.list();
        Intrinsics.checkNotNullExpressionValue(list3, "dir.list()");
        return ArraysKt.contains(list3, "settings.gradle") ? file : new File(file, "android");
    }

    public synchronized void init(ProcessingEnvironment processingEnvironment) {
        Intrinsics.checkNotNullParameter(processingEnvironment, "processingEnvironment");
        super.init(processingEnvironment);
        Utils utils = Utils.INSTANCE;
        ProcessingEnvironment processingEnv = this.processingEnv;
        Intrinsics.checkNotNullExpressionValue(processingEnv, "processingEnv");
        utils.init(processingEnv);
        File projectDir = getProjectDir(processingEnvironment);
        if (projectDir == null) {
            return;
        }
        this.projectDir = projectDir;
        this.moduleName = (String) this.processingEnv.getOptions().get(PARAM_MODULE_NAME);
        Elements elementUtils = this.processingEnv.getElementUtils();
        Intrinsics.checkNotNullExpressionValue(elementUtils, "processingEnv.elementUtils");
        this.elementUtils = elementUtils;
        Filer filer = this.processingEnv.getFiler();
        Intrinsics.checkNotNullExpressionValue(filer, "processingEnv.filer");
        this.filer = filer;
        Messager messager = this.processingEnv.getMessager();
        Intrinsics.checkNotNullExpressionValue(messager, "processingEnv.messager");
        this.messager = messager;
        Elements elements = this.elementUtils;
        CommentProvider commentProvider = null;
        if (elements == null) {
            Intrinsics.throwUninitializedPropertyAccessException("elementUtils");
            elements = null;
        }
        this.commentProvider = new CommentProvider(elements);
        ClassParser classParser = this.classParser;
        Elements elements2 = this.elementUtils;
        if (elements2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("elementUtils");
            elements2 = null;
        }
        CommentProvider commentProvider2 = this.commentProvider;
        if (commentProvider2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("commentProvider");
        } else {
            commentProvider = commentProvider2;
        }
        classParser.init(elements2, commentProvider);
    }

    private final File getDocDir() {
        File file = this.projectDir;
        if (file == null) {
            Intrinsics.throwUninitializedPropertyAccessException("projectDir");
            file = null;
        }
        String str = (String) this.processingEnv.getOptions().get("udi.doc.dir");
        if (str == null) {
            str = "doc";
        }
        File file2 = new File(file, str);
        if (!file2.exists()) {
            file2.mkdirs();
        }
        return file2;
    }

    private final File getCurrentModuleDir() {
        File parentFile = null;
        if (this.moduleName != null) {
            File file = this.projectDir;
            if (file == null) {
                Intrinsics.throwUninitializedPropertyAccessException("projectDir");
            } else {
                parentFile = file;
            }
            String str = this.moduleName;
            Intrinsics.checkNotNull(str);
            return new File(parentFile, str);
        }
        File file2 = this.kotlinGenerated;
        if (file2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("kotlinGenerated");
        } else {
            parentFile = file2;
        }
        while (!new File(parentFile, "build.gradle").exists()) {
            parentFile = parentFile.getParentFile();
            Intrinsics.checkNotNullExpressionValue(parentFile, "dir.parentFile");
        }
        return parentFile;
    }

    private final Request.Handler handlerFromElement(ExecutableElement element) {
        return new Request.Handler(element.getSimpleName().toString());
    }

    private final Map<Element, Map<Element, ApiHandlerInfo>> getApiReceivers(Map<Element, ApiInfo> apis, Set<? extends Element> getters, Set<? extends Element> setters) {
        LinkedHashMap linkedHashMap;
        LinkedHashMap linkedHashMap2;
        Iterator it;
        Object obj;
        Element element;
        LinkedHashMap linkedHashMap3;
        Iterator it2;
        LinkedHashMap linkedHashMap4;
        Object obj2;
        Iterator it3;
        Iterator it4;
        String str;
        Request setterRequest;
        Messager messager;
        Request getterRequest;
        Map<Element, ApiInfo> map = apis;
        LinkedHashMap linkedHashMap5 = new LinkedHashMap();
        Iterator<T> it5 = getters.iterator();
        while (true) {
            String str2 = "elementUtils";
            if (it5.hasNext()) {
                Element element2 = (Element) it5.next();
                Annotation annotation = element2.getAnnotation(GetterHandler.class);
                Intrinsics.checkNotNullExpressionValue(annotation, "it.getAnnotation(GetterHandler::class.java)");
                String api = getApi((GetterHandler) annotation);
                Elements elements = this.elementUtils;
                if (elements == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("elementUtils");
                    elements = null;
                }
                String str3 = api;
                ApiInfo apiInfo = map.get(elements.getTypeElement(str3));
                Set<Request.Handler> handlers = (apiInfo == null || (getterRequest = apiInfo.getGetterRequest()) == null) ? null : getterRequest.getHandlers();
                if (handlers == null) {
                    Elements elements2 = this.elementUtils;
                    if (elements2 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("elementUtils");
                        elements2 = null;
                    }
                    TypeElement typeElement = elements2.getTypeElement(str3);
                    if (typeElement == null) {
                        throw new NullPointerException("null cannot be cast to non-null type javax.lang.model.element.TypeElement");
                    }
                    Object obj3 = typeElement.getInterfaces().get(0);
                    if (obj3 == null) {
                        throw new NullPointerException("null cannot be cast to non-null type javax.lang.model.type.DeclaredType");
                    }
                    DeclaredType declaredType = (DeclaredType) obj3;
                    Messager messager2 = this.messager;
                    if (messager2 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("messager");
                        messager = null;
                    } else {
                        messager = messager2;
                    }
                    messager.printMessage(Diagnostic.Kind.ERROR, element2.getEnclosingElement() + '.' + element2.getSimpleName() + " want handle getter request, but " + api + " is " + declaredType.asElement().getSimpleName() + " don't support getter");
                }
                if (handlers != null) {
                    TypeIntrinsics.asMutableSet(handlers).add(handlerFromElement((ExecutableElement) element2));
                    Object obj4 = linkedHashMap5.get(api);
                    if (obj4 == null) {
                        obj4 = (List) new ArrayList();
                        linkedHashMap5.put(api, obj4);
                    }
                    ((List) obj4).add(element2);
                } else {
                    throw new NullPointerException("null cannot be cast to non-null type kotlin.collections.MutableSet<com.ifpdos.udi.sdk.service.doc.base.Request.Handler>");
                }
            } else {
                LinkedHashMap linkedHashMap6 = new LinkedHashMap();
                Iterator it6 = setters.iterator();
                while (it6.hasNext()) {
                    Element element3 = (Element) it6.next();
                    Annotation annotation2 = element3.getAnnotation(SetterHandler.class);
                    Intrinsics.checkNotNullExpressionValue(annotation2, "it.getAnnotation(SetterHandler::class.java)");
                    String api2 = getApi((SetterHandler) annotation2);
                    Elements elements3 = this.elementUtils;
                    if (elements3 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException(str2);
                        elements3 = null;
                    }
                    String str4 = api2;
                    ApiInfo apiInfo2 = map.get(elements3.getTypeElement(str4));
                    Set<Request.Handler> handlers2 = (apiInfo2 == null || (setterRequest = apiInfo2.getSetterRequest()) == null) ? null : setterRequest.getHandlers();
                    if (handlers2 == null) {
                        Elements elements4 = this.elementUtils;
                        if (elements4 == null) {
                            Intrinsics.throwUninitializedPropertyAccessException(str2);
                            elements4 = null;
                        }
                        TypeElement typeElement2 = elements4.getTypeElement(str4);
                        if (typeElement2 == null) {
                            throw new NullPointerException("null cannot be cast to non-null type javax.lang.model.element.TypeElement");
                        }
                        Object obj5 = typeElement2.getInterfaces().get(0);
                        if (obj5 == null) {
                            throw new NullPointerException("null cannot be cast to non-null type javax.lang.model.type.DeclaredType");
                        }
                        DeclaredType declaredType2 = (DeclaredType) obj5;
                        Messager messager3 = this.messager;
                        if (messager3 == null) {
                            Intrinsics.throwUninitializedPropertyAccessException("messager");
                            messager3 = null;
                        }
                        it4 = it6;
                        str = str2;
                        messager3.printMessage(Diagnostic.Kind.ERROR, element3.getEnclosingElement() + '.' + element3.getSimpleName() + " want handle setter request, but " + api2 + " is " + declaredType2.asElement().getSimpleName() + " don't support setter");
                    } else {
                        it4 = it6;
                        str = str2;
                    }
                    if (handlers2 != null) {
                        TypeIntrinsics.asMutableSet(handlers2).add(handlerFromElement((ExecutableElement) element3));
                        Object obj6 = linkedHashMap6.get(api2);
                        if (obj6 == null) {
                            obj6 = (List) new ArrayList();
                            linkedHashMap6.put(api2, obj6);
                        }
                        ((List) obj6).add(element3);
                        map = apis;
                        it6 = it4;
                        str2 = str;
                    } else {
                        throw new NullPointerException("null cannot be cast to non-null type kotlin.collections.MutableSet<com.ifpdos.udi.sdk.service.doc.base.Request.Handler>");
                    }
                }
                LinkedHashMap linkedHashMap7 = new LinkedHashMap(MapsKt.mapCapacity(apis.size()));
                Iterator it7 = apis.entrySet().iterator();
                while (it7.hasNext()) {
                    Map.Entry entry = (Map.Entry) it7.next();
                    Object key = entry.getKey();
                    Element element4 = (Element) entry.getKey();
                    ApiInfo apiInfo3 = (ApiInfo) entry.getValue();
                    LinkedHashMap linkedHashMap8 = new LinkedHashMap();
                    List list = (List) linkedHashMap5.get(element4.toString());
                    int i = 3;
                    if (list != null) {
                        Iterator it8 = list.iterator();
                        while (it8.hasNext()) {
                            Element element5 = (Element) it8.next();
                            Element receiver = element5.getEnclosingElement();
                            Intrinsics.checkNotNullExpressionValue(receiver, "receiver");
                            Object obj7 = linkedHashMap8.get(receiver);
                            if (obj7 == null) {
                                linkedHashMap3 = linkedHashMap5;
                                it2 = it7;
                                Element element6 = null;
                                ApiHandlerInfo apiHandlerInfo = new ApiHandlerInfo(element6, element6, i, element6);
                                linkedHashMap8.put(receiver, apiHandlerInfo);
                                obj7 = apiHandlerInfo;
                            } else {
                                linkedHashMap3 = linkedHashMap5;
                                it2 = it7;
                            }
                            ApiHandlerInfo apiHandlerInfo2 = (ApiHandlerInfo) obj7;
                            if (apiHandlerInfo2.getGetter() != null) {
                                StringBuilder sbAppend = new StringBuilder().append(receiver).append('.');
                                Element getter = apiHandlerInfo2.getGetter();
                                String string = sbAppend.append(getter != null ? getter.getSimpleName() : null).toString();
                                String string2 = new StringBuilder().append(receiver).append('.').append(element5.getSimpleName()).toString();
                                Messager messager4 = this.messager;
                                if (messager4 == null) {
                                    Intrinsics.throwUninitializedPropertyAccessException("messager");
                                    it3 = it8;
                                    messager4 = null;
                                } else {
                                    it3 = it8;
                                }
                                linkedHashMap4 = linkedHashMap7;
                                obj2 = key;
                                messager4.printMessage(Diagnostic.Kind.ERROR, apiInfo3.getUri() + " getter can't bound to " + string2 + " because is already bound to " + string);
                            } else {
                                linkedHashMap4 = linkedHashMap7;
                                obj2 = key;
                                it3 = it8;
                            }
                            apiHandlerInfo2.setGetter(element5);
                            it7 = it2;
                            it8 = it3;
                            linkedHashMap5 = linkedHashMap3;
                            linkedHashMap7 = linkedHashMap4;
                            key = obj2;
                            i = 3;
                        }
                        linkedHashMap = linkedHashMap7;
                        linkedHashMap2 = linkedHashMap5;
                        it = it7;
                        obj = key;
                        Unit unit = Unit.INSTANCE;
                    } else {
                        linkedHashMap = linkedHashMap7;
                        linkedHashMap2 = linkedHashMap5;
                        it = it7;
                        obj = key;
                    }
                    List<Element> list2 = (List) linkedHashMap6.get(element4.toString());
                    if (list2 != null) {
                        for (Element element7 : list2) {
                            Element receiver2 = element7.getEnclosingElement();
                            Intrinsics.checkNotNullExpressionValue(receiver2, "receiver");
                            Object apiHandlerInfo3 = linkedHashMap8.get(receiver2);
                            if (apiHandlerInfo3 == null) {
                                element = null;
                                apiHandlerInfo3 = new ApiHandlerInfo(element, element, 3, element);
                                linkedHashMap8.put(receiver2, apiHandlerInfo3);
                            } else {
                                element = null;
                            }
                            ApiHandlerInfo apiHandlerInfo4 = (ApiHandlerInfo) apiHandlerInfo3;
                            if (apiHandlerInfo4.getSetter() != null) {
                                StringBuilder sbAppend2 = new StringBuilder().append(receiver2).append('.');
                                Element setter = apiHandlerInfo4.getSetter();
                                String string3 = sbAppend2.append(setter != null ? setter.getSimpleName() : element).toString();
                                String string4 = new StringBuilder().append(receiver2).append('.').append(element7.getSimpleName()).toString();
                                Element element8 = this.messager;
                                if (element8 == null) {
                                    Intrinsics.throwUninitializedPropertyAccessException("messager");
                                    element8 = element;
                                }
                                element8.printMessage(Diagnostic.Kind.ERROR, apiInfo3.getUri() + " setter can't bound to " + string4 + " because is already bound to " + string3);
                            }
                            apiHandlerInfo4.setSetter(element7);
                        }
                        Unit unit2 = Unit.INSTANCE;
                    }
                    linkedHashMap7 = linkedHashMap;
                    linkedHashMap7.put(obj, linkedHashMap8);
                    it7 = it;
                    linkedHashMap5 = linkedHashMap2;
                }
                return linkedHashMap7;
            }
        }
    }

    /* JADX INFO: compiled from: ApiProcessor.kt */
    @Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\f\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0082\b\u0018\u00002\u00020\u0001B\u001d\u0012\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0003¢\u0006\u0002\u0010\u0005J\u000b\u0010\f\u001a\u0004\u0018\u00010\u0003HÆ\u0003J\u000b\u0010\r\u001a\u0004\u0018\u00010\u0003HÆ\u0003J!\u0010\u000e\u001a\u00020\u00002\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u00032\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0003HÆ\u0001J\u0013\u0010\u000f\u001a\u00020\u00102\b\u0010\u0011\u001a\u0004\u0018\u00010\u0001HÖ\u0003J\t\u0010\u0012\u001a\u00020\u0013HÖ\u0001J\t\u0010\u0014\u001a\u00020\u0015HÖ\u0001R\u001c\u0010\u0002\u001a\u0004\u0018\u00010\u0003X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0006\u0010\u0007\"\u0004\b\b\u0010\tR\u001c\u0010\u0004\u001a\u0004\u0018\u00010\u0003X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u0007\"\u0004\b\u000b\u0010\t¨\u0006\u0016"}, d2 = {"Lcom/ifpdos/udi/sdk/service/compile/ApiProcessor$ApiHandlerInfo;", "", "getter", "Ljavax/lang/model/element/Element;", "setter", "(Ljavax/lang/model/element/Element;Ljavax/lang/model/element/Element;)V", "getGetter", "()Ljavax/lang/model/element/Element;", "setGetter", "(Ljavax/lang/model/element/Element;)V", "getSetter", "setSetter", "component1", "component2", "copy", "equals", "", "other", "hashCode", "", "toString", "", "compile"}, k = 1, mv = {1, 6, 0}, xi = 48)
    private static final /* data */ class ApiHandlerInfo {
        private Element getter;
        private Element setter;

        /* JADX WARN: Illegal instructions before constructor call */
        public ApiHandlerInfo() {
            Element element = null;
            this(element, element, 3, element);
        }

        public static /* synthetic */ ApiHandlerInfo copy$default(ApiHandlerInfo apiHandlerInfo, Element element, Element element2, int i, Object obj) {
            if ((i & 1) != 0) {
                element = apiHandlerInfo.getter;
            }
            if ((i & 2) != 0) {
                element2 = apiHandlerInfo.setter;
            }
            return apiHandlerInfo.copy(element, element2);
        }

        /* JADX INFO: renamed from: component1, reason: from getter */
        public final Element getGetter() {
            return this.getter;
        }

        /* JADX INFO: renamed from: component2, reason: from getter */
        public final Element getSetter() {
            return this.setter;
        }

        public final ApiHandlerInfo copy(Element getter, Element setter) {
            return new ApiHandlerInfo(getter, setter);
        }

        public boolean equals(Object other) {
            if (this == other) {
                return true;
            }
            if (!(other instanceof ApiHandlerInfo)) {
                return false;
            }
            ApiHandlerInfo apiHandlerInfo = (ApiHandlerInfo) other;
            return Intrinsics.areEqual(this.getter, apiHandlerInfo.getter) && Intrinsics.areEqual(this.setter, apiHandlerInfo.setter);
        }

        public int hashCode() {
            Element element = this.getter;
            int iHashCode = (element == null ? 0 : element.hashCode()) * 31;
            Element element2 = this.setter;
            return iHashCode + (element2 != null ? element2.hashCode() : 0);
        }

        public String toString() {
            return "ApiHandlerInfo(getter=" + this.getter + ", setter=" + this.setter + ')';
        }

        public ApiHandlerInfo(Element element, Element element2) {
            this.getter = element;
            this.setter = element2;
        }

        public /* synthetic */ ApiHandlerInfo(Element element, Element element2, int i, DefaultConstructorMarker defaultConstructorMarker) {
            this((i & 1) != 0 ? null : element, (i & 2) != 0 ? null : element2);
        }

        public final Element getGetter() {
            return this.getter;
        }

        public final void setGetter(Element element) {
            this.getter = element;
        }

        public final Element getSetter() {
            return this.setter;
        }

        public final void setSetter(Element element) {
            this.setter = element;
        }
    }

    private final void genApi(String packageName, Map<Element, ApiInfo> allApiInfo, Set<? extends Element> getters, Set<? extends Element> setters) {
        for (Map.Entry<Element, Map<Element, ApiHandlerInfo>> entry : getApiReceivers(allApiInfo, getters, setters).entrySet()) {
            Element key = entry.getKey();
            Map<Element, ApiHandlerInfo> value = entry.getValue();
            ApiInfo apiInfo = allApiInfo.get(key);
            Intrinsics.checkNotNull(apiInfo);
            ApiInfo apiInfo2 = apiInfo;
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            for (Map.Entry<Element, ApiHandlerInfo> entry2 : value.entrySet()) {
                Element key2 = entry2.getKey();
                ApiHandlerInfo value2 = entry2.getValue();
                Request getterRequest = apiInfo2.getGetterRequest();
                if (getterRequest != null) {
                    arrayList.add(getRequestAdapterCode(value2.getGetter(), apiInfo2.getUri(), apiInfo2.getApiName() + "Api.GetterRequest", apiInfo2.getApiName() + "Api.GetterResponse", getterRequest, key2.toString()));
                }
                Request setterRequest = apiInfo2.getSetterRequest();
                if (setterRequest != null) {
                    arrayList2.add(getRequestAdapterCode(value2.getSetter(), apiInfo2.getUri(), apiInfo2.getApiName() + "Api.SetterRequest", apiInfo2.getApiName() + "Api.SetterResponse", setterRequest, key2.toString()));
                }
            }
            Map mapMutableMapOf = MapsKt.mutableMapOf(TuplesKt.to("package", packageName), TuplesKt.to("api", apiInfo2), TuplesKt.to("getterAdapters", arrayList), TuplesKt.to("setterAdapters", arrayList2), TuplesKt.to("receivers", value.entrySet().iterator()));
            Request getterRequest2 = apiInfo2.getGetterRequest();
            if (getterRequest2 != null) {
                mapMutableMapOf.put("getterRequest", genRequestCode("Getter", getterRequest2));
                mapMutableMapOf.put("getterResponse", genResponseCode("Getter", getterRequest2));
            }
            Request setterRequest2 = apiInfo2.getSetterRequest();
            if (setterRequest2 != null) {
                mapMutableMapOf.put("setterRequest", genRequestCode("Setter", setterRequest2));
                mapMutableMapOf.put("setterResponse", genResponseCode("Setter", setterRequest2));
            }
            if (apiInfo2.getNotify() != null) {
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                Request getterRequest3 = apiInfo2.getGetterRequest();
                if (getterRequest3 != null) {
                    linkedHashMap.putAll(getFieldsTypeMap(getterRequest3.getRequestClass()));
                }
                Request setterRequest3 = apiInfo2.getSetterRequest();
                if (setterRequest3 != null) {
                    linkedHashMap.putAll(getFieldsTypeMap(setterRequest3.getRequestClass()));
                }
                mapMutableMapOf.put("notifyParams", getNotifyFuncParams(apiInfo2.getUri().getMqttTopic(), linkedHashMap));
                mapMutableMapOf.put("notifyUri", getNotifyUri(apiInfo2.getUri().getMqttTopic(), linkedHashMap));
                Uri alias = apiInfo2.getAlias();
                if (alias != null) {
                    mapMutableMapOf.put("notifyAliasUri", getNotifyUri(alias.getMqttTopic(), linkedHashMap));
                }
            }
            File file = this.kotlinGenerated;
            if (file == null) {
                Intrinsics.throwUninitializedPropertyAccessException("kotlinGenerated");
                file = null;
            }
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(new File(file, key.getSimpleName() + "Api.kt")), Charsets.UTF_8);
            try {
                new DefaultMustacheFactory().compile(new StringReader(CodeTemplate.API), "code").execute(outputStreamWriter, mapMutableMapOf);
                Unit unit = Unit.INSTANCE;
                CloseableKt.closeFinally(outputStreamWriter, null);
            } finally {
            }
        }
    }

    private final Map<String, String> getFieldsTypeMap(String clazz) {
        List<IFieldWrapper> fields;
        String type;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        IClassWrapper rVar = this.classParser.parser(clazz);
        if (rVar != null && (fields = rVar.getFields(true)) != null) {
            for (IFieldWrapper iFieldWrapper : fields) {
                String name = iFieldWrapper.getName();
                if (Utils.INSTANCE.isBuildType(iFieldWrapper.getType())) {
                    type = Utils.INSTANCE.strTitleCase(iFieldWrapper.getType());
                } else {
                    type = iFieldWrapper.getType();
                }
                linkedHashMap.put(name, type);
            }
        }
        return linkedHashMap;
    }

    private final String getNotifyFuncParams(String uri, final Map<String, String> typeMap) {
        List listSplit$default = StringsKt.split$default((CharSequence) uri, new String[]{"/"}, false, 0, 6, (Object) null);
        ArrayList arrayList = new ArrayList();
        for (Object obj : listSplit$default) {
            if (StringsKt.startsWith$default((String) obj, "{", false, 2, (Object) null)) {
                arrayList.add(obj);
            }
        }
        String strJoinToString$default = CollectionsKt.joinToString$default(arrayList, ", ", null, null, 0, null, new Function1<String, CharSequence>() { // from class: com.ifpdos.udi.sdk.service.compile.ApiProcessor$getNotifyFuncParams$params$2
            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            {
                super(1);
            }

            @Override // kotlin.jvm.functions.Function1
            public final CharSequence invoke(String it) {
                Intrinsics.checkNotNullParameter(it, "it");
                CharSequence charSequenceSubSequence = it.subSequence(1, it.length() - 1);
                StringBuilder sbAppend = new StringBuilder().append((Object) charSequenceSubSequence).append(": ");
                String str = typeMap.get(charSequenceSubSequence);
                if (str == null) {
                    str = "String";
                }
                return sbAppend.append(str).toString();
            }
        }, 30, null);
        return strJoinToString$default.length() > 0 ? strJoinToString$default + ", " : strJoinToString$default;
    }

    private final String getNotifyUri(String uri, Map<String, String> typeMap) {
        List<String> listSplit$default = StringsKt.split$default((CharSequence) uri, new String[]{"/"}, false, 0, 6, (Object) null);
        ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(listSplit$default, 10));
        for (String str : listSplit$default) {
            if (StringsKt.startsWith$default(str, "{", false, 2, (Object) null)) {
                String strSubstring = str.substring(1, str.length() - 1);
                Intrinsics.checkNotNullExpressionValue(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
                String str2 = typeMap.get(strSubstring);
                if (str2 == null) {
                    str2 = "String";
                }
                if (Utils.INSTANCE.isBuildType(str2)) {
                    str = "${" + strSubstring + AbstractJsonLexerKt.END_OBJ;
                } else {
                    str = "${UdiCompileUtils.getJsonKey(" + strSubstring + ")}";
                }
            }
            arrayList.add(str);
        }
        return CollectionsKt.joinToString$default(arrayList, "/", null, null, 0, null, null, 62, null);
    }

    public boolean process(Set<? extends TypeElement> set, RoundEnvironment env) {
        try {
            return doProcess(env);
        } catch (Exception e) {
            StringWriter stringWriter = new StringWriter();
            e.printStackTrace(new PrintWriter((Writer) stringWriter, true));
            Messager messager = this.messager;
            if (messager == null) {
                Intrinsics.throwUninitializedPropertyAccessException("messager");
                messager = null;
            }
            messager.printMessage(Diagnostic.Kind.ERROR, stringWriter.toString());
            return true;
        }
    }

    private final Map<String, CommentDetails> getCommentFromDependentModules() {
        List listSplit$default;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        String str = (String) this.processingEnv.getOptions().get("udi.dependence.modules");
        List<String> listSplit$default2 = str != null ? StringsKt.split$default((CharSequence) str, new String[]{","}, false, 0, 6, (Object) null) : null;
        if (listSplit$default2 != null) {
            for (String str2 : listSplit$default2) {
                if (StringsKt.startsWith$default(str2, ":", false, 2, (Object) null)) {
                    String strSubstring = str2.substring(1);
                    Intrinsics.checkNotNullExpressionValue(strSubstring, "this as java.lang.String).substring(startIndex)");
                    listSplit$default = StringsKt.split$default((CharSequence) strSubstring, new String[]{":"}, false, 0, 6, (Object) null);
                } else {
                    listSplit$default = StringsKt.split$default((CharSequence) str2, new String[]{":"}, false, 0, 6, (Object) null);
                }
                File file = this.projectDir;
                if (file == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("projectDir");
                    file = null;
                }
                Object[] array = listSplit$default.toArray(new String[0]);
                if (array != null) {
                    String[] strArr = (String[]) array;
                    File fileSearchCodeFile = searchCodeFile(PROTOCOL_DEFINE_FILE, getChildFile(file, (String[]) Arrays.copyOf(strArr, strArr.length)), "src", "main");
                    if (fileSearchCodeFile != null) {
                        linkedHashMap.putAll(CommentParser.INSTANCE.parser(fileSearchCodeFile).getElementComments());
                    }
                } else {
                    throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
                }
            }
        }
        return linkedHashMap;
    }

    private final boolean doProcess(RoundEnvironment env) throws Exception {
        Class<?> cls;
        Object obj = this.processingEnv.getOptions().get(PARAM_KAPT_KOTLIN_GENERATED_OPTION);
        Intrinsics.checkNotNull(obj);
        this.kotlinGenerated = new File((String) obj);
        File docDir = getDocDir();
        Map<String, CommentDetails> commentFromDependentModules = getCommentFromDependentModules();
        Intrinsics.checkNotNull(env);
        Set<? extends Element> apis = env.getElementsAnnotatedWith(Api.class);
        if (apis.isEmpty()) {
            return true;
        }
        File fileSearchCodeFile = searchCodeFile(PROTOCOL_DEFINE_FILE, getCurrentModuleDir(), "src", "main");
        Intrinsics.checkNotNull(fileSearchCodeFile);
        Comment rVar = CommentParser.INSTANCE.parser(fileSearchCodeFile);
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        int i = 0;
        for (Object obj2 : rVar.getElementComments().keySet()) {
            int i2 = i + 1;
            if (i < 0) {
                CollectionsKt.throwIndexOverflow();
            }
            linkedHashMap.put((String) obj2, Integer.valueOf(i));
            i = i2;
        }
        Intrinsics.checkNotNullExpressionValue(apis, "apis");
        for (Element element : apis) {
            if (!linkedHashMap.containsKey(element.toString())) {
                linkedHashMap.put(element.toString(), Integer.valueOf(linkedHashMap.size()));
            }
        }
        Map<Element, ApiInfo> allApiInfo = getAllApiInfo(apis, linkedHashMap);
        CommentProvider commentProvider = this.commentProvider;
        if (commentProvider == null) {
            Intrinsics.throwUninitializedPropertyAccessException("commentProvider");
            commentProvider = null;
        }
        LinkedHashMap linkedHashMap2 = new LinkedHashMap();
        linkedHashMap2.putAll(commentFromDependentModules);
        linkedHashMap2.putAll(rVar.getElementComments());
        commentProvider.init(linkedHashMap2);
        String str = getPackage(fileSearchCodeFile);
        Set<? extends Element> getters = env.getElementsAnnotatedWith(GetterHandler.class);
        Set<? extends Element> setters = env.getElementsAnnotatedWith(SetterHandler.class);
        genOnlyNotifyApiBinder(str, allApiInfo.values());
        Intrinsics.checkNotNullExpressionValue(getters, "getters");
        Intrinsics.checkNotNullExpressionValue(setters, "setters");
        genApiBinder(str, getters, setters);
        genApi(str, allApiInfo, getters, setters);
        genUtilsCode(str);
        Collection<ApiInfo> collectionValues = allApiInfo.values();
        ArrayList arrayList = new ArrayList();
        for (Object obj3 : collectionValues) {
            if (((ApiInfo) obj3).getStaticCall()) {
                arrayList.add(obj3);
            }
        }
        genXml(arrayList);
        String str2 = (String) this.processingEnv.getOptions().get("udi.doc.generators");
        if (str2 == null) {
            str2 = "simple.SimpleDocGenerator";
        }
        for (String str3 : StringsKt.split$default((CharSequence) str2, new String[]{","}, false, 0, 6, (Object) null)) {
            try {
                cls = Class.forName("com.ifpdos.udi.sdk.service.doc." + str3);
            } catch (ClassNotFoundException unused) {
                cls = Class.forName(str3);
            }
            Object objNewInstance = cls.getConstructor(new Class[0]).newInstance(new Object[0]);
            if (objNewInstance == null) {
                throw new NullPointerException("null cannot be cast to non-null type com.ifpdos.udi.sdk.service.doc.base.IDocGenerator");
            }
            IDocGenerator iDocGenerator = (IDocGenerator) objNewInstance;
            List list = CollectionsKt.toList(allApiInfo.values());
            ArrayList arrayList2 = new ArrayList();
            for (Object obj4 : list) {
                if (!((ApiInfo) obj4).isHide()) {
                    arrayList2.add(obj4);
                }
            }
            iDocGenerator.genDoc(arrayList2, rVar.getDocumentComment(), this.classParser, docDir);
        }
        return false;
    }

    private final void genXml(Collection<ApiInfo> apiInfo) {
        Map mapMapOf = MapsKt.mapOf(TuplesKt.to("apis", apiInfo.iterator()));
        File fileSearchCodeFile = searchCodeFile(UDI_STATIC_API_XML_FILE, getCurrentModuleDir(), "src", "main");
        if (fileSearchCodeFile != null) {
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(fileSearchCodeFile), Charsets.UTF_8);
            try {
                new DefaultMustacheFactory().compile(new StringReader(CodeTemplate.API_XML), "code").execute(outputStreamWriter, mapMapOf);
                CloseableKt.closeFinally(outputStreamWriter, null);
            } catch (Throwable th) {
                try {
                    throw th;
                } catch (Throwable th2) {
                    CloseableKt.closeFinally(outputStreamWriter, th);
                    throw th2;
                }
            }
        }
    }

    private final void genUtilsCode(String packageName) {
        Map mapMutableMapOf = MapsKt.mutableMapOf(TuplesKt.to("package", packageName));
        File file = this.kotlinGenerated;
        if (file == null) {
            Intrinsics.throwUninitializedPropertyAccessException("kotlinGenerated");
            file = null;
        }
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(new File(file, "UdiCompileUtils.kt")), Charsets.UTF_8);
        try {
            new DefaultMustacheFactory().compile(new StringReader(CodeTemplate.UDI_COMPILE_UTILS), "code").execute(outputStreamWriter, mapMutableMapOf);
            CloseableKt.closeFinally(outputStreamWriter, null);
        } finally {
        }
    }

    private final File searchCodeFile(String fileName, File dir, String... children) {
        File file = new File(dir, fileName);
        if (file.exists()) {
            return file;
        }
        File[] fileArrListFiles = getChildFile(dir, (String[]) Arrays.copyOf(children, children.length)).listFiles();
        if (fileArrListFiles == null) {
            return null;
        }
        for (File it : fileArrListFiles) {
            Intrinsics.checkNotNullExpressionValue(it, "it");
            File fileSearchCodeFile = searchCodeFile(fileName, it, new String[0]);
            if (fileSearchCodeFile != null) {
                return fileSearchCodeFile;
            }
        }
        return null;
    }

    private final String getPackage(File srcProtocolDefine) {
        ArrayList arrayList = new ArrayList();
        for (File parentFile = srcProtocolDefine.getParentFile(); !Intrinsics.areEqual(parentFile.getName(), "java") && !Intrinsics.areEqual(parentFile.getName(), "kotlin"); parentFile = parentFile.getParentFile()) {
            String name = parentFile.getName();
            Intrinsics.checkNotNullExpressionValue(name, "dir.name");
            arrayList.add(0, name);
        }
        return CollectionsKt.joinToString$default(arrayList, ".", null, null, 0, null, null, 62, null);
    }

    private final Collection<ApiInfo> getOnlyNotifyApi(Collection<ApiInfo> apis) {
        ArrayList arrayList = new ArrayList();
        for (Object obj : apis) {
            ApiInfo apiInfo = (ApiInfo) obj;
            if (apiInfo.getSetterRequest() == null && apiInfo.getGetterRequest() == null && apiInfo.getNotify() != null) {
                arrayList.add(obj);
            }
        }
        return arrayList;
    }

    private final void genOnlyNotifyApiBinder(String packageName, Collection<ApiInfo> apis) {
        genCode(CodeTemplate.ONLY_NOTIFY_API_BINDER, MapsKt.mapOf(TuplesKt.to("package", packageName), TuplesKt.to("apis", getOnlyNotifyApi(apis))), "OnlyNotifyApiBinder.kt");
    }

    private final void genApiBinder(String packageName, Set<? extends Element> getters, Set<? extends Element> setters) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        for (Element element : getters) {
            Annotation annotation = element.getAnnotation(GetterHandler.class);
            Intrinsics.checkNotNullExpressionValue(annotation, "it.getAnnotation(GetterHandler::class.java)");
            String api = getApi((GetterHandler) annotation);
            String string = element.getEnclosingElement().toString();
            Object obj = linkedHashMap.get(string);
            if (obj == null) {
                obj = (List) new ArrayList();
                linkedHashMap.put(string, obj);
            }
            ((List) obj).add(api);
        }
        for (Element element2 : setters) {
            Annotation annotation2 = element2.getAnnotation(SetterHandler.class);
            Intrinsics.checkNotNullExpressionValue(annotation2, "it.getAnnotation(SetterHandler::class.java)");
            String api2 = getApi((SetterHandler) annotation2);
            String string2 = element2.getEnclosingElement().toString();
            Object obj2 = linkedHashMap.get(string2);
            if (obj2 == null) {
                obj2 = (List) new ArrayList();
                linkedHashMap.put(string2, obj2);
            }
            ((List) obj2).add(api2);
        }
        genCode(CodeTemplate.API_BINDER, MapsKt.mapOf(TuplesKt.to("package", packageName), TuplesKt.to("receivers", linkedHashMap.entrySet().iterator())), "ApiBinder.kt");
    }

    private final String getNotify(Api api) {
        String strSubstring;
        String string = api.toString();
        String str = string;
        int iIndexOf$default = StringsKt.indexOf$default((CharSequence) str, "notice=", 0, false, 6, (Object) null) + "notice=".length();
        int iIndexOf$default2 = StringsKt.indexOf$default((CharSequence) str, ",", iIndexOf$default, false, 4, (Object) null);
        if (iIndexOf$default != iIndexOf$default2) {
            strSubstring = string.substring(iIndexOf$default, iIndexOf$default2);
            Intrinsics.checkNotNullExpressionValue(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
        } else {
            strSubstring = null;
        }
        String strRemoveClassSuffix = strSubstring != null ? Utils.INSTANCE.removeClassSuffix(strSubstring) : null;
        if (Intrinsics.areEqual(Utils.NO_NOTIFY, strRemoveClassSuffix)) {
            return null;
        }
        return strRemoveClassSuffix;
    }

    private final boolean isProtocolInterface(TypeMirror type) {
        return StringsKt.startsWith$default(type.toString(), "com.ifpdos.udi.sdk.service.sdk.protocol.IProtocol", false, 2, (Object) null);
    }

    private final boolean isOnlyGetterProtocolInterface(TypeMirror type) {
        return StringsKt.startsWith$default(type.toString(), "com.ifpdos.udi.sdk.service.sdk.protocol.IOnlyGetterProtocol", false, 2, (Object) null);
    }

    private final boolean isOnlySetterProtocolInterface(TypeMirror type) {
        return StringsKt.startsWith$default(type.toString(), "com.ifpdos.udi.sdk.service.sdk.protocol.IOnlySetterProtocol", false, 2, (Object) null);
    }

    private final boolean isNotifyProtocolInterface(TypeMirror type) {
        return StringsKt.startsWith$default(type.toString(), "com.ifpdos.udi.sdk.service.sdk.protocol.INotifyProtocol", false, 2, (Object) null);
    }

    private final List<String> getGenericParameterTypes(Element element) throws Exception {
        String string;
        Object obj = ((TypeElement) element).getInterfaces().get(0);
        if (obj == null) {
            throw new NullPointerException("null cannot be cast to non-null type javax.lang.model.type.DeclaredType");
        }
        DeclaredType declaredType = (DeclaredType) obj;
        List typeArguments = declaredType.getTypeArguments();
        Intrinsics.checkNotNullExpressionValue(typeArguments, "protocol.typeArguments");
        List<TypeMirror> list = typeArguments;
        ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(list, 10));
        for (TypeMirror typeMirror : list) {
            if (StringsKt.startsWith$default(typeMirror.toString(), "java.util.List", false, 2, (Object) null)) {
                string = "List<" + Utils.INSTANCE.getTypeByList(typeMirror.toString()) + Typography.greater;
            } else {
                string = typeMirror.toString();
            }
            arrayList.add(string);
        }
        ArrayList arrayList2 = arrayList;
        TypeMirror typeMirror2 = (TypeMirror) declaredType;
        if (isProtocolInterface(typeMirror2)) {
            return arrayList2;
        }
        if (isOnlySetterProtocolInterface(typeMirror2)) {
            return CollectionsKt.plus((Collection) CollectionsKt.listOf((Object[]) new String[]{Utils.EMPTY_BODY, Utils.EMPTY_BODY}), (Iterable) arrayList2);
        }
        if (isOnlyGetterProtocolInterface(typeMirror2)) {
            return CollectionsKt.plus((Collection) arrayList2, (Iterable) CollectionsKt.listOf((Object[]) new String[]{Utils.EMPTY_BODY, Utils.EMPTY_BODY}));
        }
        if (isNotifyProtocolInterface(typeMirror2)) {
            return CollectionsKt.listOf((Object[]) new String[]{Utils.EMPTY_BODY, Utils.EMPTY_BODY, Utils.EMPTY_BODY, Utils.EMPTY_BODY});
        }
        throw new Exception(element + " is not IProtocol");
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0080 A[LOOP:1: B:17:0x007a->B:19:0x0080, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0093  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x00bb  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x00c2  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x00ec  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x00fc  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0111  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private final java.util.Map<javax.lang.model.element.Element, com.ifpdos.udi.sdk.service.doc.base.ApiInfo> getAllApiInfo(java.util.Set<? extends javax.lang.model.element.Element> r23, final java.util.Map<java.lang.String, java.lang.Integer> r24) throws java.lang.Exception {
        /*
            Method dump skipped, instruction units count: 392
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ifpdos.udi.sdk.service.compile.ApiProcessor.getAllApiInfo(java.util.Set, java.util.Map):java.util.Map");
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX INFO: renamed from: getAllApiInfo$lambda-42, reason: not valid java name */
    public static final int m206getAllApiInfo$lambda42(Map orders, Element element, Element element2) {
        Intrinsics.checkNotNullParameter(orders, "$orders");
        Object obj = orders.get(element.toString());
        Intrinsics.checkNotNull(obj);
        int iIntValue = ((Number) obj).intValue();
        Object obj2 = orders.get(element2.toString());
        Intrinsics.checkNotNull(obj2);
        return iIntValue > ((Number) obj2).intValue() ? 1 : -1;
    }

    private final String covertToKotlinType(String type) {
        return StringsKt.replace$default(StringsKt.replace$default(StringsKt.replace$default(StringsKt.replace$default(StringsKt.replace$default(StringsKt.replace$default(type, "java.lang.Integer", "Int", false, 4, (Object) null), "java.lang.Long", "Long", false, 4, (Object) null), "java.lang.Float", "Float", false, 4, (Object) null), "java.lang.Double", "Double", false, 4, (Object) null), "java.lang.Boolean", "Boolean", false, 4, (Object) null), "java.lang.String", "String", false, 4, (Object) null);
    }

    private final String genRequestCode(String type, Request request) {
        Map mapMutableMapOf = MapsKt.mutableMapOf(TuplesKt.to(SeewoIntent.KEY_FILE_TYPE, type));
        if (!Intrinsics.areEqual(Utils.EMPTY_BODY, request.getRequestClass())) {
            mapMutableMapOf.put("requestClass", request.getRequestClass());
        }
        return genCode(CodeTemplate.REQUEST, mapMutableMapOf);
    }

    private final String genResponseCode(String type, Request response) {
        Map mapMutableMapOf = MapsKt.mutableMapOf(TuplesKt.to(SeewoIntent.KEY_FILE_TYPE, type));
        if (!Intrinsics.areEqual(Utils.EMPTY_BODY, response.getResponseClass())) {
            mapMutableMapOf.put("responseClass", response.getResponseClass());
        }
        return genCode(CodeTemplate.RESPONSE, mapMutableMapOf);
    }

    private final String getRequestAdapterCode(Element element, Uri uri, String wrapperRequestClass, String wrapperResponseClass, Request request, String receiverClass) {
        if (element == null) {
            return "";
        }
        Map mapMutableMapOf = MapsKt.mutableMapOf(TuplesKt.to("funcName", element.getSimpleName()), TuplesKt.to("receiverName", element.getEnclosingElement().getSimpleName()), TuplesKt.to("wrapperRequestClass", wrapperRequestClass), TuplesKt.to("wrapperResponseClass", wrapperResponseClass), TuplesKt.to("request", request), TuplesKt.to("receiverClass", receiverClass));
        ExecutableElement executableElement = (ExecutableElement) element;
        List parameters = executableElement.getParameters();
        if (parameters.size() > 0) {
            String string = ((VariableElement) parameters.get(0)).asType().toString();
            if (Intrinsics.areEqual(string, "error.NonExistentClass")) {
                mapMutableMapOf.put("apiParam", true);
            } else if (StringsKt.startsWith$default(string, Utils.UDI_REQUEST, false, 2, (Object) null)) {
                mapMutableMapOf.put("requestParam", true);
            } else {
                mapMutableMapOf.put("bodyParam", true);
            }
        } else {
            mapMutableMapOf.put("noParam", true);
        }
        mapMutableMapOf.put("noReturn", Boolean.valueOf(executableElement.getReturnType().getKind() == TypeKind.VOID));
        if (Intrinsics.areEqual(Utils.EMPTY_BODY, request.getRequestClass())) {
            return genCode(CodeTemplate.EMPTY_BODY_REQUEST_ADAPTER, mapMutableMapOf);
        }
        if (uri.getQuery() != null || uri.isRestfulUri()) {
            if (uri.getQuery() != null) {
                mapMutableMapOf.put("queryKeys", getJsonFromUriQueryPart(uri, request.getRequestClass()));
            }
            if (uri.isRestfulUri()) {
                mapMutableMapOf.put("restfulKeys", getUriParamsCodeFromRestfulUri(uri, request.getRequestClass()));
            }
            return genCode(CodeTemplate.URL_URI_REQUEST_ADAPTER, mapMutableMapOf);
        }
        return genCode(CodeTemplate.NORMAL_REQUEST_ADAPTER, mapMutableMapOf);
    }

    private final String genCode(String template, Object scope) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(byteArrayOutputStream);
        new DefaultMustacheFactory().compile(new StringReader(template), "code").execute(outputStreamWriter, scope);
        outputStreamWriter.flush();
        String string = byteArrayOutputStream.toString();
        Intrinsics.checkNotNullExpressionValue(string, "out.toString()");
        return string;
    }

    private final void genCode(String template, Object scope, String codeFileName) {
        File file = this.kotlinGenerated;
        if (file == null) {
            Intrinsics.throwUninitializedPropertyAccessException("kotlinGenerated");
            file = null;
        }
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(new File(file, codeFileName)), Charsets.UTF_8);
        try {
            new DefaultMustacheFactory().compile(new StringReader(template), "code").execute(outputStreamWriter, scope);
            CloseableKt.closeFinally(outputStreamWriter, null);
        } finally {
        }
    }

    private final String getJsonFromUriQueryPart(Uri uri, String requestClass) {
        Pair pair;
        List listListOf = CollectionsKt.listOf((Object[]) new String[]{"String", "Int", "Integer", "Float", "Double", "Boolean"});
        IClassWrapper rVar = this.classParser.parser(requestClass);
        if (rVar == null) {
            throw new RuntimeException("parser " + requestClass + " failed");
        }
        List<IFieldWrapper> fields = rVar.getFields(true);
        ArrayList arrayList = new ArrayList();
        for (Object obj : fields) {
            String query = uri.getQuery();
            Intrinsics.checkNotNull(query);
            if (StringsKt.contains$default((CharSequence) query, (CharSequence) (((IFieldWrapper) obj).getName() + "={}"), false, 2, (Object) null)) {
                arrayList.add(obj);
            }
        }
        ArrayList<IFieldWrapper> arrayList2 = arrayList;
        LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt.coerceAtLeast(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(arrayList2, 10)), 16));
        for (IFieldWrapper iFieldWrapper : arrayList2) {
            String strStrTitleCase = Utils.INSTANCE.strTitleCase(iFieldWrapper.getType());
            IClassWrapper rVar2 = this.classParser.parser(iFieldWrapper.getType());
            if (rVar2 != null && rVar2.isEnum()) {
                pair = new Pair(iFieldWrapper.getName(), iFieldWrapper.getType());
            } else {
                if (!listListOf.contains(strStrTitleCase)) {
                    throw new RuntimeException(uri + " : " + iFieldWrapper.getName() + " param has a not support type : " + strStrTitleCase);
                }
                pair = new Pair(iFieldWrapper.getName(), strStrTitleCase);
            }
            linkedHashMap.put(pair.getFirst(), pair.getSecond());
        }
        StringBuilder sb = new StringBuilder();
        sb.append("listOf<Pair<String, String>>(");
        String query2 = uri.getQuery();
        Intrinsics.checkNotNull(query2);
        Iterator it = StringsKt.split$default((CharSequence) query2, new String[]{"&"}, false, 0, 6, (Object) null).iterator();
        while (it.hasNext()) {
            List listSplit$default = StringsKt.split$default((CharSequence) it.next(), new String[]{"="}, false, 0, 6, (Object) null);
            if (listSplit$default.size() == 2 && Intrinsics.areEqual(listSplit$default.get(1), "{}")) {
                sb.append("Pair(\"" + ((String) listSplit$default.get(0)) + "\", \"" + ((String) linkedHashMap.get(listSplit$default.get(0))) + "\"),");
            }
        }
        return sb.substring(0, sb.length() - 1) + ')';
    }

    private final String getUriParamsCodeFromRestfulUri(Uri uri, String requestClass) {
        Pair pair;
        List listListOf = CollectionsKt.listOf((Object[]) new String[]{"String", "Int", "Integer", "Float", "Double", "Boolean"});
        IClassWrapper rVar = this.classParser.parser(requestClass);
        if (rVar == null) {
            throw new RuntimeException("parser " + requestClass + " failed");
        }
        List listSplit$default = StringsKt.split$default((CharSequence) uri.getMqttTopic(), new String[]{"/"}, false, 0, 6, (Object) null);
        ArrayList arrayList = new ArrayList();
        for (Object obj : listSplit$default) {
            String str = (String) obj;
            if (StringsKt.startsWith$default(str, "{", false, 2, (Object) null) && StringsKt.endsWith$default(str, "}", false, 2, (Object) null)) {
                arrayList.add(obj);
            }
        }
        ArrayList<String> arrayList2 = arrayList;
        ArrayList arrayList3 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList2, 10));
        for (String str2 : arrayList2) {
            String strSubstring = str2.substring(1, str2.length() - 1);
            Intrinsics.checkNotNullExpressionValue(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
            arrayList3.add(strSubstring);
        }
        ArrayList arrayList4 = arrayList3;
        List<IFieldWrapper> fields = rVar.getFields(true);
        ArrayList arrayList5 = new ArrayList();
        for (Object obj2 : fields) {
            if (arrayList4.contains(((IFieldWrapper) obj2).getName())) {
                arrayList5.add(obj2);
            }
        }
        ArrayList<IFieldWrapper> arrayList6 = arrayList5;
        LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt.coerceAtLeast(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(arrayList6, 10)), 16));
        for (IFieldWrapper iFieldWrapper : arrayList6) {
            String strStrTitleCase = Utils.INSTANCE.strTitleCase(iFieldWrapper.getType());
            IClassWrapper rVar2 = this.classParser.parser(iFieldWrapper.getType());
            if (rVar2 != null && rVar2.isEnum()) {
                pair = new Pair(iFieldWrapper.getName(), iFieldWrapper.getType());
            } else {
                if (!listListOf.contains(strStrTitleCase)) {
                    throw new RuntimeException(uri + " : " + iFieldWrapper.getName() + " param has a not support type : " + strStrTitleCase);
                }
                pair = new Pair(iFieldWrapper.getName(), strStrTitleCase);
            }
            linkedHashMap.put(pair.getFirst(), pair.getSecond());
        }
        StringBuilder sb = new StringBuilder();
        sb.append("mapOf<String, Pair<String, String>> (");
        int i = 0;
        for (Object obj3 : StringsKt.split$default((CharSequence) uri.getMqttTopic(), new String[]{"/"}, false, 0, 6, (Object) null)) {
            int i2 = i + 1;
            if (i < 0) {
                CollectionsKt.throwIndexOverflow();
            }
            String str3 = (String) obj3;
            if (StringsKt.startsWith$default(str3, "{", false, 2, (Object) null) & StringsKt.endsWith$default(str3, "}", false, 2, (Object) null)) {
                String string = str3.subSequence(1, str3.length() - 1).toString();
                sb.append("\"" + string + "\" to Pair(parts[" + i + "], \"" + ((String) linkedHashMap.get(string)) + "\"),");
            }
            i = i2;
        }
        sb.replace(sb.length() - 1, sb.length(), ")");
        String string2 = sb.toString();
        Intrinsics.checkNotNullExpressionValue(string2, "codeBuilder.toString()");
        return string2;
    }

    public final String getApi(GetterHandler handler) {
        Intrinsics.checkNotNullParameter(handler, "handler");
        String string = handler.toString();
        int iLastIndexOf$default = StringsKt.lastIndexOf$default((CharSequence) string, "=", 0, false, 6, (Object) null) + 1;
        int length = string.length() - 1;
        Utils utils = Utils.INSTANCE;
        String strSubstring = string.substring(iLastIndexOf$default, length);
        Intrinsics.checkNotNullExpressionValue(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
        return utils.removeClassSuffix(strSubstring);
    }

    public final String getApi(SetterHandler handler) {
        Intrinsics.checkNotNullParameter(handler, "handler");
        String string = handler.toString();
        int iLastIndexOf$default = StringsKt.lastIndexOf$default((CharSequence) string, "=", 0, false, 6, (Object) null) + 1;
        int length = string.length() - 1;
        Utils utils = Utils.INSTANCE;
        String strSubstring = string.substring(iLastIndexOf$default, length);
        Intrinsics.checkNotNullExpressionValue(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
        return utils.removeClassSuffix(strSubstring);
    }

    private final File getChildFile(File dir, String... children) {
        int length = children.length;
        int i = 0;
        while (i < length) {
            File file = new File(dir, children[i]);
            i++;
            dir = file;
        }
        return dir;
    }
}
