package androidx.browser.trusted;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import androidx.browser.customtabs.q;
import androidx.browser.customtabs.z;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class i {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Uri f905a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final q f906b = new q();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public g f907c = new com.google.android.material.shape.f();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f908d = 0;

    @Nullable
    private List<String> mAdditionalTrustedOrigins;

    @Nullable
    private q.a mShareData;

    @Nullable
    private q.d mShareTarget;

    @Nullable
    private Bundle mSplashScreenParams;

    public i(Uri uri) {
        this.f905a = uri;
    }

    public final h a(z zVar) {
        if (zVar == null) {
            throw new NullPointerException("CustomTabsSession is required for launching a TWA");
        }
        q qVar = this.f906b;
        qVar.d(zVar);
        Intent intent = qVar.b().f884a;
        intent.setData(this.f905a);
        intent.putExtra("android.support.customtabs.extra.LAUNCH_AS_TRUSTED_WEB_ACTIVITY", true);
        if (this.mAdditionalTrustedOrigins != null) {
            intent.putExtra("android.support.customtabs.extra.ADDITIONAL_TRUSTED_ORIGINS", new ArrayList(this.mAdditionalTrustedOrigins));
        }
        Bundle bundle = this.mSplashScreenParams;
        if (bundle != null) {
            intent.putExtra("androidx.browser.trusted.EXTRA_SPLASH_SCREEN_PARAMS", bundle);
        }
        List<Uri> listEmptyList = Collections.emptyList();
        q.d dVar = this.mShareTarget;
        if (dVar != null && this.mShareData != null) {
            Bundle bundle2 = new Bundle();
            bundle2.putString("androidx.browser.trusted.sharing.KEY_ACTION", dVar.f32054a);
            bundle2.putString("androidx.browser.trusted.sharing.KEY_METHOD", dVar.method);
            bundle2.putString("androidx.browser.trusted.sharing.KEY_ENCTYPE", dVar.encodingType);
            q.c cVar = dVar.f32055b;
            cVar.getClass();
            Bundle bundle3 = new Bundle();
            bundle3.putString("androidx.browser.trusted.sharing.KEY_TITLE", cVar.title);
            bundle3.putString("androidx.browser.trusted.sharing.KEY_TEXT", cVar.text);
            if (cVar.files != null) {
                ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
                for (q.b bVar : cVar.files) {
                    bVar.getClass();
                    Bundle bundle4 = new Bundle();
                    bundle4.putString("androidx.browser.trusted.sharing.KEY_FILE_NAME", bVar.f32052a);
                    bundle4.putStringArrayList("androidx.browser.trusted.sharing.KEY_ACCEPTED_TYPES", new ArrayList<>(bVar.f32053b));
                    arrayList.add(bundle4);
                }
                bundle3.putParcelableArrayList("androidx.browser.trusted.sharing.KEY_FILES", arrayList);
            }
            bundle2.putBundle("androidx.browser.trusted.sharing.KEY_PARAMS", bundle3);
            intent.putExtra("androidx.browser.trusted.extra.SHARE_TARGET", bundle2);
            q.a aVar = this.mShareData;
            aVar.getClass();
            Bundle bundle5 = new Bundle();
            bundle5.putString("androidx.browser.trusted.sharing.KEY_TITLE", aVar.title);
            bundle5.putString("androidx.browser.trusted.sharing.KEY_TEXT", aVar.text);
            if (aVar.uris != null) {
                bundle5.putParcelableArrayList("androidx.browser.trusted.sharing.KEY_URIS", new ArrayList<>(aVar.uris));
            }
            intent.putExtra("androidx.browser.trusted.extra.SHARE_DATA", bundle5);
            List<Uri> list = this.mShareData.uris;
            if (list != null) {
                listEmptyList = list;
            }
        }
        intent.putExtra("androidx.browser.trusted.extra.DISPLAY_MODE", this.f907c.c());
        intent.putExtra("androidx.browser.trusted.extra.SCREEN_ORIENTATION", this.f908d);
        return new h(intent, listEmptyList);
    }

    public final void b(List list) {
        this.mAdditionalTrustedOrigins = list;
    }
}
