package com.google.android.datatransport.cct;

import ii.g;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;

/* loaded from: classes.dex */
public final class a implements g {

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

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

    /* renamed from: e, reason: collision with root package name */
    private static final String f12671e;

    /* renamed from: f, reason: collision with root package name */
    private static final Set f12672f;

    /* renamed from: g, reason: collision with root package name */
    public static final a f12673g;

    /* renamed from: h, reason: collision with root package name */
    public static final a f12674h;

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

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

    static {
        String a10 = e.a("hts/frbslgiggolai.o/0clgbthfra=snpoo", "tp:/ieaeogn.ogepscmvc/o/ac?omtjo_rt3");
        f12669c = a10;
        String a11 = e.a("hts/frbslgigp.ogepscmv/ieo/eaybtho", "tp:/ieaeogn-agolai.o/1frlglgc/aclg");
        f12670d = a11;
        String a12 = e.a("AzSCki82AwsLzKd5O8zo", "IayckHiZRO1EFl1aGoK");
        f12671e = a12;
        f12672f = Collections.unmodifiableSet(new HashSet(Arrays.asList(gi.c.b("proto"), gi.c.b("json"))));
        f12673g = new a(a10, null);
        f12674h = new a(a11, a12);
    }

    public a(String str, String str2) {
        this.f12675a = str;
        this.f12676b = str2;
    }

    public static a c(byte[] bArr) {
        String str = new String(bArr, Charset.forName("UTF-8"));
        if (!str.startsWith("1$")) {
            throw new IllegalArgumentException("Version marker missing from extras");
        }
        String[] split = str.substring(2).split(Pattern.quote("\\"), 2);
        if (split.length != 2) {
            throw new IllegalArgumentException("Extra is not a valid encoded LegacyFlgDestination");
        }
        String str2 = split[0];
        if (str2.isEmpty()) {
            throw new IllegalArgumentException("Missing endpoint in CCTDestination extras");
        }
        String str3 = split[1];
        if (str3.isEmpty()) {
            str3 = null;
        }
        return new a(str2, str3);
    }

    @Override // ii.g
    public Set a() {
        return f12672f;
    }

    public byte[] b() {
        String str = this.f12676b;
        if (str == null && this.f12675a == null) {
            return null;
        }
        Object[] objArr = new Object[4];
        objArr[0] = "1$";
        objArr[1] = this.f12675a;
        objArr[2] = "\\";
        if (str == null) {
            str = "";
        }
        objArr[3] = str;
        return String.format("%s%s%s%s", objArr).getBytes(Charset.forName("UTF-8"));
    }

    public String d() {
        return this.f12676b;
    }

    public String e() {
        return this.f12675a;
    }

    @Override // ii.f
    public byte[] getExtras() {
        return b();
    }

    @Override // ii.f
    public String getName() {
        return "cct";
    }
}
