package k1;

import com.mstar.android.samba.OnRecvMsg;
import com.mstar.android.tv.TvLanguage;
import e1.AbstractC0453a;
import e1.C0454b;
import f1.AbstractC0469f;
import g1.C0493a;
import g1.C0494b;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import l1.C0622e;
import okhttp3.HttpUrl;

/* JADX INFO: loaded from: classes.dex */
public class W extends URLConnection implements U {

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    static final int f4721k0 = 46;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    static final int f4722l0 = 1472;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    static C0622e f4723m0 = C0622e.a();

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    static long f4724n0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    static boolean f4725o0;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    protected static C0586d f4726p0;

    /* JADX INFO: renamed from: H, reason: collision with root package name */
    private long f4727H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    private long f4728I;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    private long f4729L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    private boolean f4730M;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    private int f4731Q;

    /* JADX INFO: renamed from: Z, reason: collision with root package name */
    private C0603u f4732Z;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    private C0587e f4733a0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private String f4734b;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    C0599q f4735b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    f0 f4736c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    String f4737d0;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    int f4738e0;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    int f4739f0;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private String f4740g;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    boolean f4741g0;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    int f4742h0;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    C0454b[] f4743i0;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    int f4744j0;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private long f4745r;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private long f4746x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    private int f4747y;

    static {
        try {
            String str = AbstractC0453a.f3808c;
        } catch (ClassNotFoundException e2) {
            e2.printStackTrace();
        }
        f4724n0 = AbstractC0453a.f("jcifs.smb.client.attrExpirationPeriod", 5000L);
        f4725o0 = AbstractC0453a.a("jcifs.smb.client.ignoreCopyToException", true);
        f4726p0 = new C0586d();
    }

    public W(String str) {
        this(new URL((URL) null, str, C0590h.f4881a));
    }

    static String Q(String str, String str2) {
        char[] charArray = str.toCharArray();
        int i2 = 0;
        int i3 = 0;
        for (int i4 = 0; i4 < charArray.length; i4++) {
            char c2 = charArray[i4];
            if (c2 == '&') {
                if (i2 > i3 && new String(charArray, i3, i2 - i3).equalsIgnoreCase(str2)) {
                    int i5 = i2 + 1;
                    return new String(charArray, i5, i4 - i5);
                }
                i3 = i4 + 1;
            } else if (c2 == '=') {
                i2 = i4;
            }
        }
        if (i2 <= i3 || !new String(charArray, i3, i2 - i3).equalsIgnoreCase(str2)) {
            return null;
        }
        int i6 = i2 + 1;
        return new String(charArray, i6, charArray.length - i6);
    }

    private C0603u a() {
        if (this.f4732Z == null) {
            this.f4732Z = new C0603u();
        }
        return this.f4732Z;
    }

    boolean A() {
        return this.f4744j0 < this.f4743i0.length;
    }

    boolean B() {
        f0 f0Var = this.f4736c0;
        return f0Var != null && f0Var.f4865a == 2;
    }

    public boolean C() {
        if (z().length() == 1) {
            return true;
        }
        return p() && (this.f4747y & 16) == 16;
    }

    public boolean D() throws V {
        if (z().length() == 1) {
            return false;
        }
        p();
        return (this.f4747y & 16) == 0;
    }

    public boolean E() throws V {
        if (this.f4740g == null) {
            return false;
        }
        if (z().length() == 1) {
            return this.f4740g.endsWith("$");
        }
        p();
        return (this.f4747y & 2) == 2;
    }

    boolean F() {
        return this.f4741g0 && B() && this.f4742h0 == this.f4736c0.f4873i;
    }

    boolean G() {
        int iS;
        if (this.f4739f0 == 2 || ((URLConnection) this).url.getHost().length() == 0) {
            this.f4739f0 = 2;
            return true;
        }
        z();
        if (this.f4740g != null) {
            return false;
        }
        C0454b c0454bQ = q();
        if ((c0454bQ.b() instanceof i1.g) && ((iS = ((i1.g) c0454bQ.b()).s()) == 29 || iS == 27)) {
            this.f4739f0 = 2;
            return true;
        }
        this.f4739f0 = 4;
        return false;
    }

    public long H() throws V {
        if (z().length() <= 1) {
            return 0L;
        }
        p();
        return this.f4746x;
    }

    public long I() {
        if (this.f4729L > System.currentTimeMillis()) {
            return this.f4728I;
        }
        if (y() == 8) {
            m0 m0Var = new m0(1);
            T(new l0(1), m0Var);
            this.f4728I = m0Var.f4944N0.a();
        } else if (z().length() <= 1 || this.f4739f0 == 16) {
            this.f4728I = 0L;
        } else {
            this.f4728I = R(z(), TvLanguage.KONKANI).b();
        }
        this.f4729L = System.currentTimeMillis() + f4724n0;
        return this.f4728I;
    }

