import { ClipAd } from '../../ads/models/clipAd'; import ClipsPlayerService, { NavigationEventProps } from './clipsPlayerService'; import { ClipWithLiveStreamUrl, ClipWithIndexInCategory, ClipWithIndexInCollection } from '../types/clipPlayerTypes'; export declare const ANIMATION_DURATION = 300; export type Slide = ClipWithIndexInCategory | ClipAd; export type AppendedSlide = Slide & { appendedSlideIndex: number; }; declare class ClipsNavService extends ClipsPlayerService { protected logTag: string; private activeAppendedSlideIndex_; /** The index of the currently active slide, relative to all of the slides (including ads). */ private activeSlideIndex_; private activeClip_; /** All slides (including ads). */ private allSlides_; private appendedSlides_; /** Whether at least one ad was shown to the user */ private hasUserSeenAnAd_; private isActiveCategory_; private collection_; private slidesUntilNextAdWhenMovingBackwards_; private slidesUntilNextAdWhenMovingForwards_; constructor(collection: string); /** The index of the currently visible slide (same as data-swiper-slide-index). */ get activeAppendedSlideIndex(): number; /** The currently active clip (or the last active clip if the current slide is an ad). */ get activeClip(): ClipWithIndexInCollection | null; /** The collection index of the currently active clip. */ get activeClipIndexInCollection(): number | null; /** * All appended Swiper slides (including ads). Maximum of 5. * Note: appended slide indices aren't always in ascending order (eg [4, 5, 0, 1, 2, 3]). */ get appendedSlides(): Slide[]; /** The real indices of the clips that should be loaded or preloaded. */ get clipIndicesToLoadOrPreload(): number[]; /** Whether ads should and can be shown. */ get shouldShowAds(): boolean; /** Removes any created ads and resets the appended slides. */ closePlayer(): void; /** Get a clip or ad slide by its appended slide index. */ getAppendedSlideByIndex(appendedSlideIndex: number): Slide; get isActiveCategory(): boolean; set isActiveCategory(isActiveCategory: boolean); /** Checks if a clip or clip ad is the current active slide. */ isActiveSlide(slide: Slide): boolean; /** Records a new navigation event and updates the appended slides if needed. */ recordNavigationEvent(navigationEventProps: NavigationEventProps): void; /** Records a new navigation event when the user comes back from a category view. */ reopenClipPlayer(): void; /** Updates the appended slides so that the active slide is the specified clip */ goToClip(clipId: string, newClips: ClipWithIndexInCollection[]): void; /** Updates the clips in a collection, and sets the appended slides. */ setCollectionClips(clips: ClipWithIndexInCollection[], initialClipId?: string): void; /** Records whether the user has seen an ad. */ setHasUserSeenAnAd(hasUserSeenAnAd: boolean): void; /** Updates the current collection name. */ updateCollection(collection: string): void; /** The currently active clip or ad. */ private get activeSlide_(); /** The number of clips before the first ad. Returns null if the ad frequency should be used. */ private get adInitialIndex_(); /** The number of clips in between each ad. Returns 0 if there are no ads. */ private get adFrequency_(); /** All clips in the current collection. */ private get collectionClips_(); /** The ads and clips that should be loaded or preloaded. */ private get slidesToLoadOrPreload_(); /** * Whether we should reuse and replace appended slides. If there are less than the maximum, * we can just append all slides as they are; as it won't impact the speed of the user experience. * However if there are any ads, we need to replace the slides as the ad loading states might * impact how many slides are appended. */ private get shouldReplaceAppendedSlides_(); /** The distance (in slides) between the current slide and the next ad when navigating forwards. */ private get slideBeforeNextAdOffset_(); /** The distance (in slides) between the current slide and the next ad when navigating backwards. */ private get slideBeforePreviousAdOffset_(); private checkHiddenSlides_; /** Creates a new ad page after the specified clip, and adds it to the slides array. */ private createAdPage_; /** * Checks if the next ad is loaded and replaces the slide if not. */ private replaceAdIfTimedOut_; /** Gets the index of a slide relative to another. */ private getAdjacentSlideIndex_; /** Gets a slide based on its distance to another. */ private getAdjacentSlide_; /** Gets the indices of the next and previous appended slides (both visible on desktop). */ private getAdjacentAppendedSlidesIndices_; /** Gets the indices of the initial slides to append. */ private getAppendedSlideIndices_; /** Creates the initial ad pages. */ private handleInitialNavigation_; /** Replaces the appended slides after a navigation event. */ private handleNavigation_; /** * If the user moves the slider without changing the slide, swiper.js still sends a navigation event. * We should ignore these since the correct slides are already in place. */ private isRepeatNavigationEvent_; /** * Removes an ad from the slides array. */ private removeAd_; /** * Replaces the next or previous hidden appended slide based on the navigation direction. * Also checks if any ads should be removed (as they might have been inserted on a previous loop * and might now be in the wrong position). */ private replaceAdjacentHiddenSlide_; /** Replaces an appended slide with an other. */ private replaceAppendedSlide_; /** Sets the initial appended slides when opening the player. */ private setAppendedSlides_; /** * Whether an ad should have been visible on this slide. * */ private shouldActiveSlideHaveAnAd_; } /** Whether the provided slide is an ad. */ export declare function isAd(slide: Slide | ClipWithLiveStreamUrl): slide is ClipAd; export default ClipsNavService;