import React, { useState, useCallback, useMemo, useRef, forwardRef, useImperativeHandle, } from 'react'; import type {ElementRef} from 'react'; import {View, StyleSheet, Image, Platform, processColor} from 'react-native'; import type { StyleProp, ImageStyle, NativeSyntheticEvent, ViewStyle, ImageResizeMode, } from 'react-native'; import NativeVideoComponent, { NativeCmcdConfiguration, } from './specs/VideoNativeComponent'; import type { OnAudioFocusChangedData, OnAudioTracksData, OnBandwidthUpdateData, OnBufferData, OnControlsVisibilityChange, OnExternalPlaybackChangeData, OnGetLicenseData, OnLoadStartData, OnPictureInPictureStatusChangedData, OnPlaybackStateChangedData, OnProgressData, OnSeekData, OnTextTrackDataChangedData, OnTimedMetadataData, OnVideoAspectRatioData, OnVideoErrorData, OnVideoTracksData, VideoSrc, } from './specs/VideoNativeComponent'; import { generateHeaderForNative, getReactTag, resolveAssetSourceForVideo, } from './utils'; import NativeVideoManager from './specs/NativeVideoManager'; import {ViewType, CmcdMode, VideoRef} from './types'; import type { OnLoadData, OnTextTracksData, OnReceiveAdEventData, ReactVideoProps, CmcdData, ReactVideoSource, AdConfig, AdConfigDAIVod, AdConfigDAILive, } from './types'; import type {ISO639_1} from './types/language'; import type {AdsConfig} from './specs/VideoNativeComponent'; function normalizeAdConfig( ad: AdConfig | undefined, legacyAdTagUrl: string | undefined, legacyAdLanguage: ISO639_1 | undefined, ): AdsConfig | undefined { if (ad) { // Default to 'csai' for backward compatibility with old API (ad without type) const adType = 'type' in ad ? ad.type : 'csai'; if (adType === 'ssai') { const daiAd = ad as AdConfigDAIVod | AdConfigDAILive; return { type: 'ssai', streamType: daiAd.streamType, adLanguage: daiAd.adLanguage, contentSourceId: 'contentSourceId' in daiAd ? daiAd.contentSourceId : undefined, videoId: 'videoId' in daiAd ? daiAd.videoId : undefined, assetKey: 'assetKey' in daiAd ? daiAd.assetKey : undefined, format: daiAd.format, adTagParameters: daiAd.adTagParameters, fallbackUri: daiAd.fallbackUri, }; } // CSAI (explicit or default for backward compatibility) return { type: 'csai', adTagUrl: 'adTagUrl' in ad ? ad.adTagUrl : undefined, adLanguage: ad.adLanguage, }; } // Legacy props at