    public String[] J() {
        return K("*", 22, null, null);
    }

    String[] K(String str, int i2, a0 a0Var, X x2) throws V {
        ArrayList arrayList = new ArrayList();
        j(arrayList, false, str, i2, a0Var, x2);
        return (String[]) arrayList.toArray(new String[arrayList.size()]);
    }

    public W[] L() {
        return M("*", 22, null, null);
    }

    W[] M(String str, int i2, a0 a0Var, X x2) throws V {
        ArrayList arrayList = new ArrayList();
        j(arrayList, true, str, i2, a0Var, x2);
        return (W[]) arrayList.toArray(new W[arrayList.size()]);
    }

    void N(int i2, int i3, int i4, int i5) {
        if (F()) {
            return;
        }
        this.f4738e0 = O(i2, i3, i4, i5);
        this.f4741g0 = true;
        this.f4742h0 = this.f4736c0.f4873i;
    }

    int O(int i2, int i3, int i4, int i5) {
        g();
        if (C0622e.f5384g >= 3) {
            f4723m0.println("open0: " + this.f4737d0);
        }
        if (!this.f4736c0.f4870f.f4790h.u(16)) {
            C0567D c0567d = new C0567D();
            T(new C0566C(this.f4737d0, i3, i2, null), c0567d);
            return c0567d.f4571t0;
        }
        C0608z c0608z = new C0608z();
        C0607y c0607y = new C0607y(this.f4737d0, i2, i3, this.f4731Q, i4, i5, null);
        if (this instanceof b0) {
            c0607y.f5051C0 |= 22;
            c0607y.f5052D0 |= 131072;
            c0608z.f5070G0 = true;
        }
        T(c0607y, c0608z);
        int i6 = c0608z.f5072u0;
        this.f4747y = c0608z.f5074w0 & 32767;
        this.f4727H = System.currentTimeMillis() + f4724n0;
        this.f4730M = true;
        return i6;
    }

    protected boolean P(String str, String str2) {
        int iLastIndexOf = str.lastIndexOf(47);
        int iLastIndexOf2 = str2.lastIndexOf(47);
        int length = str.length() - iLastIndexOf;
        int length2 = str2.length() - iLastIndexOf2;
        if (length > 1 && str.charAt(iLastIndexOf + 1) == '.') {
            return true;
        }
        if (length2 <= 1 || str2.charAt(iLastIndexOf2 + 1) != '.') {
            return length == length2 && str.regionMatches(true, iLastIndexOf, str2, iLastIndexOf2, length);
        }
        return true;
    }

