/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.util.Functions
 *  com.l7tech.util.Functions$Binary
 */
package com.l7tech.server.communityschemas;

import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.server.communityschemas.SchemaManagerImpl;
import com.l7tech.server.communityschemas.SchemaSourceResolver;
import com.l7tech.server.communityschemas.m;
import com.l7tech.util.Functions;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

final class l
implements SchemaSourceResolver {
    private final Map<String, SchemaManagerImpl.SchemaResource> a;
    private final Map<String, Set<SchemaManagerImpl.SchemaResource>> b;
    private static final String[] c;

    private l(Map<String, SchemaManagerImpl.SchemaResource> map, Map<String, Set<SchemaManagerImpl.SchemaResource>> map2) {
        this.a = map;
        this.b = map2;
    }

    @Override
    public String getId() {
        return c[1];
    }

    @Override
    public boolean isTransient() {
        return false;
    }

    @Override
    public boolean isRemote() {
        return false;
    }

    @Override
    public SchemaSourceResolver.SchemaSource getSchemaByTargetNamespace(Audit audit, String string) throws IOException {
        SchemaSourceResolver.SchemaSource schemaSource;
        block8: {
            block6: {
                Set<SchemaManagerImpl.SchemaResource> set;
                block7: {
                    String string2;
                    Map<String, Set<SchemaManagerImpl.SchemaResource>> map;
                    try {
                        map = this.b;
                        string2 = string == null ? "" : string;
                    }
                    catch (IOException iOException) {
                        throw l.a(iOException);
                    }
                    set = map.get(string2);
                    try {
                        try {
                            if (set == null || set.isEmpty()) break block6;
                        }
                        catch (IOException iOException) {
                            throw l.a(iOException);
                        }
                        if (set.size() != 1) break block7;
                    }
                    catch (IOException iOException) {
                        throw l.a(iOException);
                    }
                    schemaSource = this.a(set.iterator().next());
                    break block8;
                }
                Set set2 = (Set)Functions.reduce(set, new TreeSet(), (Functions.Binary)new m(this));
                throw new IOException(c[0] + String.valueOf(set2));
            }
            schemaSource = null;
        }
        return schemaSource;
    }

    @Override
    public SchemaSourceResolver.SchemaSource getSchemaByUri(Audit audit, String string) {
        SchemaManagerImpl.SchemaResource schemaResource = this.a.get(string);
        return schemaResource != null ? this.a(schemaResource) : null;
    }

    @Override
    public void refreshSchemaByUri(Audit audit, String string) {
    }

    @Override
    public void registerInvalidationListener(SchemaSourceResolver.SchemaInvalidationListener schemaInvalidationListener) {
    }

    private SchemaSourceResolver.SchemaSource a(SchemaManagerImpl.SchemaResource schemaResource) {
        return new SchemaSourceResolver.DefaultSchemaSource(schemaResource.getUri(), schemaResource.getContent(), this);
    }

    private static IOException a(IOException iOException) {
        return iOException;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "\u0011Ksx>0e9\u001elo?%d=M?j85g8\u001eyc%`}=Lxi#`g=Sz\u007f'!j9\u0012?\u007f.3}9S?e3%g(Wye22z|_miw\u0013\u000e[xe$4l.[{,\u0005%z3Rii%";
        int n3 = "\u0011Ksx>0e9\u001elo?%d=M?j85g8\u001eyc%`}=Lxi#`g=Sz\u007f'!j9\u0012?\u007f.3}9S?e3%g(Wye22z|_miw\u0013\u000e[xe$4l.[{,\u0005%z3Rii%".length();
        int n4 = 68;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = l.a(48, l.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                c = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x39);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 108;
                    case 1 -> 14;
                    case 2 -> 47;
                    case 3 -> 60;
                    case 4 -> 103;
                    case 5 -> 112;
                    default -> 57;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

