package com.revenuecat.purchases.ui.revenuecatui.components.video;

import android.content.Context;
import android.net.Uri;
import androidx.compose.runtime.MutableState;
import com.revenuecat.purchases.ui.revenuecatui.components.video.TextureVideoView;
import java.io.IOException;
import java.util.Map;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;

/* JADX INFO: loaded from: classes3.dex */
public final class VideoViewKt$Video$3$1$1 extends p implements J4.c {
    final /* synthetic */ boolean $autoPlay;
    final /* synthetic */ String $key;
    final /* synthetic */ boolean $loop;
    final /* synthetic */ boolean $muteAudio;
    final /* synthetic */ J4.a $onReady;
    final /* synthetic */ Map<String, VideoPlaybackState> $savedState;
    final /* synthetic */ TextureVideoView.ScaleType $scaleType;
    final /* synthetic */ boolean $showControls;
    final /* synthetic */ String $videoUri;
    final /* synthetic */ MutableState<TextureVideoView> $videoView;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public VideoViewKt$Video$3$1$1(Map<String, VideoPlaybackState> map, String str, boolean z6, String str2, boolean z7, boolean z8, MutableState<TextureVideoView> mutableState, TextureVideoView.ScaleType scaleType, boolean z9, J4.a aVar) {
        super(1);
        this.$savedState = map;
        this.$key = str;
        this.$autoPlay = z6;
        this.$videoUri = str2;
        this.$showControls = z7;
        this.$muteAudio = z8;
        this.$videoView = mutableState;
        this.$scaleType = scaleType;
        this.$loop = z9;
        this.$onReady = aVar;
    }

    @Override // J4.c
    public final TextureVideoView invoke(Context ctx) throws IOException {
        o.h(ctx, "ctx");
        VideoPlaybackState videoPlaybackState = this.$savedState.get(this.$key);
        if (videoPlaybackState == null) {
            videoPlaybackState = new VideoPlaybackState(0, this.$autoPlay);
        }
        int iMax = Math.max(videoPlaybackState.getPositionMs(), videoPlaybackState.getPositionMs());
        boolean playWhenReady = iMax > 0 ? videoPlaybackState.getPlayWhenReady() : this.$autoPlay;
        Uri uri = Uri.parse(this.$videoUri);
        TextureVideoView textureVideoView = new TextureVideoView(ctx, null, this.$showControls, this.$muteAudio, 2, null);
        MutableState<TextureVideoView> mutableState = this.$videoView;
        TextureVideoView.ScaleType scaleType = this.$scaleType;
        boolean z6 = this.$loop;
        J4.a aVar = this.$onReady;
        mutableState.setValue(textureVideoView);
        textureVideoView.setScaleType(scaleType);
        textureVideoView.setLooping(z6);
        textureVideoView.setAutoStart(playWhenReady);
        textureVideoView.setOnReadyCallback(aVar);
        textureVideoView.setVideoURI(uri);
        if (iMax > 0) {
            textureVideoView.setPlaybackState(new TextureVideoView.PlaybackState(iMax, playWhenReady));
        }
        return textureVideoView;
    }
}