    InterfaceC0591i R(String str, int i2) {
        g();
        if (C0622e.f5384g >= 3) {
            f4723m0.println("queryPath: " + str);
        }
        if (this.f4736c0.f4870f.f4790h.u(16)) {
            o0 o0Var = new o0(i2);
            T(new n0(str, i2), o0Var);
            return o0Var.f4954N0;
        }
        C0569F c0569f = new C0569F(((long) (this.f4736c0.f4870f.f4790h.f4835k0.f4857n * 1000)) * 60);
        T(new C0568E(str), c0569f);
        return c0569f;
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x003b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void S(k1.AbstractC0600r r9) throws k1.V {
        /*
            Method dump skipped, instruction units count: 318
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: k1.W.S(k1.r):void");
    }

    void T(AbstractC0600r abstractC0600r, AbstractC0600r abstractC0600r2) {
        while (true) {
            S(abstractC0600r);
            try {
                this.f4736c0.b(abstractC0600r, abstractC0600r2);
                return;
            } catch (C0587e e2) {
                if (e2.f4809M) {
                    throw e2;
                }
                abstractC0600r.t();
            }
        }
    }

    public boolean b() {
        if (y() == 16) {
            return true;
        }
        return p();
    }

    public boolean c() {
        if (y() == 16) {
            return true;
        }
        return p() && (this.f4747y & 1) == 0;
    }

    @Override // java.net.URLConnection
    public void connect() throws UnknownHostException, V {
        if (B()) {
            f0 f0Var = this.f4736c0;
            if (f0Var.f4870f.f4790h.f4843s0 == null) {
                f0Var.d(true);
            }
        }
        if (B()) {
            return;
        }
        z();
        r();
        while (true) {
            try {
                h();
                return;
            } catch (C0602t e2) {
                throw e2;
            } catch (V e3) {
                if (t() == null) {
                    throw e3;
                }
                if (C0622e.f5384g >= 3) {
                    e3.printStackTrace(f4723m0);
                }
            }
        }
    }

    void d() {
        f(0L);
    }

    void e(int i2, long j2) {
        if (C0622e.f5384g >= 3) {
            f4723m0.println("close: " + i2);
        }
        T(new C0604v(i2, j2), a());
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof W)) {
            return false;
        }
        W w2 = (W) obj;
        if (this == w2) {
            return true;
        }
        if (!P(((URLConnection) this).url.getPath(), ((URLConnection) w2).url.getPath())) {
            return false;
        }
        z();
        w2.z();
        if (!this.f4734b.equalsIgnoreCase(w2.f4734b)) {
            return false;
        }
        try {
            return q().equals(w2.q());
        } catch (UnknownHostException unused) {
            return w().equalsIgnoreCase(w2.w());
        }
    }

    void f(long j2) {
        if (F()) {
            e(this.f4738e0, j2);
            this.f4741g0 = false;
        }
    }

    void g() {
        try {
            connect();
        } catch (UnknownHostException e2) {
            throw new V("Failed to connect to server", e2);
        } catch (V e3) {
            throw e3;
        } catch (IOException e4) {
            throw new V("Failed to connect to server", e4);
        }
    }

    @Override // java.net.URLConnection
    public int getContentLength() {
        try {
            return (int) (I() & 4294967295L);
        } catch (V unused) {
            return 0;
        }
    }

    @Override // java.net.URLConnection
    public long getDate() {
        try {
            return H();
        } catch (V unused) {
            return 0L;
        }
    }

    @Override // java.net.URLConnection
    public InputStream getInputStream() {
        return new Y(this);
    }

    @Override // java.net.URLConnection
    public long getLastModified() {
        try {
            return H();
        } catch (V unused) {
            return 0L;
        }
    }

    @Override // java.net.URLConnection
    public OutputStream getOutputStream() {
        return new Z(this);
    }

    void h() throws C0602t {
        e0 e0VarS;
        C0454b c0454bQ = q();
        f0 f0Var = this.f4736c0;
        if (f0Var != null) {
            e0VarS = f0Var.f4870f.f4790h;
        } else {
            e0VarS = e0.s(c0454bQ, ((URLConnection) this).url.getPort());
            this.f4736c0 = e0VarS.r(this.f4735b0).a(this.f4740g, null);
        }
        String strX = x();
        f0 f0Var2 = this.f4736c0;
        f0Var2.f4872h = f4726p0.f(strX, f0Var2.f4867c, null, this.f4735b0) != null;
        f0 f0Var3 = this.f4736c0;
        if (f0Var3.f4872h) {
            f0Var3.f4865a = 2;
        }
        try {
            if (C0622e.f5384g >= 3) {
                f4723m0.println("doConnect: " + c0454bQ);
            }
            this.f4736c0.c(null, null);
        } catch (C0602t e2) {
            if (this.f4740g == null) {
                f0 f0VarA = e0VarS.r(C0599q.f4987f0).a(null, null);
                this.f4736c0 = f0VarA;
                f0VarA.c(null, null);
                return;
            }
            C0599q c0599qA = AbstractC0597o.a(((URLConnection) this).url.toString(), e2);
            if (c0599qA == null) {
                if (C0622e.f5384g >= 1 && A()) {
                    e2.printStackTrace(f4723m0);
                }
                throw e2;
            }
            this.f4735b0 = c0599qA;
            f0 f0VarA2 = e0VarS.r(c0599qA).a(this.f4740g, null);
            this.f4736c0 = f0VarA2;
            f0VarA2.f4872h = f4726p0.f(strX, f0VarA2.f4867c, null, this.f4735b0) != null;
            f0 f0Var4 = this.f4736c0;
            if (f0Var4.f4872h) {
                f0Var4.f4865a = 2;
            }
            f0Var4.c(null, null);
        }
    }

    public int hashCode() {
        int iHashCode;
        try {
            iHashCode = q().hashCode();
        } catch (UnknownHostException unused) {
            iHashCode = w().toUpperCase().hashCode();
        }
        z();
        return iHashCode + this.f4734b.toUpperCase().hashCode();
    }

    InterfaceC0589g[] i() {
        AbstractC0469f abstractC0469fE = AbstractC0469f.e("ncacn_np:" + q().f() + "[\\PIPE\\netdfs]", this.f4735b0);
        try {
            C0493a c0493a = new C0493a(w());
            abstractC0469fE.g(c0493a);
            if (c0493a.f4095h == 0) {
                return c0493a.j();
            }
            throw new V(c0493a.f4095h, true);
        } finally {
            try {
                abstractC0469fE.b();
            } catch (IOException e2) {
                if (C0622e.f5384g >= 4) {
                    e2.printStackTrace(f4723m0);
                }
            }
        }
    }

    void j(ArrayList arrayList, boolean z2, String str, int i2, a0 a0Var, X x2) throws V {
        try {
            if (((URLConnection) this).url.getHost().length() != 0 && y() != 2) {
                if (this.f4740g == null) {
                    o(arrayList, z2, str, i2, a0Var, x2);
                    return;
                } else {
                    k(arrayList, z2, str, i2, a0Var, x2);
                    return;
                }
            }
            m(arrayList, z2, str, i2, a0Var, x2);
        } catch (MalformedURLException e2) {
            throw new V(((URLConnection) this).url.toString(), e2);
        } catch (UnknownHostException e3) {
            throw new V(((URLConnection) this).url.toString(), e3);
        }
    }

    void k(ArrayList arrayList, boolean z2, String str, int i2, a0 a0Var, X x2) throws V {
        int i3;
        i0 i0Var;
        int i4;
        int i5;
        int i6;
        int iHashCode;
        a0 a0Var2 = a0Var;
        String strZ = z();
        if (((URLConnection) this).url.getPath().lastIndexOf(47) != r2.length() - 1) {
            throw new V(((URLConnection) this).url.toString() + " directory must end with '/'");
        }
        AbstractC0600r g0Var = new g0(strZ, str, i2);
        h0 h0Var = new h0();
        int i7 = 3;
        if (C0622e.f5384g >= 3) {
            f4723m0.println("doFindFirstNext: " + g0Var.f5018l0);
        }
        T(g0Var, h0Var);
        int i8 = h0Var.f4882M0;
        i0 i0Var2 = new i0(i8, h0Var.f4888S0, h0Var.f4887R0);
        h0Var.f4641F0 = (byte) 2;
        while (true) {
            int i9 = 0;
            while (true) {
                i3 = h0Var.f4646K0;
                if (i9 >= i3) {
                    break;
                }
                InterfaceC0589g interfaceC0589g = h0Var.f4647L0[i9];
                String name = interfaceC0589g.getName();
                if ((name.length() >= i7 || !(((iHashCode = name.hashCode()) == f4721k0 || iHashCode == f4722l0) && (name.equals(".") || name.equals("..")))) && ((a0Var2 == null || a0Var2.a(this, name)) && name.length() > 0)) {
                    i0Var = i0Var2;
                    i4 = i9;
                    i5 = i7;
                    i6 = i8;
                    W w2 = new W(this, name, 1, interfaceC0589g.a(), interfaceC0589g.b(), interfaceC0589g.c(), interfaceC0589g.length());
                    if (x2 == null || x2.a(w2)) {
                        if (z2) {
                            arrayList.add(w2);
                        } else {
                            arrayList.add(name);
                        }
                    }
                } else {
                    i0Var = i0Var2;
                    i4 = i9;
                    i5 = i7;
                    i6 = i8;
                }
                i9 = i4 + 1;
                i8 = i6;
                i7 = i5;
                i0Var2 = i0Var;
                a0Var2 = a0Var;
            }
            i0 i0Var3 = i0Var2;
            int i10 = i7;
            int i11 = i8;
            if (h0Var.f4883N0 || i3 == 0) {
                try {
                    T(new C0605w(i11), a());
                    return;
                } catch (V e2) {
                    if (C0622e.f5384g >= 4) {
                        e2.printStackTrace(f4723m0);
                        return;
                    }
                    return;
                }
            }
            i0Var3.E(h0Var.f4888S0, h0Var.f4887R0);
            h0Var.t();
            T(i0Var3, h0Var);
            i0Var2 = i0Var3;
            i8 = i11;
            i7 = i10;
            a0Var2 = a0Var;
        }
    }

    InterfaceC0589g[] l() {
        C0494b c0494b = new C0494b(((URLConnection) this).url.getHost());
        AbstractC0469f abstractC0469fE = AbstractC0469f.e("ncacn_np:" + q().f() + "[\\PIPE\\srvsvc]", this.f4735b0);
        try {
            abstractC0469fE.g(c0494b);
            if (c0494b.f4101h == 0) {
                return c0494b.j();
            }
            throw new V(c0494b.f4101h, true);
        } finally {
            try {
                abstractC0469fE.b();
            } catch (IOException e2) {
                if (C0622e.f5384g >= 4) {
                    e2.printStackTrace(f4723m0);
                }
            }
        }
    }

    void m(ArrayList arrayList, boolean z2, String str, int i2, a0 a0Var, X x2) throws V {
        C0592j c0592j;
        C0593k c0593k;
        int i3;
        C0593k c0593k2;
        int i4;
        int i5;
        C0592j c0592j2;
        W w2 = this;
        a0 a0Var2 = a0Var;
        int iY = ((URLConnection) w2).url.getHost().length() == 0 ? 0 : y();
        int i6 = 2;
        if (iY == 0) {
            g();
            c0592j = new C0592j(w2.f4736c0.f4870f.f4790h.f4835k0.f4848e, Integer.MIN_VALUE);
            c0593k = new C0593k();
        } else {
            if (iY != 2) {
                throw new V("The requested list operations is invalid: " + ((URLConnection) this).url.toString());
            }
            c0592j = new C0592j(((URLConnection) w2).url.getHost(), -1);
            c0593k = new C0593k();
        }
        C0592j c0592j3 = c0592j;
        C0593k c0593k3 = c0593k;
        while (true) {
            w2.T(c0592j3, c0593k3);
            int i7 = c0593k3.f4645J0;
            if (i7 != 0 && i7 != 234) {
                throw new V(c0593k3.f4645J0, true);
            }
            boolean z3 = i7 == 234;
            int i8 = c0593k3.f4646K0;
            if (z3) {
                i8--;
            }
            int i9 = i8;
            int i10 = 0;
            while (i10 < i9) {
                InterfaceC0589g interfaceC0589g = c0593k3.f4647L0[i10];
                String name = interfaceC0589g.getName();
                if ((a0Var2 == null || a0Var2.a(w2, name)) && name.length() > 0) {
                    i3 = i10;
                    c0593k2 = c0593k3;
                    i4 = i9;
                    i5 = i6;
                    c0592j2 = c0592j3;
                    W w3 = new W(this, name, interfaceC0589g.getType(), 17, 0L, 0L, 0L);
                    if (x2 == null || x2.a(w3)) {
                        if (z2) {
                            arrayList.add(w3);
                        } else {
                            arrayList.add(name);
                        }
                    }
                } else {
                    i3 = i10;
                    c0593k2 = c0593k3;
                    i4 = i9;
                    i5 = i6;
                    c0592j2 = c0592j3;
                }
                i10 = i3 + 1;
                i6 = i5;
                c0592j3 = c0592j2;
                i9 = i4;
                c0593k3 = c0593k2;
                w2 = this;
                a0Var2 = a0Var;
            }
            C0593k c0593k4 = c0593k3;
            int i11 = i6;
            C0592j c0592j4 = c0592j3;
            if (y() != i11) {
                return;
            }
            c0592j4.f4622M0 = (byte) -41;
            c0592j4.E(0, c0593k4.f4916O0);
            c0593k4.t();
            if (!z3) {
                return;
            }
            c0593k3 = c0593k4;
            i6 = i11;
            c0592j3 = c0592j4;
            w2 = this;
            a0Var2 = a0Var;
        }
    }

    InterfaceC0589g[] n() throws V {
        AbstractC0600r c0594l = new C0594l();
        C0595m c0595m = new C0595m();
        T(c0594l, c0595m);
        if (c0595m.f4645J0 == 0) {
            return c0595m.f4647L0;
        }
        throw new V(c0595m.f4645J0, true);
    }

    void o(ArrayList arrayList, boolean z2, String str, int i2, a0 a0Var, X x2) throws UnknownHostException, V {
        Iterator it;
        InterfaceC0589g[] interfaceC0589gArrN;
        a0 a0Var2 = a0Var;
        if (((URLConnection) this).url.getPath().lastIndexOf(47) != r0.length() - 1) {
            throw new V(((URLConnection) this).url.toString() + " directory must end with '/'");
        }
        if (y() != 4) {
            throw new V("The requested list operations is invalid: " + ((URLConnection) this).url.toString());
        }
        HashMap map = new HashMap();
        if (f4726p0.e(w(), this.f4735b0)) {
            try {
                for (InterfaceC0589g interfaceC0589g : i()) {
                    if (!map.containsKey(interfaceC0589g)) {
                        map.put(interfaceC0589g, interfaceC0589g);
                    }
                }
            } catch (IOException e2) {
                if (C0622e.f5384g >= 4) {
                    e2.printStackTrace(f4723m0);
                }
            }
        }
        C0454b c0454bR = r();
        IOException iOException = null;
        loop0: while (c0454bR != null) {
            try {
                h();
                try {
                    interfaceC0589gArrN = l();
                } catch (IOException e3) {
                    if (C0622e.f5384g >= 3) {
                        e3.printStackTrace(f4723m0);
                    }
                    interfaceC0589gArrN = n();
                }
                for (InterfaceC0589g interfaceC0589g2 : interfaceC0589gArrN) {
                    if (!map.containsKey(interfaceC0589g2)) {
                        map.put(interfaceC0589g2, interfaceC0589g2);
                    }
                }
                break loop0;
            } catch (IOException e4) {
                iOException = e4;
                if (C0622e.f5384g >= 3) {
                    iOException.printStackTrace(f4723m0);
                }
                c0454bR = t();
            }
        }
        if (iOException != null && map.isEmpty()) {
            if (!(iOException instanceof V)) {
                throw new V(((URLConnection) this).url.toString(), iOException);
            }
            throw ((V) iOException);
        }
        Iterator it2 = map.keySet().iterator();
        while (it2.hasNext()) {
            InterfaceC0589g interfaceC0589g3 = (InterfaceC0589g) it2.next();
            String name = interfaceC0589g3.getName();
            if (a0Var2 == null || a0Var2.a(this, name)) {
                if (name.length() > 0) {
                    it = it2;
                    W w2 = new W(this, name, interfaceC0589g3.getType(), 17, 0L, 0L, 0L);
                    if (x2 == null || x2.a(w2)) {
                        if (z2) {
                            arrayList.add(w2);
                        } else {
                            arrayList.add(name);
                        }
                    }
                } else {
                    it = it2;
                }
                it2 = it;
                a0Var2 = a0Var;
            }
        }
    }

    public boolean p() throws V {
        if (this.f4727H > System.currentTimeMillis()) {
            return this.f4730M;
        }
        this.f4747y = 17;
        this.f4745r = 0L;
        this.f4746x = 0L;
        this.f4730M = false;
        try {
            if (((URLConnection) this).url.getHost().length() != 0) {
                if (this.f4740g == null) {
                    if (y() == 2) {
                        C0454b.e(((URLConnection) this).url.getHost(), true);
                    } else {
                        C0454b.d(((URLConnection) this).url.getHost()).g();
                    }
                } else if (z().length() == 1 || this.f4740g.equalsIgnoreCase("IPC$")) {
                    g();
                } else {
                    InterfaceC0591i interfaceC0591iR = R(z(), 257);
                    this.f4747y = interfaceC0591iR.a();
                    this.f4745r = interfaceC0591iR.c();
                    this.f4746x = interfaceC0591iR.d();
                }
            }
            this.f4730M = true;
        } catch (UnknownHostException unused) {
        } catch (V e2) {
            switch (e2.c()) {
                case OnRecvMsg.NT_STATUS_NO_SUCH_FILE /* -1073741809 */:
                case OnRecvMsg.NT_STATUS_OBJECT_NAME_INVALID /* -1073741773 */:
                case OnRecvMsg.NT_STATUS_OBJECT_NAME_NOT_FOUND /* -1073741772 */:
                case OnRecvMsg.NT_STATUS_OBJECT_PATH_NOT_FOUND /* -1073741766 */:
                    break;
                default:
                    throw e2;
            }
        }
        this.f4727H = System.currentTimeMillis() + f4724n0;
        return this.f4730M;
    }

    C0454b q() {
        int i2 = this.f4744j0;
        return i2 == 0 ? r() : this.f4743i0[i2 - 1];
    }

    C0454b r() throws UnknownHostException {
        this.f4744j0 = 0;
        String host = ((URLConnection) this).url.getHost();
        String path = ((URLConnection) this).url.getPath();
        String query = ((URLConnection) this).url.getQuery();
        if (query != null) {
            String strQ = Q(query, "server");
            if (strQ != null && strQ.length() > 0) {
                this.f4743i0 = new C0454b[]{C0454b.d(strQ)};
                return t();
            }
            String strQ2 = Q(query, "address");
            if (strQ2 != null && strQ2.length() > 0) {
                this.f4743i0 = new C0454b[]{new C0454b(InetAddress.getByAddress(host, InetAddress.getByName(strQ2).getAddress()))};
                return t();
            }
        }
        if (host.length() == 0) {
            try {
                this.f4743i0 = new C0454b[]{C0454b.d(i1.g.k("\u0001\u0002__MSBROWSE__\u0002", 1, null).n())};
            } catch (UnknownHostException e2) {
                C0599q.o();
                if (C0599q.f4983b0.equals("?")) {
                    throw e2;
                }
                this.f4743i0 = C0454b.c(C0599q.f4983b0, true);
            }
        } else if (path.length() == 0 || path.equals("/")) {
            this.f4743i0 = C0454b.c(host, true);
        } else {
            this.f4743i0 = C0454b.c(host, false);
        }
        return t();
    }

    public String s() {
        z();
        if (this.f4734b.length() > 1) {
            int length = this.f4734b.length() - 2;
            while (this.f4734b.charAt(length) != '/') {
                length--;
            }
            return this.f4734b.substring(length + 1);
        }
        if (this.f4740g != null) {
            return this.f4740g + '/';
        }
        if (((URLConnection) this).url.getHost().length() <= 0) {
            return "smb://";
        }
        return ((URLConnection) this).url.getHost() + '/';
    }

    C0454b t() {
        int i2 = this.f4744j0;
        C0454b[] c0454bArr = this.f4743i0;
        if (i2 >= c0454bArr.length) {
            return null;
        }
        this.f4744j0 = i2 + 1;
        return c0454bArr[i2];
    }

    @Override // java.net.URLConnection
    public String toString() {
        return ((URLConnection) this).url.toString();
    }

    public String u() {
        String authority = ((URLConnection) this).url.getAuthority();
        if (authority.length() <= 0) {
            return "smb://";
        }
        StringBuffer stringBuffer = new StringBuffer("smb://");
        stringBuffer.append(authority);
        z();
        if (this.f4734b.length() > 1) {
            stringBuffer.append(this.f4734b);
        } else {
            stringBuffer.append('/');
        }
        String string = stringBuffer.toString();
        int length = string.length() - 2;
        while (string.charAt(length) != '/') {
            length--;
        }
        return string.substring(0, length + 1);
    }

    public String v() {
        return ((URLConnection) this).url.toString();
    }

    public String w() {
        String host = ((URLConnection) this).url.getHost();
        if (host.length() == 0) {
            return null;
        }
        return host;
    }

    String x() {
        C0587e c0587e = this.f4733a0;
        return c0587e != null ? c0587e.f4816y : w();
    }

    public int y() {
        int iS;
        if (this.f4739f0 == 0) {
            if (z().length() > 1) {
                this.f4739f0 = 1;
            } else if (this.f4740g != null) {
                g();
                if (this.f4740g.equals("IPC$")) {
                    this.f4739f0 = 16;
                } else if (this.f4736c0.f4868d.equals("LPT1:")) {
                    this.f4739f0 = 32;
                } else if (this.f4736c0.f4868d.equals("COMM")) {
                    this.f4739f0 = 64;
                } else {
                    this.f4739f0 = 8;
                }
            } else if (((URLConnection) this).url.getAuthority() == null || ((URLConnection) this).url.getAuthority().length() == 0) {
                this.f4739f0 = 2;
            } else {
                try {
                    C0454b c0454bQ = q();
                    if ((c0454bQ.b() instanceof i1.g) && ((iS = ((i1.g) c0454bQ.b()).s()) == 29 || iS == 27)) {
                        this.f4739f0 = 2;
                        return 2;
                    }
                    this.f4739f0 = 4;
                } catch (UnknownHostException e2) {
                    throw new V(((URLConnection) this).url.toString(), e2);
                }
            }
        }
        return this.f4739f0;
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x0062  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    java.lang.String z() {
        /*
            r14 = this;
            java.lang.String r0 = r14.f4737d0
            if (r0 != 0) goto Lc3
            java.net.URL r0 = r14.url
            java.lang.String r0 = r0.getPath()
            char[] r0 = r0.toCharArray()
            int r1 = r0.length
            char[] r1 = new char[r1]
            int r2 = r0.length
            r3 = 0
            r4 = r3
            r5 = r4
            r6 = r5
        L16:
            r7 = 0
            r8 = 47
            r9 = 1
            if (r4 >= r2) goto L76
            if (r6 == 0) goto L69
            r7 = 2
            if (r6 == r9) goto L25
            if (r6 == r7) goto L5e
            goto L74
        L25:
            char r10 = r0[r4]
            if (r10 != r8) goto L2a
            goto L74
        L2a:
            r11 = 46
            if (r10 != r11) goto L38
            int r12 = r4 + 1
            if (r12 >= r2) goto L36
            char r13 = r0[r12]
            if (r13 != r8) goto L38
        L36:
            r4 = r12
            goto L74
        L38:
            int r12 = r4 + 1
            if (r12 >= r2) goto L5d
            if (r10 != r11) goto L5d
            char r10 = r0[r12]
            if (r10 != r11) goto L5d
            int r10 = r4 + 2
            if (r10 >= r2) goto L4a
            char r11 = r0[r10]
            if (r11 != r8) goto L5d
        L4a:
            if (r5 != r9) goto L4e
        L4c:
            r4 = r10
            goto L74
        L4e:
            int r4 = r5 + (-1)
            if (r4 <= r9) goto L5b
            int r5 = r5 + (-2)
            char r5 = r1[r5]
            if (r5 != r8) goto L59
            goto L5b
        L59:
            r5 = r4
            goto L4e
        L5b:
            r5 = r4
            goto L4c
        L5d:
            r6 = r7
        L5e:
            char r7 = r0[r4]
            if (r7 != r8) goto L63
            r6 = r9
        L63:
            int r8 = r5 + 1
            r1[r5] = r7
            r5 = r8
            goto L74
        L69:
            char r6 = r0[r4]
            if (r6 == r8) goto L6e
            return r7
        L6e:
            int r7 = r5 + 1
            r1[r5] = r6
            r5 = r7
            r6 = r9
        L74:
            int r4 = r4 + r9
            goto L16
        L76:
            java.lang.String r0 = new java.lang.String
            r0.<init>(r1, r3, r5)
            r14.f4734b = r0
            java.lang.String r2 = "\\"
            if (r5 <= r9) goto Lbf
            int r3 = r5 + (-1)
            int r0 = r0.indexOf(r8, r9)
            if (r0 >= 0) goto L94
            java.lang.String r0 = r14.f4734b
            java.lang.String r0 = r0.substring(r9)
            r14.f4740g = r0
            r14.f4737d0 = r2
            goto Lc3
        L94:
            if (r0 != r3) goto La1
            java.lang.String r1 = r14.f4734b
            java.lang.String r0 = r1.substring(r9, r0)
            r14.f4740g = r0
            r14.f4737d0 = r2
            goto Lc3
        La1:
            java.lang.String r2 = r14.f4734b
            java.lang.String r2 = r2.substring(r9, r0)
            r14.f4740g = r2
            java.lang.String r2 = r14.f4734b
            char r1 = r1[r3]
            if (r1 != r8) goto Lb0
            r5 = r3
        Lb0:
            java.lang.String r0 = r2.substring(r0, r5)
            r14.f4737d0 = r0
            r1 = 92
            java.lang.String r0 = r0.replace(r8, r1)
            r14.f4737d0 = r0
            goto Lc3
        Lbf:
            r14.f4740g = r7
            r14.f4737d0 = r2
        Lc3:
            java.lang.String r0 = r14.f4737d0
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: k1.W.z():java.lang.String");
    }

    public W(String str, C0599q c0599q) {
        this(new URL((URL) null, str, C0590h.f4881a), c0599q);
    }

    public W(URL url) {
        this(url, new C0599q(url.getUserInfo()));
    }

    public W(URL url, C0599q c0599q) {
        super(url);
        this.f4731Q = 7;
        this.f4732Z = null;
        this.f4733a0 = null;
        this.f4736c0 = null;
        this.f4735b0 = c0599q == null ? new C0599q(url.getUserInfo()) : c0599q;
        z();
    }

    W(W w2, String str, int i2, int i3, long j2, long j3, long j4) {
        URL url;
        if (w2.G()) {
            url = new URL((URL) null, "smb://" + str + "/", C0590h.f4881a);
        } else {
            URL url2 = ((URLConnection) w2).url;
            StringBuilder sb = new StringBuilder();
            sb.append(str);
            sb.append((i3 & 16) <= 0 ? HttpUrl.FRAGMENT_ENCODE_SET : "/");
            url = new URL(url2, sb.toString());
        }
        this(url);
        this.f4735b0 = w2.f4735b0;
        if (w2.f4740g != null) {
            this.f4736c0 = w2.f4736c0;
            this.f4733a0 = w2.f4733a0;
        }
        int length = str.length() - 1;
        str = str.charAt(length) == '/' ? str.substring(0, length) : str;
        if (w2.f4740g == null) {
            this.f4737d0 = "\\";
        } else if (w2.f4737d0.equals("\\")) {
            this.f4737d0 = '\\' + str;
        } else {
            this.f4737d0 = w2.f4737d0 + '\\' + str;
        }
        this.f4739f0 = i2;
        this.f4747y = i3;
        this.f4745r = j2;
        this.f4746x = j3;
        this.f4728I = j4;
        this.f4730M = true;
        long jCurrentTimeMillis = System.currentTimeMillis() + f4724n0;
        this.f4729L = jCurrentTimeMillis;
        this.f4727H = jCurrentTimeMillis;
    }
}
